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

1282 {
1287 }
#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:31
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:855
@ TARGET_UNIT_SRC_AREA_ENTRY
Definition: SharedDefines.h:1416
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:1174
void HandleBeforeHit(SpellMissInfo missInfo)
Definition: brewfest.cpp:1207
void HandleScriptEffect(SpellEffIndex)
Definition: brewfest.cpp:1224
void FilterTargets(std::list< WorldObject * > &targets)
Definition: brewfest.cpp:1186

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.