aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/SmartScripts
diff options
context:
space:
mode:
authorModoX <moardox@gmail.com>2024-01-05 17:56:19 +0100
committerGitHub <noreply@github.com>2024-01-05 17:56:19 +0100
commit12186ef8573f60abeff4747da58767ee71092600 (patch)
tree7d9a1da93e86fa3ccd84c02658bface3ef536721 /src/server/game/AI/SmartScripts
parent390f0be9fb22766638006f43e4d0887108ba49e8 (diff)
Core/Waypoints: Refactor to split data into path and node related info in db (#29506)
Diffstat (limited to 'src/server/game/AI/SmartScripts')
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp26
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp12
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h2
5 files changed, 22 insertions, 22 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 3918f415f9d..370e2d1a9f8 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -33,7 +33,7 @@
#include "WaypointManager.h"
SmartAI::SmartAI(Creature* creature, uint32 scriptId) : CreatureAI(creature, scriptId), _charmed(false), _followCreditType(0), _followArrivedTimer(0), _followCredit(0), _followArrivedEntry(0), _followDistance(0.f), _followAngle(0.f),
- _escortState(SMART_ESCORT_NONE), _escortNPCFlags(0), _escortInvokerCheckTimer(1000), _currentWaypointNode(0), _waypointReached(false), _waypointPauseTimer(0), _waypointPauseForced(false), _repeatWaypointPath(false),
+ _escortState(SMART_ESCORT_NONE), _escortNPCFlags(0), _escortInvokerCheckTimer(1000), _currentWaypointNodeId(0), _waypointReached(false), _waypointPauseTimer(0), _waypointPauseForced(false), _repeatWaypointPath(false),
_OOCReached(false), _waypointPathEnded(false), _run(true), _evadeDisabled(false), _canCombatMove(true), _invincibilityHPLevel(0), _despawnTime(0), _despawnState(0), _vehicleConditionsTimer(0),
_gossipReturn(false), _escortQuestId(0)
{
@@ -57,7 +57,7 @@ void SmartAI::StartPath(uint32 pathId/* = 0*/, bool repeat/* = false*/, Unit* in
if (!path)
return;
- _currentWaypointNode = nodeId;
+ _currentWaypointNodeId = nodeId;
_waypointPathEnded = false;
_repeatWaypointPath = repeat;
@@ -80,7 +80,7 @@ WaypointPath const* SmartAI::LoadPath(uint32 entry)
return nullptr;
WaypointPath const* path = sWaypointMgr->GetPath(entry);
- if (!path || path->nodes.empty())
+ if (!path || path->Nodes.empty())
{
GetScript()->SetPathId(0);
return nullptr;
@@ -105,7 +105,7 @@ void SmartAI::PausePath(uint32 delay, bool forced)
if (HasEscortState(SMART_ESCORT_PAUSED))
{
- TC_LOG_ERROR("scripts.ai.sai", "SmartAI::PausePath: Creature wanted to pause waypoint (current waypoint: {}) movement while already paused, ignoring. ({})", _currentWaypointNode, me->GetGUID().ToString());
+ TC_LOG_ERROR("scripts.ai.sai", "SmartAI::PausePath: Creature wanted to pause waypoint (current waypoint: {}) movement while already paused, ignoring. ({})", _currentWaypointNodeId, me->GetGUID().ToString());
return;
}
@@ -122,7 +122,7 @@ void SmartAI::PausePath(uint32 delay, bool forced)
_waypointReached = false;
AddEscortState(SMART_ESCORT_PAUSED);
- GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_PAUSED, nullptr, _currentWaypointNode, GetScript()->GetPathId());
+ GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_PAUSED, nullptr, _currentWaypointNodeId, GetScript()->GetPathId());
}
bool SmartAI::CanResumePath()
@@ -170,7 +170,7 @@ void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail)
me->GetMotionMaster()->MoveIdle();
- GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_STOPPED, nullptr, _currentWaypointNode, GetScript()->GetPathId());
+ GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_STOPPED, nullptr, _currentWaypointNodeId, GetScript()->GetPathId());
EndPath(fail);
}
@@ -235,7 +235,7 @@ void SmartAI::EndPath(bool fail)
return;
uint32 pathid = GetScript()->GetPathId();
- GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, nullptr, _currentWaypointNode, pathid);
+ GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, nullptr, _currentWaypointNodeId, pathid);
if (_repeatWaypointPath)
{
@@ -251,7 +251,7 @@ void SmartAI::EndPath(bool fail)
void SmartAI::ResumePath()
{
- GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_RESUMED, nullptr, _currentWaypointNode, GetScript()->GetPathId());
+ GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_RESUMED, nullptr, _currentWaypointNodeId, GetScript()->GetPathId());
RemoveEscortState(SMART_ESCORT_PAUSED);
@@ -349,9 +349,9 @@ void SmartAI::WaypointReached(uint32 nodeId, uint32 pathId)
return;
}
- _currentWaypointNode = nodeId;
+ _currentWaypointNodeId = nodeId;
- GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_REACHED, nullptr, _currentWaypointNode, pathId);
+ GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_REACHED, nullptr, _currentWaypointNodeId, pathId);
if (_waypointPauseTimer && !_waypointPauseForced)
{
@@ -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.back().id)
+ if (path && _currentWaypointNodeId == path->Nodes.back().Id)
_waypointPathEnded = true;
else
SetRun(_run);
@@ -535,8 +535,8 @@ void SmartAI::JustReachedHome()
{
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType(MOTION_SLOT_DEFAULT) != WAYPOINT_MOTION_TYPE)
{
- if (me->GetWaypointPath())
- me->GetMotionMaster()->MovePath(me->GetWaypointPath(), true);
+ if (me->GetWaypointPathId())
+ me->GetMotionMaster()->MovePath(me->GetWaypointPathId(), true);
}
me->ResumeMovement();
diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h
index de11f4b7e00..e42e0b53b44 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.h
+++ b/src/server/game/AI/SmartScripts/SmartAI.h
@@ -253,7 +253,7 @@ class TC_GAME_API SmartAI : public CreatureAI
uint32 _escortState;
uint32 _escortNPCFlags;
uint32 _escortInvokerCheckTimer;
- uint32 _currentWaypointNode;
+ uint32 _currentWaypointNodeId;
bool _waypointReached;
uint32 _waypointPauseTimer;
bool _waypointPauseForced;
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index b3c7be43c7a..c1e398bc37f 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -2066,17 +2066,17 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (uint32 pathId : waypoints)
{
WaypointPath const* path = sWaypointMgr->GetPath(pathId);
- if (!path || path->nodes.empty())
+ if (!path || path->Nodes.empty())
continue;
- for (WaypointNode const& waypoint : path->nodes)
+ for (WaypointNode const& waypoint : path->Nodes)
{
- float distamceToThisNode = creature->GetDistance(waypoint.x, waypoint.y, waypoint.z);
- if (distamceToThisNode < distanceToClosest)
+ float distanceToThisNode = creature->GetDistance(waypoint.X, waypoint.Y, waypoint.Z);
+ if (distanceToThisNode < distanceToClosest)
{
- distanceToClosest = distamceToThisNode;
+ distanceToClosest = distanceToThisNode;
closest.first = pathId;
- closest.second = waypoint.id;
+ closest.second = waypoint.Id;
}
}
}
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index 2aa5a25e129..a5e63f5ef22 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -1879,7 +1879,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_ACTION_WP_START:
{
WaypointPath const* path = sWaypointMgr->GetPath(e.action.wpStart.pathID);
- if (!path || path->nodes.empty())
+ if (!path || path->Nodes.empty())
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Creature {} Event {} Action {} uses non-existent WaypointPath id {}, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.wpStart.pathID);
return false;
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 904c21544ab..6108bc3144b 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -868,7 +868,7 @@ struct SmartAction
struct
{
- SAIBool run; // unused / overridden by waypoint_data
+ SAIBool run; // unused defined by waypoint_path
uint32 pathID;
SAIBool repeat;
uint32 quest;