forked from mangosR2/scriptdev2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpet_scripts.cpp
More file actions
203 lines (172 loc) · 6.08 KB
/
pet_scripts.cpp
File metadata and controls
203 lines (172 loc) · 6.08 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/* Copyright (C) 2006 - 2013 ScriptDev2 <http://www.scriptdev2.com/>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ScriptData
SDName: pet_scripts
SD%Complete:
SDComment: To be used for pets.
SDCategory: Pet's
EndScriptData
*/
#include "precompiled.h"
#include "pet_ai.h"
/* ContentData
pet_greater_fire_elemental ?% support for shaman pet Greater fire elemental
pet_greater_earth_elemental ?% support for shaman pet Greater earth elemental
EndContentData */
enum greater_fire_elemental_spells
{
SPELL_FIRE_RING = 12470,
SPELL_FIRE_EXPLODE = 57984,
};
struct MANGOS_DLL_DECL pet_greater_fire_elemental : public ScriptedPetAI
{
pet_greater_fire_elemental(Creature* pCreature) : ScriptedPetAI(pCreature)
{
Reset();
}
uint32 m_uiFireRingTimer;
uint32 m_uiFireExplodeTimer;
Pet* m_pet;
void Reset()
{
m_pet = (Pet*)m_creature;
m_pet->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE);
m_pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
m_uiFireRingTimer = urand(3000,9000);
m_uiFireExplodeTimer = urand(4000,8000);
if(m_pet->GetOwner()->IsPvP())
m_pet->SetPvP(true);
if(m_pet->GetOwner()->IsFFAPvP())
m_pet->SetFFAPvP(true);
}
void UpdatePetAI(const uint32 diff)
{
if (!m_pet->GetOwner() || !m_pet->GetOwner()->isAlive())
m_pet->ForcedDespawn();
if (m_pet->GetOwner()->getVictim() && m_pet->getVictim() != m_pet->GetOwner()->getVictim())
AttackStart(m_pet->GetOwner()->getVictim());
if (m_uiFireRingTimer <= diff)
{
if (m_pet->IsWithinDistInMap(m_pet->getVictim(),ATTACK_DISTANCE))
DoCastSpellIfCan(m_pet,SPELL_FIRE_RING);
m_uiFireRingTimer = urand(4000,12000);
}
else m_uiFireRingTimer -= diff;
if (m_uiFireExplodeTimer <= diff)
{
DoCastSpellIfCan(m_pet->getVictim(),SPELL_FIRE_EXPLODE);
m_uiFireExplodeTimer = urand(4000,8000);
} else m_uiFireExplodeTimer -= diff;
DoMeleeAttackIfReady();
}
void UpdatePetOOCAI(const uint32 diff)
{
if (!m_pet->GetOwner() || !m_pet->GetOwner()->isAlive())
m_pet->ForcedDespawn();
if (m_pet->GetOwner() && m_pet->GetOwner()->getVictim())
{
AttackStart(m_pet->GetOwner()->getVictim());
}
else if (m_pet->GetOwner()->isInCombat())
{
AttackStart(m_pet->GetOwner()->getAttackerForHelper());
}
}
};
CreatureAI* GetAI_pet_greater_fire_elemental(Creature* pCreature)
{
return new pet_greater_fire_elemental(pCreature);
}
enum greater_earth_elemental_spells
{
SPELL_EARTH_THREAT = 36213,
SPELL_EARTH_EXPLODE = 12374,
SPELL_EARTH_AOE = 33840,
};
struct MANGOS_DLL_DECL pet_greater_earth_elemental : public ScriptedPetAI
{
pet_greater_earth_elemental(Creature* pCreature) : ScriptedPetAI(pCreature)
{
Reset();
}
uint32 m_uiEarthThreatTimer;
uint32 m_uiEarthAOETimer;
uint32 m_uiEarthAttackTimer;
Pet* m_pet;
void Reset()
{
m_pet = (Pet*)m_creature;
m_pet->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE);
m_pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
m_uiEarthThreatTimer = urand(5000,12000);
m_uiEarthAOETimer = urand(10000,30000);
m_uiEarthAttackTimer = urand(2000,8000);
if(m_pet->GetOwner()->IsPvP())
m_pet->SetPvP(true);
if(m_pet->GetOwner()->IsFFAPvP())
m_pet->SetFFAPvP(true);
}
void UpdatePetAI(const uint32 diff)
{
if (!m_pet->GetOwner() || !m_pet->GetOwner()->isAlive())
m_pet->ForcedDespawn();
if (m_pet->GetOwner()->getVictim() && m_pet->getVictim() != m_pet->GetOwner()->getVictim())
AttackStart(m_pet->GetOwner()->getVictim());
if (m_uiEarthThreatTimer <= diff)
{
DoCastSpellIfCan(m_pet,SPELL_EARTH_THREAT);
m_uiEarthThreatTimer = urand(4000,12000);
}
else m_uiEarthThreatTimer -= diff;
if (m_uiEarthAOETimer <= diff)
{
if (m_pet->IsWithinDistInMap(m_pet->getVictim(),ATTACK_DISTANCE))
DoCastSpellIfCan(m_pet,SPELL_EARTH_AOE);
m_uiEarthAOETimer = urand(10000,30000);
}
else m_uiEarthAOETimer -= diff;
if (m_uiEarthAttackTimer <= diff)
{
DoCastSpellIfCan(m_pet->getVictim(),SPELL_EARTH_EXPLODE);
m_uiEarthAttackTimer = urand(2000,8000);
}
else m_uiEarthAttackTimer -= diff;
DoMeleeAttackIfReady();
}
void UpdatePetOOCAI(const uint32 diff)
{
if (!m_pet->GetOwner() || !m_pet->GetOwner()->isAlive())
m_pet->ForcedDespawn();
if (m_pet->GetOwner() && m_pet->GetOwner()->getVictim())
{
AttackStart(m_pet->GetOwner()->getVictim());
}
else if (m_pet->GetOwner()->isInCombat())
{
AttackStart(m_pet->GetOwner()->getAttackerForHelper());
}
}
};
CreatureAI* GetAI_pet_greater_earth_elemental(Creature* pCreature)
{
return new pet_greater_earth_elemental(pCreature);
}
void AddSC_pet_scripts()
{
AutoScript s;
s.newScript("pet_greater_fire_elemental")->GetAI = &GetAI_pet_greater_fire_elemental;
s.newScript("pet_greater_earth_elemental")->GetAI = &GetAI_pet_greater_earth_elemental;
}