Lua functions

AddImmunitySpell

Registered in this checkout as EQ2Emu_lua_AddImmunitySpell; implementation found at WorldServer/Lua/LuaFunctions.cpp:10897.

Historical signature: AddImmunitySpell(ImmunityType, Spawn)

Parameter and behavior details in the historical explanation are under review against the current implementation.

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.

Checked example

Active call in a local runtime Lua script. Argument count matches current fixed C++ readers. This is a contextual call pattern, not a tested standalone script.

AddImmunitySpell(7, Target)

Evidence: server/Spells/AA/AdvanceWarning.lua:12; binding EQ2Emu_lua_AddImmunitySpell.

Current registration: WorldServer/Lua/LuaInterface.cpp. Historical explanation: EQ2Emu Lua documentation.