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

Private Member Functions

 PrepareSpellScript (spell_q12589_shoot_rjr_SpellScript)
 
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::spell_q12589_shoot_rjr_SpellScript::CheckCast ( )
inlineprivate
1241 {
1242 if (Unit* target = GetExplTargetUnit())
1243 if (target->GetEntry() == NPC_LUCKY_WILHELM)
1244 return SPELL_CAST_OK;
1245
1248 }
@ NPC_LUCKY_WILHELM
Definition: zone_sholazar_basin.cpp:1210
@ 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:1302
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::spell_q12589_shoot_rjr_SpellScript::HandleDummy ( SpellEffIndex  )
inlineprivate
Todo:
Make crunchy perform emote eat when he reaches the bird
1251 {
1252 uint32 roll = urand(1, 100);
1253
1254 uint8 ev;
1255 if (roll <= 50)
1256 ev = EVENT_MISS;
1257 else if (roll <= 83)
1258 ev = EVENT_HIT;
1259 else
1260 ev = EVENT_MISS_BIRD;
1261
1262 Unit* shooter = GetCaster();
1263 Creature* wilhelm = GetHitUnit()->ToCreature();
1264 Creature* apple = shooter->FindNearestCreature(NPC_APPLE, 30);
1265 Creature* drostan = shooter->FindNearestCreature(NPC_DROSTAN, 30);
1266
1267 if (!wilhelm || !apple || !drostan)
1268 return;
1269
1270 switch (ev)
1271 {
1272 case EVENT_MISS_BIRD:
1273 {
1274 Creature* crunchy = shooter->FindNearestCreature(NPC_CRUNCHY, 30);
1275 Creature* bird = shooter->FindNearestCreature(NPC_THICKBIRD, 30);
1276
1277 if (!bird || !crunchy)
1278 ; // fall to EVENT_MISS
1279 else
1280 {
1281 shooter->CastSpell(bird, SPELL_MISS_BIRD_APPLE);
1282 bird->CastSpell(bird, SPELL_BIRD_FALL);
1283 wilhelm->AI()->Talk(SAY_WILHELM_MISS);
1284 drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);
1285
1286 Unit::Kill(bird, bird);
1287 crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(),
1288 bird->GetMapWaterOrGroundLevel(bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ()));
1290
1291 break;
1292 }
1293 [[fallthrough]];
1294 }
1295 case EVENT_MISS:
1296 {
1297 shooter->CastSpell(wilhelm, SPELL_MISS_APPLE);
1298 wilhelm->AI()->Talk(SAY_WILHELM_MISS);
1299 drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);
1300 break;
1301 }
1302 case EVENT_HIT:
1303 {
1304 shooter->CastSpell(apple, SPELL_HIT_APPLE);
1305 apple->CastSpell(apple, SPELL_APPLE_FALL);
1306 wilhelm->AI()->Talk(SAY_WILHELM_HIT);
1307 if (Player* player = shooter->ToPlayer())
1308 player->KilledMonsterCredit(NPC_APPLE);
1309 //apple->DespawnOrUnsummon(); zomg!
1310
1311 break;
1312 }
1313 }
1314 }
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ SPELL_BIRD_FALL
Definition: zone_sholazar_basin.cpp:1220
@ EVENT_HIT
Definition: zone_sholazar_basin.cpp:1223
@ SPELL_MISS_APPLE
Definition: zone_sholazar_basin.cpp:1217
@ SAY_DROSTAN_REPLY_MISS
Definition: zone_sholazar_basin.cpp:1228
@ SPELL_MISS_BIRD_APPLE
Definition: zone_sholazar_basin.cpp:1218
@ NPC_DROSTAN
Definition: zone_sholazar_basin.cpp:1212
@ SAY_WILHELM_HIT
Definition: zone_sholazar_basin.cpp:1227
@ NPC_CRUNCHY
Definition: zone_sholazar_basin.cpp:1213
@ SPELL_APPLE_FALL
Definition: zone_sholazar_basin.cpp:1219
@ SAY_WILHELM_MISS
Definition: zone_sholazar_basin.cpp:1226
@ EVENT_MISS_BIRD
Definition: zone_sholazar_basin.cpp:1224
@ EVENT_MISS
Definition: zone_sholazar_basin.cpp:1222
@ NPC_THICKBIRD
Definition: zone_sholazar_basin.cpp:1214
@ NPC_APPLE
Definition: zone_sholazar_basin.cpp:1211
@ SPELL_HIT_APPLE
Definition: zone_sholazar_basin.cpp:1216
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:49
Definition: Creature.h:46
CreatureAI * AI() const
Definition: Creature.h:136
Player * ToPlayer()
Definition: Object.h:195
Creature * ToCreature()
Definition: Object.h:197
float GetMapWaterOrGroundLevel(float x, float y, float z, float *ground=nullptr) const
Definition: Object.cpp:3082
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2434
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
Definition: Player.h:1056
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:17956
MotionMaster * GetMotionMaster()
Definition: Unit.h:2276
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
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::spell_q12589_shoot_rjr_SpellScript::PrepareSpellScript ( spell_q12589_shoot_rjr_SpellScript  )
private

◆ Register()

void spell_q12589_shoot_rjr::spell_q12589_shoot_rjr_SpellScript::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

1317 {
1320 }
#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
void HandleDummy(SpellEffIndex)
Definition: zone_sholazar_basin.cpp:1250
SpellCastResult CheckCast()
Definition: zone_sholazar_basin.cpp:1240

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