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.