TrinityCore
Loading...
Searching...
No Matches
boss_ossirian.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 "Map.h"
23#include "MiscPackets.h"
24#include "ObjectAccessor.h"
25#include "Opcodes.h"
26#include "Player.h"
27#include "ruins_of_ahnqiraj.h"
28#include "ScriptedCreature.h"
29#include "SpellInfo.h"
30#include "TemporarySummon.h"
31#include "Weather.h"
32#include "WorldPacket.h"
33
43
60
65
72
78
80
82{
83 { -9188.4404296875f, 1940.2099609375f, 85.6390991210937f, 3.17650008201599f },
84 { -9244.41015625f, 1808.97998046875f, 85.6390991210937f, 5.63741016387939f },
85 { -9248.41015625f, 1974.82995605469f, 85.6390991210937f, 5.89920997619629f },
86 { -9282.080078125f, 1887.33996582031f, 85.6390991210937f, 2.00712990760803f },
87 { -9299.73046875f, 1748.44995117187f, 85.6390991210937f, 1.44861996173859f },
88 { -9357.8603515625f, 1929.07995605469f, 85.6390991210937f, 1.06465005874634f },
89 { -9367.169921875f, 1780.89001464844f, 85.6390991210937f, 1.90241003036499f },
90 { -9383.2900390625f, 2012.68005371094f, 85.6511001586914f, 2.93214988708496f },
91 { -9406.099609375f, 1862.38000488281f, 85.6390991210937f, 6.2308201789856f },
92 { -9407.7197265625f, 1960.2099609375f, 85.6390991210937f, 1.11700999736786f },
93 { -9432.400390625f, 1782.53002929687f, 85.6390991210937f, 5.86430978775024f },
94 { -9506.1904296875f, 1865.56994628906f, 85.6390991210937f, 4.27606010437012f }
95};
96
97float RoomRadius = 165.0f;
101Position const RoomCenter = { -9343.041992f, 1923.278198f, 85.555984f, 0.0 };
102
104{
105 public:
106 boss_ossirian() : CreatureScript("boss_ossirian") { }
107
108 struct boss_ossirianAI : public BossAI
109 {
111 {
112 Initialize();
113 SaidIntro = false;
114 }
115
117 {
118 CrystalIterator = 0;
121 }
122
127
128 void Reset() override
129 {
130 _Reset();
131 Initialize();
132 }
133
134 void SpellHit(WorldObject* caster, SpellInfo const* spellInfo) override
135 {
136 for (uint8 i = 0; i < NUM_WEAKNESS; ++i)
137 {
138 if (spellInfo->Id == SpellWeakness[i])
139 {
141 // Despawn used crystal
143 crystal->Delete();
144 if (Creature* creatureCaster = caster->ToCreature())
145 creatureCaster->DespawnOrUnsummon();
147 }
148 }
149 }
150
151 void DoAction(int32 action) override
152 {
153 if (action == ACTION_TRIGGER_WEAKNESS)
155 if (!Trigger->HasUnitState(UNIT_STATE_CASTING))
156 Trigger->CastSpell(Trigger, SpellWeakness[urand(0, 4)], false);
157
158 if (action == ACTION_KURINNAXX_DEFEATED && me->IsAlive())
160 }
161
162 void JustEngagedWith(Unit* who) override
163 {
165 events.Reset();
169
172
173 Map* map = me->GetMap();
174
176 map->SendToPlayers(weather.Write());
177
178 for (uint8 i = 0; i < NUM_TORNADOS; ++i)
179 {
181 if (Creature* Tornado = map->SummonCreature(NPC_SAND_VORTEX, Point))
182 Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true);
183 }
184
186 }
187
188 void KilledUnit(Unit* /*victim*/) override
189 {
190 Talk(SAY_SLAY);
191 }
192
193 void EnterEvadeMode(EvadeReason why) override
194 {
195 Cleanup();
198 }
199
200 void JustDied(Unit* /*killer*/) override
201 {
202 Cleanup();
203 _JustDied();
204 }
205
206 void Cleanup()
207 {
209 Crystal->Use(me);
210 }
211
213 {
215 CrystalIterator = 0;
216
218 {
219 TriggerGUID = Trigger->GetGUID();
221 {
222 CrystalGUID = Crystal->GetGUID();
224 }
225 }
226 }
227
228 void MoveInLineOfSight(Unit* who) override
229
230 {
231 if (!SaidIntro)
232 {
234 SaidIntro = true;
235 }
237 }
238
239 void UpdateAI(uint32 diff) override
240 {
241 if (!UpdateVictim())
242 return;
243
244 events.Update(diff);
245
246 // No kiting!
247 if (me->GetDistance(me->GetVictim()) > 60.00f && me->GetDistance(me->GetVictim()) < 120.00f)
249
250 bool ApplySupreme = true;
251
253 ApplySupreme = false;
254 else
255 {
256 for (uint8 i = 0; i < NUM_WEAKNESS; ++i)
257 {
258 if (me->HasAura(SpellWeakness[i]))
259 {
260 ApplySupreme = false;
261 break;
262 }
263 }
264 }
265
266 if (ApplySupreme)
267 {
270 }
271
272 while (uint32 eventId = events.ExecuteEvent())
273 {
274 switch (eventId)
275 {
276 case EVENT_SILENCE:
279 break;
280 case EVENT_CYCLONE:
283 break;
284 case EVENT_STOMP:
287 break;
288 default:
289 break;
290 }
291 }
292
294 }
295 };
296
297 CreatureAI* GetAI(Creature* creature) const override
298 {
299 return GetAQ20AI<boss_ossirianAI>(creature);
300 }
301};
302
304{
305 public:
306 go_ossirian_crystal() : GameObjectScript("go_ossirian_crystal") { }
307
309 {
310 go_ossirian_crystalAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
311
313
314 bool OnGossipHello(Player* player) override
315 {
316 // Crystal animation on use
318 Creature* ossirian = player->FindNearestCreature(NPC_OSSIRIAN, 30.0f);
319 if (!ossirian || instance->GetBossState(DATA_OSSIRIAN) != IN_PROGRESS)
320 return false;
321
322 ossirian->AI()->DoAction(ACTION_TRIGGER_WEAKNESS);
323 return true;
324 }
325 };
326
327 GameObjectAI* GetAI(GameObject* go) const override
328 {
329 return GetAQ20AI<go_ossirian_crystalAI>(go);
330 }
331};
332
334{
335 new boss_ossirian();
337}
Actions
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ GO_ACTIVATED
Definition GameObject.h:78
@ IN_PROGRESS
@ GO_SUMMON_TIMED_DESPAWN
Spells
Definition PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool spawnedOnly=true)
@ UNIT_STATE_CASTING
Definition Unit.h:235
@ ACTION_TRIGGER_WEAKNESS
@ SPELL_STOMP
@ SPELL_CURSE_OF_TONGUES
@ SPELL_WEAKNESS_FROST
@ SPELL_WEAKNESS_SHADOW
@ SPELL_SUMMON_CRYSTAL
@ SPELL_SAND_STORM
@ SPELL_WEAKNESS_ARCANE
@ SPELL_WEAKNESS_FIRE
@ SPELL_CYCLONE
@ SPELL_SUPREME
@ SPELL_WEAKNESS_NATURE
@ SPELL_SUMMON
uint8 const NUM_TORNADOS
Position CrystalCoordinates[NUM_CRYSTALS]
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_KURINAXX_DEATH
@ SAY_SLAY
@ SAY_SUPREME
@ SAY_INTRO
OssirianMisc
@ NPC_OSSIRIAN_TRIGGER
@ NPC_SAND_VORTEX
Position const RoomCenter
uint8 const NUM_CRYSTALS
float RoomRadius
uint32 const SpellWeakness[NUM_WEAKNESS]
void AddSC_boss_ossirian()
@ EVENT_CYCLONE
@ EVENT_STOMP
@ EVENT_SILENCE
uint8 const NUM_WEAKNESS
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
virtual void MoveInLineOfSight(Unit *)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
CreatureAI * AI() const
Definition Creature.h:154
void Update(uint32 time)
Definition EventMap.h:67
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
GameObject *const me
void SetLootState(LootState s, Unit *unit=nullptr)
EncounterState GetBossState(uint32 id) const
Definition Map.h:281
void SendToPlayers(WorldPacket const *data) const
Definition Map.cpp:3668
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1852
void Clear()
Definition ObjectGuid.h:150
static Creature * ToCreature(Object *o)
Definition Object.h:186
uint32 Id
Definition SpellInfo.h:289
virtual void DoAction(int32)
Definition UnitAI.h:154
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
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
Definition Unit.h:769
bool IsAlive() const
Definition Unit.h:1234
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
Unit * GetVictim() const
Definition Unit.h:859
Map * GetMap() const
Definition Object.h:449
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1992
GameObject * SummonGameObject(uint32 entry, Position const &pos, QuaternionData const &rot, Seconds respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
Definition Object.cpp:2015
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2099
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1123
void GetRandomPoint(Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition Object.cpp:1376
WorldPacket const * Write() override
CreatureAI * GetAI(Creature *creature) const override
GameObjectAI * GetAI(GameObject *go) const override
@ WEATHER_STATE_HEAVY_SANDSTORM
Definition Weather.h:59
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
@ ACTION_KURINNAXX_DEFEATED
@ NPC_OSSIRIAN
@ DATA_OSSIRIAN
@ GO_OSSIRIAN_CRYSTAL
void EnterEvadeMode(EvadeReason why) override
void SpellHit(WorldObject *caster, SpellInfo const *spellInfo) override
void JustDied(Unit *) override
void JustEngagedWith(Unit *who) override
void KilledUnit(Unit *) override
void DoAction(int32 action) override
void MoveInLineOfSight(Unit *who) override
void UpdateAI(uint32 diff) override
boss_ossirianAI(Creature *creature)
bool OnGossipHello(Player *player) override