TrinityCore
isle_of_conquest.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 "BattlegroundIC.h"
20#include "GameObject.h"
21#include "GameObjectAI.h"
22#include "Map.h"
23#include "MotionMaster.h"
24#include "ObjectAccessor.h"
25#include "PassiveAI.h"
26#include "Player.h"
27#include "ScriptedCreature.h"
28#include "SpellInfo.h"
29#include "SpellScript.h"
30#include "Vehicle.h"
31#include "WorldStateMgr.h"
32
33// TO-DO: This should be done with SmartAI, but yet it does not correctly support vehicles's AIs.
34// Even adding ReactState Passive we still have issues using SmartAI.
35
37{
38 npc_four_car_garage(Creature* creature) : NullCreatureAI(creature) { }
39
40 void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override
41 {
42 if (apply)
43 {
44 uint32 spellId = 0;
45
46 switch (me->GetEntry())
47 {
48 case NPC_DEMOLISHER:
50 break;
54 break;
58 break;
59 case NPC_CATAPULT:
61 break;
62 default:
63 return;
64 }
65
66 me->CastSpell(who, spellId, true);
67 }
68 }
69};
70
72{
75};
76
78{
79 SAY_ONBOARD = 0
80};
81
83{
84 npc_ioc_gunship_captain(Creature* creature) : ScriptedAI(creature) { }
85
86 void JustAppeared() override
87 {
90 }
91
92 void UpdateAI(uint32 diff) override
93 {
94 _events.Update(diff);
95 while (uint32 eventId = _events.ExecuteEvent())
96 {
97 switch (eventId)
98 {
99 case EVENT_TALK:
103 break;
104 case EVENT_DESPAWN:
106 break;
107 default:
108 break;
109 }
110 }
111 }
112
113private:
115};
116
118{
119 npc_ioc_siege_engine(Creature* creature) : ScriptedAI(creature) { }
120
121 static constexpr uint32 SPELL_DAMAGED = 67323;
122 static constexpr uint32 VEHICLE_REC_ID = 514;
123 static constexpr int32 ACTION_REPAIRED = 1;
124
125 void JustAppeared() override
126 {
127 me->RemoveVehicleKit(false);
129 }
130
131 void DoAction(int32 actionId) override
132 {
133 // there should be some moving involved first
134 if (actionId == ACTION_REPAIRED)
135 {
138 }
139 }
140};
141
143{
145
146 bool OnGossipHello(Player* player) override
147 {
149 return true;
150
151 if (ZoneScript* zonescript = me->GetZoneScript())
152 {
153 zonescript->DoAction(ACTION_IOC_INTERACT_CAPTURABLE_OBJECT, player, me);
154 return false;
155 }
156
157 return true;
158 }
159};
160
162{
164
165 void Reset() override
166 {
169 {
170 if (ZoneScript* zonescript = me->GetZoneScript())
171 zonescript->DoAction(ACTION_IOC_CAPTURE_CAPTURABLE_OBJECT, me, me);
172 });
173 }
174
175 void UpdateAI(uint32 diff) override
176 {
177 _scheduler.Update(diff);
178 }
179
180private:
182};
183
184// 67323 - Damaged
186{
187 void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) const
188 {
189 if (Creature const* creatureTarget = GetTarget()->ToCreature())
190 if (UnitAI* ai = creatureTarget->GetAI())
192 }
193
194 void Register() override
195 {
197 }
198};
199
200// 66630 - Alliance Gunship Portal
201// 66637 - Horde Gunship Portal
203{
204 bool Load() override
205 {
206 return GetCaster()->GetTypeId() == TYPEID_PLAYER;
207 }
208
209 void HandleScript(SpellEffIndex /*effIndex*/)
210 {
211 Player* caster = GetCaster()->ToPlayer();
212 /*
213 * HACK: GetWorldLocation() returns real position and not transportposition.
214 * ServertoClient: SMSG_MOVE_TELEPORT (0x0B39)
215 * counter: 45
216 * Tranpsort Guid: Full: xxxx Type: MOTransport Low: xxx
217 * Transport Position X: 0 Y: 0 Z: 0 O: 0
218 * Position: X: 7.305609 Y: -0.095246 Z: 34.51022 O: 0
219 */
220 caster->TeleportTo(GetHitCreature()->GetWorldLocation(), TELE_TO_NOT_LEAVE_TRANSPORT);
221 }
222
223 void Register() override
224 {
226 }
227};
228
229// 66656 - Parachute
231{
232 void HandleTriggerSpell(AuraEffect const* /*aurEff*/)
233 {
235 if (Player* target = GetTarget()->ToPlayer())
236 if (target->m_movementInfo.GetFallTime() > 2000 && !target->GetTransport())
237 target->CastSpell(target, SPELL_PARACHUTE_IC, true);
238 }
239
240 void Register() override
241 {
243 }
244};
245
247{
248 public:
249 StartLaunchEvent(Position const& pos, ObjectGuid const& guid) : _pos(pos), _guid(guid)
250 {
251 }
252
253 bool Execute(uint64 /*time*/, uint32 /*diff*/) override
254 {
256 if (!player || !player->GetVehicle())
257 return true;
258
259 player->AddAura(SPELL_LAUNCH_NO_FALLING_DAMAGE, player); // prevents falling damage
260 float speedZ = 10.0f;
261 float dist = player->GetExactDist2d(&_pos);
262
263 player->ExitVehicle();
264 player->GetMotionMaster()->MoveJump(_pos, dist, speedZ, EVENT_JUMP, true);
265 return true;
266 }
267
268 private:
271};
272
273// 66218 - Launch
275{
276 void Launch()
277 {
278 if (!GetCaster()->ToCreature() || !GetExplTargetDest())
279 return;
280
281 GetCaster()->ToCreature()->m_Events.AddEvent(new StartLaunchEvent(*GetExplTargetDest(), ASSERT_NOTNULL(GetHitPlayer())->GetGUID()), GetCaster()->ToCreature()->m_Events.CalculateTime(2500ms));
282 }
283
284 void Register() override
285 {
287 }
288};
289
291{
297
298// 66672 - Huge Seaforium Blast
299// 66676 - Seaforium Blast
301{
302 bool Validate(SpellInfo const* /*spellInfo*/) override
303 {
305 }
306
308 {
309 uint32 _creditSpell = 0;
310 Unit* caster = GetOriginalCaster();
311 if (!caster)
312 return;
313
315 _creditSpell = SPELL_A_BOMB_INABLE_CREDIT;
317 _creditSpell = SPELL_A_BOMB_INATION_CREDIT;
318
319 if (GetHitGObj() && GetHitGObj()->IsDestructibleBuilding())
320 caster->CastSpell(caster, _creditSpell, true);
321 }
322
323 void Register() override
324 {
326 }
327};
328
330{
331public:
332 at_ioc_exploit() : AreaTriggerScript("at_ioc_exploit") { }
333
334 bool OnExit(Player* player, AreaTriggerEntry const* /*trigger*/) override
335 {
336 if (Battleground* battleground = player->GetBattleground())
337 if (battleground->GetStatus() == STATUS_WAIT_JOIN)
338 battleground->TeleportPlayerToExploitLocation(player);
339
340 return true;
341 }
342};
343
345{
346public:
347 static constexpr uint32 AT_HORDE_KEEP = 5535;
348 static constexpr uint32 AT_ALLIANCE_KEEP = 5536;
349
350 at_ioc_backdoor_job() : AreaTriggerScript("at_ioc_backdoor_job") { }
351
352 bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
353 {
355 if (player->GetBGTeam() == HORDE && trigger->ID == AT_ALLIANCE_KEEP)
356 {
357 bool keepClosed = sWorldStateMgr->GetValue(BG_IC_GATE_EAST_A_WS_CLOSED, player->GetMap()) == 1
358 && sWorldStateMgr->GetValue(BG_IC_GATE_WEST_A_WS_CLOSED, player->GetMap()) == 1
359 && sWorldStateMgr->GetValue(BG_IC_GATE_FRONT_A_WS_CLOSED, player->GetMap()) == 1;
360
361 if (keepClosed)
362 player->CastSpell(player, SPELL_BACK_DOOR_JOB_ACHIEVEMENT, true);
363 }
364 else if (player->GetBGTeam() == ALLIANCE && trigger->ID == AT_HORDE_KEEP)
365 {
366 bool keepClosed = sWorldStateMgr->GetValue(BG_IC_GATE_EAST_H_WS_CLOSED, player->GetMap()) == 1
367 && sWorldStateMgr->GetValue(BG_IC_GATE_WEST_H_WS_CLOSED, player->GetMap()) == 1
368 && sWorldStateMgr->GetValue(BG_IC_GATE_FRONT_H_WS_CLOSED, player->GetMap()) == 1;
369
370 if (keepClosed)
371 player->CastSpell(player, SPELL_BACK_DOOR_JOB_ACHIEVEMENT, true);
372 }
373
374 return true;
375 }
376};
377
379{
390 new at_ioc_exploit();
392}
Texts
@ ACTION_IOC_INTERACT_CAPTURABLE_OBJECT
@ ACTION_IOC_CAPTURE_CAPTURABLE_OBJECT
@ NPC_SIEGE_ENGINE_H
@ NPC_SIEGE_ENGINE_A
@ NPC_GLAIVE_THROWER_A
@ NPC_GLAIVE_THROWER_H
@ NPC_DEMOLISHER
@ NPC_CATAPULT
@ SPELL_LAUNCH_NO_FALLING_DAMAGE
@ SPELL_DRIVING_CREDIT_GLAIVE
@ SPELL_DRIVING_CREDIT_SIEGE
@ SPELL_PARACHUTE_IC
@ SPELL_SIMPLE_TELEPORT
@ SPELL_DRIVING_CREDIT_DEMOLISHER
@ SPELL_BACK_DOOR_JOB_ACHIEVEMENT
@ SPELL_DRIVING_CREDIT_CATAPULT
@ SPELL_TELEPORT_VISUAL_ONLY
@ BG_IC_GATE_FRONT_A_WS_CLOSED
@ BG_IC_GATE_FRONT_H_WS_CLOSED
@ BG_IC_GATE_EAST_H_WS_CLOSED
@ BG_IC_GATE_WEST_H_WS_CLOSED
@ BG_IC_GATE_WEST_A_WS_CLOSED
@ BG_IC_GATE_EAST_A_WS_CLOSED
@ STATUS_WAIT_JOIN
Definition: Battleground.h:166
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:84
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition: Player.h:803
#define RegisterCreatureAI(ai_name)
Definition: ScriptMgr.h:1380
#define RegisterGameObjectAI(ai_name)
Definition: ScriptMgr.h:1398
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ EVENT_JUMP
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_GAMEOBJECT_DAMAGE
@ ALLIANCE
@ HORDE
@ GO_FLAG_NOT_SELECTABLE
@ GO_STATE_READY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define SpellHitFn(F)
Definition: SpellScript.h:854
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
#define sWorldStateMgr
Definition: WorldStateMgr.h:50
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetTarget() const
HookList< EffectApplyHandler > OnEffectRemove
Definition: SpellScript.h:2035
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
Creature *const me
Definition: CreatureAI.h:61
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
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 AddEvent(BasicEvent *event, Milliseconds e_time, bool set_addtime=true)
GameObject *const me
Definition: GameObjectAI.h:50
virtual void Reset()
Definition: GameObjectAI.h:63
GOState GetGoState() const
Definition: GameObject.h:281
bool HasFlag(GameObjectFlags flags) const
Definition: GameObject.h:273
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, JumpArrivalCastArgs const *arrivalCast=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
static Creature * ToCreature(Object *o)
Definition: Object.h:219
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static Player * ToPlayer(Object *o)
Definition: Object.h:213
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, TeleportToOptions options=TELE_TO_NONE, Optional< uint32 > instanceId={})
Definition: Player.cpp:1250
Battleground * GetBattleground() const
Definition: Player.cpp:24976
Team GetBGTeam() const
Definition: Player.cpp:23609
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Creature * GetHitCreature() const
Player * GetHitPlayer() const
Unit * GetCaster() const
HookList< HitHandler > AfterHit
Definition: SpellScript.h:852
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
WorldLocation const * GetExplTargetDest() const
SpellInfo const * GetSpellInfo() const
Unit * GetOriginalCaster() const
GameObject * GetHitGObj() const
bool Execute(uint64, uint32) override
StartLaunchEvent(Position const &pos, ObjectGuid const &guid)
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
Definition: UnitAI.h:50
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
Vehicle * GetVehicle() const
Definition: Unit.h:1713
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:11618
bool CreateVehicleKit(uint32 id, uint32 creatureEntry, bool loading=false)
Definition: Unit.cpp:11443
void RemoveVehicleKit(bool onRemoveFromWorld=false)
Definition: Unit.cpp:11459
Vehicle * GetVehicleKit() const
Definition: Unit.h:1711
virtual void ExitVehicle(Position const *exitPosition=nullptr)
Definition: Unit.cpp:12204
void InstallAllAccessories(bool evading)
Definition: Vehicle.cpp:85
Map * GetMap() const
Definition: Object.h:624
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
ZoneScript * GetZoneScript() const
Definition: Object.h:630
EventProcessor m_Events
Definition: Object.h:777
static constexpr uint32 AT_ALLIANCE_KEEP
bool OnTrigger(Player *player, AreaTriggerEntry const *trigger) override
static constexpr uint32 AT_HORDE_KEEP
bool OnExit(Player *player, AreaTriggerEntry const *) override
void HandleRemove(AuraEffect const *, AuraEffectHandleModes) const
void Register() override
void HandleScript(SpellEffIndex)
void Register() override
void HandleTriggerSpell(AuraEffect const *)
void HandleAchievementCredit(SpellEffIndex)
bool Validate(SpellInfo const *) override
void AddSC_isle_of_conquest()
@ SAY_ONBOARD
SeaforiumBombSpells
@ SPELL_SEAFORIUM_BLAST
@ SPELL_HUGE_SEAFORIUM_BLAST
@ SPELL_A_BOMB_INATION_CREDIT
@ SPELL_A_BOMB_INABLE_CREDIT
@ EVENT_DESPAWN
@ EVENT_TALK
void apply(T *val)
Definition: ByteConverter.h:41
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:106
go_ioc_capturable_object(GameObject *go)
bool OnGossipHello(Player *player) override
go_ioc_contested_object(GameObject *go)
void UpdateAI(uint32 diff) override
void PassengerBoarded(Unit *who, int8, bool apply) override
== Fields =======================================
npc_four_car_garage(Creature *creature)
void UpdateAI(uint32 diff) override
npc_ioc_gunship_captain(Creature *creature)
void JustAppeared() override
static constexpr int32 ACTION_REPAIRED
void DoAction(int32 actionId) override
static constexpr uint32 SPELL_DAMAGED
npc_ioc_siege_engine(Creature *creature)
void JustAppeared() override
static constexpr uint32 VEHICLE_REC_ID