diff options
author | Meji <alvaro.megias@outlook.com> | 2024-03-30 20:21:28 +0100 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2024-05-28 16:31:42 +0200 |
commit | 382eb5063fc63871a41bbe7b8c81db30ad3d741e (patch) | |
tree | 8ecc2690705b34dd77e3483114610c2cc65aa386 /src/server/game/Globals/ObjectMgr.cpp | |
parent | 5e1f21a0dd75c6cc56ca171360855ed65a623c44 (diff) |
Core/Creatures: Changed the spawn health field in creature table to a percentage (#29801)
(cherry picked from commit def601b4ff82ec8a90af60408a87cac92fdf070d)
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 4f362344856..cbe210594f8 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2156,9 +2156,9 @@ void ObjectMgr::LoadCreatures() // 0 1 2 3 4 5 6 7 8 9 10 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, position_x, position_y, position_z, orientation, modelid, equipment_id, spawntimesecs, wander_distance, " - // 11 12 13 14 15 16 17 18 19 20 21 - "currentwaypoint, curhealth, curmana, MovementType, spawnDifficulties, eventEntry, poolSpawnId, creature.npcflag, creature.unit_flags, creature.unit_flags2, creature.unit_flags3, " - // 22 23 24 25 26 27 + // 11 12 13 14 15 16 17 18 19 20 + "currentwaypoint, curHealthPct, MovementType, spawnDifficulties, eventEntry, poolSpawnId, creature.npcflag, creature.unit_flags, creature.unit_flags2, creature.unit_flags3, " + // 21 22 23 24 25 26 "creature.phaseUseFlags, creature.phaseid, creature.phasegroup, creature.terrainSwapMap, creature.ScriptName, creature.StringId " "FROM creature " "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid " @@ -2203,27 +2203,26 @@ void ObjectMgr::LoadCreatures() data.equipmentId = fields[8].GetInt8(); data.spawntimesecs = fields[9].GetUInt32(); data.wander_distance = fields[10].GetFloat(); - data.currentwaypoint= fields[11].GetUInt32(); - data.curhealth = fields[12].GetUInt32(); - data.curmana = fields[13].GetUInt32(); - data.movementType = fields[14].GetUInt8(); - data.spawnDifficulties = ParseSpawnDifficulties(fields[15].GetStringView(), "creature", guid, data.mapId, spawnMasks[data.mapId]); - int16 gameEvent = fields[16].GetInt8(); - data.poolId = fields[17].GetUInt32(); + data.currentwaypoint = fields[11].GetUInt32(); + data.curHealthPct = fields[12].GetUInt32(); + data.movementType = fields[13].GetUInt8(); + data.spawnDifficulties = ParseSpawnDifficulties(fields[14].GetStringView(), "creature", guid, data.mapId, spawnMasks[data.mapId]); + int16 gameEvent = fields[15].GetInt8(); + data.poolId = fields[16].GetUInt32(); + if (!fields[17].IsNull()) + data.npcflag = fields[17].GetUInt64(); if (!fields[18].IsNull()) - data.npcflag = fields[18].GetUInt64(); + data.unit_flags = fields[18].GetUInt32(); if (!fields[19].IsNull()) - data.unit_flags = fields[19].GetUInt32(); + data.unit_flags2 = fields[19].GetUInt32(); if (!fields[20].IsNull()) - data.unit_flags2 = fields[20].GetUInt32(); - if (!fields[21].IsNull()) - data.unit_flags3 = fields[21].GetUInt32(); - data.phaseUseFlags = fields[22].GetUInt8(); - data.phaseId = fields[23].GetUInt32(); - data.phaseGroup = fields[24].GetUInt32(); - data.terrainSwapMap = fields[25].GetInt32(); - data.scriptId = GetScriptId(fields[26].GetString()); - data.StringId = fields[27].GetString(); + data.unit_flags3 = fields[20].GetUInt32(); + data.phaseUseFlags = fields[21].GetUInt8(); + data.phaseId = fields[22].GetUInt32(); + data.phaseGroup = fields[23].GetUInt32(); + data.terrainSwapMap = fields[24].GetInt32(); + data.scriptId = GetScriptId(fields[25].GetString()); + data.StringId = fields[26].GetString(); data.spawnGroupData = IsTransportMap(data.mapId) ? GetLegacySpawnGroup() : GetDefaultSpawnGroup(); // transport spawns default to compatibility group MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapId); @@ -2385,6 +2384,13 @@ void ObjectMgr::LoadCreatures() } } + uint32 healthPct = std::clamp<uint32>(data.curHealthPct, 1, 100); + if (data.curHealthPct != healthPct) + { + TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with invalid `curHealthPct` {}, set to {}.", guid, data.id, data.curHealthPct, healthPct); + data.curHealthPct = healthPct; + } + if (sWorld->getBoolConfig(CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA)) { uint32 zoneId = 0; |