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

Private Member Functions

 PrepareSpellScript (spell_the_flag_of_ownership)
 
bool Load () override
 
void HandleScript (SpellEffIndex)
 
void FilterTargets (std::list< WorldObject * > &targets)
 
void HandleFinish ()
 
void Register () override
 

Private Attributes

bool haveTarget
 

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

◆ FilterTargets()

void spell_the_flag_of_ownership::FilterTargets ( std::list< WorldObject * > &  targets)
inlineprivate
155 {
156 for( std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); )
157 {
158 if (!(*itr)->IsPlayer() || (*itr)->ToPlayer()->IsAlive())
159 {
160 targets.erase(itr);
161 itr = targets.begin();
162 continue;
163 }
164 ++itr;
165 }
166 }

Referenced by Register().

◆ HandleFinish()

void spell_the_flag_of_ownership::HandleFinish ( )
inlineprivate
169 {
170 Unit* caster = GetCaster();
171 if (!caster || !caster->ToPlayer())
172 return;
173
174 if (!haveTarget)
175 {
176 caster->ToPlayer()->RemoveSpellCooldown(GetSpellInfo()->Id, true);
178 }
179 }
@ SPELL_FAILED_BAD_TARGETS
Definition: SharedDefines.h:961
Player * ToPlayer()
Definition: Object.h:201
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition: Player.cpp:3536
Definition: Unit.h:630
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
Definition: Spell.cpp:4674
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:411
Unit * GetCaster()
Definition: SpellScript.cpp:401
bool haveTarget
Definition: spell_generic.cpp:129

References SpellScript::GetCaster(), SpellScript::GetSpellInfo(), haveTarget, Player::RemoveSpellCooldown(), Spell::SendCastResult(), SPELL_FAILED_BAD_TARGETS, and Object::ToPlayer().

Referenced by Register().

◆ HandleScript()

void spell_the_flag_of_ownership::HandleScript ( SpellEffIndex  )
inlineprivate
137 {
138 Unit* caster = GetCaster();
139 if (!caster || !caster->IsPlayer())
140 return;
141 Player* target = GetHitPlayer();
142 if (!target)
143 return;
144 caster->CastSpell(target, SPELL_TAUNT_FLAG, true);
145
147 BroadcastText const* bct = sObjectMgr->GetBroadcastText(TEXT_FLAG_OF_OWNERSHIP);
148 std::string bctMsg = Acore::StringFormat(bct->GetText(loc_idx, caster->getGender()), caster->GetName(), target->GetName());
149 caster->Talk(bctMsg, CHAT_MSG_MONSTER_EMOTE, LANG_UNIVERSAL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target);
150
151 haveTarget = true;
152 }
LocaleConstant
Definition: Common.h:65
@ SPELL_TAUNT_FLAG
Definition: spell_generic.cpp:121
@ TEXT_FLAG_OF_OWNERSHIP
Definition: spell_generic.cpp:120
@ CHAT_MSG_MONSTER_EMOTE
Definition: SharedDefines.h:3168
@ LANG_UNIVERSAL
Definition: SharedDefines.h:735
#define sObjectMgr
Definition: ObjectMgr.h:1635
@ CONFIG_LISTEN_RANGE_TEXTEMOTE
Definition: IWorld.h:196
#define sWorld
Definition: World.h:443
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
bool IsPlayer() const
Definition: Object.h:200
std::string const & GetName() const
Definition: Object.h:463
Definition: Player.h:1081
WorldSession * GetSession() const
Definition: Player.h:1998
uint8 getGender() const
Definition: Unit.h:805
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:1167
virtual void Talk(std::string_view text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
Definition: Unit.cpp:21131
Definition: ObjectMgr.h:434
std::string const & GetText(LocaleConstant locale=DEFAULT_LOCALE, uint8 gender=GENDER_MALE, bool forceGender=false) const
Definition: ObjectMgr.h:456
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:498
Player * GetHitPlayer()
Definition: SpellScript.cpp:471

References Unit::CastSpell(), CHAT_MSG_MONSTER_EMOTE, CONFIG_LISTEN_RANGE_TEXTEMOTE, SpellScript::GetCaster(), Unit::getGender(), SpellScript::GetHitPlayer(), WorldObject::GetName(), Player::GetSession(), WorldSession::GetSessionDbLocaleIndex(), BroadcastText::GetText(), haveTarget, Object::IsPlayer(), LANG_UNIVERSAL, sObjectMgr, SPELL_TAUNT_FLAG, Acore::StringFormat(), sWorld, Unit::Talk(), TEXT_FLAG_OF_OWNERSHIP, and Object::ToPlayer().

Referenced by Register().

◆ Load()

bool spell_the_flag_of_ownership::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

131 {
132 haveTarget = false;
133 return true;
134 }

References haveTarget.

◆ PrepareSpellScript()

spell_the_flag_of_ownership::PrepareSpellScript ( spell_the_flag_of_ownership  )
private

◆ Register()

void spell_the_flag_of_ownership::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

182 {
186 }
@ EFFECT_0
Definition: SharedDefines.h:31
@ SPELL_EFFECT_DUMMY
Definition: SharedDefines.h:781
@ TARGET_CORPSE_SRC_AREA_ENEMY
Definition: SharedDefines.h:1497
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:354
#define SpellCastFn(F)
Definition: SpellScript.h:324
HookList< CastHandler > AfterCast
Definition: SpellScript.h:323
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:353
void FilterTargets(std::list< WorldObject * > &targets)
Definition: spell_generic.cpp:154
void HandleScript(SpellEffIndex)
Definition: spell_generic.cpp:136
void HandleFinish()
Definition: spell_generic.cpp:168

References SpellScript::AfterCast, EFFECT_0, FilterTargets(), HandleFinish(), HandleScript(), SpellScript::OnEffectHitTarget, SpellScript::OnObjectAreaTargetSelect, SPELL_EFFECT_DUMMY, SpellCastFn, SpellEffectFn, SpellObjectAreaTargetSelectFn, and TARGET_CORPSE_SRC_AREA_ENEMY.

Member Data Documentation

◆ haveTarget

bool spell_the_flag_of_ownership::haveTarget
private

Referenced by HandleFinish(), HandleScript(), and Load().