From c1ed002b4b0d30432b76f9c5df9095ade4b0b171 Mon Sep 17 00:00:00 2001 From: asterc Date: Mon, 9 May 2016 09:51:16 -0300 Subject: Core/Battleground Script for Isle of Conquest Bosses by @gerripeach --- .../IsleOfConquest/boss_ioc_horde_alliance.cpp | 132 ++++++++++ .../Northrend/IsleOfConquest/isle_of_conquest.cpp | 269 +++++++++++++++++++++ src/server/scripts/Northrend/isle_of_conquest.cpp | 269 --------------------- .../scripts/Northrend/northrend_script_loader.cpp | 6 +- 4 files changed, 405 insertions(+), 271 deletions(-) create mode 100644 src/server/scripts/Northrend/IsleOfConquest/boss_ioc_horde_alliance.cpp create mode 100644 src/server/scripts/Northrend/IsleOfConquest/isle_of_conquest.cpp delete mode 100644 src/server/scripts/Northrend/isle_of_conquest.cpp (limited to 'src/server/scripts') diff --git a/src/server/scripts/Northrend/IsleOfConquest/boss_ioc_horde_alliance.cpp b/src/server/scripts/Northrend/IsleOfConquest/boss_ioc_horde_alliance.cpp new file mode 100644 index 00000000000..71d90da21a1 --- /dev/null +++ b/src/server/scripts/Northrend/IsleOfConquest/boss_ioc_horde_alliance.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2008-2016 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "ScriptMgr.h" +#include "ScriptedCreature.h" +#include "BattlegroundIC.h" + +enum BossSpells +{ + SPELL_BRUTAL_STRIKE = 58460, + SPELL_DAGGER_THROW = 67280, + SPELL_CRUSHING_LEAP = 68506, + SPELL_RAGE = 66776 +}; + +enum BossEvents +{ + EVENT_BRUTAL_STRIKE = 1, + EVENT_DAGGER_THROW = 2, + EVENT_CRUSHING_LEAP = 3, + EVENT_CHECK_RANGE = 4 +}; + +class boss_ioc_horde_alliance : public CreatureScript +{ +public: + boss_ioc_horde_alliance() : CreatureScript("boss_ioc_horde_alliance") { } + + struct boss_ioc_horde_allianceAI : public ScriptedAI + { + boss_ioc_horde_allianceAI(Creature* creature) : ScriptedAI(creature) { } + + void Reset() override + { + _events.Reset(); + + uint32 _npcGuard; + if (me->GetEntry() == NPC_HIGH_COMMANDER_HALFORD_WYRMBANE) + _npcGuard = NPC_SEVEN_TH_LEGION_INFANTRY; + else + _npcGuard = NPC_KOR_KRON_GUARD; + + std::list guardsList; + me->GetCreatureListWithEntryInGrid(guardsList, _npcGuard, 100.0f); + for (std::list::const_iterator itr = guardsList.begin(); itr != guardsList.end(); ++itr) + (*itr)->Respawn(); + }; + + void EnterCombat(Unit* /*who*/) override + { + _events.ScheduleEvent(EVENT_BRUTAL_STRIKE, 5 * IN_MILLISECONDS); + _events.ScheduleEvent(EVENT_DAGGER_THROW, 7 * IN_MILLISECONDS); + _events.ScheduleEvent(EVENT_CHECK_RANGE, 1 * IN_MILLISECONDS); + _events.ScheduleEvent(EVENT_CRUSHING_LEAP, 15 * IN_MILLISECONDS); + } + + void SpellHit(Unit* caster, SpellInfo const* /*spell*/) override + { + if (caster->IsVehicle()) + me->Kill(caster); + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_BRUTAL_STRIKE: + DoCastVictim(SPELL_BRUTAL_STRIKE); + _events.ScheduleEvent(EVENT_BRUTAL_STRIKE, 5 * IN_MILLISECONDS); + break; + case EVENT_DAGGER_THROW: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1)) + DoCast(target, SPELL_DAGGER_THROW); + _events.ScheduleEvent(EVENT_DAGGER_THROW, 7 * IN_MILLISECONDS); + break; + case EVENT_CRUSHING_LEAP: + DoCastVictim(SPELL_CRUSHING_LEAP); + _events.ScheduleEvent(EVENT_CRUSHING_LEAP, 25 * IN_MILLISECONDS); + break; + case EVENT_CHECK_RANGE: + if (me->GetDistance(me->GetHomePosition()) > 25.0f) + DoCast(me, SPELL_RAGE); + else + me->RemoveAurasDueToSpell(SPELL_RAGE); + _events.ScheduleEvent(EVENT_CHECK_RANGE, 1 * IN_MILLISECONDS); + break; + default: + break; + } + } + + DoMeleeAttackIfReady(); + } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new boss_ioc_horde_allianceAI(creature); + } +}; + +void AddSC_boss_ioc_horde_alliance() +{ + new boss_ioc_horde_alliance(); +} diff --git a/src/server/scripts/Northrend/IsleOfConquest/isle_of_conquest.cpp b/src/server/scripts/Northrend/IsleOfConquest/isle_of_conquest.cpp new file mode 100644 index 00000000000..11cc645f0cb --- /dev/null +++ b/src/server/scripts/Northrend/IsleOfConquest/isle_of_conquest.cpp @@ -0,0 +1,269 @@ +/* + * Copyright (C) 2008-2016 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "ScriptMgr.h" +#include "ScriptedCreature.h" +#include "PassiveAI.h" +#include "BattlegroundIC.h" +#include "Player.h" +#include "Vehicle.h" +#include "SpellScript.h" +#include "SpellInfo.h" + +// TO-DO: This should be done with SmartAI, but yet it does not correctly support vehicles's AIs. +// Even adding ReactState Passive we still have issues using SmartAI. + +class npc_four_car_garage : public CreatureScript +{ + public: + npc_four_car_garage() : CreatureScript("npc_four_car_garage") { } + + struct npc_four_car_garageAI : public NullCreatureAI + { + npc_four_car_garageAI(Creature* creature) : NullCreatureAI(creature) { } + + void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override + { + if (apply) + { + uint32 spellId = 0; + + switch (me->GetEntry()) + { + case NPC_DEMOLISHER: + spellId = SPELL_DRIVING_CREDIT_DEMOLISHER; + break; + case NPC_GLAIVE_THROWER_A: + case NPC_GLAIVE_THROWER_H: + spellId = SPELL_DRIVING_CREDIT_GLAIVE; + break; + case NPC_SIEGE_ENGINE_H: + case NPC_SIEGE_ENGINE_A: + spellId = SPELL_DRIVING_CREDIT_SIEGE; + break; + case NPC_CATAPULT: + spellId = SPELL_DRIVING_CREDIT_CATAPULT; + break; + default: + return; + } + + me->CastSpell(who, spellId, true); + } + } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_four_car_garageAI(creature); + } +}; + +enum Events +{ + EVENT_TALK = 1, + EVENT_DESPAWN +}; + +enum Texts +{ + SAY_ONBOARD = 0 +}; + +class npc_ioc_gunship_captain : public CreatureScript +{ + public: + npc_ioc_gunship_captain() : CreatureScript("npc_ioc_gunship_captain") { } + + struct npc_ioc_gunship_captainAI : public ScriptedAI + { + npc_ioc_gunship_captainAI(Creature* creature) : ScriptedAI(creature) { } + + void DoAction(int32 action) override + { + if (action == ACTION_GUNSHIP_READY) + { + DoCast(me, SPELL_SIMPLE_TELEPORT); + _events.ScheduleEvent(EVENT_TALK, 3000); + } + } + + void UpdateAI(uint32 diff) override + { + _events.Update(diff); + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_TALK: + _events.ScheduleEvent(EVENT_DESPAWN, 1000); + Talk(SAY_ONBOARD); + DoCast(me, SPELL_TELEPORT_VISUAL_ONLY); + break; + case EVENT_DESPAWN: + if (me->GetMap()->ToBattlegroundMap()) + if (Battleground* bgIoC = me->GetMap()->ToBattlegroundMap()->GetBG()) + bgIoC->DelCreature(BG_IC_NPC_GUNSHIP_CAPTAIN_1); + break; + default: + break; + } + } + } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_ioc_gunship_captainAI(creature); + } +}; + +class spell_ioc_gunship_portal : public SpellScriptLoader +{ + public: + spell_ioc_gunship_portal() : SpellScriptLoader("spell_ioc_gunship_portal") { } + + class spell_ioc_gunship_portal_SpellScript : public SpellScript + { + PrepareSpellScript(spell_ioc_gunship_portal_SpellScript); + + bool Load() override + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + /* + * HACK: GetWorldLocation() returns real position and not transportposition. + * ServertoClient: SMSG_MOVE_TELEPORT (0x0B39) + * counter: 45 + * Tranpsort Guid: Full: xxxx Type: MOTransport Low: xxx + * Transport Position X: 0 Y: 0 Z: 0 O: 0 + * Position: X: 7.305609 Y: -0.095246 Z: 34.51022 O: 0 + */ + caster->TeleportTo(GetHitCreature()->GetWorldLocation(), TELE_TO_NOT_LEAVE_TRANSPORT); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_ioc_gunship_portal_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_ioc_gunship_portal_SpellScript(); + } +}; + +class spell_ioc_parachute_ic : public SpellScriptLoader +{ + public: + spell_ioc_parachute_ic() : SpellScriptLoader("spell_ioc_parachute_ic") { } + + class spell_ioc_parachute_ic_AuraScript : public AuraScript + { + PrepareAuraScript(spell_ioc_parachute_ic_AuraScript); + + void HandleTriggerSpell(AuraEffect const* /*aurEff*/) + { + if (Player* target = GetTarget()->ToPlayer()) + if (target->m_movementInfo.fallTime > 2000 && !target->GetTransport()) + target->CastSpell(target, SPELL_PARACHUTE_IC, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_ioc_parachute_ic_AuraScript::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_ioc_parachute_ic_AuraScript(); + } +}; + +class StartLaunchEvent : public BasicEvent +{ + public: + StartLaunchEvent(Position const& pos, ObjectGuid::LowType lowGuid) : _pos(pos), _lowGuid(lowGuid) + { + } + + bool Execute(uint64 /*time*/, uint32 /*diff*/) override + { + Player* player = sObjectMgr->GetPlayerByLowGUID(_lowGuid); + if (!player || !player->GetVehicle()) + return true; + + player->AddAura(SPELL_LAUNCH_NO_FALLING_DAMAGE, player); // prevents falling damage + float speedZ = 10.0f; + float dist = player->GetExactDist2d(&_pos); + + player->ExitVehicle(); + player->GetMotionMaster()->MoveJump(_pos, dist, speedZ, EVENT_JUMP, true); + return true; + } + + private: + Position _pos; + ObjectGuid::LowType _lowGuid; +}; + +class spell_ioc_launch : public SpellScriptLoader +{ + public: + spell_ioc_launch() : SpellScriptLoader("spell_ioc_launch") { } + + class spell_ioc_launch_SpellScript : public SpellScript + { + PrepareSpellScript(spell_ioc_launch_SpellScript); + + void Launch() + { + if (!GetCaster()->ToCreature() || !GetExplTargetDest()) + return; + + GetCaster()->ToCreature()->m_Events.AddEvent(new StartLaunchEvent(*GetExplTargetDest(), GetHitPlayer()->GetGUID().GetCounter()), GetCaster()->ToCreature()->m_Events.CalculateTime(2500)); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_ioc_launch_SpellScript::Launch); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_ioc_launch_SpellScript(); + } +}; + +void AddSC_isle_of_conquest() +{ + new npc_four_car_garage(); + new npc_ioc_gunship_captain(); + new spell_ioc_gunship_portal(); + new spell_ioc_parachute_ic(); + new spell_ioc_launch(); +} diff --git a/src/server/scripts/Northrend/isle_of_conquest.cpp b/src/server/scripts/Northrend/isle_of_conquest.cpp deleted file mode 100644 index 11cc645f0cb..00000000000 --- a/src/server/scripts/Northrend/isle_of_conquest.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "PassiveAI.h" -#include "BattlegroundIC.h" -#include "Player.h" -#include "Vehicle.h" -#include "SpellScript.h" -#include "SpellInfo.h" - -// TO-DO: This should be done with SmartAI, but yet it does not correctly support vehicles's AIs. -// Even adding ReactState Passive we still have issues using SmartAI. - -class npc_four_car_garage : public CreatureScript -{ - public: - npc_four_car_garage() : CreatureScript("npc_four_car_garage") { } - - struct npc_four_car_garageAI : public NullCreatureAI - { - npc_four_car_garageAI(Creature* creature) : NullCreatureAI(creature) { } - - void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override - { - if (apply) - { - uint32 spellId = 0; - - switch (me->GetEntry()) - { - case NPC_DEMOLISHER: - spellId = SPELL_DRIVING_CREDIT_DEMOLISHER; - break; - case NPC_GLAIVE_THROWER_A: - case NPC_GLAIVE_THROWER_H: - spellId = SPELL_DRIVING_CREDIT_GLAIVE; - break; - case NPC_SIEGE_ENGINE_H: - case NPC_SIEGE_ENGINE_A: - spellId = SPELL_DRIVING_CREDIT_SIEGE; - break; - case NPC_CATAPULT: - spellId = SPELL_DRIVING_CREDIT_CATAPULT; - break; - default: - return; - } - - me->CastSpell(who, spellId, true); - } - } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_four_car_garageAI(creature); - } -}; - -enum Events -{ - EVENT_TALK = 1, - EVENT_DESPAWN -}; - -enum Texts -{ - SAY_ONBOARD = 0 -}; - -class npc_ioc_gunship_captain : public CreatureScript -{ - public: - npc_ioc_gunship_captain() : CreatureScript("npc_ioc_gunship_captain") { } - - struct npc_ioc_gunship_captainAI : public ScriptedAI - { - npc_ioc_gunship_captainAI(Creature* creature) : ScriptedAI(creature) { } - - void DoAction(int32 action) override - { - if (action == ACTION_GUNSHIP_READY) - { - DoCast(me, SPELL_SIMPLE_TELEPORT); - _events.ScheduleEvent(EVENT_TALK, 3000); - } - } - - void UpdateAI(uint32 diff) override - { - _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_TALK: - _events.ScheduleEvent(EVENT_DESPAWN, 1000); - Talk(SAY_ONBOARD); - DoCast(me, SPELL_TELEPORT_VISUAL_ONLY); - break; - case EVENT_DESPAWN: - if (me->GetMap()->ToBattlegroundMap()) - if (Battleground* bgIoC = me->GetMap()->ToBattlegroundMap()->GetBG()) - bgIoC->DelCreature(BG_IC_NPC_GUNSHIP_CAPTAIN_1); - break; - default: - break; - } - } - } - - private: - EventMap _events; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_ioc_gunship_captainAI(creature); - } -}; - -class spell_ioc_gunship_portal : public SpellScriptLoader -{ - public: - spell_ioc_gunship_portal() : SpellScriptLoader("spell_ioc_gunship_portal") { } - - class spell_ioc_gunship_portal_SpellScript : public SpellScript - { - PrepareSpellScript(spell_ioc_gunship_portal_SpellScript); - - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_PLAYER; - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - Player* caster = GetCaster()->ToPlayer(); - /* - * HACK: GetWorldLocation() returns real position and not transportposition. - * ServertoClient: SMSG_MOVE_TELEPORT (0x0B39) - * counter: 45 - * Tranpsort Guid: Full: xxxx Type: MOTransport Low: xxx - * Transport Position X: 0 Y: 0 Z: 0 O: 0 - * Position: X: 7.305609 Y: -0.095246 Z: 34.51022 O: 0 - */ - caster->TeleportTo(GetHitCreature()->GetWorldLocation(), TELE_TO_NOT_LEAVE_TRANSPORT); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_ioc_gunship_portal_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_ioc_gunship_portal_SpellScript(); - } -}; - -class spell_ioc_parachute_ic : public SpellScriptLoader -{ - public: - spell_ioc_parachute_ic() : SpellScriptLoader("spell_ioc_parachute_ic") { } - - class spell_ioc_parachute_ic_AuraScript : public AuraScript - { - PrepareAuraScript(spell_ioc_parachute_ic_AuraScript); - - void HandleTriggerSpell(AuraEffect const* /*aurEff*/) - { - if (Player* target = GetTarget()->ToPlayer()) - if (target->m_movementInfo.fallTime > 2000 && !target->GetTransport()) - target->CastSpell(target, SPELL_PARACHUTE_IC, true); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_ioc_parachute_ic_AuraScript::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_ioc_parachute_ic_AuraScript(); - } -}; - -class StartLaunchEvent : public BasicEvent -{ - public: - StartLaunchEvent(Position const& pos, ObjectGuid::LowType lowGuid) : _pos(pos), _lowGuid(lowGuid) - { - } - - bool Execute(uint64 /*time*/, uint32 /*diff*/) override - { - Player* player = sObjectMgr->GetPlayerByLowGUID(_lowGuid); - if (!player || !player->GetVehicle()) - return true; - - player->AddAura(SPELL_LAUNCH_NO_FALLING_DAMAGE, player); // prevents falling damage - float speedZ = 10.0f; - float dist = player->GetExactDist2d(&_pos); - - player->ExitVehicle(); - player->GetMotionMaster()->MoveJump(_pos, dist, speedZ, EVENT_JUMP, true); - return true; - } - - private: - Position _pos; - ObjectGuid::LowType _lowGuid; -}; - -class spell_ioc_launch : public SpellScriptLoader -{ - public: - spell_ioc_launch() : SpellScriptLoader("spell_ioc_launch") { } - - class spell_ioc_launch_SpellScript : public SpellScript - { - PrepareSpellScript(spell_ioc_launch_SpellScript); - - void Launch() - { - if (!GetCaster()->ToCreature() || !GetExplTargetDest()) - return; - - GetCaster()->ToCreature()->m_Events.AddEvent(new StartLaunchEvent(*GetExplTargetDest(), GetHitPlayer()->GetGUID().GetCounter()), GetCaster()->ToCreature()->m_Events.CalculateTime(2500)); - } - - void Register() override - { - AfterHit += SpellHitFn(spell_ioc_launch_SpellScript::Launch); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_ioc_launch_SpellScript(); - } -}; - -void AddSC_isle_of_conquest() -{ - new npc_four_car_garage(); - new npc_ioc_gunship_captain(); - new spell_ioc_gunship_portal(); - new spell_ioc_parachute_ic(); - new spell_ioc_launch(); -} diff --git a/src/server/scripts/Northrend/northrend_script_loader.cpp b/src/server/scripts/Northrend/northrend_script_loader.cpp index 7d104b85f6d..d84bb1c4072 100644 --- a/src/server/scripts/Northrend/northrend_script_loader.cpp +++ b/src/server/scripts/Northrend/northrend_script_loader.cpp @@ -178,6 +178,8 @@ void AddSC_boss_baltharus_the_warborn(); void AddSC_boss_saviana_ragefire(); void AddSC_boss_general_zarithrian(); void AddSC_boss_halion(); +void AddSC_isle_of_conquest(); // Isle of Conquest +void AddSC_boss_ioc_horde_alliance(); void AddSC_dalaran(); void AddSC_borean_tundra(); @@ -190,7 +192,6 @@ void AddSC_storm_peaks(); void AddSC_wintergrasp(); void AddSC_zuldrak(); void AddSC_crystalsong_forest(); -void AddSC_isle_of_conquest(); // The name of this function should match: // void Add${NameOfDirectory}Scripts() @@ -358,6 +359,8 @@ void AddNorthrendScripts() AddSC_boss_saviana_ragefire(); AddSC_boss_general_zarithrian(); AddSC_boss_halion(); + AddSC_isle_of_conquest(); // Isle of Conquest + AddSC_boss_ioc_horde_alliance(); AddSC_dalaran(); AddSC_borean_tundra(); @@ -370,5 +373,4 @@ void AddNorthrendScripts() AddSC_wintergrasp(); AddSC_zuldrak(); AddSC_crystalsong_forest(); - AddSC_isle_of_conquest(); } -- cgit v1.2.3