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

TF2 Player Hurt Hook - True Damage Source?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Maxter
New Member
Join Date: Oct 2011
Old 10-09-2011 , 19:25   TF2 Player Hurt Hook - True Damage Source?
Reply With Quote #1

Hello.

I am trying to make a TF2 plugin which requires a hook capable of knowing the true inflictor or source of damage.

I need to check whether a player is doing damage with a specific weapon.

I have tried using the "player_hurt" event which almost works, the only problem is that this feature is for the Pyro, who can inflict damage after changing weapons.

For example, I need to check if the Pyro is hitting a player with a PowerJack, but when I use the "weaponid" EventInt provided by the event, it gives me the weapon ID of the player's currently equipped weapon. This means the player can ignite an enemy and switch to the PowerJack and the event hook thinks that the damage is being inflicted by the PowerJack, rather than the fire.

What can I do to fix this?

The information I need during this hook is:

- Attacker
- Victim
- Damage Source / Inflictor

Thank you!
Maxter is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 10-09-2011 , 20:18   Re: TF2 Player Hurt Hook - True Damage Source?
Reply With Quote #2

I'm pretty sure SDKHooks OnTakeDamage hook would fix this for you. http://forums.alliedmods.net/showthread.php?t=106748
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
Maxter
New Member
Join Date: Oct 2011
Old 10-09-2011 , 20:49   Re: TF2 Player Hurt Hook - True Damage Source?
Reply With Quote #3

I just gave that a try but I am still having trouble.

The inflictor for lingering fire damage is the same as melee damage.

The inflictor edict classname is "player" for both the lingering fire and melee damages.
Maxter is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 10-09-2011 , 20:55   Re: TF2 Player Hurt Hook - True Damage Source?
Reply With Quote #4

Look at the include file and try the new 2.0 forward prototype,
PHP Code:
(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3]), 
Try reading what weapon is and getting its classname.
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
Maxter
New Member
Join Date: Oct 2011
Old 10-09-2011 , 22:00   Re: TF2 Player Hurt Hook - True Damage Source?
Reply With Quote #5

Excellent! Thank you!
Maxter is offline
psychonic

BAFFLED
Join Date: May 2008
Old 10-09-2011 , 23:50   Re: TF2 Player Hurt Hook - True Damage Source?
Reply With Quote #6

Quote:
Originally Posted by McFlurry View Post
I'm pretty sure SDKHooks OnTakeDamage hook would fix this for you. http://forums.alliedmods.net/showthread.php?t=106748
TF2 already gives the inflictor ent index on the player_hurt event. You don't need sdkhooks.

Quote:
Originally Posted by Maxter View Post
I just gave that a try but I am still having trouble.

The inflictor for lingering fire damage is the same as melee damage.

The inflictor edict classname is "player" for both the lingering fire and melee damages.
Quote:
Originally Posted by McFlurry View Post
Look at the include file and try the new 2.0 forward prototype,
PHP Code:
(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3]), 
Try reading what weapon is and getting its classname.
As noted many times now in the sdkhooks thread, inflictor varies. If it's a player, the weapon is the one currently being held by that player (for melee or bullet/shotgun weapons). Otherwise it will be a projectile (and the projectile's owner being the weapon, owned by a player) or a weapon (again, owned by a player).

Last edited by psychonic; 10-09-2011 at 23:52.
psychonic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-10-2011 , 10:42   Re: TF2 Player Hurt Hook - True Damage Source?
Reply With Quote #7

Quote:
Originally Posted by psychonic View Post
TF2 already gives the inflictor ent index on the player_hurt event. You don't need sdkhooks.
It does? As which event property, attacker?

Code:
        "player_hurt"
        {
                "userid" "short"
                "health" "short"
                "attacker" "short"
                "damageamount" "short"
                "custom"        "short"
                "crit" "bool"
                "minicrit" "bool"
                "allseecrit" "bool"
                "weaponid" "short"
        }
(from orangebox/tf/resources/modevents.res)
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
psychonic

BAFFLED
Join Date: May 2008
Old 10-10-2011 , 10:57   Re: TF2 Player Hurt Hook - True Damage Source?
Reply With Quote #8

Quote:
Originally Posted by Maxter View Post
I just gave that a try but I am still having trouble.

The inflictor for lingering fire damage is the same as melee damage.

The inflictor edict classname is "player" for both the lingering fire and melee damages.
Quote:
Originally Posted by McFlurry View Post
Look at the include file and try the new 2.0 forward prototype,
PHP Code:
(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3]), 
Try reading what weapon is and getting its classname.
Quote:
Originally Posted by Powerlord View Post
It does? As which event property, attacker?

Code:
        "player_hurt"
        {
                "userid" "short"
                "health" "short"
                "attacker" "short"
                "damageamount" "short"
                "custom"        "short"
                "crit" "bool"
                "minicrit" "bool"
                "allseecrit" "bool"
                "weaponid" "short"
        }
(from orangebox/tf/resources/modevents.res)
It doesn't. I was mixing it up with player_death, which they did eventually add inflictor to (as inflictor_entindex).
psychonic is offline
psychonic

BAFFLED
Join Date: May 2008
Old 10-10-2011 , 11:02   Re: TF2 Player Hurt Hook - True Damage Source?
Reply With Quote #9

Quote:
Originally Posted by psychonic View Post
It doesn't. I was mixing it up with player_death, which they did eventually add inflictor to (as inflictor_entindex).
Damage custom, followed by weapon id are the best way to determine weapon from the player_hurt event.
psychonic 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 08:26.


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