Difference between revisions of "LlSetDamage"

From Second Life Wiki
Jump to navigation Jump to search
 
(15 intermediate revisions by 8 users not shown)
Line 2: Line 2:
|func_id=157|func_sleep=0.0|func_energy=10.0
|func_id=157|func_sleep=0.0|func_energy=10.0
|sort=SetDamage
|sort=SetDamage
|func=llSetDamage|p1_type=float|p1_name=damage
|func=llSetDamage|p1_type=float|p1_name=damage|p1_desc=range: -100.0 (full heal) ~ 100.0 (instant kill)
|func_footnote=If '''damage''' is greater then 100.0, it will kill the agent it hits. If the object hits another object it will {{LSLG|llDie|die}}.
|func_footnote
|func_desc=Sets the amount of damage that will be done when this object hits an agent.
|func_desc=Sets the amount of {{LSLP|damage}} that will be done when this object hits an avatar.
|return_text
|return_text
|spec
|spec=
|caveats
For an avatar to take damage when the object collides with an avatar...
*The object must not be [[STATUS_PHANTOM|phantom]] or [[llVolumeDetect]]([[TRUE]])
*The avatar must be on the land where "Safe (no damage)" is disabled.
**The object however does not need to be on or even partially over damage enabled land.
When these preconditions are met, the avatar receives the damage, and the object will [[llDie|die]] without calling the {{LSLGC|Collision|collision}} events.
|caveats=
*{{LSLP|damage}} is a [[Prim Properties|Prim Property]], and may be applied even if there is no running script.
*If {{LSLP|damage}} is 100.0 or greater, the object will instantly [[death|kill]] even a fully healthy avatar.
*If {{LSLP|damage}} is less than zero, the avatar will he healed for the indicated amount.
*If a damage enabled object hits a physics enabled object that one or more avatars are sitting on, damage will be distributed to all seated avatars.
|constants
|constants
|examples
|examples=
<syntaxhighlight lang="lsl2">//Simple autokiller bullet:
// This will instantly "kill" on collision if contact is made with avatar on damage enabled land.
 
default
{
    on_rez(integer param) // Becomes active when rezzed.
    {
        llSetDamage(100.0); // Set the damage to maximum.
        llSensor("", "", AGENT, 96.0, PI); // Sweep a 96 meter sphere searching for agents.
    }
    sensor(integer num) // If an agent is detected...
    {
        llSetStatus(STATUS_PHYSICS, TRUE); // Enable physics to allow physical movement.
        llSetTimerEvent(10.0); // Set a 10 second timer.
        llMoveToTarget(llDetectedPos(0), 0.5); // Move to the detected position.
    }
    no_sensor() // If no agents are detected...
    {
        llDie(); // Auto destruct.
    }
    timer() // If we missed our target...
    {
        llDie(); // Auto destruct.
    }
}</syntaxhighlight>
|helpers
|helpers
|also_functions
|also_functions
|also_events
|also_events
|also_articles
|also_articles=
{{LSL DefineRow||[[Damage]]|How damage works in Second Life}}
{{LSL DefineRow||[[Death]]|The concept of death in Second Life}}
{{LSL DefineRow||[[Combat]]|Combat in Second Life}}
{{LSL DefineRow||[[Weapon]]|Weapons in Second Life}}
|notes
|notes
|permission
|permission

Latest revision as of 11:43, 13 October 2023

Summary

Function: llSetDamage( float damage );
0.0 Forced Delay
10.0 Energy

Sets the amount of damage that will be done when this object hits an avatar.

• float damage range: -100.0 (full heal) ~ 100.0 (instant kill)

Specification

For an avatar to take damage when the object collides with an avatar...

  • The object must not be phantom or llVolumeDetect(TRUE)
  • The avatar must be on the land where "Safe (no damage)" is disabled.
    • The object however does not need to be on or even partially over damage enabled land.

When these preconditions are met, the avatar receives the damage, and the object will die without calling the collision events.

Caveats

  • damage is a Prim Property, and may be applied even if there is no running script.
  • If damage is 100.0 or greater, the object will instantly kill even a fully healthy avatar.
  • If damage is less than zero, the avatar will he healed for the indicated amount.
  • If a damage enabled object hits a physics enabled object that one or more avatars are sitting on, damage will be distributed to all seated avatars.

Examples

//Simple autokiller bullet:
// This will instantly "kill" on collision if contact is made with avatar on damage enabled land.

default
{
    on_rez(integer param) // Becomes active when rezzed.
    {
        llSetDamage(100.0); // Set the damage to maximum.
        llSensor("", "", AGENT, 96.0, PI); // Sweep a 96 meter sphere searching for agents.
    }
    sensor(integer num) // If an agent is detected...
    {
        llSetStatus(STATUS_PHYSICS, TRUE); // Enable physics to allow physical movement.
        llSetTimerEvent(10.0); // Set a 10 second timer.
        llMoveToTarget(llDetectedPos(0), 0.5); // Move to the detected position.
    }
    no_sensor() // If no agents are detected...
    {
        llDie(); // Auto destruct.
    }
    timer() // If we missed our target...
    {
        llDie(); // Auto destruct.
    }
}

See Also

Articles

•  Damage How damage works in Second Life
•  Death The concept of death in Second Life
•  Combat Combat in Second Life
•  Weapon Weapons in Second Life

Deep Notes

Signature

function void llSetDamage( float damage );