aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeji <alvaro.megias@outlook.com>2023-06-24 19:21:37 +0200
committerGitHub <noreply@github.com>2023-06-24 19:21:37 +0200
commit76d2f29e4e4c0e14a014676aafff2f8836f96ea0 (patch)
treea775a7fd68b525a73a72ec8c25f3c6edbc76fa33
parent76a84fcc868d794af439fe8441b0f820db764b87 (diff)
Core/SAI: Fixed event SMART_EVENT_WAYPOINT_ENDED (#29025)
* also moved "any" pointid to 0xFFFFFFFF for waypoint sai events: * SMART_EVENT_WAYPOINT_REACHED * SMART_EVENT_WAYPOINT_RESUMED * SMART_EVENT_WAYPOINT_PAUSED * SMART_EVENT_WAYPOINT_STOPPED * SMART_EVENT_WAYPOINT_ENDED
-rw-r--r--sql/updates/world/master/2023_06_24_01_world.sql2
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp8
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp2
4 files changed, 8 insertions, 6 deletions
diff --git a/sql/updates/world/master/2023_06_24_01_world.sql b/sql/updates/world/master/2023_06_24_01_world.sql
new file mode 100644
index 00000000000..39d8a48871c
--- /dev/null
+++ b/sql/updates/world/master/2023_06_24_01_world.sql
@@ -0,0 +1,2 @@
+--
+UPDATE `smart_scripts` SET `event_param1`=0xFFFFFFFF WHERE `event_type` IN (40,55,56,57,58) AND `event_param1`=0;
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 0b83f83643d..372ba77f711 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -45,7 +45,7 @@ bool SmartAI::IsAIControlled() const
return !_charmed;
}
-void SmartAI::StartPath(uint32 pathId/* = 0*/, bool repeat/* = false*/, Unit* invoker/* = nullptr*/, uint32 nodeId/* = 1*/)
+void SmartAI::StartPath(uint32 pathId/* = 0*/, bool repeat/* = false*/, Unit* invoker/* = nullptr*/, uint32 nodeId/* = 0*/)
{
if (HasEscortState(SMART_ESCORT_ESCORTING))
StopPath();
@@ -149,12 +149,12 @@ void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail)
me->GetMotionMaster()->MoveIdle();
- if (waypointInfo.first)
+ if (waypointInfo.second)
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_STOPPED, nullptr, waypointInfo.first, waypointInfo.second);
if (!fail)
{
- if (waypointInfo.first)
+ if (waypointInfo.second)
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, nullptr, waypointInfo.first, waypointInfo.second);
if (_despawnState == 1)
StartDespawn();
@@ -362,7 +362,7 @@ void SmartAI::WaypointReached(uint32 nodeId, uint32 pathId)
else if (HasEscortState(SMART_ESCORT_ESCORTING) && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
{
WaypointPath const* path = sWaypointMgr->GetPath(pathId);
- if (path && _currentWaypointNode == path->nodes.size())
+ if (path && _currentWaypointNode == path->nodes.back().id)
_waypointPathEnded = true;
else
SetRun(_run);
diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h
index a83e5175066..de11f4b7e00 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.h
+++ b/src/server/game/AI/SmartScripts/SmartAI.h
@@ -49,7 +49,7 @@ class TC_GAME_API SmartAI : public CreatureAI
bool IsAIControlled() const;
// Start moving to the desired MovePoint
- void StartPath(uint32 pathId = 0, bool repeat = false, Unit* invoker = nullptr, uint32 nodeId = 1);
+ void StartPath(uint32 pathId = 0, bool repeat = false, Unit* invoker = nullptr, uint32 nodeId = 0);
WaypointPath const* LoadPath(uint32 entry);
void PausePath(uint32 delay, bool forced = false);
bool CanResumePath();
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index fb42e3105aa..47c5dd279fd 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -3340,7 +3340,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
case SMART_EVENT_WAYPOINT_STOPPED:
case SMART_EVENT_WAYPOINT_ENDED:
{
- if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && var1 != e.event.waypoint.pathID))
+ if (!me || (e.event.waypoint.pointID != 0xFFFFFFFF && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && var1 != e.event.waypoint.pathID))
return;
ProcessAction(e, unit);
break;