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.
__________________