Function: AddImmunitySpell(ImmunityType, Spawn)
Description: Add an Immunity to the Spawn by the Immunity Type.
Parameters:
ImmunityType: UInt8 - Immunity Type to add.Spawn: Spawn - Spawn to apply immunity.
Returns: None.
Notes:
- See IMMUNITY_TYPE defines for more details.
- Requires a current spell script; a resisted spell adds no immunity. Use
AddImmunityType(Spawn, ImmunityType)for a direct spawn-script grant. - If Spawn is specified only the Spawn receives the Immunity, otherwise if it is in a Spell Script we will apply to all Spell Targets.
Original spell targets: When this function uses a spell's target list, it snapshots references to the originally selected actor allocations. It skips unavailable or departed targets instead of selecting another actor with a reused runtime ID. Accepted actors remain physically retained through the active protected callback, including Lua errors; saved userdata and target records do not keep them alive between callbacks. Explicit Spawn arguments retain their existing selection behavior. See Lua actor lifetime.