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
 
Unit * GetCaster ()
 
GameObject * GetGObjCaster ()
 
Unit * GetOriginalCaster ()
 
SpellInfo const * GetSpellInfo ()
 
SpellValue const * GetSpellValue ()
 
WorldLocation const * GetExplTargetDest ()
 
void SetExplTargetDest (WorldLocation &loc)
 
WorldObject * GetExplTargetWorldObject ()
 
Unit * GetExplTargetUnit ()
 
GameObject * GetExplTargetGObj ()
 
Item * GetExplTargetItem ()
 
Unit * GetHitUnit ()
 
Creature * GetHitCreature ()
 
Player * GetHitPlayer ()
 
Item * GetHitItem ()
 
GameObject * GetHitGObj ()
 
WorldLocation * GetHitDest ()
 
int32 GetHitDamage ()
 
void SetHitDamage (int32 damage)
 
void PreventHitDamage ()
 
int32 GetHitHeal ()
 
void SetHitHeal (int32 heal)
 
void PreventHitHeal ()
 
Spell * GetSpell ()
 
Aura * GetHitAura ()
 
void PreventHitAura ()
 
void PreventHitEffect (SpellEffIndex effIndex)
 
void PreventHitDefaultEffect (SpellEffIndex effIndex)
 
int32 GetEffectValue () const
 
void SetEffectValue (int32 value)
 
Item * GetCastItem ()
 
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< CastHandler > BeforeCast
 
HookList< CastHandler > OnCast
 
HookList< CastHandler > AfterCast
 
HookList< CheckCastHandler > OnCheckCast
 
HookList< EffectHandler > OnEffectLaunch
 
HookList< EffectHandler > OnEffectLaunchTarget
 
HookList< EffectHandler > OnEffectHit
 
HookList< EffectHandler > OnEffectHitTarget
 
HookList< BeforeHitHandler > BeforeHit
 
HookList< HitHandler > OnHit
 
HookList< HitHandler > AfterHit
 
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
 
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
 
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
 
- 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:1126
void SetExplTargetDest(WorldLocation &loc)
Definition SpellScript.cpp:428
Unit * GetCaster()
Definition SpellScript.cpp:401
Definition Unit.h:665
Definition Position.h:256

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:482
bool HasInLine(Position const *pos, float width) const
Definition Position.cpp:43

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:1523
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:120
Unit * GetHitUnit()
Definition SpellScript.cpp:453

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() == MAP_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 // Eastern Kingdoms
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 }
@ MAP_KALIMDOR
Definition AreaDefines.h:189
@ NPC_NORMAL_THUNDERBREW
Definition brewfest.cpp:269
@ NPC_NORMAL_VOODOO
Definition brewfest.cpp:267
@ NPC_NORMAL_BARLEYBREW
Definition brewfest.cpp:268
@ SPELL_WEAK_ALCOHOL
Definition brewfest.cpp:294
@ NPC_NORMAL_GORDOK
Definition brewfest.cpp:270
@ NPC_NORMAL_DROHN
Definition brewfest.cpp:266
@ SPELL_THROW_MUG_TO_PLAYER
Definition brewfest.cpp:284
Definition Object.h:860
Definition Creature.h:47
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:1372
uint32 GetMapId() const
Definition Position.h:281
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2558

References Unit::CastSpell(), WorldObject::FindNearestCreature(), SpellScript::GetCaster(), Object::GetGUID(), SpellScript::GetHitUnit(), WorldLocation::GetMapId(), MAP_KALIMDOR, 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 }
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition SharedDefines.h:843
@ TARGET_UNIT_SRC_AREA_ENTRY
Definition SharedDefines.h:1420
#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
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.


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