Fix fleeing speed to 66% run speed (#24025)

* Core/Movement: Fix fleeing speed to 66% run speed

Fix fleeing speed to 66% run speed until the creature starts returning home

* Fix build

* Don't check speed type

* Don't apply speed reduction twice

* Fix no-pch (1st try)

* Make sure every spell focus is interrupted when seeking assistance

(cherry picked from commit 4ccf01de39)
This commit is contained in:
Giacomo Pozzoni
2020-01-01 16:28:33 +01:00
committed by Shauren
parent d946d74ff9
commit d095d4afe9
6 changed files with 15 additions and 23 deletions

View File

@@ -990,7 +990,6 @@ void Creature::DoFleeToGetAssistance()
Cell::VisitGridObjects(this, searcher, radius);
SetNoSearchAssistance(true);
UpdateSpeed(MOVE_RUN);
if (!creature)
/// @todo use 31365
@@ -2105,11 +2104,7 @@ void Creature::setDeathState(DeathState s)
setActive(false);
if (HasSearchedAssistance())
{
SetNoSearchAssistance(false);
UpdateSpeed(MOVE_RUN);
}
SetNoSearchAssistance(false);
//Dismiss group if is leader
if (m_formation && m_formation->GetLeader() == this)

View File

@@ -5502,12 +5502,6 @@ bool Unit::AttackStop()
if (Creature* creature = ToCreature())
{
creature->SetNoCallAssistance(false);
if (creature->HasSearchedAssistance())
{
creature->SetNoSearchAssistance(false);
UpdateSpeed(MOVE_RUN);
}
}
SendMeleeAttackStop(victim);
@@ -8024,10 +8018,6 @@ void Unit::UpdateSpeed(UnitMoveType mtype)
if (Creature* creature = ToCreature())
{
// for creature case, we check explicit if mob searched for assistance
if (creature->HasSearchedAssistance())
speed *= 0.66f; // best guessed value, so this will be 33% reduction. Based off initial speed, mob can then "run", "walk fast" or "walk".
if (creature->HasUnitTypeMask(UNIT_MASK_MINION) && !creature->IsInCombat())
{
if (GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE)

View File

@@ -984,13 +984,14 @@ void MotionMaster::MoveFall(uint32 id/* = 0*/)
void MotionMaster::MoveSeekAssistance(float x, float y, float z)
{
if (_owner->GetTypeId() == TYPEID_UNIT)
if (Creature* creature = _owner->ToCreature())
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveSeekAssistance: '%s', seeks assistance (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z);
_owner->AttackStop();
_owner->CastStop();
_owner->ToCreature()->SetReactState(REACT_PASSIVE);
Add(new AssistanceMovementGenerator(EVENT_ASSIST_MOVE, x, y, z, _owner->GetSpeed(MOVE_RUN) * 0.66f));
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveSeekAssistance: '%s', seeks assistance (X: %f, Y: %f, Z: %f)", creature->GetGUID().ToString().c_str(), x, y, z);
creature->AttackStop();
creature->CastStop();
creature->DoNotReacquireSpellFocusTarget();
creature->SetReactState(REACT_PASSIVE);
Add(new AssistanceMovementGenerator(EVENT_ASSIST_MOVE, x, y, z));
}
else
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveSeekAssistance: '%s', attempted to seek assistance.", _owner->GetGUID().ToString().c_str());

View File

@@ -89,6 +89,8 @@ void HomeMovementGenerator<Creature>::DoInitialize(Creature* owner)
RemoveFlag(MOVEMENTGENERATOR_FLAG_INITIALIZATION_PENDING | MOVEMENTGENERATOR_FLAG_DEACTIVATED);
AddFlag(MOVEMENTGENERATOR_FLAG_INITIALIZED);
owner->SetNoSearchAssistance(false);
SetTargetLocation(owner);
}

View File

@@ -63,7 +63,7 @@ class PointMovementGenerator : public MovementGeneratorMedium<T, PointMovementGe
class AssistanceMovementGenerator : public PointMovementGenerator<Creature>
{
public:
explicit AssistanceMovementGenerator(uint32 id, float x, float y, float z, float speed = 0.0f) : PointMovementGenerator<Creature>(id, x, y, z, true, speed) { }
explicit AssistanceMovementGenerator(uint32 id, float x, float y, float z) : PointMovementGenerator<Creature>(id, x, y, z, true) { }
void Finalize(Unit*, bool, bool) override;
MovementGeneratorType GetMovementGeneratorType() const override;

View File

@@ -16,6 +16,7 @@
*/
#include "MoveSplineInit.h"
#include "Creature.h"
#include "MovementPackets.h"
#include "MoveSpline.h"
#include "PathGenerator.h"
@@ -107,6 +108,9 @@ namespace Movement
moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING;
args.velocity = unit->GetSpeed(SelectSpeedType(moveFlagsForSpeed));
if (Creature* creature = unit->ToCreature())
if (creature->HasSearchedAssistance())
args.velocity *= 0.66f;
}
// limit the speed in the same way the client does