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
22 //Only required includes
23 #include "../../game/CreatureAI.h"
24 #include "../../game/Creature.h"
25 #include "../../game/InstanceData.h"
32 class SpellCastTargets
;
35 #define MAX_SCRIPTS 1000
36 #define MAX_INSTANCE_SCRIPTS 1000
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
)
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 // -----------------------------------------
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
) {}
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
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);