TrinityCore
Loading...
Searching...
No Matches
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 "Map.h"
22#include "MotionMaster.h"
23#include "ObjectAccessor.h"
24#include "PassiveAI.h"
25#include "Player.h"
26#include "ScriptedCreature.h"
27#include "SpellInfo.h"
28#include "SpellScript.h"
29#include "Vehicle.h"
30
31// TO-DO: This should be done with SmartAI, but yet it does not correctly support vehicles's AIs.
32// Even adding ReactState Passive we still have issues using SmartAI.
33
35{
36 npc_four_car_garage(Creature* creature) : NullCreatureAI(creature) { }
37
38 void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override
39 {
40 if (apply)
41 {
42 uint32 spellId = 0;
43
44 switch (me->GetEntry())
45 {
46 case NPC_DEMOLISHER:
48 break;
52 break;
56 break;
57 case NPC_CATAPULT:
59 break;
60 default:
61 return;
62 }
63
64 me->CastSpell(who, spellId, true);
65 }
66 }
67};
68
74
76{
77 SAY_ONBOARD = 0
78};
79
81{
82 npc_ioc_gunship_captain(Creature* creature) : ScriptedAI(creature) { }
83
84 void DoAction(int32 action) override
85 {
86 if (action == ACTION_GUNSHIP_READY)
87 {
90 }
91 }
92
93 void UpdateAI(uint32 diff) override
94 {
95 _events.Update(diff);
96 while (uint32 eventId = _events.ExecuteEvent())
97 {
98 switch (eventId)
99 {
100 case EVENT_TALK:
104 break;
105 case EVENT_DESPAWN:
106 if (BattlegroundMap* iocMap = me->GetMap()->ToBattlegroundMap())
107 if (Battleground* bgIoC = iocMap->GetBG())
108 bgIoC->DelCreature(BG_IC_NPC_GUNSHIP_CAPTAIN_1);
109 break;
110 default:
111 break;
112 }
113 }
114 }
115
116private:
118};
119
120// 66630 - Alliance Gunship Portal
121// 66637 - Horde Gunship Portal
123{
125
126 bool Load() override
127 {
128 return GetCaster()->GetTypeId() == TYPEID_PLAYER;
129 }
130
131 void HandleScript(SpellEffIndex /*effIndex*/)
132 {
133 Player* caster = GetCaster()->ToPlayer();
134 /*
135 * HACK: GetWorldLocation() returns real position and not transportposition.
136 * ServertoClient: SMSG_MOVE_TELEPORT (0x0B39)
137 * counter: 45
138 * Tranpsort Guid: Full: xxxx Type: MOTransport Low: xxx
139 * Transport Position X: 0 Y: 0 Z: 0 O: 0
140 * Position: X: 7.305609 Y: -0.095246 Z: 34.51022 O: 0
141 */
142 caster->TeleportTo(GetHitCreature()->GetWorldLocation(), TELE_TO_NOT_LEAVE_TRANSPORT);
143 }
144
149};
150
151// 66656 - Parachute
153{
155
156 void HandleTriggerSpell(AuraEffect const* /*aurEff*/)
157 {
159 if (Player* target = GetTarget()->ToPlayer())
160 if (target->m_movementInfo.GetFallTime() > 2000 && !target->GetTransport())
161 target->CastSpell(target, SPELL_PARACHUTE_IC, true);
162 }
163
168};
169
171{
172 public:
173 StartLaunchEvent(Position const& pos, ObjectGuid const& guid) : _pos(pos), _guid(guid)
174 {
175 }
176
177 bool Execute(uint64 /*time*/, uint32 /*diff*/) override
178 {
180 if (!player || !player->GetVehicle())
181 return true;
182
183 player->AddAura(SPELL_LAUNCH_NO_FALLING_DAMAGE, player); // prevents falling damage
184 float speedZ = 10.0f;
185 float dist = player->GetExactDist2d(&_pos);
186
187 player->ExitVehicle();
188 player->GetMotionMaster()->MoveJump(_pos, dist, speedZ, EVENT_JUMP, true);
189 return true;
190 }
191
192 private:
195};
196
197// 66218 - Launch
199{
201
202 void Launch()
203 {
204 if (!GetCaster()->ToCreature() || !GetExplTargetDest())
205 return;
206
207 GetCaster()->ToCreature()->m_Events.AddEvent(new StartLaunchEvent(*GetExplTargetDest(), ASSERT_NOTNULL(GetHitPlayer())->GetGUID()), GetCaster()->ToCreature()->m_Events.CalculateTime(2500ms));
208 }
209
210 void Register() override
211 {
213 }
214};
215
225
226// 66672 - Huge Seaforium Blast
227// 66676 - Seaforium Blast
229{
231
232 bool Validate(SpellInfo const* /*spellInfo*/) override
233 {
235 }
236
238 {
239 uint32 _creditSpell = 0;
240 Unit* caster = GetOriginalCaster();
241 if (!caster)
242 return;
243
244 uint32 spellId = GetSpellInfo()->Id;
245 if (spellId == SPELL_SEAFORIUM_BLAST || spellId == SPELL_SEAFORIUM_BLAST_H)
246 _creditSpell = SPELL_A_BOMB_INABLE_CREDIT;
247 else if (spellId == SPELL_HUGE_SEAFORIUM_BLAST || spellId == SPELL_HUGE_SEAFORIUM_BLAST_H)
248 _creditSpell = SPELL_A_BOMB_INATION_CREDIT;
249
250 if (GetHitGObj() && GetHitGObj()->IsDestructibleBuilding())
251 caster->CastSpell(caster, _creditSpell, true);
252 }
253
258};
259
@ ACTION_GUNSHIP_READY
@ 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_DRIVING_CREDIT_CATAPULT
@ SPELL_TELEPORT_VISUAL_ONLY
@ BG_IC_NPC_GUNSHIP_CAPTAIN_1
int8_t int8
Definition Define.h:131
int32_t int32
Definition Define.h:129
uint64_t uint64
Definition Define.h:132
uint32_t uint32
Definition Define.h:133
#define ASSERT_NOTNULL(pointer)
Definition Errors.h:84
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition Player.h:680
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1139
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_GAMEOBJECT_DAMAGE
@ EVENT_JUMP
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define SpellHitFn(F)
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void AddEvent(BasicEvent *event, Milliseconds e_time, bool set_addtime=true)
BattlegroundMap * ToBattlegroundMap()
Definition Map.h:523
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false)
static Creature * ToCreature(Object *o)
Definition Object.h:186
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
static Player * ToPlayer(Object *o)
Definition Object.h:180
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0)
Definition Player.cpp:1524
uint32 Id
Definition SpellInfo.h:289
Creature * GetHitCreature() const
Player * GetHitPlayer() const
Unit * GetCaster() const
HookList< HitHandler > AfterHit
HookList< EffectHandler > OnEffectHitTarget
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)
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
Vehicle * GetVehicle() const
Definition Unit.h:1737
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:11964
virtual void ExitVehicle(Position const *exitPosition=nullptr)
Definition Unit.cpp:12661
Map * GetMap() const
Definition Object.h:449
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
EventProcessor m_Events
Definition Object.h:591
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_ioc_gunship_portal)
void HandleScript(SpellEffIndex)
void Register() override
PrepareSpellScript(spell_ioc_launch)
PrepareAuraScript(spell_ioc_parachute_ic)
void HandleTriggerSpell(AuraEffect const *)
void HandleAchievementCredit(SpellEffIndex)
PrepareSpellScript(spell_ioc_seaforium_blast_credit)
bool Validate(SpellInfo const *) override
void AddSC_isle_of_conquest()
@ SAY_ONBOARD
SeaforiumBombSpells
@ SPELL_HUGE_SEAFORIUM_BLAST_H
@ SPELL_SEAFORIUM_BLAST
@ SPELL_SEAFORIUM_BLAST_H
@ SPELL_HUGE_SEAFORIUM_BLAST
@ SPELL_A_BOMB_INATION_CREDIT
@ SPELL_A_BOMB_INABLE_CREDIT
@ EVENT_DESPAWN
@ EVENT_TALK
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
float GetExactDist2d(const float x, const float y) const
Definition Position.h:109
void PassengerBoarded(Unit *who, int8, bool apply) override
== Fields =======================================
npc_four_car_garage(Creature *creature)
void DoAction(int32 action) override
void UpdateAI(uint32 diff) override
npc_ioc_gunship_captain(Creature *creature)