mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-28 16:16:27 +00:00
feature(SmartAI/Movement) - Unify waypoint systems (#23251)
This commit is contained in:
@@ -108,20 +108,20 @@ void SmartAI::UpdateDespawn(const uint32 diff)
|
||||
mDespawnTime -= diff;
|
||||
}
|
||||
|
||||
WayPoint* SmartAI::GetNextWayPoint()
|
||||
WaypointData const* SmartAI::GetNextWayPoint()
|
||||
{
|
||||
if (!mWayPoints || mWayPoints->empty())
|
||||
return nullptr;
|
||||
|
||||
mCurrentWPID++;
|
||||
WPPath::const_iterator itr = mWayPoints->find(mCurrentWPID);
|
||||
auto itr = mWayPoints->find(mCurrentWPID);
|
||||
if (itr != mWayPoints->end())
|
||||
{
|
||||
mLastWP = (*itr).second;
|
||||
mLastWP = &(*itr).second;
|
||||
if (mLastWP->id != mCurrentWPID)
|
||||
LOG_ERROR("scripts.ai.sai", "SmartAI::GetNextWayPoint: Got not expected waypoint id {}, expected {}", mLastWP->id, mCurrentWPID);
|
||||
|
||||
return (*itr).second;
|
||||
return &(*itr).second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -138,12 +138,15 @@ void SmartAI::GenerateWayPointArray(Movement::PointsArray* points)
|
||||
points->clear();
|
||||
points->push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
|
||||
uint32 wpCounter = mCurrentWPID;
|
||||
WPPath::const_iterator itr;
|
||||
while ((itr = mWayPoints->find(wpCounter++)) != mWayPoints->end())
|
||||
auto itr = mWayPoints->find(wpCounter++);
|
||||
do
|
||||
{
|
||||
WayPoint* wp = (*itr).second;
|
||||
points->push_back(G3D::Vector3(wp->x, wp->y, wp->z));
|
||||
WaypointData const& wp = (*itr).second;
|
||||
points->push_back(G3D::Vector3(wp.x, wp.y, wp.z));
|
||||
|
||||
itr = mWayPoints->find(wpCounter++);
|
||||
}
|
||||
while (itr != mWayPoints->end());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -152,16 +155,17 @@ void SmartAI::GenerateWayPointArray(Movement::PointsArray* points)
|
||||
std::vector<G3D::Vector3> pVector;
|
||||
// xinef: first point in vector is unit real position
|
||||
pVector.push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
|
||||
uint32 length = (mWayPoints->size() - mCurrentWPID) * size;
|
||||
|
||||
uint32 cnt = 0;
|
||||
uint32 wpCounter = mCurrentWPID;
|
||||
WPPath::const_iterator itr;
|
||||
while ((itr = mWayPoints->find(wpCounter++)) != mWayPoints->end() && cnt++ <= length)
|
||||
|
||||
auto itr = mWayPoints->find(wpCounter++);
|
||||
do
|
||||
{
|
||||
WayPoint* wp = (*itr).second;
|
||||
pVector.push_back(G3D::Vector3(wp->x, wp->y, wp->z));
|
||||
WaypointData const& wp = (*itr).second;
|
||||
pVector.push_back(G3D::Vector3(wp.x, wp.y, wp.z));
|
||||
|
||||
itr = mWayPoints->find(wpCounter++);
|
||||
}
|
||||
while (itr != mWayPoints->end());
|
||||
|
||||
if (pVector.size() > 2) // more than source + dest
|
||||
{
|
||||
@@ -189,21 +193,21 @@ void SmartAI::GenerateWayPointArray(Movement::PointsArray* points)
|
||||
}
|
||||
}
|
||||
|
||||
void SmartAI::StartPath(ForcedMovement forcedMovement, uint32 path, bool repeat, Unit* invoker)
|
||||
void SmartAI::StartPath(ForcedMovement forcedMovement, uint32 path, bool repeat, Unit* invoker, PathSource pathSource)
|
||||
{
|
||||
if (HasEscortState(SMART_ESCORT_ESCORTING))
|
||||
StopPath();
|
||||
|
||||
if (path)
|
||||
{
|
||||
if (!LoadPath(path))
|
||||
if (!LoadPath(path, pathSource))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mWayPoints || mWayPoints->empty())
|
||||
return;
|
||||
|
||||
if (WayPoint* wp = GetNextWayPoint())
|
||||
if (WaypointData const* wp = GetNextWayPoint())
|
||||
{
|
||||
AddEscortState(SMART_ESCORT_ESCORTING);
|
||||
mCanRepeatPath = repeat;
|
||||
@@ -219,20 +223,37 @@ void SmartAI::StartPath(ForcedMovement forcedMovement, uint32 path, bool repeat,
|
||||
GenerateWayPointArray(&pathPoints);
|
||||
|
||||
me->GetMotionMaster()->MoveSplinePath(&pathPoints, mForcedMovement);
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, nullptr, wp->id, GetScript()->GetPathId());
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_ESCORT_START, nullptr, wp->id, GetScript()->GetPathId());
|
||||
}
|
||||
}
|
||||
|
||||
bool SmartAI::LoadPath(uint32 entry)
|
||||
bool SmartAI::LoadPath(uint32 entry, PathSource pathSource)
|
||||
{
|
||||
if (HasEscortState(SMART_ESCORT_ESCORTING))
|
||||
return false;
|
||||
|
||||
mWayPoints = sSmartWaypointMgr->GetPath(entry);
|
||||
if (!mWayPoints)
|
||||
switch (pathSource)
|
||||
{
|
||||
GetScript()->SetPathId(0);
|
||||
return false;
|
||||
case PathSource::SMART_WAYPOINT_MGR:
|
||||
{
|
||||
mWayPoints = sSmartWaypointMgr->GetPath(entry);
|
||||
if (!mWayPoints)
|
||||
{
|
||||
GetScript()->SetPathId(0);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PathSource::WAYPOINT_MGR:
|
||||
{
|
||||
mWayPoints = sWaypointMgr->GetPath(entry);
|
||||
if (!mWayPoints)
|
||||
{
|
||||
GetScript()->SetPathId(0);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GetScript()->SetPathId(entry);
|
||||
@@ -262,12 +283,12 @@ void SmartAI::PausePath(uint32 delay, bool forced)
|
||||
me->GetMotionMaster()->MoveIdle();//force stop
|
||||
|
||||
auto waypoint = mWayPoints->find(mCurrentWPID);
|
||||
if (waypoint->second->o.has_value())
|
||||
if (waypoint->second.orientation.has_value())
|
||||
{
|
||||
me->SetFacingTo(waypoint->second->o.has_value());
|
||||
me->SetFacingTo(*waypoint->second.orientation);
|
||||
}
|
||||
}
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_PAUSED, nullptr, mCurrentWPID, GetScript()->GetPathId());
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_ESCORT_PAUSED, nullptr, mCurrentWPID, GetScript()->GetPathId());
|
||||
}
|
||||
|
||||
void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail)
|
||||
@@ -285,7 +306,7 @@ void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail)
|
||||
|
||||
me->StopMoving();
|
||||
me->GetMotionMaster()->MoveIdle();
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_STOPPED, nullptr, mCurrentWPID, GetScript()->GetPathId());
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_ESCORT_STOPPED, nullptr, mCurrentWPID, GetScript()->GetPathId());
|
||||
EndPath(fail);
|
||||
}
|
||||
|
||||
@@ -354,13 +375,13 @@ void SmartAI::EndPath(bool fail)
|
||||
return;
|
||||
}
|
||||
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, nullptr, mCurrentWPID, GetScript()->GetPathId());
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_ESCORT_ENDED, nullptr, mCurrentWPID, GetScript()->GetPathId());
|
||||
mCurrentWPID = 0;
|
||||
|
||||
if (mCanRepeatPath)
|
||||
{
|
||||
if (IsAIControlled())
|
||||
StartPath(FORCED_MOVEMENT_NONE, GetScript()->GetPathId(), true);
|
||||
StartPath(mForcedMovement, GetScript()->GetPathId(), true);
|
||||
}
|
||||
else
|
||||
GetScript()->SetPathId(0);
|
||||
@@ -420,7 +441,7 @@ void SmartAI::UpdatePath(const uint32 diff)
|
||||
{
|
||||
if (!me->IsInCombat() && !HasEscortState(SMART_ESCORT_RETURNING) && (mWPReached || mForcedPaused))
|
||||
{
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_RESUMED, nullptr, mCurrentWPID, GetScript()->GetPathId());
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_ESCORT_RESUMED, nullptr, mCurrentWPID, GetScript()->GetPathId());
|
||||
RemoveEscortState(SMART_ESCORT_PAUSED);
|
||||
if (mForcedPaused)// if paused between 2 wps resend movement
|
||||
{
|
||||
@@ -599,7 +620,7 @@ void SmartAI::MovepointReached(uint32 id)
|
||||
}
|
||||
|
||||
mWPReached = true;
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_REACHED, nullptr, mCurrentWPID);
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_ESCORT_REACHED, nullptr, mCurrentWPID);
|
||||
|
||||
if (mLastWP)
|
||||
{
|
||||
@@ -636,7 +657,7 @@ void SmartAI::MovementInform(uint32 MovementType, uint32 Data)
|
||||
me->ClearUnitState(UNIT_STATE_EVADE);
|
||||
|
||||
if (MovementType == WAYPOINT_MOTION_TYPE)
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_DATA_REACHED, nullptr, Data + 1); // Data + 1 to align smart_scripts and waypoint_data Id rows
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_REACHED, nullptr, Data); // data now corresponds to columns
|
||||
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_MOVEMENTINFORM, nullptr, MovementType, Data);
|
||||
if (!HasEscortState(SMART_ESCORT_ESCORTING))
|
||||
@@ -786,7 +807,7 @@ void SmartAI::JustReachedHome()
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_REACHED_HOME);
|
||||
|
||||
if (!UpdateVictim() && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE && me->GetWaypointPath())
|
||||
me->GetMotionMaster()->MovePath(me->GetWaypointPath(), true);
|
||||
me->GetMotionMaster()->MoveWaypoint(me->GetWaypointPath(), true);
|
||||
}
|
||||
|
||||
mJustReset = false;
|
||||
@@ -943,7 +964,7 @@ void SmartAI::OnCharmed(bool /* apply */)
|
||||
if (!charmed && !me->IsInEvadeMode())
|
||||
{
|
||||
if (mCanRepeatPath)
|
||||
StartPath(FORCED_MOVEMENT_NONE, GetScript()->GetPathId(), true);
|
||||
StartPath(mForcedMovement, GetScript()->GetPathId(), true);
|
||||
|
||||
if (Unit* charmer = me->GetCharmer())
|
||||
AttackStart(charmer);
|
||||
@@ -1149,7 +1170,7 @@ void SmartAI::OnSpellClick(Unit* clicker, bool& /*result*/)
|
||||
|
||||
void SmartAI::PathEndReached(uint32 /*pathId*/)
|
||||
{
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_DATA_ENDED, nullptr, 0, me->GetWaypointPath());
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, nullptr, 0, me->GetWaypointPath());
|
||||
me->LoadPath(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,13 @@ public:
|
||||
bool IsAIControlled() const;
|
||||
|
||||
// Start moving to the desired MovePoint
|
||||
void StartPath(ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE, uint32 path = 0, bool repeat = false, Unit* invoker = nullptr);
|
||||
bool LoadPath(uint32 entry);
|
||||
void StartPath(ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE, uint32 path = 0, bool repeat = false, Unit* invoker = nullptr, PathSource pathSource = PathSource::SMART_WAYPOINT_MGR);
|
||||
bool LoadPath(uint32 entry, PathSource pathSource);
|
||||
void PausePath(uint32 delay, bool forced = false);
|
||||
void StopPath(uint32 DespawnTime = 0, uint32 quest = 0, bool fail = false);
|
||||
void EndPath(bool fail = false);
|
||||
void ResumePath();
|
||||
WayPoint* GetNextWayPoint();
|
||||
WaypointData const* GetNextWayPoint();
|
||||
void GenerateWayPointArray(Movement::PointsArray* points);
|
||||
bool HasEscortState(uint32 uiEscortState) { return (mEscortState & uiEscortState); }
|
||||
void AddEscortState(uint32 uiEscortState) { mEscortState |= uiEscortState; }
|
||||
@@ -227,13 +227,13 @@ private:
|
||||
void ReturnToLastOOCPos();
|
||||
void UpdatePath(const uint32 diff);
|
||||
SmartScript mScript;
|
||||
WPPath* mWayPoints;
|
||||
WaypointPath const* mWayPoints;
|
||||
uint32 mEscortState;
|
||||
uint32 mCurrentWPID;
|
||||
bool mWPReached;
|
||||
bool mOOCReached;
|
||||
uint32 mWPPauseTimer;
|
||||
WayPoint* mLastWP;
|
||||
WaypointData const* mLastWP;
|
||||
uint32 mEscortNPCFlags;
|
||||
uint32 GetWPCount() { return mWayPoints ? mWayPoints->size() : 0; }
|
||||
bool mCanRepeatPath;
|
||||
|
||||
@@ -1723,7 +1723,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset, e.action.setCounter.subtract);
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WP_START:
|
||||
case SMART_ACTION_ESCORT_START:
|
||||
{
|
||||
if (!IsSmart())
|
||||
break;
|
||||
@@ -1750,16 +1750,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
CAST_AI(SmartAI, me->AI())->SetDespawnTime(DespawnTime);
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WP_PAUSE:
|
||||
case SMART_ACTION_ESCORT_PAUSE:
|
||||
{
|
||||
if (!IsSmart())
|
||||
break;
|
||||
|
||||
uint32 delay = e.action.wpPause.delay;
|
||||
CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_WAYPOINT_REACHED ? false : true);
|
||||
CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_ESCORT_REACHED ? false : true);
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WP_STOP:
|
||||
case SMART_ACTION_ESCORT_STOP:
|
||||
{
|
||||
if (!IsSmart())
|
||||
break;
|
||||
@@ -1770,7 +1770,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
CAST_AI(SmartAI, me->AI())->StopPath(DespawnTime, quest, fail);
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WP_RESUME:
|
||||
case SMART_ACTION_ESCORT_RESUME:
|
||||
{
|
||||
if (!IsSmart())
|
||||
break;
|
||||
@@ -2519,21 +2519,19 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
for (uint32 wp = e.action.startClosestWaypoint.pathId1; wp <= e.action.startClosestWaypoint.pathId2; ++wp)
|
||||
{
|
||||
WPPath* path = sSmartWaypointMgr->GetPath(wp);
|
||||
WaypointPath* path = sSmartWaypointMgr->GetPath(wp);
|
||||
if (!path || path->empty())
|
||||
continue;
|
||||
|
||||
auto itrWp = path->find(1);
|
||||
if (itrWp != path->end())
|
||||
{
|
||||
if (WayPoint* wpData = itrWp->second)
|
||||
WaypointData& wpData = itrWp->second;
|
||||
float distToThisPath = creature->GetExactDistSq(wpData.x, wpData.y, wpData.z);
|
||||
if (distToThisPath < distanceToClosest)
|
||||
{
|
||||
float distToThisPath = creature->GetExactDistSq(wpData->x, wpData->y, wpData->z);
|
||||
if (distToThisPath < distanceToClosest)
|
||||
{
|
||||
distanceToClosest = distToThisPath;
|
||||
closestWpId = wp;
|
||||
}
|
||||
distanceToClosest = distToThisPath;
|
||||
closestWpId = wp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3221,7 +3219,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WAYPOINT_DATA_START:
|
||||
case SMART_ACTION_WAYPOINT_START:
|
||||
{
|
||||
if (e.action.wpData.pathId)
|
||||
{
|
||||
@@ -3230,7 +3228,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (IsCreature(target))
|
||||
{
|
||||
target->ToCreature()->LoadPath(e.action.wpData.pathId);
|
||||
target->ToCreature()->GetMotionMaster()->MovePath(e.action.wpData.pathId, e.action.wpData.repeat);
|
||||
target->ToCreature()->GetMotionMaster()->MoveWaypoint(e.action.wpData.pathId, e.action.wpData.repeat, e.action.wpData.pathSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3247,7 +3245,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
uint32 path = urand(e.action.wpDataRandom.pathId1, e.action.wpDataRandom.pathId2);
|
||||
target->ToCreature()->LoadPath(path);
|
||||
target->ToCreature()->GetMotionMaster()->MovePath(path, e.action.wpDataRandom.repeat);
|
||||
target->ToCreature()->GetMotionMaster()->MoveWaypoint(path, e.action.wpDataRandom.repeat);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4398,22 +4396,24 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
{
|
||||
if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
|
||||
return;
|
||||
if (e.event.movementInform.pathId != 0 && e.event.movementInform.pathId != me->GetWaypointPath())
|
||||
return;
|
||||
ProcessAction(e, unit, var0, var1);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_TRANSPORT_RELOCATE:
|
||||
case SMART_EVENT_WAYPOINT_START:
|
||||
case SMART_EVENT_ESCORT_START:
|
||||
{
|
||||
if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
|
||||
return;
|
||||
ProcessAction(e, unit, var0);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_WAYPOINT_REACHED:
|
||||
case SMART_EVENT_WAYPOINT_RESUMED:
|
||||
case SMART_EVENT_WAYPOINT_PAUSED:
|
||||
case SMART_EVENT_WAYPOINT_STOPPED:
|
||||
case SMART_EVENT_WAYPOINT_ENDED:
|
||||
case SMART_EVENT_ESCORT_REACHED:
|
||||
case SMART_EVENT_ESCORT_RESUMED:
|
||||
case SMART_EVENT_ESCORT_PAUSED:
|
||||
case SMART_EVENT_ESCORT_STOPPED:
|
||||
case SMART_EVENT_ESCORT_ENDED:
|
||||
{
|
||||
if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
|
||||
return;
|
||||
@@ -4807,8 +4807,8 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
RecalcTimer(e, 1200, 1200);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_WAYPOINT_DATA_REACHED:
|
||||
case SMART_EVENT_WAYPOINT_DATA_ENDED:
|
||||
case SMART_EVENT_WAYPOINT_REACHED:
|
||||
case SMART_EVENT_WAYPOINT_ENDED:
|
||||
{
|
||||
if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
|
||||
return;
|
||||
|
||||
@@ -48,12 +48,9 @@ void SmartWaypointMgr::LoadFromDB()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
for (std::unordered_map<uint32, WPPath*>::iterator itr = waypoint_map.begin(); itr != waypoint_map.end(); ++itr)
|
||||
for (auto itr : waypoint_map)
|
||||
{
|
||||
for (WPPath::iterator pathItr = itr->second->begin(); pathItr != itr->second->end(); ++pathItr)
|
||||
delete pathItr->second;
|
||||
|
||||
delete itr->second;
|
||||
delete itr.second;
|
||||
}
|
||||
|
||||
waypoint_map.clear();
|
||||
@@ -88,7 +85,7 @@ void SmartWaypointMgr::LoadFromDB()
|
||||
|
||||
if (last_entry != entry)
|
||||
{
|
||||
waypoint_map[entry] = new WPPath();
|
||||
waypoint_map[entry] = new WaypointPath();
|
||||
last_id = 1;
|
||||
count++;
|
||||
}
|
||||
@@ -97,7 +94,15 @@ void SmartWaypointMgr::LoadFromDB()
|
||||
LOG_ERROR("sql.sql", "SmartWaypointMgr::LoadFromDB: Path entry {}, unexpected point id {}, expected {}.", entry, id, last_id);
|
||||
|
||||
last_id++;
|
||||
(*waypoint_map[entry])[id] = new WayPoint(id, x, y, z, o, delay);
|
||||
WaypointData data;
|
||||
data.id = id;
|
||||
data.x = x;
|
||||
data.y = y;
|
||||
data.z = z;
|
||||
data.orientation = o;
|
||||
data.delay = delay;
|
||||
data.move_type = WAYPOINT_MOVE_TYPE_MAX;
|
||||
(*waypoint_map[entry]).emplace(id, data);
|
||||
|
||||
last_entry = entry;
|
||||
total++;
|
||||
@@ -109,12 +114,9 @@ void SmartWaypointMgr::LoadFromDB()
|
||||
|
||||
SmartWaypointMgr::~SmartWaypointMgr()
|
||||
{
|
||||
for (std::unordered_map<uint32, WPPath*>::iterator itr = waypoint_map.begin(); itr != waypoint_map.end(); ++itr)
|
||||
for (auto itr : waypoint_map)
|
||||
{
|
||||
for (WPPath::iterator pathItr = itr->second->begin(); pathItr != itr->second->end(); ++pathItr)
|
||||
delete pathItr->second;
|
||||
|
||||
delete itr->second;
|
||||
delete itr.second;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,8 +627,8 @@ bool SmartAIMgr::CheckUnusedEventParams(SmartScriptHolder const& e)
|
||||
case SMART_EVENT_CORPSE_REMOVED: return NO_PARAMS;
|
||||
case SMART_EVENT_AI_INIT: return NO_PARAMS;
|
||||
case SMART_EVENT_DATA_SET: return sizeof(SmartEvent::dataSet);
|
||||
case SMART_EVENT_WAYPOINT_START: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_WAYPOINT_REACHED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_ESCORT_START: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_ESCORT_REACHED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_TRANSPORT_ADDPLAYER: return NO_PARAMS;
|
||||
case SMART_EVENT_TRANSPORT_ADDCREATURE: return sizeof(SmartEvent::transportAddCreature);
|
||||
case SMART_EVENT_TRANSPORT_REMOVE_PLAYER: return NO_PARAMS;
|
||||
@@ -641,10 +643,10 @@ bool SmartAIMgr::CheckUnusedEventParams(SmartScriptHolder const& e)
|
||||
case SMART_EVENT_TEXT_OVER: return sizeof(SmartEvent::textOver);
|
||||
case SMART_EVENT_RECEIVE_HEAL: return sizeof(SmartEvent::minMaxRepeat);
|
||||
case SMART_EVENT_JUST_SUMMONED: return NO_PARAMS;
|
||||
case SMART_EVENT_WAYPOINT_PAUSED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_WAYPOINT_RESUMED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_WAYPOINT_STOPPED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_WAYPOINT_ENDED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_ESCORT_PAUSED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_ESCORT_RESUMED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_ESCORT_STOPPED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_ESCORT_ENDED: return sizeof(SmartEvent::waypoint);
|
||||
case SMART_EVENT_TIMED_EVENT_TRIGGERED: return sizeof(SmartEvent::timedEvent);
|
||||
case SMART_EVENT_UPDATE: return sizeof(SmartEvent::minMaxRepeat);
|
||||
case SMART_EVENT_LINK: return NO_PARAMS;
|
||||
@@ -677,8 +679,8 @@ bool SmartAIMgr::CheckUnusedEventParams(SmartScriptHolder const& e)
|
||||
case SMART_EVENT_AREA_CASTING: return sizeof(SmartEvent::minMaxRepeat);
|
||||
case SMART_EVENT_AREA_RANGE: return sizeof(SmartEvent::minMaxRepeat);
|
||||
case SMART_EVENT_SUMMONED_UNIT_EVADE: return sizeof(SmartEvent::summoned);
|
||||
case SMART_EVENT_WAYPOINT_DATA_REACHED: return sizeof(SmartEvent::wpData);
|
||||
case SMART_EVENT_WAYPOINT_DATA_ENDED: return sizeof(SmartEvent::wpData);
|
||||
case SMART_EVENT_WAYPOINT_REACHED: return sizeof(SmartEvent::wpData);
|
||||
case SMART_EVENT_WAYPOINT_ENDED: return sizeof(SmartEvent::wpData);
|
||||
default:
|
||||
LOG_WARN("sql.sql", "SmartAIMgr: entryorguid {} source_type {} id {} action_type {} is using an event {} with no unused params specified in SmartAIMgr::CheckUnusedEventParams(), please report this.",
|
||||
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetEventType());
|
||||
@@ -765,9 +767,9 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
|
||||
case SMART_ACTION_SUMMON_GO: return sizeof(SmartAction::summonGO);
|
||||
case SMART_ACTION_KILL_UNIT: return NO_PARAMS;
|
||||
case SMART_ACTION_ACTIVATE_TAXI: return sizeof(SmartAction::taxi);
|
||||
case SMART_ACTION_WP_START: return sizeof(SmartAction::wpStart);
|
||||
case SMART_ACTION_WP_PAUSE: return sizeof(SmartAction::wpPause);
|
||||
case SMART_ACTION_WP_STOP: return sizeof(SmartAction::wpStop);
|
||||
case SMART_ACTION_ESCORT_START: return sizeof(SmartAction::wpStart);
|
||||
case SMART_ACTION_ESCORT_PAUSE: return sizeof(SmartAction::wpPause);
|
||||
case SMART_ACTION_ESCORT_STOP: return sizeof(SmartAction::wpStop);
|
||||
case SMART_ACTION_ADD_ITEM: return sizeof(SmartAction::item);
|
||||
case SMART_ACTION_REMOVE_ITEM: return sizeof(SmartAction::item);
|
||||
case SMART_ACTION_INSTALL_AI_TEMPLATE: return sizeof(SmartAction::installTtemplate);
|
||||
@@ -777,7 +779,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
|
||||
case SMART_ACTION_TELEPORT: return sizeof(SmartAction::teleport);
|
||||
case SMART_ACTION_SET_COUNTER: return sizeof(SmartAction::setCounter);
|
||||
case SMART_ACTION_STORE_TARGET_LIST: return sizeof(SmartAction::storeTargets);
|
||||
case SMART_ACTION_WP_RESUME: return NO_PARAMS;
|
||||
case SMART_ACTION_ESCORT_RESUME: return NO_PARAMS;
|
||||
case SMART_ACTION_SET_ORIENTATION: return sizeof(SmartAction::orientation);
|
||||
case SMART_ACTION_CREATE_TIMED_EVENT: return sizeof(SmartAction::timeEvent);
|
||||
case SMART_ACTION_PLAYMOVIE: return sizeof(SmartAction::movie);
|
||||
@@ -875,7 +877,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
|
||||
case SMART_ACTION_PLAY_SPELL_VISUAL: return sizeof(SmartAction::spellVisual);
|
||||
case SMART_ACTION_FOLLOW_GROUP: return sizeof(SmartAction::followGroup);
|
||||
case SMART_ACTION_SET_ORIENTATION_TARGET: return sizeof(SmartAction::orientationTarget);
|
||||
case SMART_ACTION_WAYPOINT_DATA_START: return sizeof(SmartAction::wpData);
|
||||
case SMART_ACTION_WAYPOINT_START: return sizeof(SmartAction::wpData);
|
||||
case SMART_ACTION_WAYPOINT_DATA_RANDOM: return sizeof(SmartAction::wpDataRandom);
|
||||
case SMART_ACTION_MOVEMENT_STOP: return NO_PARAMS;
|
||||
case SMART_ACTION_MOVEMENT_PAUSE: return sizeof(SmartAction::move);
|
||||
@@ -1416,19 +1418,19 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_EVENT_QUEST_REWARDED:
|
||||
case SMART_EVENT_QUEST_FAIL:
|
||||
case SMART_EVENT_JUST_SUMMONED:
|
||||
case SMART_EVENT_WAYPOINT_START:
|
||||
case SMART_EVENT_WAYPOINT_REACHED:
|
||||
case SMART_EVENT_WAYPOINT_PAUSED:
|
||||
case SMART_EVENT_WAYPOINT_RESUMED:
|
||||
case SMART_EVENT_WAYPOINT_STOPPED:
|
||||
case SMART_EVENT_WAYPOINT_ENDED:
|
||||
case SMART_EVENT_ESCORT_START:
|
||||
case SMART_EVENT_ESCORT_REACHED:
|
||||
case SMART_EVENT_ESCORT_PAUSED:
|
||||
case SMART_EVENT_ESCORT_RESUMED:
|
||||
case SMART_EVENT_ESCORT_STOPPED:
|
||||
case SMART_EVENT_ESCORT_ENDED:
|
||||
case SMART_EVENT_GOSSIP_SELECT:
|
||||
case SMART_EVENT_GOSSIP_HELLO:
|
||||
case SMART_EVENT_JUST_CREATED:
|
||||
case SMART_EVENT_FOLLOW_COMPLETED:
|
||||
case SMART_EVENT_ON_SPELLCLICK:
|
||||
case SMART_EVENT_WAYPOINT_DATA_REACHED:
|
||||
case SMART_EVENT_WAYPOINT_DATA_ENDED:
|
||||
case SMART_EVENT_WAYPOINT_REACHED:
|
||||
case SMART_EVENT_WAYPOINT_ENDED:
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("sql.sql", "SmartAIMgr: Not handled event_type({}), Entry {} SourceType {} Event {} Action {}, skipped.", e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
@@ -1721,11 +1723,11 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SMART_ACTION_WP_STOP:
|
||||
case SMART_ACTION_ESCORT_STOP:
|
||||
if (e.action.wpStop.quest && !IsQuestValid(e, e.action.wpStop.quest))
|
||||
return false;
|
||||
return IsSAIBoolValid(e, e.action.wpStop.fail);
|
||||
case SMART_ACTION_WP_START:
|
||||
case SMART_ACTION_ESCORT_START:
|
||||
{
|
||||
if (!sSmartWaypointMgr->GetPath(e.action.wpStart.pathID))
|
||||
{
|
||||
@@ -1940,7 +1942,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_ACTION_STORE_TARGET_LIST:
|
||||
case SMART_ACTION_COMBAT_STOP:
|
||||
case SMART_ACTION_DIE:
|
||||
case SMART_ACTION_WP_RESUME:
|
||||
case SMART_ACTION_ESCORT_RESUME:
|
||||
case SMART_ACTION_KILL_UNIT:
|
||||
case SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL:
|
||||
case SMART_ACTION_RESET_GOBJECT:
|
||||
@@ -1950,7 +1952,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_ACTION_SET_INST_DATA64:
|
||||
case SMART_ACTION_SET_DATA:
|
||||
case SMART_ACTION_MOVE_FORWARD:
|
||||
case SMART_ACTION_WP_PAUSE:
|
||||
case SMART_ACTION_ESCORT_PAUSE:
|
||||
case SMART_ACTION_SET_FLY:
|
||||
case SMART_ACTION_FORCE_DESPAWN:
|
||||
case SMART_ACTION_SET_INGAME_PHASE_MASK:
|
||||
@@ -2020,7 +2022,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_ACTION_PLAY_SPELL_VISUAL:
|
||||
case SMART_ACTION_FOLLOW_GROUP:
|
||||
case SMART_ACTION_SET_ORIENTATION_TARGET:
|
||||
case SMART_ACTION_WAYPOINT_DATA_START:
|
||||
case SMART_ACTION_WAYPOINT_START:
|
||||
case SMART_ACTION_WAYPOINT_DATA_RANDOM:
|
||||
case SMART_ACTION_MOVEMENT_STOP:
|
||||
case SMART_ACTION_MOVEMENT_PAUSE:
|
||||
|
||||
@@ -26,29 +26,10 @@
|
||||
#include "Optional.h"
|
||||
#include "SpellMgr.h"
|
||||
#include <limits>
|
||||
#include "WaypointMgr.h"
|
||||
|
||||
typedef uint32 SAIBool;
|
||||
|
||||
struct WayPoint
|
||||
{
|
||||
WayPoint(uint32 _id, float _x, float _y, float _z, Optional<float> _o, uint32 _delay)
|
||||
{
|
||||
id = _id;
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z;
|
||||
o = _o;
|
||||
delay = _delay;
|
||||
}
|
||||
|
||||
uint32 id;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
std::optional<float> o;
|
||||
uint32 delay;
|
||||
};
|
||||
|
||||
enum eSmartAI
|
||||
{
|
||||
SMART_EVENT_PARAM_COUNT = 4,
|
||||
@@ -149,13 +130,13 @@ enum SMART_EVENT
|
||||
SMART_EVENT_SPELLHIT_TARGET = 31, // SpellID, School, CooldownMin, CooldownMax
|
||||
SMART_EVENT_DAMAGED = 32, // MinDmg, MaxDmg, CooldownMin, CooldownMax
|
||||
SMART_EVENT_DAMAGED_TARGET = 33, // MinDmg, MaxDmg, CooldownMin, CooldownMax
|
||||
SMART_EVENT_MOVEMENTINFORM = 34, // MovementType(any), PointID
|
||||
SMART_EVENT_MOVEMENTINFORM = 34, // MovementType(any), PointID, PathId(0 - any)
|
||||
SMART_EVENT_SUMMON_DESPAWNED = 35, // Entry, CooldownMin, CooldownMax
|
||||
SMART_EVENT_CORPSE_REMOVED = 36, // NONE
|
||||
SMART_EVENT_AI_INIT = 37, // NONE
|
||||
SMART_EVENT_DATA_SET = 38, // Id, Value, CooldownMin, CooldownMax
|
||||
SMART_EVENT_WAYPOINT_START = 39, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_WAYPOINT_REACHED = 40, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_ESCORT_START = 39, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_ESCORT_REACHED = 40, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_TRANSPORT_ADDPLAYER = 41, // NONE
|
||||
SMART_EVENT_TRANSPORT_ADDCREATURE = 42, // Entry (0 any)
|
||||
SMART_EVENT_TRANSPORT_REMOVE_PLAYER = 43, // NONE
|
||||
@@ -170,10 +151,10 @@ enum SMART_EVENT
|
||||
SMART_EVENT_TEXT_OVER = 52, // GroupId from creature_text, creature entry who talks (0 any)
|
||||
SMART_EVENT_RECEIVE_HEAL = 53, // MinHeal, MaxHeal, CooldownMin, CooldownMax
|
||||
SMART_EVENT_JUST_SUMMONED = 54, // none
|
||||
SMART_EVENT_WAYPOINT_PAUSED = 55, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_WAYPOINT_RESUMED = 56, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_WAYPOINT_STOPPED = 57, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_WAYPOINT_ENDED = 58, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_ESCORT_PAUSED = 55, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_ESCORT_RESUMED = 56, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_ESCORT_STOPPED = 57, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_ESCORT_ENDED = 58, // PointId(0any), pathID(0any)
|
||||
SMART_EVENT_TIMED_EVENT_TRIGGERED = 59, // id
|
||||
SMART_EVENT_UPDATE = 60, // InitialMin, InitialMax, RepeatMin, RepeatMax
|
||||
SMART_EVENT_LINK = 61, // INTERNAL USAGE, no params, used to link together multiple events, does not use any extra resources to iterate event lists needlessly
|
||||
@@ -213,8 +194,8 @@ enum SMART_EVENT
|
||||
SMART_EVENT_AREA_CASTING = 105, // min, max, repeatMin, repeatMax, rangeMin, rangeMax
|
||||
SMART_EVENT_AREA_RANGE = 106, // min, max, repeatMin, repeatMax, rangeMin, rangeMax
|
||||
SMART_EVENT_SUMMONED_UNIT_EVADE = 107, // CreatureId(0 all), CooldownMin, CooldownMax
|
||||
SMART_EVENT_WAYPOINT_DATA_REACHED = 108, // PointId (0: any), pathId (0: any)
|
||||
SMART_EVENT_WAYPOINT_DATA_ENDED = 109, // PointId (0: any), pathId (0: any)
|
||||
SMART_EVENT_WAYPOINT_REACHED = 108, // PointId (0: any), pathId (0: any)
|
||||
SMART_EVENT_WAYPOINT_ENDED = 109, // PointId (0: any), pathId (0: any)
|
||||
SMART_EVENT_IS_IN_MELEE_RANGE = 110, // min, max, repeatMin, repeatMax, dist, invert (0: false, 1: true)
|
||||
|
||||
SMART_EVENT_AC_END = 111
|
||||
@@ -356,6 +337,7 @@ struct SmartEvent
|
||||
{
|
||||
uint32 type;
|
||||
uint32 id;
|
||||
uint32 pathId;
|
||||
} movementInform;
|
||||
|
||||
struct
|
||||
@@ -608,9 +590,9 @@ enum SMART_ACTION
|
||||
SMART_ACTION_SUMMON_GO = 50, // GameObjectID, DespawnTime, targetSummon, summonType (0 time or summoner dies/1 time)
|
||||
SMART_ACTION_KILL_UNIT = 51, //
|
||||
SMART_ACTION_ACTIVATE_TAXI = 52, // TaxiID
|
||||
SMART_ACTION_WP_START = 53, // run/walk, pathID, canRepeat, quest, despawntime, reactState
|
||||
SMART_ACTION_WP_PAUSE = 54, // time
|
||||
SMART_ACTION_WP_STOP = 55, // despawnTime, quest, fail?
|
||||
SMART_ACTION_ESCORT_START = 53, // run/walk, pathID, canRepeat, quest, despawntime, reactState
|
||||
SMART_ACTION_ESCORT_PAUSE = 54, // time
|
||||
SMART_ACTION_ESCORT_STOP = 55, // despawnTime, quest, fail?
|
||||
SMART_ACTION_ADD_ITEM = 56, // itemID, count
|
||||
SMART_ACTION_REMOVE_ITEM = 57, // itemID, count
|
||||
SMART_ACTION_INSTALL_AI_TEMPLATE = 58, // AITemplateID
|
||||
@@ -620,7 +602,7 @@ enum SMART_ACTION
|
||||
SMART_ACTION_TELEPORT = 62, // mapID,
|
||||
SMART_ACTION_SET_COUNTER = 63, // id, value, reset (0/1)
|
||||
SMART_ACTION_STORE_TARGET_LIST = 64, // varID,
|
||||
SMART_ACTION_WP_RESUME = 65, // none
|
||||
SMART_ACTION_ESCORT_RESUME = 65, // none
|
||||
SMART_ACTION_SET_ORIENTATION = 66, // quick change, random orientation? (0/1), turnAngle
|
||||
SMART_ACTION_CREATE_TIMED_EVENT = 67, // id, InitialMin, InitialMax, RepeatMin(only if it repeats), RepeatMax(only if it repeats), chance
|
||||
SMART_ACTION_PLAYMOVIE = 68, // entry
|
||||
@@ -732,7 +714,7 @@ enum SMART_ACTION
|
||||
SMART_ACTION_PLAY_SPELL_VISUAL = 229, // visualId, visualIdImpact
|
||||
SMART_ACTION_FOLLOW_GROUP = 230, // followState, followType, dist
|
||||
SMART_ACTION_SET_ORIENTATION_TARGET = 231, // type, target_type, target_param1, target_param2, target_param3, target_param4
|
||||
SMART_ACTION_WAYPOINT_DATA_START = 232, // pathId, repeat
|
||||
SMART_ACTION_WAYPOINT_START = 232, // pathId, repeat, pathSource
|
||||
SMART_ACTION_WAYPOINT_DATA_RANDOM = 233, // pathId1, pathId2, repeat
|
||||
SMART_ACTION_MOVEMENT_STOP = 234, //
|
||||
SMART_ACTION_MOVEMENT_PAUSE = 235, // timer
|
||||
@@ -1482,6 +1464,7 @@ struct SmartAction
|
||||
{
|
||||
uint32 pathId;
|
||||
SAIBool repeat;
|
||||
PathSource pathSource;
|
||||
} wpData;
|
||||
|
||||
struct
|
||||
@@ -1853,8 +1836,8 @@ const uint32 SmartAIEventMask[SMART_EVENT_AC_END][2] =
|
||||
{SMART_EVENT_CORPSE_REMOVED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_AI_INIT, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_DATA_SET, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_WAYPOINT_START, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_WAYPOINT_REACHED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_ESCORT_START, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_ESCORT_REACHED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_TRANSPORT_ADDPLAYER, SMART_SCRIPT_TYPE_MASK_TRANSPORT },
|
||||
{SMART_EVENT_TRANSPORT_ADDCREATURE, SMART_SCRIPT_TYPE_MASK_TRANSPORT },
|
||||
{SMART_EVENT_TRANSPORT_REMOVE_PLAYER, SMART_SCRIPT_TYPE_MASK_TRANSPORT },
|
||||
@@ -1869,10 +1852,10 @@ const uint32 SmartAIEventMask[SMART_EVENT_AC_END][2] =
|
||||
{SMART_EVENT_TEXT_OVER, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_RECEIVE_HEAL, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_JUST_SUMMONED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_WAYPOINT_PAUSED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_WAYPOINT_RESUMED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_WAYPOINT_STOPPED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_WAYPOINT_ENDED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_ESCORT_PAUSED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_ESCORT_RESUMED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_ESCORT_STOPPED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_ESCORT_ENDED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_TIMED_EVENT_TRIGGERED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_UPDATE, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_LINK, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT + SMART_SCRIPT_TYPE_MASK_AREATRIGGER + SMART_SCRIPT_TYPE_MASK_EVENT + SMART_SCRIPT_TYPE_MASK_GOSSIP + SMART_SCRIPT_TYPE_MASK_QUEST + SMART_SCRIPT_TYPE_MASK_SPELL + SMART_SCRIPT_TYPE_MASK_TRANSPORT + SMART_SCRIPT_TYPE_MASK_INSTANCE },
|
||||
@@ -1922,8 +1905,8 @@ const uint32 SmartAIEventMask[SMART_EVENT_AC_END][2] =
|
||||
{SMART_EVENT_AREA_CASTING, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_AREA_RANGE, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_SUMMONED_UNIT_EVADE, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_WAYPOINT_DATA_REACHED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_WAYPOINT_DATA_ENDED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_WAYPOINT_REACHED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_WAYPOINT_ENDED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_IS_IN_MELEE_RANGE, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
};
|
||||
|
||||
@@ -2010,8 +1993,6 @@ public:
|
||||
static constexpr uint32 DEFAULT_PRIORITY = std::numeric_limits<uint32>::max();
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32, WayPoint*> WPPath;
|
||||
|
||||
typedef std::vector<WorldObject*> ObjectVector;
|
||||
|
||||
class ObjectGuidVector
|
||||
@@ -2059,7 +2040,7 @@ public:
|
||||
|
||||
void LoadFromDB();
|
||||
|
||||
WPPath* GetPath(uint32 id)
|
||||
WaypointPath* GetPath(uint32 id)
|
||||
{
|
||||
if (waypoint_map.find(id) != waypoint_map.end())
|
||||
return waypoint_map[id];
|
||||
@@ -2067,7 +2048,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<uint32, WPPath*> waypoint_map;
|
||||
std::unordered_map<uint32, WaypointPath*> waypoint_map;
|
||||
};
|
||||
|
||||
// all events for a single entry
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "TargetedMovementGenerator.h"
|
||||
#include "WaypointMgr.h"
|
||||
#include "WaypointMovementGenerator.h"
|
||||
#include "SmartScriptMgr.h"
|
||||
|
||||
inline MovementGenerator* GetIdleMovementGenerator()
|
||||
{
|
||||
@@ -503,19 +504,35 @@ void MotionMaster::MoveSplinePath(Movement::PointsArray* path, ForcedMovement fo
|
||||
}
|
||||
}
|
||||
|
||||
void MotionMaster::MoveSplinePath(uint32 path_id, ForcedMovement forcedMovement)
|
||||
void MotionMaster::MovePath(uint32 path_id, ForcedMovement forcedMovement, PathSource pathSource)
|
||||
{
|
||||
// convert the path id to a Movement::PointsArray*
|
||||
Movement::PointsArray* points = new Movement::PointsArray();
|
||||
WaypointPath const* path = sWaypointMgr->GetPath(path_id);
|
||||
for (uint8 i = 0; i < path->size(); ++i)
|
||||
WaypointPath const* path;
|
||||
switch (pathSource)
|
||||
{
|
||||
WaypointData const* node = path->at(i);
|
||||
points->push_back(G3D::Vector3(node->x, node->y, node->z));
|
||||
default:
|
||||
case PathSource::WAYPOINT_MGR:
|
||||
path = sWaypointMgr->GetPath(path_id);
|
||||
break;
|
||||
case PathSource::SMART_WAYPOINT_MGR:
|
||||
path = sSmartWaypointMgr->GetPath(path_id);
|
||||
break;
|
||||
}
|
||||
|
||||
if (path == nullptr)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "WaypointMovementGenerator::LoadPath: creature {} ({}) doesn't have waypoint path id: {} pathSource: {}",
|
||||
_owner->GetName(), _owner->GetGUID().ToString(), path_id, pathSource);
|
||||
return;
|
||||
}
|
||||
|
||||
Movement::PointsArray points;
|
||||
for (auto& point : *path)
|
||||
{
|
||||
points.push_back(G3D::Vector3(point.second.x, point.second.y, point.second.z));
|
||||
}
|
||||
|
||||
// pass the new PointsArray* to the appropriate MoveSplinePath function
|
||||
MoveSplinePath(points, forcedMovement);
|
||||
MoveSplinePath(&points, forcedMovement);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -881,7 +898,7 @@ void MotionMaster::Mutate(MovementGenerator* m, MovementSlot slot)
|
||||
/**
|
||||
* @brief Move the unit following a specific path. Doesn't work with UNIT_FLAG_DISABLE_MOVE
|
||||
*/
|
||||
void MotionMaster::MovePath(uint32 path_id, bool repeatable)
|
||||
void MotionMaster::MoveWaypoint(uint32 path_id, bool repeatable, PathSource pathSource)
|
||||
{
|
||||
if (!path_id)
|
||||
return;
|
||||
@@ -889,20 +906,7 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable)
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
//We set waypoint movement as new default movement generator
|
||||
// clear ALL movement generators (including default)
|
||||
/*while (!empty())
|
||||
{
|
||||
MovementGenerator *curr = top();
|
||||
curr->Finalize(*_owner);
|
||||
pop();
|
||||
if (!isStatic(curr))
|
||||
delete curr;
|
||||
}*/
|
||||
|
||||
//_owner->IsPlayer() ?
|
||||
//Mutate(new WaypointMovementGenerator<Player>(path_id, repeatable)):
|
||||
Mutate(new WaypointMovementGenerator<Creature>(path_id, repeatable), MOTION_SLOT_IDLE);
|
||||
Mutate(new WaypointMovementGenerator<Creature>(path_id, pathSource, repeatable), MOTION_SLOT_IDLE);
|
||||
|
||||
LOG_DEBUG("movement.motionmaster", "{} ({}) start moving over path(Id:{}, repeatable: {})",
|
||||
_owner->IsPlayer() ? "Player" : "Creature", _owner->GetGUID().ToString(), path_id, repeatable ? "YES" : "NO");
|
||||
|
||||
@@ -89,6 +89,12 @@ enum ForcedMovement
|
||||
FORCED_MOVEMENT_MAX
|
||||
};
|
||||
|
||||
enum class PathSource
|
||||
{
|
||||
WAYPOINT_MGR = 0,
|
||||
SMART_WAYPOINT_MGR = 1,
|
||||
};
|
||||
|
||||
struct ChaseRange
|
||||
{
|
||||
ChaseRange(float range);
|
||||
@@ -223,7 +229,7 @@ public:
|
||||
{ MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, forcedMovement, speed, pos.GetOrientation(), generatePath, forceDestination, MOTION_SLOT_ACTIVE); }
|
||||
void MovePoint(uint32 id, float x, float y, float z, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE, float speed = 0.f, float orientation = 0.0f, bool generatePath = true, bool forceDestination = true, MovementSlot slot = MOTION_SLOT_ACTIVE);
|
||||
void MoveSplinePath(Movement::PointsArray* path, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE);
|
||||
void MoveSplinePath(uint32 path_id, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE);
|
||||
void MovePath(uint32 path_id, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE, PathSource pathSource = PathSource::WAYPOINT_MGR);
|
||||
|
||||
// These two movement types should only be used with creatures having landing/takeoff animations
|
||||
void MoveLand(uint32 id, Position const& pos, float speed = 0.0f);
|
||||
@@ -244,7 +250,7 @@ public:
|
||||
void MoveSeekAssistanceDistract(uint32 timer);
|
||||
void MoveTaxiFlight(uint32 path, uint32 pathnode);
|
||||
void MoveDistract(uint32 time);
|
||||
void MovePath(uint32 path_id, bool repeatable);
|
||||
void MoveWaypoint(uint32 path_id, bool repeatable, PathSource pathSource = PathSource::WAYPOINT_MGR);
|
||||
void MoveRotate(uint32 time, RotateDirection direction);
|
||||
|
||||
[[nodiscard]] MovementGeneratorType GetCurrentMovementGeneratorType() const;
|
||||
|
||||
@@ -28,13 +28,26 @@
|
||||
#include "Spell.h"
|
||||
#include "Transport.h"
|
||||
#include "World.h"
|
||||
#include "SmartScriptMgr.h"
|
||||
|
||||
void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature)
|
||||
{
|
||||
if (!path_id)
|
||||
path_id = creature->GetWaypointPath();
|
||||
switch (i_pathSource)
|
||||
{
|
||||
case PathSource::WAYPOINT_MGR:
|
||||
{
|
||||
if (!path_id)
|
||||
path_id = creature->GetWaypointPath();
|
||||
|
||||
i_path = sWaypointMgr->GetPath(path_id);
|
||||
i_path = sWaypointMgr->GetPath(path_id);
|
||||
break;
|
||||
}
|
||||
case PathSource::SMART_WAYPOINT_MGR:
|
||||
{
|
||||
i_path = sSmartWaypointMgr->GetPath(path_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!i_path)
|
||||
{
|
||||
@@ -44,6 +57,8 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature)
|
||||
return;
|
||||
}
|
||||
|
||||
i_currentNode = i_path->begin()->first;
|
||||
|
||||
StartMoveNow(creature);
|
||||
}
|
||||
|
||||
@@ -78,22 +93,24 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature* creature)
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
m_isArrivalDone = true;
|
||||
|
||||
if (i_path->at(i_currentNode)->event_id && urand(0, 99) < i_path->at(i_currentNode)->event_chance)
|
||||
auto currentNodeItr = i_path->find(i_currentNode);
|
||||
|
||||
if (currentNodeItr->second.event_id && urand(0, 99) < currentNodeItr->second.event_chance)
|
||||
{
|
||||
LOG_DEBUG("maps.script", "Creature movement start script {} at point {} for {}.",
|
||||
i_path->at(i_currentNode)->event_id, i_currentNode, creature->GetGUID().ToString());
|
||||
currentNodeItr->second.event_id, i_currentNode, creature->GetGUID().ToString());
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
creature->GetMap()->ScriptsStart(sWaypointScripts, i_path->at(i_currentNode)->event_id, creature, nullptr);
|
||||
creature->GetMap()->ScriptsStart(sWaypointScripts, currentNodeItr->second.event_id, creature, nullptr);
|
||||
}
|
||||
|
||||
// Inform script
|
||||
MovementInform(creature);
|
||||
creature->UpdateWaypointID(i_currentNode);
|
||||
|
||||
if (i_path->at(i_currentNode)->delay)
|
||||
if (currentNodeItr->second.delay)
|
||||
{
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
Stop(i_path->at(i_currentNode)->delay);
|
||||
Stop(currentNodeItr->second.delay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,9 +133,10 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
|
||||
// Xinef: not true... update this at every waypoint!
|
||||
//if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
|
||||
{
|
||||
float x = i_path->at(i_currentNode)->x;
|
||||
float y = i_path->at(i_currentNode)->y;
|
||||
float z = i_path->at(i_currentNode)->z;
|
||||
auto currentNodeItr = i_path->find(i_currentNode);
|
||||
float x = currentNodeItr->second.x;
|
||||
float y = currentNodeItr->second.y;
|
||||
float z = currentNodeItr->second.z;
|
||||
float o = creature->GetOrientation();
|
||||
|
||||
if (!transportPath)
|
||||
@@ -146,7 +164,9 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
|
||||
return false;
|
||||
}
|
||||
|
||||
i_currentNode = (i_currentNode + 1) % i_path->size();
|
||||
++i_currentNode;
|
||||
if (i_path->rbegin()->first < i_currentNode)
|
||||
i_currentNode = i_path->begin()->first;
|
||||
}
|
||||
|
||||
// xinef: do not initialize motion if we got stunned in movementinform
|
||||
@@ -155,13 +175,14 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
|
||||
return true;
|
||||
}
|
||||
|
||||
WaypointData const* node = i_path->at(i_currentNode);
|
||||
auto currentNodeItr = i_path->find(i_currentNode);
|
||||
WaypointData const& node = currentNodeItr->second;
|
||||
|
||||
m_isArrivalDone = false;
|
||||
|
||||
creature->AddUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
|
||||
Movement::Location formationDest(node->x, node->y, node->z, 0.0f);
|
||||
Movement::Location formationDest(node.x, node.y, node.z, 0.0f);
|
||||
Movement::MoveSplineInit init(creature);
|
||||
|
||||
//! If creature is on transport, we assume waypoints set in DB are already transport offsets
|
||||
@@ -172,16 +193,16 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
|
||||
trans->CalculatePassengerPosition(formationDest.x, formationDest.y, formationDest.z, &formationDest.orientation);
|
||||
}
|
||||
|
||||
float z = node->z;
|
||||
creature->UpdateAllowedPositionZ(node->x, node->y, z);
|
||||
float z = node.z;
|
||||
creature->UpdateAllowedPositionZ(node.x, node.y, z);
|
||||
//! Do not use formationDest here, MoveTo requires transport offsets due to DisableTransportPathTransformations() call
|
||||
//! but formationDest contains global coordinates
|
||||
init.MoveTo(node->x, node->y, z, true, true);
|
||||
init.MoveTo(node.x, node.y, z, true, true);
|
||||
|
||||
if (node->orientation.has_value() && node->delay > 0)
|
||||
init.SetFacing(*node->orientation);
|
||||
if (node.orientation.has_value() && node.delay > 0)
|
||||
init.SetFacing(*node.orientation);
|
||||
|
||||
switch (node->move_type)
|
||||
switch (node.move_type)
|
||||
{
|
||||
case WAYPOINT_MOVE_TYPE_LAND:
|
||||
init.SetAnimation(Movement::ToGround);
|
||||
@@ -203,7 +224,7 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
|
||||
|
||||
//Call for creature group update
|
||||
if (creature->GetFormation() && creature->GetFormation()->GetLeader() == creature)
|
||||
creature->GetFormation()->LeaderMoveTo(formationDest.x, formationDest.y, formationDest.z, node->move_type);
|
||||
creature->GetFormation()->LeaderMoveTo(formationDest.x, formationDest.y, formationDest.z, node.move_type);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium< Crea
|
||||
public PathMovementBase<Creature, WaypointPath const*>
|
||||
{
|
||||
public:
|
||||
WaypointMovementGenerator(uint32 _path_id = 0, bool _repeating = true, bool _stalled = false)
|
||||
: PathMovementBase((WaypointPath const*)nullptr), i_nextMoveTime(0), m_isArrivalDone(false), path_id(_path_id), repeating(_repeating), stalled(_stalled) {}
|
||||
WaypointMovementGenerator(uint32 _path_id = 0, PathSource pathSource = PathSource::WAYPOINT_MGR, bool _repeating = true, bool _stalled = false)
|
||||
: PathMovementBase((WaypointPath const*)nullptr), i_nextMoveTime(0), m_isArrivalDone(false), path_id(_path_id), repeating(_repeating), stalled(_stalled), i_pathSource(pathSource) {}
|
||||
~WaypointMovementGenerator() { i_path = nullptr; }
|
||||
void DoInitialize(Creature*);
|
||||
void DoFinalize(Creature*);
|
||||
@@ -96,6 +96,7 @@ private:
|
||||
uint32 path_id;
|
||||
bool repeating;
|
||||
bool stalled;
|
||||
PathSource i_pathSource;
|
||||
};
|
||||
|
||||
/** FlightPathMovementGenerator generates movement of the player for the paths
|
||||
|
||||
@@ -30,9 +30,6 @@ WaypointMgr::~WaypointMgr()
|
||||
{
|
||||
for (WaypointPathContainer::iterator itr = _waypointStore.begin(); itr != _waypointStore.end(); ++itr)
|
||||
{
|
||||
for (WaypointPath::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
delete *it;
|
||||
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
@@ -64,7 +61,7 @@ void WaypointMgr::Load()
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
WaypointData* wp = new WaypointData();
|
||||
WaypointData data;
|
||||
|
||||
uint32 pathId = fields[0].Get<uint32>();
|
||||
WaypointPath& path = _waypointStore[pathId];
|
||||
@@ -79,28 +76,40 @@ void WaypointMgr::Load()
|
||||
Acore::NormalizeMapCoord(x);
|
||||
Acore::NormalizeMapCoord(y);
|
||||
|
||||
wp->id = fields[1].Get<uint32>();
|
||||
wp->x = x;
|
||||
wp->y = y;
|
||||
wp->z = z;
|
||||
wp->orientation = o;
|
||||
wp->move_type = fields[6].Get<uint32>();
|
||||
data.id = fields[1].Get<uint32>();
|
||||
data.x = x;
|
||||
data.y = y;
|
||||
data.z = z;
|
||||
data.orientation = o;
|
||||
data.move_type = fields[6].Get<uint32>();
|
||||
|
||||
if (wp->move_type >= WAYPOINT_MOVE_TYPE_MAX)
|
||||
if (data.move_type >= WAYPOINT_MOVE_TYPE_MAX)
|
||||
{
|
||||
//LOG_ERROR("sql.sql", "Waypoint {} in waypoint_data has invalid move_type, ignoring", wp->id);
|
||||
delete wp;
|
||||
continue;
|
||||
}
|
||||
|
||||
wp->delay = fields[7].Get<uint32>();
|
||||
wp->event_id = fields[8].Get<uint32>();
|
||||
wp->event_chance = fields[9].Get<int16>();
|
||||
data.delay = fields[7].Get<uint32>();
|
||||
data.event_id = fields[8].Get<uint32>();
|
||||
data.event_chance = fields[9].Get<int16>();
|
||||
|
||||
path.push_back(wp);
|
||||
path.emplace(data.id, data);
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
for (auto itr = _waypointStore.begin(); itr != _waypointStore.end(); )
|
||||
{
|
||||
uint32 first = itr->second.begin()->first;
|
||||
uint32 last = itr->second.rbegin()->first;
|
||||
if (last - first + 1 != itr->second.size())
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Waypoint {} in waypoint_data has non-contiguous pointids, skipping", itr->first);
|
||||
itr = _waypointStore.erase(itr);
|
||||
}
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} waypoints in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
@@ -110,9 +119,6 @@ void WaypointMgr::ReloadPath(uint32 id)
|
||||
WaypointPathContainer::iterator itr = _waypointStore.find(id);
|
||||
if (itr != _waypointStore.end())
|
||||
{
|
||||
for (WaypointPath::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
delete *it;
|
||||
|
||||
_waypointStore.erase(itr);
|
||||
}
|
||||
|
||||
@@ -130,7 +136,7 @@ void WaypointMgr::ReloadPath(uint32 id)
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
WaypointData* wp = new WaypointData();
|
||||
WaypointData data;
|
||||
|
||||
float x = fields[1].Get<float>();
|
||||
float y = fields[2].Get<float>();
|
||||
@@ -142,24 +148,23 @@ void WaypointMgr::ReloadPath(uint32 id)
|
||||
Acore::NormalizeMapCoord(x);
|
||||
Acore::NormalizeMapCoord(y);
|
||||
|
||||
wp->id = fields[0].Get<uint32>();
|
||||
wp->x = x;
|
||||
wp->y = y;
|
||||
wp->z = z;
|
||||
wp->orientation = o;
|
||||
wp->move_type = fields[5].Get<uint32>();
|
||||
data.id = fields[0].Get<uint32>();
|
||||
data.x = x;
|
||||
data.y = y;
|
||||
data.z = z;
|
||||
data.orientation = o;
|
||||
data.move_type = fields[5].Get<uint32>();
|
||||
|
||||
if (wp->move_type >= WAYPOINT_MOVE_TYPE_MAX)
|
||||
if (data.move_type >= WAYPOINT_MOVE_TYPE_MAX)
|
||||
{
|
||||
//LOG_ERROR("sql.sql", "Waypoint {} in waypoint_data has invalid move_type, ignoring", wp->id);
|
||||
delete wp;
|
||||
continue;
|
||||
}
|
||||
|
||||
wp->delay = fields[6].Get<uint32>();
|
||||
wp->event_id = fields[7].Get<uint32>();
|
||||
wp->event_chance = fields[8].Get<uint8>();
|
||||
data.delay = fields[6].Get<uint32>();
|
||||
data.event_id = fields[7].Get<uint32>();
|
||||
data.event_chance = fields[8].Get<uint8>();
|
||||
|
||||
path.push_back(wp);
|
||||
path.emplace(data.id, data);
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
enum WaypointMoveType
|
||||
{
|
||||
@@ -39,12 +40,12 @@ struct WaypointData
|
||||
float x, y, z;
|
||||
std::optional<float> orientation;
|
||||
uint32 delay;
|
||||
uint32 event_id;
|
||||
uint32 move_type;
|
||||
uint8 event_chance;
|
||||
uint32 event_id = 0;
|
||||
uint32 move_type = 0;
|
||||
uint8 event_chance = 0;
|
||||
};
|
||||
|
||||
typedef std::vector<WaypointData*> WaypointPath;
|
||||
typedef std::map<uint32, WaypointData> WaypointPath;
|
||||
typedef std::unordered_map<uint32, WaypointPath> WaypointPathContainer;
|
||||
|
||||
class WaypointMgr
|
||||
|
||||
@@ -767,7 +767,7 @@ void Map::ScriptsProcess()
|
||||
if (!sWaypointMgr->GetPath(step.script->LoadPath.PathID))
|
||||
LOG_ERROR("maps.script", "{} source object has an invalid path ({}), skipping.", step.script->GetDebugInfo(), step.script->LoadPath.PathID);
|
||||
else
|
||||
unit->GetMotionMaster()->MovePath(step.script->LoadPath.PathID, step.script->LoadPath.IsRepeatable);
|
||||
unit->GetMotionMaster()->MoveWaypoint(step.script->LoadPath.PathID, step.script->LoadPath.IsRepeatable);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -888,7 +888,7 @@ void Map::ScriptsProcess()
|
||||
cSource->GetMotionMaster()->MoveRandom((float)step.script->Movement.MovementDistance);
|
||||
break;
|
||||
case WAYPOINT_MOTION_TYPE:
|
||||
cSource->GetMotionMaster()->MovePath(step.script->Movement.Path, false);
|
||||
cSource->GetMotionMaster()->MoveWaypoint(step.script->Movement.Path, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1778,7 +1778,7 @@ bool WorldState::SummonPallid(Map* map, ScourgeInvasionData::CityAttack& zone, c
|
||||
else
|
||||
pathID = spawnLoc == 0 ? PATH_STORMWIND_KEEP : PATH_STORMWIND_TRADE_DISTRICT;
|
||||
|
||||
pallid->GetMotionMaster()->MovePath(pathID, false);
|
||||
pallid->GetMotionMaster()->MoveWaypoint(pathID, false);
|
||||
|
||||
sWorldState->SetPallidGuid(zone.zoneId, pallid->GetGUID());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user