Passive Tutorial
The passives system is different from the Effects because of legacy memory reasons. Passives may only be applied to players and cannot affect NPCs. Technically passives are converted to Effects in the HUD but they use a different syntax and set of effect IDs for legacy reasons.
See got Passives.lsl for a list of passive effect IDs (FXCUpd$*).
Passives can be set by using the Passives$set method. Passives are stored in a 2-stride array of [(int)effectID, (var)effectData ... ]. Passives remain in the HUD until the HUD is reset by relogging, changing sim, or resetting. Or until unset by the Passives$rem method.
Example of adding 10% additional dodge chance with a passive:
Passives$set(llGetOwner(), "myDodgePassive", [FXCUpd$DODGE, 0.1], 0);
Procs
Just like active effects, passives can have procs: Apply a wrapper when an event is received.
Proc data is stored in array with the following syntax:
[
// Triggers
[
[
(int)wrapper_target,
(str)event_script,
(int)event,
(arr)event_args,
(float)max_range
],
...
],
(int)max_targets,
(float)proc_chance,
(float)cooldown,
(int)flags,
(arr)wrapper
]
Example: Heal the owner for 20 HP when they use ability 5:
string healWrapper = FX_buildWrapper(
0, // Flags
0, // Min packages (ANY)
0, // Max package (ALL)
[
0, // Stacks. Anything below 1 will become 1
FX_buildPackage(
0, // Last 10 seconds.
0, // Flags
"", // Name of package.
[ // FX arrays
FX_buildFX(fx$DAMAGE_DURABILITY, [-10]) // Do -10 damage (heal 10 HP)
],
[], // Conditions: None used
[], // Events: None used
[], // Tags: none used
0, // Minimum conditions needed
0, // Max stacks: Not used
0 // Ticking: Not used
)
]
);
list passive = [
FXCUpd$PROC, Passives_buildProc(
// Trigger
[
Passives_buildTrigger(
Passives$TARG_SELF, // Wrapper target
"got SpellMan", // Event script
SpellManEvt$complete, // Event from that script that we are listening for. See got SpellMan.lsl for the event definition
[
0 // Event arg 1 (spell_index in SpellManEvt$complete must be 0 (spell 5 has ID 0)
],
0 // Any range
)
],
0, // max targets
1, // Proc chance
10, // Cooldown in seconds
0, // Flags
healWrapper
)
];
// Method to send a wrapper to a player or NPC
Passives$set(llGetOwner(), "myHealPassive", passive, 0);