View Single Post
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-17-2022 , 21:11   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #8

yes, i just want to check it in this SDKHook to modify the damage...
PHP Code:
// by using z_show_swing and get distance, we know that a shove has 90 degree width(in static) and about 95.0 distance.
// we start to get the end point first.
float v_ang[3],v_pos[3],v_fwd[3],end_pos[3];
GetClientEyeAngles(victim,v_ang);GetClientEyePosition(victim,v_pos);
GetAngleVectors(v_ang,v_fwd,NULL_VECTOR,NULL_VECTOR);
NormalizeVector(v_fwd,v_fwd); // i don't know vector from ang has been normalize or not, so do it again.
ScaleVector(v_fwd,95.0); // scale base on the distance.
AddVectors(v_pos,v_fwd,end_pos); // now get the end point.

// actually it is not the best way to check a player is shoved. The range of shove is a secotr.
// if someone know the tracehull of the min and max size, please tell me.
Handle hTrace TR_TraceHullFilterEx(v_pos,end_pos,{0.0,0.0,0.0},{0.0,0.0,0.0},MASK_PLAYERSOLID,Filter_TraceRayPlayers,victim); 
if( 
hTrace != null && TR_DidHit(hTrace) )
{
    
int client TR_GetEntityIndex(hTrace);
    if( 
<= client <= MaxClients && attacker == client // now we sure that victim is aiming the attacker
    
{
        if( 
GetEntProp(victim_melee,Prop_Send,"m_bInMeleeSwing") ) // swing = 1, other = 0.
        
{
            
damage 0.0;
            
delete hTrace;
            return 
Plugin_Changed;
        }
        else if( 
M_IsPlayerShoving(victim) )
        {
            
damage 0.0;
            
delete hTrace;
            return 
Plugin_Changed;
        }
    }
}
delete hTrace
This is the way i want to try. It is not very well actually.
Do you have some suggestion?
LinLinLin is offline