Commit Graph

44468 Commits

Author SHA1 Message Date
b76bb53b45 Merge in upstream changes v11.2.7.64978 2025-12-16 17:24:01 -05:00
d3bc42b9e9 Merge pull request #3 from araxiaonline/add-zeromq-event-bus
feat(eventbus): Add ZeroMQ Event Bus with comprehensive game event hooks
2025-12-15 16:06:47 -08:00
50631d4638 fix: Address Gemini code review security and quality issues
Security fixes (HIGH):
- Remove NOPASSWD sudo access in Dockerfile
- Require secure passwords in docker-compose.yml (no weak defaults)
- Replace libboost-all-dev with specific runtime libs in araxia_docs/Dockerfile

Code quality fixes (MEDIUM):
- Remove weak default password from .env.example
- Fix AMS_Server.lua: vendor Smallfolk dependency, add CHAT_CHANNEL_WHISPER constant
- Fix AMS_Client.lua: correct misleading comments about channel selection

Fixes issues identified by Gemini Code Assist review.
2025-12-15 19:03:10 -05:00
8c83692013 feat(eventbus): Add auction create event hook
Publishes AuctionEvent with type 'create' when players create auctions.
Only fires for player-created auctions, not during server load.
2025-12-15 18:40:17 -05:00
568d80d26e feat(eventbus): Add comprehensive event hooks for all game events
Add event hooks for:
- AuctionEvent (sold, expired) in AuctionHouseMgr.cpp
- SpellCastEvent in Spell.cpp (player-only, disabled by default)
- TradeEvent in TradeHandler.cpp
- MailEvent in Mail.cpp
- GuildEvent (join/leave) in Guild.cpp
- ZoneChangeEvent in Player.cpp
- PartyChangeEvent in Group.cpp
- ItemEquipEvent in Player.cpp
- LevelUpEvent in Player.cpp
- ChatEvent in ChatHandler.cpp
- AchievementEvent in AchievementMgr.cpp
- CombatEvent in Unit.cpp
- EncounterEvent in InstanceScript.cpp
- SpawnEvent in Creature.cpp

All events include IsEnabled() checks via AraxiaEventBusConfig.
Added eventbus_integration_test.py for testing.
2025-12-15 18:24:23 -05:00
c3f46083e8 feat(eventbus): Add player login/logout/death event publishing
- Hook into Player::AddToWorld() for login events
- Hook into Player::RemoveFromWorld() for logout events
- Hook into Player::KillPlayer() for death events
- Events include: player_guid, player_name, map context
- Context-aware topics: world.player.*, dungeon.player.*, etc.
- Respects Araxia.EventBus.EnablePlayerEvents config toggle
2025-12-15 10:35:43 -05:00
9ae822b300 feat(eventbus): Add debug logging for spawn events
- Add TC_LOG_DEBUG for PublishSpawnEvent calls
- Add TC_LOG_DEBUG when messages are sent via ZMQ
- Verified spawn events working with Python subscriber
2025-12-15 10:28:45 -05:00
3d78cc2446 feat(eventbus): Add creature spawn/despawn event publishing
- Hook into Creature::AddToWorld() to publish spawn.create events
- Hook into Creature::RemoveFromWorld() to publish spawn.delete events
- Events include: guid, entry, map_id, instance_id, position (x,y,z)
- Context-aware topics: world.spawn.*, dungeon.spawn.*, raid.spawn.*, etc.
- Respects Araxia.EventBus.EnableSpawnEvents config toggle
- Add Python test subscriber script for verification
2025-12-15 10:09:11 -05:00
29c5097967 feat(config): Add araxia.conf.dist for centralized Araxia settings
- Create araxia.conf.dist with all Araxia-specific configuration
- Move EventBus ZMQ settings from worldserver.conf.dist to araxia.conf.dist
- Add MCP server and Eluna extension config placeholders
- Install to worldserver.conf.d/ for automatic loading after worldserver.conf
- Add CMake custom target 'araxia-conf' to copy config during build

The config is loaded via TrinityCore's LoadAdditionalDir mechanism,
allowing Araxia settings to override worldserver.conf values.
2025-12-15 10:03:32 -05:00
95c30fbdf8 feat(eventbus): Add ZeroMQ event bus infrastructure
- Add libzmq dependency via pkg-config in dep/zeromq/CMakeLists.txt
- Add cppzmq header-only bindings
- Create AraxiaEventBus singleton with PUB/SUB sockets
- Add background worker thread for ZMQ I/O
- Add message envelope with JSON format (v, topic, ts, source, context, payload)
- Add context-aware topic routing (world/dungeon/raid/bg/arena)
- Add AraxiaEventBusConfig for loading settings from worldserver.conf
- Integrate EventBus init/update/shutdown into World lifecycle
- Add configuration options to worldserver.conf.dist

Part of OpenSpec: add-zeromq-event-bus
2025-12-15 09:58:46 -05:00
6bb035cfc3 feat(ahbot): Add item level scaling for AH equipment
- Add 5 new config options for item level scaling:
  - AuctionHouseBot.Items.Scaling.Enabled (default: 0)
  - AuctionHouseBot.Items.Scaling.MinItemLevel (default: 200)
  - AuctionHouseBot.Items.Scaling.MaxItemLevel (default: 500)
  - AuctionHouseBot.Items.Scaling.Chance (default: 75)
  - AuctionHouseBot.Items.Scaling.EquipmentOnly (default: 1)

- Implement scaling logic in AuctionHouseBotSeller::AddNewAuctions()
  - Uses ItemBonusMgr::GetItemBonusListForItemLevelDelta() for scaling
  - Random target ilvl within configured range
  - Respects chance and equipment-only filters

- Update SetPricesOfItem() to use scaled item level for pricing
  - 2% price increase per item level gained

- Add .ahbot stats [equipment] GM command for item level analysis
  - Shows distribution, avg/min/max ilvl, scaling config status

- Add MCP console_command support for ahbot commands
  - ahbot status, rebuild, reload, stats

Tested: Avg equipment ilvl increased from ~35 to 367.9 with default config
2025-12-15 08:20:21 -05:00
cf2d839748 lua_scripts: Add AGENTS.md, fix Ook-Ook script, add instance scripts
- AGENTS.md: Add commit workflow note, code commenting guidelines, Eluna API gotchas
- boss_ook_ook.lua: Fix GetPlayersInWorld/GetPlayersInMap errors, add stale timer safeguard
- instances/: Add Stormstout Brewery and Vortex Pinnacle boss scripts
- spawn_validator.lua: Add spawn validation utility
2025-12-14 22:33:03 -05:00
28dbbf095b MCP: Add ChatHandler fallback for GM commands, add code commenting guidelines
- ServerTools.cpp: Use ChatHandler::ParseCommands() as fallback for any unhandled GM command
- ServerTools.cpp: Add leading dot to commands for ChatHandler compatibility
- ServerTools.cpp: Add detailed header comments about GM command implementation pattern
- AGENTS.md: Add code commenting guidelines section
2025-12-14 22:29:45 -05:00
7b4ba4c31a feat(mcp): Add spawn_creature tool to ServerTools
- Extend MCP server tools for creature spawning capabilities
2025-12-14 21:09:35 -05:00
5c8da59fe8 fix(eluna): Fix GC re-entrancy crash in CollectGarbage
The CollectGarbage metamethod was calling Eluna::GetEluna(L) which uses
lua_pushstring internally. This can trigger another GC cycle while already
inside the GC handler, causing memory corruption and crashes.

The fix avoids GetEluna entirely by directly casting the userdata to
ElunaObject without type checking, which is safe since the __gc metamethod
is only called on valid userdata of the correct type.

This fixes crashes in SHOW_WAYPOINTS and other handlers that hold creature
references when GC runs during method calls.
2025-12-13 19:18:06 -05:00
fad074ef41 Merge branch 'araxia-main' of github.com:araxiaonline/TrinityCore into araxia-main 2025-12-13 19:03:19 -05:00
a3e7574e14 fix(mcp): Use walking speed for bot movement instead of default run speed 2025-12-13 17:12:53 -05:00
009b8dbbdd fix(mcp): Fix same-map teleport and add phase initialization for bot visibility
- Same-map teleport now uses direct Relocate() instead of NearTeleportTo()
  which expects client ACK that headless sessions can't provide
- Add phase initialization (phase 169) so bot players are visible to others
2025-12-13 17:02:03 -05:00
a06fd43c6c fix(mcp): Fix printf-style format specifiers to fmt-style in TC_LOG calls
TC_LOG macros use fmt library which expects {} placeholders, not %s/%u/%d.
Fixed in: AraxiaMCPServer.cpp, DatabaseTools.cpp, ServerTools.cpp,
SpawnTools.cpp, WorldScan.cpp, MCPPlayerManager.cpp
2025-12-13 12:04:02 -05:00
baeeefc139 feat(mcp): Implement GM command execution via ChatHandler
ExecuteCommand now properly executes GM commands using ChatHandler::ParseCommands()
instead of just logging them.

Also includes cross-map teleport fix from previous commit.
2025-12-13 11:54:25 -05:00
cc598584ef fix(mcp): Implement manual cross-map teleport for headless sessions
Player::TeleportTo() + HandleMoveWorldportAck() crashes for headless sessions
because it expects client state we don't have.

New approach:
- Same-map teleports use NearTeleportTo()
- Cross-map teleports manually: validate coords, create map, remove from old,
  relocate, set new map, add to new map

Tested: Scarletseer successfully teleported from map 1 to map 870 and walked
in a circle around a real player.
2025-12-13 11:45:37 -05:00
7f3fc61605 fix(mcp): Fix MCPServer shutdown crash - proper thread cleanup in destructor
The destructor was calling Shutdown() which accesses other singletons that may
already be destroyed during static destruction. Now the destructor only handles
thread cleanup directly without accessing other singletons.
2025-12-13 11:01:58 -05:00
f6239f35d6 feat(mcp): Implement MCP Player system for headless AI control
- Add MCPPlayerManager for multi-session AI player management
- Add Player::InitializeForBot() for minimal bot player initialization
- Add AraxiaCore hook system for World::Update callbacks
- Add packet capture callback for headless WorldSession
- Add 14 MCP tools for session/player control

Key fixes:
- Async login/logout to ensure map operations run on world thread
- Manual player cleanup to avoid RemoveFromWorld() hangs
- Null socket handling in WorldSession for headless sessions
- Safe shutdown without mutex issues during static destruction

Test scripts:
- test_mcp_player.sh - Interactive bash test
- test_mcp_integration.py - Python integration tests

Files:
- src/araxiaonline/mcp/MCPPlayerManager.{h,cpp}
- src/araxiaonline/mcp/MCPPlayerTools.cpp
- src/araxiaonline/AraxiaCore.{h,cpp}
- Modified: Player.{h,cpp}, WorldSession.{h,cpp}, World.cpp
2025-12-13 10:57:15 -05:00
d2b6e83ef5 feat(mcp): Add 'npc reload <entry>' command
Despawns and respawns all creatures of given entry within 500 yards.
Useful for picking up database changes without full server restart.
2025-12-08 21:21:51 -05:00
6823830ed7 feat(dragonriding): Add .flight toggle command and MCP gm_command extensions
- Add .flight toggle/sky/steady commands for players to switch flight styles
- Default to Steady Flight on login (TC behavior), opt-in to Skyriding
- Grant dragonriding spells (376777, 372608, 377920) when enabling Skyriding
- Prevent both flight style auras from being saved (managed by command)
- Add FlightCapability.SpellID application in SetFlightCapabilityID
- Extend MCP gm_command with aura/unaura/learn/unlearn support
- Add .gm advfly command for advanced flying toggle

Note: Vigor UI still requires UI Widget packet implementation (not in TC)
2025-12-07 22:32:37 -05:00
f8bd3e9a97 Fix seg fault on exit 2025-12-06 22:14:40 -05:00
0f7f84bdea MCP: Add warning about db_execute error handling
DatabaseTools.cpp:
- Add comments explaining DirectExecute doesn't return errors
- Change message from 'Query executed successfully' to 'Query submitted'
- Add warning field advising to check DBErrors.log

TC's database layer logs MySQL errors to DBErrors.log but doesn't
expose them to callers. This change makes that limitation explicit
so MCP users know to check the log after batch operations.
2025-12-06 21:52:23 -05:00
644624784c Document zone_id fix in MCP_SERVER.md session summary 2025-12-06 17:19:29 -05:00
2de6ad518a Fix SpawnTools.cpp for TC 11.x API compatibility
- DB2Stores.h instead of DBCStores.h
- FindMap(mapId, 0) instead of FindBaseNonInstanceMap
- Creature::Create with full parameter list
- Remove SaveToDB (complex in TC 11.x, use db_execute instead)
- LoadCreatureTemplates() instead of single-entry reload
- LOCALE_enUS for LocalizedString access
2025-12-06 16:28:41 -05:00
3df023b1d5 Fix MCP server shutdown segfault
Issues fixed:
- Prevent double shutdown with atomic exchange
- Remove logging during shutdown (may access destroyed singletons)
- Wrap destructor in try/catch for static destruction safety
- Simplified shutdown logic to avoid race conditions
- Don't reset _shutdownRequested to prevent re-init during destruction
2025-12-06 16:00:59 -05:00
1eff541bd0 Update MCP documentation with spawn tools 2025-12-06 15:58:23 -05:00
54f803253e Add headless spawn management tools to MCP server
New MCP tools that work without a player in-game:

- spawn_query: Query creatures spawned on a map (filter by entry/area)
- spawn_count: Get creature counts on a map
- spawn_creature: Force spawn a creature at a location
- reload_creatures: Reload creature templates from database
- console_command: Execute server console commands
- map_info: Get map information and creature counts

These tools enable AI assistants to:
- Validate spawn data after database imports
- Test creature spawns without logging in
- Query map state programmatically
- Reload creature data without restart

Part of the Scarlet Seer initiative for AI-assisted content development.
2025-12-06 15:57:47 -05:00
297f24ee1b Fix to macos segfault issue on Eluna GC 2025-12-06 09:10:54 -05:00
91031c06ec Clean up cmake setup to work better for lua between linux and macos. 2025-12-04 15:28:51 -05:00
e0aa2de5e0 Merge pull request #2 from araxiaonline/120225/feat/phase2
120225/feat/phase2
2025-12-04 05:20:33 -08:00
6a86120124 feat(mcp): Add ground height lookup and GM command execution
New MCP Tools:
- get_ground_height: VMAP/DB height lookup for spawn Z coordinates
- gm_command: Direct execution of go xyz, tele, gps, additem, die, revive

Key changes:
- WorldScan.cpp: Added GetGroundHeightAt() with VMAP + DB fallback
- ServerTools.cpp: Implemented gm_command with teleport support
- Updated MCP_SERVER.md with Dec 3 session summary

Validated Jade Forest import: 1,767 templates, 6,540 spawns working in-game
2025-12-03 19:41:15 -05:00
72510ee91e fix(mcp): Remove unused MMapFactory include 2025-12-03 19:26:01 -05:00
c2e1b557cc fix(waypoints): Display configuration and client refresh
- Fix waypoint markers showing as human models in 11.2.5 client
- Use Elven Wisp (displayId 1824) which renders correctly
- Add runtime display config via Lua shared data (no recompile needed)
- Add client refresh (DestroyForNearbyPlayers + UpdateObjectVisibilityOnCreate)
- Graceful MySQL error handling (no crash on bad MCP queries)
- Fix displayId arg parsing in VisualizeWaypointPath
- Add documentation for display IDs and configuration
2025-12-02 22:55:11 -05:00
90d3f69242 docs(content): Phase 2 - YAML Content System Design
Complete design documentation for the Araxia Content System:

## Core Documents
- README.md - Architecture overview and goals
- SCHEMA_REFERENCE.md - Complete YAML schema specifications
- CROSS_ENGINE.md - TrinityCore/AzerothCore compatibility plan
- IMPORTER_DESIGN.md - Import/Export/Diff tool design

## YAML Schemas Defined
- creature_template - NPC/mob definitions
- spawn - World spawn points
- encounter - Boss fight mechanics with phases
- instance - Dungeon/raid definitions
- loot_table - Drop tables
- patrol - Waypoint paths

## Cross-Engine Vision
- Abstract YAML layer (engine-agnostic)
- Engine adapters for TC and AC
- Translation tables for IDs
- Map compatibility matrix
- Content sharing between engines!

## Sample Content
- scarlet_champion.yml - Example creature template
- whitemane.yml - Full encounter definition with phases

## Key Features Planned
- YAML  Database import
- Database  YAML export
- Diff between versions
- Migration SQL generation
- Hot-reload for development
- MCP integration for AI assistance

Priority: Dungeons/Raids  World Content  Special Events
2025-12-01 20:30:08 -05:00
0efb7c7d7b feat(mcp): SCARLET VISION - The AI can now SEE!
World Scan WORKING! First successful scan in Scarlet Monastery:
- Detected walls using VMAP ray casting
- Found Scarlet Sentry, Disciple, Augur
- Generated room layout visualization

Fixes:
- VMapManager2.h include for full class definition
- Use VMapManager2* not IVMapManager*

Documentation:
- Updated MCP_SERVER.md with all learnings
- Added VMAP usage tips
- Added database safety notes
- Session summary with first world scan results

The moment we achieved spatial awareness:
  Location: Scarlet Monastery (2898.6, -802.9, 160.3)
  Creatures: 4 Scarlets surrounding player
  Room: Walls detected, corridor opening identified

Tonight we gave an AI eyes inside a game world.
2025-11-30 20:49:40 -05:00
444c1d12bc fix(mcp): Remove unused MMapFactory include 2025-11-30 20:35:52 -05:00
6fbead29bf feat(mcp): LIDAR-style world scan - I can SEE your surroundings!
New MCP tool: world_scan
- Casts rays in 360 degrees using VMAP collision data
- Detects walls, obstacles, room boundaries
- Detects all creatures in range with relative positions
- Generates ASCII art visualization

How it works:
1. Binary search ray casting using isInLineOfSight()
2. VMAP provides wall/building geometry
3. Nearby creatures enumerated with GetCreatureListInGrid()
4. ASCII map shows @ (you), # (walls), letters (creatures)

Example output:
+---------------------+
|   #######           |
|   # S       #       |
|   #    @>   #       |
|   #  D      #       |
|   ###########       |
+---------------------+

No player action needed - AI calls world_scan directly!
This gives me spatial awareness of your environment!
2025-11-30 20:26:18 -05:00
ab2a27f529 feat(mcp): Add semantic screenshot / UI state capture
New command: /mcpbridge ui
- Captures target info (name, GUID, level, health, type)
- Captures player info (position, zone, combat status)
- Captures mouseover, tooltip, open frames
- Stores in ElunaSharedData for MCP to read

New shared data keys:
- mcp_ui_state - Full UI state JSON
- mcp_current_target - Target details JSON

Usage:
1. Player runs /mcpbridge ui in WoW
2. AI reads via shared_data_read('mcp_current_target')
3. AI can now 'see' what you're targeting!

This enables visual debugging without actual screenshots.
2025-11-30 20:18:41 -05:00
e5ee53a1d8 feat(mcp): Add error handling & Event Bus design
Database Tools:
- Wrapped all queries in try/catch to prevent server crashes
- Errors returned as JSON instead of crashing
- Logged to araxia.mcp for debugging

AMS Bridge Fixes:
- Fixed AMS.RegisterHandler (dot not colon)
- Fixed JSON parsing for MCP messages
- Disabled auto-polling by default

Event Bus Design (EVENT_BUS_DESIGN.md):
- Unified pub/sub for C++ Core, Eluna, MCP, AMS
- Real-time event streaming (no polling)
- Enables MCP to see player targets, spawns, errors
- Phased implementation plan

Roadmap Updated:
- Phase 3: Content Creator Commands (non-GM)
- Phase 6: Event Bus implementation
2025-11-30 20:11:53 -05:00
ec14aa5545 feat(mcp): Complete Phase 2 - AMS Bridge & Direct Windsurf Connection!
HUGE MILESTONE: AI assistant now has direct real-time access to worldserver!

Phase 1 - Database & Server Tools:
- db_query, db_execute, db_tables, db_describe
- server_info, player_list, gm_command, reload_scripts

Phase 2 - Shared Data Bridge:
- shared_data_read, shared_data_write, shared_data_keys
- ElunaSharedData integration for cross-state communication
- Full client  MCP bidirectional data flow

AMS Bridge Implementation:
- Server: mcp_bridge.lua handles MCP_CHAT, MCP_CLIENT_LOG, MCP_GET_MESSAGES
- Client: MCPBridge.lua with /mcpbridge commands
- Data stored in ElunaSharedData, readable by MCP tools

Key Learnings Documented:
- nlohmann/json: Don't use value() with nullptr
- TrinityCore: Use GetBoolDefault() not GetOption<T>()
- AMS: Use AMS.Send (dot) not AMS:Send (colon) on client
- Smallfolk: Never serialize functions

Windsurf Integration:
- Add to ~/.codeium/windsurf/mcp_config.json
- AI gets direct access to all MCP tools
- No more manual curl commands!

This is SOOO FUCKING COOL!!!
2025-11-30 19:57:29 -05:00
ff78ae203b feat(mcp): Complete Phase 1 - Working MCP server with database tools
MCP Server is fully operational:
- Fixed JSON-RPC id field handling (can't use value() with nullptr)
- Fixed params extraction for tools/call
- All database tools working: db_query, db_execute, db_tables, db_describe
- Server tools working: server_info, player_list

Verified working:
- Health check endpoint returns ok
- tools/list returns all 9 registered tools
- db_query successfully queries world database

Documentation updated with:
- Implementation notes and API learnings
- File structure overview
- Phase roadmap
2025-11-30 19:11:54 -05:00
794630f1c1 fix(mcp): Suppress unused variable warning in gm_command 2025-11-30 18:51:03 -05:00
5a260341ce fix(mcp): Remove non-existent GetGameHour/GetGameTime methods 2025-11-30 18:46:47 -05:00
3705774f90 fix(mcp): Fix TrinityCore API compatibility issues
- Use GetBoolDefault/GetIntDefault/GetStringDefault instead of GetOption<T>
- Remove non-existent GetRealmName(), use hardcoded name
- Simplify Field access to just GetString() (no GetType())
- Handle null Alias in field metadata gracefully
2025-11-30 18:44:41 -05:00
54099cd629 feat(mcp): Add embedded MCP server for AI assistant integration
Phase 1 implementation of Araxia MCP Server:
- AraxiaMCPServer.cpp/.h - Core HTTP server using cpp-httplib
- DatabaseTools.cpp - db_query, db_execute, db_tables, db_describe
- ServerTools.cpp - server_info, player_list, gm_command, reload_scripts
- json.hpp (nlohmann) and httplib.h dependencies
- World.cpp integration for startup/shutdown
- Configuration via worldserver.conf (port 8765, bearer auth, localhost)

MCP Tools available:
- db_query: Safe SELECT queries on world/characters/auth
- db_execute: Logged INSERT/UPDATE/DELETE with audit trail
- db_tables: List tables in any database
- db_describe: Get table schema
- server_info: Uptime, player count, version
- player_list: Online players with details

Security: Localhost-only by default, bearer token auth, DDL blocked
2025-11-30 18:34:44 -05:00