Damage event: on_damage_final
complete
Wulfie Reanimator
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.Log In
Kyle Linden
complete
Rider Linden
I got this in as final_damage(integer count). I still need to write up the wiki page but it behaves much the same as on_damage(integer count) but is fired AFTER damage has been applied.
Wulfie Reanimator
That'll do great, thank you!
Thunder Rahja
During combat community user group, Rider stated that this was implemented as
final_damage
on the beta grid in simulator version Combat2 2024-03-28.8472338807.Thunder Rahja
The combat log does report the final damage (as "event":"DAMAGE"), but due to the nature of a potentially spammy channel for listening, I can't recommend it as is. Either
on_damage_final
or a dedicated, filterable combat_log event could solve this problem for reporting final damage received.