Lua functions

CastEntityCommand

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

Historical signature: CastEntityCommand(caster, target, id, command)

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

Function: CastEntityCommand(caster, target, id, command)

Description: Requests a named entity command from its command list, using a connected Player as caster and a non-Player spawn as target. The caster and target must share the operation zone. Commands with a cast time complete after their timer expires; instant commands execute immediately when the session is available.

Parameters:

  • caster (Spawn) - Connected Player that issues the command.
  • target (Spawn) - Non-Player spawn receiving the command.
  • id (uint32) - Entity-command list ID used for descriptor lookup.
  • command (string) - Command name to find in that list.

Returns: None.

Delayed completion: Catalogue lookup returns an owned command value. Catalogue reload or removal cannot invalidate that value before the request enters its command timer.

The request owns a command snapshot and remembers the original actor allocations. Before startup, it retains neither actor. A busy session postpones startup; the full cast duration begins after the original session admits its Player and UI. Pending startup never switches to a replacement Player or connection. Changed or removed producer descriptors cannot change an admitted timer's text. Expired actors do not redirect the command to replacements with the same runtime IDs. Completion retains admitted actors through script and command handling. An admitted timed cast owns the original Player's cast flag and spell-lock changes until completion or cancellation; cleanup cannot clear a newer cast's ownership or later spell-status changes. An already-started cast can finish after reconnect when the original Player allocation resumes. A busy completion retries on a later tick; Player replacement or zoning during the spawn script stops subsequent command handling. See Lua actor lifetime.

Connection lifetime: Each player or group-member connection resolved by this function is retained through the native call. A disconnect or reconnect during a callback cannot destroy that retained connection or switch the ongoing call to a replacement. A later Lua call resolves the current connection. This does not extend the lifetime of unrelated spawn or item userdata.

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.

CastEntityCommand(Player, target, 1312, "Reap")

Evidence: server/ItemScripts/SpiritReaper.lua:15; binding EQ2Emu_lua_CastEntityCommand.

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