Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/server/game/AI/CreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ class CreatureAI : public UnitAI
// Called at waypoint reached or point movement finished
virtual void MovementInform(uint32 /*type*/, uint32 /*id*/) {}

// Called at MovePath End
virtual void PathEndReached(uint32 /*pathId*/) {}

/// == Waypoints system =============================

virtual void WaypointPathStarted(uint32 /*pathId*/) { }
Expand Down
9 changes: 3 additions & 6 deletions src/server/game/AI/SmartScripts/SmartAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,12 +1329,6 @@ void SmartAI::OnSpellClick(Unit* clicker, bool& /*result*/)
GetScript()->ProcessEventsFor(SMART_EVENT_ON_SPELLCLICK, clicker);
}

void SmartAI::PathEndReached(uint32 /*pathId*/)
{
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, nullptr, 0, me->GetWaypointPath());
me->LoadPath(0);
}

void SmartAI::WaypointPathStarted(uint32 /*pathId*/)
{
}
Expand All @@ -1345,6 +1339,9 @@ void SmartAI::WaypointStarted(uint32 /*nodeId*/, uint32 /*pathId*/)

void SmartAI::WaypointReached(uint32 nodeId, uint32 pathId)
{
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, nullptr, 0, me->GetWaypointPath());
me->LoadPath(0);
Comment on lines +1342 to +1343

@coderabbitai coderabbitai Bot Aug 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
rg -n -A35 -B10 \
  'WaypointReached|WaypointPathEnded|pathEnded|LoadPath\(0\)' \
  src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp \
  src/server/game/AI/SmartScripts/SmartAI.cpp

Repository: azerothcore/azerothcore-wotlk

Length of output: 23972


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- changed SmartAI diff ---'
git diff -- src/server/game/AI/SmartScripts/SmartAI.cpp

printf '%s\n' '--- callback declarations and implementations ---'
rg -n -A12 -B8 \
  'WaypointPathEnded|WaypointReached|LoadPath\(uint32|LoadPath\(0\)|SMART_EVENT_WAYPOINT_ENDED|SMART_EVENT_WAYPOINT_REACHED' \
  src/server/game/AI src/server/game/Entities src/server/game/Movement

printf '%s\n' '--- relevant current source ---'
sed -n '1315,1365p' src/server/game/AI/SmartScripts/SmartAI.cpp
sed -n '125,205p' src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp

Repository: azerothcore/azerothcore-wotlk

Length of output: 46034


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- checkout state ---'
git status --short
git log -1 --oneline

printf '%s\n' '--- parent implementation ---'
git show HEAD^:src/server/game/AI/SmartScripts/SmartAI.cpp | sed -n '1328,1362p'
git show HEAD^:src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp | sed -n '135,202p'

printf '%s\n' '--- all Creature::LoadPath(0) callers ---'
rg -n -B8 -A8 'me->LoadPath\(0\)|LoadPath\(0\)' src

printf '%s\n' '--- event filter and path state ---'
sed -n '5018,5036p' src/server/game/AI/SmartScripts/SmartScript.cpp
sed -n '350,366p' src/server/game/Entities/Creature/Creature.h

Repository: azerothcore/azerothcore-wotlk

Length of output: 9425


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- merge commit parents ---'
git show -s --format='%H%n%P%n%B' HEAD

printf '%s\n' '--- file diff against first parent ---'
git diff --stat HEAD^1 HEAD -- src/server/game/AI/SmartScripts/SmartAI.cpp src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
git diff HEAD^1 HEAD -- src/server/game/AI/SmartScripts/SmartAI.cpp src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp

printf '%s\n' '--- file diff against second parent ---'
git diff --stat HEAD^2 HEAD -- src/server/game/AI/SmartScripts/SmartAI.cpp src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
git diff HEAD^2 HEAD -- src/server/game/AI/SmartScripts/SmartAI.cpp src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp

printf '%s\n' '--- combined diff for the target method ---'
git diff --cc HEAD -- src/server/game/AI/SmartScripts/SmartAI.cpp

Repository: azerothcore/azerothcore-wotlk

Length of output: 3153


Move path-end processing to WaypointPathEnded. WaypointReached runs for every waypoint, so these lines dispatch SMART_EVENT_WAYPOINT_ENDED and clear Creature::m_path_id before the path ends; the final callback can dispatch the event again. Remove both lines from WaypointReached and process the event and path reset once in WaypointPathEnded.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need help here, should I keep it like this or is there another way?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PkllonG Do not keep these lines in WaypointReached; that callback runs at every waypoint. Move both lines to WaypointPathEnded, before its return, so SMART_EVENT_WAYPOINT_ENDED dispatches once when the path ends and me->LoadPath(0) clears the completed path once.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No errors were found after testing, like .go c 139275

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PkllonG, the test result is useful, but it does not validate the callback timing. WaypointReached still runs at every node, so SMART_EVENT_WAYPOINT_ENDED and me->LoadPath(0) must remain in WaypointPathEnded to run once at path completion.

You are interacting with an AI system.


if (!HasEscortState(SMART_ESCORT_ESCORTING))
{
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_REACHED, nullptr, nodeId, pathId);
Expand Down
2 changes: 0 additions & 2 deletions src/server/game/AI/SmartScripts/SmartAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ class SmartAI : public CreatureAI

void OnSpellClick(Unit* clicker, bool& result) override;

void PathEndReached(uint32 pathId) override;

void WaypointPathStarted(uint32 pathId) override;
void WaypointStarted(uint32 nodeId, uint32 pathId) override;
void WaypointReached(uint32 nodeId, uint32 pathId) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@ void WaypointMovementGenerator<Creature>::ProcessWaypointArrival(Creature* creat
{
creature->UpdateCurrentWaypointInfo(0, 0);

if (CreatureAI* AI = creature->AI())
AI->PathEndReached(pathId);

// Re-fetch AI — PathEndReached may have despawned the creature or swapped its AI
if (CreatureAI* AI = creature->AI())
AI->WaypointPathEnded(waypointId, pathId);
}
Expand Down Expand Up @@ -441,10 +437,7 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
_done = true;
_smoothSplineLaunched = false;
creature->UpdateCurrentWaypointInfo(0, 0);
if (CreatureAI* AI = creature->AI())
AI->PathEndReached(endPathId);

// Re-fetch AI — PathEndReached may have despawned the creature or swapped its AI
if (CreatureAI* AI = creature->AI())
AI->WaypointPathEnded(endWpId, endPathId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct boss_chromaggus : public BossAI
}
}

void PathEndReached(uint32 /*pathId*/) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
{
if (Unit* player = ObjectAccessor::GetUnit(*me, _playerGUID))
me->SetInCombatWith(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ struct boss_nefarian : public BossAI
}
}

void PathEndReached(uint32 /*pathId*/) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
{
me->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
me->SetCanFly(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ struct boss_nightbane : public BossAI
ScriptedAI::MoveInLineOfSight(who);
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 nodeId, uint32 pathId) override
{
BossAI::PathEndReached(pathId);
BossAI::WaypointPathEnded(nodeId, pathId);
if (pathId == me->GetEntry()*10) // intro
{
me->GetMap()->SetVisibilityRange(DEFAULT_VISIBILITY_INSTANCE); // restore visibility
Expand Down
4 changes: 2 additions & 2 deletions src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ struct boss_jeklik : public BossAI
me->GetMotionMaster()->MoveWaypoint(PATH_JEKLIK_INTRO, false);
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 nodeId, uint32 pathId) override
{
BossAI::PathEndReached(pathId);
BossAI::WaypointPathEnded(nodeId, pathId);

me->SetDisableGravity(false);
me->SetCombatMovement(true);
Expand Down
4 changes: 2 additions & 2 deletions src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct npc_cameron : public ScriptedAI
me->GetMotionMaster()->MovePoint(0, MovePosPositions.back());
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
{
switch (pathId)
{
Expand Down Expand Up @@ -390,7 +390,7 @@ struct npc_eastvale_peasent : public ScriptedAI
}
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
{
if (pathId == _path)
{
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct npc_partygoer_pather : public ScriptedAI
_events.ScheduleEvent(EVENT_RANDOM_ACTION_PATHER, 11s, 14s);
}

void PathEndReached(uint32 /*pathId*/) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
{
++_path;
if (_path > 594444)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct boss_anetheron : public BossAI
me->GetMotionMaster()->MoveWaypoint(urand(ALLIANCE_BASE_CHARGE_1, ALLIANCE_BASE_CHARGE_3), false);
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
{
switch (pathId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct boss_rage_winterchill : public BossAI
me->GetMotionMaster()->MoveWaypoint(urand(ALLIANCE_BASE_CHARGE_1, ALLIANCE_BASE_CHARGE_3), false);
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
{
switch (pathId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class npc_hyjal_jaina : public CreatureScript
hyjal->SetData(DATA_RESET_ALLIANCE, 0);
}

void PathEndReached(uint32 /*pathId*/) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
{
DoCastSelf(SPELL_MASS_TELEPORT);
Talk(SAY_TELEPORT);
Expand Down Expand Up @@ -501,7 +501,7 @@ struct npc_hyjal_ground_trash : public ScriptedAI
}
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
{
// Delay is required because we are calling the movement generator from inside the pathing hook.
// If we issue another call here, it will be flushed before it is executed.
Expand Down Expand Up @@ -615,7 +615,7 @@ struct npc_hyjal_gargoyle : public ScriptedAI
}
}

void PathEndReached(uint32 /* pathId */) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
{
// TODO: Do they do something special after finishing the path?
me->m_Events.AddEventAtOffset([this]()
Expand Down Expand Up @@ -681,7 +681,7 @@ struct npc_hyjal_frost_wyrm : public ScriptedAI
}
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
{
if (pathId == FROST_WYRM_FORTRESS)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ struct npc_hive_zara_swarmer : public ScriptedAI
{
npc_hive_zara_swarmer(Creature* creature) : ScriptedAI(creature) { }

void PathEndReached(uint32 /*pathId*/) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
{
// Delay is required because we are calling the movement generator from inside the pathing hook.
// If we issue another call here, it will be flushed before it is executed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ struct brann_bronzebeard : public ScriptedAI
}
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
{
switch (pathId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct boss_ambassador_hellmaw : public BossAI
ScriptedAI::AttackStart(who);
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
{
if (pathId == PATH_ID_START)
{
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Outland/BlackTemple/boss_illidan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ struct npc_akama_illidan : public ScriptedAI
}
}

void PathEndReached(uint32 pathId) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
{
switch (pathId)
{
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Outland/zone_shadowmoon_valley.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ struct dragonmaw_race_npc : public ScriptedAI
}
}

void PathEndReached(uint32 /*pathId*/) override
void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
{
Reset();
}
Expand Down
Loading