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

Private Member Functions

 PrepareSpellScript (spell_q12589_shoot_rjr)
 
bool Validate (SpellInfo const *) override
 
SpellCastResult CheckCast ()
 
void HandleDummy (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 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
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Function Documentation

◆ CheckCast()

SpellCastResult spell_q12589_shoot_rjr::CheckCast ( )
inlineprivate
970 {
971 if (Unit* target = GetExplTargetUnit())
972 if (target->GetEntry() == NPC_LUCKY_WILHELM)
973 return SPELL_CAST_OK;
974
977 }
@ SPELL_CUSTOM_ERROR_MUST_TARGET_WILHELM
Definition SharedDefines.h:1158
@ SPELL_FAILED_CUSTOM_ERROR
Definition SharedDefines.h:1109
@ SPELL_CAST_OK
Definition SharedDefines.h:1126
Unit * GetExplTargetUnit()
Definition SpellScript.cpp:433
void SetCustomCastResultMessage(SpellCustomErrors result)
Definition SpellScript.cpp:646
Definition Unit.h:664
@ NPC_LUCKY_WILHELM
Definition zone_sholazar_basin.cpp:939

References SpellScript::GetExplTargetUnit(), NPC_LUCKY_WILHELM, SpellScript::SetCustomCastResultMessage(), SPELL_CAST_OK, SPELL_CUSTOM_ERROR_MUST_TARGET_WILHELM, and SPELL_FAILED_CUSTOM_ERROR.

Referenced by Register().

◆ HandleDummy()

void spell_q12589_shoot_rjr::HandleDummy ( SpellEffIndex  )
inlineprivate
Todo:
Make crunchy perform emote eat when he reaches the bird
980 {
981 uint32 roll = urand(1, 100);
982
983 uint8 ev;
984 if (roll <= 50)
985 ev = EVENT_MISS;
986 else if (roll <= 83)
987 ev = EVENT_HIT;
988 else
989 ev = EVENT_MISS_BIRD;
990
991 Unit* shooter = GetCaster();
992 Creature* wilhelm = GetHitUnit()->ToCreature();
993 Creature* apple = shooter->FindNearestCreature(NPC_APPLE, 30);
994 Creature* drostan = shooter->FindNearestCreature(NPC_DROSTAN, 30);
995
996 if (!wilhelm || !apple || !drostan)
997 return;
998
999 switch (ev)
1000 {
1001 case EVENT_MISS_BIRD:
1002 {
1003 Creature* crunchy = shooter->FindNearestCreature(NPC_CRUNCHY, 30);
1004 Creature* bird = shooter->FindNearestCreature(NPC_THICKBIRD, 30);
1005
1006 if (!bird || !crunchy)
1007 ; // fall to EVENT_MISS
1008 else
1009 {
1010 shooter->CastSpell(bird, SPELL_MISS_BIRD_APPLE);
1011 bird->CastSpell(bird, SPELL_BIRD_FALL);
1012 wilhelm->AI()->Talk(SAY_WILHELM_MISS);
1013 drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);
1014
1015 Unit::Kill(bird, bird);
1016 crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(),
1017 bird->GetMapWaterOrGroundLevel(bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ()));
1019
1020 break;
1021 }
1022 [[fallthrough]];
1023 }
1024 case EVENT_MISS:
1025 {
1026 shooter->CastSpell(wilhelm, SPELL_MISS_APPLE);
1027 wilhelm->AI()->Talk(SAY_WILHELM_MISS);
1028 drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);
1029 break;
1030 }
1031 case EVENT_HIT:
1032 {
1033 shooter->CastSpell(apple, SPELL_HIT_APPLE);
1034 apple->CastSpell(apple, SPELL_APPLE_FALL);
1035 wilhelm->AI()->Talk(SAY_WILHELM_HIT);
1036 if (Player* player = shooter->ToPlayer())
1037 player->KilledMonsterCredit(NPC_APPLE);
1038 //apple->DespawnOrUnsummon(); zomg!
1039
1040 break;
1041 }
1042 }
1043 }
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr, Milliseconds delay=0ms)
Causes the creature to talk/say the text assigned to their entry in the creature_text database table.
Definition CreatureAI.cpp:67
Definition Creature.h:47
CreatureAI * AI() const
Definition Creature.h:144
void MovePoint(uint32 id, const Position &pos, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, float speed=0.f, bool generatePath=true, bool forceDestination=true, std::optional< AnimTier > animTier=std::nullopt)
Definition MotionMaster.h:240
Player * ToPlayer()
Definition Object.h:202
Creature * ToCreature()
Definition Object.h:206
Definition Player.h:1084
Unit * GetHitUnit()
Definition SpellScript.cpp:448
Unit * GetCaster()
Definition SpellScript.cpp:401
static void Kill(Unit *killer, Unit *victim, bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition Unit.cpp:13964
MotionMaster * GetMotionMaster()
Definition Unit.h:1759
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:1375
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2498
float GetMapWaterOrGroundLevel(Position pos, float *ground=nullptr) const
Definition Object.h:705
float GetPositionZ() const
Definition Position.h:123
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122
@ SPELL_BIRD_FALL
Definition zone_sholazar_basin.cpp:949
@ EVENT_HIT
Definition zone_sholazar_basin.cpp:952
@ SPELL_MISS_APPLE
Definition zone_sholazar_basin.cpp:946
@ SAY_DROSTAN_REPLY_MISS
Definition zone_sholazar_basin.cpp:957
@ SPELL_MISS_BIRD_APPLE
Definition zone_sholazar_basin.cpp:947
@ NPC_DROSTAN
Definition zone_sholazar_basin.cpp:941
@ SAY_WILHELM_HIT
Definition zone_sholazar_basin.cpp:956
@ NPC_CRUNCHY
Definition zone_sholazar_basin.cpp:942
@ SPELL_APPLE_FALL
Definition zone_sholazar_basin.cpp:948
@ SAY_WILHELM_MISS
Definition zone_sholazar_basin.cpp:955
@ EVENT_MISS_BIRD
Definition zone_sholazar_basin.cpp:953
@ EVENT_MISS
Definition zone_sholazar_basin.cpp:951
@ NPC_THICKBIRD
Definition zone_sholazar_basin.cpp:943
@ NPC_APPLE
Definition zone_sholazar_basin.cpp:940
@ SPELL_HIT_APPLE
Definition zone_sholazar_basin.cpp:945

References Creature::AI(), Unit::CastSpell(), EVENT_HIT, EVENT_MISS, EVENT_MISS_BIRD, WorldObject::FindNearestCreature(), SpellScript::GetCaster(), SpellScript::GetHitUnit(), WorldObject::GetMapWaterOrGroundLevel(), Unit::GetMotionMaster(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::Kill(), MotionMaster::MovePoint(), NPC_APPLE, NPC_CRUNCHY, NPC_DROSTAN, NPC_THICKBIRD, SAY_DROSTAN_REPLY_MISS, SAY_WILHELM_HIT, SAY_WILHELM_MISS, SPELL_APPLE_FALL, SPELL_BIRD_FALL, SPELL_HIT_APPLE, SPELL_MISS_APPLE, SPELL_MISS_BIRD_APPLE, CreatureAI::Talk(), Object::ToCreature(), Object::ToPlayer(), and urand().

Referenced by Register().

◆ PrepareSpellScript()

spell_q12589_shoot_rjr::PrepareSpellScript ( spell_q12589_shoot_rjr  )
private

◆ Register()

void spell_q12589_shoot_rjr::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

1046 {
1049 }
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:769
#define SpellCheckCastFn(F)
Definition SpellScript.h:329
#define SpellEffectFn(F, I, N)
Definition SpellScript.h:337
HookList< CheckCastHandler > OnCheckCast
Definition SpellScript.h:328
HookList< EffectHandler > OnEffectHitTarget
Definition SpellScript.h:336
SpellCastResult CheckCast()
Definition zone_sholazar_basin.cpp:969
void HandleDummy(SpellEffIndex)
Definition zone_sholazar_basin.cpp:979

References CheckCast(), EFFECT_0, HandleDummy(), SpellScript::OnCheckCast, SpellScript::OnEffectHitTarget, SPELL_EFFECT_DUMMY, SpellCheckCastFn, and SpellEffectFn.

◆ Validate()

bool spell_q12589_shoot_rjr::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

965 {
967 }
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition SpellScript.h:125

References SPELL_APPLE_FALL, SPELL_BIRD_FALL, SPELL_HIT_APPLE, SPELL_MISS_APPLE, SPELL_MISS_BIRD_APPLE, and _SpellScript::ValidateSpellInfo().


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