-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SpawnGroup: Attempt to remedy dungeon spawn group creature entry gen
- Loading branch information
1 parent
877d607
commit b1bec88
Showing
1 changed file
with
72 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,10 +240,9 @@ void SpawnGroup::Spawn(bool force) | |
|
||
std::shuffle(eligibleGuids.begin(), eligibleGuids.end(), *GetRandomGenerator()); | ||
|
||
for (auto itr = eligibleGuids.begin(); itr != eligibleGuids.end() && !eligibleGuids.empty() && m_objects.size() < m_entry.MaxCount; ++itr) | ||
for (auto itr = eligibleGuids.begin(); itr != eligibleGuids.end() && !eligibleGuids.empty() && m_objects.size() < m_entry.MaxCount;) | ||
{ | ||
uint32 dbGuid = (*itr)->DbGuid; | ||
uint32 entry = 0; | ||
if (m_entry.HasChancedSpawns) | ||
{ | ||
if ((*itr)->Chance) | ||
|
@@ -259,44 +258,89 @@ void SpawnGroup::Spawn(bool force) | |
spawn = spawnItr->second; | ||
|
||
if (!spawn) | ||
{ | ||
itr = eligibleGuids.erase(itr); | ||
continue; | ||
} | ||
} | ||
else // filling redundant entries when a group has chanced spawns for optimization so we can stop at start | ||
m_chosenSpawns[dbGuid] = true; | ||
|
||
++itr; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
killerwife
Author
Contributor
|
||
} | ||
} | ||
|
||
// creatures pick random entry on first spawn in dungeons - else always pick random entry | ||
if (GetObjectTypeId() == TYPEID_UNIT) | ||
eligibleGuids.resize(m_entry.MaxCount - m_objects.size()); // now we have final count for processing | ||
|
||
auto pickCreatureEntry = [&](const SpawnGroupDbGuids* guids) -> uint32 | ||
{ | ||
uint32 entry; | ||
// some group members can have static entry, or selfcontained random entry | ||
if (guids->RandomEntry) | ||
entry = sObjectMgr.GetRandomCreatureEntry(guids->DbGuid); | ||
else if (guids->OwnEntry) | ||
entry = guids->OwnEntry; | ||
else | ||
entry = GetEligibleEntry(validEntries, minEntries); | ||
|
||
return entry; | ||
}; | ||
|
||
auto pickGoEntry = [&](const SpawnGroupDbGuids* guids) -> uint32 | ||
{ | ||
uint32 entry; | ||
// some group members can have static entry, or selfcontained random entry | ||
if (guids->RandomEntry) | ||
entry = sObjectMgr.GetRandomGameObjectEntry(guids->DbGuid); | ||
else if (guids->OwnEntry) | ||
entry = guids->OwnEntry; | ||
else | ||
entry = GetEligibleEntry(validEntries, minEntries); | ||
|
||
return entry; | ||
}; | ||
|
||
// pick static and random entry first in dungeons so spawn group logic can decide after | ||
if (m_map.IsDungeon() && GetObjectTypeId() == TYPEID_UNIT) | ||
{ | ||
for (auto data : eligibleGuids) | ||
{ | ||
if (m_map.IsDungeon()) | ||
if (data->RandomEntry || data->OwnEntry) | ||
{ | ||
// only held in memory - implement saving to db if it becomes a major issue | ||
if (m_chosenEntries.find(dbGuid) == m_chosenEntries.end()) | ||
{ | ||
// some group members can have static entry, or selfcontained random entry | ||
if ((*itr)->RandomEntry) | ||
entry = sObjectMgr.GetRandomCreatureEntry(dbGuid); | ||
else if ((*itr)->OwnEntry) | ||
entry = (*itr)->OwnEntry; | ||
else | ||
entry = GetEligibleEntry(validEntries, minEntries); | ||
m_chosenEntries[dbGuid] = entry; | ||
} | ||
else | ||
entry = m_chosenEntries[dbGuid]; | ||
uint32 entry = pickCreatureEntry(data); | ||
m_chosenEntries[data->DbGuid] = entry; | ||
if (entry && validEntries[entry]) | ||
--validEntries[entry]; | ||
} | ||
else | ||
entry = GetEligibleEntry(validEntries, minEntries); | ||
} | ||
else // GOs always pick random entry | ||
for (auto data : eligibleGuids) | ||
{ | ||
if ((*itr)->RandomEntry) | ||
entry = sObjectMgr.GetRandomGameObjectEntry(dbGuid); | ||
else if ((*itr)->OwnEntry) | ||
entry = (*itr)->OwnEntry; | ||
else | ||
entry = GetEligibleEntry(validEntries, minEntries); | ||
if (!data->RandomEntry && !data->OwnEntry) | ||
{ | ||
uint32 entry = pickCreatureEntry(data); | ||
m_chosenEntries[data->DbGuid] = entry; | ||
if (entry && validEntries[entry]) | ||
--validEntries[entry]; | ||
} | ||
} | ||
} | ||
|
||
for (auto itr = eligibleGuids.begin(); itr != eligibleGuids.end(); ++itr) | ||
{ | ||
uint32 dbGuid = (*itr)->DbGuid; | ||
uint32 entry = 0; | ||
// creatures pick random entry on first spawn in dungeons - else always pick random entry | ||
if (m_map.IsDungeon() && GetObjectTypeId() == TYPEID_UNIT) | ||
entry = m_chosenEntries[dbGuid]; // only held in memory - implement saving to db if it becomes a major issue | ||
else | ||
{ | ||
if (GetObjectTypeId() == TYPEID_UNIT) | ||
entry = pickCreatureEntry(*itr); | ||
else // GOs always pick random entry | ||
entry = pickGoEntry(*itr); | ||
if (entry && validEntries[entry]) | ||
--validEntries[entry]; | ||
} | ||
|
||
float x, y; | ||
if (GetObjectTypeId() == TYPEID_UNIT) | ||
|
@@ -319,8 +363,6 @@ void SpawnGroup::Spawn(bool force) | |
else | ||
WorldObject::SpawnGameObject(dbGuid, &m_map, entry); | ||
} | ||
if (entry && validEntries[entry]) | ||
--validEntries[entry]; | ||
} | ||
} | ||
|
||
|
is this
++itr;
maybe one scope too deep down?