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
1168 {
1169 if (Unit* caster = GetCaster())
1170 {
1171 WorldLocation pPosition = WorldLocation(*caster);
1172 caster->MovePositionToFirstCollision(pPosition, 14.f, 0.f);
1173 SetExplTargetDest(pPosition);
1174 }
1175
1176 return SPELL_CAST_OK;
1177 }
@ SPELL_CAST_OK
Definition SharedDefines.h:1126
void SetExplTargetDest(WorldLocation &loc)
Definition SpellScript.cpp:428
Unit * GetCaster()
Definition SpellScript.cpp:401
Definition Unit.h:670
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
1180 {
1181 Unit* caster = GetCaster();
1182 if (!caster)
1183 return;
1184
1185 WorldObject* target = nullptr;
1186 for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
1187 if (caster->HasInLine((*itr), 2.0f))
1188 {
1189 target = (*itr);
1190 break;
1191 }
1192
1193 targets.clear();
1194 if (target)
1195 targets.push_back(target);
1196
1197 targets.push_back(caster);
1198 }
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
1201 {
1202 if (missInfo != SPELL_MISS_NONE)
1203 {
1204 return;
1205 }
1206
1207 if (Unit* target = GetHitUnit())
1208 {
1209 if (!GetCaster() || target->GetGUID() == GetCaster()->GetGUID())
1210 return;
1211
1212 WorldLocation pPosition = WorldLocation(target->GetMapId(), target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + 4.0f, target->GetOrientation());
1213 SetExplTargetDest(pPosition);
1214 }
1215 }
@ 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
1218 {
1219 Unit* caster = GetCaster();
1220 if (!caster)
1221 return;
1222
1223 if (!GetHitUnit() || GetHitUnit()->GetGUID() != caster->GetGUID())
1224 return;
1225
1226 std::vector<Creature*> bakers;
1227 if (caster->GetMapId() == MAP_KALIMDOR)
1228 {
1229 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_VOODOO, 40.0f))
1230 {
1231 bakers.push_back(creature);
1232 }
1233
1234 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_DROHN, 40.0f))
1235 {
1236 bakers.push_back(creature);
1237 }
1238
1239 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_GORDOK, 40.0f))
1240 {
1241 bakers.push_back(creature);
1242 }
1243 }
1244 else // Eastern Kingdoms
1245 {
1246 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_THUNDERBREW, 40.0f))
1247 {
1248 bakers.push_back(creature);
1249 }
1250
1251 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_BARLEYBREW, 40.0f))
1252 {
1253 bakers.push_back(creature);
1254 }
1255
1256 if (Creature* creature = caster->FindNearestCreature(NPC_NORMAL_GORDOK, 40.0f))
1257 {
1258 bakers.push_back(creature);
1259 }
1260 }
1261
1262 if (!bakers.empty())
1263 {
1264 std::sort(bakers.begin(), bakers.end(), Acore::ObjectDistanceOrderPred(caster));
1265 if (Creature* creature = *bakers.begin())
1266 {
1267 creature->CastSpell(caster, SPELL_THROW_MUG_TO_PLAYER, true);
1268 }
1269 }
1270
1271 caster->CastSpell(caster, SPELL_WEAK_ALCOHOL, true);
1272 }
@ MAP_KALIMDOR
Definition AreaDefines.h:189
@ NPC_NORMAL_THUNDERBREW
Definition brewfest.cpp:261
@ NPC_NORMAL_VOODOO
Definition brewfest.cpp:259
@ NPC_NORMAL_BARLEYBREW
Definition brewfest.cpp:260
@ SPELL_WEAK_ALCOHOL
Definition brewfest.cpp:286
@ NPC_NORMAL_GORDOK
Definition brewfest.cpp:262
@ NPC_NORMAL_DROHN
Definition brewfest.cpp:258
@ SPELL_THROW_MUG_TO_PLAYER
Definition brewfest.cpp:276
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:1378
uint32 GetMapId() const
Definition Position.h:281
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2565

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.

1275 {
1280 }
@ 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:1167
void HandleBeforeHit(SpellMissInfo missInfo)
Definition brewfest.cpp:1200
void HandleScriptEffect(SpellEffIndex)
Definition brewfest.cpp:1217
void FilterTargets(std::list< WorldObject * > &targets)
Definition brewfest.cpp:1179

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: