Skip to content

Commit

Permalink
SpawnGroup: Reorder creature_spawn_entry code to stop double reroll f…
Browse files Browse the repository at this point in the history
…or creature
  • Loading branch information
killerwife committed Nov 8, 2024
1 parent db15240 commit b8f98ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1604,9 +1604,6 @@ bool Creature::CreateFromProto(uint32 dbGuid, uint32 guidlow, CreatureInfo const

Object::_Create(dbGuid, guidlow, newEntry, cinfo->GetHighGuid());

if (uint32 entry = sObjectMgr.GetRandomCreatureEntry(GetDbGuid()))
newEntry = entry;

return UpdateEntry(newEntry, data, eventData, false);
}

Expand All @@ -1629,10 +1626,6 @@ bool Creature::LoadFromDB(uint32 dbGuid, Map* map, uint32 newGuid, uint32 forced

uint32 entry = forcedEntry ? forcedEntry : data->id;

// get data for dual spawn instances
if (entry == 0)
entry = GetCreatureConditionalSpawnEntry(dbGuid, map);

SpawnGroupEntry* groupEntry = map->GetMapDataContainer().GetSpawnGroupByGuid(dbGuid, TYPEID_UNIT); // use dynguid by default \o/
CreatureGroup* group = nullptr;
if (groupEntry)
Expand All @@ -1642,6 +1635,13 @@ bool Creature::LoadFromDB(uint32 dbGuid, Map* map, uint32 newGuid, uint32 forced
entry = group->GetGuidEntry(dbGuid);
}

// get data for dual spawn instances - spawn group precedes it because
if (entry == 0)
entry = GetCreatureConditionalSpawnEntry(dbGuid, map);

if (entry == 0)
entry = sObjectMgr.GetRandomCreatureEntry(GetDbGuid());

GameEventCreatureData const* eventData = sGameEventMgr.GetCreatureUpdateDataForActiveEvent(dbGuid);
if (!entry && eventData)
entry = eventData->entry_id;
Expand Down
6 changes: 3 additions & 3 deletions src/game/Entities/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,9 @@ bool GameObject::LoadFromDB(uint32 dbGuid, Map* map, uint32 newGuid, uint32 forc
entry = group->GetGuidEntry(dbGuid);
}

if (uint32 randomEntry = sObjectMgr.GetRandomGameObjectEntry(dbGuid))
entry = randomEntry;

bool dynguid = false;
if (map->IsDynguidForced())
dynguid = true;
Expand All @@ -919,9 +922,6 @@ bool GameObject::LoadFromDB(uint32 dbGuid, Map* map, uint32 newGuid, uint32 forc
if (dynguid || newGuid == 0)
newGuid = map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT);

if (uint32 randomEntry = sObjectMgr.GetRandomGameObjectEntry(dbGuid))
entry = randomEntry;

if (!Create(dbGuid, newGuid, entry, map, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, GO_STATE_READY))
return false;

Expand Down

0 comments on commit b8f98ba

Please sign in to comment.