mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
Core/Creature: update health/mana/damage/armor when changing a creature's entry while keeping the original level.
Fixes an issue introduced in a6ef9d4.
This commit is contained in:
@@ -438,10 +438,9 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
|
||||
if (updateLevel)
|
||||
SelectLevel();
|
||||
|
||||
UpdateLevelDependantStats();
|
||||
|
||||
SetMeleeDamageSchool(SpellSchools(cInfo->dmgschool));
|
||||
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(getLevel(), cInfo->unit_class);
|
||||
float armor = (float)stats->GenerateArmor(cInfo); /// @todo Why is this treated as uint32 when it's a float?
|
||||
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, armor);
|
||||
SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_HOLY]));
|
||||
SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_FIRE]));
|
||||
SetModifierValue(UNIT_MOD_RESISTANCE_NATURE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_NATURE]));
|
||||
@@ -1177,15 +1176,18 @@ void Creature::SelectLevel()
|
||||
{
|
||||
CreatureTemplate const* cInfo = GetCreatureTemplate();
|
||||
|
||||
uint32 rank = IsPet() ? 0 : cInfo->rank;
|
||||
|
||||
// level
|
||||
uint8 minlevel = std::min(cInfo->maxlevel, cInfo->minlevel);
|
||||
uint8 maxlevel = std::max(cInfo->maxlevel, cInfo->minlevel);
|
||||
uint8 level = minlevel == maxlevel ? minlevel : urand(minlevel, maxlevel);
|
||||
SetLevel(level);
|
||||
}
|
||||
|
||||
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(level, cInfo->unit_class);
|
||||
void Creature::UpdateLevelDependantStats()
|
||||
{
|
||||
CreatureTemplate const* cInfo = GetCreatureTemplate();
|
||||
uint32 rank = IsPet() ? 0 : cInfo->rank;
|
||||
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(getLevel(), cInfo->unit_class);
|
||||
|
||||
// health
|
||||
float healthmod = _GetHealthMod(rank);
|
||||
@@ -1228,6 +1230,9 @@ void Creature::SelectLevel()
|
||||
|
||||
SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, stats->AttackPower);
|
||||
SetModifierValue(UNIT_MOD_ATTACK_POWER_RANGED, BASE_VALUE, stats->RangedAttackPower);
|
||||
|
||||
float armor = (float)stats->GenerateArmor(cInfo); /// @todo Why is this treated as uint32 when it's a float?
|
||||
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, armor);
|
||||
}
|
||||
|
||||
float Creature::_GetHealthMod(int32 Rank)
|
||||
|
||||
@@ -441,6 +441,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data = nullptr, uint32 vehId = 0);
|
||||
bool LoadCreaturesAddon();
|
||||
void SelectLevel();
|
||||
void UpdateLevelDependantStats();
|
||||
void LoadEquipment(int8 id = 1, bool force = false);
|
||||
void SetSpawnHealth();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user