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

Hook Shortstop "shove"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wliu
Veteran Member
Join Date: Apr 2013
Old 07-18-2016 , 15:04   Hook Shortstop "shove"
Reply With Quote #1

I'm looking for a way to detect when a player with the Shortstop shoves someone, but I can't find any related events. I did try object_deflected but that didn't work. Does anyone have any ideas?
__________________
~Wliu
Wliu is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 07-18-2016 , 16:29   Re: Hook Shortstop "shove"
Reply With Quote #2

It fires a player_hurt event, maybe you can use that?

PHP Code:
Server event "player_hurt"Tick 154378:
"userid" "322"
"health" "124"
"attacker" "322"
"damageamount" "1"
"custom" "0"
"showdisguisedcrit" "0"
"crit" "0"
"minicrit" "0"
"allseecrit" "0"
"weaponid" "17"
"bonuseffect" "4" 
Dunno if any of these properties are unique to the shove tho

Edit:
Apart from the 1 Dmg

Edit Edit:
And it also applies the cond 115 (TFCond_KnockedIntoAir) to the shoved person (Used whenever a player is under the effects of Compression blast. Removed when the player touches the ground.)

Edit Edit Edit:
I also plays the weapons/push_impact.wav (Weapon_Hands.PushImpact) sound
__________________

Last edited by Pelipoika; 07-18-2016 at 16:38.
Pelipoika is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 07-18-2016 , 16:38   Re: Hook Shortstop "shove"
Reply With Quote #3

You could catch it with OnTakeDamage or by looking for that push sound "Weapon_Hands.PushImpact" in a NormalSoundHook.
__________________
pheadxdll is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-18-2016 , 17:42   Re: Hook Shortstop "shove"
Reply With Quote #4

Quote:
Originally Posted by Pelipoika View Post
It fires a player_hurt event, maybe you can use that?

PHP Code:
Server event "player_hurt"Tick 154378:
"userid" "322"
"health" "124"
"attacker" "322"
"damageamount" "1"
"custom" "0"
"showdisguisedcrit" "0"
"crit" "0"
"minicrit" "0"
"allseecrit" "0"
"weaponid" "17"
"bonuseffect" "4" 
Dunno if any of these properties are unique to the shove tho

Edit:
Apart from the 1 Dmg

Edit Edit:
And it also applies the cond 115 (TFCond_KnockedIntoAir) to the shoved person (Used whenever a player is under the effects of Compression blast. Removed when the player touches the ground.)

Edit Edit Edit:
I also plays the weapons/push_impact.wav (Weapon_Hands.PushImpact) sound
I don't remember bonuseffect being a thing. I assume that's new. 4 may be unique to the Shortstop.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 07-19-2016 , 14:17   Re: Hook Shortstop "shove"
Reply With Quote #5

Awesome, thanks! bonuseffect or the TFCondition should work.

EDIT: Did a quick Google search for bonuseffect. It looks like a value of 2 is the Demoman's double-donk and 4 is any other knockback-related effect like rocket jumps? Not too sure.
__________________
~Wliu

Last edited by Wliu; 07-19-2016 at 14:23.
Wliu is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 07-19-2016 , 16:09   Re: Hook Shortstop "shove"
Reply With Quote #6

Ok Powerlord (I think it's you at least), you can blame me for causing the X-Y Problem here .

What I really wanted to do in the first place was modify the amount of knockback the Shortstop push causes (for x10). Unfortunately it only emits a player_hurt event and OnTakeDamage doesn't get called (where I'm pretty sure I could have scaled the damageForce vector).

Also, the attacker userid for the shove is the same as the client's...
__________________
~Wliu
Wliu is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 05-10-2018 , 00:34   Re: Hook Shortstop "shove"
Reply With Quote #7

Going to be that guy so I can put this question to rest. I had a similar issue back when I needed to detect the shove (for a custom achievement); I revisited it today after working on some other projects that had me thinking.

Use a hook on OnTakeDamage(Post|Alive|AlivePost). It does work (if not before, it does now):

Code:
public void OnTakeDamagePost(int victim, int attacker, int inflictor, float damage,
		int damagetype, int weapon, const float damageForce[3], const float damagePosition[3]) {
	if (attacker != victim) {
		// attacker is equal to victim on shortstop push events
		return;
	}

	if (!IsValidEntity(weapon) || !HasEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex")) {
		// we don't have a weapon to work with
		return;
	}
	
	if (TF2_GetItemDefinitionIndex(weapon) != 220) {
		// not the shortstop (personal stock function, but you should be able to figure it out)
		return;
	}

	int owner = GetEntPropEnt(weapon, Prop_Send, "m_hOwnerEntity");
	LogMessage("%N bumped %N with shortstop", owner, victim);
}
A couple of other things that need tweaking:
  • The player_hurt isn't fired in a way that the attacker can see. No damage numbers.
  • Killing a player directly with an initial shove doesn't propagate the weapon through player_death (on a non-assist it acts like the player suicided). On multiple hits within a short timespan, it's treated as an assist.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 05-10-2018 at 00:35.
nosoop is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-12-2018 , 10:14   Re: Hook Shortstop "shove"
Reply With Quote #8

Quote:
Originally Posted by nosoop View Post
Going to be that guy so I can put this question to rest. I had a similar issue back when I needed to detect the shove (for a custom achievement); I revisited it today after working on some other projects that had me thinking.

Use a hook on OnTakeDamage(Post|Alive|AlivePost). It does work (if not before, it does now):

Code:
public void OnTakeDamagePost(int victim, int attacker, int inflictor, float damage,
		int damagetype, int weapon, const float damageForce[3], const float damagePosition[3]) {
	if (attacker != victim) {
		// attacker is equal to victim on shortstop push events
		return;
	}

	if (!IsValidEntity(weapon) || !HasEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex")) {
		// we don't have a weapon to work with
		return;
	}
	
	if (TF2_GetItemDefinitionIndex(weapon) != 220) {
		// not the shortstop (personal stock function, but you should be able to figure it out)
		return;
	}

	int owner = GetEntPropEnt(weapon, Prop_Send, "m_hOwnerEntity");
	LogMessage("%N bumped %N with shortstop", owner, victim);
}
A couple of other things that need tweaking:
  • The player_hurt isn't fired in a way that the attacker can see. No damage numbers.
  • Killing a player directly with an initial shove doesn't propagate the weapon through player_death (on a non-assist it acts like the player suicided). On multiple hits within a short timespan, it's treated as an assist.
Thanks for this!
ThatKidWhoGames 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 04:28.


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