Relocated 'stop movement' code into class Mob from class Bot

This commit is contained in:
Uleat 2018-02-01 05:38:10 -05:00
parent 8805021960
commit d71dbd1751
4 changed files with 24 additions and 21 deletions

View File

@ -2041,18 +2041,6 @@ void Bot::SetTarget(Mob* mob) {
} }
} }
void Bot::ForceMovementEnd() {
FixZ();
SetCurrentSpeed(0);
if (moved)
moved = false;
}
void Bot::ForceMovementEnd(float new_heading) {
SetHeading(new_heading);
ForceMovementEnd();
}
// AI Processing for the Bot object // AI Processing for the Bot object
void Bot::AI_Process() { void Bot::AI_Process() {
@ -2135,7 +2123,7 @@ void Bot::AI_Process() {
// Can't move if rooted... // Can't move if rooted...
if (IsRooted() && IsMoving()) { if (IsRooted() && IsMoving()) {
ForceMovementEnd(); StopMoving();
return; return;
} }
@ -2263,7 +2251,7 @@ void Bot::AI_Process() {
SetTarget(nullptr); SetTarget(nullptr);
if (IsMoving()) if (IsMoving())
ForceMovementEnd(); StopMoving();
return; return;
} }
@ -2418,7 +2406,7 @@ void Bot::AI_Process() {
// We can fight // We can fight
if (atCombatRange) { if (atCombatRange) {
if (IsMoving()) { if (IsMoving()) {
ForceMovementEnd(CalculateHeadingToTarget(tar->GetX(), tar->GetY())); StopMoving(CalculateHeadingToTarget(tar->GetX(), tar->GetY()));
return; return;
} }
@ -2644,7 +2632,7 @@ void Bot::AI_Process() {
} }
else { else {
if (IsMoving()) if (IsMoving())
ForceMovementEnd(); StopMoving();
else else
SendPosition(); SendPosition();
@ -2698,7 +2686,7 @@ void Bot::AI_Process() {
// Leash the bot // Leash the bot
if (lo_distance > BOT_LEASH_DISTANCE) { if (lo_distance > BOT_LEASH_DISTANCE) {
if (IsMoving()) if (IsMoving())
ForceMovementEnd(); StopMoving();
Warp(glm::vec3(leash_owner->GetPosition())); Warp(glm::vec3(leash_owner->GetPosition()));
@ -2754,7 +2742,7 @@ void Bot::AI_Process() {
} }
else { else {
if (IsMoving()) { if (IsMoving()) {
ForceMovementEnd(); StopMoving();
return; return;
} }
} }

View File

@ -405,9 +405,7 @@ public:
bool AIHealRotation(Mob* tar, bool useFastHeals); bool AIHealRotation(Mob* tar, bool useFastHeals);
bool GetPauseAI() { return _pauseAI; } bool GetPauseAI() { return _pauseAI; }
void SetPauseAI(bool pause_flag) { _pauseAI = pause_flag; } void SetPauseAI(bool pause_flag) { _pauseAI = pause_flag; }
void ForceMovementEnd();
void ForceMovementEnd(float new_heading);
// Mob AI Virtual Override Methods // Mob AI Virtual Override Methods
virtual void AI_Process(); virtual void AI_Process();
virtual void AI_Stop(); virtual void AI_Stop();

View File

@ -1437,6 +1437,21 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal
} }
} }
void Mob::StopMoving() {
FixZ();
SetCurrentSpeed(0);
if (moved)
moved = false;
}
void Mob::StopMoving(float new_heading) {
SetHeading(new_heading);
FixZ();
SetCurrentSpeed(0);
if (moved)
moved = false;
}
/* Used for mobs standing still - this does not send a delta */ /* Used for mobs standing still - this does not send a delta */
void Mob::SendPosition() { void Mob::SendPosition() {
auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));

View File

@ -569,6 +569,8 @@ public:
void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu); void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu);
void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu); void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu);
void SendPosition(); void SendPosition();
void StopMoving();
void StopMoving(float new_heading);
void SetSpawned() { spawned = true; }; void SetSpawned() { spawned = true; };
bool Spawned() { return spawned; }; bool Spawned() { return spawned; };
virtual bool ShouldISpawnFor(Client *c) { return true; } virtual bool ShouldISpawnFor(Client *c) { return true; }