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

Private Member Functions

 PrepareSpellScript (spell_brewfest_fill_keg)
 
void HandleAfterHit ()
 
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

◆ HandleAfterHit()

void spell_brewfest_fill_keg::HandleAfterHit ( )
inlineprivate
1078 {
1079 if (GetCaster() && GetCaster()->ToPlayer())
1080 {
1081 if (Item* itemCaster = GetCastItem())
1082 {
1083 Player* player = GetCaster()->ToPlayer();
1084 uint32 item = 0;
1085 switch (itemCaster->GetEntry())
1086 {
1087 case GREEN_EMPTY_KEG:
1088 case BLUE_EMPTY_KEG:
1089 item = itemCaster->GetEntry() + urand(1, 5); // 5 items, id in range empty+1-5
1090 break;
1091 case YELLOW_EMPTY_KEG:
1092 if (uint8 num = urand(0, 4))
1093 item = 32916 + num;
1094 else
1095 item = 32915;
1096 break;
1097 }
1098
1099 if (item && player->AddItem(item, 1)) // ensure filled keg is stored
1100 {
1101 player->DestroyItemCount(itemCaster->GetEntry(), 1, true);
1102 GetSpell()->m_CastItem = nullptr;
1104 }
1105 }
1106 }
1107 }
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ YELLOW_EMPTY_KEG
Definition: brewfest.cpp:1070
@ BLUE_EMPTY_KEG
Definition: brewfest.cpp:1069
@ GREEN_EMPTY_KEG
Definition: brewfest.cpp:1068
Definition: Item.h:214
Player * ToPlayer()
Definition: Object.h:195
void Clear()
Definition: ObjectGuid.h:140
Definition: Player.h:1046
bool AddItem(uint32 itemId, uint32 count)
Definition: Player.cpp:15441
void DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check=false)
Definition: PlayerStorage.cpp:3149
Item * m_CastItem
Definition: Spell.h:521
ObjectGuid m_castItemGUID
Definition: Spell.h:523
Item * GetCastItem()
Definition: SpellScript.cpp:620
Spell * GetSpell()
Definition: SpellScript.h:442
Unit * GetCaster()
Definition: SpellScript.cpp:401

References Player::AddItem(), BLUE_EMPTY_KEG, ObjectGuid::Clear(), Player::DestroyItemCount(), SpellScript::GetCaster(), SpellScript::GetCastItem(), SpellScript::GetSpell(), GREEN_EMPTY_KEG, Spell::m_CastItem, Spell::m_castItemGUID, Object::ToPlayer(), urand(), and YELLOW_EMPTY_KEG.

Referenced by Register().

◆ PrepareSpellScript()

spell_brewfest_fill_keg::PrepareSpellScript ( spell_brewfest_fill_keg  )
private

◆ Register()

void spell_brewfest_fill_keg::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

1110 {
1112 }
#define SpellHitFn(F)
Definition: SpellScript.h:349
HookList< HitHandler > AfterHit
Definition: SpellScript.h:347
void HandleAfterHit()
Definition: brewfest.cpp:1077

References SpellScript::AfterHit, HandleAfterHit(), and SpellHitFn.