scripting

package
v0.0.0-...-f18b069 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: GPL-3.0 Imports: 25 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PlayerEventFirstLogin        = 30
	PlayerEventCharacterCreate   = 1 // OnCreate fires with the live Player*; Go has no player object at create time, so the engine never fires this event
	PlayerEventCharacterDelete   = 2
	PlayerEventLogin             = 3
	PlayerEventLogout            = 4
	PlayerEventSpellCast         = 5 // OnSpellCast fires from finishSpellCast (client/item casts) and castSpellDirectWithOverrides (triggered casts); the spell object is luaSpellObject (lua_spell.go)
	PlayerEventDuelRequest       = 9
	PlayerEventDuelStart         = 10
	PlayerEventDuelEnd           = 11
	PlayerEventKillPlayer        = 6
	PlayerEventKillCreature      = 7
	PlayerEventKilledByCreature  = 8
	PlayerEventGiveXP            = 12
	PlayerEventLevelChange       = 13
	PlayerEventMoneyChange       = 14 // OnMoneyChanged fires from Player::ModifyMoney (Player.cpp:22826); Go fires it from session modifyPlayerMoney (quest_reward_grant.go), which every ModifyMoney-equivalent money write routes through; direct SetMoney-style writes (GM set, SetCoinage, values-table write) fire nothing, like C++
	PlayerEventReputationChange  = 15
	PlayerEventTalentChange      = 16 // OnTalentsChange fires from Player::SetFreeTalentPoints; Go fires it from the shared setter (skills.go setFreeTalentPointsOverride), the learn/reset/level-up recompute arms (fireTalentPointsChanged) and the login-load recompute (handlePlayerLogin, LoadFromDB :17979), matching the C++ SetFreeTalentPoints calls in LearnTalent/ResetTalents/InitTalentForLevel
	PlayerEventTalentReset       = 17 // OnTalentsReset fires from Player::ResetTalents (Player.cpp:3992, first statement, before the no-talents/cost arms); Go fires it from resetTalents (skills.go), covering the Lua binding, at-login reset, .reset talents and talent-wipe confirm
	PlayerEventChat              = 18
	PlayerEventWhisper           = 19
	PlayerEventGroupChat         = 20
	PlayerEventGuildChat         = 21
	PlayerEventChannelChat       = 22
	PlayerEventEmote             = 23
	PlayerEventTextEmote         = 24
	PlayerEventSave              = 25
	PlayerEventBindToInstance    = 26 // OnBindToInstance fires from Player::BindToInstance (Player.cpp:19121, ScriptMgr.cpp:2162); Go fires it from the instance-lock-response bind write (engine/world/group.go), the one bind site modeled as BindToInstance; worldport instance-save creation does not bind the player and fires nothing
	PlayerEventUpdateZone        = 27
	PlayerEventMapChange         = 28
	PlayerEventEquip             = 29
	PlayerEventCanUseItem        = 31
	PlayerEventLootItem          = 32
	PlayerEventEnterCombat       = 33 // OnPlayerEnterCombat fires from CombatManager::NotifyAICombat per new combat reference; Go fires it from markPlayerInCombat (combat.go) on the false->true UNIT_FLAG_IN_COMBAT transition at every combat-enter site, the first-ref twin (no ref model)
	PlayerEventLeaveCombat       = 34 // OnPlayerLeaveCombat fires from CombatManager reference teardown (CombatManager.cpp:88-337); Go fires it from markPlayerOutOfCombat (combat.go) on the true->false UNIT_FLAG_IN_COMBAT transition at every combat-leave site, the last-ref twin (no ref model)
	PlayerEventRepop             = 35
	PlayerEventResurrect         = 36
	PlayerEventLootMoney         = 37
	PlayerEventQuestAbandon      = 38
	PlayerEventLearnTalents      = 39 // OnLearnTalents fires from Player::LearnTalent (Player.cpp:25559, success path); Go fires it from learnTalent (skills.go), covering the Lua binding and both client opcode paths (CMSG_LEARN_TALENT / CMSG_LEARN_PREVIEW_TALENTS)
	PlayerEventQuestStatusChange = 40 // OnQuestStatusChange fires from Player::AddQuest/RewardQuest/SetQuestStatus/quest-abandon/EffectQuestClear (ScriptMgr.cpp:2194); Hooks.h marks 40 UNUSED and ScriptMgr::OnQuestStatusChange is PlayerScript-only (no Eluna call), so Go event 40 is a custom extension surfacing that hook to Lua as (event, player, questId), void
	PlayerEventCommand           = 42
	MapEventOnPlayerEnter        = 21
	MapEventOnPlayerLeave        = 22
)
View Source
const (
	GuildEventOnAddMember     = 1
	GuildEventOnRemoveMember  = 2
	GuildEventOnMotdChange    = 3
	GuildEventOnInfoChange    = 4
	GuildEventOnCreate        = 5
	GuildEventOnDisband       = 6
	GuildEventOnMoneyWithdraw = 7
	GuildEventOnMoneyDeposit  = 8
	GuildEventOnItemMove      = 9
	GuildEventOnEvent         = 10
	GuildEventOnBankEvent     = 11
)

Eluna GuildEvents contract for RegisterGuildEvent. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/Hooks.h GuildEvents): 1-11 are all fired by Eluna::GuildHooks; only the events the engine fires carry Go constants.

View Source
const (
	GroupEventOnMemberAdd    = 1
	GroupEventOnMemberInvite = 2
	GroupEventOnMemberRemove = 3
	GroupEventOnLeaderChange = 4
	GroupEventOnDisband      = 5
	GroupEventOnCreate       = 6
)

Eluna GroupEvents contract for RegisterGroupEvent. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/Hooks.h GroupEvents): GROUP_EVENT_ON_CREATE (6) has no fire site in this fork — Eluna::GroupHooks::OnCreate is never called from ScriptMgr or Group — so it is documented but never fired by the engine.

View Source
const (
	VehicleEventOnInstall          = 1
	VehicleEventOnUninstall        = 2
	VehicleEventOnInstallAccessory = 4
	VehicleEventOnAddPassenger     = 5
	VehicleEventOnRemovePassenger  = 6
)

Eluna VehicleEvents contract for RegisterVehicleEvent. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/Hooks.h VehicleEvents): 3 is UNUSED in C++ and carries no Go constant. The engine fires all five live events; the vehicle argument is the base creature object (Go has no Vehicle userdata type — see triggerVehicleEvent in engine/world).

View Source
const (
	GameObjectEventOnAIUpdate      = 1
	GameObjectEventOnSpawn         = 2
	GameObjectEventOnDummyEffect   = 3
	GameObjectEventOnQuestAccept   = 4
	GameObjectEventOnQuestReward   = 5
	GameObjectEventOnDialogStatus  = 6
	GameObjectEventOnDestroyed     = 7
	GameObjectEventOnDamaged       = 8
	GameObjectEventOnLootState     = 9
	GameObjectEventOnGOStateChange = 10
	GameObjectEventOnAdd           = 12
	GameObjectEventOnRemove        = 13
	GameObjectEventOnUse           = 14
)

Eluna GameObjectEvents contract for RegisterGameObjectEvent. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/Hooks.h GameObjectEvents): 11 is UNUSED in C++ and carries no Go constant; only the events the engine fires carry Go constants.

View Source
const (
	ItemEventOnDummyEffect = 1
	ItemEventOnUse         = 2
	ItemEventOnQuestAccept = 3
	ItemEventOnExpire      = 4
	ItemEventOnRemove      = 5
)

Eluna ItemEvents contract for RegisterItemEvent. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/Hooks.h ItemEvents). The engine fires ON_USE (2), ON_QUEST_ACCEPT (3) and ON_EXPIRE (4); ON_DUMMY_EFFECT (1) and ON_REMOVE (5) carry constants but have no Go fire sites (documented in engine/world/item_hooks.go).

View Source
const (
	GossipEventOnHello  = 1
	GossipEventOnSelect = 2
)

Eluna GossipEvents contract shared by RegisterCreatureGossipEvent, RegisterGameObjectGossipEvent, RegisterItemGossipEvent and RegisterPlayerGossipEvent. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/Hooks.h GossipEvents). The engine fires the item gossip arms (ON_HELLO, ON_SELECT) via TriggerItemGossipEvent; the creature arms fire inline in engine/world/gossip.go; the gameobject hello arm fires via TriggerGameObjectGossipEvent from handleGameObjectUse; the gameobject select arm fires via TriggerGameObjectGossipEvent from the gameobject branch of handleGossipSelectOption (gameobject_hooks.go), and the player select arm fires via TriggerPlayerGossipEvent from the player branch — both keyed like their Eluna bindings (HandleGossipSelectOptionOpcode, MiscHandler.cpp:138-227).

View Source
const (
	InstanceEventOnInitialize             = 1
	InstanceEventOnLoad                   = 2
	InstanceEventOnUpdate                 = 3
	InstanceEventOnPlayerEnter            = 4
	InstanceEventOnCreatureCreate         = 5
	InstanceEventOnGameObjectCreate       = 6
	InstanceEventOnCheckEncounterProgress = 7
	// InstanceEventOnSetData is a Go-only extension: the fork's Eluna
	// InstanceEvents enum ends at 7 (LuaEngine/Hooks.h
	// INSTANCE_EVENT_COUNT), and C++ InstanceScript::SetData has no
	// Eluna hook — the C++ instance script IS the SetData consumer.
	// Go has no C++ instance script (the instance script is Lua), so
	// the InstanceData:SetData write path (engine/world/
	// instance_hooks.go) fires this event with (event,
	// instance_data, map, type, data), letting the Lua instance
	// script run the SetData switch (e.g. Eye of Eternity
	// DATA_VORTEX_HANDLING -> VortexHandling).
	InstanceEventOnSetData = 8
	// InstanceEventOnUnitDeath is a Go-only extension on the same
	// free-slot precedent: C++ InstanceScript::OnUnitDeath
	// (ZoneScript.h) has no Eluna hook, but the C++ instance script
	// IS the OnUnitDeath consumer (e.g. Drak'Tharon Keep forwards
	// crystal-handler deaths to Novos). Go has no C++ instance
	// script, so the creature death path (engine/world/kill.go
	// clearCreatureDeathState, the Unit::setDeathState twin, plus the
	// session onCreatureKilled funnel arm) fires this event with
	// (event, instance_data, map, unit), letting the Lua instance
	// script run the OnUnitDeath switch. Fires for creature deaths
	// only; player deaths in instances take a separate session path
	// with no fire yet.
	InstanceEventOnUnitDeath = 9
)

Eluna InstanceEvents contract for RegisterMapEvent/RegisterInstanceEvent. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/Hooks.h InstanceEvents). RegisterMapEvent binds a map ID (Go kind "map:<mapID>"); RegisterInstanceEvent binds an instance ID (Go kind "instance:<id>") — C++ fires both binding maps at every fire site (LuaEngine/InstanceHooks.cpp START_HOOK). The engine fires ON_UPDATE (3), ON_PLAYER_ENTER (4), ON_CREATURE_CREATE (5), ON_GAMEOBJECT_CREATE (6) and ON_CHECK_ENCOUNTER_IN_PROGRESS (7); ON_INITIALIZE (1) is #ifndef TRINITY-dead in C++ on this fork and ON_LOAD (2) fires from the worldport entry path (engine/world/instance_hooks.go fireInstanceLoad), once per (map, instance) per server run, before ON_PLAYER_ENTER. ON_SET_DATA (8) is the Go-only extension above, fired from the InstanceData:SetData write path.

View Source
const (
	ServerEventAddonMessage = 30
	// ServerEventLuaStateClose is ELUNA_EVENT_ON_LUA_STATE_CLOSE
	// (LuaEngine/Hooks.h:123 = 16, args (event)): fires just before the
	// Lua state shuts down (on shutdown and restart). The Go engine fires
	// it at the end of Server.Stop, after WORLD_EVENT_ON_SHUTDOWN (15),
	// matching the C++ teardown order (World::ShutdownServ, then Eluna
	// destruction -> CloseLua -> OnLuaStateClose, LuaEngine.cpp:202).
	ServerEventLuaStateClose = 16
	// ServerEventLuaStateOpen is ELUNA_EVENT_ON_LUA_STATE_OPEN
	// (LuaEngine/Hooks.h:153 = 33, args (event)): fires after all scripts
	// are loaded. The Go engine fires it at the end of Runtime.Load,
	// matching Eluna::LoadScripts (LuaEngine.cpp:520).
	ServerEventLuaStateOpen = 33
	// ServerEventAreaTrigger is the Eluna TRIGGER_EVENT_ON_TRIGGER
	// (LuaEngine/Hooks.h:135 = 24, args (event, player, triggerId)):
	// ServerHooks.cpp:115-125 fires it from
	// WorldSession::HandleAreaTriggerOpcode (MiscHandler.cpp:678) after
	// the radius validation, and a boolean true return vetoes the rest
	// of the handler (CallAllFunctionsBool).
	ServerEventAreaTrigger = 24
	// ServerEventPacketReceive is SERVER_EVENT_ON_PACKET_RECEIVE
	// (LuaEngine/Hooks.h:108 = 5, args (event, packet, player) - player only
	// if accessible): fires on every received packet before the opcode
	// handler. Each hook's first return is a boolean (false blocks the
	// handler) and the second return may be a Packet userdata that replaces
	// the packet the handler sees (LuaEngine/PacketHooks.cpp:93-115,
	// CallOneFunction(n, 2, 2)).
	ServerEventPacketReceive = 5
	// ServerEventPacketSend is SERVER_EVENT_ON_PACKET_SEND
	// (LuaEngine/Hooks.h:110 = 7, args (event, packet, player) - player only
	// if accessible): fires on every outgoing packet. Each hook's first
	// return is a boolean (false drops the packet); Lua receives a copy and
	// cannot alter the outgoing packet (LuaEngine/PacketHooks.cpp:42-80,
	// CallOneFunction(n, 2, 1)).
	ServerEventPacketSend = 7
	// ServerEventOpenStateChange is WORLD_EVENT_ON_OPEN_STATE_CHANGE
	// (LuaEngine/Hooks.h:129 = 8, args (event, open)): World::SetClosed
	// inverts the value for scripters (World.cpp:208), so "closed on"
	// pushes open=false and "closed off" pushes open=true.
	ServerEventOpenStateChange = 8
	// ServerEventConfigLoad is WORLD_EVENT_ON_CONFIG_LOAD
	// (LuaEngine/Hooks.h:114 = 9, args (event, reload)): C++ fires
	// OnConfigLoad(false) from World.cpp:2208 after Eluna scripts run,
	// before OnStartup (Main.cpp:336), and OnConfigLoad(true) on config
	// reload (World.cpp:1533). The Go engine fires only the initial
	// arm, immediately before the startup fire below; Go has no config
	// reload, so the reload arm stays out.
	ServerEventConfigLoad = 9
	// ServerEventShutdownInit is WORLD_EVENT_ON_SHUTDOWN_INIT
	// (LuaEngine/Hooks.h:116 = 11, args (event, code, mask)):
	// ServerHooks.cpp:282-288 fires it from World::ShutdownServ
	// (World.cpp:3022) after the initial countdown message, with the
	// ShutdownExitCode (0 shutdown, 2 restart) and ShutdownMask
	// (World.h:54-58: 1 restart, 2 idle, 4 force).
	ServerEventShutdownInit = 11
	// ServerEventShutdownCancel is WORLD_EVENT_ON_SHUTDOWN_CANCEL
	// (LuaEngine/Hooks.h:117 = 12, args (event)): ServerHooks.cpp:290-295
	// fires it from World::ShutdownCancel (World.cpp:3069) after the
	// cancel broadcast, only when a timer actually existed.
	ServerEventShutdownCancel = 12
	// ServerEventMapUpdate is MAP_EVENT_ON_UPDATE
	// (LuaEngine/Hooks.h:132 = 23, args (event, map, diff)):
	// ServerHooks.cpp:354-360 fires it from ScriptMgr::OnMapUpdate
	// (ScriptMgr.cpp:1560), called from Map::Update (Map.cpp:907) on
	// every map update. The Go engine fires it from the world tick
	// for each map carrying at least one session; a player-less Go
	// map has no materialized update at all, so it never fires (the
	// same scope rule as updateInstanceScriptTicks).
	ServerEventMapUpdate = 23
	// ServerEventGameEventStart is GAME_EVENT_START
	// (LuaEngine/Hooks.h:155 = 34, args (event, gameeventid)):
	// GameEventMgr::StartEvent fires it via Eluna::OnGameEventStart
	// (GameEventMgr.cpp:152/179, ServerHooks.cpp:90-95) once the event
	// is active. The Go engine fires it from the world tick when a
	// GAMEEVENT_NORMAL event enters the cached active set (see
	// game_event_hooks.go); world-event states stay inactive, matching
	// the idle-GameEventMgr stance in conditions.go.
	ServerEventGameEventStart = 34
	// ServerEventGameEventStop is GAME_EVENT_STOP
	// (LuaEngine/Hooks.h:156 = 35, args (event, gameeventid)):
	// GameEventMgr::StopEvent fires it via Eluna::OnGameEventStop
	// (GameEventMgr.cpp:229, ServerHooks.cpp:97-101) once the event is
	// no longer active. Go fires it from the same tick diff, after the
	// starts, mirroring GameEventMgr::Update's activate-then-deactivate
	// order (GameEventMgr.cpp:1143-1156).
	ServerEventGameEventStop = 35
	// ServerEventWeatherChange is WEATHER_EVENT_ON_CHANGE
	// (LuaEngine/Hooks.h:137 = 25, args (event, zoneId, state, grade)):
	// Weather::UpdateWeather fires it via ScriptMgr::OnWeatherChange
	// only when players in the zone received the packet (Weather.cpp),
	// with state from GetWeatherState and grade the clamped intensity.
	ServerEventWeatherChange = 25
	// ServerEventAuctionAdd/Remove/Successful/Expire are the Eluna
	// AUCTION_EVENT_ON_* hooks (LuaEngine/Hooks.h:141-144 = 26-29,
	// args (event, auctionId, owner, item, expireTime, buyout,
	// startBid, currentBid, bidderGUIDLow)): ServerHooks.cpp
	// OnAdd/OnRemove/OnSuccessful/OnExpire push them from
	// ScriptMgr::OnAuctionAdd/Remove/Successful/Expire
	// (AuctionHouseMgr.cpp). All four share the C++ prologue gate:
	// the owner must be online (FindPlayer) and the item must resolve
	// in the auction item map (GetAItem), else nothing fires.
	ServerEventAuctionAdd        = 26
	ServerEventAuctionRemove     = 27
	ServerEventAuctionSuccessful = 28
	ServerEventAuctionExpire     = 29
	// ServerEventDeleteCreature / ServerEventDeleteGameObject are the
	// Eluna WORLD_EVENT_ON_DELETE_CREATURE/GAMEOBJECT hooks
	// (LuaEngine/Hooks.h:149-150 = 31/32, args (event, creature) /
	// (event, gameobject)): Map::AddObjectToRemoveList (Map.cpp:3545-3553)
	// fires them when an object is queued for deletion, before
	// CleanupsBeforeDelete — not on RemoveFromWorld (that is creature
	// event 37 / GO event 13 territory). Go has no deferred remove list,
	// so the fires land at the permanent-deletion point of each leg.
	ServerEventDeleteCreature   = 31
	ServerEventDeleteGameObject = 32
)

Eluna ServerEvents contract for RegisterServerEvent. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/Hooks.h ServerEvents); only the events the engine fires carry Go constants.

View Source
const (
	// BGEventOnStart is BG_EVENT_ON_START (args (event, bg, bgId,
	// instanceId)): fires when a match starts.
	BGEventOnStart = 1
	// BGEventOnEnd is BG_EVENT_ON_END (args (event, bg, bgId,
	// instanceId, winner)): fires when a match ends; winner is the
	// TeamId index (0 Alliance, 1 Horde, 2 neutral/draw).
	BGEventOnEnd = 2
	// BGEventOnCreate is BG_EVENT_ON_CREATE (args (event, bg, bgId,
	// instanceId)): fires when a battleground state materializes.
	BGEventOnCreate = 3
	// BGEventOnPreDestroy is BG_EVENT_ON_PRE_DESTROY (args (event, bg,
	// bgId, instanceId)): fires when a battleground state is removed.
	BGEventOnPreDestroy = 4
)

Eluna BGEvents contract for RegisterBGEvent. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/Hooks.h:334-337). All four carry the "Needs to be added to TC" comment there: no ScriptMgr call site invokes OnBGStart/OnBGEnd/OnBGCreate/OnBGDestroy in C++, so the events never fire upstream. The Go engine fires them at its own battleground lifecycle legs (world/triggerBGEvent) so registered handlers are no longer dead; only the events the engine fires carry Go constants.

View Source
const (
	CreatureEventOnEnterCombat             = 1
	CreatureEventOnLeaveCombat             = 2
	CreatureEventOnTargetDied              = 3
	CreatureEventOnDied                    = 4
	CreatureEventOnSpawn                   = 5
	CreatureEventOnReachWP                 = 6
	CreatureEventOnAIUpdate                = 7
	CreatureEventOnReceiveEmote            = 8
	CreatureEventOnDamageTaken             = 9
	CreatureEventOnPreCombat               = 10
	CreatureEventOnHealReceived            = 11
	CreatureEventOnOwnerAttacked           = 12
	CreatureEventOnOwnerAttackedAt         = 13
	CreatureEventOnHitBySpell              = 14
	CreatureEventOnSpellHitTarget          = 15
	CreatureEventOnJustSummonedCreature    = 19
	CreatureEventOnSummonedCreatureDespawn = 20
	CreatureEventOnSummonedCreatureDied    = 21
	CreatureEventOnSummoned                = 22
	CreatureEventOnReset                   = 23
	CreatureEventOnReachHome               = 24
	CreatureEventOnCorpseRemoved           = 26
	CreatureEventOnMoveInLOS               = 27
	// CreatureEventOnMovementInform is the Go-side MovementInform hook
	// (event 28, args (event, creature, type, id)): C++ motion-master
	// generators call AI->MovementInform(type, id) on finalize, and
	// Eluna turns WAYPOINT_MOTION_TYPE into ON_REACH_WP (6) while the
	// other types reach this hook — POINT (8, MovePoint id),
	// EFFECT (16, MoveJump id), FOLLOW (14, target GUID counter).
	// CHASE (5) has no Go finalize arm (Go's chase re-paths instead
	// of finalizing) and no in-tree consumer needs it.
	CreatureEventOnMovementInform = 28
	CreatureEventOnDummyEffect    = 30
	CreatureEventOnQuestAccept    = 31
	CreatureEventOnQuestReward    = 34
	CreatureEventOnDialogStatus   = 35
	CreatureEventOnAdd            = 36
	CreatureEventOnRemove         = 37
	// CreatureEventOnDoAction is a Go-side extension (no C++ Eluna hook):
	// CreatureAI::DoAction dispatches through the AI virtual table, which
	// Lua-ported AIs have no bearer for, so creature:DoAction(action) is
	// the transport — it fires (event, creature, action) on the entry
	// then unique bindings, the void-hook twin of the other creature
	// events (C++ DoAction returns void, so returns are discarded). 38
	// is unused in the TrinityCore LuaEngine CreatureEvents numbering.
	CreatureEventOnDoAction = 38
	// CreatureEventOnSpellClick is a Go-side extension (no C++ Eluna hook):
	// CreatureAI::OnSpellClick dispatches through the AI virtual table, which
	// Lua-ported AIs have no bearer for, so the spell-click funnel fires
	// (event, creature, clicker, handled) on the entry then unique bindings,
	// the void-hook twin of the other creature events (C++ OnSpellClick
	// returns void, so returns are discarded). 39 is unused in the
	// TrinityCore LuaEngine CreatureEvents numbering.
	CreatureEventOnSpellClick = 39
	// CreatureEventOnSetGUID is a Go-side extension (no C++ Eluna hook):
	// CreatureAI::SetGUID dispatches through the AI virtual table, which
	// Lua-ported AIs have no bearer <redacted>, so creature:SetGUID(guid, id) is
	// the transport — it fires (event, creature, guid, id) on the entry
	// then unique bindings, the void-hook twin of the other creature
	// events (C++ SetGUID returns void, so returns are discarded). The
	// guid is the low half (GetGUIDLow convention): packed GUIDs lose
	// bits through Lua numbers, so senders pass the counter half and
	// receivers resolve it with GetCreatureByGUID. 40 is the next free
	// slot after the DoAction-38 / SpellClick-39 precedents.
	CreatureEventOnSetGUID = 40
	// CreatureEventOnSetData is a Go-side extension (no C++ Eluna hook):
	// CreatureAI::SetData dispatches through the AI virtual table, which
	// Lua-ported AIs have no bearer of, so creature:SetData(type, data) is
	// the transport — it fires (event, creature, type, data) on the entry
	// then unique bindings, the void-hook twin of the other creature
	// events (C++ SetData returns void, so returns are discarded). The
	// store write still lands first, so a handler reading GetData sees
	// the new value. 41 is the next free slot after the SetGUID-40
	// precedent.
	CreatureEventOnSetData = 41
)

Eluna CreatureEvents contract for RegisterCreatureEvent / RegisterUniqueCreatureEvent. The world engine fires these through TriggerCreatureEvent; scripts use the raw event numbers. Numbering is the TrinityCore LuaEngine numbering (LuaEngine/GlobalMethods.h CreatureEvents, hooks fired in LuaEngine/CreatureHooks.cpp): 16-18, 25, 29, 32-33 are UNUSED in C++ and carry no Go constant. 28 is likewise unused in C++ Eluna; Go assigns it to CreatureEventOnMovementInform below, a Go-side extension on the free slot (the DoAction-38 precedent), matching the event number every in-tree "no ev28" note cites. 11 is likewise unused by C++ Eluna (CreatureHooks has no heal hook); Go uses it for CreatureEventOnHealReceived, a Go-side extension fired from the Unit::DealHeal AI-hook arm, not a C++ Eluna event.

View Source
const (
	AuraEventOnPeriodic         = 1
	AuraEventOnApply            = 2
	AuraEventOnRemove           = 3
	AuraEventOnChangeAmount     = 4
	AuraEventOnDispel           = 5
	AuraEventOnProc             = 6
	AuraEventOnBeforeDispel     = 7
	AuraEventOnCheckAreaTarget  = 8
	AuraEventOnEffectAbsorb     = 9
	AuraEventAfterEffectAbsorb  = 10
	AuraEventOnEffectCalcAmount = 11
)

AuraEvents contract for RegisterAuraEvent(spellID, event, fn). There is no C++ Eluna RegisterAuraEvent: this is a Go-side extension mirroring Aura::CallScriptEffectPeriodicHandlers (SpellAuras.cpp:2341-2361), the hook AuraEffect::PeriodicTick runs before its switch (SpellAuraEffects.cpp:868-872). A handler returning boolean true is the AuraScript PreventDefaultAction() arm: the default tick is skipped. The hook fires for every periodic aura type, not just PERIODIC_DUMMY (226), because C++ runs it ahead of the switch for all of them; handlers registered for a spellID see its ticks regardless of which effect index the C++ registration bound, so multi-effect auras must filter on the aura object when the C++ script bound a single effect. OnApply/OnRemove mirror AuraEffect::HandleEffect's CallScriptEffectApplyHandlers arms (SpellAuras.cpp:2341-2361 twin): they fire once per fresh application / actual removal, on both the player and creature apply/remove funnels, with args (event, aura, target) like the periodic hook. They are notification-only: a handler returning true does NOT prevent the apply/remove — the aura record is already registered (apply) or erased (remove) when the hook fires, and Go performs the default effect handling inline at several points rather than in one skippable step, so there is no veto to model. The remove hook's aura object reads the removed record's last values (a snapshot: GetCaster/GetAmount/GetTickNumber still resolve); writes to it land on the detached record and are inert. Re-casts that merge or refresh an existing aura do not re-fire OnApply. OnChangeAmount mirrors the AURA_EFFECT_HANDLE_CHANGE_AMOUNT arm of AuraEffect::ChangeAmount (SpellAuraEffects.cpp:662-683), fired by Aura::ModStackAmount/SetStackAmount (SpellAuras.cpp:1008-1030) when a merge re-cast raises the aura's stack count. A re-cast that only refreshes duration (already at max stacks, or a non-stackable aura) does not fire it — C++ ChangeAmount returns early when the amount is unchanged. Notification-only like OnApply; handlers read the new stack count via aura:GetStackAmount(). OnDispel mirrors Aura::CallScriptAfterDispel (Unit.cpp:3955): it fires once per successful dispel application, after the charge/stack decrement (ModCharges/ModStackAmount, Unit.cpp:3949-3952), with args (event, aura, target, dispeller) — the dispeller is DispelInfo::GetDispeller(). It fires whether or not the aura is fully removed, like C++; a charge/stack aura that survives the decrement still fires it. Notification-only like OnApply. The hook fires from the SPELL_EFFECT_DISPEL funnel (player, pet, and owned-creature casters), the SPELL_EFFECT_DISPEL_MECHANIC funnel, and the wild-creature dispel funnels; the aura object reads a snapshot captured before the decrement, so GetCaster still resolves after a full removal. Steal never fires it (RemoveAurasDueToSpellBySteal, Unit.cpp:3969, has no dispel-hook call). OnBeforeDispel mirrors Aura::CallScriptDispel (Unit.cpp:3947): it fires once per successful dispel application, before the charge/stack decrement, with the same args (event, aura, target, dispeller) and the same snapshot aura object as OnDispel. A handler returning boolean true is DispelInfo::SetRemovedCharges(0): the decrement is skipped and the aura keeps its charges, like C++; the AfterDispel hook still fires afterwards. It fires only from the SPELL_EFFECT_DISPEL funnels (session and wild-creature casters) — EffectDispelMechanic removes via Unit::RemoveAura (SpellEffects.cpp:4761), which calls no dispel hook, so the mechanic funnels never fire it. OnProc mirrors AuraScript::OnEffectProc (AuraEffectProcFn, SpellAuras.cpp:2192-2212 via Aura::TriggerProcOnEvent): it fires once per eligible proc effect, after the proc gates (flags, chance roll, charge/cooldown consumption) and before that effect's default leg (the DBC trigger-spell cast, the scriptAuraProcCast dummy arm, or the putricide/vampiric special cases). Args are (event, aura, target, actor, procTarget, damage, procEvent): target is the aura holder (the periodic-hook convention), actor is the proc actor as a unit object (nil when the event carries no actor GUID), procTarget is the proc target as a unit object (the triggerTargetGUID — the damage victim on the done side, the attacker on the taken side), damage is the proc event's damage (0 for non-damage events — the handler gates on it, like the C++ damageInfo->GetDamage() early return), and procEvent is the ProcEventInfo object (lua_aura.go procEventObject): GetSpellId/GetSpellIconId (0 when the event carries no spell — melee/kill events), GetSpellFamilyFlags(index) / GetRank (the event spell's family flags and chain rank — 0/no-spell reads 0 flags and rank 0; a chained spell with no rank row reads rank 1, the C++ GetRank no-chain value), GetSchoolMask (the event spell's school, or the melee/damage school), GetTypeMask/GetSpellTypeMask/GetSpellPhaseMask/ GetHitMask (the raw proc masks), GetDamage/GetHeal/GetEffectiveHeal, GetActor/GetActionTarget/GetProcTarget, IsTriggered, and the eighth arg is the effect index of the eligible effect that fired (0-based, the AuraEffectProcFn effect the script registered on); a handler ignores other indices, so a multi-effect aura's counter arm cannot double-fire. The C++ CheckProc gate (DoCheckProc) has no separate hook: a port expresses it by returning true (PreventDefaultAction, skipping the default leg) when the gate FAILS — the inverted veto, e.g. decimation (spell_warlock.lua) and culling the herd (spell_pet_hunter.lua). Absorb/resist/block/overkill are not forwarded (Go proc events carry no DamageInfo breakdown). The weapon attack type IS forwarded as procEvent:GetAttackType (lua_aura.go): the melee done-side site threads it, other events read BASE_ATTACK (0). A handler returning boolean true is PreventDefaultAction(): the default leg for that effect is skipped, matching C++ where the script handler replaces the trigger cast. Both proc loops fire it: the session loop (player and pet mod-owner auras) and the creature loop (boss_ai.go fireCreatureAuraProcLoop, creature-held auras including hunter pets). OnCheckAreaTarget mirrors AuraScript::DoCheckAreaTarget (AuraCheckAreaTargetFn, SpellScript.cpp:727-729, SpellAuras.cpp:2233- 2248): it fires when an area aura's target map is (re)computed for a candidate unit, with args (event, aura, target), and the results are ANDed — a handler returning boolean false rejects the target, so the aura is not applied to it, like C++ (Aura::CanBeAppliedOn -> CheckAreaTarget, SpellAuras.cpp:1860-1877, gates Aura::UpdateTargetMap). A handler returning true or nothing passes the target. The aura object is a pending ref: the aura is not yet applied, so GetCasterGUID/GetCaster read the incoming aura's caster and GetOwner reads nil (the C++ owner is the dynobj, which has no Lua unit object); GetAmount/GetDuration read 0. The hook fires only from the dynobj (persistent-area-aura) apply sites — the two 500ms target-map passes and the creature cast-time leg — not from single-target or non-dynobj area-aura applies, so unit area auras (paladin auras, yogg keeper aura) do not fire it yet. OnEffectAbsorb mirrors AuraScript::OnEffectAbsorb (AuraEffectAbsorbFn, SpellScript.h): it fires once per school-absorb aura effect in Unit::CalcAbsorbResist (Unit.cpp:1882-1912), with args (event, aura, target, damage, absorbAmount) — damage is the remaining damage at that aura's turn in the absorb order (dmgInfo.GetDamage()), absorbAmount is the pool the aura would absorb (GetAmount(), 0 for an unlimited -1 pool, NOT yet clamped to the remaining damage). A handler returning a number rewrites the absorb amount (clamped to [0, remaining damage] by the caller, like C++ RoundToInterval); a handler returning boolean true is PreventDefaultAction and the aura absorbs nothing this hit; nil keeps the pool candidate. The fire is deferred past the absorb loop's lock (absorption.go): Lua never runs under castMu/auraMu, so the hook sees the at-turn damage recorded in the loop while later shields have already applied — the total absorbed is identical to C++, only the pool-drain split across coexisting shields can differ. The mana-shield leg has no twin: C++ fires the separate OnEffectManaShield hook there and no in-tree script uses it. The special Go absorb legs (guardian spirit, ardent defender, astral shift, scriptAbsorbHit) run before the hook, so a Lua port of one of those spells would never fire its hook — those spells are Go-owned. AfterEffectAbsorb mirrors AuraScript::AfterEffectAbsorb (AuraEffectAbsorbFn, SpellScript.h): it fires once per school-absorb aura effect after that effect's absorb is applied in Unit::CalcAbsorbResist (Unit.cpp:1909-1912), with args (event, aura, target, damage, absorbAmount) — damage is the remaining damage after this aura's absorb, absorbAmount the amount this aura actually absorbed this hit. It is notification-only (C++ handlers return void); the fire is deferred to the same post-lock pass as OnEffectAbsorb, so all ev9 handlers run before any ev10 handler — C++ interleaves them per aura, Go batches them per pass. The generic-loop absorbs are recorded for the same pass, so an aura with no ev9 handler (ice barrier) still fires its after hook; the mana-shield loop fires the separate AfterEffectManaShield hook in C++, so mana shield never fires this one.

View Source
const (
	SpellEventOnCast                   = 1
	SpellEventOnHit                    = 2
	SpellEventAfterHit                 = 3
	SpellEventOnEffectHit              = 4
	SpellEventOnEffectHitTarget        = 5
	SpellEventBeforeHit                = 6
	SpellEventOnObjectAreaTargetSelect = 7
	SpellEventOnCheckCast              = 8
	SpellEventAfterCast                = 9
	SpellEventOnEffectLaunchTarget     = 10
)

SpellEvents contract for RegisterSpellEvent(spellID, event, fn). There is no C++ Eluna RegisterSpellEvent: this is a Go-side extension mirroring the AuraEvents one, over the SpellScript hooks in SpellScript.h. Only the hooks Go can fire exist here: OnCast mirrors Spell::CallScriptOnCastHandlers (Spell.cpp:3432, :7951), fired once per cast after target selection and before SendSpellGo, with args (event, spell); OnHit mirrors the CallScriptOnHitHandlers arm (Spell.cpp:2377, in Spell::TargetInfo::PreprocessTarget, before the effect loop deals damage in C++), fired once per unit hit target, with args (event, spell, hitTarget). All three twins fire pre-damage (boss_ai.go pass-1 position; spells.go client path and triggered funnel, moved 2026-11-09), so a handler sees the target alive on a lethal hit, like C++; the damage-rewrite legs ride the pre-damage spellScriptOnHitDamage table and the lethal-latch legs ride spellScriptOnHitLatch (spell_onhit.go) instead — GetHitDamage() still reads the pre-effect seed at OnHit, matching C++. AfterHit mirrors CallScriptAfterHitHandlers (Spell.cpp: 2659), fired once per unit hit target after the per-hit trigger consumer, with the same args. OnEffectHit mirrors CallScriptEffectHandlers in the SPELL_EFFECT_HANDLE_HIT mode (Spell.cpp:5168, called from Spell::HandleEffects; the HIT phase runs in _handle_immediate_phase, Spell.cpp:3722-3730), fired once per non-zero effect with no unit target, with args (event, spell, effectIndex). OnEffectHitTarget mirrors the same call in the SPELL_EFFECT_HANDLE_HIT_TARGET mode (Spell.cpp:2909, called from Spell::DoSpellEffectHit per unit target), fired once per (effect, live hit target) in effect-major order, with args (event, spell, hitTarget, effectIndex). BeforeHit mirrors CallScriptBeforeHitHandlers (Spell.cpp:2357, in Spell::TargetInfo::PreprocessTarget), fired once per unit hit target, miss-inclusive, with args (event, spell, hitTarget, missInfo) where missInfo is the C++ SpellMissInfo number (0 = SPELL_MISS_NONE; the Go protocol values are numerically identical). All six are notification-only: a handler returning true does NOT veto anything — C++ OnCast has no veto (CheckCast is the gate). The hit-damage legs are modeled through the per-cast spellHitDamageState (lua_spell.go): spell:GetHitDamage() reads the pre-effect seed (0 on a fresh target, Spell.cpp:2344) in BeforeHit/OnHit/OnEffectHitTarget and the final post-mitigation damage (Spell.cpp:2547) at AfterHit, and spell:SetHitDamage() writes the seed in the modifiable hooks (SpellScript.cpp:421-434) — a recorded write only, since Go's damage arms never consult the seed; it never rescales dealt damage. The record is threaded from the damage arms on all three paths (creatureEffectSpellDamage / creatureEffectSpellDamageCreature; the player paths write damageByTarget in their damage arms), so AfterHit reads the recorded final damage everywhere; the inline victim-spell path fires no SpellScript hooks at all, so no hit-damage model is needed there. GetHitHeal/SetHitHeal and PreventHitDamage have no Go model. PreventHitDefaultEffect IS modeled on the creature path: the ev4/ev5 spell object records the veto in the per-cast spellEffectPreventState (lua_spell.go), which the TriggerSpell, ForceCast, TriggerMissile, ScriptEffect and ApplyAura arms consult before running; the player path threads the record through finishSpellCast and the funnel path threads it through castSpellDirectWithOverrides, so a funnel-cast PreventHitDefaultEffect leg suppresses the default too, and for SCRIPT_EFFECT legs the Go default is a per-spell no-op unless a case exists in creatureEffectScriptEffect / handleEffectScriptEffect. The hitTarget is the Lua unit object (player or creature) or nil when the target GUID resolves to nothing; GO, item and corpse TargetInfo legs (Spell.cpp:2661-2707) have no Go model and never fire. OnEffectHitTarget fires on all three paths: the creature path, the triggered (funnel) path, and the player path (finishSpellCast's applyEffects, which re-derives the shared per-effect partition ahead of the effects switch — the damage/heal/aura arms' friendly-area / ref-centered / cone switch — since the player path resolves each effect's target list per case inside that switch). OnObjectAreaTargetSelect mirrors the SpellScript hook of the same name (SpellScript.h, fired from Spell::SelectImplicitAreaTargets, Spell.cpp:1227, inside SelectTargets ahead of OnCast at :3432), fired once per effect carrying a selecting leg (area, cone, entry or ref-centered implicit target), with args (event, spell, effectIndex, targets) where targets is a SpellTargetList object. The handler MUTATES the list through its methods — GetTargets() reads the current list as a table of unit objects, GetCount() its size, Remove(unit) drops one unit, Clear() empties it, Add(unit) appends one unit — and the mutated list is that effect's hit list for every effect arm below (the C++ std::list<WorldObject*>& mutation model); the return value is ignored. The list a handler sees is the Go per-effect partition (bossConeEffectTargets), i.e. the flat hit list for non-cone spells, minus the caster unless the effect carries a friendly area leg (C++ enemy/entry/ref/cone lists never contain the caster; friendly-area lists do). Creature path (boss_ai.go, the fire site ahead of the GO packet) and player path (finishSpellCast, the fire site after target selection and the aura-scaling arm, ahead of the GO packet; the rewritten lists reach the launch-target loop, the ev5 loop and the damage/heal/aura arms via playerSpellTargetSelectFiltered, and the other arms still iterate their own derivations). The The triggered funnel fires it too (spells.go:27682). GO-area legs (51/52/108) never fire it — the list holds units only. The deferred-fire call re-runs the cast function, so a cast-time cast fires it once, at fire time, like OnCast. OnCheckCast mirrors the SpellScript hook of the same name (SpellScript.h:342-344, fired from Spell::CheckCast, Spell.cpp:5515, via CallScriptCheckCastHandlers at :7977-7996), fired once per player-path cast at the end of the CheckCast gauntlet in handleCastSpell, after the last generic gate and before the cast is registered, with args (event, spell). Unlike the other SpellEvents it is NOT notification-only: a handler returns a SpellCastResult number; the first non-OK result fails the cast with that code (C++ keeps the first failure, Spell.cpp:7988-7990). SPELL_CAST_OK is 255 in C++ (SharedDefines.h:1171, custom value, never sent to the client), so a nil, 0, or 255 return passes and any other 1-254 value fails the cast. GetCastTime reads 0 here — C++ calculates m_casttime only after the first CheckCast (Spell.cpp:3130-3136) — and m_CastItem is nil on this path, so GetCastItem reads nil. Triggered casts never reach handleCastSpell, matching C++ TRIGGERED_IGNORE_CAST_CHECK; creature casts fire the same hook from their own gauntlet (fireCreatureSpellCheckCast, boss_ai.go). AfterCast mirrors the SpellScript hook of the same name (SpellScript.h:390, fired from Spell::_cast, Spell.cpp:3501, after the immediate/launch legs and before the spell_linked tail), fired once per cast with args (event, spell). Notification-only like OnCast: the handler cannot veto anything, it runs after the effects — the gunship incinerating-blast energy drain (spell_igb_incinerating_blast::RemoveEnergy, SetPower(ENERGY, 0)) rides it. Creature path (boss_ai.go, after the AfterHit loop) and player path (finishSpellCast, before the spell_linked tail on both branches — cast time, not missile arrival, on the delayed branch); the triggered funnel runs no AfterCast fire yet. OnEffectLaunchTarget mirrors the SpellScript hook of the same name (SpellScript.h:397, fired from Spell::HandleLaunchPhase, Spell.cpp:7753, per (effect, unit target) with m_damage reset to 0 first), fired once per (effect, live hit target) in effect-major order with args (event, spell, hitTarget, effectIndex), ahead of the default arms like OnEffectHitTarget. It IS a modifiable hook (IsInEffectHook covers LAUNCH_TARGET): a handler's SetEffectValue rewrites m_spell->damage for that (effect, target), and the creature damage arms apply the rewrite when they compute that target's base; GetEffectValue reads the rewritten value. Creature path (boss_ai.go launch pre-pass) and player path (finishSpellCast, at _cast time ahead of the delayed/immediate split); the triggered funnel runs no launch-target fire yet.

Variables

This section is empty.

Functions

func CallState

func CallState(ctx context.Context) (*lua.State, bool)

CallState returns the *lua.State of the method call in progress, if ctx is a method-dispatch context from objectIndex. Object methods that need raw stack access — WorldObject:RegisterEvent stores its callback function ref — read it here; plain value methods never do.

func GameObjectGossipKind

func GameObjectGossipKind(entry uint32) string

GameObjectGossipKind is the hook kind for RegisterGameObjectGossipEvent(entry, event, fn): "gameobject_gossip:<entry>", mirroring Eluna's GameObjectGossipBindings entry key (LuaEngine/GossipHooks.cpp).

func ItemGossipKind

func ItemGossipKind(entry uint32) string

ItemGossipKind is the hook kind for RegisterItemGossipEvent(entry, event, fn): "item_gossip:<entry>", mirroring Eluna's ItemGossipBindings entry key (LuaEngine/GossipHooks.cpp).

func PlayerGossipKind

func PlayerGossipKind(menuID uint32) string

PlayerGossipKind is the hook kind for RegisterPlayerGossipEvent(menuID, event, fn): "player_gossip:<menuID>", mirroring Eluna's PlayerGossipBindings menuId key (LuaEngine/GossipHooks.cpp:66).

func PushObject

func PushObject(state *lua.State, object *Object)

Types

type BGLive

type BGLive struct {
	Load func() (BGSnapshot, bool)
}

BGLive carries the snapshot behind a Lua BattleGround object. A nil Load or a false return means the battleground is unknown, and the methods read zero values.

type BGSnapshot

type BGSnapshot struct {
	Name              string
	MinLevel          uint32
	MaxLevel          uint32
	MinPlayers        uint32
	MaxPlayers        uint32
	MinPlayersPerTeam uint32
	MaxPlayersPerTeam uint32
	Winner            uint32
	// Status is the BattlegroundStatus at snapshot time (Battleground.h:
	// NONE 0, WAIT_QUEUE 1, WAIT_JOIN 2, IN_PROGRESS 3, WAIT_LEAVE 4),
	// and EndTime is m_EndTime in milliseconds (Battleground.cpp:512-517:
	// 0 while running, TIME_TO_AUTOREMOVE at end, decremented by
	// _ProcessLeave). Both are snapshot by the hook fire point, never
	// re-read under a state lock (see bgScriptObject).
	Status  uint32
	EndTime uint32
	// BracketID is the BattlegroundBracketId (Battleground.h:270, the
	// PvPDifficulty.dbc RangeIndex SetBracket banks at creation,
	// Battleground.cpp:1791); the C++ ctor default is BG_BRACKET_ID_FIRST
	// (0), which is also what an unbanked snapshot reads.
	BracketID uint32
	Map       *Object
	// AliveAlliance/AliveHorde are GetAlivePlayersCountByTeam's counts
	// (Battleground.cpp:1737: m_Players members of the team, online and
	// alive, excluding Spirit of Redemption form); InvitedAlliance/
	// InvitedHorde are m_InvitedAlliance/m_InvitedHorde (Battleground.h:
	// 323-327, invitees not yet removed, entered or not); PlayersAlliance/
	// PlayersHorde are GetPlayersCountByTeam's m_Players counts. All six
	// come from the world engine's slot scan at snapshot time (see
	// bgScriptObject), never re-read under a state lock.
	AliveAlliance   uint32
	AliveHorde      uint32
	InvitedAlliance uint32
	InvitedHorde    uint32
	PlayersAlliance uint32
	PlayersHorde    uint32
}

BGSnapshot is the battleground state behind a Lua BattleGround object: the fields BattleGroundMethods.h reads from the live BattleGround*. The snapshot is taken at hook-fire time (the world engine builds it before Trigger, so no method re-reads battleground state while a hook runs under a per-map state lock). Winner is the C++ PvPTeamId (SharedDefines.h:3499-3501: Horde 0, Alliance 1, Neutral 2); the world engine translates the hook's Team argument (Alliance 0, Horde 1) into it, and non-END fires read Neutral, the C++ _winnerTeamId default. MinPlayers/MaxPlayers are the per-team counts doubled (BattlegroundMgr.cpp:505-508). MinLevel/MaxLevel are the instance's m_LevelMin/m_LevelMax: the banked bracket range when the pop banked one (SetBracket, Battleground.cpp:1792), else the template row's overall range. GetBonusHonorFromKillCount therefore reads the bracket max, as C++ does (Battleground.cpp:809).

type BanArgs

type BanArgs struct {
	Mode      int
	NameOrIP  string
	Duration  uint32
	Reason    string
	WhoBanned string
}

BanArgs is the GlobalMethods::Ban argument shape: mode 0 = account, 1 = character, 2 = IP; Duration is seconds, like the C++ uint32 BanAccount overload Eluna calls. The provider returns the Eluna result int (0 success, 1 syntax, 2 not found, 3 longer/existing ban) and a non-empty luaL_argerror message for the name/IP argument when the C++ validation arm rejects it.

type Config

type Config struct {
	Enabled                      bool
	ScriptPath                   string
	CoreName                     string
	CoreVersion                  string
	RealmID                      uint32
	CoreExpansion                uint32
	PlayerProvider               func() []*Object
	GameEventProvider            func() []uint32
	GameEventControlProvider     func(eventID uint32, start, force bool)
	MapProvider                  func(mapID, instanceID uint32) *Object
	WorldMessageProvider         func(string)
	AreaNameProvider             func(id uint32) (string, bool)
	SpellFamilyFlagsProvider     func(spellID uint32, index uint32) uint32
	SpellFamilyNameProvider      func(spellID uint32) uint32
	SpellDispelTypeProvider      func(spellID uint32) uint32
	SpellPositiveProvider        func(spellID uint32) bool
	SpellItemEnchantmentProvider func(enchantID uint32, index uint32) (uint32, uint32)
	SpawnProvider                func(SpawnArgs) *Object
	TaxiPathProvider             func(TaxiPathArgs) uint32
	SendMailProvider             func(SendMailArgs) error
	VendorAddProvider            func(entry, item uint32, maxCount int32, incrTime, extCost uint32)
	VendorRemoveProvider         func(entry, item uint32) error
	VendorRemoveAllProvider      func(entry uint32)
	KickProvider                 func(playerGUID uint64)
	BanProvider                  func(args BanArgs) (int, string)
	SaveAllPlayersProvider       func()
	AuthDatabase                 *sql.DB
	CharacterDB                  *sql.DB
	WorldDatabase                *sql.DB
	Logger                       *slog.Logger
}

type GroupLive

type GroupLive struct {
	Load    func() (GroupSnapshot, bool)
	Players func() []*Object
}

GroupLive carries the live-data callbacks behind a Lua Group object. Load re-reads the roster (Eluna methods read the live Group*); Players enumerates the online player objects for the GetMembers/GetLeader filters. Either may be nil.

type GroupMemberLive

type GroupMemberLive struct {
	GUID      uint64
	Name      string
	SubGroup  uint8
	Assistant bool
}

GroupMemberLive is one live group roster entry behind a Lua Group object.

type GroupSnapshot

type GroupSnapshot struct {
	LeaderGUID uint64
	Members    []GroupMemberLive
	IsRaid     bool
	IsBG       bool
}

GroupSnapshot is the live group roster behind a Lua Group object.

type GuildLive

type GuildLive struct {
	Load    func() (GuildSnapshot, bool)
	Players func() []*Object
}

GuildLive carries the live-data callbacks behind a Lua Guild object. Load re-reads the guild row (Eluna methods read the live Guild*, not a push-time copy); Players enumerates the online player objects for the GetLeader/GetMembers filters. Either may be nil.

type GuildSnapshot

type GuildSnapshot struct {
	Name        string
	LeaderGUID  uint64
	MemberCount uint32
	MOTD        string
	Info        string
}

GuildSnapshot is the live guild row behind a Lua Guild object: the fields Eluna's GuildMethods.h reads from the live Guild*.

type Hook

type Hook struct {
	Kind  string
	Event int
}

type Int64

type Int64 int64

type ItemInstanceLive

type ItemInstanceLive struct {
	OwnerGUID         uint64
	Flags             uint32
	Count             uint32
	Durability        uint32
	Enchantments      string
	Slot              uint8
	BagSlot           uint8
	InBag             bool
	NotEmptyBag       bool
	BoundByEnchant    bool
	BOPTradeable      bool
	AllowedTradeGUIDs []uint64
	RandomPropertyId  int32
	OwnerLevel        uint32
}

ItemInstanceLive is the item_instance row plus the character_inventory position behind a Lua Item object: the fields Eluna's instance-bound Item methods read through Item itself (Item.h/Item.cpp). BagSlot is the container's slot, or INVENTORY_SLOT_BAG_0 (255) for a top-level item (Item.cpp:713-715, GetBagSlot); InBag is m_container != nullptr, i.e. the character_inventory bag column is non-zero.

type ItemInstanceUpdate

type ItemInstanceUpdate struct {
	OwnerGUID    *uint64
	Flags        *uint32
	Count        *uint32
	Enchantments *string
	// EnchantSlot marks a SetEnchantment write (never ClearEnchantment):
	// the world layer sends Item::SetEnchantment's log pair for this slot.
	EnchantSlot *uint32
}

ItemLive carries the template-data callback behind a Lua Item object. Load re-reads the item_template row (Eluna's methods read the live Item::GetTemplate()); a nil Load or a false return means the row is missing, and the template methods push nil — C++ would dereference a null template there, so Go takes the safe arm. LoadInstance re-reads the item_instance row and inventory position the same way; a nil LoadInstance means the object is template-only (loot/quest items) and the instance methods push nil. Players enumerates the online player objects for GetOwner's FindPlayer-style lookup. ItemInstanceUpdate is one persisted item_instance column write behind a Lua Item mutation: only non-nil fields are written, so a caller that computed a new value from a fresh LoadInstance read cannot clobber unrelated columns. The world loader owns the SQL; the scripting layer owns the C++ argument order and flag/enchantment-string arithmetic.

type ItemLive

type ItemLive struct {
	LoadTemplate func() (ItemTemplateLive, bool)
	LoadInstance func() (ItemInstanceLive, bool)
	// UpdateInstance persists one ItemInstanceUpdate against the
	// item_instance row; nil on template-only objects, where mutations
	// have no row and are silent no-ops. Writes land immediately, so
	// SaveToDB is a no-op flush on top of them.
	UpdateInstance func(ItemInstanceUpdate) bool
	// EnchantmentExists is the SpellItemEnchantment DBC lookup behind
	// SetEnchantment's C++ store check; nil reads as not found.
	EnchantmentExists func(uint32) bool
	// InTrade is the goroutine-safe Item::IsInTrade read (Item.h:108):
	// the world's server-guarded mirror of mb_in_trade; nil reads as
	// not in trade.
	InTrade func(uint64) bool
	Players func() []*Object
}

type ItemTemplateLive

type ItemTemplateLive struct {
	Name                              string
	Class, SubClass, DisplayInfoID    uint32
	Quality, ItemLevel, RequiredLevel uint32
	BuyPrice                          int32
	BuyCount                          uint32
	SellPrice, InventoryType          uint32
	AllowableClass, AllowableRace     uint32
	Stackable                         int32
	ContainerSlots, StatsCount        uint32
	Flags, BagFamily                  uint32
	StartQuest, ItemSet               uint32
	RandomProperty, RandomSuffix      int32
	MaxDurability                     uint32
	SpellIDs                          [5]uint32
	SpellTriggers                     [5]uint32
}

ItemTemplateLive is the item_template row behind a Lua Item object: the fields Eluna's Item methods read through Item::GetTemplate(). The spell slots mirror MAX_ITEM_PROTO_SPELLS = 5 (ItemTemplate.h:597).

type MailItemPair

type MailItemPair struct {
	Entry  uint32
	Amount uint32
}

MailItemPair is one (entry, amount) attachment pair of SendMail.

type MapLive

type MapLive struct {
	Load         func() (MapSnapshot, bool)
	InstanceData func() *Object
	Difficulty   func(context.Context) (int64, bool)
	Players      func() []MapPlayerLive
	SetWeather   func(context.Context, uint32, uint32, float32)
	// SetZoneWeatherOverride is the Go-only Map::SetZoneWeather twin
	// (Map.cpp:4783): C++ Eluna exposes no zone-override method (its
	// Map SetWeather is the Weather::SetWeather type/grade arm), so
	// boss-script ports that need raw states (LK fog/blacksnow) call
	// the Map object's SetZoneWeather (zone, state, grade) instead.
	SetZoneWeatherOverride func(context.Context, uint32, uint32, float32)
	// SetZoneLightOverride is the Go-only Map::SetZoneOverrideLight
	// twin (Map.cpp:4802): C++ Eluna exposes no light-override
	// method, so boss-script ports call the Map object's
	// SetZoneOverrideLight (zone, area, override, transition).
	SetZoneLightOverride func(context.Context, uint32, uint32, uint32, uint32)
	WorldObject          func(context.Context, uint64) *Object
	// GameObjectByLowGuid resolves a gameobject by its DB counter
	// half (the GetGUIDLow convention): Lua numbers cannot carry a
	// packed 64-bit GO GUID, so callers pass the low GUID and the
	// callback rebuilds the packed GUID from the row. A nil callback
	// reads nil.
	GameObjectByLowGuid func(context.Context, uint32) *Object
	AreaID              func(x, y, z float32) uint32
	// Height reads the .map grid height for Map::GetHeight's Eluna
	// call shape; false means no readable height chunk, and the
	// method turns that (and the INVALID_HEIGHT sentinel) into nil.
	Height func(x, y float32) (float32, bool)
	// SaveInstanceData persists the instance data table
	// (InstanceScript::SaveToDB, InstanceScript.cpp:60-71): the world
	// side marshals the registry table (scripting.MarshalInstanceData)
	// and writes it to instance.data, preserving the
	// completedEncounters mask. A nil callback leaves the method a
	// no-op, matching the old behavior for snapshot-only maps.
	SaveInstanceData func(ctx context.Context) error
}

MapLive carries the live-data callbacks behind a Lua Map object. Load re-reads the DBC entry; a nil Load or a false return means the entry is missing, and the DBC-backed methods push nil/false. Difficulty re-reads the per-instance spawn mode (Map::GetDifficulty is GetSpawnMode); a nil callback or a false return means normal mode. Players enumerates the worldReady players on this map instance; a nil callback means none. SetWeather applies a zone weather change; a nil callback drops it. WorldObject resolves a GUID to the Lua object Eluna pushes for MapMethods.h GetWorldObject (Map.cpp GetPlayer/GetCreature/GetPet/ GetGameObject/GetCorpse); a nil callback means no object resolves.

type MapPlayerLive

type MapPlayerLive struct {
	Player *Object
	IsGM   bool
	Team   uint32
}

MapPlayerLive is one live player behind a Lua Map object: the player object plus the fields MapMethods.h's GetPlayers/GetPlayerCount filters read (a session behind the player; GetPlayersCountExceptGMs skips GMs).

type MapSnapshot

type MapSnapshot struct {
	Name                                       string
	IsDungeon, IsRaid, IsArena, IsBattleground bool
}

MapSnapshot is the map DBC entry behind a Lua Map object: the fields Eluna's Map methods read through Map + sMapStore (MapMethods.h; MapEntry::IsDungeon/IsRaid/IsBattleArena/IsBattleground).

type Object

type Object struct {
	Type    string
	Methods map[string]ObjectMethod
	Fields  map[string]any
}

func NewBattleGroundObject

func NewBattleGroundObject(bgTypeID, mapID, instanceID uint32, live BGLive) *Object

NewBattleGroundObject builds the Lua BattleGround object surface for the BG_EVENT_* hooks: GetName/GetTypeId/GetMapId/GetInstanceId/GetMap/ GetMinLevel/GetMaxLevel/GetMinPlayers/GetMaxPlayers/GetMinPlayersPerTeam/ GetMaxPlayersPerTeam/GetWinner/GetBonusHonorFromKillCount/GetStatus/ GetEndTime/GetBracketId/GetAlivePlayersCountByTeam/GetFreeSlotsForTeam (BattleGroundMethods.h). GetBonusHonorFromKillCount is the pure C++ formula (Battleground.cpp:806-811): hk_honor_at_level(min(maxLevel, 80), kills) = ceil(level * 1.55 * kills), without the OnHonorCalculation script hook, which has no Go twin. GetStatus/GetEndTime/GetBracketId read the pre-fire snapshot (see bgScriptObject), not live state. GetAlivePlayersCountByTeam takes the C++ Team domain (SharedDefines.h:797-802: ALLIANCE 469, HORDE 67), not TeamId 0/1: any other argument matches no member and reads 0, like the C++ exact Team comparison against BattlegroundPlayer.Team. GetFreeSlotsForTeam ports Battleground.cpp:1126-1196 under the default Battleground.InvitationType = 0 (NO_BALANCE, World.cpp:1205): WAIT_JOIN reads the no-balance leg (MaxPlayersPerTeam minus invited, clamped at 0) and IN_PROGRESS reads the balanced diff/diff2/diff3 formula; every other status reads 0. Its else branch treats any non-ALLIANCE argument as HORDE, like the C++. DELTAS: the snapshot counts come from the Go slot roster, not m_Players: offline members in C++'s 5-minute grace are absent (no session to scan), and Spirit of Redemption form is not excluded separately (Go death sets Health 0, so the alive gate already drops dead priests).

func NewGroupObject

func NewGroupObject(groupGUID uint64, live GroupLive) *Object

NewGroupObject builds the Lua Group object surface: the ID, GUID, LeaderGUID and member GUID fields plus the GetId/GetGUID/GetLeaderGUID/ GetMembers/GetMembersCount/IsLeader/IsFull/IsRaidGroup/IsBGGroup/IsMember/ IsAssistant/SameSubGroup/HasFreeSlotSubGroup/GetMemberGUID/GetMemberGroup methods (GroupMethods.h). GetMembers pushes the online Player objects for members with sessions, like the C++. It is the Go model of Eluna's Push(group) (LuaEngine/GroupHooks.cpp via ElunaTemplate), shared by the world engine's group event hooks. The mutating surface (AddMember/SetLeader/RemoveMember/Disband/ConvertToRaid/SetMembersGroup/ SetTargetIcon/SendPacket, GroupMethods.h) is attached by the world engine's attachGroupMutations, which re-resolves the live group per call. groupGUID is the protocol group GUID (0x1F50 high bits, as in world group.go's groupGUID).

func NewGuildObject

func NewGuildObject(guildID uint32, live GuildLive) *Object

NewGuildObject builds the Lua Guild object surface: the ID, Name, LeaderGUID, MemberCount, MOTD and Info fields plus the GetId/GetName/ GetLeaderGUID/GetMemberCount/GetMOTD/GetInfo/GetLeader/GetMembers methods. It is the Go model of Eluna's Push(guild) (LuaEngine/GuildHooks.cpp via ElunaTemplate), shared by the GetGuildBy* globals and the world engine's guild event hooks. The mutating surface (SetLeader/SetBankTabText/ SendPacket/SendPacketToRanked/Disband/AddMember/DeleteMember/SetMemberRank, GuildMethods.h) is attached by the world engine's attachGuildMutations, which re-resolves the live guild per call; snapshot-only objects (the globals) carry the read surface only.

func NewItemObject

func NewItemObject(guid uint64, entry, count uint32, live ItemLive) *Object

NewItemObject builds the Lua Item object surface for hooks that hand scripts a live item (Eluna's Push(Item*) via ElunaTemplate): the GUID, Entry and Count fields plus the template-read methods GetName, GetQuality, GetClass, GetSubClass, GetDisplayId, GetItemLevel, GetRequiredLevel, GetBuyPrice, GetBuyCount, GetSellPrice, GetInventoryType, GetAllowableClass, GetAllowableRace, GetMaxStackCount, GetBagSize, GetStatsCount, GetItemSet, GetRandomProperty, GetRandomSuffix, HasQuest, IsBag, IsPotion, IsBoundAccountWide, IsWeaponVellum, IsArmorVellum, IsConjuredConsumable, IsCurrencyToken, GetSpellId and GetSpellTrigger (ItemMethods.h), plus the instance-bound reads GetOwner, GetOwnerGUID, GetSlot, GetBagSlot, GetEnchantmentId, IsSoulBound, IsEquipped, IsBroken, IsLocked, IsBoundByEnchant, IsNotEmptyBag, IsInBag, IsNotBoundToPlayer, CanBeTraded and GetItemLink when the object carries a LoadInstance. The generic object methods supply GetEntry/GetGUID/GetGUIDLow/GetTypeId (object.go). The mutating surface (SetOwner, SetBinding, SetCount, SetEnchantment, ClearEnchantment, SaveToDB) writes through the world's UpdateInstance callback straight to the item_instance row, so a later LoadInstance read sees the write; the world layer also sends the owner session the values block for the changed fields (plus the SetEnchantment log pair), so a live client sees the change at once. IsInTrade reads the world's server-guarded mb_in_trade mirror (see trade.go), never the session trade state, so it is safe from any Lua goroutine.

func NewMapObject

func NewMapObject(mapID, instanceID uint32, live MapLive) *Object

NewMapObject builds the Lua Map object surface for the MAP_EVENT_* and INSTANCE_EVENT_* hooks: GetMapId/GetInstanceId ride the generic object methods (object.go) and the DBC-backed GetName/IsDungeon/IsRaid/IsArena/ IsBattleground come from the live MapLive (MapMethods.h). The live legs (IsEmpty/IsHeroic/GetDifficulty/GetPlayerCount/GetPlayers/SetWeather/ SetZoneWeather/GetInstanceData/SaveInstanceData/GetAreaId/GetHeight) read the MapLive callbacks. GetWorldObject dispatches on the GUID high part through the live WorldObject callback (nil callback or nil return reads nil, matching Eluna's Push(nullptr) arm).

type ObjectMethod

type ObjectMethod func(context.Context, []any) ([]any, error)

type Packet

type Packet struct {
	Opcode  uint32
	Data    []byte
	ReadPos int
}

type Query

type Query struct {
	// contains filtered or unexported fields
}

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

func NewRuntime

func NewRuntime(c Config) *Runtime

func (*Runtime) CreateObjectTimer

func (r *Runtime) CreateObjectTimer(state *lua.State, functionIndex int, owner uint64, object func(ctx context.Context) (any, bool)) int

CreateObjectTimer registers a WorldObject:RegisterEvent timer (Eluna WorldObjectMethods.h:867-897) for owner: the callback fires as (eventId, delay, repeats, object) like C++ OnTimedEvent, with object re-resolved at fire time; when the owner no longer resolves the timer is dropped, matching Eluna destroying the object's event processor with the object. functionIndex is the callback's stack index in the calling method dispatch (self is index 1, so 2 for obj:RegisterEvent(fn, ...)). The id comes from the same counter as CreateLuaEvent, so global and object ids never collide.

func (*Runtime) HasCreatureEvent

func (r *Runtime) HasCreatureEvent(entry uint32, event int) bool

HasCreatureEvent reports whether at least one non-cancelled hook is registered for the given creature entry and event — the entry-binding half of HasHook, so per-tick sighting loops can skip the Lua dispatch entirely when no handler could fire (Eluna Bindings::HasBindingsFor).

func (*Runtime) HasHook

func (r *Runtime) HasHook(kind string, event int) bool

HasHook reports whether at least one non-cancelled hook is registered for the given kind and event — the Go model of Eluna's Bindings::HasBindingsFor, which the START_HOOK macros consult before running hook prologues such as PlayerTalkClass::ClearMenus().

func (*Runtime) Hooks

func (r *Runtime) Hooks() []Hook

func (*Runtime) InstanceDataNumber

func (r *Runtime) InstanceDataNumber(mapID, instanceID uint32, key string) (float64, bool)

InstanceDataNumber reads one numeric field of the (map, instance) data table, reporting false when the table or field is absent or not a number — the Go-side read of the Lua shared instanceData table (the ElunaInstanceAI Lua data table), for engine code that must evaluate instance-script state without a Lua call frame (e.g. the DATA_TYPE_INSTANCE_SCRIPT achievement gate, AchievementMgr.cpp:404-424, whose C++ form reads the instance script's members directly). A nil runtime reads absent, matching MarshalInstanceData above.

func (*Runtime) Load

func (r *Runtime) Load(ctx context.Context) error

func (*Runtime) LoadFailures

func (r *Runtime) LoadFailures() []error

func (*Runtime) LoadString

func (r *Runtime) LoadString(source string) error

func (*Runtime) LoadedFiles

func (r *Runtime) LoadedFiles() []string

func (*Runtime) MarshalInstanceData

func (r *Runtime) MarshalInstanceData(mapID, instanceID uint32, bossStates map[uint32]uint8) (string, error)

MarshalInstanceData serializes the (map, instance) data table to the base64 blob stored in instance.data, plus the live boss states the caller passes (nil when the caller has none; an instance with no data table yet marshals as the empty table, matching C++ SaveToDB on a fresh shim; a nil runtime reads empty). Boss states are written raw and in boss-id order, matching C++ WriteSaveDataBossStates; the load-side normalization lives in the caller.

func (*Runtime) RemoveObjectTimer

func (r *Runtime) RemoveObjectTimer(owner uint64, id int)

RemoveObjectTimer aborts one object timer by id (WorldObject: RemoveEventById, WorldObjectMethods.h:903-911); timers owned by another object or global timers are untouched, matching C++ where the per-object processor only holds its own events.

func (*Runtime) RemoveObjectTimers

func (r *Runtime) RemoveObjectTimers(owner uint64)

RemoveObjectTimers aborts every timer owned by owner (WorldObject: RemoveEvents, WorldObjectMethods.h:914-919); global timers survive.

func (*Runtime) SetAreaNameProvider

func (r *Runtime) SetAreaNameProvider(provider func(id uint32) (string, bool))

func (*Runtime) SetBanProvider

func (r *Runtime) SetBanProvider(provider func(args BanArgs) (int, string))

func (*Runtime) SetGameEventControlProvider

func (r *Runtime) SetGameEventControlProvider(provider func(eventID uint32, start, force bool))

func (*Runtime) SetGameEventProvider

func (r *Runtime) SetGameEventProvider(provider func() []uint32)

func (*Runtime) SetKickProvider

func (r *Runtime) SetKickProvider(provider func(playerGUID uint64))

func (*Runtime) SetMapProvider

func (r *Runtime) SetMapProvider(provider func(mapID, instanceID uint32) *Object)

func (*Runtime) SetPlayerProvider

func (r *Runtime) SetPlayerProvider(provider func() []*Object)

func (*Runtime) SetSaveAllPlayersProvider

func (r *Runtime) SetSaveAllPlayersProvider(provider func())

func (*Runtime) SetSendMailProvider

func (r *Runtime) SetSendMailProvider(provider func(SendMailArgs) error)

func (*Runtime) SetSpawnProvider

func (r *Runtime) SetSpawnProvider(provider func(SpawnArgs) *Object)

func (*Runtime) SetSpellDispelTypeProvider

func (r *Runtime) SetSpellDispelTypeProvider(provider func(spellID uint32) uint32)

func (*Runtime) SetSpellFamilyFlagsProvider

func (r *Runtime) SetSpellFamilyFlagsProvider(provider func(spellID uint32, index uint32) uint32)

func (*Runtime) SetSpellFamilyNameProvider

func (r *Runtime) SetSpellFamilyNameProvider(provider func(spellID uint32) uint32)

func (*Runtime) SetSpellItemEnchantmentProvider

func (r *Runtime) SetSpellItemEnchantmentProvider(provider func(enchantID uint32, index uint32) (uint32, uint32))

func (*Runtime) SetSpellPositiveProvider

func (r *Runtime) SetSpellPositiveProvider(provider func(spellID uint32) bool)

func (*Runtime) SetTaxiPathProvider

func (r *Runtime) SetTaxiPathProvider(provider func(TaxiPathArgs) uint32)

func (*Runtime) SetVendorAddProvider

func (r *Runtime) SetVendorAddProvider(provider func(entry, item uint32, maxCount int32, incrTime, extCost uint32))

func (*Runtime) SetVendorRemoveAllProvider

func (r *Runtime) SetVendorRemoveAllProvider(provider func(entry uint32))

func (*Runtime) SetVendorRemoveProvider

func (r *Runtime) SetVendorRemoveProvider(provider func(entry, item uint32) error)

func (*Runtime) SetWorldMessageProvider

func (r *Runtime) SetWorldMessageProvider(provider func(string))

func (*Runtime) Tick

func (r *Runtime) Tick(ctx context.Context, elapsed int64) error

func (*Runtime) Trigger

func (r *Runtime) Trigger(ctx context.Context, kind string, event int, args ...any) ([]any, error)

func (*Runtime) TriggerAuraEvent

func (r *Runtime) TriggerAuraEvent(ctx context.Context, spellID uint32, event int, args ...any) ([]any, error)

TriggerAuraEvent fires hooks registered with RegisterAuraEvent(spellID, event, fn) for the given spell. Callers pass the Eluna-style leading event number in args, like TriggerCreatureEvent.

func (*Runtime) TriggerBGEvent

func (r *Runtime) TriggerBGEvent(ctx context.Context, event int, args ...any) ([]any, error)

TriggerBGEvent fires hooks registered with RegisterBGEvent(event, fn). C++ Eluna battleground hooks pass (event, bg, bgId, instanceId[, winner]) (LuaEngine/BattleGroundHooks.cpp), so the event number is prepended like TriggerVehicleEvent. Callers pass the C++ argument order without the leading event.

func (*Runtime) TriggerCreatureEvent

func (r *Runtime) TriggerCreatureEvent(ctx context.Context, entry uint32, event int, args ...any) ([]any, error)

TriggerCreatureEvent fires hooks registered with RegisterCreatureEvent(entry, event, fn) for the given creature entry.

func (*Runtime) TriggerCreatureEvent2

func (r *Runtime) TriggerCreatureEvent2(ctx context.Context, entry uint32, event int, args ...any) ([][]any, error)

TriggerCreatureEvent2 fires hooks registered with RegisterCreatureEvent(entry, event, fn) for the given creature entry, capturing two return values per handler. It exists for Eluna hooks whose C++ call sites consume a second return via CallOneFunction(n, args, 2): CREATURE_EVENT_ON_DAMAGE_TAKEN (9) rewrites damage, and CREATURE_EVENT_ON_CORPSE_REMOVED (26) rewrites respawnDelay. Each inner slice is [firstReturn, secondReturn] in handler call order.

func (*Runtime) TriggerCreatureEvent2Updated

func (r *Runtime) TriggerCreatureEvent2Updated(ctx context.Context, entry uint32, event int, args []any, update func(returns []any)) ([][]any, error)

TriggerCreatureEvent2Updated is TriggerCreatureEvent2 with per-handler argument chaining: after each handler's returns are captured, update may mutate args for the subsequent handlers, mirroring Eluna's ReplaceArgument. Used by CREATURE_EVENT_ON_DAMAGE_TAKEN (9), whose C++ loop rewrites the damage argument each handler sees.

func (*Runtime) TriggerGameObjectEvent

func (r *Runtime) TriggerGameObjectEvent(ctx context.Context, entry uint32, event int, args ...any) ([]any, error)

TriggerGameObjectEvent fires hooks registered with RegisterGameObjectEvent(entry, event, fn) for the given gameobject entry. C++ Eluna gameobject hooks pass (event, go, ...) (LuaEngine/ GameObjectHooks.cpp), so the event number is prepended like TriggerGuildEvent.

func (*Runtime) TriggerGameObjectGossipEvent

func (r *Runtime) TriggerGameObjectGossipEvent(ctx context.Context, entry uint32, event int, args ...any) ([]any, error)

TriggerGameObjectGossipEvent fires hooks registered with RegisterGameObjectGossipEvent(entry, event, fn) for the given gameobject entry. C++ Eluna gossip hooks pass (event, player, go, ...) (LuaEngine/GossipHooks.cpp), so the event number is prepended like TriggerItemGossipEvent. Callers pass the C++ argument order without the leading event.

func (*Runtime) TriggerGroupEvent

func (r *Runtime) TriggerGroupEvent(ctx context.Context, event int, args ...any) ([]any, error)

TriggerGroupEvent fires hooks registered with RegisterGroupEvent(event, fn). C++ Eluna group hooks pass (event, group, ...) (LuaEngine/ GroupHooks.cpp), so the event number is prepended like TriggerGuildEvent.

func (*Runtime) TriggerGuildEvent

func (r *Runtime) TriggerGuildEvent(ctx context.Context, event int, args ...any) ([]any, error)

TriggerGuildEvent fires hooks registered with RegisterGuildEvent(event, fn). C++ Eluna guild hooks pass (event, guild, ...) (LuaEngine/ GuildHooks.cpp), so the event number is prepended like TriggerServerEvent.

func (*Runtime) TriggerGuildEventUpdated

func (r *Runtime) TriggerGuildEventUpdated(ctx context.Context, event int, args []any, update func(returns []any)) ([][]any, error)

TriggerGuildEventUpdated is TriggerGuildEvent with per-handler argument chaining: after each handler's returns are captured, update may mutate args for the subsequent handlers, mirroring Eluna's ReplaceArgument. Used by GUILD_EVENT_ON_MONEY_WITHDRAW (7) and GUILD_EVENT_ON_MONEY_DEPOSIT (8), whose C++ call sites (GuildHooks.cpp OnMemberWitdrawMoney / OnMemberDepositMoney) consume one numeric return per handler as the new amount and rewrite the argument each handler sees (CallOneFunction(n, args, 1), so nresults is 1).

func (*Runtime) TriggerInstanceEvent

func (r *Runtime) TriggerInstanceEvent(ctx context.Context, mapID, instanceID uint32, event int, args ...any) ([]any, error)

TriggerInstanceEvent fires hooks registered with RegisterMapEvent(mapID, event, fn) (kind "map:<mapID>") and RegisterInstanceEvent(instanceID, event, fn) (kind "instance:<instanceID>"), mirroring Eluna::InstanceHooks (LuaEngine/InstanceHooks.cpp), whose START_HOOK macro calls CallAllFunctions over both the map-level and instance-level binding maps at every fire site. C++ instance hooks pass (event, instance_data, map, ...) (LuaEngine/InstanceHooks.cpp), so the event number is prepended like TriggerMapEvent. Callers pass the C++ argument order without the leading event.

func (*Runtime) TriggerItemEvent

func (r *Runtime) TriggerItemEvent(ctx context.Context, entry uint32, event int, args ...any) ([]any, error)

TriggerItemEvent fires hooks registered with RegisterItemEvent(entry, event, fn) for the given item entry. C++ Eluna item hooks pass (event, player, item, ...) (LuaEngine/ ItemHooks.cpp), so the event number is prepended like TriggerGameObjectEvent. Callers pass the C++ argument order without the leading event.

func (*Runtime) TriggerItemGossipEvent

func (r *Runtime) TriggerItemGossipEvent(ctx context.Context, entry uint32, event int, args ...any) ([]any, error)

TriggerItemGossipEvent fires hooks registered with RegisterItemGossipEvent(entry, event, fn) for the given item entry. C++ Eluna gossip hooks pass (event, player, item, ...) (LuaEngine/ GossipHooks.cpp), so the event number is prepended like TriggerItemEvent. Callers pass the C++ argument order without the leading event.

func (*Runtime) TriggerMapEvent

func (r *Runtime) TriggerMapEvent(ctx context.Context, mapID uint32, event int, args ...any) ([]any, error)

func (*Runtime) TriggerPacketEvent

func (r *Runtime) TriggerPacketEvent(ctx context.Context, opcode, event int, args ...any) ([]any, error)

func (*Runtime) TriggerPacketEvent2

func (r *Runtime) TriggerPacketEvent2(ctx context.Context, opcode, event int, args ...any) ([][]any, error)

TriggerPacketEvent2 fires hooks registered with RegisterPacketEvent(opcode, event, fn), capturing two return values per handler, like TriggerCreatureEvent2. It exists for the fork's per-opcode RECEIVE bindings, whose C++ lookup site (LuaEngine/PacketHooks.cpp:117-119) consumes two returns per handler: a boolean false first return blocks the opcode handler and a Packet userdata second return replaces the packet the handler sees. NOTE the fork quirk: that lookup uses the SEND event number (PACKET_EVENT_ON_PACKET_SEND = 7, LuaEngine/Hooks.h:96), so on receive the engine fires event-7 per-opcode bindings, never event-5 ones.

func (*Runtime) TriggerPlayerEvent

func (r *Runtime) TriggerPlayerEvent(ctx context.Context, event int, args ...any) ([]any, error)

func (*Runtime) TriggerPlayerEvent2

func (r *Runtime) TriggerPlayerEvent2(ctx context.Context, event int, args ...any) ([][]any, error)

TriggerPlayerEvent2 is TriggerPlayerEvent capturing two returns per handler, mirroring TriggerCreatureEvent2: Eluna chat hooks consume a second return (CallOneFunction(n, args, 2)) carrying the rewritten message, so the chat path fires through this instead of Trigger.

func (*Runtime) TriggerPlayerEventUpdated

func (r *Runtime) TriggerPlayerEventUpdated(ctx context.Context, event int, args []any, update func(returns []any)) ([][]any, error)

TriggerPlayerEventUpdated is the chained-argument player-event trigger, mirroring Eluna's ReplaceArgument semantics (LuaEngine/PlayerHooks.cpp): hooks whose C++ call sites consume a numeric return (PLAYER_EVENT_ON_GIVE_XP rewrites amount, PLAYER_EVENT_ON_MONEY_CHANGE rewrites amount, PLAYER_EVENT_ON_REPUTATION_CHANGE rewrites standing) pass each handler the rewritten argument, so update mutates args between handler invocations.

func (*Runtime) TriggerPlayerGossipEvent

func (r *Runtime) TriggerPlayerGossipEvent(ctx context.Context, menuID uint32, event int, args ...any) ([]any, error)

TriggerPlayerGossipEvent fires hooks registered with RegisterPlayerGossipEvent(menuID, event, fn) for the given gossip menu. C++ Eluna gossip hooks pass (event, player, ...) (LuaEngine/GossipHooks.cpp), so the event number is prepended like TriggerGameObjectGossipEvent. The player select arm passes (event, player, player, sender, action, code-or-nil) with no cancel semantics (CallAllFunctions, GossipHooks.cpp:78).

func (*Runtime) TriggerServerEvent

func (r *Runtime) TriggerServerEvent(ctx context.Context, event int, args ...any) ([]any, error)

func (*Runtime) TriggerServerEvent2

func (r *Runtime) TriggerServerEvent2(ctx context.Context, event int, args ...any) ([][]any, error)

TriggerServerEvent2 fires hooks registered with RegisterServerEvent(event, fn), capturing two return values per handler. It exists for Eluna hooks whose C++ call sites consume a second return via CallOneFunction(n, args, 2): SERVER_EVENT_ON_PACKET_RECEIVE (5), where a boolean false first return blocks the opcode handler and a Packet userdata second return replaces the packet the handler sees (LuaEngine/PacketHooks.cpp:93-115). The TryLock guard mirrors TriggerPacketEvent: packet hooks can fire while a hook already holds the runtime lock (e.g. Lua -> SendPacket -> send hooks), in which case the fire is skipped instead of deadlocking.

func (*Runtime) TriggerServerEventGuarded

func (r *Runtime) TriggerServerEventGuarded(ctx context.Context, event int, args ...any) ([]any, error)

TriggerServerEventGuarded is TriggerServerEvent with TriggerServerEvent2's TryLock guard: the packet-send hook fire (world firePacketSendHooks) runs on the write path, so a send-hook handler that broadcasts via Group or Guild SendPacket re-enters the send-hook fire on the same goroutine while triggerNUpdated still holds r.mu. The blocking TriggerServerEvent would deadlock there; the guarded fire is skipped instead, like the receive path, and the packet is delivered.

func (*Runtime) TriggerSpellEvent

func (r *Runtime) TriggerSpellEvent(ctx context.Context, spellID uint32, event int, args ...any) ([]any, error)

TriggerSpellEvent fires hooks registered with RegisterSpellEvent(spellID, event, fn) for the given spell. Callers pass the Eluna-style leading event number in args, like TriggerAuraEvent.

func (*Runtime) TriggerSpellEvent2

func (r *Runtime) TriggerSpellEvent2(ctx context.Context, spellID uint32, event int, args ...any) ([][]any, error)

TriggerSpellEvent2 fires hooks registered with RegisterSpellEvent(spellID, event, fn) for the given spell, capturing two return values per handler, mirroring TriggerCreatureEvent2: SPELL_EVENT_ON_CHECK_CAST (8) reads the custom-error id behind SPELL_FAILED_CUSTOM_ERROR as its second return. Each inner slice is [firstReturn, secondReturn] in handler call order.

func (*Runtime) TriggerUniqueCreatureEvent

func (r *Runtime) TriggerUniqueCreatureEvent(ctx context.Context, guid uint64, instanceID uint32, event int, args ...any) ([]any, error)

TriggerUniqueCreatureEvent fires hooks registered with RegisterUniqueCreatureEvent(guid, instanceID, event, fn).

func (*Runtime) TriggerUniqueCreatureEvent2Updated

func (r *Runtime) TriggerUniqueCreatureEvent2Updated(ctx context.Context, guid uint64, instanceID uint32, event int, args []any, update func(returns []any)) ([][]any, error)

TriggerUniqueCreatureEvent2Updated is the two-return, chained-argument variant of TriggerUniqueCreatureEvent. Eluna creature hooks consume both the entry bindings and the unique bindings (SetupStack merges CreatureEventBindings then CreatureUniqueBindings), so callers run the entry pass first and then this pass, threading the same args/update through both to mirror ReplaceArgument chaining across families.

func (*Runtime) TriggerVehicleEvent

func (r *Runtime) TriggerVehicleEvent(ctx context.Context, event int, args ...any) ([]any, error)

TriggerVehicleEvent fires hooks registered with RegisterVehicleEvent(event, fn). C++ Eluna vehicle hooks pass (event, vehicle, ...) (LuaEngine/ VehicleHooks.cpp), so the event number is prepended like TriggerGroupEvent.

func (*Runtime) UnmarshalInstanceData

func (r *Runtime) UnmarshalInstanceData(mapID, instanceID uint32, encoded string) (map[uint32]uint8, error)

UnmarshalInstanceData replaces the (map, instance) data table with the decoded blob and returns the boss states the blob carried (nil when the blob has no bossStates section, as with blobs written before the section existed): C++ Load swaps in the decoded table wholesale (CreateInstanceData), so stale keys from a previous load do not survive. The table keeps its registry identity — scripts only ever hold the InstanceData userdata handle, never the raw table. The caller applies the boss states itself, normalizing them first (InstanceScript::ReadSaveDataBossStates).

type SendMailArgs

type SendMailArgs struct {
	Subject     string
	Text        string
	ReceiverLow uint32
	SenderLow   uint32
	Stationery  uint32
	Delay       uint32
	Money       uint32
	COD         uint32
	Items       []MailItemPair
}

SendMailArgs is the GlobalMethods::SendMail argument shape. Stationery defaults to MAIL_STATIONERY_DEFAULT (41); Delay is added to the game time in seconds by MailDraft::SendMailTo, despite the Eluna doc calling it milliseconds.

type SpawnArgs

type SpawnArgs struct {
	SpawnType        uint32
	Entry            uint32
	MapID            uint32
	InstanceID       uint32
	X, Y, Z, O       float32
	Save             bool
	DurOrRespawnTime uint32
	Phase            uint32
}

SpawnArgs is the GlobalMethods::PerformIngameSpawn argument shape: spawnType 1 = creature, 2 = gameobject; DurOrRespawnTime is the raw C++ durorresptime (milliseconds on the creature arm, seconds on the gameobject arm — the asymmetry is in the C++ itself, not a Go choice).

type TaxiPathArgs

type TaxiPathArgs struct {
	Waypoints []TaxiWaypoint
	MountA    uint32
	MountH    uint32
	Price     uint32
	PathID    uint32
}

TaxiPathArgs is the GlobalMethods::AddTaxiPath argument shape: (waypoints, mountA, mountH, price = 0, pathId = 0). The provider returns the used path id.

type TaxiWaypoint

type TaxiWaypoint struct {
	MapID   uint32
	X, Y, Z float32
	Flags   uint32
	Delay   uint32
}

TaxiWaypoint is one GlobalMethods::AddTaxiPath waypoint: MapID, X, Y, Z mandatory, Flags and Delay optional (both default 0).

type UInt64

type UInt64 uint64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL