Over 100 camangos Cata commits applied (to c12950)

Over 100 camangos Cata commits applied. up to and inclusing c12950.
This commit is contained in:
Charles A Edwards 2016-08-20 17:10:24 +01:00 committed by Antz
parent b4ec0440aa
commit eef77eadb9
117 changed files with 4314 additions and 3547 deletions

View file

@ -47,7 +47,7 @@ void HomeMovementGenerator<Creature>::_setTargetLocation(Creature& owner)
Movement::MoveSplineInit init(owner);
float x, y, z, o;
// at apply we can select more nice return points base at current movegen
if (owner.GetMotionMaster()->empty() || !owner.GetMotionMaster()->top()->GetResetPosition(owner, x, y, z))
if (owner.GetMotionMaster()->empty() || !owner.GetMotionMaster()->top()->GetResetPosition(owner, x, y, z, o))
{
owner.GetRespawnCoord(x, y, z, &o);
init.SetFacing(o);

View file

@ -76,6 +76,8 @@ class MotionMaster : private std::stack<MovementGenerator*>
void Initialize();
MovementGenerator const* GetCurrent() const { return top(); }
MovementGenerator* operator->(void) { return top(); }
using Impl::top;

View file

@ -59,7 +59,7 @@ class MovementGenerator
virtual void unitSpeedChanged() { }
// used by Evade code for select point to evade with expected restart default movement
virtual bool GetResetPosition(Unit&, float& /*x*/, float& /*y*/, float& /*z*/) const { return false; }
virtual bool GetResetPosition(Unit&, float& /*x*/, float& /*y*/, float& /*z*/, float& o) const { return false; }
// given destination unreachable? due to pathfinsing or other
virtual bool IsReachable() const { return true; }
@ -70,7 +70,7 @@ class MovementGenerator
};
template<class T, class D>
class MovementGeneratorMedium : public MovementGenerator
class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator
{
public:
void Initialize(Unit& u) override
@ -98,10 +98,10 @@ class MovementGeneratorMedium : public MovementGenerator
// u->AssertIsType<T>();
return (static_cast<D*>(this))->Update(*((T*)&u), time_diff);
}
bool GetResetPosition(Unit& u, float& x, float& y, float& z) const override
bool GetResetPosition(Unit& u, float& x, float& y, float& z, float& o) const override
{
// u->AssertIsType<T>();
return (static_cast<D const*>(this))->GetResetPosition(*((T*)&u), x, y, z);
return (static_cast<D const*>(this))->GetResetPosition(*((T*)&u), x, y, z, o);
}
public:
// Will not link if not overridden in the generators
@ -112,7 +112,7 @@ class MovementGeneratorMedium : public MovementGenerator
bool Update(T& u, const uint32& time_diff);
// not need always overwrites
bool GetResetPosition(T& /*u*/, float& /*x*/, float& /*y*/, float& /*z*/) const { return false; }
bool GetResetPosition(T& /*u*/, float& /*x*/, float& /*y*/, float& /*z*/, float& /*o*/) const { return false; }
};
struct SelectableMovement : public FactoryHolder<MovementGenerator, MovementGeneratorType>

View file

@ -101,10 +101,11 @@ class PathFinder
const dtNavMeshQuery* m_navMeshQuery; // the nav mesh query used to find the path
dtQueryFilter m_filter; // use single filter for all movements, update it when needed
void setStartPosition(const Vector3 &point) { m_startPosition = point; }
void setEndPosition(const Vector3 &point) { m_actualEndPosition = point; m_endPosition = point; }
void setActualEndPosition(const Vector3 &point) { m_actualEndPosition = point; }
void setStartPosition(const Vector3& point) { m_startPosition = point; }
void setEndPosition(const Vector3& point) { m_actualEndPosition = point; m_endPosition = point; }
void setActualEndPosition(const Vector3& point) { m_actualEndPosition = point; }
void clear()
{

View file

@ -317,11 +317,11 @@ void FollowMovementGenerator<T>::Reset(T& owner)
// This factor defines how much of the bounding-radius (as measurement of size) will be used for recalculating a new following position
// The smaller, the more micro movement, the bigger, possibly no proper movement updates
#define FOLLOW_RECALCULATE_FACTOR 0.1f
#define FOLLOW_RECALCULATE_FACTOR 1.0f
// This factor defines when the distance of a follower will have impact onto following-position updates
#define FOLLOW_DIST_GAP_FOR_DIST_FACTOR 3.0f
// This factor defines how much of the follow-distance will be used as sloppyness value (if the above distance is exceeded)
#define FOLLOW_DIST_RECALCULATE_FACTOR 0.1f
#define FOLLOW_DIST_RECALCULATE_FACTOR 1.0f
template<class T>
float FollowMovementGenerator<T>::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const

View file

@ -38,40 +38,35 @@
#include <cassert>
//-----------------------------------------------//
void WaypointMovementGenerator<Creature>::LoadPath(Creature& creature)
void WaypointMovementGenerator<Creature>::LoadPath(Creature& creature, int32 pathId, WaypointPathOrigin wpOrigin, uint32 overwriteEntry)
{
DETAIL_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "LoadPath: loading waypoint path for %s", creature.GetGuidStr().c_str());
i_path = sWaypointMgr.GetPath(creature.GetGUIDLow());
if (!overwriteEntry)
overwriteEntry = creature.GetEntry();
// We may LoadPath() for several occasions:
if (wpOrigin == PATH_NO_PATH && pathId == 0)
i_path = sWaypointMgr.GetDefaultPath(overwriteEntry, creature.GetGUIDLow(), &m_PathOrigin);
else
{
m_PathOrigin = wpOrigin == PATH_NO_PATH ? PATH_FROM_ENTRY : wpOrigin;
i_path = sWaypointMgr.GetPathFromOrigin(overwriteEntry, creature.GetGUIDLow(), pathId, m_PathOrigin);
}
m_pathId = pathId;
// 1: When creature.MovementType=2
// 1a) Path is selected by creature.guid == creature_movement.id
// 1b) Path for 1a) does not exist and then use path from creature.GetEntry() == creature_movement_template.entry
// 2: When creature_template.MovementType=2
// 2a) Creature is summoned and has creature_template.MovementType=2
// Creators need to be sure that creature_movement_template is always valid for summons.
// Mob that can be summoned anywhere should not have creature_movement_template for example.
// No movement found for guid
// No movement found for entry nor guid
if (!i_path)
{
i_path = sWaypointMgr.GetPathTemplate(creature.GetEntry());
// No movement found for entry
if (!i_path)
{
sLog.outErrorDb("WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path",
creature.GetName(), creature.GetEntry(), creature.GetGUIDLow());
return;
}
if (m_PathOrigin == PATH_FROM_EXTERNAL)
sLog.outErrorScriptLib("WaypointMovementGenerator::LoadPath: %s doesn't have waypoint path %i", creature.GetGuidStr().c_str(), pathId);
else
sLog.outErrorDb("WaypointMovementGenerator::LoadPath: %s doesn't have waypoint path %i", creature.GetGuidStr().c_str(), pathId);
return;
}
// Initialize the i_currentNode to point to the first node
if (i_path->empty())
return;
// Initialize the i_currentNode to point to the first node
i_currentNode = i_path->begin()->first;
m_lastReachedWaypoint = 0;
}
@ -80,10 +75,6 @@ void WaypointMovementGenerator<Creature>::Initialize(Creature& creature)
{
creature.addUnitState(UNIT_STAT_ROAMING);
creature.clearUnitState(UNIT_STAT_WAYPOINT_PAUSED);
LoadPath(creature);
StartMoveNow(creature);
}
void WaypointMovementGenerator<Creature>::Finalize(Creature& creature)
@ -158,23 +149,16 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
}
if (MangosStringLocale const* textData = sObjectMgr.GetMangosStringLocale(textId))
creature.MonsterText(textData, nullptr);
creature.MonsterText(textData, NULL);
else
sLog.outErrorDb("%s reached waypoint %u, attempted to do text %i, but required text-data could not be found", creature.GetGuidStr().c_str(), i_currentNode, textId);
}
}
// Inform script
MovementInform(creature);
Stop(node.delay);
}
void WaypointMovementGenerator<Creature>::StartMoveNow(Creature& creature)
{
i_nextMoveTime.Reset(0);
StartMove(creature);
}
void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
{
if (!i_path || i_path->empty())
@ -254,13 +238,7 @@ bool WaypointMovementGenerator<Creature>::Update(Creature& creature, const uint3
return true;
}
void WaypointMovementGenerator<Creature>::MovementInform(Creature& creature)
{
if (creature.AI())
creature.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode);
}
bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x, float& y, float& z) const
bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x, float& y, float& z, float& o) const
{
// prevent a crash at empty waypoint path.
if (!i_path || i_path->empty())
@ -271,9 +249,34 @@ bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x,
if (!m_lastReachedWaypoint && lastPoint == i_path->end())
return false;
MANGOS_ASSERT(lastPoint != i_path->end());
MANGOS_ASSERT(lastPoint != i_path->end());
WaypointNode const* curWP = &(lastPoint->second);
x = curWP->x;
y = curWP->y;
z = curWP->z;
if (curWP->orientation != 100)
o = curWP->orientation;
else // Calculate the resulting angle based on positions between previous and current waypoint
{
WaypointNode const* prevWP;
if (lastPoint != i_path->begin()) // Not the first waypoint
{
--lastPoint;
prevWP = &(lastPoint->second);
}
else // Take the last waypoint (crbegin()) as previous
prevWP = &(i_path->rbegin()->second);
float dx = x - prevWP->x;
float dy = y - prevWP->y;
o = atan2(dy, dx); // returns value between -Pi..Pi
o = (o >= 0) ? o : 2 * M_PI_F + o;
}
x = lastPoint->second.x; y = lastPoint->second.y; z = lastPoint->second.z;
return true;
}
@ -418,9 +421,12 @@ void FlightPathMovementGenerator::DoEventIfAny(Player& player, TaxiPathNodeEntry
}
}
bool FlightPathMovementGenerator::GetResetPosition(Player&, float& x, float& y, float& z) const
bool FlightPathMovementGenerator::GetResetPosition(Player&, float& x, float& y, float& z, float& o) const
{
const TaxiPathNodeEntry& node = (*i_path)[i_currentNode];
x = node.x; y = node.y; z = node.z;
x = node.x;
y = node.y;
z = node.z;
return true;
}

View file

@ -42,7 +42,7 @@
#define STOP_TIME_FOR_PLAYER (3 * MINUTE * IN_MILLISECONDS) // 3 Minutes
template<class T, class P>
class PathMovementBase
class MANGOS_DLL_SPEC PathMovementBase
{
public:
PathMovementBase() : i_currentNode(0) {}
@ -66,9 +66,9 @@ template<class T>
class WaypointMovementGenerator;
template<>
class WaypointMovementGenerator<Creature>
class MANGOS_DLL_SPEC WaypointMovementGenerator<Creature>
: public MovementGeneratorMedium< Creature, WaypointMovementGenerator<Creature> >,
public PathMovementBase<Creature, WaypointPath const*>
public PathMovementBase<Creature, WaypointPath const*>
{
public:
WaypointMovementGenerator(Creature&) : i_nextMoveTime(0), m_isArrivalDone(false), m_lastReachedWaypoint(0) {}
@ -78,21 +78,21 @@ class WaypointMovementGenerator<Creature>
void Finalize(Creature&);
void Reset(Creature& u);
bool Update(Creature& u, const uint32& diff);
void MovementInform(Creature&);
void InitializeWaypointPath(Creature& u, int32 id, WaypointPathOrigin wpSource, uint32 initialDelay, uint32 overwriteEntry);
MovementGeneratorType GetMovementGeneratorType() const { return WAYPOINT_MOTION_TYPE; }
// now path movement implmementation
void LoadPath(Creature& c);
bool GetResetPosition(Creature&, float& x, float& y, float& z) const;
bool GetResetPosition(Creature&, float& /*x*/, float& /*y*/, float& /*z*/, float& /*o*/) const;
uint32 getLastReachedWaypoint() const { return m_lastReachedWaypoint; }
void GetPathInformation(int32& pathId, WaypointPathOrigin& wpOrigin) const { pathId = m_pathId; wpOrigin = m_PathOrigin; }
void GetPathInformation(std::ostringstream& oss) const;
void AddToWaypointPauseTime(int32 waitTimeDiff);
uint32 getLastReachedWaypoint() const { return m_lastReachedWaypoint; }
bool SetNextWaypoint(uint32 pointId);
private:
void LoadPath(Creature& c, int32 id, WaypointPathOrigin wpOrigin, uint32 overwriteEntry);
void Stop(int32 time) { i_nextMoveTime.Reset(time); }
bool Stopped(Creature& u);
bool CanMove(int32 diff, Creature& u);
@ -100,11 +100,12 @@ class WaypointMovementGenerator<Creature>
void OnArrived(Creature&);
void StartMove(Creature&);
void StartMoveNow(Creature& creature);
ShortTimeTracker i_nextMoveTime;
bool m_isArrivalDone;
uint32 m_lastReachedWaypoint;
uint32 m_lastReachedWaypoint;
int32 m_pathId;
WaypointPathOrigin m_PathOrigin;
};
/** FlightPathMovementGenerator generates movement of the player for the paths
@ -133,7 +134,7 @@ class FlightPathMovementGenerator
void SetCurrentNodeAfterTeleport();
void SkipCurrentNode() { ++i_currentNode; }
void DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure);
bool GetResetPosition(Player&, float& x, float& y, float& z) const;
bool GetResetPosition(Player&, float& x, float& y, float& z, float& o) const;
};
#endif