AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
spell_hun_chimera_shot Class Reference
Inheritance diagram for spell_hun_chimera_shot:
SpellScript _SpellScript

Private Member Functions

 PrepareSpellScript (spell_hun_chimera_shot)
 
bool Validate (SpellInfo const *) override
 
void HandleScriptEffect (SpellEffIndex)
 
void Register () override
 

Additional Inherited Members

- Public Member Functions inherited from SpellScript
bool _Validate (SpellInfo const *entry) override
 
bool _Load (Spell *spell)
 
void _InitHit ()
 
bool _IsEffectPrevented (SpellEffIndex effIndex)
 
bool _IsDefaultEffectPrevented (SpellEffIndex effIndex)
 
void _PrepareScriptCall (SpellScriptHookType hookType)
 
void _FinishScriptCall ()
 
bool IsInCheckCastHook () const
 
bool IsInTargetHook () const
 
bool IsInHitPhase () const
 
bool IsInEffectHook () const
 
UnitGetCaster ()
 
UnitGetOriginalCaster ()
 
SpellInfo const * GetSpellInfo ()
 
SpellValue const * GetSpellValue ()
 
WorldLocation const * GetExplTargetDest ()
 
void SetExplTargetDest (WorldLocation &loc)
 
WorldObjectGetExplTargetWorldObject ()
 
UnitGetExplTargetUnit ()
 
GameObjectGetExplTargetGObj ()
 
ItemGetExplTargetItem ()
 
UnitGetHitUnit ()
 
CreatureGetHitCreature ()
 
PlayerGetHitPlayer ()
 
ItemGetHitItem ()
 
GameObjectGetHitGObj ()
 
WorldLocationGetHitDest ()
 
int32 GetHitDamage ()
 
void SetHitDamage (int32 damage)
 
void PreventHitDamage ()
 
int32 GetHitHeal ()
 
void SetHitHeal (int32 heal)
 
void PreventHitHeal ()
 
SpellGetSpell ()
 
AuraGetHitAura ()
 
void PreventHitAura ()
 
void PreventHitEffect (SpellEffIndex effIndex)
 
void PreventHitDefaultEffect (SpellEffIndex effIndex)
 
int32 GetEffectValue () const
 
void SetEffectValue (int32 value)
 
ItemGetCastItem ()
 
void CreateItem (uint32 effIndex, uint32 itemId)
 
SpellInfo const * GetTriggeringSpell ()
 
void FinishCast (SpellCastResult result)
 
void Cancel ()
 
void SetCustomCastResultMessage (SpellCustomErrors result)
 
- Public Member Functions inherited from _SpellScript
 _SpellScript ()
 
virtual ~_SpellScript ()
 
virtual void _Register ()
 
virtual void _Unload ()
 
virtual void _Init (std::string const *scriptname, uint32 spellId)
 
std::string const * _GetScriptName () const
 
virtual void Register ()=0
 
virtual bool Validate (SpellInfo const *)
 
virtual bool Load ()
 
virtual void Unload ()
 
- Static Public Member Functions inherited from _SpellScript
static bool ValidateSpellInfo (std::initializer_list< uint32 > spellIds)
 
template<class T >
static bool ValidateSpellInfo (T const &spellIds)
 
- Public Attributes inherited from SpellScript
HookList< CastHandlerBeforeCast
 
HookList< CastHandlerOnCast
 
HookList< CastHandlerAfterCast
 
HookList< CheckCastHandlerOnCheckCast
 
HookList< EffectHandlerOnEffectLaunch
 
HookList< EffectHandlerOnEffectLaunchTarget
 
HookList< EffectHandlerOnEffectHit
 
HookList< EffectHandlerOnEffectHitTarget
 
HookList< BeforeHitHandlerBeforeHit
 
HookList< HitHandlerOnHit
 
HookList< HitHandlerAfterHit
 
HookList< ObjectAreaTargetSelectHandlerOnObjectAreaTargetSelect
 
HookList< ObjectTargetSelectHandlerOnObjectTargetSelect
 
HookList< DestinationTargetSelectHandlerOnDestinationTargetSelect
 
virtual bool _Validate (SpellInfo const *entry)
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Function Documentation

◆ HandleScriptEffect()

void spell_hun_chimera_shot::HandleScriptEffect ( SpellEffIndex  )
inlineprivate
Todo:
: Caster uses unitTarget?
430 {
431 Unit* caster = GetCaster();
432 if (Unit* unitTarget = GetHitUnit())
433 {
434 uint32 spellId = 0;
435 int32 basePoint = 0;
436 Unit::AuraApplicationMap& Auras = unitTarget->GetAppliedAuras();
437 for (Unit::AuraApplicationMap::iterator i = Auras.begin(); i != Auras.end(); ++i)
438 {
439 Aura* aura = i->second->GetBase();
440 if (aura->GetCasterGUID() != caster->GetGUID())
441 continue;
442
443 // Search only Serpent Sting, Viper Sting, Scorpid Sting auras
444 flag96 familyFlag = aura->GetSpellInfo()->SpellFamilyFlags;
445 if (!(familyFlag[1] & 0x00000080 || familyFlag[0] & 0x0000C000))
446 continue;
447 if (AuraEffect* aurEff = aura->GetEffect(0))
448 {
449 // Serpent Sting - Instantly deals 40% of the damage done by your Serpent Sting.
450 if (familyFlag[0] & 0x4000)
451 {
452 int32 TickCount = aurEff->GetTotalTicks();
454 basePoint = aurEff->GetAmount();
455 ApplyPct(basePoint, TickCount * 40);
456 basePoint = unitTarget->SpellDamageBonusTaken(caster, aura->GetSpellInfo(), basePoint, DOT, aura->GetStackAmount());
457 }
458 // Viper Sting - Instantly restores mana to you equal to 60% of the total amount drained by your Viper Sting.
459 else if (familyFlag[1] & 0x00000080)
460 {
461 int32 TickCount = aura->GetEffect(0)->GetTotalTicks();
463
464 // Amount of one aura tick
465 basePoint = int32(CalculatePct(unitTarget->GetMaxPower(POWER_MANA), aurEff->GetAmount()));
466 int32 casterBasePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 50;
467 if (basePoint > casterBasePoint)
468 basePoint = casterBasePoint;
469 ApplyPct(basePoint, TickCount * 60);
470 }
471 // Scorpid Sting - Attempts to Disarm the target for 10 sec. This effect cannot occur more than once per 1 minute.
472 else if (familyFlag[0] & 0x00008000)
473 {
474 if (caster->ToPlayer()) // Scorpid Sting - Add 1 minute cooldown
475 {
477 break;
478
480 }
481
483 }
484
485 // Refresh aura duration
486 aura->RefreshDuration();
487 aurEff->ChangeAmount(aurEff->CalculateAmount(caster), false);
488 }
489 break;
490 }
491
492 if (spellId)
493 caster->CastCustomSpell(unitTarget, spellId, &basePoint, 0, 0, true);
494 }
495 }
std::int32_t int32
Definition: Define.h:104
std::uint32_t uint32
Definition: Define.h:108
T ApplyPct(T &base, U pct)
Definition: Util.h:73
T CalculatePct(T base, U pct)
Definition: Util.h:61
@ DOT
Definition: Unit.h:437
@ SPELL_HUNTER_CHIMERA_SHOT_SCORPID
Definition: spell_hunter.cpp:53
@ SPELL_HUNTER_CHIMERA_SHOT_VIPER
Definition: spell_hunter.cpp:52
@ SPELL_HUNTER_CHIMERA_SHOT_SERPENT
Definition: spell_hunter.cpp:51
@ POWER_MANA
Definition: SharedDefines.h:241
Definition: Util.h:446
Player * ToPlayer()
Definition: Object.h:195
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
bool HasSpellCooldown(uint32 spell_id) const override
Definition: Player.cpp:16214
void AddSpellCooldown(uint32 spell_id, uint32 itemid, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition: Player.cpp:10983
Definition: Unit.h:1290
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1299
SpellCastResult CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1226
Definition: SpellAuraEffects.h:39
int32 GetTotalTicks() const
Definition: SpellAuraEffects.cpp:7006
Definition: SpellAuras.h:87
void RefreshDuration(bool withMods=false)
Definition: SpellAuras.cpp:894
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:105
AuraEffect * GetEffect(uint8 effIndex) const
Definition: SpellAuras.h:175
uint8 GetStackAmount() const
Definition: SpellAuras.h:148
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:100
flag96 SpellFamilyFlags
Definition: SpellInfo.h:386
Unit * GetHitUnit()
Definition: SpellScript.cpp:448
Unit * GetCaster()
Definition: SpellScript.cpp:401

References Player::AddSpellCooldown(), ApplyPct(), CalculatePct(), Unit::CastCustomSpell(), DOT, SpellScript::GetCaster(), Aura::GetCasterGUID(), Aura::GetEffect(), Object::GetGUID(), SpellScript::GetHitUnit(), Aura::GetSpellInfo(), Aura::GetStackAmount(), AuraEffect::GetTotalTicks(), Player::HasSpellCooldown(), POWER_MANA, Aura::RefreshDuration(), SPELL_HUNTER_CHIMERA_SHOT_SCORPID, SPELL_HUNTER_CHIMERA_SHOT_SERPENT, SPELL_HUNTER_CHIMERA_SHOT_VIPER, SpellInfo::SpellFamilyFlags, and Object::ToPlayer().

Referenced by Register().

◆ PrepareSpellScript()

spell_hun_chimera_shot::PrepareSpellScript ( spell_hun_chimera_shot  )
private

◆ Register()

void spell_hun_chimera_shot::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

498 {
500 }
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:827
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
void HandleScriptEffect(SpellEffIndex)
Definition: spell_hunter.cpp:429

References EFFECT_0, HandleScriptEffect(), SpellScript::OnEffectHitTarget, SPELL_EFFECT_SCRIPT_EFFECT, and SpellEffectFn.

◆ Validate()

bool spell_hun_chimera_shot::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual