Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
spell_hunter.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/*
7 * Scripts for spells with SPELLFAMILY_HUNTER, SPELLFAMILY_PET and SPELLFAMILY_GENERIC spells used by hunter players.
8 * Ordered alphabetically using scriptname.
9 * Scriptnames of files in this file should be prefixed with "spell_hun_".
10 */
11
12#include "Pet.h"
13#include "ScriptMgr.h"
14#include "Cell.h"
15#include "CellImpl.h"
16#include "GridNotifiers.h"
17#include "GridNotifiersImpl.h"
18#include "SpellScript.h"
19#include "SpellAuraEffects.h"
20
49
51{
52public:
53 spell_hun_a_murder_of_crows() : SpellScriptLoader("spell_hun_a_murder_of_crows") { }
54
56 {
58
59 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
60 {
61 if (!sSpellMgr->GetSpellInfo(SPELL_HUNTER_A_MURDER_OF_CROWS))
62 return false;
63 return true;
64 }
65
66 void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
67 {
68 if (Unit* target = GetTarget())
69 {
70 if (Player* player = GetCaster()->ToPlayer())
71 {
72 player->CastSpell(target, SPELL_HUNTER_CROW_TRIGGER, true); // crow trigger+visual + (Dummy: cdr at 20% target HP NYI)
73 player->CastSpell(target, SPELL_HUNTER_CROW_DMG, true);
74 player->CastSpell(target, SPELL_HUNTER_DELAYED_CROW, true);
75 player->CastSpell(target, SPELL_HUNTER_CROW_DMG, true);
76 player->CastSpell(target, SPELL_HUNTER_DELAYED_CROW2, true);
77 player->CastSpell(target, SPELL_HUNTER_CROW_DMG, true);
78 }
79 }
80 }
81
86 };
87
92};
93
94// 53209 - Chimera Shot
96{
97public:
98 spell_hun_chimera_shot() : SpellScriptLoader("spell_hun_chimera_shot") { }
99
101 {
103
104 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
105 {
106 if (!sSpellMgr->GetSpellInfo(SPELL_HUNTER_CHIMERA_SHOT_HEAL) ||
108 return false;
109 return true;
110 }
111
113 {
115 }
116
118 {
120
121 if (Aura* aur = GetHitUnit()->GetAura(SPELL_HUNTER_SERPENT_STING, GetCaster()->GetGUID()))
122 aur->SetDuration(aur->GetSpellInfo()->GetMaxDuration(), true);
123 }
124
129 };
130
135};
136
137// 77767 - Cobra Shot
139{
140public:
141 spell_hun_cobra_shot() : SpellScriptLoader("spell_hun_cobra_shot") { }
142
144 {
146
147 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
148 {
151 return false;
152 return true;
153 }
154
156 {
158 }
159
161 {
163
164 if (Aura* aur = GetHitUnit()->GetAura(SPELL_HUNTER_SERPENT_STING, GetCaster()->GetGUID()))
165 {
166 int32 newDuration = aur->GetDuration() + GetEffectValue() * IN_MILLISECONDS;
167 aur->SetDuration(std::min(newDuration, aur->GetMaxDuration()), true);
168 }
169 }
170
175 };
176
181};
182
183// 82926 - Fire!
185{
186public:
187 spell_hun_fire() : SpellScriptLoader("spell_hun_fire") { }
188
190 {
192
193 void HandleEffectCalcSpellMod(AuraEffect const* aurEff, SpellModifier*& spellMod)
194 {
195 if (!spellMod)
196 {
197 spellMod = new SpellModifier(GetAura());
198 spellMod->op = SPELLMOD_CASTING_TIME;
199 spellMod->type = SPELLMOD_PCT;
200 spellMod->spellId = GetId();
201 spellMod->mask = GetSpellInfo()->Effects[aurEff->GetEffIndex()].SpellClassMask;
202 }
203
204 spellMod->value = -(float)aurEff->GetAmount();
205 }
206
211 };
212
214 {
215 return new spell_hun_fire_AuraScript();
216 }
217};
218
219// -19464 Improved Serpent Sting
221{
222public:
223 spell_hun_improved_serpent_sting() : SpellScriptLoader("spell_hun_improved_serpent_sting") { }
224
226 {
228
229 void HandleEffectCalcSpellMod(AuraEffect const* aurEff, SpellModifier*& spellMod)
230 {
231 if (!spellMod)
232 {
233 spellMod = new SpellModifier(GetAura());
234 spellMod->op = SpellModOp(aurEff->GetMiscValue());
235 spellMod->type = SPELLMOD_PCT;
236 spellMod->spellId = GetId();
237 spellMod->mask = GetSpellInfo()->Effects[aurEff->GetEffIndex()].SpellClassMask;
238 }
239
240 spellMod->value = (float)aurEff->GetAmount();
241 }
242
247 };
248
253};
254
255// 53412 - Invigoration
257{
258public:
259 spell_hun_invigoration() : SpellScriptLoader("spell_hun_invigoration") { }
260
262 {
264
265 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
266 {
268 return false;
269 return true;
270 }
271
273 {
274 if (Unit* unitTarget = GetHitUnit())
275 if (AuraEffect* aurEff = unitTarget->GetDummyAuraEffect(SPELLFAMILY_HUNTER, 3487, 0))
276 if (roll_chance_i(aurEff->GetAmount()))
277 unitTarget->CastSpell(unitTarget, SPELL_HUNTER_INVIGORATION_TRIGGERED, true);
278 }
279
284 };
285
290};
291
292// 53478 - Last Stand Pet
294{
295public:
296 spell_hun_last_stand_pet() : SpellScriptLoader("spell_hun_last_stand_pet") { }
297
299 {
301
302 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
303 {
305 return false;
306 return true;
307 }
308
309 void HandleDummy(SpellEffIndex /*effIndex*/)
310 {
311 Unit* caster = GetCaster();
312 int32 healthModSpellBasePoints0 = int32(caster->CountPctFromMaxHealth(30));
313 caster->CastCustomSpell(caster, SPELL_HUNTER_PET_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL);
314 }
315
320 };
321
326};
327
328// 53271 - Masters Call
330{
331public:
332 spell_hun_masters_call() : SpellScriptLoader("spell_hun_masters_call") { }
333
335 {
337
338 bool Validate(SpellInfo const* spellInfo) OVERRIDE
339 {
341 !sSpellMgr->GetSpellInfo(spellInfo->Effects[EFFECT_0].CalcValue()))
342 return false;
343 return true;
344 }
345
346 void HandleDummy(SpellEffIndex /*effIndex*/)
347 {
348 if (Unit* ally = GetHitUnit())
349 if (Player* caster = GetCaster()->ToPlayer())
350 if (Pet* target = caster->GetPet())
351 {
353 target->CastSpell(ally, GetEffectValue(), castMask);
354 }
355 }
356
358 {
359 if (Unit* target = GetHitUnit())
360 {
361 // Cannot be processed while pet is dead
363 target->CastSpell(target, SPELL_HUNTER_MASTERS_CALL_TRIGGERED, castMask);
364 }
365 }
366
372 };
373
378};
379
380// 34477 - Misdirection
382{
383public:
384 spell_hun_misdirection() : SpellScriptLoader("spell_hun_misdirection") { }
385
421
426};
427
428// 35079 - Misdirection (Proc)
454
455// 54044 - Pet Carrion Feeder
457{
458public:
459 spell_hun_pet_carrion_feeder() : SpellScriptLoader("spell_hun_pet_carrion_feeder") { }
460
462 {
464
466 {
467 if (!GetCaster()->IsPet())
468 return false;
469 return true;
470 }
471
472 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
473 {
475 return false;
476 return true;
477 }
478
480 {
481 Unit* caster = GetCaster();
482 float max_range = GetSpellInfo()->GetMaxRange(false);
483 WorldObject* result = NULL;
484 // search for nearby enemy corpse in range
487 caster->GetMap()->VisitFirstFound(caster->m_positionX, caster->m_positionY, max_range, searcher);
488 if (!result)
491 }
492
493 void HandleDummy(SpellEffIndex /*effIndex*/)
494 {
495 Unit* caster = GetCaster();
497 }
498
504 };
505
510};
511
512// 55709 - Pet Heart of the Phoenix
514{
515public:
516 spell_hun_pet_heart_of_the_phoenix() : SpellScriptLoader("spell_hun_pet_heart_of_the_phoenix") { }
517
519 {
521
523 {
524 if (!GetCaster()->IsPet())
525 return false;
526 return true;
527 }
528
529 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
530 {
532 return false;
533 return true;
534 }
535
536 void HandleScript(SpellEffIndex /*effIndex*/)
537 {
538 Unit* caster = GetCaster();
539 if (Unit* owner = caster->GetOwner())
541 {
542 owner->CastCustomSpell(SPELL_HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED, SPELLVALUE_BASE_POINT0, 100, caster, true);
544 }
545 }
546
551 };
552
557};
558
559// 82925 - Ready, Set, Aim...
561{
562public:
563 spell_hun_ready_set_aim() : SpellScriptLoader("spell_hun_ready_set_aim") { }
564
566 {
568
569 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
570 {
571 if (!sSpellMgr->GetSpellInfo(SPELL_HUNTER_FIRE))
572 return false;
573 return true;
574 }
575
576 void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
577 {
578 if (GetStackAmount() == 5)
579 {
580 GetTarget()->CastSpell(GetTarget(), SPELL_HUNTER_FIRE, true, NULL, aurEff);
582 }
583 }
584
589 };
590
595};
596
597// 37506 - Scatter Shot
599{
600public:
601 spell_hun_scatter_shot() : SpellScriptLoader("spell_hun_scatter_shot") { }
602
626
631};
632
633// 56641 - Steady Shot
635{
636public:
637 spell_hun_steady_shot() : SpellScriptLoader("spell_hun_steady_shot") { }
638
640 {
642
643 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
644 {
645 if (!sSpellMgr->GetSpellInfo(SPELL_HUNTER_STEADY_SHOT_FOCUS))
646 return false;
647 return true;
648 }
649
651 {
653 }
654
659
664 };
665
670};
671
672// 1515 - Tame Beast
674{
675public:
676 spell_hun_tame_beast() : SpellScriptLoader("spell_hun_tame_beast") { }
677
679 {
681
683 {
684 Unit* caster = GetCaster();
685 if (caster->GetTypeId() != TypeID::TYPEID_PLAYER)
687
688 if (!GetExplTargetUnit())
690
691 if (Creature* target = GetExplTargetUnit()->ToCreature())
692 {
693 if (target->getLevel() > caster->getLevel())
695
696 // use SMSG_PET_TAME_FAILURE?
697 if (!target->GetCreatureTemplate()->IsTameable(caster->ToPlayer()->CanTameExoticPets()))
699
700 if (caster->GetPetGUID())
702
703 if (caster->GetCharmGUID())
705 }
706 else
708
710 }
711
716 };
717
722};
723
724// 34497 - Thrill of the Hunt
726{
727public:
728 spell_hun_thrill_of_the_hunt() : SpellScriptLoader("spell_hun_thrill_of_the_hunt") { }
729
731 {
733
734 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
735 {
736 if (!sSpellMgr->GetSpellInfo(SPELL_HUNTER_THRILL_OF_THE_HUNT))
737 return false;
738 return true;
739 }
740
741 void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
742 {
744 //int32 focus = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), SpellSchoolMask(eventInfo.GetDamageInfo()->GetSchoolMask()));
745 //focus = CalculatePct(focus, aurEff->GetAmount());
746
747 //GetTarget()->CastCustomSpell(GetTarget(), SPELL_HUNTER_THRILL_OF_THE_HUNT, &focus, NULL, NULL, true, NULL, aurEff);
748 }
749
754 };
755
760};
761
@ IN_MILLISECONDS
Definition Common.h:125
std::int32_t int32
Definition Define.h:73
#define OVERRIDE
Definition Define.h:60
@ TYPEID_PLAYER
Definition Object.h:55
@ SPELLMOD_PCT
Definition Player.h:67
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELLFAMILY_HUNTER
SpellCastResult
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_DUMMY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK
@ AURA_EFFECT_HANDLE_REAL
#define sSpellMgr
Definition SpellMgr.h:744
#define SpellCheckCastFn(F)
#define AuraEffectProcFn(F, I, N)
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraCheckProcFn(F)
#define SpellHitFn(F)
#define AuraEffectCalcSpellModFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
@ TARGET_CHECK_ENEMY
SpellModOp
Definition Unit.h:72
@ SPELLMOD_CASTING_TIME
Definition Unit.h:83
@ SPELLVALUE_BASE_POINT0
Definition Unit.h:114
@ AURA_REMOVE_BY_DEFAULT
Definition Unit.h:407
TriggerCastFlags
Definition Unit.h:415
@ TRIGGERED_FULL_MASK
Will ignore most target checks (mostly DBC target checks).
Definition Unit.h:435
@ TRIGGERED_IGNORE_CASTER_AURASTATE
Will ignore shapeshift checks.
Definition Unit.h:428
@ CURRENT_AUTOREPEAT_SPELL
Definition Unit.h:1111
bool roll_chance_i(int chance)
Definition Util.h:89
int32 GetMiscValue() const
uint32 GetEffIndex() const
int32 GetAmount() const
void PreventDefaultAction()
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
SpellInfo const * GetSpellInfo() const
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetCaster() const
HookList< EffectCalcSpellModHandler > DoEffectCalcSpellMod
Aura * GetAura() const
Unit * GetTarget() const
HookList< CheckProcHandler > DoCheckProc
HookList< EffectProcHandler > OnEffectProc
uint8 GetStackAmount() const
uint32 GetId() const
void VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &notifier)
Definition Map.h:715
Player * ToPlayer()
Definition Object.h:204
TypeID GetTypeId() const
Definition Object.h:131
Definition Pet.h:28
void SendAttackSwingCancelAttack()
Definition Player.cpp:15465
bool CanTameExoticPets() const
Definition Player.h:2624
flag128 SpellClassMask
Definition SpellInfo.h:109
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition SpellInfo.h:255
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
Unit * GetExplTargetUnit()
HookList< CheckCastHandler > OnCheckCast
SpellInfo const * GetSpellInfo()
HookList< HitHandler > OnHit
HookList< EffectHandler > OnEffectHit
HookList< EffectHandler > OnEffectHitTarget
Unit * GetHitUnit()
int32 GetEffectValue()
Unit * GetCaster()
SpellScriptLoader(const char *name)
Definition Unit.h:1367
Unit * GetOwner() const
Definition Unit.cpp:2339
uint64 GetCharmGUID() const
Definition Unit.h:2079
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
uint64 GetPetGUID() const
Definition Unit.h:2087
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
Unit * GetRedirectThreatTarget()
Definition Unit.cpp:7158
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void ResetRedirectThreat()
Definition Unit.h:2720
uint32 CountPctFromMaxHealth(int32 pct) const
Definition Unit.h:1633
uint8 getLevel() const
Definition Unit.h:1528
bool AttackStop()
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition Unit.cpp:1365
Map * GetMap() const
Definition Object.h:740
AuraScript * GetAuraScript() const OVERRIDE
PrepareSpellScript(spell_hun_chimera_shot_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_hun_cobra_shot_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
void HandleEffectCalcSpellMod(AuraEffect const *aurEff, SpellModifier *&spellMod)
PrepareAuraScript(spell_hun_fire_AuraScript)
AuraScript * GetAuraScript() const OVERRIDE
void HandleEffectCalcSpellMod(AuraEffect const *aurEff, SpellModifier *&spellMod)
AuraScript * GetAuraScript() const OVERRIDE
PrepareSpellScript(spell_hun_invigoration_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_hun_last_stand_pet_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
bool Validate(SpellInfo const *spellInfo) OVERRIDE
PrepareSpellScript(spell_hun_masters_call_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
PrepareAuraScript(spell_hun_misdirection_AuraScript)
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
void HandleProc(AuraEffect const *aurEff, ProcEventInfo &)
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
AuraScript * GetAuraScript() const OVERRIDE
AuraScript * GetAuraScript() const OVERRIDE
PrepareSpellScript(spell_hun_pet_carrion_feeder_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
PrepareAuraScript(spell_hun_ready_set_aim_AuraScript)
void OnApply(AuraEffect const *aurEff, AuraEffectHandleModes)
AuraScript * GetAuraScript() const OVERRIDE
PrepareSpellScript(spell_hun_scatter_shot_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_hun_steady_shot_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_hun_tame_beast_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
void HandleEffectProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
AuraScript * GetAuraScript() const OVERRIDE
@ SPELL_HUNTER_INVIGORATION_TRIGGERED
@ SPELL_HUNTER_PET_HEART_OF_THE_PHOENIX
@ SPELL_HUNTER_GENERIC_ENERGIZE_FOCUS
@ SPELL_HUNTER_CROW_DMG
@ SPELL_HUNTER_STEADY_SHOT_FOCUS
@ SPELL_HUNTER_MISDIRECTION_PROC
@ SPELL_HUNTER_SERPENT_STING
@ SPELL_HUNTER_LOCK_AND_LOAD
@ SPELL_HUNTER_MASTERS_CALL_TRIGGERED
@ SPELL_HUNTER_THRILL_OF_THE_HUNT
@ SPELL_HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF
@ SPELL_HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED
@ SPELL_HUNTER_DELAYED_CROW2
@ SPELL_HUNTER_CHIMERA_SHOT_HEAL
@ SPELL_HUNTER_FIRE
@ SPELL_HUNTER_A_MURDER_OF_CROWS
@ SPELL_HUNTER_CROW_TRIGGER
@ SPELL_HUNTER_PET_CARRION_FEEDER_TRIGGERED
@ SPELL_HUNTER_PET_LAST_STAND_TRIGGERED
@ SPELL_HUNTER_BESTIAL_WRATH
@ SPELL_HUNTER_DELAYED_CROW
void AddSC_hunter_spell_scripts()
float m_positionX
Definition Object.h:287
float m_positionY
Definition Object.h:288
SpellModOp op
Definition Player.h:171
SpellModType type
Definition Player.h:172
uint32 spellId
Definition Player.h:176
flag128 mask
Definition Player.h:175
float value
Definition Player.h:174