Skip to content

Commit

Permalink
Creature: Resolve issues causing mobs not spawning with full health a…
Browse files Browse the repository at this point in the history
…nd power
  • Loading branch information
killerwife committed May 5, 2024
1 parent 52db10a commit 7d168e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ void Creature::SelectLevel(uint32 forcedLevel /*= USE_DEFAULT_DATABASE_LEVEL*/)
float rangedAttackPwr = 0.f;

float healthMultiplier = 1.f;
float manaMultiplier = 1.f;
float powerMultiplier = 1.f;

float strength = 0.f;
float agility = 0.f;
Expand All @@ -1325,7 +1325,7 @@ void Creature::SelectLevel(uint32 forcedLevel /*= USE_DEFAULT_DATABASE_LEVEL*/)
mana = cCLS->BaseMana;
// mana
if (cinfo->PowerMultiplier > 0)
manaMultiplier = cinfo->PowerMultiplier;
powerMultiplier = cinfo->PowerMultiplier;

// armor
if (cinfo->ArmorMultiplier >= 0)
Expand Down Expand Up @@ -1423,7 +1423,6 @@ void Creature::SelectLevel(uint32 forcedLevel /*= USE_DEFAULT_DATABASE_LEVEL*/)
// health
SetCreateHealth(health);
SetMaxHealth(health);
SetHealth(health);

// all power types
for (int i = POWER_MANA; i <= POWER_HAPPINESS; ++i)
Expand All @@ -1447,7 +1446,6 @@ void Creature::SelectLevel(uint32 forcedLevel /*= USE_DEFAULT_DATABASE_LEVEL*/)

// Mana requires an extra field to be set
SetMaxPower(Powers(i), maxValue);
SetPower(Powers(i), value);

if (i == POWER_MANA)
SetCreateMana(value);
Expand Down Expand Up @@ -1479,9 +1477,13 @@ void Creature::SelectLevel(uint32 forcedLevel /*= USE_DEFAULT_DATABASE_LEVEL*/)

// multipliers
SetModifierValue(UNIT_MOD_HEALTH, TOTAL_PCT, healthMultiplier);
SetModifierValue(UNIT_MOD_MANA, TOTAL_PCT, manaMultiplier);
SetModifierValue(UnitMods(UNIT_MOD_MANA + (int)GetPowerType()), TOTAL_PCT, powerMultiplier);

UpdateAllStats();

SetHealth(GetMaxHealth());
for (int i = POWER_MANA; i <= POWER_HAPPINESS; ++i)
SetPower(Powers(i), GetMaxPower(Powers(i)));
}

float Creature::_GetHealthMod(int32 Rank)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ CreatureClassLvlStats const* ObjectMgr::GetCreatureClassLvlStats(uint32 level, u

CreatureClassLvlStats const* cCLS = &m_creatureClassLvlStats[level][classToIndex[unitClass]][expansion];

if (cCLS->BaseHealth != 0 && cCLS->BaseDamage > 0.1f)
if ((cCLS->BaseHealth != 0 || cCLS->Stamina > 0) && cCLS->BaseDamage > 0.1f)
return cCLS;

return nullptr;
Expand Down

0 comments on commit 7d168e2

Please sign in to comment.