Raised This Month: $ Target: $400
 0% 

Hit/Knife in back/rear ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
waza123a
Member
Join Date: Mar 2010
Old 06-21-2014 , 08:31   Hit/Knife in back/rear ?
Reply With Quote #1

Is there a way to detect, if player was kicked/shoot/knifed in back/rear ?
Attached Thumbnails
Click image for larger version

Name:	back.png
Views:	105
Size:	42.2 KB
ID:	134724  
__________________
Life is good, sometimes...
waza123a is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 06-21-2014 , 10:42   Re: Hit/Knife in back/rear ?
Reply With Quote #2

You can try to hook TraceAttack on "player", check if player was attacked with knife.

When dealing dmg with a knife stab, it hurts 65hp points, but if it's from behind, this gets mult by 3, so the total damage done it's 195hp points. There wouldn't be other greater dmg value, so you can use it to check.

Or also, you can imitate engine's way to check if player attacked behind another:

PHP Code:
    UTIL_MakeVectorsm_pPlayer->pev->v_angle ); 
    
// and later...

    
float flDamage 65.0;
        if( 
pEntity && pEntity->IsPlayer() )        
    {            
        
Vector2D vec2LOS;            
        
Vector vecForward gpGlobals->v_forward;
        
UTIL_MakeVectorsm_pPlayer->pev->angles );
        
vec2LOS vecForward.Make2D();            
        
vec2LOS vec2LOS.Normalize();
        if( 
DotProductvec2LOSgpGlobals->v_forward.Make2D() ) > 0.8 )            
        {                    
            
flDamage *= 3.0;            
        }        
    }
        
UTIL_MakeVectorsm_pPlayer->pev->v_angle );        
    
ClearMultiDamage();
        
pEntity->TraceAttackm_pPlayer->pevflDamagegpGlobals->v_forward, &trDMG_NEVERGIB DMG_BULLET );        
    
ApplyMultiDamagem_pPlayer->pevm_pPlayer->pev ); 
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
waza123a
Member
Join Date: Mar 2010
Old 06-21-2014 , 10:52   Re: Hit/Knife in back/rear ?
Reply With Quote #3

it's very interesting, but its 2014y, and no one ever want to check "hit in back" ? maybe there is some released code somewhere.. ?

of course i will try to create that function with damage *3, thanks for idea.
__________________
Life is good, sometimes...

Last edited by waza123a; 06-21-2014 at 10:54.
waza123a is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-21-2014 , 10:56   Re: Hit/Knife in back/rear ?
Reply With Quote #4

I didn't make it. Found it somewhere.
Code:
bool:IsBackstab(const attacker, const victim) {         new Float: vec1[3];     new Float: vec2[3];         velocity_by_aim(attacker, 1, vec1);         new Float:invlen = xs_rsqrt(vec1[0] * vec1[0] + vec1[1] * vec1[1]);     vec1[0] *= invlen;     vec1[1] *= invlen;         pev(victim, pev_angles, vec2);     angle_vector(vec2, ANGLEVECTOR_FORWARD, vec2);         return vec1[0] * vec2[0] + vec1[1] * vec2[1] > 0.8 ? true : false; }
__________________

Last edited by Black Rose; 06-21-2014 at 10:57.
Black Rose is offline
waza123a
Member
Join Date: Mar 2010
Old 06-21-2014 , 11:00   Re: Hit/Knife in back/rear ?
Reply With Quote #5

awesome, thanks! will try
__________________
Life is good, sometimes...
waza123a is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 06-21-2014 , 17:06   Re: Hit/Knife in back/rear ?
Reply With Quote #6

PHP Code:
public OnTraceAttack(iVictimiAttackerFloat:flDamageFloat:vecDirection[3], iTrHandlebitsDamageType)
{
    if(
bitsDamageType == (DMG_BULLET|DMG_NEVERGIB// specific knife damage mask
    
&& is_user_alive(iAttacker// some dmgs can be done while user is dead, so you are checking if attacker it's player also
    
&& get_user_weapon(iAttacker) == CSW_KNIFE
    
&& flDamage == 192.0)
    {
        
client_print(0print_chat"Hey! I've attacked you from behind 6969")
    }

__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS 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 21:12.


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