eq2emu/docs/lua_functions/AddSpellTimer.md

32 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2025-05-28 21:48:33 -04:00
### Function: AddSpellTimer(DelayMS, FunctionName, Caster, Target)
2025-05-04 14:34:15 -04:00
2025-05-28 21:48:33 -04:00
**Description:** Used only in a Spell Script. Schedules a call to a function (by name) in the spawns script after a specified delay in milliseconds. This is typically used within NPC scripts to create timed events (like delayed attacks or actions) without blocking the main thread.
2025-05-04 14:34:15 -04:00
2025-05-28 21:48:33 -04:00
**Parameters:**
2025-05-04 14:34:15 -04:00
2025-05-28 21:48:33 -04:00
`DelayMS`: Int32 The delay in milliseconds before the function is called.
`FunctionName`: String The name of the function in the NPCs Lua script to call when the timer expires.
`Caster`: Spawn The source spawn who was the caster/originator.
`Target`: Spawn The target spawn who will be included as a secondary argument
2025-05-04 14:34:15 -04:00
2025-05-28 21:48:33 -04:00
**Returns:** None.
2025-05-04 14:34:15 -04:00
2025-05-28 21:48:33 -04:00
**Example:**
```lua
2025-05-14 09:46:52 -04:00
-- taken from Spells/Commoner/Knockdown.lua
-- Timer argument taken from spell data in the database, after Timer elapses we call RemoveStunBlur
function cast(Caster, Target, Timer)
if not IsEpic(Target) then
PlayAnimation(Target, 72)
AddControlEffect(Target, 4)
BlurVision(Target, 1.0)
AddSpellTimer(Timer, "RemoveStunBlur")
end
end
function RemoveStunBlur(Caster, Target)
RemoveControlEffect(Target, 4)
BlurVision(Target, 0)
2025-05-28 21:48:33 -04:00
end
```