Currently we have the
on_damage
event, which allows scripts to react to incoming damage and modify it.
The problem:
There is no predictable order to these events across separate scripts or attachments, so the event can't be used for cases where you only care about "how much damage have I actually received?" This is because, after your script checks the incoming/adjusted damage with
llDetectedDamage
, another script might modify it even more. (This can be observed by calling the function again later during the
same
event and getting a different value.)
default
{
on_damage(integer i)
{
list damage;
damage = llDetectedDamage(0);
llOwnerSay(llList2CSV(damage)); // 10.0, 0, 10.0
llSleep(1);
damage = llDetectedDamage(0);
llOwnerSay(llList2CSV(damage)); // 0.0, 0, 10.0
}
}
The solution:
The
on_damage_final
event will trigger only after all
on_damage
events have been processed and the damage is genuinely getting applied to an avatar. Functions like
llAdjustDamage
have no effect during this event. Ideally
llDetected*
functions should still work, so scripts can know things about the source.