TrinityCore
pet_generic.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Spell and creature scripts in this file are not ordered but grouped(all scripts related to same creature in same place).
20 * Scriptnames of spells and creatures in this file should be prefixed with "spell_pet_gen_" and "npc_pet_gen_" respectively.
21 */
22
23#include "ScriptMgr.h"
24#include "MotionMaster.h"
25#include "PassiveAI.h"
26#include "PetDefines.h"
27#include "Player.h"
28#include "ScriptedCreature.h"
29#include "SpellAuraEffects.h"
30#include "SpellScript.h"
31#include "TemporarySummon.h"
32
34{
39 EVENT_DRINK = 4
40};
41
43{
45
46 void Reset() override
47 {
48 _events.Reset();
50 }
51
52 void EnterEvadeMode(EvadeReason why) override
53 {
54 if (!_EnterEvadeMode(why))
55 return;
56
57 Reset();
58 }
59
60 void ReceiveEmote(Player* /*player*/, uint32 emote) override
61 {
63 me->StopMoving();
64
65 switch (emote)
66 {
67 case TEXT_EMOTE_BOW:
69 break;
72 break;
73 }
74 }
75
76 void UpdateAI(uint32 diff) override
77 {
78 _events.Update(diff);
79
80 if (Unit* owner = me->GetCharmerOrOwner())
81 if (!me->IsWithinDist(owner, 30.f))
83
84 while (uint32 eventId = _events.ExecuteEvent())
85 {
86 switch (eventId)
87 {
88 case EVENT_FOCUS:
89 if (Unit* owner = me->GetCharmerOrOwner())
90 me->SetFacingToObject(owner);
92 break;
93 case EVENT_EMOTE:
96 break;
97 case EVENT_FOLLOW:
98 if (Unit* owner = me->GetCharmerOrOwner())
100 break;
101 case EVENT_DRINK:
103 break;
104 default:
105 break;
106 }
107 }
108 }
109
110private:
112};
113
115{
117
121
123{
124 npc_pet_gen_soul_trader(Creature* creature) : ScriptedAI(creature) { }
125
126 void OnDespawn() override
127 {
128 if (Unit* owner = me->GetOwner())
130 }
131
132 void JustAppeared() override
133 {
135 if (Unit* owner = me->GetOwner())
137
139 }
140};
141
143{
147
148 NPC_LICH_PET = 36979
150
151// 69735 - Lich Pet OnSummon
153{
154 bool Validate(SpellInfo const* /*spellInfo*/) override
155 {
157 }
158
159 void HandleScript(SpellEffIndex /*effIndex*/)
160 {
161 Unit* target = GetHitUnit();
162 target->CastSpell(target, SPELL_LICH_PET_AURA, true);
163 }
164
165 void Register() override
166 {
168 }
169};
170
171// 69736 - Lich Pet Aura Remove
173{
174 bool Validate(SpellInfo const* /*spellInfo*/) override
175 {
177 }
178
179 void HandleScript(SpellEffIndex /*effIndex*/)
180 {
182 }
183
184 void Register() override
185 {
187 }
188};
189
190// 69732 - Lich Pet Aura
192{
193 bool Validate(SpellInfo const* /*spellInfo*/) override
194 {
196 }
197
198 bool CheckProc(ProcEventInfo& eventInfo)
199 {
200 return (eventInfo.GetProcTarget()->GetTypeId() == TYPEID_PLAYER);
201 }
202
203 void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
204 {
206
207 Unit* owner = GetUnitOwner();
208
209 std::list<TempSummon*> minionList;
210 owner->GetAllMinionsByEntry(minionList, NPC_LICH_PET);
211 for (TempSummon* minion : minionList)
212 owner->CastSpell(minion, SPELL_LICH_PET_AURA_ONKILL, true);
213 }
214
215 void Register() override
216 {
219 }
220};
221
222// 70050 - [DND] Lich Pet
224{
225 bool Validate(SpellInfo const* /*spellInfo*/) override
226 {
228 }
229
230 void OnPeriodic(AuraEffect const* /*aurEff*/)
231 {
232 // The chance to cast this spell is not 100%.
233 // Triggered spell roots creature for 3 sec and plays anim and sound (doesn't require any script).
234 // Emote and sound never shows up in sniffs because both comes from spell visual directly.
235 // Both 69683 and 70050 can trigger spells at once and are not linked together in any way.
236 // Effect of 70050 is overlapped by effect of 69683 but not instantly (69683 is a series of spell casts, takes longer to execute).
237 // However, for some reason emote is not played if creature is idle and only if creature is moving or is already rooted.
238 // For now it's scripted manually in script below to play emote always.
239 if (roll_chance_i(50))
241 }
242
243 void Register() override
244 {
246 }
247};
248
249// 70049 - [DND] Lich Pet
251{
252 void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
253 {
255 }
256
257 void Register() override
258 {
260 }
261};
262
263// 69682 - Lil' K.T. Focus
265{
266 bool Validate(SpellInfo const* spellInfo) override
267 {
268 return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
269 }
270
271 void HandleScript(SpellEffIndex /*effIndex*/)
272 {
274 }
275
276 void Register() override
277 {
279 }
280};
281
283{
292}
uint32_t uint32
Definition: Define.h:142
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
#define PET_FOLLOW_ANGLE
Definition: PetDefines.h:98
#define PET_FOLLOW_DIST
Definition: PetDefines.h:97
bool roll_chance_i(int chance)
Definition: Random.h:59
#define RegisterCreatureAI(ai_name)
Definition: ScriptMgr.h:1380
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ EMOTE_ONESHOT_CUSTOM_SPELL_01
@ EMOTE_ONESHOT_BOW
@ TEXT_EMOTE_BOW
@ TEXT_EMOTE_DRINK
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PROC_TRIGGER_SPELL
@ SPELL_AURA_MOD_ROOT
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define AuraEffectProcFn(F, I, N)
Definition: SpellScript.h:2160
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectApplyFn(F, I, N, M)
Definition: SpellScript.h:2029
#define AuraCheckProcFn(F)
Definition: SpellScript.h:2130
EvadeReason
Definition: UnitAICommon.h:30
@ CURRENT_CHANNELED_SPELL
Definition: Unit.h:591
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:2028
Unit * GetTarget() const
HookList< CheckProcHandler > DoCheckProc
Definition: SpellScript.h:2129
HookList< EffectProcHandler > OnEffectProc
Definition: SpellScript.h:2155
Unit * GetUnitOwner() const
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:299
virtual void JustAppeared()
Definition: CreatureAI.cpp:194
Creature *const me
Definition: CreatureAI.h:61
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void Reset()
Definition: EventMap.cpp:21
void MoveFollow(Unit *target, float dist, ChaseAngle angle, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_ACTIVE)
TypeID GetTypeId() const
Definition: Object.h:173
Unit * GetProcTarget() const
Definition: Unit.h:495
int32 CalcValue(WorldObject const *caster=nullptr, int32 const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
Definition: SpellInfo.cpp:495
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition: SpellInfo.h:577
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition: Unit.cpp:12671
void StopMoving()
Definition: Unit.cpp:10049
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1200
void GetAllMinionsByEntry(std::list< TempSummon * > &Minions, uint32 entry)
Definition: Unit.cpp:6235
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition: Unit.cpp:1598
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:3017
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
Unit * GetOwner() const
Definition: Object.cpp:2229
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1142
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
bool CheckProc(ProcEventInfo &eventInfo)
void HandleProc(AuraEffect *, ProcEventInfo &)
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *spellInfo) override
void HandleScript(SpellEffIndex)
void HandleScript(SpellEffIndex)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void OnPeriodic(AuraEffect const *)
LichPet
@ SPELL_LICH_PET_AURA
@ NPC_LICH_PET
@ SPELL_LICH_PET_AURA_ONKILL
@ SPELL_LICH_PET_EMOTE
PandarenMonkMisc
Definition: pet_generic.cpp:34
@ EVENT_FOLLOW
Definition: pet_generic.cpp:38
@ EVENT_EMOTE
Definition: pet_generic.cpp:37
@ EVENT_DRINK
Definition: pet_generic.cpp:39
@ EVENT_FOCUS
Definition: pet_generic.cpp:36
@ SPELL_PANDAREN_MONK
Definition: pet_generic.cpp:35
SoulTrader
@ SAY_SOUL_TRADER_INTRO
@ SPELL_ETHEREAL_ONSUMMON
@ SPELL_ETHEREAL_PET_REMOVE_AURA
void AddSC_generic_pet_scripts()
npc_pet_gen_pandaren_monk(Creature *creature)
Definition: pet_generic.cpp:44
void EnterEvadeMode(EvadeReason why) override
Definition: pet_generic.cpp:52
void ReceiveEmote(Player *, uint32 emote) override
Definition: pet_generic.cpp:60
void UpdateAI(uint32 diff) override
Definition: pet_generic.cpp:76
npc_pet_gen_soul_trader(Creature *creature)
void JustAppeared() override
void OnDespawn() override