feat(Core/Creature): Dual id Spawning WIP (#10115)

* feat(Core/Creature): Multi id Spawning WIP

* Update Creature.cpp

* Update PR

* Add Sql

* Update rev_1641837958335217980.sql

* Update src/server/game/Globals/ObjectMgr.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update src/server/game/Globals/ObjectMgr.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update rev_1641837958335217980.sql

* Update cs_npc.cpp

* Create changes_1641842959398297300.md

* Fixed issue added with random model PR

* Update GameEventMgr.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
Malcrom
2022-01-10 22:09:14 -04:00
committed by GitHub
parent e0abe515ef
commit 2fd8b00d7b
9 changed files with 113 additions and 58 deletions

View File

@@ -1486,7 +1486,7 @@ void ObjectMgr::LoadCreatureMovementOverrides()
"COALESCE(cmo.InteractionPauseTimer, ctm.InteractionPauseTimer) "
"FROM creature_movement_override AS cmo "
"LEFT JOIN creature AS c ON c.guid = cmo.SpawnId "
"LEFT JOIN creature_template_movement AS ctm ON ctm.CreatureId = c.id");
"LEFT JOIN creature_template_movement AS ctm ON ctm.CreatureId = c.creature_id1");
if (!result)
{
LOG_INFO("server.loading", ">> Loaded 0 creature movement overrides. DB table `creature_movement_override` is empty!");
@@ -1984,11 +1984,11 @@ void ObjectMgr::LoadCreatures()
{
uint32 oldMSTime = getMSTime();
// 0 1 2 3 4 5 6 7 8 9 10
QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
// 11 12 13 14 15 16 17 18 19 20 21
// 0 1 2 3 4 5 6 7 8 9 10 11
QueryResult result = WorldDatabase.Query("SELECT creature.guid, creature_id1, creature_id2, chance_id1, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
// 12 13 14 15 16 17 18 19 20 21 22
"currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, "
// 22
// 23
"creature.ScriptName "
"FROM creature "
"LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
@@ -2016,37 +2016,56 @@ void ObjectMgr::LoadCreatures()
Field* fields = result->Fetch();
ObjectGuid::LowType spawnId = fields[0].GetUInt32();
uint32 entry = fields[1].GetUInt32();
uint32 id = fields[1].GetUInt32();
uint32 id2 = fields[2].GetUInt32();
uint32 chance = fields[3].GetUInt32();
CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
CreatureTemplate const* cInfo = GetCreatureTemplate(id);
if (!cInfo)
{
LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: %u) with non existing creature entry %u, skipped.", spawnId, entry);
LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: %u) with non existing creature entry %u in creature_id1 field, skipped.", spawnId, id);
continue;
}
CreatureTemplate const* cInfo2 = GetCreatureTemplate(id2);
if (!cInfo2 && id2)
{
LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: %u) with non existing creature entry %u in creature_id2 field, skipped.", spawnId, id2);
continue;
}
if (!chance || chance > 100)
{
LOG_ERROR("sql.sql", "Table `creature` chance_id1 (Value: %u) must be greater than 0 and less than or equal to 100, skipped.", chance);
continue;
}
if (chance == 100 && id2)
{
LOG_ERROR("sql.sql", "Table `creature` has spawnid = %u chance = 100 even though creature_id2 has an entry. changed to 50.", spawnId);
chance = 50;
}
CreatureData& data = _creatureDataStore[spawnId];
data.id = entry;
data.mapid = fields[2].GetUInt16();
data.equipmentId = fields[3].GetInt8();
data.posX = fields[4].GetFloat();
data.posY = fields[5].GetFloat();
data.posZ = fields[6].GetFloat();
data.orientation = fields[7].GetFloat();
data.spawntimesecs = fields[8].GetUInt32();
data.wander_distance = fields[9].GetFloat();
data.currentwaypoint = fields[10].GetUInt32();
data.curhealth = fields[11].GetUInt32();
data.curmana = fields[12].GetUInt32();
data.movementType = fields[13].GetUInt8();
data.spawnMask = fields[14].GetUInt8();
data.phaseMask = fields[15].GetUInt32();
int16 gameEvent = fields[16].GetInt8();
uint32 PoolId = fields[17].GetUInt32();
data.npcflag = fields[18].GetUInt32();
data.unit_flags = fields[19].GetUInt32();
data.dynamicflags = fields[20].GetUInt32();
data.ScriptId = GetScriptId(fields[21].GetString());
data.id = id;
data.id2 = id2;
data.chance_id1 = chance;
data.mapid = fields[4].GetUInt16();
data.equipmentId = fields[5].GetInt8();
data.posX = fields[6].GetFloat();
data.posY = fields[7].GetFloat();
data.posZ = fields[8].GetFloat();
data.orientation = fields[9].GetFloat();
data.spawntimesecs = fields[10].GetUInt32();
data.wander_distance = fields[11].GetFloat();
data.currentwaypoint = fields[12].GetUInt32();
data.curhealth = fields[13].GetUInt32();
data.curmana = fields[14].GetUInt32();
data.movementType = fields[15].GetUInt8();
data.spawnMask = fields[16].GetUInt8();
data.phaseMask = fields[17].GetUInt32();
int16 gameEvent = fields[18].GetInt8();
uint32 PoolId = fields[19].GetUInt32();
data.npcflag = fields[20].GetUInt32();
data.unit_flags = fields[21].GetUInt32();
data.dynamicflags = fields[22].GetUInt32();
data.ScriptId = GetScriptId(fields[23].GetString());
if (!data.ScriptId)
data.ScriptId = cInfo->ScriptID;