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 8508f84 commit f11362c
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 @@ -1319,7 +1319,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 @@ -1345,7 +1345,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 @@ -1443,7 +1443,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_RUNIC_POWER; ++i)
Expand All @@ -1469,7 +1468,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 @@ -1501,9 +1499,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 @@ -1017,7 +1017,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 f11362c

Please sign in to comment.