Combat
Combat (originally the Combat2 Project, an enhancement to the Linden Combat system) is the standard way to build damage systems in Second Life. It is not meant to be a complete combat system on its own but provides the tools that let you make one.
In Second Life there are a host of combat communities scattered across the grid. These communities use a wide variety of combat systems, HUDs and weapon systems. Some are completely custom, relying on scripts to arbitrate health and damage, while others are based on the Linden Lab Combat System (LLCS).
The goal is a coherent set of tools that lets residents create complex and compelling combat systems using a common and easy to use framework. Damage only works where the parcel allows it (check with llGetParcelFlags).
Concepts
- Can apply damage
directly, or on collision by giving a prim a damage amount (PRIM_DAMAGE) - Damage can have a damage type associated to it
- Damage events
- If a script (object, vehicle or attachment) has a damage event this will be called first before final damage is applied
- Scripts may modify the actual amount of damage in a damage event if the region allows it
- Inside the event, what hit, who owns it, its key and who rezzed it are read with the detected functions
- Objects have a health property, and any avatar’s or object’s health can be read
- Scripts have to manage this property themselves; Unlike agents the simulator will not apply damage to the object health and instead only trigger damage and final damage events
- Sensors can scan for
damageableobjects and avatars that are not on a safe parcel - When an avatar dies, its attachments get an
on_deathevent
- Combat Log has been added which allows for auditing and other usecases
- Records all damage events, damage adjustments and kills in a combat-specific public channel
- System generated messages by a specific ID that scripts may filter to
- Scripts may write to this channel if not restricted so by the region
- New region-wide settings, region owners may:
- Throttle damage per second dealt to a target by a single source
- Limit damage to a target by a maximum per a single event
- Select a number of options as to what happens when agent health drops to 0 such as:
- Teleport home (same as old LLCS)
- Teleport to region’s telehub
- Teleport to parcel’s landing point
- No action — Which can allow a custom scripted respawn system to act instead for example
- Set a brief period of invulnerability, during which agents may neither deal nor receive damage
- Whether health is reset to 100% on death
- Tweak the speed of health regeneration per second or disable health regeneration
- Whether scripts are allowed to adjust damage or write to the combat log
- Scripts read these settings with
llGetEnv(see Additional)
Functions and events
These are the functions and events directly related to combat, as well as related functions for rezzing projectiles.
key | llRezObjectWithParams(string item, list options) |
void | llAdjustDamage(integer number, float new_damage) |
void | llDamage(key target, float damage, integer damage_type) |
list | llDetectedDamage(integer number) |
key | llDetectedRezzer(integer number) |
float | llGetHealth(key id) |
event | on_damage(integer num_detected) |
event | final_damage(integer num_detected) |
event | on_death() |
string | llGetStartString() |
integer | llDerezObject(key id, integer flags) |
Combat Log
System-generated log messages are collected and sent into the COMBAT_CHANNEL in a JSON format (see the message format). Read them with a listener and llJsonGetValue in the listen event.
Damage types
Weapons and projectiles
Scripting Details
Here are the functions and events in detail.
key | llRezObjectWithParams(string item, list options)New function for rezzing objects with a variety of parameters, particularly useful for avoiding the overhead of starting a script for each bullet |
void | llAdjustDamage(integer number, float new_damage)Modifies the amount of damage that will be applied by the current on_damage event after it has completed processing |
void | llDamage(key target, float damage, integer damage_type)Delivers damage to tasks and agent in the same region with an integer describing the type of damage. Negative damage can be used to heal instead. You can also go above 100.0 damage unlike collideable damage |
list | llDetectedDamage(integer number)Returns a list describing a single damage event within an on_damage event |
key | llDetectedRezzer(integer number)Returns a key that is the UUID of the object or avatar that rezzed the detected object |
float | llGetHealth(key id)Returns the current health of an avatar or object in the region |
event | on_damage(integer num_detected)Triggered when damage has been inflicted on an avatar or task in the world but before damage has been applied or distributed |
event | final_damage(integer num_detected)Triggered after after all on_damage events in all scripts and attachments have processed and damage has been applied to the avatar or distributed to all seated avatars |
event | on_death()Triggered on all attachments worn by an avatar when that avatar’s health reaches 0 |
string | llGetStartString()New function to retrieve the string passed with llRezObjectWithParams via REZ_PARAM_STRING, particularly useful for avoiding overhead and delay when having to communicate any necessary information |
integer | llDerezObject(key id, integer flags)Derezzes an object previously rezzed from within the object containing the script |
Additional
- Damage types — Provided for convenience and a suggestion. Scripters can add custom ones or repurpose the damage type fields
llListen- Channel reserved at
COMBAT_CHANNEL - System generated combat log messages sent by
COMBAT_LOG_ID - Scripts may also write to this channel if the region allows it (see
"restrict_combat_log"below)
- Channel reserved at
llSensor— Scripts may filter byDAMAGEABLEfor objects in world that process damage (that is if they have aon_damageand/orfinal_damageevent — the object’s health doesn’t matter)llGetObjectDetails— Additional values around health, damage and typeOBJECT_HEALTH— Retrieves the health of an avatar or primOBJECT_DAMAGE— Retrieves the amount of damage a prim inflicts on collisionOBJECT_DAMAGE_TYPE— Retrieves the type of damage a prim inflicts on collision
llRezObjectWithParams— Apply damage to rezzed objectsREZ_DAMAGE— The amount of damage applied to an agent upon collision with this objectREZ_DAMAGE_TYPE— The damage type to apply when this prim collides with another objectREZ_PARAM_STRING— String parameter that can be passed into the rezzed object with a maximum string length of 1024 bytes
llSetLinkPrimitiveParamsFast— New parameter added to adjust damage amount and damage type for collision damagePRIM_DAMAGE— Set damage amount and damage type
llGetEnv— Several new values are added"allow_damage_adjust"— Are scripts allowed to adjust damage"restrict_combat_log"— Are scripts allowed to write to the combat log"restore_health"— Is health reset to 100% on death"invulnerability_time"— Invulnerablitiy time applied after avatar death"damage_throttle"— The maximum number of points of damage a single source may inflict on a target per second. This is a Damage Per Second (DPS) throttle"damage_limit"— The maximum number of points of damage a single damage collision or call viallDamagemay inflict"health_regen_rate"— The speed of health regeneration in hitpoints per second"death_action"— Set the action to take when an avatar dies in the region
llSetLinkSitFlags— Flags that can be applied to sit targetsSIT_FLAG_NO_COLLIDE— Disable the avatar’s collision volume when they are seated on this sit targetSIT_FLAG_NO_DAMAGE— Do not distribute damage to agents sitting on this sit target
llGetParcelFlags—PARCEL_FLAG_ALLOW_DAMAGEis set where damage is enabled; elsewhere avatars are safe
Related
Section titled “Related”- Thread on the Second Life community forums by Rider Linden announcing the project: Pew! Pew! Pew! Linden Damage & Combat 2.0
- Feedback for suggesting, voting and commenting on ideas
- Thread on draft proposal for Combat 2.1 changes by adding Teams & Respawns concepts from Rider Linden: Combat 2.1: Teams & Respawn
See also Feature InputFeature PhysicsFeature EffectsFeature SoundFeature InventoryPage Guide: turret rotation (aiming a turret with the camera)
Known Issues
Section titled “Known Issues”- Sitting Avatars with
SIT_FLAGS_NO_DAMAGEmay still attempt to process damage which can cause various issues, such as still generating damage logs and affecting objects withllSetDamage
Wishlist
Section titled “Wishlist”Adapted from the Second Life Wiki page Category:LSL Combat2 (revision 1218481, 2025-10-11), including the transcluded Template:LSL Constants/Custom Damage Types (revision 1218868, 2026-06-03) and Template:LSL Constants/Damage Types (revision 1216840, 2024-06-26); history, by Second Life Wiki contributors, under CC BY-SA 3.0. Last wiki edit: .