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

Private Member Functions

 PrepareSpellScript (spell_brewfest_toss_mug)
 
SpellCastResult CheckCast ()
 
void FilterTargets (std::list< WorldObject * > &targets)
 
void HandleBeforeHit (SpellMissInfo missInfo)
 
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

◆ CheckCast()

SpellCastResult spell_brewfest_toss_mug::CheckCast ( )
inlineprivate
1167 {
1168 if (Unit* caster = GetCaster())
1169 {
1170 WorldLocation pPosition = WorldLocation(*caster);
1171 caster->MovePositionToFirstCollision(pPosition, 14.f, 0.f);
1172 SetExplTargetDest(pPosition);
1173 }
1174
1175 return SPELL_CAST_OK;
1176 }
@ SPELL_CAST_OK
Definition: SharedDefines.h:1110
Definition: Position.h:251
Definition: Unit.h:1290
void SetExplTargetDest(WorldLocation &loc)
Definition: SpellScript.cpp:423
Unit * GetCaster()
Definition: SpellScript.cpp:401

References SpellScript::GetCaster(), SpellScript::SetExplTargetDest(), and SPELL_CAST_OK.

Referenced by Register().

◆ FilterTargets()

void spell_brewfest_toss_mug::FilterTargets ( std::list< WorldObject * > &  targets)
inlineprivate
1179 {
1180 Unit* caster = GetCaster();
1181 if (!caster)
1182 return;
1183
1184 WorldObject* target = nullptr;
1185 for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
1186 if (caster->HasInLine((*itr), 2.0f))
1187 {
1188 target = (*itr);
1189 break;
1190 }
1191
1192 targets.clear();
1193 if (target)
1194 targets.push_back(target);
1195
1196 targets.push_back(caster);
1197 }
Definition: Object.h:393
bool HasInLine(Position const *pos, float width) const
Definition: Position.cpp:42

References SpellScript::GetCaster(), and Position::HasInLine().

Referenced by Register().

◆ HandleBeforeHit()

void spell_brewfest_toss_mug::HandleBeforeHit ( SpellMissInfo  missInfo)
inlineprivate
1200 {
1201 if (missInfo != SPELL_MISS_NONE)
1202 {
1203 return;
1204 }
1205
1206 if (Unit* target = GetHitUnit())
1207 {
1208 if (!GetCaster() || target->GetGUID() == GetCaster()->GetGUID())
1209 return;
1210
1211 WorldLocation pPosition = WorldLocation(target->GetMapId(), target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + 4.0f, target->GetOrientation());
1212 SetExplTargetDest(pPosition);
1213 }
1214 }
@ SPELL_MISS_NONE
Definition: SharedDefines.h:1491
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
Unit * GetHitUnit()
Definition: SpellScript.cpp:448

References SpellScript::GetCaster(), Object::GetGUID(), SpellScript::GetHitUnit(), SpellScript::SetExplTargetDest(), and SPELL_MISS_NONE.

Referenced by Register().

◆ HandleScriptEffect()

void spell_brewfest_toss_mug::HandleScriptEffect ( SpellEffIndex  )
inlineprivate
1217 {
1218 Unit* caster = GetCaster();
1219 if (!caster)
1220 return;
1221
1222 if (!GetHitUnit() || GetHitUnit()->GetGUID() != caster->GetGUID())
1223 return;
1224
1225 std::vector<Creature*> bakers;
1226 if (caster->GetMapId() == 1) // Kalimdor
1227 {
1228 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_VOODOO, 40.0f))
1229 {
1230 bakers.push_back(creature);
1231 }
1232
1233 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_DROHN, 40.0f))
1234 {
1235 bakers.push_back(creature);
1236 }
1237
1238 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_GORDOK, 40.0f))
1239 {
1240 bakers.push_back(creature);
1241 }
1242 }
1243 else // EK
1244 {
1245 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_THUNDERBREW, 40.0f))
1246 {
1247 bakers.push_back(creature);
1248 }
1249
1250 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_BARLEYBREW, 40.0f))
1251 {
1252 bakers.push_back(creature);
1253 }
1254
1255 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_GORDOK, 40.0f))
1256 {
1257 bakers.push_back(creature);
1258 }
1259 }
1260
1261 if (!bakers.empty())
1262 {
1263 std::sort(bakers.begin(), bakers.end(), Acore::ObjectDistanceOrderPred(caster));
1264 if (Creature* creature = *bakers.begin())
1265 {
1266 creature->CastSpell(caster, SPELL_THROW_MUG_TO_PLAYER, true);
1267 }
1268 }
1269
1270 caster->CastSpell(caster, SPELL_WEAK_ALCOHOL, true);
1271 }
@ NPC_NORMAL_THUNDERBREW
Definition: brewfest.cpp:266
@ NPC_NORMAL_VOODOO
Definition: brewfest.cpp:264
@ NPC_NORMAL_BARLEYBREW
Definition: brewfest.cpp:265
@ SPELL_WEAK_ALCOHOL
Definition: brewfest.cpp:291
@ NPC_NORMAL_GORDOK
Definition: brewfest.cpp:267
@ NPC_NORMAL_DROHN
Definition: brewfest.cpp:263
@ SPELL_THROW_MUG_TO_PLAYER
Definition: brewfest.cpp:281
Definition: Creature.h:46
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2394
Definition: Object.h:681
uint32 GetMapId() const
Definition: Position.h:276
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:1428

References Unit::CastSpell(), WorldObject::FindNearestCreature(), SpellScript::GetCaster(), Object::GetGUID(), SpellScript::GetHitUnit(), WorldLocation::GetMapId(), NPC_NORMAL_BARLEYBREW, NPC_NORMAL_DROHN, NPC_NORMAL_GORDOK, NPC_NORMAL_THUNDERBREW, NPC_NORMAL_VOODOO, SPELL_THROW_MUG_TO_PLAYER, and SPELL_WEAK_ALCOHOL.

Referenced by Register().

◆ PrepareSpellScript()

spell_brewfest_toss_mug::PrepareSpellScript ( spell_brewfest_toss_mug  )
private

◆ Register()

void spell_brewfest_toss_mug::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

1274 {
1279 }
#define BeforeSpellHitFn(F)
Definition: SpellScript.h:342
#define SpellCheckCastFn(F)
Definition: SpellScript.h:329
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:354
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:827
@ TARGET_UNIT_SRC_AREA_ENTRY
Definition: SharedDefines.h:1388
HookList< CheckCastHandler > OnCheckCast
Definition: SpellScript.h:328
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
HookList< BeforeHitHandler > BeforeHit
Definition: SpellScript.h:341
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:353
SpellCastResult CheckCast()
Definition: brewfest.cpp:1166
void HandleBeforeHit(SpellMissInfo missInfo)
Definition: brewfest.cpp:1199
void HandleScriptEffect(SpellEffIndex)
Definition: brewfest.cpp:1216
void FilterTargets(std::list< WorldObject * > &targets)
Definition: brewfest.cpp:1178

References SpellScript::BeforeHit, BeforeSpellHitFn, CheckCast(), EFFECT_0, FilterTargets(), HandleBeforeHit(), HandleScriptEffect(), SpellScript::OnCheckCast, SpellScript::OnEffectHitTarget, SpellScript::OnObjectAreaTargetSelect, SPELL_EFFECT_SCRIPT_EFFECT, SpellCheckCastFn, SpellEffectFn, SpellObjectAreaTargetSelectFn, and TARGET_UNIT_SRC_AREA_ENTRY.