Information for hooks
Posted: Sat Sep 05, 2020 3:17 pm
In l4d2 I am trying to hook damage dealt to the 'infected' enemies.
This works just fine for physics or player entities (when modified) but for whatever reason, infected don't appear to be entities? What baffles me even more is that in 'infected_hurt', I am able to created an entity from the userid -> index and it will return a classname. What would I need to do to hook damage to them?
I think I need to find the appropriate function to hook for when they take damage. However I am not sure where to find a list of appropriate functions. I've been perusing https://developer.valvesoftware.com/ for any information I can obtain but I haven't found much luck. There's gotta be a better way than reverse engineering via disassemblers/memory editing etc...?
Syntax: Select all
@EntityPreHook(EntityCondition.is_not_player, 'on_take_damage')
def infected_pre_take_damage(stack_data):
print("Non-player took damage")
victim = make_object(Entity, stack_data[0])
info = make_object(TakeDamageInfo, stack_data[1])
attacker = Entity(info.attacker)
pprint(dir(victim))
if attacker.is_player():
pprint(victim)
'''
weapon = Entity(info.attacker)
owner = Player(index_from_inthandle(weapon.owner_handle))
info.attacker = owner.index
info.inflictor = owner.index
'''
print(victim.classname)
#if victim.classname in ('infected', 'witch', 'player'):
print("%s %s was attacked"%(victim.index, victim.classname,))
print("done")
This works just fine for physics or player entities (when modified) but for whatever reason, infected don't appear to be entities? What baffles me even more is that in 'infected_hurt', I am able to created an entity from the userid -> index and it will return a classname. What would I need to do to hook damage to them?
I think I need to find the appropriate function to hook for when they take damage. However I am not sure where to find a list of appropriate functions. I've been perusing https://developer.valvesoftware.com/ for any information I can obtain but I haven't found much luck. There's gotta be a better way than reverse engineering via disassemblers/memory editing etc...?