TrinityCore
boss_keristrasza.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 "GameObject.h"
20#include "GameObjectAI.h"
21#include "InstanceScript.h"
22#include "nexus.h"
23#include "ObjectAccessor.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
26#include "SpellScript.h"
27
29{
30 //Spells
39};
40
42{
46};
47
49{
50 // Yell
56 SAY_FRENZY = 5
57};
58
59enum Misc
60{
63};
64
65struct boss_keristrasza : public BossAI
66{
68 {
69 Initialize();
70 }
71
73 {
74 _enrage = false;
75 _intenseCold = true;
76 }
77
78 void Reset() override
79 {
80 Initialize();
81 _intenseColdList.clear();
82
84 _Reset();
85 }
86
87 void JustEngagedWith(Unit* who) override
88 {
92
96 }
97
98 void JustDied(Unit* /*killer*/) override
99 {
101 _JustDied();
102 }
103
104 void KilledUnit(Unit* who) override
105 {
106 if (who->GetTypeId() == TYPEID_PLAYER)
107 Talk(SAY_SLAY);
108 }
109
110 bool CheckContainmentSpheres(bool remove_prison = false)
111 {
115
116 for (uint8 i = 0; i < DATA_CONTAINMENT_SPHERES; ++i)
117 {
119 if (!ContainmentSphere)
120 return false;
121 if (ContainmentSphere->GetGoState() != GO_STATE_ACTIVE)
122 return false;
123 }
124 if (remove_prison)
125 RemovePrison(true);
126 return true;
127 }
128
129 void RemovePrison(bool remove)
130 {
131 if (remove)
132 {
133 me->SetImmuneToAll(false);
136 }
137 else
138 {
139 me->SetImmuneToAll(true);
141 }
142 }
143
144 void SetGUID(ObjectGuid const& guid, int32 id) override
145 {
146 if (id == DATA_INTENSE_COLD)
147 _intenseColdList.push_back(guid);
148 }
149
150 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
151 {
152 if (!_enrage && me->HealthBelowPctDamaged(25, damage))
153 {
157 _enrage = true;
158 }
159 }
160
161 void UpdateAI(uint32 diff) override
162 {
163 if (!UpdateVictim())
164 return;
165
166 events.Update(diff);
167
169 return;
170
171 while (uint32 eventId = events.ExecuteEvent())
172 {
173 switch (eventId)
174 {
178 break;
182 break;
183 case EVENT_TAIL_SWEEP:
185 if (IsHeroic())
187 else if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
190 break;
191 default:
192 break;
193 }
194
196 return;
197 }
198 }
199
200private:
204public:
206};
207
209{
210 containment_sphere(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
211
213
214 bool OnGossipHello(Player* /*player*/) override
215 {
217 if (keristrasza && keristrasza->IsAlive())
218 {
219 // maybe these are hacks :(
222
223 ENSURE_AI(boss_keristrasza, keristrasza->AI())->CheckContainmentSpheres(true);
224 }
225 return true;
226 }
227};
228
229// 48095 - Intense Cold
231{
232 void HandlePeriodicTick(AuraEffect const* /*aurEff*/)
233 {
234 if (GetStackAmount() < 2)
235 return;
236 Unit* caster = GetCaster();
238 if (!caster || !caster->GetAI())
239 return;
240 caster->GetAI()->SetGUID(GetTarget()->GetGUID(), DATA_INTENSE_COLD);
241 }
242
243 void Register() override
244 {
246 }
247};
248
250{
251 public:
253 {
254 }
255
256 bool OnCheck(Player* player, Unit* target) override
257 {
258 if (!target)
259 return false;
260
261 GuidList const& _intenseColdList = ENSURE_AI(boss_keristrasza, target->GetAI())->_intenseColdList;
262 if (!_intenseColdList.empty())
263 for (GuidList::const_iterator itr = _intenseColdList.begin(); itr != _intenseColdList.end(); ++itr)
264 if (player->GetGUID() == *itr)
265 return false;
266
267 return true;
268 }
269};
270
272{
277}
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
@ EFFECT_1
Definition: SharedDefines.h:31
@ GO_FLAG_NOT_SELECTABLE
@ GO_STATE_ACTIVE
@ SPELL_AURA_PERIODIC_DAMAGE
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define ENSURE_AI(a, b)
Definition: UnitAI.h:29
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ DATA_CONTAINMENT_SPHERES
@ DATA_INTENSE_COLD
@ SAY_CRYSTAL_NOVA
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_SLAY
@ SAY_FRENZY
@ SAY_ENRAGE
@ SPELL_ENRAGE
@ SPELL_INTENSE_COLD
@ SPELL_INTENSE_COLD_TRIGGERED
@ SPELL_CRYSTALFIRE_BREATH
@ SPELL_CRYSTAL_CHAINS
@ SPELL_FROZEN_PRISON
@ SPELL_TAIL_SWEEP
@ SPELL_CRYSTALLIZE
void AddSC_boss_keristrasza()
@ EVENT_TAIL_SWEEP
@ EVENT_CRYSTAL_FIRE_BREATH
@ EVENT_CRYSTAL_CHAINS_CRYSTALLIZE
Yells
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetCaster() const
Unit * GetTarget() const
uint8 GetStackAmount() const
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetImmuneToAll(bool apply) override
Definition: Creature.h:167
CreatureAI * AI() const
Definition: Creature.h:214
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
GameObject *const me
Definition: GameObjectAI.h:50
void SetGoState(GOState state)
GOState GetGoState() const
Definition: GameObject.h:281
void SetFlag(GameObjectFlags flags)
Definition: GameObject.h:274
virtual ObjectGuid GetGuidData(uint32 type) const override
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
virtual void SetGUID(ObjectGuid const &, int32=0)
Definition: UnitAI.h:75
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
bool IsAlive() const
Definition: Unit.h:1164
UnitAI * GetAI() const
Definition: Unit.h:660
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
bool OnCheck(Player *player, Unit *target) override
void HandlePeriodicTick(AuraEffect const *)
void Register() override
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
#define RegisterNexusGameObjectAI(ai_name)
Definition: nexus.h:75
@ ANOMALUS_CONTAINMENT_SPHERE
Definition: nexus.h:36
@ ORMOROKS_CONTAINMENT_SPHERE
Definition: nexus.h:37
@ TELESTRAS_CONTAINMENT_SPHERE
Definition: nexus.h:38
@ DATA_KERISTRASZA
Definition: nexus.h:34
#define RegisterNexusCreatureAI(ai_name)
Definition: nexus.h:74
bool IsHeroic() const
T const & DUNGEON_MODE(T const &normal5, T const &heroic10) const
void Reset() override
void KilledUnit(Unit *who) override
void JustEngagedWith(Unit *who) override
void UpdateAI(uint32 diff) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
boss_keristrasza(Creature *creature)
void JustDied(Unit *) override
bool CheckContainmentSpheres(bool remove_prison=false)
void RemovePrison(bool remove)
void SetGUID(ObjectGuid const &guid, int32 id) override
ObjectGuid ContainmentSphereGUIDs[DATA_CONTAINMENT_SPHERES]
InstanceScript * instance
bool OnGossipHello(Player *) override
containment_sphere(GameObject *go)