TrinityCore
Loading...
Searching...
No Matches
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
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
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
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
169};
170
171// 69736 - Lich Pet Aura Remove
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
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(50))
241 }
242
247};
248
249// 70049 - [DND] Lich Pet
262
263// 69682 - Lil' K.T. Focus
265{
266 bool Validate(SpellInfo const* spellInfo) override
267 {
268 return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) });
269 }
270
275
280};
281
uint32_t uint32
Definition Define.h:154
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
#define PET_FOLLOW_ANGLE
Definition PetDefines.h:99
#define PET_FOLLOW_DIST
Definition PetDefines.h:98
bool roll_chance(T chance)
Definition Random.h:55
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ 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)
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraCheckProcFn(F)
EvadeReason
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:599
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
HookList< CheckProcHandler > DoCheckProc
HookList< EffectProcHandler > OnEffectProc
Unit * GetUnitOwner() const
TypeID GetTypeId() const
Definition BaseEntity.h:166
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
virtual void JustAppeared()
Creature *const me
Definition CreatureAI.h:63
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
void MoveFollow(Unit *target, float dist, Optional< ChaseAngle > angle={}, Optional< Milliseconds > duration={}, bool ignoreTargetWalk=false, MovementSlot slot=MOTION_SLOT_ACTIVE, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
Unit * GetProcTarget() const
Definition Unit.h:501
int32 CalcValueAsInt(WorldObject const *caster=nullptr, SpellEffectValue const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:588
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
int32 GetEffectValueAsInt() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition Unit.cpp:13307
void StopMoving()
Definition Unit.cpp:10680
Unit * GetCharmerOrOwner() const
Definition Unit.h:1221
void GetAllMinionsByEntry(std::list< TempSummon * > &Minions, uint32 entry)
Definition Unit.cpp:6420
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition Unit.cpp:1657
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition Unit.cpp:3159
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
Unit * GetOwner() const
Definition Object.cpp:1598
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:496
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
@ EVENT_FOLLOW
@ EVENT_EMOTE
@ EVENT_DRINK
@ EVENT_FOCUS
@ SPELL_PANDAREN_MONK
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)
void EnterEvadeMode(EvadeReason why) override
void ReceiveEmote(Player *, uint32 emote) override
void UpdateAI(uint32 diff) override
npc_pet_gen_soul_trader(Creature *creature)
void JustAppeared() override
void OnDespawn() override