Lua functions

SummonPet

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

Historical signature: SummonPet(spawn, pet_id, max_level)

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

Function: SummonPet(spawn, pet_id, max_level)

Description: Create a summoned combat pet from an NPC database definition during a spell callback. The pet receives the owner's faction and level, capped by max_level when nonzero, the summoning spell identity, and a combat-pet brain. The new actor has an explicit construction owner until publication. A configured pet script's prespawn callback can resolve it through GetPet(spawn); cancellation before publication returns nil and retires the abandoned actor.

Parameters:

  • spawn (Spawn) - Player or NPC entity that will own the pet.
  • pet_id (uint32) - Nonzero NPC database spawn ID, not a runtime ID or client index.
  • max_level (uint8, optional; default 0) - Maximum pet level; 0 uses the owner's level.

Returns: The created pet Spawn object, or nil for an invalid owner, existing combat pet, missing/invalid NPC definition, unavailable or resisted spell, canceled construction, or rejected admission. Failed construction releases its server allocation through retirement.

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.

SummonPet(Caster, PetID, MaxLvl)

Evidence: server/Spells/ClassicRefresh/Mage/Enchanter/Illusionist/Personae-2552540.lua:13; binding EQ2Emu_lua_SummonPet.

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