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
1108 {
1109 Creature* creature = GetHitCreature();
1110 Player* player = GetCaster()->ToPlayer();
1111
1112 if (!creature || !player)
1113 return;
1114
1116 return;
1117
1118 sCreatureTextMgr->SendChat(creature, SAY_PERSUADE_RAND, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, player);
1119
1120 if (roll_chance_f(30.0f))
1121 {
1122 creature->CombatStop(true);
1123 creature->GetMotionMaster()->MoveIdle();
1124 creature->SetImmuneToPC(true);
1126 creature->SetReactState(REACT_PASSIVE);
1127
1128 creature->AI()->Talk(SAY_PERSUADED1, 8s);
1129 creature->AI()->Talk(SAY_PERSUADED2, 16s);
1130 creature->AI()->Talk(SAY_PERSUADED3, 24s);
1131 creature->AI()->Talk(SAY_PERSUADED4, 32s);
1132
1133 ObjectGuid playerGuid = player->GetGUID();
1134
1135 creature->m_Events.AddEventAtOffset([creature, playerGuid]
1136 {
1137 if (Player* caster = ObjectAccessor::GetPlayer(*creature, playerGuid))
1138 sCreatureTextMgr->SendChat(creature, SAY_PERSUADED5, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, caster);
1139 }, 40s);
1140
1141 creature->m_Events.AddEventAtOffset([creature, playerGuid]
1142 {
1143 creature->AI()->Talk(SAY_PERSUADED6);
1144
1145 if (Player* caster = ObjectAccessor::GetPlayer(*creature, playerGuid))
1146 {
1147 Unit::Kill(caster, creature);
1148 caster->GroupEventHappens(QUEST_HOW_TO_WIN_FRIENDS, creature);
1149 }
1150 else
1151 creature->KillSelf();
1152 }, 48s);
1153 }
1154 else
1155 creature->AI()->Talk(SAY_CRUSADER, 1s);
1156 }
#define sCreatureTextMgr
Definition CreatureTextMgr.h:123
@ TEXT_RANGE_NORMAL
Definition CreatureTextMgr.h:30
bool roll_chance_f(float chance)
Definition Random.h:57
@ CHAT_MSG_ADDON
Definition SharedDefines.h:3384
@ 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:567
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:100
CreatureAI * AI() const
Definition Creature.h:144
void AddEventAtOffset(BasicEvent *event, Milliseconds offset, uint8 eventGroup=0)
Definition EventProcessor.h:108
void MoveIdle()
Definition MotionMaster.cpp:235
Definition ObjectGuid.h:121
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:1086
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:13975
MotionMaster * GetMotionMaster()
Definition Unit.h:1758
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:7532
void SetUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition Unit.h:749
void KillSelf(bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition Unit.h:1235
void SetImmuneToPC(bool apply, bool keepCombat=false)
Definition Unit.cpp:10631
EventProcessor m_Events
Definition Object.h:742
Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:244
@ NPC_SCARLET_LORD_MCCREE
Definition zone_the_scarlet_enclave.cpp:1093
@ SAY_CRUSADER
Definition zone_the_scarlet_enclave.cpp:1079
@ SAY_PERSUADED4
Definition zone_the_scarlet_enclave.cpp:1083
@ QUEST_HOW_TO_WIN_FRIENDS
Definition zone_the_scarlet_enclave.cpp:1087
@ SAY_PERSUADED5
Definition zone_the_scarlet_enclave.cpp:1084
@ NPC_SCARLET_COMMANDER
Definition zone_the_scarlet_enclave.cpp:1090
@ SAY_PERSUADED3
Definition zone_the_scarlet_enclave.cpp:1082
@ SAY_PERSUADED2
Definition zone_the_scarlet_enclave.cpp:1081
@ SAY_PERSUADE_RAND
Definition zone_the_scarlet_enclave.cpp:1086
@ NPC_SCARLET_PREACHER
Definition zone_the_scarlet_enclave.cpp:1089
@ NPC_SCARLET_CRUSADER
Definition zone_the_scarlet_enclave.cpp:1091
@ SAY_PERSUADED6
Definition zone_the_scarlet_enclave.cpp:1085
@ SAY_PERSUADED1
Definition zone_the_scarlet_enclave.cpp:1080
@ NPC_SCARLET_MARKSMAN
Definition zone_the_scarlet_enclave.cpp:1092

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.

1102 {
1103 return GetCaster() && GetCaster()->IsPlayer()
1105 }
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:103
bool IsPlayer() const
Definition Object.h:201
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1489

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.

1159 {
1161 }
@ 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:1107

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


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