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

Private Member Functions

 PrepareSpellScript (spell_chapter5_return_to_capital)
 
bool Validate (SpellInfo const *) override
 
void HandleHit (SpellEffIndex)
 
void Register () override
 

Private Attributes

uint8 _emote
 

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

◆ HandleHit()

void spell_chapter5_return_to_capital::HandleHit ( SpellEffIndex  )
inlineprivate
2501 {
2502 Creature* creature = GetHitUnit()->ToCreature();
2503 Player* player = GetCaster()->ToPlayer();
2504 uint32 spellId = GetSpellInfo()->Id;
2505
2506 if (!spellId || !creature || !player || player->IsGameMaster() || !player->IsAlive() || !creature->IsAlive() || creature->IsInCombat())
2507 return;
2508
2509 if (creature->HasSpellCooldown(spellId))
2510 return;
2511
2512 if (creature->GetEntry() == NPC_SW_GUARD || creature->GetEntry() == NPC_ROYAL_GUARD || creature->GetEntry() == NPC_CITY_PATROLLER || creature->GetEntry() == NPC_OG_GUARD || creature->GetEntry() == NPC_KOR_ELITE)
2513 {
2514 _emote = urand(2,4);
2515 if (creature)
2516 {
2517 creature->PauseMovement(5000);
2518 creature->SetFacingToObject(player, 30s);
2519
2520 if (roll_chance_i(30))
2521 {
2522 creature->AI()->Talk(_emote, player);
2523 creature->CastSpell(player, ReturnToCapitalSpells[_emote - 2]);
2524 }
2525 else
2526 {
2527 creature->AI()->Talk(SAY_INSULT_TO_DK, player);
2529 }
2530 }
2531 }
2532 /*/// @todo: This needs to be further investigated as there are some "guard" npcs, that have civilian flags and non guard npcs should also insult the dk.
2533 else
2534 if (creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN)
2535 {
2536 creature->HandleEmoteCommand(EMOTE_STATE_COWER); // from sniff, emote 431 for a while, then reset (with "%s cowers in fear." text)
2537 creature->PlayDirectSound(14556); // from sniff
2538 if (player)
2539 {
2540 LocaleConstant loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
2541 if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(TEXT_BROADCAST_COWER))
2542 creature->TextEmote(bct->GetText(loc_idx, creature->getGender()), creature);
2543 }
2544 }
2545 */
2546
2547 creature->AddSpellCooldown(spellId, 0, 30000);
2548 }
static First const & RAND(First const &first, Second const &second, Rest const &... rest)
Definition CreatureAIImpl.h:25
std::uint32_t uint32
Definition Define.h:107
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
bool roll_chance_i(int chance)
Definition Random.h:63
@ EMOTE_ONESHOT_POINT
Definition SharedDefines.h:1921
@ EMOTE_ONESHOT_RUDE
Definition SharedDefines.h:1910
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
bool HasSpellCooldown(uint32 spell_id) const override
Definition Creature.cpp:3044
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition Creature.cpp:2989
CreatureAI * AI() const
Definition Creature.h:144
Player * ToPlayer()
Definition Object.h:202
uint32 GetEntry() const
Definition Object.h:117
Creature * ToCreature()
Definition Object.h:206
Definition Player.h:1086
bool IsGameMaster() const
Definition Player.h:1178
uint32 Id
Definition SpellInfo.h:344
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:411
Unit * GetHitUnit()
Definition SpellScript.cpp:448
Unit * GetCaster()
Definition SpellScript.cpp:401
void SetFacingToObject(WorldObject *object, Milliseconds timed=0ms)
Definition Unit.cpp:16465
bool IsAlive() const
Definition Unit.h:1793
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:1361
virtual void PauseMovement(uint32 timer=0, uint8 slot=0)
Disable the unit movement by clearing UNIT_STATE_MOVING and stopping the spline.
Definition Unit.cpp:13053
void HandleEmoteCommand(uint32 emoteId)
Definition Unit.cpp:2187
bool IsInCombat() const
Definition Unit.h:936
uint8 _emote
Definition zone_the_scarlet_enclave.cpp:2555
uint32 ReturnToCapitalSpells[3]
Definition zone_the_scarlet_enclave.cpp:2484
@ NPC_CITY_PATROLLER
Definition zone_the_scarlet_enclave.cpp:2477
@ SAY_INSULT_TO_DK
Definition zone_the_scarlet_enclave.cpp:2473
@ NPC_SW_GUARD
Definition zone_the_scarlet_enclave.cpp:2475
@ NPC_ROYAL_GUARD
Definition zone_the_scarlet_enclave.cpp:2476
@ NPC_OG_GUARD
Definition zone_the_scarlet_enclave.cpp:2478
@ NPC_KOR_ELITE
Definition zone_the_scarlet_enclave.cpp:2479

References _emote, Creature::AddSpellCooldown(), Creature::AI(), Unit::CastSpell(), EMOTE_ONESHOT_POINT, EMOTE_ONESHOT_RUDE, SpellScript::GetCaster(), Object::GetEntry(), SpellScript::GetHitUnit(), SpellScript::GetSpellInfo(), Unit::HandleEmoteCommand(), Creature::HasSpellCooldown(), SpellInfo::Id, Unit::IsAlive(), Player::IsGameMaster(), Unit::IsInCombat(), NPC_CITY_PATROLLER, NPC_KOR_ELITE, NPC_OG_GUARD, NPC_ROYAL_GUARD, NPC_SW_GUARD, Unit::PauseMovement(), RAND(), ReturnToCapitalSpells, roll_chance_i(), SAY_INSULT_TO_DK, Unit::SetFacingToObject(), CreatureAI::Talk(), Object::ToCreature(), Object::ToPlayer(), and urand().

Referenced by Register().

◆ PrepareSpellScript()

spell_chapter5_return_to_capital::PrepareSpellScript ( spell_chapter5_return_to_capital  )
private

◆ Register()

void spell_chapter5_return_to_capital::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

2551 {
2553 }
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:769
#define SpellEffectFn(F, I, N)
Definition SpellScript.h:337
HookList< EffectHandler > OnEffectHitTarget
Definition SpellScript.h:336
void HandleHit(SpellEffIndex)
Definition zone_the_scarlet_enclave.cpp:2500

References EFFECT_0, HandleHit(), SpellScript::OnEffectHitTarget, SPELL_EFFECT_DUMMY, and SpellEffectFn.

◆ Validate()

bool spell_chapter5_return_to_capital::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

2496 {
2498 }
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition SpellScript.h:125
@ SPELL_RETURN_TO_ORGRIMMAR_SPIT
Definition zone_the_scarlet_enclave.cpp:2468
@ SPELL_RETURN_TO_ORGRIMMAR_APPLE
Definition zone_the_scarlet_enclave.cpp:2466
@ SPELL_RETURN_TO_ORGRIMMAR_BANANA
Definition zone_the_scarlet_enclave.cpp:2467

References SPELL_RETURN_TO_ORGRIMMAR_APPLE, SPELL_RETURN_TO_ORGRIMMAR_BANANA, SPELL_RETURN_TO_ORGRIMMAR_SPIT, and _SpellScript::ValidateSpellInfo().

Member Data Documentation

◆ _emote

uint8 spell_chapter5_return_to_capital::_emote
private

Referenced by HandleHit().


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