AzerothCore 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
1176 {
1177 if (Unit* caster = GetCaster())
1178 {
1179 WorldLocation pPosition = WorldLocation(*caster);
1180 caster->MovePositionToFirstCollision(pPosition, 14.f, 0.f);
1181 SetExplTargetDest(pPosition);
1182 }
1183
1184 return SPELL_CAST_OK;
1185 }
@ 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
1188 {
1189 Unit* caster = GetCaster();
1190 if (!caster)
1191 return;
1192
1193 WorldObject* target = nullptr;
1194 for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
1195 if (caster->HasInLine((*itr), 2.0f))
1196 {
1197 target = (*itr);
1198 break;
1199 }
1200
1201 targets.clear();
1202 if (target)
1203 targets.push_back(target);
1204
1205 targets.push_back(caster);
1206 }
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
1209 {
1210 if (missInfo != SPELL_MISS_NONE)
1211 {
1212 return;
1213 }
1214
1215 if (Unit* target = GetHitUnit())
1216 {
1217 if (!GetCaster() || target->GetGUID() == GetCaster()->GetGUID())
1218 return;
1219
1220 WorldLocation pPosition = WorldLocation(target->GetMapId(), target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + 4.0f, target->GetOrientation());
1221 SetExplTargetDest(pPosition);
1222 }
1223 }
@ 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
1226 {
1227 Unit* caster = GetCaster();
1228 if (!caster)
1229 return;
1230
1231 if (!GetHitUnit() || GetHitUnit()->GetGUID() != caster->GetGUID())
1232 return;
1233
1234 std::vector<Creature*> bakers;
1235 if (caster->GetMapId() == 1) // Kalimdor
1236 {
1237 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_VOODOO, 40.0f))
1238 {
1239 bakers.push_back(creature);
1240 }
1241
1242 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_DROHN, 40.0f))
1243 {
1244 bakers.push_back(creature);
1245 }
1246
1247 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_GORDOK, 40.0f))
1248 {
1249 bakers.push_back(creature);
1250 }
1251 }
1252 else // EK
1253 {
1254 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_THUNDERBREW, 40.0f))
1255 {
1256 bakers.push_back(creature);
1257 }
1258
1259 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_BARLEYBREW, 40.0f))
1260 {
1261 bakers.push_back(creature);
1262 }
1263
1264 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_GORDOK, 40.0f))
1265 {
1266 bakers.push_back(creature);
1267 }
1268 }
1269
1270 if (!bakers.empty())
1271 {
1272 std::sort(bakers.begin(), bakers.end(), Acore::ObjectDistanceOrderPred(caster));
1273 if (Creature* creature = *bakers.begin())
1274 {
1275 creature->CastSpell(caster, SPELL_THROW_MUG_TO_PLAYER, true);
1276 }
1277 }
1278
1279 caster->CastSpell(caster, SPELL_WEAK_ALCOHOL, true);
1280 }
@ 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:2409
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:1169

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.

1283 {
1288 }
#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:1175
void HandleBeforeHit(SpellMissInfo missInfo)
Definition: brewfest.cpp:1208
void HandleScriptEffect(SpellEffIndex)
Definition: brewfest.cpp:1225
void FilterTargets(std::list< WorldObject * > &targets)
Definition: brewfest.cpp:1187

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.