forked from TrinityCore/TrinityCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpet_generic.cpp
More file actions
330 lines (281 loc) · 9.57 KB
/
pet_generic.cpp
File metadata and controls
330 lines (281 loc) · 9.57 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/*
* Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.org/>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "npc_pet_gen_".
*/
/* ContentData
npc_pet_gen_baby_blizzard_bear 100% Baby Blizzard Bear sits down occasionally
npc_pet_gen_egbert 100% Egbert run's around
npc_pet_gen_pandaren_monk 100% Pandaren Monk drinks and bows with you
npc_pet_gen_mojo 100% Mojo follows you when you kiss it
EndContentData */
#include "ScriptMgr.h"
#include "DB2Structure.h"
#include "Map.h"
#include "MotionMaster.h"
#include "ObjectAccessor.h"
#include "PassiveAI.h"
#include "PetDefines.h"
#include "Player.h"
#include "ScriptedCreature.h"
enum BabyBlizzardBearMisc
{
SPELL_BBB_PET_SIT = 61853,
EVENT_BBB_PET_SIT = 1,
EVENT_BBB_PET_SIT_INTER = 2
};
class npc_pet_gen_baby_blizzard_bear : public CreatureScript
{
public:
npc_pet_gen_baby_blizzard_bear() : CreatureScript("npc_pet_gen_baby_blizzard_bear") {}
struct npc_pet_gen_baby_blizzard_bearAI : public NullCreatureAI
{
npc_pet_gen_baby_blizzard_bearAI(Creature* creature) : NullCreatureAI(creature)
{
if (Unit* owner = me->GetCharmerOrOwner())
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle());
_events.ScheduleEvent(EVENT_BBB_PET_SIT, urandms(10, 30));
}
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
if (Unit* owner = me->GetCharmerOrOwner())
if (!me->IsWithinDist(owner, 25.f))
me->InterruptSpell(CURRENT_CHANNELED_SPELL);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_BBB_PET_SIT:
me->CastSpell(me, SPELL_BBB_PET_SIT, false);
_events.ScheduleEvent(EVENT_BBB_PET_SIT_INTER, urandms(15, 30));
break;
case EVENT_BBB_PET_SIT_INTER:
me->InterruptSpell(CURRENT_CHANNELED_SPELL);
_events.ScheduleEvent(EVENT_BBB_PET_SIT, urandms(10, 30));
break;
default:
break;
}
}
}
private:
EventMap _events;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_gen_baby_blizzard_bearAI(creature);
}
};
enum EgbertMisc
{
SPELL_EGBERT = 40669,
EVENT_RETURN = 3
};
class npc_pet_gen_egbert : public CreatureScript
{
public:
npc_pet_gen_egbert() : CreatureScript("npc_pet_gen_egbert") {}
struct npc_pet_gen_egbertAI : public NullCreatureAI
{
npc_pet_gen_egbertAI(Creature* creature) : NullCreatureAI(creature)
{
if (Unit* owner = me->GetCharmerOrOwner())
if (owner->GetMap()->GetEntry()->ExpansionID > 1)
me->SetCanFly(true);
}
void Reset() override
{
_events.Reset();
if (Unit* owner = me->GetCharmerOrOwner())
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle());
}
void EnterEvadeMode(EvadeReason why) override
{
if (!_EnterEvadeMode(why))
return;
Reset();
}
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
if (Unit* owner = me->GetCharmerOrOwner())
{
if (!me->IsWithinDist(owner, 40.f))
{
me->RemoveAura(SPELL_EGBERT);
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle());
}
}
if (me->HasAura(SPELL_EGBERT))
_events.ScheduleEvent(EVENT_RETURN, urandms(5, 20));
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_RETURN:
me->RemoveAura(SPELL_EGBERT);
break;
default:
break;
}
}
}
private:
EventMap _events;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_gen_egbertAI(creature);
}
};
enum PandarenMonkMisc
{
SPELL_PANDAREN_MONK = 69800,
EVENT_FOCUS = 1,
EVENT_EMOTE = 2,
EVENT_FOLLOW = 3,
EVENT_DRINK = 4
};
class npc_pet_gen_pandaren_monk : public CreatureScript
{
public:
npc_pet_gen_pandaren_monk() : CreatureScript("npc_pet_gen_pandaren_monk") {}
struct npc_pet_gen_pandaren_monkAI : public NullCreatureAI
{
npc_pet_gen_pandaren_monkAI(Creature* creature) : NullCreatureAI(creature) { }
void Reset() override
{
_events.Reset();
_events.ScheduleEvent(EVENT_FOCUS, 1000);
}
void EnterEvadeMode(EvadeReason why) override
{
if (!_EnterEvadeMode(why))
return;
Reset();
}
void ReceiveEmote(Player* /*player*/, uint32 emote) override
{
me->InterruptSpell(CURRENT_CHANNELED_SPELL);
me->StopMoving();
switch (emote)
{
case TEXT_EMOTE_BOW:
_events.ScheduleEvent(EVENT_FOCUS, 1000);
break;
case TEXT_EMOTE_DRINK:
_events.ScheduleEvent(EVENT_DRINK, 1000);
break;
}
}
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
if (Unit* owner = me->GetCharmerOrOwner())
if (!me->IsWithinDist(owner, 30.f))
me->InterruptSpell(CURRENT_CHANNELED_SPELL);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_FOCUS:
if (Unit* owner = me->GetCharmerOrOwner())
me->SetFacingToObject(owner);
_events.ScheduleEvent(EVENT_EMOTE, 1000);
break;
case EVENT_EMOTE:
me->HandleEmoteCommand(EMOTE_ONESHOT_BOW);
_events.ScheduleEvent(EVENT_FOLLOW, 1000);
break;
case EVENT_FOLLOW:
if (Unit* owner = me->GetCharmerOrOwner())
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
break;
case EVENT_DRINK:
me->CastSpell(me, SPELL_PANDAREN_MONK, false);
break;
default:
break;
}
}
}
private:
EventMap _events;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_pet_gen_pandaren_monkAI(creature);
}
};
enum Mojo
{
SAY_MOJO = 0,
SPELL_FEELING_FROGGY = 43906,
SPELL_SEDUCTION_VISUAL = 43919
};
class npc_pet_gen_mojo : public CreatureScript
{
public:
npc_pet_gen_mojo() : CreatureScript("npc_pet_gen_mojo") { }
struct npc_pet_gen_mojoAI : public ScriptedAI
{
npc_pet_gen_mojoAI(Creature* creature) : ScriptedAI(creature)
{
}
void Reset() override
{
_victimGUID.Clear();
if (Unit* owner = me->GetOwner())
me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f);
}
void EnterCombat(Unit* /*who*/) override { }
void UpdateAI(uint32 /*diff*/) override { }
void ReceiveEmote(Player* player, uint32 emote) override
{
me->HandleEmoteCommand(emote);
Unit* owner = me->GetOwner();
if (emote != TEXT_EMOTE_KISS || !owner || owner->GetTypeId() != TYPEID_PLAYER ||
owner->ToPlayer()->GetTeam() != player->GetTeam())
{
return;
}
Talk(SAY_MOJO, player);
if (!_victimGUID.IsEmpty())
if (Player* victim = ObjectAccessor::GetPlayer(*me, _victimGUID))
victim->RemoveAura(SPELL_FEELING_FROGGY);
_victimGUID = player->GetGUID();
DoCast(player, SPELL_FEELING_FROGGY, true);
DoCast(me, SPELL_SEDUCTION_VISUAL, true);
me->GetMotionMaster()->MoveFollow(player, 0.0f, 0.0f);
}
private:
ObjectGuid _victimGUID;
};
CreatureAI* GetAI(Creature* creature) const override
{
return new npc_pet_gen_mojoAI(creature);
}
};
void AddSC_generic_pet_scripts()
{
new npc_pet_gen_baby_blizzard_bear();
new npc_pet_gen_egbert();
new npc_pet_gen_pandaren_monk();
new npc_pet_gen_mojo();
}