Godot Version
4.3.rc3
Question
20 people shoot you applying different effects. Burn, poison, slow, stun, rate of fire change, gold earned change, scale changed, etc. Things stack, they last for different amounts of time, etc.
There are lots of ways to make this work. The most obvious is a lot of hard coded code and a lot of timers (or collapse effects into a timeline histogram or process an array of effects with a single polling timer on a fix poll cycle, etc.)
on_hit(hit: Hit):
if hit.effects[0].trait_affected = rate_of_fire:
create timer(hit.effects[0].time)
rate_of_fire *= hit.effects[0].value_change
elif hit.effects[0].trait_affected = health:
blah
elif hit.effects[0].trait_affected = range:
elif hit.effects[0].trait_affected = scale:
elif hit.effects[0].trait_affected = movement_speed:
i can do this but it’s a lot of boring code. i thought i heard a rumor that GDScript has more elegant ways of handling this sort of thing. Maybe:
on_hit(trait_name, change, duration):
self.modify_property(trait_name, self.get(trait_name) + change)
create timer stuff
Buffing, debuffing and DoT are common enough i figure a bazillion people have come up with clever, elegant, efficient ways to do this. Anyone here know some?