SerialEventUnitSetDamage questions

killmeplease

Mk Z on Steam
Joined
Nov 22, 2007
Messages
2,795
Location
Samara
hello!
i have two questions about this function
1. i read somewhere events marked as serial only work when the user looks at the spot where the event tooks place, is it true?
2. this event passes the id of the unit being damaged and damage values, but how to know what unit did inflict the damage?

what i want is to undo a portion of the dealt damage if it was a ranged attack: bombardment deals less damage to wounded units as they have less soldiers thus area bombardment becomes less effective.

e.g. theres 20 damage, if the bombarded unit had 100 hp, the full 20 damage is dealt. if the unit had 50 hp, only 10 (1/2) is dealt, if unit had 10 hp, 2 (1/10) is dealt...
 
From observation - we don't have the UI code so it's impossible to be definitive ... SerialEvents are typically used to update the UI (mainly the 3d world view) - in the case of SerialEventUnitSetDamage the health bar in the unit flag, the health bar in the unit panel and the "decimated" state of the unit's 3d model - so if the player can't see the tile (not if they are actually looking at it, but if it's in the FoW) there is no need to update the UI (as the UI will correctly initialise that tile/unit when it is revealed to the player) so the event is generally not sent. For example, a fight between two AI units in the FoW will probably not send the events.

And now for the mud to cloud the waters - not all of them behave this way. If the event was useful to a scenario it may behave differently. And some of them "just are".

This also explains why most of the SerialEvents appear to be missing parameters (in this case the unit dishing out the damage) the UI doesn't need to know which unit caused the damage, just that the unit is damaged. The SerialEvent sent when an improvement is destroyed doesn't include what was destroyed (it doesn't matter, the UI just needs to redraw the tile without any improvement).
 
Back
Top Bottom