fix (Core/Movement) Allow MoveFollow to not inherit walkstate of the target to fix Enchanted Elemental speed (#19498)

* MoveFollow with own walkstate

* switch
This commit is contained in:
Tereneckla
2024-07-29 11:30:42 +00:00
committed by GitHub
parent 4c087c1c5f
commit e44e8fe109
5 changed files with 27 additions and 23 deletions

View File

@@ -270,7 +270,7 @@ void MotionMaster::MoveTargetedHome(bool walk /*= false*/)
if (target)
{
LOG_DEBUG("movement.motionmaster", "Following {} ({})", target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetGUID().ToString());
Mutate(new FollowMovementGenerator<Creature>(target, PET_FOLLOW_DIST, _owner->GetFollowAngle()), MOTION_SLOT_ACTIVE);
Mutate(new FollowMovementGenerator<Creature>(target, PET_FOLLOW_DIST, _owner->GetFollowAngle(),true), MOTION_SLOT_ACTIVE);
}
}
else
@@ -391,7 +391,7 @@ void MotionMaster::MoveCircleTarget(Unit* target)
init.Launch();
}
void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlot slot)
void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlot slot, bool inheritWalkState)
{
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
// ignore movement request if target not exist
@@ -405,13 +405,13 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlo
{
LOG_DEBUG("movement.motionmaster", "Player ({}) follow to {} ({})",
_owner->GetGUID().ToString(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetGUID().ToString());
Mutate(new FollowMovementGenerator<Player>(target, dist, angle), slot);
Mutate(new FollowMovementGenerator<Player>(target, dist, angle, inheritWalkState), slot);
}
else
{
LOG_DEBUG("movement.motionmaster", "Creature ({}) follow to {} ({})",
_owner->GetGUID().ToString(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetGUID().ToString());
Mutate(new FollowMovementGenerator<Creature>(target, dist, angle), slot);
Mutate(new FollowMovementGenerator<Creature>(target, dist, angle, inheritWalkState), slot);
}
}

View File

@@ -199,7 +199,7 @@ public:
void MoveIdle();
void MoveTargetedHome(bool walk = false);
void MoveRandom(float wanderDistance = 0.0f);
void MoveFollow(Unit* target, float dist, float angle, MovementSlot slot = MOTION_SLOT_ACTIVE);
void MoveFollow(Unit* target, float dist, float angle, MovementSlot slot = MOTION_SLOT_ACTIVE, bool inheritWalkState = true);
void MoveChase(Unit* target, std::optional<ChaseRange> dist = {}, std::optional<ChaseAngle> angle = {});
void MoveChase(Unit* target, float dist, float angle) { MoveChase(target, ChaseRange(dist), ChaseAngle(angle)); }
void MoveChase(Unit* target, float dist) { MoveChase(target, ChaseRange(dist)); }

View File

@@ -520,7 +520,9 @@ bool FollowMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
Movement::MoveSplineInit init(owner);
init.MovebyPath(i_path->GetPath());
init.SetWalk(target->IsWalking() || target->movespline->isWalking());
if (_inheritWalkState)
init.SetWalk(target->IsWalking() || target->movespline->isWalking());
if (Optional<float> velocity = GetVelocity(owner, target, i_path->GetActualEndPosition(), owner->IsGuardian()))
init.SetVelocity(*velocity);
init.Launch();

View File

@@ -74,8 +74,8 @@ template<class T>
class FollowMovementGenerator : public MovementGeneratorMedium<T, FollowMovementGenerator<T>>, public TargetedMovementGeneratorBase
{
public:
FollowMovementGenerator(Unit* target, float range, ChaseAngle angle)
: TargetedMovementGeneratorBase(target), i_path(nullptr), i_recheckPredictedDistanceTimer(0), i_recheckPredictedDistance(false), _range(range), _angle(angle) {}
FollowMovementGenerator(Unit* target, float range, ChaseAngle angle, bool inheritWalkState)
: TargetedMovementGeneratorBase(target), i_path(nullptr), i_recheckPredictedDistanceTimer(0), i_recheckPredictedDistance(false), _range(range), _angle(angle),_inheritWalkState(inheritWalkState) {}
~FollowMovementGenerator() { }
MovementGeneratorType GetMovementGeneratorType() { return FOLLOW_MOTION_TYPE; }
@@ -106,6 +106,7 @@ private:
Optional<Position> _lastPredictedPosition;
float _range;
ChaseAngle _angle;
bool _inheritWalkState;
};
#endif

View File

@@ -132,21 +132,22 @@ struct boss_lady_vashj : public BossAI
void JustSummoned(Creature* summon) override
{
summons.Summon(summon);
if (summon->GetEntry() == WORLD_TRIGGER)
{
summon->CastSpell(summon, SPELL_MAGIC_BARRIER);
}
else if (summon->GetEntry() == NPC_TOXIC_SPOREBAT)
{
summon->GetMotionMaster()->MoveRandom(30.0f);
}
else if (summon->GetEntry() == NPC_ENCHANTED_ELEMENTAL)
{
summon->GetMotionMaster()->MoveFollow(me, 0.0f, 0.0f);
}
else if (summon->GetEntry() != NPC_TAINTED_ELEMENTAL)
{
summon->GetMotionMaster()->MovePoint(POINT_HOME, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), true, true);
switch(summon->GetEntry()) {
case(WORLD_TRIGGER):
summon->CastSpell(summon, SPELL_MAGIC_BARRIER);
break;
case(NPC_ENCHANTED_ELEMENTAL):
summon->GetMotionMaster()->MoveFollow(me, 0.0f, 0.0f, MOTION_SLOT_ACTIVE, false);
summon->SetWalk(true);
summon->SetReactState(REACT_PASSIVE);
break;
case(NPC_TAINTED_ELEMENTAL):
break;
case(NPC_TOXIC_SPOREBAT):
summon->GetMotionMaster()->MoveRandom(30.0f);
break;
default:
summon->GetMotionMaster()->MovePoint(POINT_HOME, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), true, true);
}
}