Raised This Month: $51 Target: $400
 12% 

Knife Distance by SchlumPF


Post New Thread Reply   
 
Thread Tools Display Modes
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-14-2009 , 14:20   Re: Knife Distance 0.2 by SchlumPF
Reply With Quote #31

updated to 0.2, check the mainpost

i decided to show the ifnromation gathered by the plugin like ljstats does. this means ill add something like colorchat and i think ill change the hardcoded values to cvars.
what about a top15? #1 = player with most frags or most damage done or even best k/d ratio?

by using tracelines i would have detected knifehits by this:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#pragma semicolon 1

#define isPlayer(%1) (1 <= %1 <= g_iMaxPlayers)

#define TRACE_OFFSET 4

#define COLOR_RED 0
#define COLOR_GREEN 250
#define COLOR_BLUE 150
#define COORDS_X -0.75
#define COORDS_Y -1.0
#define HOLDTIME 1.5

enum AttackType
{
    
STAB 0,
    
SLASH
}

enum TraceType
{
    
TRACELINE 0,
    
TRACEHULL
}

new 
g_szTraceType[TraceType][] =
{
    
"TraceLine",
    
"TraceHull"
};

new 
g_szHitgroup[8][] =
{
    
"Full Body",
    
"Head",
    
"Chest",
    
"Stomach",
    
"Left Arm",
    
"Right Arm",
    
"Left Leg",
    
"Right Leg"
};

new 
g_iTraceHandle[33][AttackType];

new 
g_szBuffer[512];

new 
g_bAlive[33];
new 
g_szNickname[33][32];

new 
g_iMaxPlayers;

public 
plugin_init( )
{
    
register_plugin"Knife Distance""TEST""SchlumPF" );
    
    
register_forwardFM_TraceLine"fwdTraceLine_Post");
    
register_forwardFM_TraceHull"fwdTraceHull_Post");

    
RegisterHamHam_TakeDamage"player""hamTakeDamagePlayer_Post");
    
    
RegisterHamHam_Killed"player""hamKilledPlayer_Post");
    
RegisterHamHam_Spawn"player""hamSpawnPlayer_Post");
    
    
g_iMaxPlayers get_maxplayers( );
}

// i couldn't retrieve the received damage in the trace-hooks :X
public hamTakeDamagePlayer_PostplrinflictorattackerFloat:damagedamage_bits )
{
    if( 
get_user_weaponattacker ) == CSW_KNIFE )
    {
        static 
len;
        
len strleng_szBuffer );
        
        
formatexg_szBuffer[len], 511 len"^nDamage: %.f"damage );
        
        
set_hudmessageCOLOR_REDCOLOR_GREENCOLOR_BLUECOORDS_XCOORDS_Y00.0HOLDTIME0.00.0);
        
show_hudmessageattackerg_szBuffer );
    }
}

public 
client_connectplr )
{
    
get_user_nameplrg_szNickname[plr], 31 );
}

public 
client_infochangedplr )
{
    static 
curName[32], newName[32];
    
get_user_nameplrcurName31 );
    
get_user_infoplr"name"newName31 );
    
    if( !
equalnewNamecurName ) )
    {
        
copyg_szNickname[plr], 31newName );
    }
}

public 
hamKilledPlayer_Postplr )
{
    
g_bAlive[plr] = false;
}

public 
hamSpawnPlayer_Postplr )
{
    if( 
is_user_aliveplr ) && get_user_teamplr ) )
    {
        
g_bAlive[plr] = true;
    }
}

public 
fwdTraceLine_PostFloat:vecSrc[3], Float:vecEnd[3], conditionenttr )
{
    if( 
isPlayerent ) && g_bAlive[ent] )
    {
        if( !
g_iTraceHandle[ent][STAB] && condition == DONT_IGNORE_MONSTERS )
        {
            static 
distance;
            
distance floatroundget_distance_fvecSrcvecEnd ) );
            
            if( 
distance == 48.0 )
            {
                
g_iTraceHandle[ent][STAB] = tr TRACE_OFFSET;
                
g_iTraceHandle[ent][SLASH] = tr;
            }
            else if( 
distance == 32.0 )
            {
                
g_iTraceHandle[ent][STAB] = tr;
                
g_iTraceHandle[ent][SLASH] = tr TRACE_OFFSET;
            }
        }
    
        if( 
tr == g_iTraceHandle[ent][STAB] )
        {
            
getKnifeDistanceentvecSrctrSTABTRACELINE );
        }
        else if( 
tr == g_iTraceHandle[ent][SLASH] )
        {
            
getKnifeDistanceentvecSrctrSLASHTRACELINE );
        }
    }
}

public 
fwdTraceHull_PostFloat:vecSrc[3], Float:vecEnd[3], conditionhullenttr )
{
    if( 
isPlayerent ) && g_bAlive[ent] )
    {
        if( 
tr == g_iTraceHandle[ent][STAB] )
        {
            
getKnifeDistanceentvecSrctrSTABTRACEHULL );
        }
        else if( 
tr == g_iTraceHandle[ent][SLASH] )
        {
            
getKnifeDistanceentvecSrctrSLASHTRACEHULL );
        }
    }
}

public 
getKnifeDistanceentFloat:vecSrc[3], trAttackType:attackTraceType:trace )
{    
    static 
fraction;
    
get_tr2trTR_flFractionfraction );
    
    if( 
fraction == 1.0 )
    {
        return 
0;
    }
    
    static 
hit;
    
hit get_tr2trTR_pHit );
    
    if( !
isPlayerhit ) )
    {
        return 
0;
    }

    static 
Float:vecEndPos[3];
    
    if( 
attack == STAB )
    {
        
get_tr2trTR_vecEndPosvecEndPos );
        
formatg_szBuffer511"Stab Stats (%s)^nDistance: %.6f (max 32.0)^nHit: %s (%s)"g_szTraceType[trace], get_distance_fvecSrcvecEndPos ), g_szNickname[hit], g_szHitgroup[get_tr2trTR_iHitgroup )] );
    }
    else if( 
attack == SLASH )
    {
        
get_tr2trTR_vecEndPosvecEndPos );
        
formatg_szBuffer511"Slash Stats (%s)^nDistance: %.6f (max 48.0)^nHit: %s (%s)"g_szTraceType[trace], get_distance_fvecSrcvecEndPos ), g_szNickname[hit], g_szHitgroup[get_tr2trTR_iHitgroup )] );
    }
    
    return 
FMRES_IGNORED;

__________________

Last edited by SchlumPF*; 05-14-2009 at 14:24.
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-14-2009 , 14:35   Re: Knife Distance 0.2 by SchlumPF
Reply With Quote #32

Don't know if useful but you may want to add the real damage done. ( pev_take_dmg )

And about g_bAlive[plr] = false; , you should do in client_disconnect() too.
Arkshine is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-14-2009 , 14:37   Re: Knife Distance 0.2 by SchlumPF
Reply With Quote #33

pev_take_dmg didnt work in the traceline way, didnt check it with the TraceAttack one cuz xPaw my testing "bitch" worked enough today :X
gonna test it later ofc and add it in 0.2a or sth
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-14-2009 , 14:46   Re: Knife Distance 0.2 by SchlumPF
Reply With Quote #34

formatex( g_szBuffer[len], 511 - len, "^nDamage: %.f (Real: %d)", damage, pev( plr, pev_dmg_take ) );

Works fine for me :p
Arkshine is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-14-2009 , 15:26   Re: Knife Distance 0.2 by SchlumPF
Reply With Quote #35

takedamage is called after traceattack (read it somewhere but cant remember where) and the trace forwards are called after it too.
if you did this in Ham_TakeDamage ->

PHP Code:
// player.cpp
int CBasePlayer :: TakeDamageentvars_t *pevInflictorentvars_t *pevAttackerfloat flDamageint bitsDamageType )
{
    
// bla blubb

    // keep track of amount of damage last sustained
    
m_lastDamageAmount flDamage;  // <-

    // bla blubb
}


// combat.cpp
int CBaseMonster :: TakeDamageentvars_t *pevInflictorentvars_t *pevAttackerfloat flDamageint bitsDamageType )
{
    
float    flTake;

    
// bla blubb

    //!!!LATER - make armor consideration here!
    
flTake flDamage;

    
// bla blubb

    // add to the damage total for clients, which will be sent as a single
    // message at the end of the frame
    // todo: remove after combining shotgun blasts?
    
if ( IsPlayer() )
    {
        if ( 
pevInflictor )
            
pev->dmg_inflictor ENT(pevInflictor);

        
pev->dmg_take += flTake// <-

        // check for godmode or invincibility
        
if ( pev->flags FL_GODMODE )
        {
            return 
0;
        }
    }

    
// bla blubb

__________________

Last edited by SchlumPF*; 05-14-2009 at 15:33.
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-14-2009 , 15:35   Re: Knife Distance 0.2 by SchlumPF
Reply With Quote #36

You're right. Well, it was seemed the value was correct. Anyway, nvm.
Arkshine is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-15-2009 , 11:27   Re: Knife Distance 0.3 by SchlumPF
Reply With Quote #37

updated to 0.3, check the mainpost
ill add cvars soon. also, ill add a top15 as soon as i get some feedback of ppl who use this on their server since i am not that familar with knifing :X
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
CuLLi
BANNED
Join Date: Apr 2009
Location: Romania (piratebay) C
Old 05-15-2009 , 14:28   Re: Knife Distance 0.3 by SchlumPF
Reply With Quote #38

top15 for KD??? i loveeeeeeeeeeeeee u :X

but i think is useless, because every noob can have a lucky 31+ units stab without skill, like in my server. (not like in LJ)

and the differences would very minor

Last edited by CuLLi; 05-15-2009 at 14:32.
CuLLi is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-15-2009 , 15:49   Re: Knife Distance 0.3 by SchlumPF
Reply With Quote #39

i did not think about a distance top15 cuz ppl could trick it easily, for example by attacking afk players. more like a statistic with points for certain events such as a stab hs or slashing a player (7slashes).

there is a small bug in my plugin when you duck and attack your opponents feet. the maximum distance is then range*2 but unfortunately i cannot simply divide the distance by 2 cuz it would be very inaccurate

//edit
updated, plugin is now really 100% accurate. check the changelog for more changes
__________________

Last edited by SchlumPF*; 05-17-2009 at 07:32.
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
CuLLi
BANNED
Join Date: Apr 2009
Location: Romania (piratebay) C
Old 05-21-2009 , 13:46   Re: Knife Distance 0.4 by SchlumPF
Reply With Quote #40

Quote:
L 05/21/2009 - 20:44:10: [AMXX] Invalid Plugin (plugin "knife_distance.amxx")
CuLLi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode