Documentation
¶
Index ¶
- type Bot
- func (b *Bot) AttackTarget(guid uint64) error
- func (b *Bot) CanCast(spellID uint32, targetGUID uint64) bool
- func (b *Bot) CastSpell(spellID uint32, targetGUID uint64) error
- func (b *Bot) ConsumeTeleport() bool
- func (b *Bot) Events() []BotEvent
- func (b *Bot) FaceTarget(guid uint64) bool
- func (b *Bot) GetClass() uint8
- func (b *Bot) GetFacing() float32
- func (b *Bot) GetHealth() (current, max uint32)
- func (b *Bot) GetLevel() uint32
- func (b *Bot) GetNearbyPlayers(maxDist float32) []luaengine.UnitInfo
- func (b *Bot) GetNearbyUnits(maxDist float32) []luaengine.UnitInfo
- func (b *Bot) GetOwnGUID() uint64
- func (b *Bot) GetPetGUID() uint64
- func (b *Bot) GetPosition() (x, y, z, o float32)
- func (b *Bot) GetPower() (current, max uint32)
- func (b *Bot) GetPowerType() uint8
- func (b *Bot) GetRace() uint8
- func (b *Bot) GetStance() int
- func (b *Bot) GetTargetGUID() uint64
- func (b *Bot) GetUnitInfo(guid uint64) *luaengine.UnitInfo
- func (b *Bot) HasAuraOn(guid uint64, spellID uint32) bool
- func (b *Bot) InCombat() bool
- func (b *Bot) IsAlive() bool
- func (b *Bot) IsBehindTarget(targetGUID uint64) bool
- func (b *Bot) IsMoving() bool
- func (b *Bot) IsSpellReady(spellID uint32) bool
- func (b *Bot) LoadAIBundle(bundle scenario.AIBundle) error
- func (b *Bot) LoadLuaScript(code string) error
- func (b *Bot) Log(format string, args ...interface{})
- func (b *Bot) Loot(guid uint64) error
- func (b *Bot) LootAll(guid uint64) error
- func (b *Bot) MoveTo(x, y, z float32) error
- func (b *Bot) PetAttack(target uint64)
- func (b *Bot) Run() BotResult
- func (b *Bot) RunAIOnly() BotResult
- func (b *Bot) SendChat(message string) error
- func (b *Bot) SendCommand(command string) error
- func (b *Bot) SendGuildCommand(command string) error
- func (b *Bot) SetFacing(o float32) error
- func (b *Bot) SetLevel(level uint32)
- func (b *Bot) SetSheathed(state uint32) error
- func (b *Bot) SetTarget(guid uint64) error
- func (b *Bot) Status() BotResult
- func (b *Bot) Stop()
- func (b *Bot) StopAttack() error
- func (b *Bot) StopMoving() error
- func (b *Bot) ValidationMode() bool
- type BotEvent
- type BotResult
- type BotStatus
- type Config
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot implements the WoW client bot logic with behavior tree AI.
func NewHeadlessBot ¶
func NewHeadlessBot(wc *client.WorldClient, cfg Config) *Bot
NewHeadlessBot creates a bot attached to an already-authenticated and logged-in WorldClient. It skips auth/char creation/login and the optional DB pre-setup. Useful for integration tests and library use. The caller is responsible for maintaining the WorldClient lifecycle.
func (*Bot) AttackTarget ¶
func (*Bot) ConsumeTeleport ¶
ConsumeTeleport returns true once after a completed summon/teleport so Lua can clear sticky state and re-settle at the new position.
func (*Bot) FaceTarget ¶
func (*Bot) GetOwnGUID ¶
func (*Bot) GetPetGUID ¶
func (*Bot) GetPosition ¶
func (*Bot) GetPowerType ¶
func (*Bot) GetTargetGUID ¶
func (*Bot) HasAuraOn ¶
Extended BotAPI methods for the Lua AI framework (warrior rends, pet, stance, aura checks, etc.)
func (*Bot) IsBehindTarget ¶
func (*Bot) IsSpellReady ¶
func (*Bot) LoadAIBundle ¶
LoadAIBundle applies a full AIBundle (Main + Helpers + Data + TickFunc) at runtime. This enables live phase broadcasts and richer scenario AI updates. It DoStrings Main then each Helper, sets scenario_data, and overrides the tick func. Existing globals from prior loads are not cleared (Lua state is additive for functions).
func (*Bot) LoadLuaScript ¶
LoadLuaScript loads a Lua script at runtime (simple string form). For richer updates including helpers/data/tick func switch use LoadAIBundle.
func (*Bot) LootAll ¶
LootAll opens loot, takes money, and releases without blocking the AI tick. Previously this slept 700ms on the AI goroutine, which froze ticks and caused loot spam under Lua grind (validation run: 122× CMSG_LOOT in ~45s). Server responses arrive asynchronously via OnLootOpened / SMSG_LOOT_*.
func (*Bot) RunAIOnly ¶
RunAIOnly runs only the AI loop (assumes world + nav + lua already attached/initialized). Does not perform login or full lifecycle management. Pairs with NewHeadlessBot.
func (*Bot) SendCommand ¶
func (*Bot) SendGuildCommand ¶
func (*Bot) SetSheathed ¶
func (*Bot) StopAttack ¶
func (*Bot) StopMoving ¶
func (*Bot) ValidationMode ¶
ValidationMode satisfies the luaengine.BotAPI requirement. It is the central cheap gate for all heavy validation tooling (structured logs, packet traces, ring buffers, detailed aura data, etc.). When false (the default for regular operation), callers must do almost no work.
type BotEvent ¶
type BotEvent struct {
Time time.Time `json:"time"`
Type string `json:"type"`
Message string `json:"message"`
}
BotEvent is a notable event that occurred during the bot's life.
type BotResult ¶
type BotResult struct {
ID string `json:"id"`
Status BotStatus `json:"status"`
Error string `json:"error,omitempty"`
Level uint32 `json:"level,omitempty"`
Kills int `json:"kills,omitempty"`
Deaths int `json:"deaths,omitempty"`
}
BotResult holds the result of a bot run
type Config ¶
type Config struct {
Username string `json:"username"`
Password string `json:"password"`
AuthServer string `json:"auth_server"`
CharacterName string `json:"character_name"`
RealmIndex int `json:"realm_index"`
Race uint8 `json:"race"`
Class uint8 `json:"class"`
Gender uint8 `json:"gender"`
// Navigation
DataDir string `json:"data_dir"` // root containing mmaps/, maps/, vmaps/
PathfindingAddress string `json:"pathfinding_address"` // optional remote (deprioritized)
// Lua
LuaScript string `json:"lua_script"` // path to .lua file (DoFile)
LuaCode string `json:"lua_code"` // inline script (DoString). Precedence: AIBundle > LuaCode > LuaScript
// AIBundle carries richer scenario-distributed AI (Main + Helpers + Data + TickFunc).
// When non-empty, takes precedence for initial AI payload.
AIBundle scenario.AIBundle `json:"ai_bundle"`
// Behavior mode (preserved for backward compat with existing load tests)
Mode string `json:"mode"` // "grind", "hogger", "dungeon", "idle", "lua"
// AI tick interval (ms). Default 200.
AITickMs int `json:"ai_tick_ms"`
// Dungeon for "dungeon" mode.
DungeonName string `json:"dungeon_name"`
// DeleteExistingCharacters: before creating target char, delete others on account.
DeleteExistingCharacters bool `json:"delete_existing_characters"`
// LogDecisionsToChat emits major AI decisions via /say (throttled).
LogDecisionsToChat bool `json:"log_decisions_to_chat"`
// DisableTargetCache forces fresh target scans every tick (debug).
DisableTargetCache bool `json:"disable_target_cache"`
// ValidationMode enables heavier instrumentation only used during E2E quality runs:
// - Structured decision + outcome logging to ValidationLogPath (JSONL)
// - Ring buffers for recent cast results / aura deltas (for post-run assertions)
// - Optional packet tracing
// When false (the default for regular runs), these paths allocate nothing and do minimal work.
ValidationMode bool `json:"validation_mode"`
// ValidationLogPath when set (and ValidationMode true) writes structured events
// (decisions, cast results, aura changes, value snapshots) for later analysis.
// Example: "validation/warrior-rend-001.jsonl". Empty = disabled.
ValidationLogPath string `json:"validation_log_path"`
// EnablePacketTrace when true + ValidationMode, logs or records selected high-value
// opcodes (SPELL_GO, AURA_UPDATE*, ATTACKERSTATE, etc.) with timestamps.
// Expensive; off by default.
EnablePacketTrace bool `json:"enable_packet_trace"`
// EnableDetailedAuras when true keeps richer per-aura metadata (duration, stacks, caster).
// The basic spellID set for HasAura is always maintained (cheap). Detailed is opt-in.
EnableDetailedAuras bool `json:"enable_detailed_auras"`
// SkipCharacterSetup skips the entire auth + char enum/create/login flow.
// Use together with NewHeadlessBot when you already performed login via client.WorldClient.
SkipCharacterSetup bool `json:"skip_character_setup"`
// AllowDBSetup gates the old preLoginDBSetup (level/pos/spells/gear via direct MySQL).
// Default false for library and test use. When true + CharDBDSN provided, the
// legacy DB path remains available for load-test modes that relied on it.
AllowDBSetup bool `json:"allow_db_setup"`
// CharDBDSN is the DSN for acore_characters used only when AllowDBSetup is true.
CharDBDSN string `json:"char_db_dsn"`
}
Config holds configuration for a bot instance. This is the public config for AzerothGhost. It loosens coupling: DB setup is opt-in; headless usage is supported; Lua can be provided inline (LuaCode) or via AIBundle for scenarios.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with common defaults applied.
type Option ¶
type Option func(*Config)
Option is a functional option for NewBot.
func WithAIBundle ¶
WithAIBundle provides a full scenario AIBundle.
func WithAllowDBSetup ¶
WithAllowDBSetup enables the legacy pre-login DB writes (off by default).
func WithBehaviorProvider ¶
func WithBehaviorProvider(_ interface{}) Option
WithBehaviorProvider can be used in future to inject a custom Behavior. Placeholder for the interface described in the design.
func WithDataDir ¶
WithDataDir sets the pathfinding data directory.
func WithLuaCode ¶
WithLuaCode provides inline Lua code (higher precedence than LuaScript file).
func WithSkipCharacterSetup ¶
WithSkipCharacterSetup requests that Run() skips auth/char/login.