TrinityCore
Loading...
Searching...
No Matches
boss_sartura.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ScriptMgr.h"
19#include "InstanceScript.h"
20#include "ScriptedCreature.h"
21#include "SpellAuraEffects.h"
22#include "SpellScript.h"
23#include "temple_of_ahnqiraj.h"
24#include "Player.h"
25
33
35{
36 // Sartura
41
42 // Guard
45};
46
59
60// 15516 - Battleguard Sartura
61struct boss_sartura : public BossAI
62{
63 boss_sartura(Creature* creature) : BossAI(creature, DATA_SARTURA), _frenzied(false) { }
64
65 void Reset() override
66 {
67 _Reset();
68 _frenzied = false;
69 }
70
80
81 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
82 {
83 if (!_frenzied && me->HealthBelowPctDamaged(25, damage))
84 {
85 _frenzied = true;
87 }
88 }
89
90 void OnSpellCast(SpellInfo const* spell) override
91 {
92 if (spell->Id == SPELL_FRENZY)
94 }
95
96 void KilledUnit(Unit* /*victim*/) override
97 {
99 }
100
101 void JustDied(Unit* /*killer*/) override
102 {
104 _JustDied();
105 }
106
107 void UpdateAI(uint32 diff) override
108 {
109 if (!UpdateVictim())
110 return;
111
112 events.Update(diff);
113
115 return;
116
117 while (uint32 eventId = events.ExecuteEvent())
118 {
119 switch (eventId)
120 {
123 events.Repeat(2s, 5s);
124 break;
125 case EVENT_WHIRLWIND:
127 events.Repeat(20s, 25s);
128 break;
129 case EVENT_FRENZY:
131 break;
132 case EVENT_BERSERK:
134 break;
135 default:
136 break;
137 }
138
140 return;
141 }
142
144 }
145
146private:
148};
149
150// 15984 - Sartura's Royal Guard
152{
153 npc_sartura_royal_guard(Creature* creature) : ScriptedAI(creature) { }
154
155 void Reset() override
156 {
157 _events.Reset();
158 }
159
160 void JustEngagedWith(Unit* /*who*/) override
161 {
164 }
165
166 void UpdateAI(uint32 diff) override
167 {
168 if (!UpdateVictim())
169 return;
170
171 _events.Update(diff);
172
174 return;
175
176 while (uint32 eventId = _events.ExecuteEvent())
177 {
178 switch (eventId)
179 {
180 case EVENT_KNOCKBACK:
182 _events.Repeat(20s, 30s);
183 break;
186 _events.Repeat(10s, 20s);
187 break;
188 default:
189 break;
190 }
191
193 return;
194 }
195
197 }
198
199private:
201};
202
203// 26084 - Whirlwind
204// 26686 - Whirlwind
206{
208
209 void HandleScript(SpellEffIndex /*effIndex*/)
210 {
211 Creature* caster = GetCaster()->ToCreature();
212 if (!caster)
213 return;
214
215 SpellInfo const* spellInfo = GetTriggeringSpell();
216 if (!spellInfo)
217 return;
218
219 if (AuraEffect const* eff = caster->GetAuraEffect(spellInfo->Id, EFFECT_0))
220 {
221 if (eff->GetTickNumber() != spellInfo->GetMaxTicks())
222 {
223 if (spellInfo->Id == SPELL_WHIRLWIND_GUARD)
224 if (urand(0, 2))
225 return;
226
227 // This requires additional research
229 if (Unit* target = caster->AI()->SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
230 caster->GetThreatManager().AddThreat(target, 100000.0f);
231 }
232 else
234 }
235 }
236
241};
242
243// 4052
245{
246public:
247 at_aq_battleguard_sartura() : AreaTriggerScript("at_aq_battleguard_sartura") { }
248
249 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
250 {
251 if (InstanceScript* instance = player->GetInstanceScript())
252 if (Creature* sartura = instance->GetCreature(DATA_SARTURA))
253 sartura->AI()->AttackStart(player);
254
255 return true;
256 }
257};
258
uint32_t uint32
Definition Define.h:133
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
void AddSC_boss_sartura()
SarturaTexts
@ SAY_DEATH
@ SAY_AGGRO
@ EMOTE_FRENZY
@ SAY_SLAY
SarturaEvents
@ EVENT_SUNDERING_CLEAVE
@ EVENT_WHIRLWIND
@ EVENT_WHIRLWIND_GUARD
@ EVENT_KNOCKBACK
@ EVENT_BERSERK
@ EVENT_FRENZY
SarturaSpells
@ SPELL_SUNDERING_CLEAVE
@ SPELL_KNOCKBACK
@ SPELL_FRENZY
@ SPELL_WHIRLWIND_GUARD
@ SPELL_BERSERK
@ SPELL_WHIRLWIND
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
CreatureAI * AI() const
Definition Creature.h:154
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
static Creature * ToCreature(Object *o)
Definition Object.h:186
uint32 GetMaxTicks() const
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
SpellInfo const * GetTriggeringSpell() const
void AddThreat(Unit *target, float amount, SpellInfo const *spell=nullptr, bool ignoreModifiers=false, bool ignoreRedirects=false)
== AFFECT MY THREAT LIST ==
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
Definition Unit.h:769
ThreatManager & GetThreatManager()
Definition Unit.h:1155
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition Unit.cpp:4359
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
PrepareSpellScript(spell_sartura_whirlwind)
void HandleScript(SpellEffIndex)
void KilledUnit(Unit *) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void OnSpellCast(SpellInfo const *spell) override
boss_sartura(Creature *creature)
void JustEngagedWith(Unit *who) override
void Reset() override
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
npc_sartura_royal_guard(Creature *creature)
#define RegisterAQ40CreatureAI(ai_name)
@ DATA_SARTURA