Difference between revisions of "LlSetDamage"
Jump to navigation
Jump to search
All Issues ~ Search JIRA for related Bugs
Fred Gandt (talk | contribs) (I have tested this. I'm not just guessing.) |
Fred Gandt (talk | contribs) m (Fixed script example (sensor arc and range were back to front).) |
||
Line 19: | Line 19: | ||
|constants | |constants | ||
|examples= | |examples= | ||
<lsl>//Simple autokiller bullet: | <lsl>//Simple autokiller bullet: | ||
// | // This will instantly "kill" on collision if contact is made with avatar on damage enabled land. | ||
default | |||
default { | { | ||
on_rez(integer | on_rez(integer param) // Becomes active when rezzed. | ||
{ | |||
llSensor("", "", AGENT | 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... | |||
sensor(integer num) { | { | ||
llSetStatus(STATUS_PHYSICS, TRUE); | llSetStatus(STATUS_PHYSICS, TRUE); // Enable physics to allow physical movement. | ||
llSetTimerEvent(10.0); // Set a 10 second timer. | |||
llMoveToTarget(llDetectedPos(0), | 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. | |||
} | } | ||
}</lsl> | }</lsl> |
Revision as of 17:05, 9 May 2010
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: llSetDamage( float damage );157 | Function ID |
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: 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 and
- The avatar must be on the land where "Safe (no damage)" is disabled.
- The object needs only be partially over damage enabled land. Its pos need not be.
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 the object is not partially over damage enabled land when it collides, 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.
Examples
<lsl>//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. }}</lsl>