mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 01:29:07 +00:00
fix(Core/Unit): Reduce mobs speed when low on health (#7932)
This commit is contained in:
@@ -9773,7 +9773,6 @@ bool Unit::AttackStop()
|
||||
if (creature->HasSearchedAssistance())
|
||||
{
|
||||
creature->SetNoSearchAssistance(false);
|
||||
UpdateSpeed(MOVE_RUN, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13496,11 +13495,23 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
||||
break;
|
||||
}
|
||||
|
||||
// for creature case, we check explicit if mob searched for assistance
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
int32 slowFromHealth = 0;
|
||||
Creature* creature = ToCreature();
|
||||
// ignore pets, player owned vehicles, and mobs immune to snare
|
||||
if (creature
|
||||
&& !IsPet()
|
||||
&& !(IsControlledByPlayer() && IsVehicle())
|
||||
&& !(creature->HasMechanicTemplateImmunity(MECHANIC_SNARE))
|
||||
&& !(creature->IsDungeonBoss()))
|
||||
{
|
||||
if (ToCreature()->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".
|
||||
// 1.6% for each % under 30.
|
||||
// use min(0, health-30) so that we don't boost mobs above 30.
|
||||
slowFromHealth = (int32) std::min(0.0f, (1.66f * (GetHealthPct() - 30.0f)));
|
||||
}
|
||||
|
||||
if (slowFromHealth)
|
||||
{
|
||||
AddPct(speed, slowFromHealth);
|
||||
}
|
||||
|
||||
// Apply strongest slow aura mod to speed
|
||||
@@ -14566,8 +14577,16 @@ void Unit::SetHealth(uint32 val)
|
||||
val = maxHealth;
|
||||
}
|
||||
|
||||
float prevHealthPct = GetHealthPct();
|
||||
|
||||
SetUInt32Value(UNIT_FIELD_HEALTH, val);
|
||||
|
||||
// mobs that are now or were below 30% need to update their speed
|
||||
if (GetTypeId() == TYPEID_UNIT && (prevHealthPct < 30.0 || HealthBelowPct(30)))
|
||||
{
|
||||
UpdateSpeed(MOVE_RUN, false);
|
||||
}
|
||||
|
||||
// group update
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user