Difference between revisions of "LlSetDamage"

From Second Life Wiki
Jump to: navigation, search
m
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(5 intermediate revisions by 2 users not shown)
Line 8: Line 8:
 
|spec=
 
|spec=
 
For an avatar to take damage when the object collides with an avatar...
 
For an avatar to take damage when the object collides with an avatar...
*The object must be physical, and
+
*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 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.
 
When these preconditions are met, the avatar receives the damage, and the object will [[llDie|die]] without calling the {{LSLGC|Collision|collision}} events.
 
|caveats=
 
|caveats=
*If '''damage''' is outside the range of [0, 100], it performs an instant kill.
+
*If '''damage''' is 100.0 or greater, the object will instantly [[death|kill]] even a fully healthy avatar.
*If the object is not over damage enabled land when it collides, the object will ''not'' die and the {{LSLGC|Collision|collision}} or {{LSLGC|Land Collision|land_collision}} events will be queued.
+
*If '''damage''' is zero or less, no damage will be inflicted and the object will ''not'' die and the {{LSLGC|Collision|collision}} or {{LSLGC|Land Collision|land_collision}} events will be queued.
*If the object is not physical, the object will be damage enabled if it becomes physical; it will however not be physical while it is not damage enabled.
+
 
*If a damage enabled object hits a physics enabled object that an avatar is sitting on, the avatar receives the damage just the same as they would if they had been hit directly.
 
*If a damage enabled object hits a physics enabled object that an avatar is sitting on, the avatar receives the damage just the same as they would if they had been hit directly.
 
|constants
 
|constants
 
|examples=
 
|examples=
<lsl>//Simple autokiller bullet:  
+
<source lang="lsl2">//Simple autokiller bullet:
//When it rezzed it scans for the closest person,
+
// This will instantly "kill" on collision if contact is made with avatar on damage enabled land.
//Moves to their location and kills them. (Because
+
 
//It collides with them)
+
default
default {
+
{
     on_rez(integer i) {
+
     on_rez(integer param) // Becomes active when rezzed.
         llSetTimerEvent(10.0);
+
    {
         llSensor("", "", AGENT, PI, 96.0);
+
         llSetDamage(100.0); // Set the damage to maximum.
 +
         llSensor("", "", AGENT, 96.0, PI); // Sweep a 96 meter sphere searching for agents.
 
     }
 
     }
    timer() { llDie(); }
+
     sensor(integer num) // If an agent is detected...
     sensor(integer num) {
+
    {
         llSetStatus(STATUS_PHYSICS, TRUE);
+
         llSetStatus(STATUS_PHYSICS, TRUE); // Enable physics to allow physical movement.
         llSetDamage(100.0);
+
         llSetTimerEvent(10.0); // Set a 10 second timer.
         llMoveToTarget(llDetectedPos(0), 1.0);
+
         llMoveToTarget(llDetectedPos(0), 0.5); // Move to the detected position.
 
     }
 
     }
}</lsl>
+
    no_sensor() // If no agents are detected...
 +
    {
 +
        llDie(); // Auto destruct.
 +
    }
 +
    timer() // If we missed our target...
 +
    {
 +
        llDie(); // Auto destruct.
 +
    }
 +
}</source>
 
|helpers
 
|helpers
 
|also_functions
 
|also_functions

Latest revision as of 14:44, 22 January 2015

Summary

Function: llSetDamage( float damage );

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

• float damage range: 0.0 (no damage) ~ 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

  • If damage is 100.0 or greater, the object will instantly kill even a fully healthy avatar.
  • If damage is zero or less, no damage will be inflicted and the object will not die and the collision or land_collision events will be queued.
  • If a damage enabled object hits a physics enabled object that an avatar is sitting on, the avatar receives the damage just the same as they would if they had been hit directly.
All Issues ~ Search JIRA for related Bugs

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.
    }
}

Deep Notes

Search JIRA for related Issues

Signature

function void llSetDamage( float damage );