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
1259 {
1260 Creature* creature = GetHitUnit()->ToCreature();
1261 Player* player = GetCaster()->ToPlayer();
1262 uint32 spellId = GetSpellInfo()->Id;
1263
1264 if (!spellId || !creature || !player || player->IsGameMaster() || !player->IsAlive() || !creature->IsAlive() || creature->IsInCombat())
1265 return;
1266
1267 if (creature->HasSpellCooldown(spellId))
1268 return;
1269
1270 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)
1271 {
1272 _emote = urand(2,4);
1273 if (creature)
1274 {
1275 creature->PauseMovement(5000);
1276 creature->SetTimedFacingToObject(player, 30000);
1277
1278 if (roll_chance_i(30))
1279 {
1280 creature->AI()->Talk(_emote, player);
1281 creature->CastSpell(player, ReturnToCapitalSpells[_emote - 2]);
1282 }
1283 else
1284 {
1285 creature->AI()->Talk(SAY_INSULT_TO_DK, player);
1287 }
1288 }
1289 }
1290 /*/// @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.
1291 else
1292 if (creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN)
1293 {
1294 creature->HandleEmoteCommand(EMOTE_STATE_COWER); // from sniff, emote 431 for a while, then reset (with "%s cowers in fear." text)
1295 creature->PlayDirectSound(14556); // from sniff
1296 if (player)
1297 {
1298 LocaleConstant loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
1299 if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(TEXT_BROADCAST_COWER))
1300 creature->TextEmote(bct->GetText(loc_idx, creature->getGender()), creature);
1301 }
1302 }
1303 */
1304
1305 creature->AddSpellCooldown(spellId, 0, 30000);
1306 }
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:1917
@ EMOTE_ONESHOT_RUDE
Definition SharedDefines.h:1906
uint32 ReturnToCapitalSpells[3]
Definition chapter5.cpp:1242
@ NPC_CITY_PATROLLER
Definition chapter5.cpp:1235
@ SAY_INSULT_TO_DK
Definition chapter5.cpp:1231
@ NPC_SW_GUARD
Definition chapter5.cpp:1233
@ NPC_ROYAL_GUARD
Definition chapter5.cpp:1234
@ NPC_OG_GUARD
Definition chapter5.cpp:1236
@ NPC_KOR_ELITE
Definition chapter5.cpp:1237
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:52
Definition Creature.h:43
bool HasSpellCooldown(uint32 spell_id) const override
Definition Creature.cpp:2930
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition Creature.cpp:2875
CreatureAI * AI() const
Definition Creature.h:141
Player * ToPlayer()
Definition Object.h:202
uint32 GetEntry() const
Definition Object.h:116
Creature * ToCreature()
Definition Object.h:206
Definition Player.h:1082
bool IsGameMaster() const
Definition Player.h:1176
uint32 Id
Definition SpellInfo.h:320
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:411
Unit * GetHitUnit()
Definition SpellScript.cpp:448
Unit * GetCaster()
Definition SpellScript.cpp:401
bool IsAlive() const
Definition Unit.h:1698
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:1179
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:16702
void SetTimedFacingToObject(WorldObject *object, uint32 time)
Definition Unit.cpp:20350
void HandleEmoteCommand(uint32 emoteId)
Definition Unit.cpp:2012
bool IsInCombat() const
Definition Unit.h:877
uint8 _emote
Definition chapter5.cpp:1313

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::SetTimedFacingToObject(), 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.

1309 {
1311 }
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:781
#define SpellEffectFn(F, I, N)
Definition SpellScript.h:337
HookList< EffectHandler > OnEffectHitTarget
Definition SpellScript.h:336
void HandleHit(SpellEffIndex)
Definition chapter5.cpp:1258

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.

1254 {
1256 }
@ SPELL_RETURN_TO_ORGRIMMAR_SPIT
Definition chapter5.cpp:1226
@ SPELL_RETURN_TO_ORGRIMMAR_APPLE
Definition chapter5.cpp:1224
@ SPELL_RETURN_TO_ORGRIMMAR_BANANA
Definition chapter5.cpp:1225
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition SpellScript.h:125

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: