TrinityCore
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 "Player.h"
26#include "ruins_of_ahnqiraj.h"
27#include "ScriptedCreature.h"
28#include "SpellInfo.h"
29#include "TemporarySummon.h"
30#include "Weather.h"
31
33{
38 SAY_DEATH = 4
39};
40
42{
46 SPELL_STOMP = 25188,
48 SPELL_SUMMON = 20477,
50
56};
57
59{
61};
62
64{
67 EVENT_STOMP = 3
68};
69
71
73{
74 { -9188.4404296875f, 1940.2099609375f, 85.6390991210937f, 3.17650008201599f },
75 { -9244.41015625f, 1808.97998046875f, 85.6390991210937f, 5.63741016387939f },
76 { -9248.41015625f, 1974.82995605469f, 85.6390991210937f, 5.89920997619629f },
77 { -9282.080078125f, 1887.33996582031f, 85.6390991210937f, 2.00712990760803f },
78 { -9299.73046875f, 1748.44995117187f, 85.6390991210937f, 1.44861996173859f },
79 { -9357.8603515625f, 1929.07995605469f, 85.6390991210937f, 1.06465005874634f },
80 { -9367.169921875f, 1780.89001464844f, 85.6390991210937f, 1.90241003036499f },
81 { -9383.2900390625f, 2012.68005371094f, 85.6511001586914f, 2.93214988708496f },
82 { -9406.099609375f, 1862.38000488281f, 85.6390991210937f, 6.2308201789856f },
83 { -9407.7197265625f, 1960.2099609375f, 85.6390991210937f, 1.11700999736786f },
84 { -9432.400390625f, 1782.53002929687f, 85.6390991210937f, 5.86430978775024f },
85 { -9506.1904296875f, 1865.56994628906f, 85.6390991210937f, 4.27606010437012f }
86};
87
88float RoomRadius = 165.0f;
92Position const RoomCenter = { -9343.041992f, 1923.278198f, 85.555984f, 0.0 };
93
95{
96 public:
97 boss_ossirian() : CreatureScript("boss_ossirian") { }
98
99 struct boss_ossirianAI : public BossAI
100 {
102 {
103 Initialize();
104 SaidIntro = false;
105 }
106
108 {
109 CrystalIterator = 0;
112 }
113
118
119 void Reset() override
120 {
121 _Reset();
122 Initialize();
123 }
124
125 void SpellHit(WorldObject* caster, SpellInfo const* spellInfo) override
126 {
127 for (uint8 i = 0; i < NUM_WEAKNESS; ++i)
128 {
129 if (spellInfo->Id == SpellWeakness[i])
130 {
132 // Despawn used crystal
134 crystal->Delete();
135 if (Creature* creatureCaster = caster->ToCreature())
136 creatureCaster->DespawnOrUnsummon();
138 }
139 }
140 }
141
142 void DoAction(int32 action) override
143 {
144 if (action == ACTION_TRIGGER_WEAKNESS)
146 if (!Trigger->HasUnitState(UNIT_STATE_CASTING))
147 Trigger->CastSpell(Trigger, SpellWeakness[urand(0, 4)], false);
148 }
149
150 void JustEngagedWith(Unit* who) override
151 {
153 events.Reset();
157
160
161 Map* map = me->GetMap();
162
164 map->SendToPlayers(weather.Write());
165
166 for (uint8 i = 0; i < NUM_TORNADOS; ++i)
167 {
169 if (Creature* Tornado = map->SummonCreature(NPC_SAND_VORTEX, Point))
170 Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true);
171 }
172
174 }
175
176 void KilledUnit(Unit* /*victim*/) override
177 {
178 Talk(SAY_SLAY);
179 }
180
181 void EnterEvadeMode(EvadeReason why) override
182 {
183 Cleanup();
186 }
187
188 void JustDied(Unit* /*killer*/) override
189 {
190 Cleanup();
191 _JustDied();
192 }
193
194 void Cleanup()
195 {
197 Crystal->Use(me);
198 }
199
201 {
203 CrystalIterator = 0;
204
206 {
207 TriggerGUID = Trigger->GetGUID();
209 {
210 CrystalGUID = Crystal->GetGUID();
212 }
213 }
214 }
215
216 void MoveInLineOfSight(Unit* who) override
217
218 {
219 if (!SaidIntro)
220 {
222 SaidIntro = true;
223 }
225 }
226
227 void UpdateAI(uint32 diff) override
228 {
229 if (!UpdateVictim())
230 return;
231
232 events.Update(diff);
233
234 // No kiting!
235 if (me->GetDistance(me->GetVictim()) > 60.00f && me->GetDistance(me->GetVictim()) < 120.00f)
237
238 bool ApplySupreme = true;
239
241 ApplySupreme = false;
242 else
243 {
244 for (uint8 i = 0; i < NUM_WEAKNESS; ++i)
245 {
246 if (me->HasAura(SpellWeakness[i]))
247 {
248 ApplySupreme = false;
249 break;
250 }
251 }
252 }
253
254 if (ApplySupreme)
255 {
258 }
259
260 while (uint32 eventId = events.ExecuteEvent())
261 {
262 switch (eventId)
263 {
264 case EVENT_SILENCE:
267 break;
268 case EVENT_CYCLONE:
271 break;
272 case EVENT_STOMP:
275 break;
276 default:
277 break;
278 }
279 }
280 }
281 };
282
283 CreatureAI* GetAI(Creature* creature) const override
284 {
285 return GetAQ20AI<boss_ossirianAI>(creature);
286 }
287};
288
290{
291 public:
292 go_ossirian_crystal() : GameObjectScript("go_ossirian_crystal") { }
293
295 {
296 go_ossirian_crystalAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
297
299
300 bool OnGossipHello(Player* player) override
301 {
302 // Crystal animation on use
304 Creature* ossirian = player->FindNearestCreature(NPC_OSSIRIAN, 30.0f);
305 if (!ossirian || instance->GetBossState(DATA_OSSIRIAN) != IN_PROGRESS)
306 return false;
307
308 ossirian->AI()->DoAction(ACTION_TRIGGER_WEAKNESS);
309 return true;
310 }
311 };
312
313 GameObjectAI* GetAI(GameObject* go) const override
314 {
315 return GetAQ20AI<go_ossirian_crystalAI>(go);
316 }
317};
318
320{
321 new boss_ossirian();
323}
Texts
Actions
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ GO_ACTIVATED
Definition: GameObject.h:158
@ IN_PROGRESS
@ GO_SUMMON_TIMED_DESPAWN
Definition: ObjectDefines.h:84
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)
EvadeReason
Definition: UnitAICommon.h:30
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ 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_SLAY
@ SAY_SUPREME
@ SAY_INTRO
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
void _JustDied()
virtual void MoveInLineOfSight(Unit *)
Definition: CreatureAI.cpp:122
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
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
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
void Reset()
Definition: EventMap.cpp:21
GameObject *const me
Definition: GameObjectAI.h:50
void SetLootState(LootState s, Unit *unit=nullptr)
EncounterState GetBossState(uint32 id) const
Definition: Map.h:189
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, Milliseconds duration=0ms, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty, SmoothPhasingInfo const *smoothPhasingInfo=nullptr)
Definition: Object.cpp:1836
void SendToPlayers(WorldPacket const *data) const
Definition: Map.cpp:2690
void Clear()
Definition: ObjectGuid.h:286
static Creature * ToCreature(Object *o)
Definition: Object.h:219
uint32 const Id
Definition: SpellInfo.h:325
virtual void DoAction(int32)
Definition: UnitAI.h:72
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
Definition: Unit.h:627
Unit * GetVictim() const
Definition: Unit.h:715
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
Map * GetMap() const
Definition: Object.h:624
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:2025
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1078
void GetRandomPoint(Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition: Object.cpp:1331
WorldPacket const * Write() override
CreatureAI * GetAI(Creature *creature) const override
GameObjectAI * GetAI(GameObject *go) const override
@ WEATHER_STATE_HEAVY_SANDSTORM
Definition: Weather.h:58
TC_GAME_API void Trigger(uint32 gameEventId, WorldObject *source, WorldObject *target)
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
@ NPC_OSSIRIAN_TRIGGER
@ NPC_SAND_VORTEX
@ NPC_OSSIRIAN
@ DATA_OSSIRIAN
@ GO_OSSIRIAN_CRYSTAL
constexpr float GetOrientation() const
Definition: Position.h:79
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
Definition: GameObject.cpp:118
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