Merge branch 'dynamicSpawnMerge' of https://gitlab.com/trinitycore/TrinityCore_434 into 4.3.4
# Conflicts: # src/server/game/Entities/Creature/Creature.cpp # src/server/game/Entities/Object/Object.cpp # src/server/game/Maps/Map.cpp # src/server/game/Maps/Map.h
This commit is contained in:
commit
59d169e8e4
87 files changed
+3209
-1000
No files matched your search
@@ -48,7 +48,7 @@ BossBoundaryData::~BossBoundaryData()
|
||||
delete it->Boundary;
|
||||
}
|
||||
|
||||
InstanceScript::InstanceScript(Map* map) : instance(map), completedEncounters(0)
|
||||
InstanceScript::InstanceScript(Map* map) : instance(map), completedEncounters(0), _instanceSpawnGroups(sObjectMgr->GetSpawnGroupsForInstance(map->GetId()))
|
||||
{
|
||||
#ifdef TRINITY_API_USE_DYNAMIC_LINKING
|
||||
uint32 scriptId = sObjectMgr->GetInstanceTemplate(map->GetId())->ScriptId;
|
||||
@@ -188,27 +188,6 @@ void InstanceScript::LoadObjectData(ObjectData const* data, ObjectInfoMap& objec
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceScript::UpdateMinionState(Creature* minion, EncounterState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case NOT_STARTED:
|
||||
if (!minion->IsAlive())
|
||||
minion->Respawn();
|
||||
else if (minion->IsInCombat())
|
||||
minion->AI()->EnterEvadeMode();
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
if (!minion->IsAlive())
|
||||
minion->Respawn();
|
||||
else if (!minion->GetVictim())
|
||||
minion->AI()->DoZoneInCombat();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceScript::UpdateDoorState(GameObject* door)
|
||||
{
|
||||
DoorInfoMapBounds range = doors.equal_range(door->GetEntry());
|
||||
@@ -238,6 +217,60 @@ void InstanceScript::UpdateDoorState(GameObject* door)
|
||||
door->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY);
|
||||
}
|
||||
|
||||
void InstanceScript::UpdateMinionState(Creature* minion, EncounterState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case NOT_STARTED:
|
||||
if (!minion->IsAlive())
|
||||
minion->Respawn();
|
||||
else if (minion->IsInCombat())
|
||||
minion->AI()->EnterEvadeMode();
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
if (!minion->IsAlive())
|
||||
minion->Respawn();
|
||||
else if (!minion->GetVictim())
|
||||
minion->AI()->DoZoneInCombat();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceScript::UpdateSpawnGroups()
|
||||
{
|
||||
if (!_instanceSpawnGroups)
|
||||
return;
|
||||
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;
|
||||
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))
|
||||
continue;
|
||||
if (info.Flags & InstanceSpawnGroupInfo::FLAG_BLOCK_SPAWN)
|
||||
curValue = FORCEBLOCK;
|
||||
else if (info.Flags & InstanceSpawnGroupInfo::FLAG_ACTIVATE_SPAWN)
|
||||
curValue = SPAWN;
|
||||
}
|
||||
for (auto const& pair : newStates)
|
||||
{
|
||||
uint32 const groupId = pair.first;
|
||||
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);
|
||||
else // otherwise, set it as inactive so it no longer respawns (but don't despawn it)
|
||||
instance->SetSpawnGroupInactive(groupId);
|
||||
}
|
||||
}
|
||||
|
||||
BossInfo* InstanceScript::GetBossInfo(uint32 id)
|
||||
{
|
||||
ASSERT(id < bosses.size());
|
||||
@@ -312,7 +345,7 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
|
||||
if (bossInfo->state == TO_BE_DECIDED) // loading
|
||||
{
|
||||
bossInfo->state = state;
|
||||
//TC_LOG_ERROR("misc", "Inialize boss %u state as %u.", id, (uint32)state);
|
||||
TC_LOG_DEBUG("scripts", "InstanceScript: Initialize boss %u state as %s (map %u, %u).", id, GetBossStateName(state), instance->GetId(), instance->GetInstanceId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -321,6 +354,12 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
|
||||
if (bossInfo->state == state)
|
||||
return false;
|
||||
|
||||
if (bossInfo->state == DONE)
|
||||
{
|
||||
TC_LOG_ERROR("map", "InstanceScript: Tried to set instance state from %s back to %s for map %u, instance id %u. Blocked!", GetBossStateName(bossInfo->state), GetBossStateName(state), instance->GetId(), instance->GetInstanceId());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (state == DONE)
|
||||
for (GuidSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i)
|
||||
if (Creature* minion = instance->GetCreature(*i))
|
||||
@@ -364,6 +403,7 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
|
||||
if (Creature* minion = instance->GetCreature(*i))
|
||||
UpdateMinionState(minion, state);
|
||||
|
||||
UpdateSpawnGroups();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -374,6 +414,13 @@ bool InstanceScript::_SkipCheckRequiredBosses(Player const* player /*= nullptr*/
|
||||
return player && player->GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_INSTANCE_REQUIRED_BOSSES);
|
||||
}
|
||||
|
||||
void InstanceScript::Create()
|
||||
{
|
||||
for (size_t i = 0; i < bosses.size(); ++i)
|
||||
SetBossState(i, NOT_STARTED);
|
||||
UpdateSpawnGroups();
|
||||
}
|
||||
|
||||
void InstanceScript::Load(char const* data)
|
||||
{
|
||||
if (!data)
|
||||
@@ -424,6 +471,7 @@ void InstanceScript::ReadSaveDataBossStates(std::istringstream& data)
|
||||
if (buff < TO_BE_DECIDED)
|
||||
SetBossState(bossId, EncounterState(buff));
|
||||
}
|
||||
UpdateSpawnGroups();
|
||||
}
|
||||
|
||||
std::string InstanceScript::GetSaveData()
|
||||
@@ -756,7 +804,7 @@ void InstanceScript::UpdateEncounterStateForSpellCast(uint32 spellId, Unit* sour
|
||||
UpdateEncounterState(ENCOUNTER_CREDIT_CAST_SPELL, spellId, source);
|
||||
}
|
||||
|
||||
std::string InstanceScript::GetBossStateName(uint8 state)
|
||||
/*static*/ std::string InstanceScript::GetBossStateName(uint8 state)
|
||||
{
|
||||
// See enum EncounterState in InstanceScript.h
|
||||
switch (state)
|
||||
|
||||
Reference in new issue
Block a user