feat(Core/Movement): Allow waypoints to use 0 as valid facing value (#11681)

* feat(Core/Movement): Allow waypoints to use 0 as valid facing value

* cherry-pick commit (4747515872)

Co-Authored-By: Ovah <18347559+Ovahlord@users.noreply.github.com>

* Update SmartScriptMgr.h

* a

* Update SmartAI.cpp

* Update SmartAI.cpp

* Update SmartAI.cpp

* typo

* Update SmartAI.cpp

* Update SmartAI.cpp

* Compile fix

* compile #2

* Update WaypointMgr.h

* Update SmartScriptMgr.h

* compile fix again

Co-authored-by: Ovah <18347559+Ovahlord@users.noreply.github.com>
Co-authored-by: MDIC <joshua.lee.betts@gmail.com>
This commit is contained in:
Kitzunu
2022-05-21 23:42:41 +02:00
committed by GitHub
parent 92cf37731a
commit 90fccacad5
7 changed files with 27 additions and 15 deletions

View File

@@ -0,0 +1,6 @@
--
ALTER TABLE `waypoint_data` CHANGE `orientation` `orientation` FLOAT DEFAULT NULL NULL;
UPDATE `waypoint_data` SET `orientation`= NULL WHERE `orientation`= 0;
ALTER TABLE `waypoints` CHANGE `orientation` `orientation` FLOAT DEFAULT NULL NULL;
UPDATE `waypoints` SET `orientation`= NULL WHERE `orientation`= 0;

View File

@@ -257,9 +257,9 @@ void SmartAI::PausePath(uint32 delay, bool forced)
me->GetMotionMaster()->MoveIdle();//force stop
auto waypoint = mWayPoints->find(mCurrentWPID);
if (float orientation = waypoint->second->o)
if (waypoint->second->o.has_value())
{
me->SetFacingTo(orientation);
me->SetFacingTo(waypoint->second->o.has_value());
}
}
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_PAUSED, nullptr, mCurrentWPID, GetScript()->GetPathId());

View File

@@ -79,11 +79,12 @@ void SmartWaypointMgr::LoadFromDB()
Field* fields = result->Fetch();
uint32 entry = fields[0].Get<uint32>();
uint32 id = fields[1].Get<uint32>();
float x, y, z, o;
x = fields[2].Get<float>();
y = fields[3].Get<float>();
z = fields[4].Get<float>();
o = fields[5].Get<float>();
float x = fields[2].Get<float>();
float y = fields[3].Get<float>();
float z = fields[4].Get<float>();
Optional<float> o;
if (!fields[5].IsNull())
o = fields[5].Get<float>();
uint32 delay = fields[6].Get<uint32>();
if (last_entry != entry)

View File

@@ -22,6 +22,7 @@
#include "Creature.h"
#include "CreatureAI.h"
#include "DBCStores.h"
#include "Optional.h"
#include "Spell.h"
#include "SpellMgr.h"
#include "Unit.h"
@@ -30,7 +31,7 @@ typedef uint32 SAIBool;
struct WayPoint
{
WayPoint(uint32 _id, float _x, float _y, float _z, float _o, uint32 _delay)
WayPoint(uint32 _id, float _x, float _y, float _z, Optional<float> _o, uint32 _delay)
{
id = _id;
x = _x;
@@ -44,7 +45,7 @@ struct WayPoint
float x;
float y;
float z;
float o;
std::optional<float> o;
uint32 delay;
};

View File

@@ -175,9 +175,8 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
//! but formationDest contains global coordinates
init.MoveTo(node->x, node->y, z, true, true);
//! Accepts angles such as 0.00001 and -0.00001, 0 must be ignored, default value in waypoint table
if (node->orientation && node->delay)
init.SetFacing(node->orientation);
if (node->orientation.has_value() && node->delay > 0)
init.SetFacing(*node->orientation);
switch (node->move_type)
{

View File

@@ -70,7 +70,9 @@ void WaypointMgr::Load()
float x = fields[2].Get<float>();
float y = fields[3].Get<float>();
float z = fields[4].Get<float>();
float o = fields[5].Get<float>();
std::optional<float > o;
if (!fields[5].IsNull())
o = fields[5].Get<float>();
Acore::NormalizeMapCoord(x);
Acore::NormalizeMapCoord(y);
@@ -131,7 +133,9 @@ void WaypointMgr::ReloadPath(uint32 id)
float x = fields[1].Get<float>();
float y = fields[2].Get<float>();
float z = fields[3].Get<float>();
float o = fields[4].Get<float>();
std::optional<float> o;
if (!fields[4].IsNull())
o = fields[4].Get<float>();
Acore::NormalizeMapCoord(x);
Acore::NormalizeMapCoord(y);

View File

@@ -35,7 +35,8 @@ enum WaypointMoveType
struct WaypointData
{
uint32 id;
float x, y, z, orientation;
float x, y, z;
std::optional<float> orientation;
uint32 delay;
uint32 event_id;
uint32 move_type;