Raised This Month: $32 Target: $400
 8% 

How to set victim's hitzones?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Leech_v2
Senior Member
Join Date: Mar 2011
Location: Chinese GuangDong
Old 05-25-2012 , 20:04   How to set victim's hitzones?
Reply With Quote #1

Code:
public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], trace, bits) 
{
    if (!is_user_connected(victim) || !is_user_connected(attacker)) return HAM_IGNORED
    if (get_user_team(victim)!=1) return HAM_IGNORED

    new Float:end[3]
    get_tr2(trace, TR_vecEndPos, end)
    new hitbone = find_closest_bone(victim, end)
    if (!hitbone) set_pdata_int(victim, 75, 0, 5)
    if (hitbone && hitbone<=2) set_pdata_int(victim, 75, 2, 5)
    if (hitbone>2 && hitbone<=5) set_pdata_int(victim, 75, 5, 5)
    if (hitbone>5 && hitbone<=8) set_pdata_int(victim, 75, 4, 5)
    if (hitbone>8 && hitbone<=17) set_pdata_int(victim, 75, 1, 5)
    if (hitbone>17 && hitbone<=20) set_pdata_int(victim, 75, 6, 5)
    if (hitbone>20 && hitbone<=23) set_pdata_int(victim, 75, 7, 5)
    if (hitbone==24) set_pdata_int(victim, 75, 3, 5)
    if (hitbone>24 && hitbone<=28) set_pdata_int(victim, 75, 7, 5)
    if (hitbone>28 && hitbone<=32) set_pdata_int(victim, 75, 6, 5)
    if (hitbone>32 && hitbone<=34) set_pdata_int(victim, 75, 3, 5)
    return HAM_IGNORED
}
stock find_closest_bone(id, Float:endtrace[3]) 
{ 
    new Float:ang[3], Float:org[3], Float:dist = 9999999.99, Float:curorigin[3], bone_nr 
    for (new i=1;i<=34;i++) 
    {
        engfunc(EngFunc_GetBonePosition, any:id, any:i, any:curorigin, any:ang)
        xs_vec_sub(curorigin, endtrace, ang)
        if (xs_vec_len(ang)<=dist)
        {
            org = curorigin
            dist = xs_vec_len(ang)
            bone_nr = i
        }
        if (dist<=2.0)
        {
            break
        }
    }
    return bone_nr
}
Leech_v2 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-26-2012 , 00:06   Re: How to set victim's hitzones?
Reply With Quote #2

set_user_hitzones?
__________________
Bugsy is offline
Leech_v2
Senior Member
Join Date: Mar 2011
Location: Chinese GuangDong
Old 05-26-2012 , 04:35   Re: How to set victim's hitzones?
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
set_user_hitzones(victim, 0, 32)?
set_user_hitzones(victim, attacker, 32)?
set_user_hitzones(0, victim, 32)?
set_user_hitzones(attacker, victim, 32)?

Last edited by Leech_v2; 05-26-2012 at 04:35.
Leech_v2 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-26-2012 , 11:38   Re: How to set victim's hitzones?
Reply With Quote #4

Code:
set_user_hitzones ( index = 0, target = 0, body = 255 ) 

Set index to a player's index and leave target at 0 to define what bodyparts this player can hit when he is firing.

Set index to 0 and target to a player's index to define what bodyparts on player other players can hit when they are firing.

Set both index and target to 0 to define globally what bodyparts people can hit and what bodyparts can be hit when firing. 
PHP Code:
set_user_hitzonesvictim HITZONES 
To specify HITZONES, use this.

Code:
enum HitZones ( <<=1 )
{
	HZ_GENERIC = 1,
	HZ_HEAD,
	HZ_CHEST,
	HZ_STOMACH,
	HZ_LEFTARM,
	HZ_RIGHTARM,
	HZ_LEFTLEG,
	HZ_RIGHTLEG
}
HITZONES can be a combination of zones which are added via bitwise OR like this:

PHP Code:
HZ_HEAD HZ_CHEST HZ_STOMACH 
__________________

Last edited by Bugsy; 05-26-2012 at 11:39.
Bugsy is offline
Leech_v2
Senior Member
Join Date: Mar 2011
Location: Chinese GuangDong
Old 05-27-2012 , 00:20   Re: How to set victim's hitzones?
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Code:
set_user_hitzones ( index = 0, target = 0, body = 255 ) 
 
Set index to a player's index and leave target at 0 to define what bodyparts this player can hit when he is firing.
 
Set index to 0 and target to a player's index to define what bodyparts on player other players can hit when they are firing.
 
Set both index and target to 0 to define globally what bodyparts people can hit and what bodyparts can be hit when firing. 
PHP Code:
set_user_hitzonesvictim HITZONES 
To specify HITZONES, use this.

Code:
enum HitZones ( <<=1 )
{
    HZ_GENERIC = 1,
    HZ_HEAD,
    HZ_CHEST,
    HZ_STOMACH,
    HZ_LEFTARM,
    HZ_RIGHTARM,
    HZ_LEFTLEG,
    HZ_RIGHTLEG
}
HITZONES can be a combination of zones which are added via bitwise OR like this:

PHP Code:
HZ_HEAD HZ_CHEST HZ_STOMACH 
The game would be closed when i hit player.
Leech_v2 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 14:00.


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