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
1238 {
1239 if (Unit* target = GetExplTargetUnit())
1240 if (target->GetEntry() == NPC_LUCKY_WILHELM)
1241 return SPELL_CAST_OK;
1242
1245 }
@ NPC_LUCKY_WILHELM
Definition: zone_sholazar_basin.cpp:1207
@ SPELL_CUSTOM_ERROR_MUST_TARGET_WILHELM
Definition: SharedDefines.h:1142
@ SPELL_FAILED_CUSTOM_ERROR
Definition: SharedDefines.h:1093
@ SPELL_CAST_OK
Definition: SharedDefines.h:1110
Definition: Unit.h:1290
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
1248 {
1249 uint32 roll = urand(1, 100);
1250
1251 uint8 ev;
1252 if (roll <= 50)
1253 ev = EVENT_MISS;
1254 else if (roll <= 83)
1255 ev = EVENT_HIT;
1256 else
1257 ev = EVENT_MISS_BIRD;
1258
1259 Unit* shooter = GetCaster();
1260 Creature* wilhelm = GetHitUnit()->ToCreature();
1261 Creature* apple = shooter->FindNearestCreature(NPC_APPLE, 30);
1262 Creature* drostan = shooter->FindNearestCreature(NPC_DROSTAN, 30);
1263
1264 if (!wilhelm || !apple || !drostan)
1265 return;
1266
1267 switch (ev)
1268 {
1269 case EVENT_MISS_BIRD:
1270 {
1271 Creature* crunchy = shooter->FindNearestCreature(NPC_CRUNCHY, 30);
1272 Creature* bird = shooter->FindNearestCreature(NPC_THICKBIRD, 30);
1273
1274 if (!bird || !crunchy)
1275 ; // fall to EVENT_MISS
1276 else
1277 {
1278 shooter->CastSpell(bird, SPELL_MISS_BIRD_APPLE);
1279 bird->CastSpell(bird, SPELL_BIRD_FALL);
1280 wilhelm->AI()->Talk(SAY_WILHELM_MISS);
1281 drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);
1282
1283 Unit::Kill(bird, bird);
1284 crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(),
1285 bird->GetMapWaterOrGroundLevel(bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ()));
1287
1288 break;
1289 }
1290 [[fallthrough]];
1291 }
1292 case EVENT_MISS:
1293 {
1294 shooter->CastSpell(wilhelm, SPELL_MISS_APPLE);
1295 wilhelm->AI()->Talk(SAY_WILHELM_MISS);
1296 drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);
1297 break;
1298 }
1299 case EVENT_HIT:
1300 {
1301 shooter->CastSpell(apple, SPELL_HIT_APPLE);
1302 apple->CastSpell(apple, SPELL_APPLE_FALL);
1303 wilhelm->AI()->Talk(SAY_WILHELM_HIT);
1304 if (Player* player = shooter->ToPlayer())
1305 player->KilledMonsterCredit(NPC_APPLE);
1306 //apple->DespawnOrUnsummon(); zomg!
1307
1308 break;
1309 }
1310 }
1311 }
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:1217
@ EVENT_HIT
Definition: zone_sholazar_basin.cpp:1220
@ SPELL_MISS_APPLE
Definition: zone_sholazar_basin.cpp:1214
@ SAY_DROSTAN_REPLY_MISS
Definition: zone_sholazar_basin.cpp:1225
@ SPELL_MISS_BIRD_APPLE
Definition: zone_sholazar_basin.cpp:1215
@ NPC_DROSTAN
Definition: zone_sholazar_basin.cpp:1209
@ SAY_WILHELM_HIT
Definition: zone_sholazar_basin.cpp:1224
@ NPC_CRUNCHY
Definition: zone_sholazar_basin.cpp:1210
@ SPELL_APPLE_FALL
Definition: zone_sholazar_basin.cpp:1216
@ SAY_WILHELM_MISS
Definition: zone_sholazar_basin.cpp:1223
@ EVENT_MISS_BIRD
Definition: zone_sholazar_basin.cpp:1221
@ EVENT_MISS
Definition: zone_sholazar_basin.cpp:1219
@ NPC_THICKBIRD
Definition: zone_sholazar_basin.cpp:1211
@ NPC_APPLE
Definition: zone_sholazar_basin.cpp:1208
@ SPELL_HIT_APPLE
Definition: zone_sholazar_basin.cpp:1213
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:135
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:3057
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2409
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
Definition: Player.h:1046
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:17862
MotionMaster * GetMotionMaster()
Definition: Unit.h:2262
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:210
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.

1314 {
1317 }
#define SpellCheckCastFn(F)
Definition: SpellScript.h:329
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_DUMMY
Definition: SharedDefines.h:753
HookList< CheckCastHandler > OnCheckCast
Definition: SpellScript.h:328
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
void HandleDummy(SpellEffIndex)
Definition: zone_sholazar_basin.cpp:1247
SpellCastResult CheckCast()
Definition: zone_sholazar_basin.cpp:1237

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