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 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_q12589_shoot_rjr::CheckCast ( )
inlineprivate
1224 {
1225 if (Unit* target = GetExplTargetUnit())
1226 if (target->GetEntry() == NPC_LUCKY_WILHELM)
1227 return SPELL_CAST_OK;
1228
1231 }
@ NPC_LUCKY_WILHELM
Definition: zone_sholazar_basin.cpp:1193
@ SPELL_CUSTOM_ERROR_MUST_TARGET_WILHELM
Definition: SharedDefines.h:1170
@ SPELL_FAILED_CUSTOM_ERROR
Definition: SharedDefines.h:1121
@ SPELL_CAST_OK
Definition: SharedDefines.h:1138
Definition: Unit.h:630
Unit * GetExplTargetUnit()
Definition: SpellScript.cpp:433
void SetCustomCastResultMessage(SpellCustomErrors result)
Definition: SpellScript.cpp:646

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
1234 {
1235 uint32 roll = urand(1, 100);
1236
1237 uint8 ev;
1238 if (roll <= 50)
1239 ev = EVENT_MISS;
1240 else if (roll <= 83)
1241 ev = EVENT_HIT;
1242 else
1243 ev = EVENT_MISS_BIRD;
1244
1245 Unit* shooter = GetCaster();
1246 Creature* wilhelm = GetHitUnit()->ToCreature();
1247 Creature* apple = shooter->FindNearestCreature(NPC_APPLE, 30);
1248 Creature* drostan = shooter->FindNearestCreature(NPC_DROSTAN, 30);
1249
1250 if (!wilhelm || !apple || !drostan)
1251 return;
1252
1253 switch (ev)
1254 {
1255 case EVENT_MISS_BIRD:
1256 {
1257 Creature* crunchy = shooter->FindNearestCreature(NPC_CRUNCHY, 30);
1258 Creature* bird = shooter->FindNearestCreature(NPC_THICKBIRD, 30);
1259
1260 if (!bird || !crunchy)
1261 ; // fall to EVENT_MISS
1262 else
1263 {
1264 shooter->CastSpell(bird, SPELL_MISS_BIRD_APPLE);
1265 bird->CastSpell(bird, SPELL_BIRD_FALL);
1266 wilhelm->AI()->Talk(SAY_WILHELM_MISS);
1267 drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);
1268
1269 Unit::Kill(bird, bird);
1270 crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(),
1271 bird->GetMapWaterOrGroundLevel(bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ()));
1273
1274 break;
1275 }
1276 [[fallthrough]];
1277 }
1278 case EVENT_MISS:
1279 {
1280 shooter->CastSpell(wilhelm, SPELL_MISS_APPLE);
1281 wilhelm->AI()->Talk(SAY_WILHELM_MISS);
1282 drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);
1283 break;
1284 }
1285 case EVENT_HIT:
1286 {
1287 shooter->CastSpell(apple, SPELL_HIT_APPLE);
1288 apple->CastSpell(apple, SPELL_APPLE_FALL);
1289 wilhelm->AI()->Talk(SAY_WILHELM_HIT);
1290 if (Player* player = shooter->ToPlayer())
1291 player->KilledMonsterCredit(NPC_APPLE);
1292 //apple->DespawnOrUnsummon(); zomg!
1293
1294 break;
1295 }
1296 }
1297 }
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
@ SPELL_BIRD_FALL
Definition: zone_sholazar_basin.cpp:1203
@ EVENT_HIT
Definition: zone_sholazar_basin.cpp:1206
@ SPELL_MISS_APPLE
Definition: zone_sholazar_basin.cpp:1200
@ SAY_DROSTAN_REPLY_MISS
Definition: zone_sholazar_basin.cpp:1211
@ SPELL_MISS_BIRD_APPLE
Definition: zone_sholazar_basin.cpp:1201
@ NPC_DROSTAN
Definition: zone_sholazar_basin.cpp:1195
@ SAY_WILHELM_HIT
Definition: zone_sholazar_basin.cpp:1210
@ NPC_CRUNCHY
Definition: zone_sholazar_basin.cpp:1196
@ SPELL_APPLE_FALL
Definition: zone_sholazar_basin.cpp:1202
@ SAY_WILHELM_MISS
Definition: zone_sholazar_basin.cpp:1209
@ EVENT_MISS_BIRD
Definition: zone_sholazar_basin.cpp:1207
@ EVENT_MISS
Definition: zone_sholazar_basin.cpp:1205
@ NPC_THICKBIRD
Definition: zone_sholazar_basin.cpp:1197
@ NPC_APPLE
Definition: zone_sholazar_basin.cpp:1194
@ SPELL_HIT_APPLE
Definition: zone_sholazar_basin.cpp:1199
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr, Milliseconds delay=0s)
Causes the creature to talk/say the text assigned to their entry in the creature_text database table.
Definition: CreatureAI.cpp:50
Definition: Creature.h:46
CreatureAI * AI() const
Definition: Creature.h:143
Player * ToPlayer()
Definition: Object.h:198
Creature * ToCreature()
Definition: Object.h:202
float GetMapWaterOrGroundLevel(float x, float y, float z, float *ground=nullptr) const
Definition: Object.cpp:3126
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2446
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
Definition: Player.h:1064
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:17658
MotionMaster * GetMotionMaster()
Definition: Unit.h:1601
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:1168
void MovePoint(uint32 id, const Position &pos, bool generatePath=true, bool forceDestination=true)
Definition: MotionMaster.h:211
Unit * GetHitUnit()
Definition: SpellScript.cpp:448
Unit * GetCaster()
Definition: SpellScript.cpp:401

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.

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

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.

1219 {
1221 }
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().