Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2025-06-01 14:55:09 +08:00
66 changed files with 1638 additions and 550 deletions

View File

@@ -2672,29 +2672,30 @@ 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);
return IsWithinDist(victim, dist);
}
if (!dist)
return true;
float x, y, z;
x = y = z = 0.0f;
if (GetMotionMaster()->GetMotionSlot(MOTION_SLOT_IDLE)->GetResetPosition(x, y, z))
return IsInDist2d(x, y, 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 IsInDist2d(&m_homePosition, dist);
}
CreatureAddon const* Creature::GetCreatureAddon() const
@@ -3730,6 +3731,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())