forked from insider42/scriptdev2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsc_creature.h
More file actions
183 lines (130 loc) · 6.18 KB
/
sc_creature.h
File metadata and controls
183 lines (130 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* Copyright (C) 2006 - 2011 ScriptDev2 <http://www.scriptdev2.com/>
* This program is free software licensed under GPL version 2
* Please see the included DOCS/LICENSE.TXT for more information */
#ifndef SC_CREATURE_H
#define SC_CREATURE_H
#include "CreatureAI.h"
#include "Creature.h"
//Spell targets used by SelectSpell
enum SelectTarget
{
SELECT_TARGET_DONTCARE = 0, //All target types allowed
SELECT_TARGET_SELF, //Only Self casting
SELECT_TARGET_SINGLE_ENEMY, //Only Single Enemy
SELECT_TARGET_AOE_ENEMY, //Only AoE Enemy
SELECT_TARGET_ANY_ENEMY, //AoE or Single Enemy
SELECT_TARGET_SINGLE_FRIEND, //Only Single Friend
SELECT_TARGET_AOE_FRIEND, //Only AoE Friend
SELECT_TARGET_ANY_FRIEND, //AoE or Single Friend
};
//Spell Effects used by SelectSpell
enum SelectEffect
{
SELECT_EFFECT_DONTCARE = 0, //All spell effects allowed
SELECT_EFFECT_DAMAGE, //Spell does damage
SELECT_EFFECT_HEALING, //Spell does healing
SELECT_EFFECT_AURA, //Spell applies an aura
};
enum SCEquip
{
EQUIP_NO_CHANGE = -1,
EQUIP_UNEQUIP = 0
};
struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
{
explicit ScriptedAI(Creature* pCreature);
~ScriptedAI() {}
//*************
//CreatureAI Functions
//*************
//Called if IsVisible(Unit *who) is true at each *who move
void MoveInLineOfSight(Unit*);
//Called at each attack of m_creature by any victim
void AttackStart(Unit*);
// Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
void EnterCombat(Unit*);
//Called at stoping attack by any attacker
void EnterEvadeMode();
//Called at any heal cast/item used (call non implemented in mangos)
void HealBy(Unit* pHealer, uint32 uiAmountHealed) {}
// Called at any Damage to any victim (before damage apply)
void DamageDeal(Unit* pDoneTo, uint32& uiDamage) {}
// Called at any Damage from any attacker (before damage apply)
void DamageTaken(Unit* pDoneBy, uint32& uiDamage) {}
//Is unit visible for MoveInLineOfSight
bool IsVisible(Unit* pWho) const;
//Called at World update tick
void UpdateAI(const uint32);
//Called at creature death
void JustDied(Unit*) {}
//Called at creature killing another unit
void KilledUnit(Unit*) {}
// Called when the creature summon successfully other creature
void JustSummoned(Creature*) {}
// Called when a summoned creature is despawned
void SummonedCreatureDespawn(Creature*) {}
// Called when hit by a spell
void SpellHit(Unit*, const SpellEntry*) {}
// Called when creature is spawned or respawned (for reseting variables)
void JustRespawned();
//Called at waypoint reached or PointMovement end
void MovementInform(uint32, uint32) {}
//*************
// Variables
//*************
//*************
//Pure virtual functions
//*************
//Called at creature reset either by death or evade
virtual void Reset() = 0;
//Called at creature EnterCombat
virtual void Aggro(Unit*);
//*************
//AI Helper Functions
//*************
//Start movement toward victim
void DoStartMovement(Unit* pVictim, float fDistance = 0, float fAngle = 0);
//Start no movement on victim
void DoStartNoMovement(Unit* pVictim);
//Stop attack of current victim
void DoStopAttack();
//Cast spell by Id
void DoCast(Unit* pTarget, uint32 uiSpellId, bool bTriggered = false);
//Cast spell by spell info
void DoCastSpell(Unit* pTarget, SpellEntry const* pSpellInfo, bool bTriggered = false);
//Plays a sound to all nearby players
void DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId);
//Drops all threat to 0%. Does not remove players from the threat list
void DoResetThreat();
//Teleports a player without dropping threat (only teleports to same map)
void DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, float fO);
//Returns friendly unit with the most amount of hp missing from max hp
Unit* DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff = 1);
//Returns a list of friendly CC'd units within range
std::list<Creature*> DoFindFriendlyCC(float fRange);
//Returns a list of all friendly units missing a specific buff within range
std::list<Creature*> DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellId);
//Return a player with at least minimumRange from m_creature
Player* GetPlayerAtMinimumRange(float fMinimumRange);
//Spawns a creature relative to m_creature
Creature* DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime);
//Returns spells that meet the specified criteria from the creatures spell list
SpellEntry const* SelectSpell(Unit* pTarget, int32 uiSchool, int32 uiMechanic, SelectTarget selectTargets, uint32 uiPowerCostMin, uint32 uiPowerCostMax, float fRangeMin, float fRangeMax, SelectEffect selectEffect);
//Checks if you can cast the specified spell
bool CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggered = false);
void SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand = EQUIP_NO_CHANGE, int32 uiOffHand = EQUIP_NO_CHANGE, int32 uiRanged = EQUIP_NO_CHANGE);
//Generally used to control if MoveChase() is to be used or not in AttackStart(). Some creatures does not chase victims
void SetCombatMovement(bool bCombatMove);
bool IsCombatMovement() { return m_bCombatMovement; }
bool EnterEvadeIfOutOfCombatArea(const uint32 uiDiff);
private:
bool m_bCombatMovement;
uint32 m_uiEvadeCheckCooldown;
};
struct MANGOS_DLL_DECL Scripted_NoMovementAI : public ScriptedAI
{
Scripted_NoMovementAI(Creature* pCreature) : ScriptedAI(pCreature) {}
//Called at each attack of m_creature by any victim
void AttackStart(Unit*);
};
#endif