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

Private Member Functions

 PrepareSpellScript (spell_chapter2_persuasive_strike)
 
bool Load () override
 
void HandleHit (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 bool Validate (SpellInfo const *)
 
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_chapter2_persuasive_strike::HandleHit ( SpellEffIndex  )
inlineprivate
982 {
983 Creature* creature = GetHitCreature();
984 Player* player = GetCaster()->ToPlayer();
985
986 if (!creature || !player)
987 return;
988
990 return;
991
992 sCreatureTextMgr->SendChat(creature, SAY_PERSUADE_RAND, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, player);
993
994 if (roll_chance_f(30.0f))
995 {
996 creature->CombatStop(true);
997 creature->GetMotionMaster()->MoveIdle();
998 creature->SetImmuneToPC(true);
1000 creature->SetReactState(REACT_PASSIVE);
1001
1002 creature->AI()->Talk(SAY_PERSUADED1, 8s);
1003 creature->AI()->Talk(SAY_PERSUADED2, 16s);
1004 creature->AI()->Talk(SAY_PERSUADED3, 24s);
1005 creature->AI()->Talk(SAY_PERSUADED4, 32s);
1006
1007 ObjectGuid playerGuid = player->GetGUID();
1008
1009 creature->m_Events.AddEventAtOffset([creature, playerGuid]
1010 {
1011 if (Player* caster = ObjectAccessor::GetPlayer(*creature, playerGuid))
1012 sCreatureTextMgr->SendChat(creature, SAY_PERSUADED5, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, caster);
1013 }, 40s);
1014
1015 creature->m_Events.AddEventAtOffset([creature, playerGuid]
1016 {
1017 creature->AI()->Talk(SAY_PERSUADED6);
1018
1019 if (Player* caster = ObjectAccessor::GetPlayer(*creature, playerGuid))
1020 {
1021 Unit::Kill(caster, creature);
1022 caster->GroupEventHappens(QUEST_HOW_TO_WIN_FRIENDS, creature);
1023 }
1024 else
1025 creature->KillSelf();
1026 }, 48s);
1027 }
1028 else
1029 creature->AI()->Talk(SAY_CRUSADER, 1s);
1030 }
#define sCreatureTextMgr
Definition CreatureTextMgr.h:110
@ TEXT_RANGE_NORMAL
Definition CreatureTextMgr.h:30
bool roll_chance_f(float chance)
Definition Random.h:57
@ CHAT_MSG_ADDON
Definition SharedDefines.h:3386
@ LANG_ADDON
Definition SharedDefines.h:741
@ TEAM_NEUTRAL
Definition SharedDefines.h:750
@ UNIT_FLAG_NON_ATTACKABLE
Definition UnitDefines.h:258
@ REACT_PASSIVE
Definition Unit.h:566
@ NPC_SCARLET_LORD_MCCREE
Definition chapter2.cpp:967
@ SAY_CRUSADER
Definition chapter2.cpp:953
@ SAY_PERSUADED4
Definition chapter2.cpp:957
@ QUEST_HOW_TO_WIN_FRIENDS
Definition chapter2.cpp:961
@ SAY_PERSUADED5
Definition chapter2.cpp:958
@ NPC_SCARLET_COMMANDER
Definition chapter2.cpp:964
@ SAY_PERSUADED3
Definition chapter2.cpp:956
@ SAY_PERSUADED2
Definition chapter2.cpp:955
@ SAY_PERSUADE_RAND
Definition chapter2.cpp:960
@ NPC_SCARLET_PREACHER
Definition chapter2.cpp:963
@ NPC_SCARLET_CRUSADER
Definition chapter2.cpp:965
@ SAY_PERSUADED6
Definition chapter2.cpp:959
@ SAY_PERSUADED1
Definition chapter2.cpp:954
@ NPC_SCARLET_MARKSMAN
Definition chapter2.cpp:966
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
void SetReactState(ReactStates state)
A creature can have 3 ReactStates : Agressive, Passive, Neutral.
Definition Creature.h:99
CreatureAI * AI() const
Definition Creature.h:143
void AddEventAtOffset(BasicEvent *event, Milliseconds offset, uint8 eventGroup=0)
Definition EventProcessor.h:108
void MoveIdle()
Definition MotionMaster.cpp:234
Definition ObjectGuid.h:118
Player * ToPlayer()
Definition Object.h:202
bool EntryEquals(T... entries) const
Definition Object.h:234
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
Definition Player.h:1084
Creature * GetHitCreature()
Definition SpellScript.cpp:458
Unit * GetCaster()
Definition SpellScript.cpp:401
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:13938
MotionMaster * GetMotionMaster()
Definition Unit.h:1758
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:7469
void SetUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition Unit.h:748
void KillSelf(bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition Unit.h:1234
void SetImmuneToPC(bool apply, bool keepCombat=false)
Definition Unit.cpp:10597
EventProcessor m_Events
Definition Object.h:736
Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:220

References EventProcessor::AddEventAtOffset(), Creature::AI(), CHAT_MSG_ADDON, Unit::CombatStop(), Object::EntryEquals(), SpellScript::GetCaster(), Object::GetGUID(), SpellScript::GetHitCreature(), Unit::GetMotionMaster(), ObjectAccessor::GetPlayer(), Unit::Kill(), Unit::KillSelf(), LANG_ADDON, WorldObject::m_Events, MotionMaster::MoveIdle(), NPC_SCARLET_COMMANDER, NPC_SCARLET_CRUSADER, NPC_SCARLET_LORD_MCCREE, NPC_SCARLET_MARKSMAN, NPC_SCARLET_PREACHER, QUEST_HOW_TO_WIN_FRIENDS, REACT_PASSIVE, roll_chance_f(), SAY_CRUSADER, SAY_PERSUADE_RAND, SAY_PERSUADED1, SAY_PERSUADED2, SAY_PERSUADED3, SAY_PERSUADED4, SAY_PERSUADED5, SAY_PERSUADED6, sCreatureTextMgr, Unit::SetImmuneToPC(), Creature::SetReactState(), Unit::SetUnitFlag(), CreatureAI::Talk(), TEAM_NEUTRAL, TEXT_RANGE_NORMAL, Object::ToPlayer(), and UNIT_FLAG_NON_ATTACKABLE.

Referenced by Register().

◆ Load()

bool spell_chapter2_persuasive_strike::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

976 {
977 return GetCaster() && GetCaster()->IsPlayer()
979 }
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:103
bool IsPlayer() const
Definition Object.h:201
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1462

References SpellScript::GetCaster(), Player::GetQuestStatus(), Object::IsPlayer(), QUEST_HOW_TO_WIN_FRIENDS, QUEST_STATUS_INCOMPLETE, and Object::ToPlayer().

◆ PrepareSpellScript()

spell_chapter2_persuasive_strike::PrepareSpellScript ( spell_chapter2_persuasive_strike  )
private

◆ Register()

void spell_chapter2_persuasive_strike::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

1033 {
1035 }
@ 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 chapter2.cpp:981

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


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