Lua functions

AddSkillBonus

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

Historical signature: AddSkillBonus(spawn, skill_id, value)

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

Function: AddSkillBonus(spawn, skill_id, value)

Description: Adds a nonzero skill bonus to Players or NPCs. In an active, bound spell context, the bonus uses the current spell ID and applies to its living, eligible targets; a resisted spell applies nothing. Otherwise it applies to spawn under spell ID zero.

Parameters:

  • spawn (Spawn) - Player or NPC used when there is no active, bound spell context.
  • skill_id (int32) - Skill ID, for example from GetSkillIDByName.
  • value (number) - Nonzero floating-point bonus. Effective skill calculations truncate each bonus to an integer.

Returns: None.

Bonus storage: The engine owns spell rows and their skill values. Player additions replace the value for an existing spell/skill pair; NPC additions preserve the first value for that pair and adjust current and maximum values once. Internal readers receive owned copies, so updating or removing the stored row does not invalidate a previously captured value. This does not change the Lua signature or return values.

Spell caster lifetime: When this function reads a spell's caster, it retains that allocation for the native operation. Retirement or callback reentry cannot replace its caster with a different allocation at the same address or runtime ID. A known expired or cleared caster is not rediscovered through a replacement connection. An actor already owned by the active callback remains usable through that callback. See Lua actor lifetime.

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.

AddSkillBonus(Target, GetSkillIDByName("Focus"), Focus)

Evidence: server/Spells/AA/UnwaveringResolve.lua:14; binding EQ2Emu_lua_AddSkillBonus.

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