mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-01 10:03:47 +00:00
feat(Core/Creature): Allow 3 ids per spawn point. TESTING (#10169)
* feat(Core/Creature): Allow 3 ids per spawn point. * Move GetRandomId to a function * Update id to id1 * Fixed some errors crashing core and text * Set ids to lowercase for GetRandomId function * Update src/server/database/Database/Implementation/WorldDatabase.cpp Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Co-authored-by: acidmanifesto <joshua.lee.betts@gmail.com> Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
@@ -1310,7 +1310,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
dynamicflags = 0;
|
||||
}
|
||||
|
||||
data.id = GetEntry();
|
||||
data.id1 = GetEntry();
|
||||
data.mapid = mapid;
|
||||
data.phaseMask = phaseMask;
|
||||
data.displayid = displayId;
|
||||
@@ -1357,7 +1357,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
stmt->setUInt32(index++, m_spawnId);
|
||||
stmt->setUInt32(index++, GetEntry());
|
||||
stmt->setUInt32(index++, 0);
|
||||
stmt->setFloat(index++, 100.0f);
|
||||
stmt->setUInt32(index++, 0);
|
||||
stmt->setUInt16(index++, uint16(mapid));
|
||||
stmt->setUInt8(index++, spawnMask);
|
||||
stmt->setUInt32(index++, GetPhaseMask());
|
||||
@@ -1613,9 +1613,7 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad
|
||||
m_spawnId = spawnId;
|
||||
|
||||
// Add to world
|
||||
uint32 entry = data->id;
|
||||
if(data->id2)
|
||||
entry = (roll_chance_f(data->chance_id1)) ? data->id : data->id2;
|
||||
uint32 entry = GetRandomId(data->id1, data->id2, data->id3);
|
||||
|
||||
if (!Create(map->GenerateLowGuid<HighGuid::Unit>(), map, data->phaseMask, entry, 0, data->posX, data->posY, data->posZ, data->orientation, data))
|
||||
return false;
|
||||
@@ -1913,7 +1911,7 @@ void Creature::Respawn(bool force)
|
||||
// Respawn check if spawn has 2 entries
|
||||
if (data->id2)
|
||||
{
|
||||
uint32 entry = (roll_chance_f(data->chance_id1)) ? data->id : data->id2;
|
||||
uint32 entry = GetRandomId(data->id1, data->id2, data->id3);
|
||||
UpdateEntry(entry, data, true); // Select Random Entry
|
||||
m_defaultMovementType = MovementGeneratorType(data->movementType); // Reload Movement Type
|
||||
LoadEquipment(data->equipmentId); // Reload Equipment
|
||||
@@ -3458,3 +3456,33 @@ bool Creature::CanPeriodicallyCallForAssistance() const
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 Creature::GetRandomId(uint32 id1, uint32 id2, uint32 id3)
|
||||
{
|
||||
uint32 id = id1;
|
||||
uint8 ids = 0;
|
||||
|
||||
if (id2)
|
||||
{
|
||||
++ids;
|
||||
if (id3) ++ids;
|
||||
}
|
||||
|
||||
if (ids)
|
||||
{
|
||||
uint8 idNumber = urand(0, ids);
|
||||
switch (idNumber)
|
||||
{
|
||||
case 0:
|
||||
id = id1;
|
||||
break;
|
||||
case 1:
|
||||
id = id2;
|
||||
break;
|
||||
case 2:
|
||||
id = id3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user