fix(Core/BattlegroundAV) Irondeep/Coldtooth Supplies never despawning (#8612)

This commit is contained in:
Skjalf
2021-10-21 19:03:47 -03:00
committed by GitHub
parent a009e935ac
commit c2381a5a1c
5 changed files with 16 additions and 5 deletions
@@ -1610,7 +1610,7 @@ Creature* Battleground::GetBGCreature(uint32 type)
return creature; return creature;
} }
void Battleground::SpawnBGObject(uint32 type, uint32 respawntime) void Battleground::SpawnBGObject(uint32 type, uint32 respawntime, uint32 forceRespawnDelay)
{ {
if (Map* map = FindBgMap()) if (Map* map = FindBgMap())
if (GameObject* obj = map->GetGameObject(BgObjects[type])) if (GameObject* obj = map->GetGameObject(BgObjects[type]))
@@ -1622,6 +1622,11 @@ void Battleground::SpawnBGObject(uint32 type, uint32 respawntime)
obj->SetLootState(GO_READY); obj->SetLootState(GO_READY);
obj->SetRespawnTime(respawntime); obj->SetRespawnTime(respawntime);
map->AddToMap(obj); map->AddToMap(obj);
if (forceRespawnDelay)
{
obj->SetRespawnDelay(forceRespawnDelay);
}
} }
} }
+1 -1
View File
@@ -567,7 +567,7 @@ public:
typedef GuidVector BGCreatures; typedef GuidVector BGCreatures;
BGObjects BgObjects; BGObjects BgObjects;
BGCreatures BgCreatures; BGCreatures BgCreatures;
void SpawnBGObject(uint32 type, uint32 respawntime); void SpawnBGObject(uint32 type, uint32 respawntime, uint32 forceRespawnDelay = 0);
bool AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime = 0, GOState goState = GO_STATE_READY); bool AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime = 0, GOState goState = GO_STATE_READY);
Creature* AddCreature(uint32 entry, uint32 type, float x, float y, float z, float o, uint32 respawntime = 0, MotionTransport* transport = nullptr); Creature* AddCreature(uint32 entry, uint32 type, float x, float y, float z, float o, uint32 respawntime = 0, MotionTransport* transport = nullptr);
bool DelCreature(uint32 type); bool DelCreature(uint32 type);
@@ -437,9 +437,9 @@ void BattlegroundAV::StartingEventOpenDoors()
{ {
LOG_DEBUG("bg.battleground", "BG_AV: start spawning mine stuff"); LOG_DEBUG("bg.battleground", "BG_AV: start spawning mine stuff");
for (uint16 i = BG_AV_OBJECT_MINE_SUPPLY_N_MIN; i <= BG_AV_OBJECT_MINE_SUPPLY_N_MAX; i++) for (uint16 i = BG_AV_OBJECT_MINE_SUPPLY_N_MIN; i <= BG_AV_OBJECT_MINE_SUPPLY_N_MAX; i++)
SpawnBGObject(i, RESPAWN_IMMEDIATELY); SpawnBGObject(i, RESPAWN_IMMEDIATELY, 5 * MINUTE);
for (uint16 i = BG_AV_OBJECT_MINE_SUPPLY_S_MIN; i <= BG_AV_OBJECT_MINE_SUPPLY_S_MAX; i++) for (uint16 i = BG_AV_OBJECT_MINE_SUPPLY_S_MIN; i <= BG_AV_OBJECT_MINE_SUPPLY_S_MAX; i++)
SpawnBGObject(i, RESPAWN_IMMEDIATELY); SpawnBGObject(i, RESPAWN_IMMEDIATELY, 5 * MINUTE);
for (uint8 mine = AV_NORTH_MINE; mine <= AV_SOUTH_MINE; mine++) //mine population for (uint8 mine = AV_NORTH_MINE; mine <= AV_SOUTH_MINE; mine++) //mine population
ChangeMineOwner(mine, TEAM_NEUTRAL, true); ChangeMineOwner(mine, TEAM_NEUTRAL, true);
@@ -1194,13 +1194,18 @@ bool GameObject::IsInvisibleDueToDespawn() const
void GameObject::SetRespawnTime(int32 respawn) void GameObject::SetRespawnTime(int32 respawn)
{ {
m_respawnTime = respawn > 0 ? time(nullptr) + respawn : 0; m_respawnTime = respawn > 0 ? time(nullptr) + respawn : 0;
m_respawnDelayTime = respawn > 0 ? respawn : 0; SetRespawnDelay(respawn);
if (respawn && !m_spawnedByDefault) if (respawn && !m_spawnedByDefault)
{ {
UpdateObjectVisibility(true); UpdateObjectVisibility(true);
} }
} }
void GameObject::SetRespawnDelay(int32 respawn)
{
m_respawnDelayTime = respawn > 0 ? respawn : 0;
}
void GameObject::Respawn() void GameObject::Respawn()
{ {
if (m_spawnedByDefault && m_respawnTime > 0) if (m_spawnedByDefault && m_respawnTime > 0)
@@ -811,6 +811,7 @@ public:
} }
void SetRespawnTime(int32 respawn); void SetRespawnTime(int32 respawn);
void SetRespawnDelay(int32 respawn);
void Respawn(); void Respawn();
[[nodiscard]] bool isSpawned() const [[nodiscard]] bool isSpawned() const
{ {