fix(Core/Spells): Correct follow position for Pets and Companions. (#23154)
Co-authored-by: sogladev <sogladev@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <numbers>
|
||||||
|
|
||||||
enum ReactStates : uint8;
|
enum ReactStates : uint8;
|
||||||
|
|
||||||
@@ -202,8 +203,10 @@ enum PetScalingSpells
|
|||||||
SPELL_RISEN_GHOUL_SELF_STUN = 47466,
|
SPELL_RISEN_GHOUL_SELF_STUN = 47466,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PET_FOLLOW_DIST 1.0f
|
constexpr float PET_FOLLOW_DIST = 2.0f;
|
||||||
#define PET_FOLLOW_ANGLE (M_PI/2)
|
constexpr float PET_FOLLOW_ANGLE = std::numbers::pi_v<float> / 2;
|
||||||
|
constexpr float MINI_PET_SUMMON_ANGLE = std::numbers::pi_v<float> / 4;
|
||||||
|
constexpr float MINI_PET_FOLLOW_ANGLE = std::numbers::pi_v<float>;
|
||||||
|
|
||||||
class PetStable
|
class PetStable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2429,8 +2429,14 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SUMMON_TYPE_JEEVES:
|
|
||||||
case SUMMON_TYPE_MINIPET:
|
case SUMMON_TYPE_MINIPET:
|
||||||
|
// For companions, recalculate the position to ensure they spawn at the intended π/4 angle.
|
||||||
|
destTarget->Relocate(m_originalCaster->GetNearPosition(
|
||||||
|
m_originalCaster->GetDistance2d(destTarget->GetPositionX(), destTarget->GetPositionY()),
|
||||||
|
MINI_PET_SUMMON_ANGLE
|
||||||
|
));
|
||||||
|
[[fallthrough]];
|
||||||
|
case SUMMON_TYPE_JEEVES:
|
||||||
{
|
{
|
||||||
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn);
|
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn);
|
||||||
if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION))
|
if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION))
|
||||||
@@ -2446,8 +2452,9 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
|
|||||||
//summon->AI()->EnterEvadeMode();
|
//summon->AI()->EnterEvadeMode();
|
||||||
if (properties->Type != SUMMON_TYPE_JEEVES)
|
if (properties->Type != SUMMON_TYPE_JEEVES)
|
||||||
{
|
{
|
||||||
|
summon->SetFacingToObject(m_originalCaster);
|
||||||
summon->GetMotionMaster()->Clear(false);
|
summon->GetMotionMaster()->Clear(false);
|
||||||
summon->GetMotionMaster()->MoveFollow(m_originalCaster, PET_FOLLOW_DIST, summon->GetFollowAngle(), MOTION_SLOT_ACTIVE);
|
summon->GetMotionMaster()->MoveFollow(m_originalCaster, PET_FOLLOW_DIST, MINI_PET_FOLLOW_ANGLE, MOTION_SLOT_ACTIVE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ struct npc_pet_gen_argent_pony_bridle : public ScriptedAI
|
|||||||
if (Unit* owner = me->GetCharmerOrOwner())
|
if (Unit* owner = me->GetCharmerOrOwner())
|
||||||
{
|
{
|
||||||
me->GetMotionMaster()->Clear(false);
|
me->GetMotionMaster()->Clear(false);
|
||||||
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE);
|
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, MINI_PET_FOLLOW_ANGLE, MOTION_SLOT_ACTIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,7 +709,7 @@ struct npc_pet_gen_toxic_wasteling : public PassiveAI
|
|||||||
if (Unit* owner = me->GetCharmerOrOwner())
|
if (Unit* owner = me->GetCharmerOrOwner())
|
||||||
{
|
{
|
||||||
me->GetMotionMaster()->Clear(false);
|
me->GetMotionMaster()->Clear(false);
|
||||||
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE);
|
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, MINI_PET_FOLLOW_ANGLE, MOTION_SLOT_ACTIVE);
|
||||||
}
|
}
|
||||||
me->AddAura(71854, me); // Growth
|
me->AddAura(71854, me); // Growth
|
||||||
checkTimer = 0;
|
checkTimer = 0;
|
||||||
|
|||||||
@@ -1083,7 +1083,7 @@ class spell_item_enchanted_broom_periodic : public AuraScript
|
|||||||
{
|
{
|
||||||
if (owner->isMoving())
|
if (owner->isMoving())
|
||||||
{
|
{
|
||||||
GetTarget()->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, GetTarget()->GetFollowAngle(), MOTION_SLOT_ACTIVE);
|
GetTarget()->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, MINI_PET_FOLLOW_ANGLE, MOTION_SLOT_ACTIVE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user