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

Private Member Functions

 PrepareSpellScript (spell_item_mad_alchemists_potion)
 
void SecondaryEffect ()
 
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 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
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Function Documentation

◆ PrepareSpellScript()

spell_item_mad_alchemists_potion::PrepareSpellScript ( spell_item_mad_alchemists_potion  )
private

◆ Register()

void spell_item_mad_alchemists_potion::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

5063 {
5065 }
#define SpellCastFn(F)
Definition SpellScript.h:324
HookList< CastHandler > AfterCast
Definition SpellScript.h:323
void SecondaryEffect()
Definition spell_item.cpp:5002

References SpellScript::AfterCast, SecondaryEffect(), and SpellCastFn.

◆ SecondaryEffect()

void spell_item_mad_alchemists_potion::SecondaryEffect ( )
inlineprivate
5003 {
5004 std::vector<uint32> availableElixirs =
5005 {
5006 // Battle Elixirs
5007 33720, // Onslaught Elixir (28102)
5008 54452, // Adept's Elixir (28103)
5009 33726, // Elixir of Mastery (28104)
5010 28490, // Elixir of Major Strength (22824)
5011 28491, // Elixir of Healing Power (22825)
5012 28493, // Elixir of Major Frost Power (22827)
5013 54494, // Elixir of Major Agility (22831)
5014 28501, // Elixir of Major Firepower (22833)
5015 28503, // Elixir of Major Shadow Power (22835)
5016 38954, // Fel Strength Elixir (31679)
5017 // Guardian Elixirs
5018 39625, // Elixir of Major Fortitude (32062)
5019 39626, // Earthen Elixir (32063)
5020 39627, // Elixir of Draenic Wisdom (32067)
5021 39628, // Elixir of Ironskin (32068)
5022 28502, // Elixir of Major Defense (22834)
5023 28514, // Elixir of Empowerment (22848)
5024 // Other
5025 28489, // Elixir of Camouflage (22823)
5026 28496 // Elixir of the Searching Eye (22830)
5027 };
5028
5029 Unit* target = GetCaster();
5030
5031 if (target->getPowerType() == POWER_MANA)
5032 availableElixirs.push_back(28509); // Elixir of Major Mageblood (22840)
5033
5034 uint32 chosenElixir = Acore::Containers::SelectRandomContainerElement(availableElixirs);
5035
5036 bool useElixir = true;
5037
5038 SpellGroup chosenSpellGroup = SPELL_GROUP_NONE;
5039 if (sSpellMgr->IsSpellMemberOfSpellGroup(chosenElixir, SPELL_GROUP_ELIXIR_BATTLE))
5040 chosenSpellGroup = SPELL_GROUP_ELIXIR_BATTLE;
5041 if (sSpellMgr->IsSpellMemberOfSpellGroup(chosenElixir, SPELL_GROUP_ELIXIR_GUARDIAN))
5042 chosenSpellGroup = SPELL_GROUP_ELIXIR_GUARDIAN;
5043 // If another spell of the same group is already active the elixir should not be cast
5044 if (chosenSpellGroup != SPELL_GROUP_NONE)
5045 {
5046 Unit::AuraApplicationMap const& auraMap = target->GetAppliedAuras();
5047 for (auto itr = auraMap.begin(); itr != auraMap.end(); ++itr)
5048 {
5049 uint32 spellId = itr->second->GetBase()->GetId();
5050 if (sSpellMgr->IsSpellMemberOfSpellGroup(spellId, chosenSpellGroup) && spellId != chosenElixir)
5051 {
5052 useElixir = false;
5053 break;
5054 }
5055 }
5056 }
5057
5058 if (useElixir)
5059 target->CastSpell(target, chosenElixir, GetCastItem());
5060 }
std::uint32_t uint32
Definition Define.h:107
@ POWER_MANA
Definition SharedDefines.h:257
SpellGroup
Definition SpellMgr.h:331
@ SPELL_GROUP_NONE
Definition SpellMgr.h:332
@ SPELL_GROUP_ELIXIR_BATTLE
Definition SpellMgr.h:333
@ SPELL_GROUP_ELIXIR_GUARDIAN
Definition SpellMgr.h:334
#define sSpellMgr
Definition SpellMgr.h:847
Item * GetCastItem()
Definition SpellScript.cpp:620
Unit * GetCaster()
Definition SpellScript.cpp:401
Definition Unit.h:665
boost::container::flat_multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:674
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition Unit.cpp:1361
Powers getPowerType() const
Definition Unit.h:1132
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:1384
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:133

References Unit::CastSpell(), Unit::GetAppliedAuras(), SpellScript::GetCaster(), SpellScript::GetCastItem(), Unit::getPowerType(), POWER_MANA, Acore::Containers::SelectRandomContainerElement(), SPELL_GROUP_ELIXIR_BATTLE, SPELL_GROUP_ELIXIR_GUARDIAN, SPELL_GROUP_NONE, and sSpellMgr.

Referenced by Register().


The documentation for this class was generated from the following file: