TrinityCore
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 "AreaTrigger.h"
20#include "AreaTriggerAI.h"
21#include "DB2Structure.h"
22#include "GameObject.h"
23#include "GameTime.h"
24#include "MotionMaster.h"
25#include "ObjectAccessor.h"
26#include "ScriptedCreature.h"
27#include "Player.h"
28#include "TemporarySummon.h"
29#include "World.h"
30#include "ZoneScript.h"
31
32/*######
33## at_coilfang_waterfall
34######*/
35
37{
39};
40
42{
43 public:
45
46 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
47 {
49 if (go->getLootState() == GO_READY)
50 go->UseDoorOrButton();
51
52 return false;
53 }
54};
55
56/*#####
57## at_legion_teleporter
58#####*/
59
61{
64
67};
68
70{
71 public:
73
74 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
75 {
76 if (player->IsAlive() && !player->IsInCombat())
77 {
79 {
80 player->CastSpell(player, SPELL_TELE_A_TO, false);
81 return true;
82 }
83
84 if (player->GetTeam() == HORDE && player->GetQuestRewardStatus(QUEST_GAINING_ACCESS_H))
85 {
86 player->CastSpell(player, SPELL_TELE_H_TO, false);
87 return true;
88 }
89
90 return false;
91 }
92 return false;
93 }
94};
95
96/*######
97## at_scent_larkorwi
98######*/
99
101{
103 NPC_LARKORWI_MATE = 9683
105
107{
108 public:
110
111 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
112 {
114 {
115 if (!player->FindNearestCreature(NPC_LARKORWI_MATE, 15))
117 }
118
119 return false;
120 }
121};
122
123/*######
124## at_sholazar_waygate
125######*/
126
128{
131
133 AT_UNGORO = 5047,
134
138};
139
141{
142 public:
144
145 bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
146 {
147 if (!player->isDead() && (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) != QUEST_STATUS_NONE ||
149 {
150 switch (trigger->ID)
151 {
152 case AT_SHOLAZAR:
153 player->CastSpell(player, SPELL_SHOLAZAR_TO_UNGORO_TELEPORT, true);
154 break;
155
156 case AT_UNGORO:
157 player->CastSpell(player, SPELL_UNGORO_TO_SHOLAZAR_TELEPORT, true);
158 break;
159 }
160 }
161
162 return false;
163 }
164};
165
166/*######
167## at_nats_landing
168######*/
169
171{
174 NPC_LURKING_SHARK = 23928
176
178{
179 public:
181
182 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
183 {
184 if (!player->IsAlive() || !player->HasAura(SPELL_FISH_PASTE))
185 return false;
186
188 {
189 if (!player->FindNearestCreature(NPC_LURKING_SHARK, 20.0f))
190 {
191 if (Creature* shark = player->SummonCreature(NPC_LURKING_SHARK, -4246.243f, -3922.356f, -7.488f, 5.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 100s))
192 shark->AI()->AttackStart(player);
193
194 return false;
195 }
196 }
197 return true;
198 }
199};
200
201/*######
202## at_brewfest
203######*/
204
206{
209
212
214
215 AREATRIGGER_TALK_COOLDOWN = 5, // in seconds
216};
217
219{
220 public:
222 {
223 // Initialize for cooldown
225 }
226
227 bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
228 {
229 uint32 triggerId = trigger->ID;
230 // Second trigger happened too early after first, skip for now
232 return false;
233
234 switch (triggerId)
235 {
237 if (Creature* tapper = player->FindNearestCreature(NPC_TAPPER_SWINDLEKEG, 20.0f))
238 tapper->AI()->Talk(SAY_WELCOME, player);
239 break;
241 if (Creature* ipfelkofer = player->FindNearestCreature(NPC_IPFELKOFER_IRONKEG, 20.0f))
242 ipfelkofer->AI()->Talk(SAY_WELCOME, player);
243 break;
244 default:
245 break;
246 }
247
249 return false;
250 }
251
252 private:
253 std::map<uint32, time_t> _triggerTimes;
254};
255
256/*######
257## at_area_52_entrance
258######*/
259
261{
265
270};
271
273{
274 public:
276 {
278 }
279
280 bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
281 {
282 float x = 0.0f, y = 0.0f, z = 0.0f;
283
284 if (!player->IsAlive())
285 return false;
286
287 uint32 triggerId = trigger->ID;
289 return false;
290
291 switch (triggerId)
292 {
293 case AT_AREA_52_EAST:
294 x = 3044.176f;
295 y = 3610.692f;
296 z = 143.61f;
297 break;
298 case AT_AREA_52_NORTH:
299 x = 3114.87f;
300 y = 3687.619f;
301 z = 143.62f;
302 break;
303 case AT_AREA_52_WEST:
304 x = 3017.79f;
305 y = 3746.806f;
306 z = 144.27f;
307 break;
308 case AT_AREA_52_SOUTH:
309 x = 2950.63f;
310 y = 3719.905f;
311 z = 143.33f;
312 break;
313 }
314
315 player->SummonCreature(NPC_SPOTLIGHT, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 5s);
316 player->AddAura(SPELL_A52_NEURALYZER, player);
318 return false;
319 }
320
321 private:
322 std::map<uint32, time_t> _triggerTimes;
323};
324
325/*######
326 ## at_frostgrips_hollow
327 ######*/
328
330{
332
335
337 DATA_START = 0
339
340Position const stormforgedMonitorPosition = {6963.95f, 45.65f, 818.71f, 4.948f};
341Position const stormforgedEradictorPosition = {6983.18f, 7.15f, 806.33f, 2.228f};
342
344{
345public:
347 {
350 }
351
352 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
353 {
355 return false;
356
357 Creature* stormforgedMonitor = ObjectAccessor::GetCreature(*player, stormforgedMonitorGUID);
358 if (stormforgedMonitor)
359 return false;
360
361 Creature* stormforgedEradictor = ObjectAccessor::GetCreature(*player, stormforgedEradictorGUID);
362 if (stormforgedEradictor)
363 return false;
364
366 if (stormforgedMonitor)
367 {
368 stormforgedMonitorGUID = stormforgedMonitor->GetGUID();
369 stormforgedMonitor->SetWalk(false);
371 stormforgedMonitor->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);
372 stormforgedMonitor->GetMotionMaster()->MovePath((NPC_STORMFORGED_MONITOR * 100) << 3, false);
373 }
374
376 if (stormforgedEradictor)
377 {
378 stormforgedEradictorGUID = stormforgedEradictor->GetGUID();
379 stormforgedEradictor->GetMotionMaster()->MovePath((NPC_STORMFORGED_ERADICTOR * 100) << 3, false);
380 }
381
382 return true;
383 }
384
385private:
388};
389
391{
393 {
395
397 };
398
400
401 void OnUnitEnter(Unit* unit) override
402 {
403 Player* player = unit->ToPlayer();
404 if (!player)
405 return;
406
409 }
410};
411
413{
414 if (GameObject* buffObject = player->FindNearestGameObjectWithOptions(4.0f, { .StringId = "bg_buff_object" }))
415 {
416 buffObject->ActivateObject(GameObjectActions::Disturb, 0, player);
417 buffObject->DespawnOrUnsummon();
418 }
419}
420
422{
424
425 void OnUnitEnter(Unit* unit) override
426 {
427 if (!unit->IsPlayer())
428 return;
429
431 }
432};
433
435{
436public:
438
439 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
440 {
441 HandleBuffAreaTrigger(player);
442 return true;
443 }
444};
445
447{
449
450 void OnUnitEnter(Unit* unit) override
451 {
452 if (!unit->IsPlayer())
453 return;
454
455 Player* player = unit->ToPlayer();
456 if (ZoneScript* zoneScript = at->GetZoneScript())
457 if (zoneScript->CanCaptureFlag(at, player))
458 zoneScript->OnCaptureFlag(at, player);
459 }
460};
461
463{
476}
uint32_t uint32
Definition: Define.h:142
@ GO_READY
Definition: GameObject.h:157
@ TEMPSUMMON_TIMED_DESPAWN
Definition: ObjectDefines.h:65
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition: ObjectDefines.h:66
@ QUEST_STATUS_REWARDED
Definition: QuestDef.h:148
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:145
@ QUEST_STATUS_NONE
Definition: QuestDef.h:142
#define RegisterAreaTriggerAI(ai_name)
Definition: ScriptMgr.h:1416
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool spawnedOnly=true)
@ ALLIANCE
@ HORDE
@ UNIT_STATE_IGNORE_PATHFINDING
Definition: Unit.h:283
void HandleBuffAreaTrigger(Player *player)
@ QUEST_MEETING_A_GREAT_ONE
@ QUEST_THE_MAKERS_OVERLOOK
@ SPELL_UNGORO_TO_SHOLAZAR_TELEPORT
@ QUEST_THE_MAKERS_PERCH
@ SPELL_SHOLAZAR_TO_UNGORO_TELEPORT
@ 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
@ NPC_SPOTLIGHT
@ 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
LegionTeleporter
@ SPELL_TELE_H_TO
@ SPELL_TELE_A_TO
@ QUEST_GAINING_ACCESS_A
@ QUEST_GAINING_ACCESS_H
@ TYPE_WAYPOINT
@ NPC_STORMFORGED_ERADICTOR
@ QUEST_THE_LONESOME_WATCHER
@ NPC_STORMFORGED_MONITOR
AreaTrigger *const at
Definition: AreaTriggerAI.h:33
std::map< uint32, time_t > _triggerTimes
bool OnTrigger(Player *player, AreaTriggerEntry const *trigger) override
bool OnTrigger(Player *player, AreaTriggerEntry const *) 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 *trigger) override
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 Clear()
Definition: ObjectGuid.h:286
bool IsPlayer() const
Definition: Object.h:212
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition: Player.cpp:16680
bool GetQuestRewardStatus(uint32 quest_id) const
Definition: Player.cpp:16033
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:16050
Team GetTeam() const
Definition: Player.h:2235
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:11618
bool IsAlive() const
Definition: Unit.h:1164
void AddUnitState(uint32 f)
Definition: Unit.h:731
bool SetWalk(bool enable)
Definition: Unit.cpp:12707
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
bool IsInCombat() const
Definition: Unit.h:1043
bool isDead() const
Definition: Unit.h:1166
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
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
ZoneScript * GetZoneScript() const
Definition: Object.h:630
GameObject * FindNearestGameObjectWithOptions(float range, FindGameObjectOptions const &options) const
Definition: Object.cpp:2179
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
time_t GetGameTime()
Definition: GameTime.cpp:44
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetPositionZ() const
Definition: Position.h:78
void OnUnitEnter(Unit *unit) override
areatrigger_action_capture_flag(AreaTrigger *areatrigger)
areatrigger_battleground_buffs(AreaTrigger *areatrigger)
void OnUnitEnter(Unit *unit) override
areatrigger_stormwind_teleport_unit(AreaTrigger *areatrigger)