diff --git a/sql/updates/WIP/omnotron.sql b/sql/updates/WIP/omnotron.sql
new file mode 100644
index 00000000000..db5af063a8e
--- /dev/null
+++ b/sql/updates/WIP/omnotron.sql
@@ -0,0 +1,122 @@
+-- Template Updates
+-- Omnotron
+UPDATE `creature_template` SET `ScriptName`= 'boss_omnotron_defense_system' WHERE `entry`= 42186;
+-- Golems
+UPDATE `creature_template` SET `unit_flags2`= 0, `unit_flags`= 0x02000000 | 0x80000000, `ScriptName`= 'npc_omnotron_golem' WHERE `entry` IN (42166, 42178, 42179, 42180);
+
+
+-- Texts
+DELETE FROM `creature_text` WHERE `CreatureID` IN (42166, 42178, 42179, 42180, 42186);
+INSERT INTO `creature_text` (`CreatureID`, `GroupID`, `ID`, `Text`, `Type`, `Language`, `Probability`, `Emote`, `Duration`, `Sound`, `BroadcastTextId`, `comment`) VALUES
+-- Omnotron
+(42186, 0, 0, 'Electron unit activated.', 14, 0, 100, 0, 0, 21865, 47924, 'Omnotron to Electron'),
+(42186, 1, 0, 'Toxitron unit activated.', 14, 0, 100, 0, 0, 21867, 47926, 'Omnotron to Toxitron'),
+(42186, 2, 0, 'Magmatron unit activated.', 14, 0, 100, 0, 0, 21866, 47925, 'Omnotron to Magmatron'),
+(42186, 3, 0, 'Arcanotron unit activated.', 14, 0, 100, 0, 0, 23378, 47927, 'Omnotron to Arcanotron'),
+(42186, 4, 0, 'Electron unit shield systems online.', 14, 0, 100, 0, 0, 21869, 47928, 'Omnotron to Electron'),
+(42186, 5, 0, 'Toxitron unit shield systems online.', 14, 0, 100, 0, 0, 21871, 47956, 'Omnotron to Toxitron'),
+(42186, 6, 0, 'Arcanotron unit shield systems online.', 14, 0, 100, 0, 0, 21872, 47930, 'Omnotron to Arcanotron'),
+(42186, 7, 0, 'Magmatron unit shield systems online.', 14, 0, 100, 0, 0, 21870, 47929, 'Omnotron to Magmatron'),
+(42186, 8, 0, 'Rerouting excess energy to Magmatron unit. Engage flamethrower device.', 14, 0, 100, 0, 0, 21873, 47931, 'Omnotron to Magmatron'),
+(42186, 9, 0, 'Defense systems obliterated. Powering down...', 14, 0, 100, 0, 0, 21864, 47934, 'Omnotron to Player');
+
+/*
+(42166, @GROUP_ID+0, @ID+, '|TInterface\\Icons\\spell_arcane_arcaneresilience.blp:20|t%s begins to cast|cFFFE1CF7|Hspell:79729|h [Power Conversion]!|r', 41, 0, 100, 0, 0, 0, UNKNOWN, 'Arcanotron'),
+(42178, @GROUP_ID+0, @ID+, '|TInterface\\Icons\\ability_hunter_mastermarksman.blp:20|t%s sets his eye on |cFFFF0000$n|r and begins to cast|cFFFF0000|Hspell:79501|h [Acquiring Target]!|r', 41, 0, 100, 0, 0, 0, UNKNOWN, 'Magmatron to Player'),
+(42179, @GROUP_ID+0, @ID+, '|TInterface\\Icons\\spell_shaman_staticshock.blp:20|t%s casts|cFF1CF2FE|Hspell:79888|h [Lightning Conductor]|h|r at |cFF1CF2FE$n|r!', 41, 0, 100, 0, 0, 0, UNKNOWN, 'Electron to Player'),
+(42179, @GROUP_ID+1, @ID+, '|TInterface\\Icons\\spell_nature_lightningshield.blp:20|t%s begins to cast|cFF1CF2FE|Hspell:79900|h [Unstable Shield]!|r', 41, 0, 100, 0, 0, 0, UNKNOWN, 'Electron'),
+(42180, @GROUP_ID+0, @ID+, '|TInterface\\Icons\\spell_nature_nullifydisease.blp:20|t%s begins to cast|cFF1CFE1C|Hspell:79835|h [Poison Soaked Shell]!|r', 41, 0, 100, 0, 0, 0, UNKNOWN, 'Toxitron'),
+*/
+
+-- Spells
+DELETE FROM `spell_script_names` WHERE `ScriptName` IN
+('spell_omnotron_controller_recharge',
+'spell_omnotron_recharging',
+'spell_omnotron_activated',
+'spell_omnotron_inactive');
+
+INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
+(78696, 'spell_omnotron_controller_recharge'),
+(78697, 'spell_omnotron_recharging'),
+(95019, 'spell_omnotron_recharging'),
+(95020, 'spell_omnotron_recharging'),
+(95021, 'spell_omnotron_recharging'),
+(78698, 'spell_omnotron_recharging'),
+(95025, 'spell_omnotron_recharging'),
+(95026, 'spell_omnotron_recharging'),
+(95027, 'spell_omnotron_recharging'),
+(78700, 'spell_omnotron_recharging'),
+(95022, 'spell_omnotron_recharging'),
+(95023, 'spell_omnotron_recharging'),
+(95024, 'spell_omnotron_recharging'),
+(78699, 'spell_omnotron_recharging'),
+(95028, 'spell_omnotron_recharging'),
+(95029, 'spell_omnotron_recharging'),
+(95030, 'spell_omnotron_recharging'),
+(78740, 'spell_omnotron_activated'),
+(95016, 'spell_omnotron_activated'),
+(95017, 'spell_omnotron_activated'),
+(95018, 'spell_omnotron_activated'),
+(78726, 'spell_omnotron_inactive');
+
+-- Conditions
+DELETE FROM `conditions` WHERE `SourceEntry` IN (79920, 78696, 78697, 95019, 95020, 95021, 78698, 95025, 95026, 95027, 78699, 78700, 95022, 95023, 95024, 95028, 95029, 95030) AND `SourceTypeOrReferenceId`= 13;
+INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ScriptName`, `Comment`) VALUES
+(13, 1, 79920, 0, 0, 31, 0, 3, 42179, 0, 0, 0, '', 'Shared Health - Target Electron'),
+(13, 1, 79920, 0, 1, 31, 0, 3, 42178, 0, 0, 0, '', 'Shared Health - Target Magmatron'),
+(13, 1, 79920, 0, 2, 31, 0, 3, 42180, 0, 0, 0, '', 'Shared Health - Target Toxitron'),
+
+(13, 1, 79920, 0, 3, 31, 0, 3, 42166, 0, 0, 0, '', 'Shared Health - Target Arcanotron'),
+
+(13, 1, 78696, 0, 0, 31, 0, 3, 42179, 0, 0, 0, '', 'Controller Recharge - Target Electron'),
+(13, 1, 78696, 0, 1, 31, 0, 3, 42178, 0, 0, 0, '', 'Controller Recharge - Target Magmatron'),
+(13, 1, 78696, 0, 2, 31, 0, 3, 42180, 0, 0, 0, '', 'Controller Recharge - Target Toxitron'),
+(13, 1, 78696, 0, 3, 31, 0, 3, 42166, 0, 0, 0, '', 'Controller Recharge - Target Arcanotron'),
+
+(13, 1, 78697, 0, 0, 31, 0, 3, 42179, 0, 0, 0, '', 'Recharging - Target Electron'),
+(13, 1, 95019, 0, 0, 31, 0, 3, 42179, 0, 0, 0, '', 'Recharging - Target Electron'),
+(13, 1, 95020, 0, 0, 31, 0, 3, 42179, 0, 0, 0, '', 'Recharging - Target Electron'),
+(13, 1, 95021, 0, 0, 31, 0, 3, 42179, 0, 0, 0, '', 'Recharging - Target Electron'),
+
+(13, 1, 78698, 0, 0, 31, 0, 3, 42178, 0, 0, 0, '', 'Recharging - Target Magmatron'),
+(13, 1, 95025, 0, 0, 31, 0, 3, 42178, 0, 0, 0, '', 'Recharging - Target Magmatron'),
+(13, 1, 95026, 0, 0, 31, 0, 3, 42178, 0, 0, 0, '', 'Recharging - Target Magmatron'),
+(13, 1, 95027, 0, 0, 31, 0, 3, 42178, 0, 0, 0, '', 'Recharging - Target Magmatron'),
+
+(13, 1, 78700, 0, 0, 31, 0, 3, 42180, 0, 0, 0, '', 'Recharging - Target Toxitron'),
+(13, 1, 95022, 0, 0, 31, 0, 3, 42180, 0, 0, 0, '', 'Recharging - Target Toxitron'),
+(13, 1, 95023, 0, 0, 31, 0, 3, 42180, 0, 0, 0, '', 'Recharging - Target Toxitron'),
+(13, 1, 95024, 0, 0, 31, 0, 3, 42180, 0, 0, 0, '', 'Recharging - Target Toxitron'),
+
+(13, 1, 78699, 0, 0, 31, 0, 3, 42166, 0, 0, 0, '', 'Recharging - Target Arcanotron'),
+(13, 1, 95028, 0, 0, 31, 0, 3, 42166, 0, 0, 0, '', 'Recharging - Target Arcanotron'),
+(13, 1, 95029, 0, 0, 31, 0, 3, 42166, 0, 0, 0, '', 'Recharging - Target Arcanotron'),
+(13, 1, 95030, 0, 0, 31, 0, 3, 42166, 0, 0, 0, '', 'Recharging - Target Arcanotron');
+
+-- Summon Groups
+DELETE FROM `creature_summon_groups` WHERE `summonerId`= 42186 AND `summonerType`= 0;
+INSERT INTO `creature_summon_groups` (`summonerId`, `summonerType`, `groupId`, `entry`, `position_x`, `position_y`, `position_z`, `orientation`, `summonType`, `summonTime`) VALUES
+(42186, 0, 0, 42179, -342.519, -405.134, 214.0583, 0.9424778, 8, 0),
+(42186, 0, 0, 42178, -308.807, -405.278, 214.0873, 2.111848, 8, 0),
+(42186, 0, 0, 42180, -333.632, -411.866, 214.1353, 1.291544, 8, 0),
+(42186, 0, 0, 42166, -315.415, -412.474, 214.0963, 1.832596, 8, 0);
+
+-- Waypoints
+DELETE FROM `waypoint_data` WHERE `id`= 4218600;
+INSERT INTO `waypoint_data`(`id`, `point`, `position_x`, `position_y`, `position_z`) VALUES
+(4218600, 1, -309.7726, -392.9861, 213.9485),
+(4218600, 2, -324.7795, -399.0781, 213.8248),
+(4218600, 3, -342.2674, -392.6615, 213.9369),
+(4218600, 4, -324.7795, -399.0781, 213.8248);
+
+-- Addons
+DELETE FROM `creature_template_addon` WHERE `entry` IN (42179, 42178, 42180, 42166);
+INSERT INTO `creature_template_addon` (`entry`, `bytes1`, `bytes2`, `auras`) VALUES
+(42179, 0, 1, '78726 82265 78725 73059'),
+(42178, 0, 1, '78726 82265 78725 73059'),
+(42180, 0, 1, '78726 82265 78725 73059'),
+(42166, 0, 1, '78726 82265 78725 73059');
+
+-- Delete encounter related creature
+DELETE FROM `creature` WHERE `guid` IN (250043, 250044, 250045, 250046);
+DELETE FROM `creature_addon` WHERE `guid` IN (250043, 250044, 250045, 250046);
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/blackwing_descent.h b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/blackwing_descent.h
index 233aa053df7..5d21d5f5d59 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/blackwing_descent.h
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/blackwing_descent.h
@@ -36,18 +36,22 @@ enum BWDDataTypes
DATA_NEFARIANS_END = 5,
// Encounter Data
+ /*Magmaw*/
DATA_PREPARE_MASSIVE_CRASH_AND_GET_TARGET_GUID,
DATA_NEFARIAN_MAGMAW,
+
+ /*Omnotron Defense System*/
+ DATA_ELECTRON,
+ DATA_MAGMATRON,
+ DATA_TOXITRON,
+ DATA_ARCANOTRON,
};
enum BWDCreatureIds
{
// Bosses
BOSS_MAGMAW = 41570,
- BOSS_MAGMATRON = 42178,
- BOSS_ARCANOTRON = 42166,
- BOSS_TOXITRON = 42180,
- BOSS_ELECTRON = 42179,
+ BOSS_OMNOTRON = 42186,
BOSS_CHIMAERON = 43296,
BOSS_ATRAMEDES = 41442,
BOSS_MALORIAK = 41378,
@@ -67,7 +71,14 @@ enum BWDCreatureIds
NPC_MAGMAW_SPIKE_STALKER = 41767,
NPC_NEFARIAN_MAGMAW = 49427,
NPC_BLAZING_BONE_CONSTRUCT = 49416,
- NPC_IGNITION = 49447
+ NPC_IGNITION = 49447,
+
+ /*Omnotron Defense System*/
+ NPC_MAGMATRON = 42178,
+ NPC_ARCANOTRON = 42166,
+ NPC_TOXITRON = 42180,
+ NPC_ELECTRON = 42179,
+
};
enum BWDGameObjectIds
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_omnotron_defense_system.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_omnotron_defense_system.cpp
new file mode 100644
index 00000000000..b93620d4890
--- /dev/null
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_omnotron_defense_system.cpp
@@ -0,0 +1,504 @@
+/*
+ * Copyright (C) 2008-2019 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 "ObjectMgr.h"
+#include "ScriptMgr.h"
+#include "ScriptedCreature.h"
+#include "SpellScript.h"
+#include "SpellAuraEffects.h"
+#include "Player.h"
+#include "blackwing_descent.h"
+
+enum Spells
+{
+ // Omnotron
+ SPELL_CONTROLLER_RECHARGE = 78696,
+ SPELL_RECHARGING_ELECTRON = 78697,
+ SPELL_RECHARGING_MAGMATRON = 78698,
+ SPELL_RECHARGING_ARCANOTRON = 78699,
+ SPELL_RECHARGING_TOXITRON = 78700,
+
+ // Omnotron Defense System
+ SPELL_INACTIVE = 78726,
+ SPELL_POWERED_DOWN = 82265,
+ SPELL_SHARED_HEALTH = 79920,
+ SPELL_ACTIVATED = 78740,
+ SPELL_SHUTTING_DOWN = 78746,
+};
+
+enum Texts
+{
+ // Omnotron
+ SAY_ACTIVATE_ELECTRON = 0,
+ SAY_ACTIVATE_TOXITRON = 1,
+ SAY_ACTIVATE_MAGMATRON = 2,
+ SAY_ACTIVATE_ARCANOTRON = 3,
+
+ SAY_SHIELD_ELECTRON = 4,
+ SAY_SHIELD_TOXITRON = 5,
+ SAY_SHIELD_MAGMATRON = 6,
+ SAY_SHIELD_ARCANOTRON = 7,
+};
+
+enum Events
+{
+ // Omnotron
+ EVENT_LINK_GOLEM_HEALTH = 1,
+ EVENT_POWER_UP_FIRST_GOLEM,
+
+ // Omnotron Defense System
+};
+
+enum Actions
+{
+ // Omnotron
+ ACTION_GOLEM_ACTIVATED = 0,
+ ACTION_START_ENCOUNTER = 1,
+ ACTION_STOP_ENCOUNTER = 2,
+
+ // Omnotron Defense System
+ ACTION_ACTIVATE_GOLEM = 0,
+ ACTION_DEACTIVATE_GOLEM = 1
+};
+
+enum Data
+{
+ DATA_NEXT_GOLEM_IN_QUEUE = 0
+};
+
+Position const FirstGolemPatrolStartPoint = { -324.665f, -398.085f, 213.8214f };
+
+enum MovePoints
+{
+ POINT_START_WAYPOINTS = 1
+};
+
+enum SummonGroups
+{
+ SUMMON_GROUP_GOLEMS = 0
+};
+
+struct GolemInfo
+{
+ uint8 ActivateTextId;
+ uint8 ShieldTextId;
+};
+
+std::unordered_map _golemInfoMap =
+{
+ { NPC_ELECTRON, { SAY_ACTIVATE_ELECTRON, SAY_SHIELD_ELECTRON } },
+ { NPC_MAGMATRON, { SAY_ACTIVATE_MAGMATRON, SAY_SHIELD_MAGMATRON } },
+ { NPC_ARCANOTRON, { SAY_ACTIVATE_ARCANOTRON, SAY_SHIELD_ARCANOTRON } },
+ { NPC_TOXITRON, { SAY_ACTIVATE_TOXITRON, SAY_SHIELD_TOXITRON } }
+};
+
+struct boss_omnotron_defense_system : public BossAI
+{
+ boss_omnotron_defense_system(Creature* creature) : BossAI(creature, DATA_OMNOTRON_DEFENSE_SYSTEM)
+ {
+ Initialize();
+ }
+
+ void Initialize()
+ {
+ }
+
+ void Reset() override
+ {
+ _Reset();
+ Initialize();
+ me->SummonCreatureGroup(SUMMON_GROUP_GOLEMS);
+ events.ScheduleEvent(EVENT_LINK_GOLEM_HEALTH, 5s);
+ events.ScheduleEvent(EVENT_POWER_UP_FIRST_GOLEM, 10s);
+ }
+
+ void JustSummoned(Creature* summon) override
+ {
+
+ switch (summon->GetEntry())
+ {
+ case NPC_ELECTRON:
+ case NPC_MAGMATRON:
+ case NPC_TOXITRON:
+ case NPC_ARCANOTRON:
+ _golemGuidVector.push_back(summon->GetGUID());
+ break;
+ default:
+ summons.Summon(summon);
+ break;
+ }
+ }
+
+ ObjectGuid GetGUID(int32 type) const override
+ {
+ switch (type)
+ {
+ case DATA_NEXT_GOLEM_IN_QUEUE:
+ return _nextGolemGUID;
+ default:
+ return ObjectGuid::Empty;
+ }
+
+ return ObjectGuid::Empty;
+ }
+
+ void DoAction(int32 action) override
+ {
+ switch (action)
+ {
+ case ACTION_GOLEM_ACTIVATED:
+ if (instance->GetBossState(DATA_OMNOTRON_DEFENSE_SYSTEM) == IN_PROGRESS)
+ {
+ if (Creature* golem = ObjectAccessor::GetCreature(*me, _nextGolemGUID))
+ {
+ Talk(_golemInfoMap[golem->GetEntry()].ActivateTextId);
+ golem->CastSpell(golem, SPELL_ACTIVATED);
+ }
+
+ SelectNextGolemGUID();
+ DoCastAOE(SPELL_CONTROLLER_RECHARGE, true);
+ }
+ break;
+ case ACTION_START_ENCOUNTER:
+ instance->SetBossState(DATA_OMNOTRON_DEFENSE_SYSTEM, IN_PROGRESS);
+ // Since we blocked the first action call with our first golem we call it right away now to continue the cycle
+ DoAction(ACTION_GOLEM_ACTIVATED);
+ break;
+ case ACTION_STOP_ENCOUNTER:
+ for (uint8 i = DATA_ELECTRON; i < DATA_ELECTRON + 4; i++)
+ {
+ if (Creature* golem = instance->GetCreature(i))
+ {
+ instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, golem);
+ golem->DespawnOrUnsummon(100ms);
+ }
+ }
+
+ instance->SetBossState(DATA_OMNOTRON_DEFENSE_SYSTEM, FAIL);
+ _DespawnAtEvade();
+ break;
+ default:
+ break;
+ }
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ events.Update(diff);
+
+ while (uint32 eventId = events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_LINK_GOLEM_HEALTH:
+ for (ObjectGuid guid : _golemGuidVector)
+ if (Creature* golem = ObjectAccessor::GetCreature(*me, guid))
+ golem->CastSpell(golem, SPELL_SHARED_HEALTH, true);
+ break;
+ case EVENT_POWER_UP_FIRST_GOLEM:
+ // Randomize our golem order for each encounter
+ Trinity::Containers::RandomShuffle(_golemGuidVector);
+ SelectNextGolemGUID();
+ DoCastAOE(SPELL_CONTROLLER_RECHARGE);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+private:
+ GuidVector _golemGuidVector;
+ ObjectGuid _nextGolemGUID;
+
+ // Selects the ObjectGuid for the next Golem
+ void SelectNextGolemGUID()
+ {
+ _nextGolemGUID = _golemGuidVector.front();
+ _golemGuidVector.erase(_golemGuidVector.begin());
+ _golemGuidVector.push_back(_nextGolemGUID);
+ }
+};
+
+struct npc_omnotron_golem : public ScriptedAI
+{
+ npc_omnotron_golem(Creature* creature) : ScriptedAI(creature), _instance(me->GetInstanceScript())
+ {
+ Initialize();
+ }
+
+ void Initialize()
+ {
+ me->SetReactState(REACT_PASSIVE);
+ }
+
+ void JustEngagedWith(Unit* /*who*/) override
+ {
+ if (_instance->GetBossState(DATA_OMNOTRON_DEFENSE_SYSTEM) != IN_PROGRESS)
+ {
+ if (Creature* omnotron = _instance->GetCreature(DATA_OMNOTRON_DEFENSE_SYSTEM))
+ omnotron->AI()->DoAction(ACTION_START_ENCOUNTER);
+ }
+
+ _instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 1);
+ }
+
+ void EnterEvadeMode(EvadeReason /*why*/) override
+ {
+ _EnterEvadeMode();
+
+ if (Creature* omnotron = _instance->GetCreature(DATA_OMNOTRON_DEFENSE_SYSTEM))
+ omnotron->AI()->DoAction(ACTION_STOP_ENCOUNTER);
+ }
+
+ void MovementInform(uint32 type, uint32 pointId) override
+ {
+ if (type != POINT_MOTION_TYPE)
+ return;
+
+ if (pointId == POINT_START_WAYPOINTS)
+ {
+ me->GetMotionMaster()->MovePath(BOSS_OMNOTRON * 100, true);
+ me->SetWalk(true);
+ }
+ }
+
+ void DoAction(int32 action) override
+ {
+ switch (action)
+ {
+ case ACTION_ACTIVATE_GOLEM:
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ me->SetReactState(REACT_AGGRESSIVE);
+ me->RemoveAurasDueToSpell(SPELL_INACTIVE);
+ me->RemoveAurasDueToSpell(SPELL_POWERED_DOWN);
+
+ if (_instance->GetBossState(DATA_OMNOTRON_DEFENSE_SYSTEM) != IN_PROGRESS)
+ {
+ me->SetWalk(true);
+ me->GetMotionMaster()->MovePoint(POINT_START_WAYPOINTS, FirstGolemPatrolStartPoint);
+ }
+ else
+ DoZoneInCombat();
+
+ // Golem is online, time to inform the controller about it
+ if (Creature* omnotron = _instance->GetCreature(DATA_OMNOTRON_DEFENSE_SYSTEM))
+ omnotron->AI()->DoAction(ACTION_GOLEM_ACTIVATED);
+ break;
+ case ACTION_DEACTIVATE_GOLEM:
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ _events.Reset();
+ break;
+ default:
+ break;
+ }
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ UpdateVictim();
+
+ _events.Update(diff);
+
+ while (uint32 eventId = _events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case 0:
+ break;
+ default:
+ break;
+ }
+ }
+
+ DoMeleeAttackIfReady();
+ }
+
+private:
+ EventMap _events;
+ InstanceScript* _instance;
+};
+
+class GuidCheck
+{
+ public:
+ GuidCheck(ObjectGuid golemGUID) : _golemGUID(golemGUID) { }
+
+ bool operator()(WorldObject* object)
+ {
+ return object->GetGUID() != _golemGUID;
+ }
+ private:
+ ObjectGuid _golemGUID;
+};
+
+class spell_omnotron_controller_recharge : public SpellScript
+{
+ PrepareSpellScript(spell_omnotron_controller_recharge);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ return ValidateSpellInfo(
+ {
+ SPELL_RECHARGING_ELECTRON,
+ SPELL_RECHARGING_MAGMATRON,
+ SPELL_RECHARGING_TOXITRON,
+ SPELL_RECHARGING_ARCANOTRON
+ });
+ }
+
+ void FilterTargets(std::list& targets)
+ {
+ if (targets.empty())
+ return;
+
+ InstanceScript* instance = GetCaster()->GetInstanceScript();
+ if (!instance)
+ return;
+
+ Creature* omnotron = instance->GetCreature(DATA_OMNOTRON_DEFENSE_SYSTEM);
+ if (!omnotron)
+ return;
+
+ ObjectGuid golemGuid = omnotron->AI()->GetGUID(DATA_NEXT_GOLEM_IN_QUEUE);
+ targets.remove_if(GuidCheck(golemGuid));
+ }
+
+ void HandleScriptEffect(SpellEffIndex /*effIndex*/)
+ {
+ if (Unit* caster = GetCaster())
+ {
+ uint32 rechargingSpellId = 0;
+ switch (GetHitUnit()->GetEntry())
+ {
+ case NPC_ELECTRON:
+ rechargingSpellId = SPELL_RECHARGING_ELECTRON;
+ break;
+ case NPC_MAGMATRON:
+ rechargingSpellId = SPELL_RECHARGING_MAGMATRON;
+ break;
+ case NPC_TOXITRON:
+ rechargingSpellId = SPELL_RECHARGING_TOXITRON;
+ break;
+ case NPC_ARCANOTRON:
+ rechargingSpellId = SPELL_RECHARGING_ARCANOTRON;
+ break;
+ default:
+ break;
+ }
+
+ if (rechargingSpellId)
+ caster->CastSpell(caster, rechargingSpellId);
+ }
+ }
+
+ void Register() override
+ {
+ OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_omnotron_controller_recharge::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY);
+ OnEffectHitTarget += SpellEffectFn(spell_omnotron_controller_recharge::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
+ }
+};
+
+class spell_omnotron_recharging : public AuraScript
+{
+ PrepareAuraScript(spell_omnotron_recharging);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ return ValidateSpellInfo(
+ {
+ SPELL_INACTIVE,
+ SPELL_POWERED_DOWN
+ });
+ }
+
+ void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
+ {
+ if (Creature* golem = GetTarget()->ToCreature())
+ if (golem->IsAIEnabled)
+ golem->AI()->DoAction(ACTION_ACTIVATE_GOLEM);
+ }
+
+ void Register() override
+ {
+ AfterEffectRemove += AuraEffectRemoveFn(spell_omnotron_recharging::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_ENERGIZE, AURA_EFFECT_HANDLE_REAL);
+ }
+};
+
+class spell_omnotron_activated : public AuraScript
+{
+ PrepareAuraScript(spell_omnotron_activated);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ return ValidateSpellInfo({ SPELL_SHUTTING_DOWN });
+ }
+
+ void HandleTick(AuraEffect const* /*aurEff*/)
+ {
+ PreventDefaultAction();
+ if (Unit* caster = GetCaster())
+ if (caster->GetVictim())
+ if (caster->GetVictim())
+ caster->CastSpell(GetCaster()->GetVictim(), GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST));
+ }
+
+ void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
+ {
+ GetTarget()->CastSpell(GetTarget(), SPELL_SHUTTING_DOWN);
+ }
+
+ void Register() override
+ {
+ OnEffectPeriodic += AuraEffectPeriodicFn(spell_omnotron_activated::HandleTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
+ AfterEffectRemove += AuraEffectRemoveFn(spell_omnotron_activated::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
+ }
+};
+
+class spell_omnotron_inactive : public SpellScript
+{
+ PrepareSpellScript(spell_omnotron_inactive);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ return ValidateSpellInfo({ SPELL_RECHARGING_ELECTRON });
+ }
+
+ void HandleScriptEffect(SpellEffIndex /*effIndex*/)
+ {
+ Unit* target = GetHitUnit();
+ target->CastSpell(target, SPELL_POWERED_DOWN, true);
+ if (Creature* golem = target->ToCreature())
+ if (golem->IsAIEnabled)
+ golem->AI()->DoAction(ACTION_DEACTIVATE_GOLEM);
+ }
+
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_omnotron_inactive::HandleScriptEffect, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT);
+ }
+};
+
+void AddSC_boss_omnotron_defense_system()
+{
+ RegisterBlackwingDescentCreatureAI(boss_omnotron_defense_system);
+ RegisterBlackwingDescentCreatureAI(npc_omnotron_golem);
+ RegisterSpellScript(spell_omnotron_controller_recharge);
+ RegisterAuraScript(spell_omnotron_recharging);
+ RegisterAuraScript(spell_omnotron_activated);
+ RegisterSpellScript(spell_omnotron_inactive);
+}
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/instance_blackwing_descent.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/instance_blackwing_descent.cpp
index 7e95c9e7a4a..1c7c82c329e 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/instance_blackwing_descent.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/instance_blackwing_descent.cpp
@@ -23,9 +23,14 @@
ObjectData const creatureData[] =
{
- { BOSS_MAGMAW, DATA_MAGMAW },
- { NPC_NEFARIAN_MAGMAW, DATA_NEFARIAN_MAGMAW },
- { 0, 0 } // END
+ { BOSS_MAGMAW, DATA_MAGMAW },
+ { BOSS_OMNOTRON, DATA_OMNOTRON_DEFENSE_SYSTEM },
+ { NPC_ELECTRON, DATA_ELECTRON },
+ { NPC_MAGMATRON, DATA_MAGMATRON },
+ { NPC_TOXITRON, DATA_TOXITRON },
+ { NPC_ARCANOTRON, DATA_ARCANOTRON },
+ { NPC_NEFARIAN_MAGMAW, DATA_NEFARIAN_MAGMAW },
+ { 0, 0 } // END
};
ObjectData const gameobjectData[] =
diff --git a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp
index 5e85108f6ea..f66849e5e6e 100644
--- a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp
+++ b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp
@@ -75,6 +75,7 @@ void AddSC_boss_nefarian();
void AddSC_instance_blackwing_lair();
void AddSC_instance_blackwing_descent(); //Blackwing Descent
void AddSC_boss_magmaw();
+void AddSC_boss_omnotron_defense_system();
void AddSC_instance_deadmines(); //Deadmines
void AddSC_boss_glubtok();
void AddSC_boss_helix_gearbreaker();
@@ -300,6 +301,7 @@ void AddEasternKingdomsScripts()
AddSC_instance_blackwing_lair();
AddSC_instance_blackwing_descent(); //Blackwing Descent
AddSC_boss_magmaw();
+ AddSC_boss_omnotron_defense_system();
AddSC_instance_deadmines(); //Deadmines
AddSC_boss_glubtok();
AddSC_boss_helix_gearbreaker();