llAdjustDamage bypasses SIT_FLAGS_NO_DAMAGE
closed
Tactical UwU
Alternative Title: Don't wear body armor while sitting in a tank.
May or may not be related to: https://feedback.secondlife.com/scripting-bugs/p/sit-flags-no-damage-still-attempts-to-process-llcs-damage-on-sitting-avatars
llAdjustDamage processes as normal when executed while the avatar is sitting on an object with SIT_FLAGS_NO_DAMAGE enabled.
[Reproduction]
OBJ1: Object that avatar sits on.
llSitTarget(<0.0,0.0,.25>,ZERO_ROTATION);
llSetLinkSitFlags(-1,SIT_FLAGS_NO_DAMAGE);
OBJ2: Any scripted object that modifies or alters damage during the on_damage step. Worn on avatar.
Expected Behavior: Avatar remains Undamaged
Actual Behavior: Output of llAdjustDamage is applied to avatar.
Log In
Maestro Linden
closed
Maestro Linden
needs info
Maestro Linden
Hi Tactical UwU, I'm having trouble reproducing this issue. Here's what I tried:
- Rez a box and put the 'body armor' script (shown below) in it
- Visit a damage-enabled area and get hit with a 10 damage bullet
- Observe the 'body armor' script successfully adjusts the damage to 5, as reported by the script itself and observing that health only goes down to 95% rather than 90%
- Rez a box and put 'invulnerability chair' script (also below) in it. This object has SIT_FLAGS_NO_DAMAGE enabled
- Sit on 'invulnerability chair' and get hit with some more 10 damage bullets, with some bullets hitting the avatar directly and some hitting the 'invulnerability chair' prim
I'm seeing the expected results - when the avatar is seated on 'invulnerability chair', no damage is dealt to the avatar. In fact, the body armor script doesn't even get an on_damage() event indicating that there is incoming damage to process.
I also see this expected behavior if the avatar sits on 'invulnerability chair' first, and then wears 'body armor'.
Are you seeing damage when using my example scripts?
// body armor script - cut incoming damage in half when worn
default
{
state_entry()
{
llSetObjectName("body armor");
}
on_damage(integer num_detected)
{
while(num_detected--)
{
float damage = llList2Float(llDetectedDamage(num_detected), 0);
if(llGetEnv("allow_damage_adjust") == (string)TRUE)
{
// this armor halves damage
float new_damage = damage / 2.0;
llSay(0, "Got on_damage with " + (string)damage
+ " original damage - modifying to " + (string)new_damage);
llAdjustDamage(num_detected, new_damage);
}
else
{
llSay(0, "Got on_damage with damage " + (string)damage
+ " but damage adjustment is not enabled here!");
}
}
}
}
//invulnerability chair - protected from damage when sitting on this script
default
{
state_entry()
{
llSetObjectName("invulnerability chair");
llSetScale(<1,1,1>);
llSitTarget(<3, 0, 0>,ZERO_ROTATION);
llSetLinkSitFlags(LINK_SET, SIT_FLAG_NO_DAMAGE);
llSay(0, "Enabled SIT_FLAG_NO_DAMAGE on object");
}
}
Tactical UwU
Maestro Linden I have been unable to replicate the issue as previously described nor with the materials you have provided. I had originally noticed this problem in December however I was only recently reminded about filling out a bug report for it. Looking through server release notes made no mention of this specific issue.
It does appear the matter is resolved but perhaps for the unintended reasons. The on_damage and final_damage events appear to not be registering whilst the avatar is seated on an object with SIT_FLAG_NO_DAMAGE enabled, thus preventing llAdjustDamage from being executed. That said, this is a good thing because that resolves this issue.
Tests I ran:
- Taking damage while sitting on an object with SIT_FLAGS_NO_DAMAGE enabled. Results in avatar remaining undamaged, body armor has no effect.
- Taking damage while sitting on a PHANTOM object. Body armor and avatar take damage as expected.
- Taking damage while sitting on a normal object. Behaves as expected.
Maestro Linden
Thanks for confirming!