[6922] Whitespace and newline fixes
[getmangos.git] / src / bindings / universal / ScriptMgr.h
blob415aa23cc6a676f85bae7faec906af75142f1513
1 /*
2 * Copyright (C) 2005-2008 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), GetAI(NULL)
47 std::string Name;
49 // -- Quest/gossip Methods to be scripted --
50 bool (*pGossipHello )(Player *player, Creature *_Creature);
51 bool (*pQuestAccept )(Player *player, Creature *_Creature, Quest const*_Quest );
52 bool (*pGossipSelect )(Player *player, Creature *_Creature, uint32 sender, uint32 action );
53 bool (*pGossipSelectWithCode)(Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode );
54 bool (*pQuestSelect )(Player *player, Creature *_Creature, Quest const*_Quest );
55 bool (*pQuestComplete )(Player *player, Creature *_Creature, Quest const*_Quest );
56 uint32 (*pNPCDialogStatus )(Player *player, Creature *_Creature );
57 uint32 (*pGODialogStatus )(Player *player, GameObject * _GO );
58 bool (*pChooseReward )(Player *player, Creature *_Creature, Quest const*_Quest, uint32 opt );
59 bool (*pItemHello )(Player *player, Item *_Item, Quest const*_Quest );
60 bool (*pGOHello )(Player *player, GameObject *_GO );
61 bool (*pAreaTrigger )(Player *player, AreaTriggerEntry* at);
62 bool (*pItemQuestAccept )(Player *player, Item *_Item, Quest const*_Quest );
63 bool (*pGOQuestAccept )(Player *player, GameObject *_GO, Quest const*_Quest );
64 bool (*pGOChooseReward )(Player *player, GameObject *_GO, Quest const*_Quest, uint32 opt );
65 bool (*pReceiveEmote )(Player *player, Creature *_Creature, uint32 emote );
66 bool (*pItemUse )(Player *player, Item* _Item, SpellCastTargets const& targets);
68 CreatureAI* (*GetAI)(Creature *_Creature);
69 InstanceData* (*GetInstanceData)(Map*);
70 // -----------------------------------------
72 void registerSelf();
75 #define VISIBLE_RANGE (50.0f)
77 struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
79 ScriptedAI(Creature* creature) : m_creature(creature) {}
80 ~ScriptedAI() {}
82 // Called if IsVisible(Unit *who) is true at each *who move
83 void MoveInLineOfSight(Unit *) {}
85 // Called at each attack of m_creature by any victim
86 void AttackStart(Unit *) {}
88 // Called at stopping attack by any attacker
89 void EnterEvadeMode();
91 // Called at any heal cast/item used (call non implemented)
92 void HealBy(Unit* /*healer*/, uint32 /*amount_healed*/) {}
94 // Called at any Damage to any victim (before damage apply)
95 void DamageDeal(Unit* /*done_to*/, uint32& /*damage*/) {}
97 // Called at any Damage from any attacker (before damage apply)
98 void DamageTaken(Unit* /*done_by*/, uint32& /*damage*/) {}
100 // Is unit visible for MoveInLineOfSight
101 bool IsVisible(Unit* who) const
103 return !who->HasStealthAura() && m_creature->GetDistance(who) <= VISIBLE_RANGE;
106 // Called at World update tick
107 void UpdateAI(const uint32);
109 // Called when the creature is killed
110 void JustDied(Unit *){}
112 // Called when the creature kills a unit
113 void KilledUnit(Unit *){}
115 // Called when hit by a spell
116 void SpellHit(Unit *, const SpellEntry*){}
118 Creature* m_creature;
120 //= Some useful helpers =========================
122 // Start attack of victim and go to him
123 void DoStartAttack(Unit* victim);
125 // Stop attack of current victim
126 void DoStopAttack();
128 // Cast spell
129 void DoCast(Unit* victim, uint32 spelId)
131 m_creature->CastSpell(victim,spelId,true);
134 void DoCastSpell(Unit* who,SpellEntry *spellInfo)
136 m_creature->CastSpell(who,spellInfo,true);
139 void DoSay(char const* text, uint32 language)
141 m_creature->Say(text,language,0);
144 void DoGoHome();
147 #endif