From c2381a5a1c97f489800cad697e3045b0cb192898 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Thu, 21 Oct 2021 19:03:47 -0300 Subject: [PATCH] fix(Core/BattlegroundAV) Irondeep/Coldtooth Supplies never despawning (#8612) --- src/server/game/Battlegrounds/Battleground.cpp | 7 ++++++- src/server/game/Battlegrounds/Battleground.h | 2 +- src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp | 4 ++-- src/server/game/Entities/GameObject/GameObject.cpp | 7 ++++++- src/server/game/Entities/GameObject/GameObject.h | 1 + 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 5441cb1a1..088cf91cf 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1610,7 +1610,7 @@ Creature* Battleground::GetBGCreature(uint32 type) return creature; } -void Battleground::SpawnBGObject(uint32 type, uint32 respawntime) +void Battleground::SpawnBGObject(uint32 type, uint32 respawntime, uint32 forceRespawnDelay) { if (Map* map = FindBgMap()) if (GameObject* obj = map->GetGameObject(BgObjects[type])) @@ -1622,6 +1622,11 @@ void Battleground::SpawnBGObject(uint32 type, uint32 respawntime) obj->SetLootState(GO_READY); obj->SetRespawnTime(respawntime); map->AddToMap(obj); + + if (forceRespawnDelay) + { + obj->SetRespawnDelay(forceRespawnDelay); + } } } diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 8275de200..54c7e8553 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -567,7 +567,7 @@ public: typedef GuidVector BGCreatures; BGObjects BgObjects; 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); Creature* AddCreature(uint32 entry, uint32 type, float x, float y, float z, float o, uint32 respawntime = 0, MotionTransport* transport = nullptr); bool DelCreature(uint32 type); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index b94b28fd6..d4950c147 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -437,9 +437,9 @@ void BattlegroundAV::StartingEventOpenDoors() { 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++) - 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++) - SpawnBGObject(i, RESPAWN_IMMEDIATELY); + SpawnBGObject(i, RESPAWN_IMMEDIATELY, 5 * MINUTE); for (uint8 mine = AV_NORTH_MINE; mine <= AV_SOUTH_MINE; mine++) //mine population ChangeMineOwner(mine, TEAM_NEUTRAL, true); diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 65da670a5..7961912ef 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1194,13 +1194,18 @@ bool GameObject::IsInvisibleDueToDespawn() const void GameObject::SetRespawnTime(int32 respawn) { m_respawnTime = respawn > 0 ? time(nullptr) + respawn : 0; - m_respawnDelayTime = respawn > 0 ? respawn : 0; + SetRespawnDelay(respawn); if (respawn && !m_spawnedByDefault) { UpdateObjectVisibility(true); } } +void GameObject::SetRespawnDelay(int32 respawn) +{ + m_respawnDelayTime = respawn > 0 ? respawn : 0; +} + void GameObject::Respawn() { if (m_spawnedByDefault && m_respawnTime > 0) diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index c2e303347..01c31959f 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -811,6 +811,7 @@ public: } void SetRespawnTime(int32 respawn); + void SetRespawnDelay(int32 respawn); void Respawn(); [[nodiscard]] bool isSpawned() const {