mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-21 02:20:00 +01:00
72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
#ifndef _PLAYERBOT_RAIDULDUARBOSSHELPER_H
|
|
#define _PLAYERBOT_RAIDULDUARBOSSHELPER_H
|
|
|
|
#include "AiObject.h"
|
|
#include "AiObjectContext.h"
|
|
#include "EventMap.h"
|
|
#include "Log.h"
|
|
#include "ObjectGuid.h"
|
|
#include "Player.h"
|
|
#include "PlayerbotAI.h"
|
|
#include "Playerbots.h"
|
|
#include "ScriptedCreature.h"
|
|
#include "RaidUlduarScripts.h"
|
|
#include "SharedDefines.h"
|
|
|
|
#include <string>
|
|
|
|
const uint32 ULDUAR_MAP_ID = 603;
|
|
|
|
template<class BossAiType>
|
|
class GenericBossHelper : public AiObject {
|
|
public:
|
|
GenericBossHelper(PlayerbotAI* botAI, std::string name): AiObject(botAI), _name(name) {}
|
|
virtual bool UpdateBossAI() {
|
|
if (!bot->IsInCombat()) {
|
|
_unit = nullptr;
|
|
}
|
|
if(_unit && (!_unit->IsInWorld() || !_unit->IsAlive())) {
|
|
_unit = nullptr;
|
|
}
|
|
if (!_unit) {
|
|
_unit = AI_VALUE2(Unit*, "find target", _name);
|
|
if (!_unit) {
|
|
return false;
|
|
}
|
|
_target = _unit->ToCreature();
|
|
if (!_target) {
|
|
return false;
|
|
}
|
|
_ai = dynamic_cast<BossAiType *>(_target->GetAI());
|
|
if (!_ai) {
|
|
return false;
|
|
}
|
|
_event_map = &_ai->events;
|
|
if (!_event_map) {
|
|
return false;
|
|
}
|
|
}
|
|
if (!_event_map) {
|
|
return false;
|
|
}
|
|
_timer = _event_map->GetTimer();
|
|
return true;
|
|
}
|
|
virtual void Reset() {
|
|
_unit = nullptr;
|
|
_target = nullptr;
|
|
_ai = nullptr;
|
|
_event_map = nullptr;
|
|
_timer = 0;
|
|
}
|
|
protected:
|
|
std::string _name;
|
|
Unit* _unit = nullptr;
|
|
Creature* _target = nullptr;
|
|
BossAiType *_ai = nullptr;
|
|
EventMap* _event_map = nullptr;
|
|
uint32 _timer = 0;
|
|
};
|
|
|
|
#endif
|