User:Nexii Malthus/SLMC/Damageable Objects

From Second Life Wiki
Jump to navigation Jump to search

With the new Combat2 update it becomes possible to allow objects to be able to be damaged as well as manage their own health. This allows one to create scripted objects that integrate into the Linden Lab Combat System, from armored vehicles, damageable walls and buildings, makeshift barricades and more.

However as Combat2 is a broad set of tools for residents, it is somewhat open to interpretation. Although the main approach would be to make a scripted object that both can process damage and manages it's own health -- it does mean that it is possible to create objects that process damage but have no health, or have health but do not process damage.

For an example script of managing damage and health see the Object-based Health script.


What makes an object damageable?

An object becomes damageable when it has a script with an on_damage or final_damage event. That is enough to define it as being able to process damage.


What gives an object health?

Health is a floating point value. Objects start with 0.0 health by default. An object can be given health via setting a number via PRIM_HEALTH. This property can only be changed by a call to llSetPrimitiveParams or llSetLinkPrimitiveParamsFast.

Unlike avatars the health value is not restricted and be any number even beyond 100.0.


Do damage collisions or llDamage calls automatically subtract health for objects?

No.

The simulator will not automatically set health based on damage for you, this only applies to avatars.

Instead you need to set object health via PRIM_HEALTH, manually tracking health in your script. You can track current health via llGetHealth or manage it via a global variable in your script.


Does damage to an object generate a DAMAGE event in the Combat Log?

Yes, damage events will be generated in the combat log as soon as you finish processing them in the events.


Does setting an object to 0 health generate a DEATH event in the Combat Log?

No death events will be generated by the simulator for objects.

However because the Combat Log is just a normal channel, and if writing to the Combat log is allowed by region settings, it is highly recommended to generate a custom OBJECT_DEATH event that matches the DEATH event signature. You can read more about it in the Combat Log on writing to the log.

This allows HUDs, systems and auditing tools to provide feedback to residents or be used to understand what is going on.