mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-01 18:13:48 +00:00
fix(Core/Unit): Reduce mobs speed when low on health (#7932)
This commit is contained in:
@@ -1805,7 +1805,6 @@ void Creature::setDeathState(DeathState s, bool despawn)
|
|||||||
if (HasSearchedAssistance())
|
if (HasSearchedAssistance())
|
||||||
{
|
{
|
||||||
SetNoSearchAssistance(false);
|
SetNoSearchAssistance(false);
|
||||||
UpdateSpeed(MOVE_RUN, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dismiss group if is leader
|
//Dismiss group if is leader
|
||||||
|
|||||||
@@ -9773,7 +9773,6 @@ bool Unit::AttackStop()
|
|||||||
if (creature->HasSearchedAssistance())
|
if (creature->HasSearchedAssistance())
|
||||||
{
|
{
|
||||||
creature->SetNoSearchAssistance(false);
|
creature->SetNoSearchAssistance(false);
|
||||||
UpdateSpeed(MOVE_RUN, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13496,11 +13495,23 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for creature case, we check explicit if mob searched for assistance
|
int32 slowFromHealth = 0;
|
||||||
if (GetTypeId() == TYPEID_UNIT)
|
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())
|
// 1.6% for each % under 30.
|
||||||
speed *= 0.66f; // best guessed value, so this will be 33% reduction. Based off initial speed, mob can then "run", "walk fast" or "walk".
|
// 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
|
// Apply strongest slow aura mod to speed
|
||||||
@@ -14566,8 +14577,16 @@ void Unit::SetHealth(uint32 val)
|
|||||||
val = maxHealth;
|
val = maxHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float prevHealthPct = GetHealthPct();
|
||||||
|
|
||||||
SetUInt32Value(UNIT_FIELD_HEALTH, val);
|
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
|
// group update
|
||||||
if (GetTypeId() == TYPEID_PLAYER)
|
if (GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -115,9 +115,6 @@ namespace Movement
|
|||||||
moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING;
|
moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING;
|
||||||
|
|
||||||
args.velocity = unit->GetSpeed(SelectSpeedType(moveFlagsForSpeed));
|
args.velocity = unit->GetSpeed(SelectSpeedType(moveFlagsForSpeed));
|
||||||
if (Creature* creature = unit->ToCreature())
|
|
||||||
if (creature->HasSearchedAssistance())
|
|
||||||
args.velocity *= 0.66f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// limit the speed in the same way the client does
|
// limit the speed in the same way the client does
|
||||||
|
|||||||
Reference in New Issue
Block a user