[7668] Cleanup In CreatureAI function descriptions and AttackStart/AttackedBy use.
[AHbot.git] / src / bindings / universal / ScriptMgr.h
blob7bfaf2431b9bde3919ca160cc55dcd91000be76a
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
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 SCRIPTMGR_H
20 #define SCRIPTMGR_H
22 //Only required includes
23 #include "../../game/CreatureAI.h"
24 #include "../../game/Creature.h"
25 #include "../../game/InstanceData.h"
27 class Player;
28 class Creature;
29 class Quest;
30 class Item;
31 class GameObject;
32 class SpellCastTargets;
33 class Map;
35 #define MAX_SCRIPTS 1000
36 #define MAX_INSTANCE_SCRIPTS 1000
38 struct Script
40 Script() :
41 pGossipHello(NULL), pQuestAccept(NULL), pGossipSelect(NULL), pGossipSelectWithCode(NULL),
42 pQuestSelect(NULL), pQuestComplete(NULL), pNPCDialogStatus(NULL), pGODialogStatus(NULL), pChooseReward(NULL),
43 pItemHello(NULL), pGOHello(NULL), pAreaTrigger(NULL), pItemQuestAccept(NULL), pGOQuestAccept(NULL),
44 pGOChooseReward(NULL), pReceiveEmote(NULL), pItemUse(NULL), pEffectDummyGameObj(NULL), pEffectDummyCreature(NULL),
45 pEffectDummyItem(NULL), GetAI(NULL)
48 std::string Name;
50 // -- Quest/gossip Methods to be scripted --
51 bool (*pGossipHello )(Player *player, Creature *_Creature);
52 bool (*pQuestAccept )(Player *player, Creature *_Creature, Quest const*_Quest );
53 bool (*pGossipSelect )(Player *player, Creature *_Creature, uint32 sender, uint32 action );
54 bool (*pGossipSelectWithCode)(Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode );
55 bool (*pQuestSelect )(Player *player, Creature *_Creature, Quest const*_Quest );
56 bool (*pQuestComplete )(Player *player, Creature *_Creature, Quest const*_Quest );
57 uint32 (*pNPCDialogStatus )(Player *player, Creature *_Creature );
58 uint32 (*pGODialogStatus )(Player *player, GameObject * _GO );
59 bool (*pChooseReward )(Player *player, Creature *_Creature, Quest const*_Quest, uint32 opt );
60 bool (*pItemHello )(Player *player, Item *_Item, Quest const*_Quest );
61 bool (*pGOHello )(Player *player, GameObject *_GO );
62 bool (*pAreaTrigger )(Player *player, AreaTriggerEntry* at);
63 bool (*pItemQuestAccept )(Player *player, Item *_Item, Quest const*_Quest );
64 bool (*pGOQuestAccept )(Player *player, GameObject *_GO, Quest const*_Quest );
65 bool (*pGOChooseReward )(Player *player, GameObject *_GO, Quest const*_Quest, uint32 opt );
66 bool (*pReceiveEmote )(Player *player, Creature *_Creature, uint32 emote );
67 bool (*pItemUse )(Player *player, Item* _Item, SpellCastTargets const& targets);
68 bool (*pEffectDummyGameObj )(Unit*, uint32, uint32, GameObject* );
69 bool (*pEffectDummyCreature )(Unit*, uint32, uint32, Creature* );
70 bool (*pEffectDummyItem )(Unit*, uint32, uint32, Item* );
72 CreatureAI* (*GetAI)(Creature *_Creature);
73 InstanceData* (*GetInstanceData)(Map*);
74 // -----------------------------------------
76 void registerSelf();
79 #define VISIBLE_RANGE (50.0f)
81 // Read function descriptions in CreatureAI
82 struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
84 explicit ScriptedAI(Creature* creature) : CreatureAI(creature) {}
85 ~ScriptedAI() {}
87 // Called at stopping attack by any attacker
88 void EnterEvadeMode();
90 // Is unit visible for MoveInLineOfSight
91 bool IsVisible(Unit* who) const
93 return !who->HasStealthAura() && m_creature->GetDistance(who) <= VISIBLE_RANGE;
96 // Called at World update tick
97 void UpdateAI(const uint32);
99 //= Some useful helpers =========================
101 // Start attack of victim and go to him
102 void DoStartAttack(Unit* victim);
104 // Stop attack of current victim
105 void DoStopAttack();
107 // Cast spell
108 void DoCast(Unit* victim, uint32 spelId)
110 m_creature->CastSpell(victim,spelId,true);
113 void DoCastSpell(Unit* who,SpellEntry *spellInfo)
115 m_creature->CastSpell(who,spellInfo,true);
118 void DoSay(int32 text_id, uint32 language)
120 m_creature->Say(text_id,language,0);
123 void DoGoHome();
126 #endif