azerothcore / azerothcore-wotlk

Complete Open Source and Modular solution for MMO
http://www.azerothcore.org
GNU Affero General Public License v3.0
6.52k stars 2.61k forks source link

[BG-Alterac Valley] Mine Supplies never despawn #8548

Closed Nyeriah closed 3 years ago

Nyeriah commented 3 years ago

Current Behaviour

Original CC Report: https://github.com/chromiecraft/chromiecraft/issues/2096

Irondeep supplies (https://wowgaming.altervista.org/aowow/?object=178785) in Alterac Valley can be repeatedly looted. They are for quest Irondeep Supplies (https://wowgaming.altervista.org/aowow/?object=178785) which awards 3g 10 silver and can be done repeatedly.

https://user-images.githubusercontent.com/80769357/137381185-eccde730-cf94-4362-a309-5dca8f4fa2a9.mp4

Expected Blizzlike Behaviour

After looting Irondeep Supplies they should despawn, and go on respawn timer.

Source

https://youtu.be/nwhM9Ari434?t=8

Steps to reproduce the problem

  1. Go into Alterac Valley
  2. take quest Irondeep Supplies (https://wowgaming.altervista.org/aowow/?object=178785)
  3. Go to Irondeep Mine and loot the supplies repeatedly

Extra Notes

Nyeriah: Has to do with how BG gameobjects are handled, they're presumed to never despawn (fine for most battlegrounds, but AV is an exception as it has PvE elements like this)

AC rev. hash/commit

https://github.com/chromiecraft/azerothcore-wotlk/commit/b2f08934bcc60491f8fa8971f98837b2d48a489e

Operating system

Win11 x64

Custom changes or Modules

No response

gurveleg commented 3 years ago

Might be worth checking Coldtooth Supplies also, I didn't get a chance to do it in last AV. https://wowgaming.altervista.org/aowow/?object=178784

Nyeriah commented 3 years ago

Might be worth checking Coldtooth Supplies also, I didn't get a chance to do it in last AV. https://wowgaming.altervista.org/aowow/?object=178784

Yes, it’s a generic issue to every game object, I’m not sure if there are others but it’s guaranteed to be the case for all of them, no exceptions

Nyeriah commented 3 years ago

Some important research notes that I will leave here so they don't get lost:

GameObjects spawned are created without a respawn timer (in general) https://github.com/azerothcore/azerothcore-wotlk/blob/master/src/server/game/Entities/GameObject/GameObject.cpp#L250

The respawntimer tends to be filled after the object has been created, during the spawn process.

But this does not happen in battlegrounds: https://github.com/azerothcore/azerothcore-wotlk/blob/master/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp#L1272

Notice that there's a RESPAWN_ONE_DAY param being passed into that function call. Turns out that param has been silenced: https://github.com/azerothcore/azerothcore-wotlk/blob/master/src/server/game/Battlegrounds/Battleground.cpp#L1511

In other words, despite being passed, it isn't used for anything.

The default respawn timer for GameObjects in battlegrounds seems to be set to one day. I added logs everywhere, wasn't able to figure out where that is set.

However, the respawnDelayTimer is reset to 0 once the BG starts*, which seems to cause them to instantly respawn right after being used. Setting the respawnDelayTimer causes them to behave properly.

**Happens because SetRespawnTimer(0) is used to force them to respawn when they're meant to "reset" https://github.com/azerothcore/azerothcore-wotlk/blob/master/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp#L439-L444