mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-02 10:33:46 +00:00
fix(Core/Creature): Leashing improvements. (#22129)
Co-authored-by: killerwife <killerwife@users.noreply.github.com> Co-authored-by: 天鹭 <18535853+PkllonG@users.noreply.github.com>
This commit is contained in:
@@ -2671,29 +2671,28 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
|
||||
|
||||
// pussywizard: don't check distance to home position if recently damaged (allow kiting away from spawnpoint!)
|
||||
// xinef: this should include taunt auras
|
||||
if (!isWorldBoss() && (GetLastLeashExtensionTime() + 12 > GameTime::GetGameTime().count() || HasTauntAura()))
|
||||
if (!isWorldBoss() && (GetLastLeashExtensionTime() + GetLeashTimer() > GameTime::GetGameTime().count() || HasTauntAura()))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (skipDistCheck)
|
||||
return true;
|
||||
|
||||
// xinef: added size factor for huge npcs
|
||||
float dist = std::min<float>(GetDetectionRange() + GetObjectSize() * 2, 150.0f);
|
||||
float dist = sWorld->getFloatConfig(CONFIG_CREATURE_LEASH_RADIUS);
|
||||
|
||||
if (Unit* unit = GetCharmerOrOwner())
|
||||
if (GetCharmerOrOwner())
|
||||
{
|
||||
dist = std::min<float>(GetMap()->GetVisibilityRange() + GetObjectSize() * 2, 150.0f);
|
||||
return victim->IsWithinDist(unit, dist);
|
||||
}
|
||||
else
|
||||
{
|
||||
// to prevent creatures in air ignore attacks because distance is already too high...
|
||||
if (GetMovementTemplate().IsFlightAllowed())
|
||||
return victim->IsInDist2d(&m_homePosition, dist);
|
||||
else
|
||||
return victim->IsInDist(&m_homePosition, dist);
|
||||
return IsWithinDist(victim, dist);
|
||||
}
|
||||
|
||||
if (!dist)
|
||||
return true;
|
||||
|
||||
float x, y, z;
|
||||
GetMotionMaster()->GetMotionSlot(MOTION_SLOT_IDLE)->GetResetPosition(x, y, z);
|
||||
|
||||
return IsInDist2d(x, y, dist);
|
||||
}
|
||||
|
||||
CreatureAddon const* Creature::GetCreatureAddon() const
|
||||
@@ -3729,6 +3728,16 @@ void Creature::UpdateLeashExtensionTime()
|
||||
(*GetLastLeashExtensionTimePtr()) = GameTime::GetGameTime().count();
|
||||
}
|
||||
|
||||
uint8 Creature::GetLeashTimer() const
|
||||
{ // Based on testing on Classic, seems to range from ~11s for low level mobs (1-5) to ~16s for high level mobs (70+)
|
||||
uint8 timerOffset = 11;
|
||||
|
||||
uint8 timerModifier = uint8(GetLevel() / 10) - 2;
|
||||
|
||||
// Formula is likely not quite correct, but better than flat timer
|
||||
return std::max<uint8>(timerOffset, timerOffset + timerModifier);
|
||||
}
|
||||
|
||||
bool Creature::CanPeriodicallyCallForAssistance() const
|
||||
{
|
||||
if (!IsInCombat())
|
||||
|
||||
@@ -391,6 +391,7 @@ public:
|
||||
void ClearLastLeashExtensionTimePtr();
|
||||
time_t GetLastLeashExtensionTime() const;
|
||||
void UpdateLeashExtensionTime();
|
||||
uint8 GetLeashTimer() const;
|
||||
|
||||
bool IsFreeToMove();
|
||||
static constexpr uint32 MOVE_CIRCLE_CHECK_INTERVAL = 3000;
|
||||
|
||||
Reference in New Issue
Block a user