Core/Maps: implement new flags for instance spawn groups to allow to restrict spawn groups to horde or alliance only
*use the new flags to restrict the Scarlet Monastery Alliance spawns to alliance players only
This commit is contained in:
1 parent
4a28a9d700
commit
4ff5b6189d
5 files changed
+41
-33
No files matched your search
@@ -242,49 +242,35 @@ void InstanceScript::UpdateSpawnGroups()
|
||||
{
|
||||
if (!_instanceSpawnGroups)
|
||||
return;
|
||||
enum states : uint8
|
||||
{
|
||||
BLOCK = 0x0,
|
||||
SPAWN = 0x1,
|
||||
FORCEBLOCK = 0x2,
|
||||
FORCEDESPAWN = 0x4
|
||||
};
|
||||
|
||||
std::unordered_map<uint32, uint8> newStates;
|
||||
enum states { BLOCK, SPAWN, FORCEBLOCK };
|
||||
std::unordered_map<uint32, states> newStates;
|
||||
for (auto it = _instanceSpawnGroups->begin(), end = _instanceSpawnGroups->end(); it != end; ++it)
|
||||
{
|
||||
InstanceSpawnGroupInfo const& info = *it;
|
||||
uint8& curValue = newStates[info.SpawnGroupId]; // makes sure there's a BLOCK value in the map
|
||||
states& curValue = newStates[info.SpawnGroupId]; // makes sure there's a BLOCK value in the map
|
||||
if (curValue == FORCEBLOCK) // nothing will change this
|
||||
continue;
|
||||
if (!((1 << GetBossState(info.BossStateId)) & info.BossStates))
|
||||
if (info.BossStates && !((1 << GetBossState(info.BossStateId)) & info.BossStates)) // allow boss state 0 to always bypass this check
|
||||
continue;
|
||||
if (instance->GetTeamIdInInstance() == TEAM_ALLIANCE && (info.Flags & InstanceSpawnGroupInfo::FLAG_HORDE_ONLY)
|
||||
|| instance->GetTeamIdInInstance() == TEAM_HORDE && (info.Flags & InstanceSpawnGroupInfo::FLAG_ALLIANCE_ONLY))
|
||||
continue;
|
||||
if (info.Flags & InstanceSpawnGroupInfo::FLAG_BLOCK_SPAWN)
|
||||
curValue |= FORCEBLOCK;
|
||||
if (info.Flags & InstanceSpawnGroupInfo::FLAG_ACTIVATE_SPAWN)
|
||||
curValue |= SPAWN;
|
||||
if (info.Flags & InstanceSpawnGroupInfo::FLAG_FORCE_DESPAWN)
|
||||
curValue |= FORCEDESPAWN;
|
||||
curValue = FORCEBLOCK;
|
||||
else if (info.Flags & InstanceSpawnGroupInfo::FLAG_ACTIVATE_SPAWN)
|
||||
curValue = SPAWN;
|
||||
}
|
||||
for (auto const& pair : newStates)
|
||||
{
|
||||
uint32 const groupId = pair.first;
|
||||
uint8 state = pair.second;
|
||||
// Spawn group is already active, skip
|
||||
if (instance->IsSpawnGroupActive(groupId) == (state & SPAWN))
|
||||
continue;
|
||||
|
||||
// Spawn group shall be spawned, spawn it
|
||||
if (state & SPAWN)
|
||||
bool const doSpawn = (pair.second == SPAWN);
|
||||
if (instance->IsSpawnGroupActive(groupId) == doSpawn)
|
||||
continue; // nothing to do here
|
||||
// if we should spawn group, then spawn it...
|
||||
if (doSpawn)
|
||||
instance->SpawnGroupSpawn(groupId);
|
||||
|
||||
// Spawn group shall be disabled, disable it
|
||||
if (state & FORCEBLOCK)
|
||||
else // otherwise, set it as inactive so it no longer respawns (but don't despawn it)
|
||||
instance->SetSpawnGroupInactive(groupId);
|
||||
|
||||
// Spawn group shall be despawned, despawn it
|
||||
if (state & FORCEDESPAWN)
|
||||
instance->SpawnGroupDespawn(groupId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user