Core/Player: fixed initializing base hp

This commit is contained in:
Ovahlord
2024-08-03 19:04:43 +02:00
parent 89bd2d7720
commit 46fbab3f42
4 changed files with 19 additions and 18 deletions

View File

@@ -2097,12 +2097,12 @@ void Player::GiveLevel(uint8 level)
PlayerLevelInfo info;
sObjectMgr->GetPlayerLevelInfo(GetRace(), GetClass(), level, &info);
uint32 basemana = 0;
sObjectMgr->GetPlayerClassLevelInfo(GetClass(), level, basemana);
uint32 basemana = 0, baseHp = 0;
sObjectMgr->GetPlayerClassLevelInfo(GetClass(), level, basemana, baseHp);
WorldPackets::Misc::LevelUpInfo packet;
packet.Level = level;
packet.HealthDelta = 0;
packet.HealthDelta = int32(baseHp) - int32(GetCreateHealth());
/// @todo find some better solution
// for (int i = 0; i < MAX_STORED_POWERS; ++i)
@@ -2131,7 +2131,7 @@ void Player::GiveLevel(uint8 level)
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
SetCreateStat(Stats(i), info.stats[i]);
SetCreateHealth(0);
SetCreateHealth(baseHp);
SetCreateMana(basemana);
InitGlyphsForLevel();
@@ -2182,8 +2182,8 @@ void Player::InitStatsForLevel(bool reapplyMods)
if (reapplyMods) //reapply stats values only on .reset stats (level) command
_RemoveAllStatBonuses();
uint32 basemana = 0;
sObjectMgr->GetPlayerClassLevelInfo(GetClass(), GetLevel(), basemana);
uint32 basemana = 0, baseHp = 0;
sObjectMgr->GetPlayerClassLevelInfo(GetClass(), GetLevel(), basemana, baseHp);
PlayerLevelInfo info;
sObjectMgr->GetPlayerLevelInfo(GetRace(), GetClass(), GetLevel(), &info);
@@ -2221,7 +2221,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
SetStat(Stats(i), info.stats[i]);
SetCreateHealth(0);
SetCreateHealth(baseHp);
//set create powers
SetCreateMana(basemana);

View File

@@ -111,10 +111,10 @@ void Unit::UpdatePowerRegen(Powers powerType)
case POWER_MANA:
{
// Get base of Mana Pool in sBaseMPGameTable
uint32 basemana = 0;
uint32 basemana = 0, basehp = 0;
if (IsPlayer())
sObjectMgr->GetPlayerClassLevelInfo(GetClass(), GetLevel(), basemana);
sObjectMgr->GetPlayerClassLevelInfo(GetClass(), GetLevel(), basemana, basehp);
else
basemana = GetCreateMana(); // this should also get replaced by the base mana game table in the future.

View File

@@ -4395,7 +4395,7 @@ void ObjectMgr::LoadPlayerInfo()
}
}
void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, uint32& baseMana) const
void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, uint32& baseMana, uint32& baseHp) const
{
if (level < 1 || class_ >= MAX_CLASSES)
return;
@@ -4403,14 +4403,15 @@ void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, uint32& base
if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
GtOctBaseMpByClassEntry const* mp = sOctBaseMpByClassGameTable.GetRow(level);
if (!mp)
{
TC_LOG_ERROR("misc", "Tried to get non-existant Class-Level combination data for base hp/mp. Class {} Level {}", class_, level);
return;
}
if (GtOctBaseMpByClassEntry const* mp = sOctBaseMpByClassGameTable.GetRow(level))
baseMana = uint32(GetGameTableColumnForClass(mp, class_));
else
baseMana = 0;
baseMana = uint32(GetGameTableColumnForClass(mp, class_));
if (GtOctBaseHpByClassEntry const* hp = sOctBaseHpByClassGameTable.GetRow(level))
baseHp = uint32(GetGameTableColumnForClass(hp, class_));
else
baseHp = 0;
}
void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const

View File

@@ -1162,7 +1162,7 @@ class TC_GAME_API ObjectMgr
PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint8 level) const;
void GetPlayerClassLevelInfo(uint32 class_, uint8 level, uint32& baseMana) const;
void GetPlayerClassLevelInfo(uint32 class_, uint8 level, uint32& baseMana, uint32& baseHp) const;
PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const;