Core/Player: Use DBC data to set the correct amount of hp and mana based on player level and class

This commit is contained in:
Subv committed 2012-08-04 11:33:49 -05:00
1 parent 5518daa74b
commit d9da2e8e50
10 files changed
+44 -124

No files matched your search

@@ -0,0 +1 @@
DROP TABLE IF EXISTS `player_classlevelstats`;
+4
View File
@@ -107,6 +107,8 @@ DBCStorage <GtOCTRegenHPEntry> sGtOCTRegenHPStore(GtOCTRegenHPfmt);
DBCStorage <GtRegenHPPerSptEntry> sGtRegenHPPerSptStore(GtRegenHPPerSptfmt);
DBCStorage <gtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore(GtOCTHpPerStaminafmt);
DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt);
DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore(GtOCTBaseHPByClassfmt);
DBCStorage <GtOCTBaseMPByClassEntry> sGtOCTBaseMPByClassStore(GtOCTBaseMPByClassfmt);
DBCStorage <HolidaysEntry> sHolidaysStore(Holidaysfmt);
@@ -396,6 +398,8 @@ void LoadDBCStores(const std::string& dataPath)
//LoadDBC(dbcCount, availableDbcLocales, bad_dbc_files, sGtOCTRegenMPStore, dbcPath, "gtOCTRegenMP.dbc"); -- not used currently
//LoadDBC(availableDbcLocales, bad_dbc_files, sGtRegenHPPerSptStore, dbcPath, "gtRegenHPPerSpt.dbc");//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sGtRegenMPPerSptStore, dbcPath, "gtRegenMPPerSpt.dbc");//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sGtOCTBaseHPByClassStore, dbcPath, "gtOCTBaseHPByClass.dbc");//15595
LoadDBC(availableDbcLocales, bad_dbc_files, sGtOCTBaseMPByClassStore, dbcPath, "gtOCTBaseMPByClass.dbc");//15595
LoadDBC(availableDbcLocales, bad_dbc_files, sHolidaysStore, dbcPath, "Holidays.dbc");//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sImportPriceArmorStore, dbcPath, "ImportPriceArmor.dbc"); // 15595
+2
View File
@@ -120,6 +120,8 @@ extern DBCStorage <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingSca
extern DBCStorage <GtRegenHPPerSptEntry> sGtRegenHPPerSptStore;
extern DBCStorage <gtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore;
extern DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore;
extern DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore;
extern DBCStorage <GtOCTBaseMPByClassEntry> sGtOCTBaseMPByClassStore;
extern DBCStorage <HolidaysEntry> sHolidaysStore;
extern DBCStorage <ImportPriceArmorEntry> sImportPriceArmorStore;
extern DBCStorage <ImportPriceQualityEntry> sImportPriceQualityStore;
@@ -1117,6 +1117,15 @@ struct GtRegenMPPerSptEntry
float ratio;
};
struct GtOCTBaseHPByClassEntry
{
float ratio;
};
struct GtOCTBaseMPByClassEntry
{
float ratio;
};
/* no used
struct HolidayDescriptionsEntry
{
+2
View File
@@ -77,6 +77,8 @@ const char GtOCTRegenHPfmt[]="f";
//const char GtOCTRegenMPfmt[]="f";
const char GtRegenHPPerSptfmt[]="f";
const char GtRegenMPPerSptfmt[]="xf";
const char GtOCTBaseHPByClassfmt[]="df";
const char GtOCTBaseMPByClassfmt[]="df";
const char Holidaysfmt[]="niiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiixxsiix";
const char ImportPriceArmorfmt[]="nffff";
const char ImportPriceQualityfmt[]="nf";
+11 -11
View File
@@ -3062,15 +3062,15 @@ void Player::GiveLevel(uint8 level)
PlayerLevelInfo info;
sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), level, &info);
PlayerClassLevelInfo classInfo;
sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, &classInfo);
uint32 basehp = 0, basemana = 0;
sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, basehp, basemana);
// send levelup info to client
WorldPacket data(SMSG_LEVELUP_INFO, (4+4+MAX_STORED_POWERS*4+MAX_STATS*4));
data << uint32(level);
data << uint32(int32(classInfo.basehealth) - int32(GetCreateHealth()));
data << uint32(int32(basehp) - int32(GetCreateHealth()));
// for (int i = 0; i < MAX_STORED_POWERS; ++i) // Powers loop (0-10)
data << uint32(int32(classInfo.basemana) - int32(GetCreateMana()));
data << uint32(int32(basemana) - int32(GetCreateMana()));
data << uint32(0);
data << uint32(0);
data << uint32(0);
@@ -3096,8 +3096,8 @@ void Player::GiveLevel(uint8 level)
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
SetCreateStat(Stats(i), info.stats[i]);
SetCreateHealth(classInfo.basehealth);
SetCreateMana(classInfo.basemana);
SetCreateHealth(basehp);
SetCreateMana(basemana);
InitTalentForLevel();
InitTaxiNodesForLevel();
@@ -3191,8 +3191,8 @@ void Player::InitStatsForLevel(bool reapplyMods)
if (reapplyMods) //reapply stats values only on .reset stats (level) command
_RemoveAllStatBonuses();
PlayerClassLevelInfo classInfo;
sObjectMgr->GetPlayerClassLevelInfo(getClass(), getLevel(), &classInfo);
uint32 basehp = 0, basemana = 0;
sObjectMgr->GetPlayerClassLevelInfo(getClass(), getLevel(), basehp, basemana);
PlayerLevelInfo info;
sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), getLevel(), &info);
@@ -3219,10 +3219,10 @@ void Player::InitStatsForLevel(bool reapplyMods)
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
SetStat(Stats(i), info.stats[i]);
SetCreateHealth(classInfo.basehealth);
SetCreateHealth(basehp);
//set create powers
SetCreateMana(classInfo.basemana);
SetCreateMana(basemana);
SetArmor(int32(m_createStats[STAT_AGILITY]*2));
@@ -3302,7 +3302,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
SetMaxPower(Powers(i), GetCreatePowers(Powers(i)));
SetMaxHealth(classInfo.basehealth); // stamina bonus will applied later
SetMaxHealth(basehp); // stamina bonus will applied later
// cleanup mounted state (it will set correctly at aura loading if player saved at mount.
SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0);
-14
View File
@@ -221,20 +221,6 @@ struct PlayerCreateInfoItem
typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems;
struct PlayerClassLevelInfo
{
PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
uint16 basehealth;
uint16 basemana;
};
struct PlayerClassInfo
{
PlayerClassInfo() : levelInfo(NULL) { }
PlayerClassLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
};
struct PlayerLevelInfo
{
PlayerLevelInfo() { for (uint8 i=0; i < MAX_STATS; ++i) stats[i] = 0; }
+13 -90
View File
@@ -244,10 +244,6 @@ ObjectMgr::~ObjectMgr()
for (PetLevelInfoContainer::iterator i = _petInfoStore.begin(); i != _petInfoStore.end(); ++i)
delete[] i->second;
// free only if loaded
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
delete[] _playerClassInfo[class_].levelInfo;
for (int race = 0; race < MAX_RACES; ++race)
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
delete[] _playerInfo[race][class_].levelInfo;
@@ -3252,87 +3248,6 @@ void ObjectMgr::LoadPlayerInfo()
}
}
// Loading levels data (class only dependent)
sLog->outString("Loading Player Create Level HP/Mana Data...");
{
uint32 oldMSTime = getMSTime();
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT class, level, basehp, basemana FROM player_classlevelstats");
if (!result)
{
sLog->outErrorDb(">> Loaded 0 level health/mana definitions. DB table `game_event_condition` is empty.");
sLog->outString();
exit(1);
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 current_class = fields[0].GetUInt8();
if (current_class >= MAX_CLASSES)
{
sLog->outErrorDb("Wrong class %u in `player_classlevelstats` table, ignoring.", current_class);
continue;
}
uint8 current_level = fields[1].GetUInt8(); // Can't be > than STRONG_MAX_LEVEL (hardcoded level maximum) due to var type
if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
{
sLog->outDetail("Unused (> MaxPlayerLevel in worldserver.conf) level %u in `player_classlevelstats` table, ignoring.", current_level);
++count; // make result loading percent "expected" correct in case disabled detail mode for example.
continue;
}
PlayerClassInfo* pClassInfo = &_playerClassInfo[current_class];
if (!pClassInfo->levelInfo)
pClassInfo->levelInfo = new PlayerClassLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
PlayerClassLevelInfo* pClassLevelInfo = &pClassInfo->levelInfo[current_level-1];
pClassLevelInfo->basehealth = fields[2].GetUInt16();
pClassLevelInfo->basemana = fields[3].GetUInt16();
++count;
}
while (result->NextRow());
// Fill gaps and check integrity
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
{
// skip non existed classes
if (!sChrClassesStore.LookupEntry(class_))
continue;
PlayerClassInfo* pClassInfo = &_playerClassInfo[class_];
// fatal error if no level 1 data
if (!pClassInfo->levelInfo || pClassInfo->levelInfo[0].basehealth == 0)
{
sLog->outErrorDb("Class %i Level 1 does not have health/mana data!", class_);
exit(1);
}
// fill level gaps
for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
if (pClassInfo->levelInfo[level].basehealth == 0)
{
sLog->outErrorDb("Class %i Level %i does not have health/mana data. Using stats data of level %i.", class_, level+1, level);
pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level-1];
}
}
}
sLog->outString(">> Loaded %u level health/mana definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
// Loading levels data (class/race dependent)
sLog->outString("Loading Player Create Level Stats Data...");
{
@@ -3507,17 +3422,25 @@ void ObjectMgr::LoadPlayerInfo()
}
}
void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, PlayerClassLevelInfo* info) const
void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, uint32& baseHP, uint32& baseMana) const
{
if (level < 1 || class_ >= MAX_CLASSES)
return;
PlayerClassInfo const* pInfo = &_playerClassInfo[class_];
if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
*info = pInfo->levelInfo[level-1];
GtOCTBaseHPByClassEntry const* hp = sGtOCTBaseHPByClassStore.LookupEntry((class_-1) * GT_MAX_LEVEL + level-1);
GtOCTBaseMPByClassEntry const* mp = sGtOCTBaseMPByClassStore.LookupEntry((class_-1) * GT_MAX_LEVEL + level-1);
if (!hp || !mp)
{
sLog->outError("Tried to get non-existant Class-Level combination data for base hp/mp. Class %u Level %u", class_, level);
return;
}
baseHP = uint32(hp->ratio);
baseMana = uint32(mp->ratio);
}
void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const
+1 -9
View File
@@ -652,13 +652,7 @@ class ObjectMgr
PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint8 level) const;
PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const
{
if (class_ >= MAX_CLASSES)
return NULL;
return &_playerClassInfo[class_];
}
void GetPlayerClassLevelInfo(uint32 class_, uint8 level, PlayerClassLevelInfo* info) const;
void GetPlayerClassLevelInfo(uint32 class_, uint8 level, uint32& baseHP, uint32& baseMana) const;
PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const
{
@@ -1255,8 +1249,6 @@ class ObjectMgr
// PetLevelInfoContainer[creature_id][level]
PetLevelInfoContainer _petInfoStore; // [creature_id][level]
PlayerClassInfo _playerClassInfo[MAX_CLASSES];
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const;
PlayerInfo _playerInfo[MAX_RACES][MAX_CLASSES];
+1
View File
@@ -1636,6 +1636,7 @@ void WorldSession::SendReforgeResult(bool success)
{
WorldPacket data(SMSG_REFORGE_RESULT, 1);
data.WriteBit(success);
data.FlushBits();
SendPacket(&data);
}