From 9ecc3c679d6f4ffdd21dcba0b860f4f833dfeadd Mon Sep 17 00:00:00 2001 From: bladez Date: Thu, 25 Jan 2018 07:06:01 +1100 Subject: [PATCH] Prevent instant GO respawn when despawn is called without a valid respawn delay being set (#1313) * Don't always use respawn delay when using GameObject::Despawn, many objects which call this have a delay of 0 and hence instantly respawn Requires further research * Force Corrupted Songflower respawn delay * Actually use respawn time * Don't set spawned by default for Cleansed Songflower - it will disappear at next object update, and also causes it to automatically respawn Instead, leave it as m_spawnedByDefault = false and the timer be a despawn timer. The corrupted flower respawning will remove it from the world --- src/game/Objects/GameObject.cpp | 8 +++++++- src/scripts/kalimdor/felwood/felwood.cpp | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/game/Objects/GameObject.cpp b/src/game/Objects/GameObject.cpp index f21d348e5..27568094e 100644 --- a/src/game/Objects/GameObject.cpp +++ b/src/game/Objects/GameObject.cpp @@ -2253,7 +2253,13 @@ void GameObject::Despawn() { if (m_spawnedByDefault) { - SetRespawnTime(GetRespawnDelay()); + // TODO: Research this more. Some GOBJs don't set a respawn delay time, but call ::Despawn + // If this happens, they will respawn instantly which is most likely undesired behaviour + uint32 respawnTime = GetRespawnDelay(); + if (!respawnTime) + respawnTime = data->GetRandomRespawnTime(); + + SetRespawnTime(respawnTime); } else { diff --git a/src/scripts/kalimdor/felwood/felwood.cpp b/src/scripts/kalimdor/felwood/felwood.cpp index 7ffb52956..9d75931c2 100644 --- a/src/scripts/kalimdor/felwood/felwood.cpp +++ b/src/scripts/kalimdor/felwood/felwood.cpp @@ -869,8 +869,11 @@ public: if (GameObject* cleansed = me->SummonGameObject(cleansedEntry, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0.0, 0.0, 0.0, 0.0, 0.0, CLEANSED_PLANT_RESPAWN_TIMER)) { cleansedGuid = cleansed->GetObjectGuid(); - cleansed->SetSpawnedByDefault(true); } + + if (const GameObjectData* data = me->GetGOData()) + me->SetRespawnDelay(data->ComputeRespawnDelay(data->GetRandomRespawnTime())); + me->Despawn(); me->DestroyForNearbyPlayers(); }