BattleGrounds: Refactor and Fix bots re-spawning when graveyard meanwhile gets lost (#937)

* Update ReleaseSpiritAction.cpp

* Update ReleaseSpiritAction.cpp

* Update ReleaseSpiritAction.cpp

* Update ReleaseSpiritAction.cpp

* Update ReleaseSpiritAction.h

* Update ReleaseSpiritAction.h

* Update ReleaseSpiritAction.cpp

* Update ReleaseSpiritAction.cpp

* Update ReleaseSpiritAction.cpp

* Refactor (#68)

* Refactored ReleaseSpiritAction.cpp

* Ref ReleaseSpiritAction.h

* Restore comment
This commit is contained in:
SaW
2025-02-04 13:30:35 +01:00
committed by GitHub
parent fb683b3846
commit 308c0b437e
2 changed files with 178 additions and 168 deletions

View File

@@ -3,10 +3,8 @@
* and/or modify it under version 2 of the License, or (at your option), any later version.
*/
#ifndef _PLAYERBOT_RELEASESPIRITACTION_H
#define _PLAYERBOT_RELEASESPIRITACTION_H
#include <cstdint>
#ifndef PLAYERBOT_RELEASESPIRITACTION_H
#define PLAYERBOT_RELEASESPIRITACTION_H
#include "Action.h"
#include "ReviveFromCorpseAction.h"
@@ -16,34 +14,46 @@ class PlayerbotAI;
class ReleaseSpiritAction : public Action
{
public:
ReleaseSpiritAction(PlayerbotAI* botAI, std::string const name = "release") : Action(botAI, name) {}
ReleaseSpiritAction(PlayerbotAI* botAI, const std::string& name = "release")
: Action(botAI, name) {}
bool Execute(Event event) override;
void LogRelease(const std::string& releaseType, bool isAutoRelease = false) const;
protected:
void IncrementDeathCount() const;
};
class AutoReleaseSpiritAction : public ReleaseSpiritAction
{
public:
AutoReleaseSpiritAction(PlayerbotAI* botAI, std::string const name = "auto release")
: ReleaseSpiritAction(botAI, name)
{
}
AutoReleaseSpiritAction(PlayerbotAI* botAI, const std::string& name = "auto release")
: ReleaseSpiritAction(botAI, name) {}
bool Execute(Event event) override;
bool isUseful() override;
private:
inline static std::unordered_map<uint32_t, time_t> botReleaseTimes;
uint32_t bg_gossip_time = 0;
bool HandleBattlegroundSpiritHealer();
bool ShouldAutoRelease() const;
bool ShouldDelayBattlegroundRelease() const;
inline static std::unordered_map<uint32_t, time_t> m_botReleaseTimes;
time_t m_bgGossipTime = 0;
};
class RepopAction : public SpiritHealerAction
{
public:
RepopAction(PlayerbotAI* botAI, std::string const name = "repop") : SpiritHealerAction(botAI, name) {}
RepopAction(PlayerbotAI* botAI, const std::string& name = "repop")
: SpiritHealerAction(botAI, name) {}
bool Execute(Event event) override;
bool isUseful() override;
private:
int64 CalculateDeadTime() const;
void PerformGraveyardTeleport(const GraveyardStruct* graveyard) const;
};
#endif