Skip to content

Commit

Permalink
[3.3.5][master] Core/Movement: Smooth movement #13467 (#18020)
Browse files Browse the repository at this point in the history
Implement smooth movement for all waypoint pathing and escortai
  • Loading branch information
Riztazz authored and DDuarte committed Nov 24, 2016
1 parent 90a5811 commit 28050f3
Show file tree
Hide file tree
Showing 14 changed files with 578 additions and 590 deletions.
349 changes: 149 additions & 200 deletions src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp

Large diffs are not rendered by default.

39 changes: 8 additions & 31 deletions src/server/game/AI/ScriptedAI/ScriptedEscortAI.h
Expand Up @@ -20,27 +20,11 @@
#define SC_ESCORTAI_H

#include "ScriptSystem.h"
#include "WaypointMovementGenerator.h"
#include "WaypointManager.h"

#define DEFAULT_MAX_PLAYER_DISTANCE 50

struct Escort_Waypoint
{
Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w)
{
id = _id;
x = _x;
y = _y;
z = _z;
WaitTimeMs = _w;
}

uint32 id;
float x;
float y;
float z;
uint32 WaitTimeMs;
};

enum eEscortState
{
STATE_ESCORT_NONE = 0x000, //nothing in progress
Expand All @@ -56,7 +40,6 @@ struct TC_GAME_API npc_escortAI : public ScriptedAI
~npc_escortAI() { }

// CreatureAI functions
void AttackStart(Unit* who) override;

void MoveInLineOfSight(Unit* who) override;

Expand All @@ -76,15 +59,6 @@ struct TC_GAME_API npc_escortAI : public ScriptedAI
// EscortAI functions
void AddWaypoint(uint32 id, float x, float y, float z, uint32 waitTime = 0); // waitTime is in ms

//this will set the current position to x/y/z/o, and the current WP to pointId.
bool SetNextWaypoint(uint32 pointId, float x, float y, float z, float orientation);

//this will set the current position to WP start position (if setPosition == true),
//and the current WP to pointId
bool SetNextWaypoint(uint32 pointId, bool setPosition = true, bool resetWaypointsOnFail = true);

bool GetWaypointPosition(uint32 pointId, float& x, float& y, float& z);

virtual void WaypointReached(uint32 pointId) = 0;
virtual void WaypointStart(uint32 /*pointId*/) { }

Expand All @@ -104,6 +78,7 @@ struct TC_GAME_API npc_escortAI : public ScriptedAI
bool GetAttack() const { return m_bIsActiveAttacker; }//used in EnterEvadeMode override
void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; }
ObjectGuid GetEventStarterGUID() const { return m_uiPlayerGUID; }
void SetWaitTimer(uint32 Timer) { m_uiWPWaitTimer = Timer; }

protected:
Player* GetPlayerForEscort() { return ObjectAccessor::GetPlayer(*me, m_uiPlayerGUID); }
Expand All @@ -121,11 +96,11 @@ struct TC_GAME_API npc_escortAI : public ScriptedAI
uint32 m_uiPlayerCheckTimer;
uint32 m_uiEscortState;
float MaxPlayerDistance;
uint32 LastWP;

Quest const* m_pQuestForEscort; //generally passed in Start() when regular escort script.
WaypointPath _path;

std::list<Escort_Waypoint> WaypointList;
std::list<Escort_Waypoint>::iterator CurrentWP;
Quest const* m_pQuestForEscort; //generally passed in Start() when regular escort script.

bool m_bIsActiveAttacker; //obsolete, determined by faction.
bool m_bIsRunning; //all creatures are walking by default (has flag MOVEMENTFLAG_WALK)
Expand All @@ -135,5 +110,7 @@ struct TC_GAME_API npc_escortAI : public ScriptedAI
bool DespawnAtFar;
bool ScriptWP;
bool HasImmuneToNPCFlags;
bool m_bStarted;
bool m_bEnded;
};
#endif

4 comments on commit 28050f3

@Kittnz
Copy link
Member

@Kittnz Kittnz commented on 28050f3 Nov 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SAI scripts still need to be updated.

@Riztazz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there is only a few of those - i'll post one as example later

@Kittnz
Copy link
Member

@Kittnz Kittnz commented on 28050f3 Nov 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work either way 👍

@Rushor
Copy link
Contributor

@Rushor Rushor commented on 28050f3 Dec 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

massive problems with most escortscripts (corescript or SAI). detailed discussion and infos in #18401

Please sign in to comment.