TrinityCore
zone_dun_morogh.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 "AreaTrigger.h"
19#include "AreaTriggerAI.h"
20#include "MotionMaster.h"
21#include "PassiveAI.h"
22#include "Player.h"
23#include "ScriptMgr.h"
24#include "ScriptedCreature.h"
25#include "Vehicle.h"
26
28{
33 SPELL_FREEZE_ANIM = 77910
34};
35
36/*######
37# npc_frozen_mountaineer
38######*/
39
41{
42public:
43 npc_frozen_mountaineer() : CreatureScript("npc_frozen_mountaineer") { }
44
46 {
47 npc_frozen_mountaineerAI(Creature* creature) : ScriptedAI(creature), _dataOneSet(false) { }
48
49 void Reset() override
50 {
51 _events.Reset();
54 }
55
56 void SetData(uint32 /*type*/, uint32 data) override
57 {
58 if (data == DATA_SET_ICE_BROKEN && !_dataOneSet)
59 {
62 _dataOneSet = true;
64 }
65 }
66
67 void UpdateAI(uint32 diff) override
68 {
69 if (!_dataOneSet)
70 return;
71
72 _events.Update(diff);
73
75 {
76 me->GetMotionMaster()->MovePoint(0, me->GetPositionX() + (std::cos(me->GetOrientation()) * 15.0f), me->GetPositionY() + (std::sin(me->GetOrientation()) * 15.0f), me->GetPositionZ());
78 }
79 }
80 private:
83 };
84
85 CreatureAI* GetAI(Creature* creature) const override
86 {
87 return new npc_frozen_mountaineerAI(creature);
88 }
89};
90
92{
97
101
104
108
113
115
118
126
127// 46185 - Sanitron 5000
129{
130 npc_sanitron_5000(Creature* creature) : NullCreatureAI(creature) { }
131
133 {
134 if (me->HasStringId("SanitronLeft"))
136 else if (me->HasStringId("SanitronMiddle"))
138 else if (me->HasStringId("SanitronRight"))
140 return 0;
141 }
142
143 void PassengerBoarded(Unit* passenger, int8 /*seatId*/, bool apply) override
144 {
145 if (!apply)
146 return;
147
148 Player* player = passenger->ToPlayer();
149 if (!player)
150 return;
151
153 player->TalkedToCreature(me->GetEntry(), me->GetGUID());
154 me->GetMotionMaster()->MovePath(GetPathId(), false);
155 }
156
157 void ForceCastOnPassenger(FindCreatureOptions const& options, uint32 spellId)
158 {
159 std::list<Creature*> bunnys;
160 me->GetCreatureListWithOptionsInGrid(bunnys, 20.0f, options);
161
162 Vehicle* veh = me->GetVehicleKit();
163 if (!veh)
164 return;
165
166 Unit* passenger = veh->GetPassenger(0);
167 if (!passenger)
168 return;
169
170 for (Creature* bunny : bunnys)
171 {
172 bunny->CastSpell(passenger, spellId, false);
173 }
174 }
175
176 void WaypointReached(uint32 waypointId, uint32 pathId) override
177 {
179 {
180 if (waypointId == WAYPOINT_SANITRON_STAGE_ONE)
181 ForceCastOnPassenger({ .CreatureId = NPC_DECONTAMINATION_BUNNY, .StringId = "DecontaminationStageOne" }, SPELL_DECONTAMINATE_STAGE_1);
182 else if (waypointId == WAYPOINT_SANITRON_STAGE_TWO)
183 {
185 ForceCastOnPassenger({ .CreatureId = NPC_DECONTAMINATION_BUNNY, .StringId = "DecontaminationStageTwo" }, SPELL_DECONTAMINATE_STAGE_2);
186 }
187 else if (waypointId == WAYPOINT_SANITRON_STAGE_THREE)
188 ForceCastOnPassenger({ .CreatureId = NPC_DECONTAMINATION_BUNNY, .StringId = "DecontaminationStageThree" }, SPELL_DECONTAMINATE_STAGE_3);
189 else if (waypointId == WAYPOINT_SANITRON_FINISH)
190 {
191 _scheduler.Schedule(2s, [this](TaskContext task)
192 {
195 task.Schedule(1s, [this](TaskContext /*task*/)
196 {
197 if (Creature* technician = me->FindNearestCreatureWithOptions(30.0f, { .CreatureId = NPC_SAFE_TECHNICIAN, .StringId = "SafeTechnicianSanitron" }))
198 technician->AI()->DoAction(ACTION_TECHNICIAN_START_EVENT);
199
200 me->KillSelf();
201 });
202 });
203 }
204 }
205 }
206
207 void WaypointStarted(uint32 waypointId, uint32 pathId) override
208 {
210 {
211 if (waypointId == WAYPOINT_SANITRON_STAGE_THREE)
212 {
213 if (Creature* technician = me->FindNearestCreatureWithOptions(30.0f, { .CreatureId = NPC_SAFE_TECHNICIAN, .StringId = "SafeTechnicianSayText" }))
214 technician->AI()->Talk(SAY_TECHNICIAN_CLEAN_CANNON);
215 }
216 else if (waypointId == WAYPOINT_SANITRON_FINISH)
217 {
220 }
221 }
222 }
223
224 void UpdateAI(uint32 diff) override
225 {
226 _scheduler.Update(diff);
227 }
228
229private:
231};
232
233Position const SafeTechnicianSanitron = { -5178.169f, 696.795f, 288.22797f };
234
235// 46230 - S.A.F.E Technician
237{
239
240 void DoAction(int32 action) override
241 {
242 if (action == ACTION_TECHNICIAN_START_EVENT)
243 {
244 if (!_isEventStarted)
245 {
246 _isEventStarted = true;
248 me->SetFacingTo(0.2967f);
249 _scheduler.Schedule(2s + 500ms, [this](TaskContext /*task*/)
250 {
252 });
253 }
254 }
255 }
256
257 void MovementInform(uint32 type, uint32 pointId) override
258 {
259 if (type != POINT_MOTION_TYPE)
260 return;
261
262 if (pointId == POINT_SAFE_TECHNICIAN_SANITRON)
263 {
264 me->SetFacingTo(1.5009f);
265 _scheduler.Schedule(1s, [this](TaskContext task)
266 {
268 task.Schedule(2s, [this](TaskContext task)
269 {
271 task.Schedule(5s, [this](TaskContext /*task*/)
272 {
273 me->SetWalk(true);
275 me->GetMotionMaster()->MovePoint(POINT_SAFE_TECHNICIAN_FINISH, me->GetHomePosition(), true, me->GetHomePosition().GetOrientation());
276 });
277 });
278 });
279 }
280 else if (pointId == POINT_SAFE_TECHNICIAN_FINISH)
281 {
283 _isEventStarted = false;
284 }
285 }
286
287 void UpdateAI(uint32 diff) override
288 {
289 _scheduler.Update(diff);
290 }
291
292private:
295};
296
298{
299 // Creature
303}
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
@ POINT_MOTION_TYPE
#define RegisterCreatureAI(ai_name)
Definition: ScriptMgr.h:1380
@ EMOTE_STATE_USESTANDING
@ EMOTE_STATE_WORK_MINING
@ EMOTE_STATE_NONE
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
Creature *const me
Definition: CreatureAI.h:61
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:373
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
bool HasStringId(std::string_view id) const
Definition: Creature.cpp:3165
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
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, bool generatePath=true)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
void TalkedToCreature(uint32 entry, ObjectGuid guid)
Definition: Player.cpp:16709
TaskContext & Schedule(std::chrono::duration< Rep, Period > time, TaskScheduler::task_handler_t task)
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void SetEmoteState(Emote emote)
Definition: Unit.h:852
bool SetWalk(bool enable)
Definition: Unit.cpp:12707
void SetFacingTo(float const ori, bool force=true)
Definition: Unit.cpp:12653
void RemoveAllAuras()
Definition: Unit.cpp:4242
Vehicle * GetVehicleKit() const
Definition: Unit.h:1711
void KillSelf(bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition: Unit.h:921
Unit * GetPassenger(int8 seatId) const
Gets a passenger on specified seat.
Definition: Vehicle.cpp:291
Creature * FindNearestCreatureWithOptions(float range, FindCreatureOptions const &options) const
Definition: Object.cpp:2157
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
void GetCreatureListWithOptionsInGrid(Container &creatureContainer, float maxSearchRange, FindCreatureOptions const &options) const
Definition: Object.cpp:3320
CreatureAI * GetAI(Creature *creature) const override
void apply(T *val)
Definition: ByteConverter.h:41
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetOrientation() const
Definition: Position.h:79
constexpr float GetPositionZ() const
Definition: Position.h:78
void SetData(uint32, uint32 data) override
void DoAction(int32 action) override
npc_safe_technician_sanitron(Creature *creature)
void MovementInform(uint32 type, uint32 pointId) override
void UpdateAI(uint32 diff) override
void PassengerBoarded(Unit *passenger, int8, bool apply) override
== Fields =======================================
void WaypointReached(uint32 waypointId, uint32 pathId) override
void ForceCastOnPassenger(FindCreatureOptions const &options, uint32 spellId)
uint32 GetPathId() const
void UpdateAI(uint32 diff) override
TaskScheduler _scheduler
npc_sanitron_5000(Creature *creature)
void WaypointStarted(uint32 waypointId, uint32 pathId) override
== Waypoints system =============================
Position const SafeTechnicianSanitron
FrozenMountaineer
@ SPELL_FREEZE_ANIM
@ DATA_SET_ICE_BROKEN
@ SAY_MONSTEREMOTE
@ EVENT_RUN_AWAY
@ SPELL_SUMMON_FROZEN_TOMB
void AddSC_dun_morogh()
DecontaminationData
@ POINT_SAFE_TECHNICIAN_FINISH
@ SPELL_SANITRON_COSMETIC_EXPLOSION
@ WAYPOINT_SANITRON_STAGE_TWO
@ SPELL_DECONTAMINATE_STAGE_1
@ NPC_CLEAN_CANNON_X2
@ PATH_SANITRON_LEFT_START
@ NPC_SAFE_TECHNICIAN
@ SAY_SANITRON_FINISH
@ WAYPOINT_SANITRON_STAGE_THREE
@ NPC_SANITRON_5000
@ PATH_SANITRON_MIDDLE_START
@ SPELL_DECONTAMINATE_STAGE_3
@ SAY_SANITRON_DESTROY
@ PATH_SANITRON_RIGHT_START
@ ACTION_TECHNICIAN_START_EVENT
@ SAY_TECHNICIAN_CLEAN_CANNON
@ SPELL_DECONTAMINATE_STAGE_2
@ WAYPOINT_SANITRON_FINISH
@ SPELL_CLEAN_CANNON_CLEAN_BURST
@ NPC_DECONTAMINATION_BUNNY
@ SPELL_FORCE_CAST_GNOMEREGAN_AURA
@ SAY_TECHNICIAN_SANITRON_DESTROY
@ WAYPOINT_SANITRON_STAGE_ONE
@ SAY_SANITRON_START
@ POINT_SAFE_TECHNICIAN_SANITRON