llSetDamage(float damage)

Sets the amount of damage that will be done to an avatar that the scripted object collides with. The scripted object will die (be deleted) immediately on colliding and no event handlers will be executed first.

damage is a percentage (0 – 100), with 100% meaning instant death on colliding with the object. Lower values will damage the avatar and kill it if its life energy (indicated in the middle of the menu bar on the Second Life client) is lower or equal to the damage.

This function only has an effect on damage-enabled land. Anywhere else it does nothing and the object will not die on collisions. If you need it to die, it’s recommended you use llDie in the collision event.

I noticed (as probably many) that a damage object colliding with another object that an avatar is sitting on will inflict the damage percentage to the avatar, which is kinda annoying, especially when trying to make an armored vehicle. -AgentRevolution

Negative values do not heal the victim. Values outside the 0-100 range are treated as 100% (i.e. instant kill).

//By James Benedek
//50% Damage Script For Linden Damage Land
default
{
         state_entry()
         {
          llSetDamage(50);//will take 50% health from the avatar who collides with the object with this script in
         }
}

 

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