Commit Graph
1161 Commits
Author SHA1 Message Date
luis 41f361a630 Fix crash 2026-03-24 19:30:23 -03:00
luis 6d3375f01d ready 2026-03-24 03:04:30 -03:00
luis fb7c43cd57 ++ 2026-03-24 03:00:32 -03:00
agatho 819706874b Accept quests immediately when already at quest giver
When SearchForQuestGivers found a quest giver at 0yd distance, it
deferred to the pending system which required another UpdateBehavior
tick. With the 150ms throttle and only ~6 calls per session, the
follow-up never happened.

Now resolves the creature and calls ProcessQuestGiver immediately
when the bot is already within interaction distance, instead of
deferring to the next tick.

Signed-off-by: luis <[email protected]>
2026-03-24 02:36:52 -03:00
agatho 8042cd9da8 Fix AbandonQuest not removing quests — add RemoveActiveQuest before every AbandonQuest call
Signed-off-by: luis <[email protected]>
2026-03-24 02:36:24 -03:00
agatho cca29fdfa0 Fix remaining bot idle issues and clean up diagnostic logging
- Abandon quests with no ender in DB immediately on first attempt
  instead of waiting for 3 failures (fixes quest 55660 blocking)
- Loot strategy only activates on game objects within INTERACTION_DISTANCE
  preventing distant spatial grid objects from blocking quest strategy
- Rest threshold lowered to 15-25% for no-consumable resting
  (was 30-50%, causing bots at 50% health to idle without food)
- Downgrade 275 TC_LOG_ERROR calls to TC_LOG_DEBUG in QuestStrategy
- Downgrade STRAT-SELECT diagnostic to TRACE
- Downgrade target scanner evaluation log to TRACE
- Downgrade auto-accept check diagnostic to DEBUG

Signed-off-by: luis <[email protected]>
2026-03-24 02:35:27 -03:00
agatho 1e9be20087 Add worker-thread-safe position cache from movespline to BotAI
bot->GetPositionX/Y/Z() is only updated on the main thread during
Player::Update(). Worker threads reading it mid-spline get stale data.

BotAI now caches the current position at the start of each UpdateAI():
- If a movespline is active: uses FinalDestination() as effective position
- If idle: uses last known server position

GetCurrentPosition() provides this cached value for any worker thread
code that needs accurate bot location. Quest strategy's pending quest
giver distance check now uses this instead of bot->GetPositionX/Y/Z().

Also re-added navmesh reachability check to spatial grid quest giver
scan to skip unreachable NPCs (towers, cliffs) before selection.

Signed-off-by: luis <[email protected]>
2026-03-24 02:34:40 -03:00
agatho c127948a26 Fix quest giver distance using spline destination instead of stale position
bot->GetPositionX/Y() returns the server-side position which lags behind
the client during active spline movement. The bot visually stands at the
NPC but GetExactDist2d reports 77yd because the position hasn't been
updated by the main thread yet.

Now uses movespline->FinalDestination() as the bot's effective position
when a spline is active. This matches where the client renders the bot.

Also re-added navmesh reachability check to the spatial grid scan to
skip unreachable NPCs (towers, cliffs) before selection.

Signed-off-by: luis <[email protected]>
2026-03-23 09:24:19 -03:00
agatho a5c8d85089 Rewrite SearchForQuestGivers to use spatial grid instead of live grid
SafeGridOperations::GetCreatureListSafe accessed the live grid which
returned stale creatures from the old map after teleports (worker thread
data race on m_currMap). The bot searched for quest givers on the wrong
continent.

Now uses DoubleBufferedSpatialGrid which provides lock-free atomic
snapshots updated by the main thread. Worker threads always read current
map data. The scan uses creature snapshot fields (hasQuestGiver, entry,
position, isDead) and quest relation DB lookups (thread-safe static data)
to find quest givers without touching any live creature pointers.

Quest acceptance still uses live creature pointers but only in the
pending quest giver arrival phase, when the bot is physically at the NPC
and the data is guaranteed current.

Signed-off-by: luis <[email protected]>
2026-03-23 09:21:44 -03:00
agatho 6746649e95 Revert quest log cleanup — bots earned their quests legitimately
Signed-off-by: luis <[email protected]>
2026-03-23 09:21:04 -03:00
agatho 7fb99f6fa8 Clear pre-loaded quest log on first quest strategy run
Signed-off-by: luis <[email protected]>
2026-03-23 09:20:31 -03:00
agatho 6566e59412 Add teleport cooldown and auto-accept diagnostics
Worker thread reads stale map/grid data after TeleportTo, causing quest
giver searches to return creatures from the old map. Added 5-second
cooldown after each teleport to let the main thread process the map
change before the quest strategy runs again.

Also added diagnostic logging to ProcessQuestGiver auto-accept phase
to trace why quests aren't being accepted (alreadyHas, blacklisted,
canTake, canAdd checks).

Added navmesh reachability check to quest giver selection and position
diagnostic for pending quest giver distance debugging.

Signed-off-by: luis <[email protected]>
2026-03-23 09:19:27 -03:00
agatho 572f6826af Validate quest giver navmesh reachability before selection
Bots walked to quest givers on unreachable terrain (towers, cliffs)
because SearchForQuestGivers selected by straight-line distance without
checking if the navmesh could path there. The bot stopped at the
closest navmesh point, 77+ yards from the NPC.

Now uses PathGenerator to verify navmesh reachability before selecting
a quest giver. Unreachable NPCs are skipped in favor of reachable ones.

Also allows interaction when the NPC is found via grid scan (within
50yd) even if the stored position distance is larger, handling cases
where navmesh pathing ends at a different point than the stored coords.

Signed-off-by: luis <[email protected]>
2026-03-23 09:17:23 -03:00
agatho 88e61e37bb Replace CastSpell hearthstone with TeleportTo for bot homebind travel
CastSpell(8690) failed silently for bots without a hearthstone item in
inventory (gear application failed at creation). Bots stood idle in
wrong zones because the hearthstone cast did nothing.

Use Player::TeleportTo(m_homebind) directly — no item required, no
cooldown, no cast time. This is already used elsewhere in the module
(AdvancedBehaviorManager, PlayerbotCommands, TravelRouteManager).

Signed-off-by: luis <[email protected]>
2026-03-23 09:16:49 -03:00
agatho a15abe4cc0 Refine stale route timeout to only fire when stuck walking to first dock
The 2-minute timeout incorrectly killed routes where the bot was
waiting for a ship, riding a transport, or on later legs. Now only
fires when stuck in WALKING_TO_TRANSPORT state on leg 0 — the specific
case caused by worker thread GetMapId() staleness after teleport.

Signed-off-by: luis <[email protected]>
2026-03-23 09:16:16 -03:00
agatho 8fdbe66c57 Add timeout-based stale route detection for worker thread map staleness
bot->GetMapId() returns stale data on worker threads after a teleport
because m_mapId is updated on the main thread only. The existing map
comparison check fails — the worker still sees the old map ID.

Added a 2-minute timeout: if the travel route has been active for over
2 minutes without completing the first leg, it's considered stale and
cleared. This handles the case where the bot hearthstoned to a
different map but the worker thread can't detect the map change.

Signed-off-by: luis <[email protected]>
2026-03-23 09:15:40 -03:00
agatho 017e21d98f Fix quest giver arrival check using 3D distance instead of 2D
Bots stopped 30+ yards from quest givers because 3D distance included
Z-height difference (stairs, ramps, platforms). The bot was visually
at the NPC but the 3D dist of 31yd > INTERACTION_DISTANCE of 5yd.

Switched all pending quest giver distance checks to 2D, matching how
WoW's gossip interaction works. Also widened grid scan to 50yd for
finding NPCs when ObjectAccessor fails.

Signed-off-by: luis <[email protected]>
2026-03-23 09:13:27 -03:00
agatho 04c06abf21 Fix false falling state blocking all bot movement
IsOnGround() returned false when GroundValidator::GetGroundHeight
returned INVALID_HEIGHT (map data not loaded), causing the state
machine to set MOVEMENTFLAG_FALLING. This permanently blocked
MovePoint from generating splines — bots stood idle despite movement
commands being issued every tick.

Changed INVALID_HEIGHT to assume on-ground (safe default). A bot at
a spawn point is never falling.

Also added INFO diagnostic to HandleOnTransport for travel visibility.

Signed-off-by: luis <[email protected]>
2026-03-23 09:12:39 -03:00
luis 2e2cdd1a08 Db fixes 2026-03-22 21:05:07 -03:00
luis 7564d3e5fa typo 2026-03-22 20:46:27 -03:00
luis 22fa9aaba3 Core/Players: Fixed custom playercreateinfo_item using 0 in race/class columns (should apply to all races/classes) 2026-03-22 20:05:02 -03:00
luis d9bdbf86b9 ++ 2026-03-22 20:03:13 -03:00
luis 84ae6f7bbc Core/GameObjects: Implement "EnableDoodadSets" for phaseableMO gameobject type 2026-03-22 19:32:20 -03:00
luis ee2721db00 Core/GameObjects: Initialize gameobject type before creating its model 2026-03-22 19:31:06 -03:00
luis a30688baab tmog sql 2026-03-22 19:29:02 -03:00
luis a2983a2961 typo 2026-03-22 19:07:16 -03:00
luis 0665cda727 typo 2026-03-22 19:05:38 -03:00
luis c9dab6ac93 new tmog still not ready wait for sqls 2026-03-22 18:57:22 -03:00
luis aed90f22e5 tmog part 1 2026-03-22 18:11:58 -03:00
luis 9ec349ebaf ++typo 2026-03-21 05:16:42 -03:00
luis 039a2fe347 ++ 2026-03-21 04:33:39 -03:00
luis 396ff73361 fix areatrigger issue on tp 2026-03-21 00:07:18 -03:00
luis 197894449f Core/Objects: Add ignoreNestedChangesMask argument to BuildValuesUpdateForPlayerWithMask functions 2026-03-21 00:04:33 -03:00
luis ab7ba67bcd Core/Objects: Fixed crashes happening when trying to force send dynamic/map/set updatefield changes 2026-03-20 22:49:31 -03:00
luis e73c288b95 66527 2026-03-20 22:42:30 -03:00
luis 3adc7d1ff9 mapflags 3 2026-03-20 22:42:04 -03:00
luis 07458287a8 Core: Updated allowed build to 12.0.1.66431 2026-03-20 22:30:19 -03:00
luis f7af1f5a5b fix lua 2026-03-20 20:45:24 -03:00
luis 06a7860594 Housing: Fix fixture hookpoint linking, door GO management, and map visibility
Fixture System:
- Use MeshObject GUIDs (HighGuid 56) for FHousingFixture_C Guid and
  AttachParentGUID fields instead of Housing GUIDs. The client's fixture
  manager searches the frame tree using AttachParentGUID as key, and frames
  are indexed by MeshObject entity GUIDs. This fixes fixture hookpoints
  showing "None" despite fixtures being spawned.
- Force-send AT entity CREATE/VALUES to player before ENTER_PLOT packet,
  matching the retail pattern where UPDATE_OBJECT and ENTER_PLOT arrive at
  the same timestamp.
- Set MAX_VISIBILITY_DISTANCE on HousingMap and HouseInteriorMap so all
  entities are visible map-wide, eliminating entity streaming race conditions.
- Add PreloadHousingMaps at server startup with LoadAllCells for
  neighborhood maps (validates map type before loading).

Fixture Placement:
- Door (entrance) replacement: placing a new door auto-removes any existing
  door at a different hook and despawns/respawns the clickable door GO.
- Hook exclusivity: placing a fixture removes any existing fixture at that
  hook first.
- Fix DELETE_FIXTURE handler: pass original hookID to RemoveFixture instead
  of resolved parent componentID. Fixtures are keyed by hookID.
- Remove default fixture respawn on delete (was causing flicker loop).

Door GO Management:
- Add RespawnDoorGOAtHook/DespawnDoorGO methods for targeted door GO
  updates without full house rebuild.
- Door GO positioned at fixture MeshObject location (exact hookpoint).
- Force-send CREATE to player immediately after spawning door GO.
- Auto-create missing door GO templates from ExteriorComponent DB2 at
  startup (EnsureDoorGameObjectTemplates) with retail values:
  Lock=4296, autoClose=3000, startOpen=1.

Interior Exit:
- Use ExteriorComponentExitPoint position for interior→exterior teleport,
  placing player in front of the door they entered through.

Other:
- Add MeshObject::AddRoomDoor for HousingRoomData Doors array population.
- Rename HousingPackets PlotAreaTriggerGuid to NeighborhoodEntityGuid.
2026-03-20 01:36:59 -03:00
luis ad0637b126 Pet Battles: Fix BattlePetState IDs from DB2, add per-type weather damage
Cross-referenced BattlePetState.db2 via wago.tools/WoWDBDefs and fixed
wrong state IDs: Stat_Accuracy is 41 (was 22=Mechanic_IsStunned),
Mod_HealingDealtPercent is 65 (was 26=Ramping_DamageID),
Mod_HealingTakenPercent is 66 (was 27=Ramping_DamageUses).

Added per-type weather damage bonus using the 3-state mechanism from
DB2: Mod_PetTypeDamageDealtPercent(87) + Mod_PetType_ID(89) restricts
damage bonuses to matching ability types (e.g. Rain = +25% Aquatic
only, not all damage). Also added Add_FlatDamageTaken(71) for
Sandstorm-style damage shields.

Expanded enum to 43 states covering weather markers (53-63, 316),
mechanics, cosmetics, and combat modifiers — all verified against
BattlePetState.db2 LuaName field.
2026-03-20 01:23:39 -03:00
luis 8f9c7c3de8 Pet Battles: Wire state-driven weather system from DB2
Replace dead hardcoded PetBattleWeatherType enum with a data-driven
weather system that reads BattlePetAbilityState entries from DB2.

The old system had SetWeather/GetWeatherDamageModifier/GetWeatherHealingModifier
functions but SetWeather was never called, so weather abilities fired
visually (aura icon appeared) but had zero gameplay effect.

Now weather modifiers (damage %, healing %, accuracy, speed) are loaded
from BattlePetAbilityState DB2 onto the environment slot when a weather
aura is applied, and read back during combat calculations. Elemental
pets remain immune to all weather effects.
2026-03-20 01:22:05 -03:00
agatho 8d65207489 Fix stale travel route blocking bots already on destination map
The stale route check only compared origin map, missing cases where
the bot spawned on the destination map (e.g. quest ender on same
continent). Route to Ratchet dock (Kalimdor) blocked a bot in
Northshire (Eastern Kingdoms) because originMapId matched.

Now also clears the route when the bot is already on the destination
map — no cross-map travel needed, just walk directly.

Added diagnostic logging to travel check for visibility.

Signed-off-by: luis <[email protected]>
2026-03-20 01:18:28 -03:00
agatho 2eaca0645a Clear stale travel route after map change from hearthstone
After hearthstoning to a new map, the travel manager's route (planned
for the old map) stayed active and blocked all quest processing. The
bot stood idle forever because UpdateBehavior returned early every tick.

Now detects when the bot's current map differs from the route's origin
map and clears the stale travel manager, allowing quest processing to
resume on the new map.

Also added INFO-level diagnostic to HandleOnTransport for travel
movement visibility.

Signed-off-by: luis <[email protected]>
2026-03-20 01:17:56 -03:00
agatho 0bf86c6aa0 Handle auto-accept quests (QUEST_FLAGS_AUTO_ACCEPT) for bots
Starting zone quests like Reclaiming Sunstrider Isle use the auto-accept
flag (0x80000) which bypasses the normal gossip menu. PrepareQuestMenu
doesn't include them, so bots stood idle at quest givers like Magistrix
Erona without accepting anything.

SearchForQuestGivers now also checks quest relations for auto-accept
quests when evaluating NPCs. ProcessQuestGiver runs auto-accept quests
first via AddQuestAndCheckCompletion before processing the gossip menu
for normal quests.

Signed-off-by: luis <[email protected]>
2026-03-20 01:17:25 -03:00
agatho 6dc54587b1 Fix quest giver interaction failing when ObjectAccessor can't find NPC
ObjectAccessor::GetCreature fails for some NPCs even when the bot is
standing next to them. Added grid scan fallback using creature entry
from the GUID to find the actual NPC within interaction range.

Also switched to 2D distance for position-based checks to prevent
Z-height differences from causing false "too far" results.

Signed-off-by: luis <[email protected]>
2026-03-20 01:16:51 -03:00
agatho 5614394566 Allow cross-map quest hub search and hearthstone travel
QuestHubDatabase::IsAppropriateFor no longer restricts to same map,
so bots stranded on a continent with no level-appropriate content can
find hubs on other maps. Cross-map hubs get a 0.5x scoring penalty to
prefer same-map when available.

When no quest hubs or quest givers are found nearby, bots now:
1. Search QuestHubDatabase across all maps
2. If best hub is cross-map and hearthstone goes there, cast hearthstone
3. If best hub needs multi-leg travel, use TravelRouteManager
4. If no hubs at all, use hearthstone as last resort

Signed-off-by: luis <[email protected]>
2026-03-20 01:16:13 -03:00
agatho 94a0a769d5 Use PrepareQuestMenu for quest eligibility instead of CanTakeQuest
CanTakeQuest returned true for quests that weren't actually available
in-game because ContentTuning data was missing, making GetQuestMinLevel
return 0. Bots walked to NPCs that had no quests to offer.

Replace manual quest relation iteration + CanTakeQuest with
Player::PrepareQuestMenu which is TrinityCore's authoritative check
for quest availability. This is the same system that renders quest
exclamation marks for real players and properly handles ContentTuning,
phase visibility, conditions, and all edge cases.

Applied to both SearchForQuestGivers (scan phase) and ProcessQuestGiver
(acceptance phase).

Signed-off-by: luis <[email protected]>
2026-03-20 01:15:31 -03:00
agatho facd9e31e0 Fix pending quest giver lost when ObjectAccessor fails
The pending quest giver check used ObjectAccessor::GetCreature which
can fail for phased/special NPCs like Image of Archmage Xylem, causing
the GUID to be cleared and the bot to stop walking mid-path.

Now stores the NPC position alongside the GUID. The bot walks to the
stored position even if creature lookup fails, and attempts grid scan
for quest givers on arrival. Also logs at INFO level for diagnosis.

Signed-off-by: luis <[email protected]>
2026-03-20 01:14:53 -03:00
agatho cd2722498d Fix rest threshold randomized every tick causing inconsistent behavior
The critical rest threshold (no consumables path) was calling frand()
on every IsActive() check, producing a different threshold each tick.
Bots at moderate health (49-53%) would flicker between rest and other
strategies because the random threshold kept changing.

Moved to a per-bot threshold assigned once at construction (30-50%)
so each bot has a stable, unique resting personality.

Signed-off-by: luis <[email protected]>
2026-03-20 01:14:25 -03:00
agatho 281f8ac25e Fix corpses not marked as looted after bot picks up items
Add SendLootRelease() after looting all items from a corpse. Without
this, the corpse stayed "lootable" forever and FindLootableCorpses kept
returning it, causing loot strategy to permanently block quest strategy.

Signed-off-by: luis <[email protected]>
2026-03-20 01:13:46 -03:00