TrinityCore
Loading...
Searching...
No Matches
areatrigger_scripts.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 "DBCStructure.h"
20#include "GameObject.h"
21#include "GameTime.h"
22#include "MotionMaster.h"
23#include "ObjectAccessor.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
26#include "TemporarySummon.h"
27
28/*######
29## at_coilfang_waterfall
30######*/
31
36
38{
39 public:
41
42 bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) override
43 {
45 if (go->getLootState() == GO_READY)
46 go->UseDoorOrButton();
47
48 return false;
49 }
50};
51
52/*#####
53## at_legion_teleporter
54#####*/
55
64
66{
67 public:
69
70 bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) override
71 {
72 if (player->IsAlive() && !player->IsInCombat())
73 {
75 {
76 player->CastSpell(player, SPELL_TELE_A_TO, false);
77 return true;
78 }
79
80 if (player->GetTeam() == HORDE && player->GetQuestRewardStatus(QUEST_GAINING_ACCESS_H))
81 {
82 player->CastSpell(player, SPELL_TELE_H_TO, false);
83 return true;
84 }
85
86 return false;
87 }
88 return false;
89 }
90};
91
92/*######
93## at_scent_larkorwi
94######*/
95
101
103{
104 public:
106
107 bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) override
108 {
110 {
111 if (!player->FindNearestCreature(NPC_LARKORWI_MATE, 15))
113 }
114
115 return false;
116 }
117};
118
119/*######
120## at_sholazar_waygate
121######*/
122
135
137{
138 public:
140
141 bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
142 {
143 if (!player->isDead() && (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) != QUEST_STATUS_NONE ||
145 {
146 switch (trigger->ID)
147 {
148 case AT_SHOLAZAR:
149 player->CastSpell(player, SPELL_SHOLAZAR_TO_UNGORO_TELEPORT, true);
150 break;
151
152 case AT_UNGORO:
153 player->CastSpell(player, SPELL_UNGORO_TO_SHOLAZAR_TELEPORT, true);
154 break;
155 }
156 }
157
158 return false;
159 }
160};
161
162/*######
163## at_nats_landing
164######*/
165
172
174{
175 public:
177
178 bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) override
179 {
180 if (!player->IsAlive() || !player->HasAura(SPELL_FISH_PASTE))
181 return false;
182
184 {
185 if (!player->FindNearestCreature(NPC_LURKING_SHARK, 20.0f))
186 {
187 if (Creature* shark = player->SummonCreature(NPC_LURKING_SHARK, -4246.243f, -3922.356f, -7.488f, 5.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 100s))
188 shark->AI()->AttackStart(player);
189
190 return false;
191 }
192 }
193 return true;
194 }
195};
196
197/*######
198## at_sentry_point
199######*/
200
202{
203 SPELL_TELEPORT_VISUAL = 799, // TODO Find the correct spell
205 NPC_TERVOSH = 4967
207
209{
210public:
212
213 bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/)
214 {
216 if (!player->IsAlive() || quest_status == QUEST_STATUS_NONE || quest_status == QUEST_STATUS_REWARDED)
217 return false;
218
219 if (!player->FindNearestCreature(NPC_TERVOSH, 100.0f))
220 {
221 if (Creature* tervosh = player->SummonCreature(NPC_TERVOSH, -3476.51f, -4105.94f, 17.1f, 5.3816f, TEMPSUMMON_TIMED_DESPAWN, 1min))
222 tervosh->CastSpell(tervosh, SPELL_TELEPORT_VISUAL, true);
223 }
224
225 return true;
226 }
227};
228
229/*######
230## at_brewfest
231######*/
232
245
247{
248 public:
250 {
251 // Initialize for cooldown
253 }
254
255 bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
256 {
257 uint32 triggerId = trigger->ID;
258 // Second trigger happened too early after first, skip for now
260 return false;
261
262 switch (triggerId)
263 {
265 if (Creature* tapper = player->FindNearestCreature(NPC_TAPPER_SWINDLEKEG, 20.0f))
266 tapper->AI()->Talk(SAY_WELCOME, player);
267 break;
269 if (Creature* ipfelkofer = player->FindNearestCreature(NPC_IPFELKOFER_IRONKEG, 20.0f))
270 ipfelkofer->AI()->Talk(SAY_WELCOME, player);
271 break;
272 default:
273 break;
274 }
275
277 return false;
278 }
279
280 private:
281 std::map<uint32, time_t> _triggerTimes;
282};
283
284/*######
285## at_area_52_entrance
286######*/
287
299
301{
302 public:
307
308 bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
309 {
310 float x = 0.0f, y = 0.0f, z = 0.0f;
311
312 if (!player->IsAlive())
313 return false;
314
315 uint32 triggerId = trigger->ID;
317 return false;
318
319 switch (triggerId)
320 {
321 case AT_AREA_52_EAST:
322 x = 3044.176f;
323 y = 3610.692f;
324 z = 143.61f;
325 break;
326 case AT_AREA_52_NORTH:
327 x = 3114.87f;
328 y = 3687.619f;
329 z = 143.62f;
330 break;
331 case AT_AREA_52_WEST:
332 x = 3017.79f;
333 y = 3746.806f;
334 z = 144.27f;
335 break;
336 case AT_AREA_52_SOUTH:
337 x = 2950.63f;
338 y = 3719.905f;
339 z = 143.33f;
340 break;
341 }
342
343 player->SummonCreature(NPC_SPOTLIGHT, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 5s);
344 player->AddAura(SPELL_A52_NEURALYZER, player);
346 return false;
347 }
348
349 private:
350 std::map<uint32, time_t> _triggerTimes;
351};
352
353/*######
354 ## at_frostgrips_hollow
355 ######*/
356
367
368Position const stormforgedMonitorPosition = {6963.95f, 45.65f, 818.71f, 4.948f};
369Position const stormforgedEradictorPosition = {6983.18f, 7.15f, 806.33f, 2.228f};
370
372{
373public:
379
380 bool OnTrigger(Player* player, AreaTriggerEntry const* /* trigger */) override
381 {
383 return false;
384
385 Creature* stormforgedMonitor = ObjectAccessor::GetCreature(*player, stormforgedMonitorGUID);
386 if (stormforgedMonitor)
387 return false;
388
389 Creature* stormforgedEradictor = ObjectAccessor::GetCreature(*player, stormforgedEradictorGUID);
390 if (stormforgedEradictor)
391 return false;
392
394 if (stormforgedMonitor)
395 {
396 stormforgedMonitorGUID = stormforgedMonitor->GetGUID();
397 stormforgedMonitor->SetWalk(false);
399 stormforgedMonitor->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);
400 stormforgedMonitor->GetMotionMaster()->MovePath((NPC_STORMFORGED_MONITOR * 100) << 3, false);
401 }
402
404 if (stormforgedEradictor)
405 {
406 stormforgedEradictorGUID = stormforgedEradictor->GetGUID();
407 stormforgedEradictor->GetMotionMaster()->MovePath((NPC_STORMFORGED_ERADICTOR * 100) << 3, false);
408 }
409
410 return true;
411 }
412
413private:
416};
417
uint32_t uint32
Definition Define.h:133
@ GO_READY
Definition GameObject.h:77
@ TEMPSUMMON_TIMED_DESPAWN
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
QuestStatus
Definition QuestDef.h:103
@ QUEST_STATUS_REWARDED
Definition QuestDef.h:110
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:107
@ QUEST_STATUS_NONE
Definition QuestDef.h:104
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool spawnedOnly=true)
@ ALLIANCE
@ HORDE
@ UNIT_STATE_IGNORE_PATHFINDING
Definition Unit.h:248
@ QUEST_MEETING_A_GREAT_ONE
@ QUEST_THE_MAKERS_OVERLOOK
@ SPELL_UNGORO_TO_SHOLAZAR_TELEPORT
@ QUEST_THE_MAKERS_PERCH
@ SPELL_SHOLAZAR_TO_UNGORO_TELEPORT
@ QUEST_MISSING_DIPLO_PT14
@ SPELL_TELEPORT_VISUAL
@ SPELL_FISH_PASTE
@ QUEST_NATS_BARGAIN
@ NPC_LURKING_SHARK
Position const stormforgedEradictorPosition
@ QUEST_SCENT_OF_LARKORWI
@ NPC_LARKORWI_MATE
@ AT_AREA_52_EAST
@ AT_AREA_52_WEST
@ AT_AREA_52_NORTH
@ SUMMON_COOLDOWN
@ AT_AREA_52_SOUTH
@ SPELL_A52_NEURALYZER
@ GO_COILFANG_WATERFALL
void AddSC_areatrigger_scripts()
@ NPC_IPFELKOFER_IRONKEG
@ AT_BREWFEST_DUROTAR
@ AREATRIGGER_TALK_COOLDOWN
@ AT_BREWFEST_DUN_MOROGH
@ NPC_TAPPER_SWINDLEKEG
Position const stormforgedMonitorPosition
@ SPELL_TELE_H_TO
@ SPELL_TELE_A_TO
@ QUEST_GAINING_ACCESS_A
@ QUEST_GAINING_ACCESS_H
@ NPC_STORMFORGED_ERADICTOR
@ QUEST_THE_LONESOME_WATCHER
@ NPC_STORMFORGED_MONITOR
std::map< uint32, time_t > _triggerTimes
bool OnTrigger(Player *player, AreaTriggerEntry const *trigger) override
bool OnTrigger(Player *player, AreaTriggerEntry const *trigger) override
std::map< uint32, time_t > _triggerTimes
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
bool OnTrigger(Player *player, AreaTriggerEntry const *)
bool OnTrigger(Player *player, AreaTriggerEntry const *trigger) override
void MovePath(uint32 pathId, bool repeatable)
void Clear()
Definition ObjectGuid.h:150
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetTeam() const
Definition Player.h:1832
bool GetQuestRewardStatus(uint32 quest_id) const
Definition Player.cpp:15626
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition Player.cpp:15642
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:11964
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 AddUnitState(uint32 f)
Definition Unit.h:875
bool SetWalk(bool enable)
Definition Unit.cpp:13268
bool IsInCombat() const
Definition Unit.h:1144
bool isDead() const
Definition Unit.h:1236
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
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
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2099
time_t GetGameTime()
Definition GameTime.cpp:42
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
float GetPositionZ() const
Definition Position.h:81
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80