Skip to content

Commit

Permalink
Core/Creatures: Load expansion data from HealthScalingExpansion col…
Browse files Browse the repository at this point in the history
…umn instead of the now-deprecated `exp` one
  • Loading branch information
Kinzcool committed Sep 6, 2016
1 parent 050d5d8 commit 35dcb45
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 76 deletions.
1 change: 1 addition & 0 deletions sql/updates/world/6.x/2016_09_06_05_world_.sql
@@ -0,0 +1 @@
ALTER TABLE `creature_template` DROP COLUMN `exp`;
Expand Up @@ -76,7 +76,7 @@ void WorldDatabaseConnection::DoPrepareStatements()
PrepareStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID, "SELECT id FROM waypoint_scripts WHERE guid = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_DEL_CREATURE, "DELETE FROM creature WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(WORLD_SEL_COMMANDS, "SELECT name, permission, help FROM command", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, femaleName, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, HealthScalingExpansion, RequiredExpansion, VignetteID, faction, npcflag, speed_walk, speed_run, scale, rank, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_class, trainer_race, type, type_flags, type_flags2, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, femaleName, subname, IconName, gossip_menu_id, minlevel, maxlevel, HealthScalingExpansion, RequiredExpansion, VignetteID, faction, npcflag, speed_walk, speed_run, scale, rank, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_class, trainer_race, type, type_flags, type_flags2, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_", CONNECTION_SYNCH);
Expand Down
5 changes: 2 additions & 3 deletions src/server/game/Entities/Creature/Creature.h
Expand Up @@ -91,7 +91,6 @@ struct TC_GAME_API CreatureTemplate
uint32 GossipMenuId;
int16 minlevel;
int16 maxlevel;
int32 expansion;
int32 HealthScalingExpansion;
uint32 RequiredExpansion;
uint32 VignetteID; /// @todo Read Vignette.db2
Expand Down Expand Up @@ -229,7 +228,7 @@ struct TC_GAME_API CreatureBaseStats

uint32 GenerateHealth(CreatureTemplate const* info) const
{
return uint32(ceil(BaseHealth[info->expansion] * info->ModHealth * info->ModHealthExtra));
return uint32(ceil(BaseHealth[info->HealthScalingExpansion] * info->ModHealth * info->ModHealthExtra));
}

uint32 GenerateMana(CreatureTemplate const* info) const
Expand All @@ -248,7 +247,7 @@ struct TC_GAME_API CreatureBaseStats

float GenerateBaseDamage(CreatureTemplate const* info) const
{
return BaseDamage[info->expansion];
return BaseDamage[info->HealthScalingExpansion];
}

static CreatureBaseStats const* GetBaseStats(uint8 level, uint8 unitClass);
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Pet/Pet.cpp
Expand Up @@ -872,7 +872,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
{
// remove elite bonuses included in DB values
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(petlevel, cinfo->unit_class);
SetCreateHealth(stats->BaseHealth[cinfo->expansion]);
SetCreateHealth(stats->BaseHealth[cinfo->HealthScalingExpansion]);
SetCreateMana(stats->BaseMana);

SetCreateStat(STAT_STRENGTH, 22);
Expand Down
140 changes: 70 additions & 70 deletions src/server/game/Globals/ObjectMgr.cpp
Expand Up @@ -415,19 +415,19 @@ void ObjectMgr::LoadCreatureTemplates()

// 0 1 2 3 4 5 6 7 8
QueryResult result = WorldDatabase.Query("SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, "
// 9 10 11 12 13 14 15 16 17 18 19 20
"modelid4, name, femaleName, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, HealthScalingExpansion, RequiredExpansion, VignetteID, "
// 21 22 23 24 25 26 27 28 29 30 31
// 9 10 11 12 13 14 15 16 17 18 19
"modelid4, name, femaleName, subname, IconName, gossip_menu_id, minlevel, maxlevel, HealthScalingExpansion, RequiredExpansion, VignetteID, "
// 20 21 22 23 24 25 26 27 28 29 30
"faction, npcflag, speed_walk, speed_run, scale, rank, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, "
// 32 33 34 35 36 37 38 39 40
// 31 32 33 34 35 36 37 38 39
"unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_class, trainer_race, type, "
// 41 42 43 44 45 46 47 48 49 50 51
// 40 41 42 43 44 45 46 47 48 49 50
"type_flags, type_flags2, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, "
// 52 53 54 55 56 57 58 59 60 61 62 63 64
// 51 52 53 54 55 56 57 58 59 60 61 62 63
"spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, VehicleId, mingold, maxgold, AIName, MovementType, "
// 65 66 67 68 69 70 71 72 73
// 64 65 66 67 68 69 70 71 72
"InhabitType, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, ArmorModifier, DamageModifier, ExperienceModifier, "
// 74 75 76 77 78 79
// 73 74 75 76 77 78
"RacialLeader, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template");

if (!result)
Expand Down Expand Up @@ -478,62 +478,61 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
creatureTemplate.GossipMenuId = fields[14].GetUInt32();
creatureTemplate.minlevel = fields[15].GetInt16();
creatureTemplate.maxlevel = fields[16].GetInt16();
creatureTemplate.expansion = fields[17].GetInt16();
creatureTemplate.HealthScalingExpansion = fields[18].GetInt32();
creatureTemplate.RequiredExpansion = fields[19].GetUInt32();
creatureTemplate.VignetteID = fields[20].GetUInt32();
creatureTemplate.faction = fields[21].GetUInt16();
creatureTemplate.npcflag = fields[22].GetUInt64();
creatureTemplate.speed_walk = fields[23].GetFloat();
creatureTemplate.speed_run = fields[24].GetFloat();
creatureTemplate.scale = fields[25].GetFloat();
creatureTemplate.rank = uint32(fields[26].GetUInt8());
creatureTemplate.dmgschool = uint32(fields[27].GetInt8());
creatureTemplate.BaseAttackTime = fields[28].GetUInt32();
creatureTemplate.RangeAttackTime = fields[29].GetUInt32();
creatureTemplate.BaseVariance = fields[30].GetFloat();
creatureTemplate.RangeVariance = fields[31].GetFloat();
creatureTemplate.unit_class = uint32(fields[32].GetUInt8());
creatureTemplate.unit_flags = fields[33].GetUInt32();
creatureTemplate.unit_flags2 = fields[34].GetUInt32();
creatureTemplate.dynamicflags = fields[35].GetUInt32();
creatureTemplate.family = uint32(fields[36].GetUInt8());
creatureTemplate.trainer_type = uint32(fields[37].GetUInt8());
creatureTemplate.trainer_class = uint32(fields[38].GetUInt8());
creatureTemplate.trainer_race = uint32(fields[39].GetUInt8());
creatureTemplate.type = uint32(fields[40].GetUInt8());
creatureTemplate.type_flags = fields[41].GetUInt32();
creatureTemplate.type_flags2 = fields[42].GetUInt32();
creatureTemplate.lootid = fields[43].GetUInt32();
creatureTemplate.pickpocketLootId = fields[44].GetUInt32();
creatureTemplate.SkinLootId = fields[45].GetUInt32();
creatureTemplate.HealthScalingExpansion = fields[17].GetInt32();
creatureTemplate.RequiredExpansion = fields[18].GetUInt32();
creatureTemplate.VignetteID = fields[19].GetUInt32();
creatureTemplate.faction = fields[20].GetUInt16();
creatureTemplate.npcflag = fields[21].GetUInt64();
creatureTemplate.speed_walk = fields[22].GetFloat();
creatureTemplate.speed_run = fields[23].GetFloat();
creatureTemplate.scale = fields[24].GetFloat();
creatureTemplate.rank = uint32(fields[25].GetUInt8());
creatureTemplate.dmgschool = uint32(fields[26].GetInt8());
creatureTemplate.BaseAttackTime = fields[27].GetUInt32();
creatureTemplate.RangeAttackTime = fields[28].GetUInt32();
creatureTemplate.BaseVariance = fields[29].GetFloat();
creatureTemplate.RangeVariance = fields[30].GetFloat();
creatureTemplate.unit_class = uint32(fields[31].GetUInt8());
creatureTemplate.unit_flags = fields[32].GetUInt32();
creatureTemplate.unit_flags2 = fields[33].GetUInt32();
creatureTemplate.dynamicflags = fields[34].GetUInt32();
creatureTemplate.family = uint32(fields[35].GetUInt8());
creatureTemplate.trainer_type = uint32(fields[36].GetUInt8());
creatureTemplate.trainer_class = uint32(fields[37].GetUInt8());
creatureTemplate.trainer_race = uint32(fields[38].GetUInt8());
creatureTemplate.type = uint32(fields[39].GetUInt8());
creatureTemplate.type_flags = fields[40].GetUInt32();
creatureTemplate.type_flags2 = fields[41].GetUInt32();
creatureTemplate.lootid = fields[42].GetUInt32();
creatureTemplate.pickpocketLootId = fields[43].GetUInt32();
creatureTemplate.SkinLootId = fields[44].GetUInt32();

for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
creatureTemplate.resistance[i] = fields[46 + i - 1].GetInt16();
creatureTemplate.resistance[i] = fields[45 + i - 1].GetInt16();

for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
creatureTemplate.spells[i] = fields[52 + i].GetUInt32();

creatureTemplate.VehicleId = fields[60].GetUInt32();
creatureTemplate.mingold = fields[61].GetUInt32();
creatureTemplate.maxgold = fields[62].GetUInt32();
creatureTemplate.AIName = fields[63].GetString();
creatureTemplate.MovementType = uint32(fields[64].GetUInt8());
creatureTemplate.InhabitType = uint32(fields[65].GetUInt8());
creatureTemplate.HoverHeight = fields[66].GetFloat();
creatureTemplate.ModHealth = fields[67].GetFloat();
creatureTemplate.ModHealthExtra = fields[68].GetFloat();
creatureTemplate.ModMana = fields[69].GetFloat();
creatureTemplate.ModManaExtra = fields[70].GetFloat();
creatureTemplate.ModArmor = fields[71].GetFloat();
creatureTemplate.ModDamage = fields[72].GetFloat();
creatureTemplate.ModExperience = fields[73].GetFloat();
creatureTemplate.RacialLeader = fields[74].GetBool();
creatureTemplate.movementId = fields[75].GetUInt32();
creatureTemplate.RegenHealth = fields[76].GetBool();
creatureTemplate.MechanicImmuneMask = fields[77].GetUInt32();
creatureTemplate.flags_extra = fields[78].GetUInt32();
creatureTemplate.ScriptID = GetScriptId(fields[79].GetString());
creatureTemplate.spells[i] = fields[51 + i].GetUInt32();

creatureTemplate.VehicleId = fields[59].GetUInt32();
creatureTemplate.mingold = fields[60].GetUInt32();
creatureTemplate.maxgold = fields[61].GetUInt32();
creatureTemplate.AIName = fields[62].GetString();
creatureTemplate.MovementType = uint32(fields[63].GetUInt8());
creatureTemplate.InhabitType = uint32(fields[64].GetUInt8());
creatureTemplate.HoverHeight = fields[65].GetFloat();
creatureTemplate.ModHealth = fields[66].GetFloat();
creatureTemplate.ModHealthExtra = fields[67].GetFloat();
creatureTemplate.ModMana = fields[68].GetFloat();
creatureTemplate.ModManaExtra = fields[69].GetFloat();
creatureTemplate.ModArmor = fields[70].GetFloat();
creatureTemplate.ModDamage = fields[71].GetFloat();
creatureTemplate.ModExperience = fields[72].GetFloat();
creatureTemplate.RacialLeader = fields[73].GetBool();
creatureTemplate.movementId = fields[74].GetUInt32();
creatureTemplate.RegenHealth = fields[75].GetBool();
creatureTemplate.MechanicImmuneMask = fields[76].GetUInt32();
creatureTemplate.flags_extra = fields[77].GetUInt32();
creatureTemplate.ScriptID = GetScriptId(fields[78].GetString());
}

void ObjectMgr::LoadCreatureTemplateAddons()
Expand Down Expand Up @@ -687,10 +686,10 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
if (!ok2)
continue;

if (cInfo->expansion > difficultyInfo->expansion)
if (cInfo->HealthScalingExpansion > difficultyInfo->HealthScalingExpansion)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u, exp %u) has different `exp` in difficulty %u mode (Entry: %u, exp %u).",
cInfo->Entry, cInfo->expansion, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->expansion);
TC_LOG_ERROR("sql.sql", "Creature (ID: %u, Expansion: %u) has different `HealthScalingExpansion` in difficulty %u mode (ID: %u, Expansion %u).",
cInfo->Entry, cInfo->HealthScalingExpansion, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->HealthScalingExpansion);
}

if (cInfo->faction != difficultyInfo->faction)
Expand Down Expand Up @@ -965,10 +964,10 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
const_cast<CreatureTemplate*>(cInfo)->scale = 1.0f;
}

if (cInfo->expansion > (MAX_EXPANSIONS - 1))
if (cInfo->HealthScalingExpansion > (MAX_EXPANSIONS - 1))
{
TC_LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: %u) with `exp` %u. Ignored and set to 0.", cInfo->Entry, cInfo->expansion);
const_cast<CreatureTemplate*>(cInfo)->expansion = 0;
TC_LOG_ERROR("sql.sql", "Table `creature_template` lists creature (ID: %u) with invalid `HealthScalingExpansion` %u. Ignored and set to 0.", cInfo->Entry, cInfo->HealthScalingExpansion);
const_cast<CreatureTemplate*>(cInfo)->HealthScalingExpansion = 0;
}

if ((cInfo->HealthScalingExpansion > (MAX_EXPANSIONS - 1)) && cInfo->HealthScalingExpansion != EXPANSION_LEVEL_CURRENT)
Expand All @@ -989,13 +988,14 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
const_cast<CreatureTemplate*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED;
}

// -1 is used in the client for auto-updating the levels
// having their expansion set to it to the latest one
if (cInfo->expansion == -1)
// -1, as expansion, is used in CreatureDifficulty.db2 for
// auto-updating the levels of creatures having their expansion
// set to that value to the current expansion's max leveling level
if (cInfo->HealthScalingExpansion == EXPANSION_LEVEL_CURRENT)
{
const_cast<CreatureTemplate*>(cInfo)->minlevel = (MAX_LEVEL + cInfo->minlevel);
const_cast<CreatureTemplate*>(cInfo)->maxlevel = (MAX_LEVEL + cInfo->maxlevel);
const_cast<CreatureTemplate*>(cInfo)->expansion = CURRENT_EXPANSION;
const_cast<CreatureTemplate*>(cInfo)->HealthScalingExpansion = CURRENT_EXPANSION;
}

if (cInfo->minlevel < 1 || cInfo->minlevel > STRONG_MAX_LEVEL)
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Miscellaneous/Formulas.h
Expand Up @@ -181,7 +181,7 @@ namespace Trinity
if (gain && creature)
{
// Players get only 10% xp for killing creatures of lower expansion levels than himself
if ((uint32(creature->GetCreatureTemplate()->expansion) < GetExpansionForLevel(player->getLevel())))
if ((uint32(creature->GetCreatureTemplate()->HealthScalingExpansion) < GetExpansionForLevel(player->getLevel())))
gain = uint32(round(gain / 10.0f));

if (creature->isElite())
Expand Down

0 comments on commit 35dcb45

Please sign in to comment.