aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/CreatureAIImpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/AI/CreatureAIImpl.h')
-rw-r--r--src/server/game/AI/CreatureAIImpl.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h
index e0346eac10a..b2036d815bd 100644
--- a/src/server/game/AI/CreatureAIImpl.h
+++ b/src/server/game/AI/CreatureAIImpl.h
@@ -17,17 +17,13 @@
#ifndef CREATUREAIIMPL_H
#define CREATUREAIIMPL_H
-#include "Common.h"
-#include "Define.h"
-#include "TemporarySummon.h"
-#include "CreatureAI.h"
-#include "SpellMgr.h"
-
-#include <functional>
+#include "Random.h"
#include <type_traits>
+class WorldObject;
+
template<typename First, typename Second, typename... Rest>
-static inline First const& RAND(First const& first, Second const& second, Rest const&... rest)
+inline First const& RAND(First const& first, Second const& second, Rest const&... rest)
{
std::reference_wrapper<typename std::add_const<First>::type> const pack[] = { first, second, rest... };
return pack[urand(0, sizeof...(rest) + 1)].get();
@@ -65,5 +61,15 @@ struct AISpellInfoType
AISpellInfoType* GetAISpellInfo(uint32 i);
-#endif
+TC_GAME_API bool InstanceHasScript(WorldObject const* obj, char const* scriptName);
+
+template <class AI, class T>
+AI* GetInstanceAI(T* obj, char const* scriptName)
+{
+ if (InstanceHasScript(obj, scriptName))
+ return new AI(obj);
+
+ return nullptr;
+}
+#endif