[2771] Applied MaNGOS coding style (see trunk/bcpp.cfg).
[mangos-git.git] / src / game / CreatureAI.h
blob8040a31607484200017aa25f80798234eb77fbb5
1 /*
2 * Copyright (C) 2005,2006 MaNGOS <http://www.mangosproject.org/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOS_CREATUREAI_H
20 #define MANGOS_CREATUREAI_H
22 #include "Common.h"
23 #include "Platform/Define.h"
24 #include "Policies/Singleton.h"
25 #include "Dynamic/ObjectRegistry.h"
26 #include "Dynamic/FactoryHolder.h"
28 class Unit;
29 class Creature;
31 #define TIME_INTERVAL_LOOK 5000
32 #define VISIBILITY_RANGE 10000
34 class MANGOS_DLL_SPEC CreatureAI
36 public:
38 virtual ~CreatureAI();
40 virtual void MoveInLineOfSight(Unit *) = 0;
42 virtual void AttackStart(Unit *) = 0;
44 virtual void AttackStop(Unit *) = 0;
46 virtual void HealBy(Unit *healer, uint32 amount_healed) = 0;
48 virtual void DamageInflict(Unit *done_by, uint32 amount_damage) = 0;
50 virtual bool IsVisible(Unit *) const = 0;
52 virtual void UpdateAI(const uint32 diff) = 0;
55 struct SelectableAI : public FactoryHolder<CreatureAI>, public Permissible<Creature>
58 SelectableAI(const char *id) : FactoryHolder<CreatureAI>(id) {}
61 template<class REAL_AI>
62 struct CreatureAIFactory : public SelectableAI
64 CreatureAIFactory(const char *name) : SelectableAI(name) {}
66 CreatureAI* Create(void *) const;
68 int Permit(const Creature *c) const { return REAL_AI::Permissible(c); }
71 #define PERMIT_BASE_NO -1
72 #define PERMIT_BASE_IDLE 1
73 #define PERMIT_BASE_REACTIVE 100
74 #define PERMIT_BASE_PROACTIVE 200
75 #define PERMIT_BASE_FACTION_SPECIFIC 400
76 #define PERMIT_BASE_SPECIAL 800
78 typedef FactoryHolder<CreatureAI> CreatureAICreator;
79 typedef FactoryHolder<CreatureAI>::FactoryHolderRegistry CreatureAIRegistry;
80 typedef FactoryHolder<CreatureAI>::FactoryHolderRepository CreatureAIRepository;
81 #endif