point_hurt: cs go
What do you mean you "have to use point_hurt" for other things? Any damage you wish to deal can easily be done with <entity>.take_damage without the need of point_hurt.
I really don't see how adjusting the damage within an on_take_damage prehook and then using a TickRepeat or tick_delay.delay to deal further damage is 'convoluted'. The latter portion is pretty much what you would want to do anyway with the extra damage not dealt right then. The only difference is that you would just need to adjust the damage amount instead of creating a point_hurt object to deal further damage immediately.
I really don't see how adjusting the damage within an on_take_damage prehook and then using a TickRepeat or tick_delay.delay to deal further damage is 'convoluted'. The latter portion is pretty much what you would want to do anyway with the extra damage not dealt right then. The only difference is that you would just need to adjust the damage amount instead of creating a point_hurt object to deal further damage immediately.
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Correct, Entity.take_damage is calling Entity.on_take_damage internally: ../source-python/packages/source-python/entities/specials.py#L143
Oh, you right. I just checked the code. Well, in that case it would be quite easy to get rid of this problem. We could also update our take_damage() method so that it takes an additional keyword. E.g. try_trampoline=True. Our take_damage() method would then look like this. If we use this implementation, we can always use take_damage within a hook and if you would like to "enable" the recursion you can simply set try_trampoline to False.
Edit: After thinking about it again, we should set the default value to False, because other scripts that have a hook on this function will never get notified of the damage done. try_trampoline should only be set to True within a hook.
Syntax: Select all
def take_damage(
self, damage, damage_type=DamageTypes.GENERIC, attacker_index=None,
weapon_index=None, hitgroup=HitGroup.GENERIC, try_trampoline=True,
**kwargs):
# Code...
if try_trampoline:
try:
# Try calling the trampoline
self.on_take_damage.call_trampoline(take_damage_info)
except ValueError:
# If it failed, the function probably wasn't hooked
self.on_take_damage(take_damage_info)
else:
self.on_take_damage(take_damage_info)
Edit: After thinking about it again, we should set the default value to False, because other scripts that have a hook on this function will never get notified of the damage done. try_trampoline should only be set to True within a hook.
Why am I not able to get a userid from the given index?
Syntax: Select all
@PreHook(on_take_damage)
def pre_on_take_damage(args):
#ammo attacker base_damage bullet damage damaged_other_players force inflictor penetrated position radius recoil reported_position stats type weapon
info = make_object(TakeDamageInfo, args[1])
# Is this world damage?
print(info.attacker)
if info.attacker == 0:
return
victim = dnd.dndPlayerDictionary[userid_from_pointer(args[0])]
# ValueError: Unable to get a UserID from the given index (xxx).
attacker = dnd.dndPlayerDictionary[userid_from_index(info.attacker)]
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Syntax: Select all
from entities.constants import WORLD_ENTITY_INDEX
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 80 guests