diff options
4 files changed, 280 insertions, 351 deletions
diff --git a/sql/updates/world/2014_09_03_00_world_creature_summon_groups.sql b/sql/updates/world/2014_09_03_00_world_creature_summon_groups.sql new file mode 100644 index 00000000000..aba5b88b1d4 --- /dev/null +++ b/sql/updates/world/2014_09_03_00_world_creature_summon_groups.sql @@ -0,0 +1,18 @@ +-- SWP: Move Muru summons to database
+SET @MURU := 25741;
+DELETE FROM `creature_summon_groups` WHERE `summonerId` = @MURU AND `entry` IN (25798, 25799, 25744);
+INSERT INTO `creature_summon_groups` (`summonerId`, `summonerType`, `groupId`, `entry`, `position_x`, `position_y`, `position_z`, `orientation`, `summonType`, `summonTime`) VALUES
+(@MURU, 0, 0, 25799, 1780.16, 666.83, 71.19, 5.21, 5, 0), -- Shadowsword Fury Mage
+(@MURU, 0, 0, 25799, 1847.93, 600.30, 71.30, 2.57, 5, 0),
+(@MURU, 0, 0, 25798, 1779.97, 660.64, 71.19, 5.28, 5, 0), -- Shadowsword Berserker
+(@MURU, 0, 0, 25798, 1786.20, 661.01, 71.19, 4.51, 5, 0),
+(@MURU, 0, 0, 25798, 1845.17, 602.63, 71.28, 2.43, 5, 0),
+(@MURU, 0, 0, 25798, 1842.91, 599.93, 71.23, 2.44, 5, 0),
+(@MURU, 0, 1, 25744, 1819.90, 609.80, 69.74, 1.94, 5, 0), -- Darkfiend
+(@MURU, 0, 1, 25744, 1829.39, 617.89, 69.73, 2.61, 5, 0),
+(@MURU, 0, 1, 25744, 1801.98, 633.62, 69.74, 5.71, 5, 0),
+(@MURU, 0, 1, 25744, 1830.88, 629.99, 69.73, 3.52, 5, 0),
+(@MURU, 0, 1, 25744, 1800.38, 621.41, 69.74, 0.22, 5, 0),
+(@MURU, 0, 1, 25744, 1808.30, 612.45, 69.73, 1.02, 5, 0),
+(@MURU, 0, 1, 25744, 1823.90, 639.69, 69.74, 4.12, 5, 0),
+(@MURU, 0, 1, 25744, 1811.85, 640.46, 69.73, 4.97, 5, 0);
diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp index 20d0364ab79..6e7425a75a3 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp @@ -355,6 +355,7 @@ void AuctionBotBuyer::AddNewAuctionBuyerBotBid(BuyerConfiguration& config) uint32 bidPrice; uint32 bidPriceByItem; uint32 minBidPrice; + uint32 minBuyPrice; if (auction->bid >= auction->startbid) { bidPrice = auction->GetAuctionOutBid(); @@ -373,6 +374,7 @@ void AuctionBotBuyer::AddNewAuctionBuyerBotBid(BuyerConfiguration& config) inGameBuyPrice = 0; inGameBidPrice = 0; minBidPrice = 0; + minBuyPrice = 0; } else { @@ -381,6 +383,7 @@ void AuctionBotBuyer::AddNewAuctionBuyerBotBid(BuyerConfiguration& config) inGameBuyPrice = sameItemItr->second.BuyPrice / sameItemItr->second.ItemCount; inGameBidPrice = sameItemItr->second.BidPrice / sameItemItr->second.ItemCount; minBidPrice = sameItemItr->second.MinBidPrice; + minBuyPrice = sameItemItr->second.MinBuyPrice; } uint32 maxBidablePrice = maxBuyablePrice - (maxBuyablePrice / 30); // Max Bidable price defined to 70% of max buyable price @@ -389,14 +392,14 @@ void AuctionBotBuyer::AddNewAuctionBuyerBotBid(BuyerConfiguration& config) TC_LOG_DEBUG("ahbot", "AHBot: MaxPrice of Entry %u is %.1fg.", itr->second.AuctionId, double(maxBuyablePrice) / 10000.0); TC_LOG_DEBUG("ahbot", "AHBot: GamePrice buy=%.1fg, bid=%.1fg.", inGameBuyPrice / 10000, inGameBidPrice / 10000); TC_LOG_DEBUG("ahbot", "AHBot: Minimal price see in AH Buy=%ug, Bid=%ug.", - sameItemItr->second.MinBuyPrice / 10000, minBidPrice / 10000); + minBuyPrice / 10000, minBidPrice / 10000); TC_LOG_DEBUG("ahbot", "AHBot: Actual Entry price, Buy=%ug, Bid=%ug.", buyoutPrice / 10000, bidPrice / 10000); if (!auction->owner) // Original auction owner maxChance = maxChance / 5; // if Owner is AHBot this mean player placed bid on this auction. We divide by 5 chance for AhBuyer to place bid on it. (This make more challenge than ignore entry) if (auction->buyout != 0) // Is the item directly buyable? { - if (IsBuyableEntry(buyoutPrice, inGameBuyPrice, maxBuyablePrice, sameItemItr->second.MinBuyPrice, maxChance, config.FactionChance)) + if (IsBuyableEntry(buyoutPrice, inGameBuyPrice, maxBuyablePrice, minBuyPrice, maxChance, config.FactionChance)) { if (IsBidableEntry(bidPriceByItem, inGameBuyPrice, maxBidablePrice, minBidPrice, maxChance / 2, config.FactionChance)) { diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index 6ccce62cb6f..ec0bae0f27f 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -74,71 +74,51 @@ enum Spells SPELL_BLACKHOLE_GROW = 46228 }; -enum BossTimers +enum Events { - TIMER_DARKNESS = 0, - TIMER_HUMANOIDES = 1, - TIMER_PHASE = 2, - TIMER_SENTINEL = 3 + // M'uru + EVENT_DARKNESS = 1, + EVENT_SUMMON_HUMANOIDS, + EVENT_SUMMON_SENTINEL, + EVENT_PHASE_TRANSITION, // Delayed phase transition. + EVENT_ENRAGE, + + // Entropius + EVENT_SUMMON_BLACK_HOLE }; -float DarkFiends[8][4] = +enum Phases { - {1819.9f, 609.80f, 69.74f, 1.94f}, - {1829.39f, 617.89f, 69.73f, 2.61f}, - {1801.98f, 633.62f, 69.74f, 5.71f}, - {1830.88f, 629.99f, 69.73f, 3.52f}, - {1800.38f, 621.41f, 69.74f, 0.22f}, - {1808.3f, 612.45f, 69.73f, 1.02f}, - {1823.9f, 639.69f, 69.74f, 4.12f}, - {1811.85f, 640.46f, 69.73f, 4.97f} + PHASE_ONE = 1, + PHASE_TWO, }; -float Humanoides[6][5] = +enum CreatureGroups { - {NPC_FURY_MAGE, 1780.16f, 666.83f, 71.19f, 5.21f}, - {NPC_FURY_MAGE, 1847.93f, 600.30f, 71.30f, 2.57f}, - {NPC_BERSERKER, 1779.97f, 660.64f, 71.19f, 5.28f}, - {NPC_BERSERKER, 1786.2f, 661.01f, 71.19f, 4.51f}, - {NPC_BERSERKER, 1845.17f, 602.63f, 71.28f, 2.43f}, - {NPC_BERSERKER, 1842.91f, 599.93f, 71.23f, 2.44f} + CREATURE_GROUP_HUMANOIDS, + CREATURE_GROUP_DARKFIENDS }; -uint32 EnrageTimer = 600000; - class boss_entropius : public CreatureScript { public: boss_entropius() : CreatureScript("boss_entropius") { } - struct boss_entropiusAI : public ScriptedAI + struct boss_entropiusAI : public BossAI { - boss_entropiusAI(Creature* creature) : ScriptedAI(creature), Summons(me) - { - instance = creature->GetInstanceScript(); - } - - InstanceScript* instance; - SummonList Summons; - - uint32 BlackHoleSummonTimer; + boss_entropiusAI(Creature* creature) : BossAI(creature, DATA_MURU) { } void Reset() override { - BlackHoleSummonTimer = 15000; - DoCastAOE(SPELL_NEGATIVE_ENERGY_E, false); - - Summons.DespawnAll(); - - instance->SetBossState(DATA_MURU, NOT_STARTED); + DoCastAOE(SPELL_NEGATIVE_ENERGY_E); } void EnterCombat(Unit* /*who*/) override { + _EnterCombat(); DoCastAOE(SPELL_NEGATIVE_ENERGY_E, true); - DoCast(me, SPELL_ENTROPIUS_SPAWN, false); - - instance->SetBossState(DATA_MURU, IN_PROGRESS); + DoCast(me, SPELL_ENTROPIUS_SPAWN); + events.ScheduleEvent(EVENT_SUMMON_BLACK_HOLE, 15000); } void JustSummoned(Creature* summoned) override @@ -146,7 +126,7 @@ public: switch (summoned->GetEntry()) { case NPC_DARK_FIENDS: - summoned->CastSpell(summoned, SPELL_DARKFIEND_VISUAL, false); + summoned->CastSpell(summoned, SPELL_DARKFIEND_VISUAL); break; case NPC_DARKNESS: summoned->AddUnitState(UNIT_STATE_STUNNED); @@ -156,42 +136,27 @@ public: break; } summoned->AI()->AttackStart(SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true)); - Summons.Summon(summoned); + summons.Summon(summoned); } - void JustDied(Unit* /*killer*/) override + void ExecuteEvent(uint32 eventId) override { - Summons.DespawnAll(); - instance->SetBossState(DATA_MURU, DONE); + if (eventId == EVENT_SUMMON_BLACK_HOLE) + { + if (Unit* random = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) + DoCast(random, SPELL_DARKNESS_E); + if (Unit* random = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) + random->CastSpell(random, SPELL_BLACKHOLE); + events.ScheduleEvent(EVENT_SUMMON_BLACK_HOLE, 15000); + } } - void UpdateAI(uint32 diff) override + void EnterEvadeMode() override { - if (!UpdateVictim()) - return; - - if (EnrageTimer < diff && !me->HasAura(SPELL_ENRAGE, 0)) - { - DoCast(me, SPELL_ENRAGE, false); - } else EnrageTimer -= diff; - - if (BlackHoleSummonTimer <= diff) - { - Unit* random = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true); - if (!random) - return; - - DoCast(random, SPELL_DARKNESS_E, false); - - random = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true); - if (!random) - return; - - random->CastSpell(random, SPELL_BLACKHOLE, false); - BlackHoleSummonTimer = 15000; - } else BlackHoleSummonTimer -= diff; - - DoMeleeAttackIfReady(); + if (Creature* muru = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_MURU))) + muru->AI()->Reset(); // Reset encounter. + me->DisappearAndDie(); + summons.DespawnAll(); } }; @@ -206,58 +171,51 @@ class boss_muru : public CreatureScript public: boss_muru() : CreatureScript("boss_muru") { } - struct boss_muruAI : public ScriptedAI + struct boss_muruAI : public BossAI { - boss_muruAI(Creature* creature) : ScriptedAI(creature), Summons(creature) + boss_muruAI(Creature* creature) : BossAI(creature, DATA_MURU) { + Initialize(); SetCombatMovement(false); - instance = creature->GetInstanceScript(); } - InstanceScript* instance; - SummonList Summons; - - uint8 Phase; - uint32 Timer[4]; - - bool DarkFiend; - - void Reset() override + void Initialize() { DarkFiend = false; - Phase = 1; - - EnrageTimer = 600000; - Timer[TIMER_DARKNESS] = 45000; - Timer[TIMER_HUMANOIDES] = 10000; - Timer[TIMER_PHASE] = 2000; - Timer[TIMER_SENTINEL] = 31500; + HasEnraged = false; + EntropiusGUID = 0; + } + void Reset() override + { + Initialize(); + _Reset(); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetVisible(true); - - Summons.DespawnAll(); - instance->SetBossState(DATA_MURU, NOT_STARTED); } void EnterCombat(Unit* /*who*/) override { - DoCastAOE(SPELL_NEGATIVE_ENERGY, false); - instance->SetBossState(DATA_MURU, IN_PROGRESS); + _EnterCombat(); + events.SetPhase(PHASE_ONE); + events.ScheduleEvent(EVENT_ENRAGE, 600000); + events.ScheduleEvent(EVENT_DARKNESS, 45000, 0, PHASE_ONE); + events.ScheduleEvent(EVENT_SUMMON_HUMANOIDS, 10000, 0, PHASE_ONE); + events.ScheduleEvent(EVENT_SUMMON_SENTINEL, 31500, 0, PHASE_ONE); + DoCastAOE(SPELL_NEGATIVE_ENERGY); } void DamageTaken(Unit* /*done_by*/, uint32 &damage) override { - if (damage > me->GetHealth() && Phase == 1) + if (damage > me->GetHealth() && events.IsInPhase(PHASE_ONE)) { damage = 0; - Phase = 2; me->RemoveAllAuras(); - DoCast(me, SPELL_OPEN_ALL_PORTALS, false); + DoCast(me, SPELL_OPEN_ALL_PORTALS); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + events.SetPhase(PHASE_TWO); + events.ScheduleEvent(EVENT_PHASE_TRANSITION, 2000); } - if (Phase > 1 && Phase < 4) - damage = 0; } void JustSummoned(Creature* summoned) override @@ -266,96 +224,61 @@ public: { case NPC_ENTROPIUS: me->SetVisible(false); + EntropiusGUID = summoned->GetGUID(); + if (HasEnraged) // If we hit phase transition while enraged, enrage Entropius as well. + summoned->CastSpell(summoned, SPELL_ENRAGE); break; case NPC_DARK_FIENDS: - summoned->CastSpell(summoned, SPELL_DARKFIEND_VISUAL, false); + summoned->CastSpell(summoned, SPELL_DARKFIEND_VISUAL); break; } summoned->AI()->AttackStart(SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true)); - Summons.Summon(summoned); + summons.Summon(summoned); } - void UpdateAI(uint32 diff) override + void ExecuteEvent(uint32 eventId) override { - if (!UpdateVictim()) - return; - - if (Phase == 3) + switch (eventId) { - if (Timer[TIMER_PHASE] <= diff) - { - switch (instance->GetBossState(DATA_MURU)) + case EVENT_DARKNESS: + if (!DarkFiend) { - case NOT_STARTED: - Reset(); - break; - case DONE: - Phase = 4; - me->DisappearAndDie(); - break; - default: - break; + DarkFiend = true; + DoCastAOE(SPELL_DARKNESS); } - Timer[TIMER_PHASE] = 3000; - } else Timer[TIMER_PHASE] -= diff; - return; - } - - if (EnrageTimer < diff && !me->HasAura(SPELL_ENRAGE, 0)) - { - DoCast(me, SPELL_ENRAGE, false); - } else EnrageTimer -= diff; - - for (uint8 i = 0; i < 4; ++i) - { - if (Timer[i] <= diff) - { - switch (i) + else { - case TIMER_DARKNESS: - if (!DarkFiend) - { - DoCastAOE(SPELL_DARKNESS, false); - Timer[TIMER_DARKNESS] = 3000; - DarkFiend = true; - } - else - { - DarkFiend = false; - for (uint8 j = 0; j < 8; ++j) - me->SummonCreature(NPC_DARK_FIENDS, DarkFiends[j][0], DarkFiends[j][1], DarkFiends[j][2], DarkFiends[j][3], TEMPSUMMON_CORPSE_DESPAWN, 0); - Timer[TIMER_DARKNESS] = 42000; - } - break; - case TIMER_HUMANOIDES: - for (uint8 j = 0; j < 6; ++j) - me->SummonCreature(uint32(Humanoides[j][0]), Humanoides[j][1], Humanoides[j][2], Humanoides[j][3], Humanoides[j][4], TEMPSUMMON_CORPSE_DESPAWN, 0); - Timer[TIMER_HUMANOIDES] = 60000; - break; - case TIMER_PHASE: - me->RemoveAllAuras(); - DoCast(me, SPELL_SUMMON_ENTROPIUS, false); - Timer[TIMER_PHASE] = 3000; - Phase = 3; - return; - case TIMER_SENTINEL: - DoCastAOE(SPELL_OPEN_PORTAL_2, false); - Timer[TIMER_SENTINEL] = 30000; - break; + DarkFiend = false; + me->SummonCreatureGroup(CREATURE_GROUP_DARKFIENDS); } + events.ScheduleEvent(EVENT_DARKNESS, DarkFiend ? 3000 : 42000, 0, PHASE_ONE); + break; + case EVENT_SUMMON_HUMANOIDS: + me->SummonCreatureGroup(CREATURE_GROUP_DARKFIENDS); + events.ScheduleEvent(EVENT_SUMMON_HUMANOIDS, 60000, 0, PHASE_ONE); + break; + case EVENT_SUMMON_SENTINEL: + DoCastAOE(SPELL_OPEN_PORTAL_2); + events.ScheduleEvent(EVENT_SUMMON_SENTINEL, 30000, 0, PHASE_ONE); + break; + case EVENT_PHASE_TRANSITION: + DoCast(me, SPELL_SUMMON_ENTROPIUS); + break; + case EVENT_ENRAGE: + if (Creature* entropius = ObjectAccessor::GetCreature(*me, EntropiusGUID)) + entropius->CastSpell(entropius, SPELL_ENRAGE); + DoCast(me, SPELL_ENRAGE); + HasEnraged = true; + break; + default: break; - } - } - - // Timer - for (uint8 i = 0; i < 4; ++i) - { - if (i != TIMER_PHASE) - Timer[i] -= diff; - else if (Phase == 2) - Timer[i] -= diff; } } + + private: + bool DarkFiend; + bool HasEnraged; + uint64 EntropiusGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -405,8 +328,8 @@ public: void JustSummoned(Creature* summoned) override { - if (Player* Target = ObjectAccessor::GetPlayer(*me, instance->GetData64(DATA_PLAYER_GUID))) - summoned->AI()->AttackStart(Target); + if (Player* target = ObjectAccessor::GetPlayer(*me, instance->GetData64(DATA_PLAYER_GUID))) + summoned->AI()->AttackStart(target); Summons.Summon(summoned); } @@ -415,15 +338,15 @@ public: { float x, y, z, o; me->GetHomePosition(x, y, z, o); - DoTeleportTo(x, y, z); + me->NearTeleportTo(x, y, z, o); InAction = true; switch (Spell->Id) { case SPELL_OPEN_ALL_PORTALS: - DoCastAOE(SPELL_OPEN_PORTAL, false); + DoCastAOE(SPELL_OPEN_PORTAL); break; case SPELL_OPEN_PORTAL_2: - DoCastAOE(SPELL_OPEN_PORTAL, false); + DoCastAOE(SPELL_OPEN_PORTAL); SummonSentinel = true; break; } @@ -533,13 +456,14 @@ public: float x, y, z, o; me->GetHomePosition(x, y, z, o); - DoTeleportTo(x, y, 71); + me->NearTeleportTo(x, y, 71, o); } - void JustDied(Unit* /*killer*/) override + void JustDied(Unit* killer) override { for (uint8 i = 0; i < 8; ++i) - me->SummonCreature(NPC_VOID_SPAWN, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), float(rand32() % 6), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 180000); + if (Creature* temp = me->SummonCreature(NPC_VOID_SPAWN, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), float(rand32() % 6), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 180000)) + temp->AI()->AttackStart(killer); } void UpdateAI(uint32 diff) override diff --git a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp index 3415451fef5..6c3e820e10f 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -19,7 +18,7 @@ /* ScriptData SDName: Boss_Mother_Shahraz SD%Complete: 80 -SDComment: Saber Lash missing, Fatal Attraction slightly incorrect; need to damage only if affected players are within range of each other +SDComment: Fatal Attraction slightly incorrect; need to damage only if affected players are within range of each other SDCategory: Black Temple EndScriptData */ @@ -27,17 +26,19 @@ EndScriptData */ #include "ScriptedCreature.h" #include "black_temple.h" -enum MotherShahraz +enum Texts { //Speech'n'Sounds - SAY_TAUNT = 0, - SAY_AGGRO = 1, - SAY_SPELL = 2, - SAY_SLAY = 3, - SAY_ENRAGE = 4, - SAY_DEATH = 5, + SAY_TAUNT = 0, + SAY_AGGRO = 1, + SAY_SPELL = 2, + SAY_SLAY = 3, + SAY_ENRAGE = 4, + SAY_DEATH = 5 +}; - //Spells +enum Spells +{ SPELL_BEAM_SINISTER = 40859, SPELL_BEAM_VILE = 40860, SPELL_BEAM_WICKED = 40861, @@ -51,6 +52,26 @@ enum MotherShahraz SPELL_BERSERK = 45078 }; +enum Events +{ + EVENT_RANDOM_BEAM = 1, + EVENT_PRISMATIC_SHIELD, + EVENT_FATAL_ATTRACTION, + EVENT_FATAL_ATTRACTION_EXPLOSION, + EVENT_SABER_SLASH, + EVENT_SILENCING_SHRIEK, + EVENT_RANDOM_TAUNT, + EVENT_BERSERK +}; + +enum Beams +{ + SINISTER_BEAM, + VILE_BEAM, + WICKED_BEAM, + SINFUL_BEAM +}; + uint32 PrismaticAuras[]= { 40880, // Shadow @@ -82,62 +103,41 @@ class boss_mother_shahraz : public CreatureScript public: boss_mother_shahraz() : CreatureScript("boss_mother_shahraz") { } - CreatureAI* GetAI(Creature* creature) const override + struct boss_shahrazAI : public BossAI { - return GetInstanceAI<boss_shahrazAI>(creature); - } - - struct boss_shahrazAI : public ScriptedAI - { - boss_shahrazAI(Creature* creature) : ScriptedAI(creature) + boss_shahrazAI(Creature* creature) : BossAI(creature, DATA_MOTHER_SHAHRAZ) { - instance = creature->GetInstanceScript(); + Initialize(); } - InstanceScript* instance; - - uint64 TargetGUID[3]; - uint32 BeamTimer; - uint32 BeamCount; - uint32 CurrentBeam; - uint32 PrismaticShieldTimer; - uint32 FatalAttractionTimer; - uint32 FatalAttractionExplodeTimer; - uint32 ShriekTimer; - uint32 SaberTimer; - uint32 RandomYellTimer; - uint32 EnrageTimer; - uint32 ExplosionCount; - - bool Enraged; - - void Reset() override + void Initialize() { - instance->SetBossState(DATA_MOTHER_SHAHRAZ, NOT_STARTED); - for (uint8 i = 0; i<3; ++i) TargetGUID[i] = 0; - BeamTimer = 20000; // Timers may be incorrect BeamCount = 0; - CurrentBeam = 0; // 0 - Sinister, 1 - Vile, 2 - Wicked, 3 - Sinful - PrismaticShieldTimer = 0; - FatalAttractionTimer = 60000; - FatalAttractionExplodeTimer = 70000; - ShriekTimer = 30000; - SaberTimer = 35000; - RandomYellTimer = urand(70, 111) * 1000; - EnrageTimer = 600000; + CurrentBeam = SINISTER_BEAM; // 0 - Sinister, 1 - Vile, 2 - Wicked, 3 - Sinful ExplosionCount = 0; - Enraged = false; } - void EnterCombat(Unit* /*who*/) override + void Reset() override { - instance->SetBossState(DATA_MOTHER_SHAHRAZ, IN_PROGRESS); + Initialize(); + _Reset(); + } - DoZoneInCombat(); + void EnterCombat(Unit* /*who*/) override + { + _EnterCombat(); + events.ScheduleEvent(EVENT_RANDOM_BEAM, 20000); // Timers may be incorrect + events.ScheduleEvent(EVENT_FATAL_ATTRACTION, 60000); + events.ScheduleEvent(EVENT_FATAL_ATTRACTION_EXPLOSION, 70000); + events.ScheduleEvent(EVENT_SILENCING_SHRIEK, 30000); + events.ScheduleEvent(EVENT_SABER_SLASH, 35000); + events.ScheduleEvent(EVENT_RANDOM_TAUNT, urand(70000, 111000)); + events.ScheduleEvent(EVENT_PRISMATIC_SHIELD, 1000); + events.ScheduleEvent(EVENT_BERSERK, 600000); Talk(SAY_AGGRO); } @@ -148,152 +148,136 @@ public: void JustDied(Unit* /*killer*/) override { - instance->SetBossState(DATA_MOTHER_SHAHRAZ, DONE); - + _JustDied(); Talk(SAY_DEATH); } void TeleportPlayers() { - uint32 random = rand32() % 7; + uint32 random = urand(0, 7); float X = TeleportPoint[random].x; float Y = TeleportPoint[random].y; float Z = TeleportPoint[random].z; for (uint8 i = 0; i < 3; ++i) { - Unit* unit = SelectTarget(SELECT_TARGET_RANDOM, 1); - if (unit && unit->IsAlive() && (unit->GetTypeId() == TYPEID_PLAYER)) - { - TargetGUID[i] = unit->GetGUID(); - unit->CastSpell(unit, SPELL_TELEPORT_VISUAL, true); - DoTeleportPlayer(unit, X, Y, Z, unit->GetOrientation()); - } + if (Unit* unit = SelectTarget(SELECT_TARGET_RANDOM, 1)) + if (unit->IsAlive() && unit->GetTypeId() == TYPEID_PLAYER) + { + TargetGUID[i] = unit->GetGUID(); + unit->CastSpell(unit, SPELL_TELEPORT_VISUAL, true); + DoTeleportPlayer(unit, X, Y, Z, unit->GetOrientation()); + } } } - void UpdateAI(uint32 diff) override + void DamageTaken(Unit* /*attacker*/, uint32 &damage) override { - if (!UpdateVictim()) - return; - - if (HealthBelowPct(10) && !Enraged) + if (!Enraged && me->HealthBelowPctDamaged(10, damage)) { Enraged = true; DoCast(me, SPELL_ENRAGE, true); Talk(SAY_ENRAGE); } + } - //Randomly cast one beam. - if (BeamTimer <= diff) - { - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0); - if (!target || !target->IsAlive()) - return; - - BeamTimer = 9000; - - switch (CurrentBeam) - { - case 0: - DoCast(target, SPELL_BEAM_SINISTER); - break; - case 1: - DoCast(target, SPELL_BEAM_VILE); - break; - case 2: - DoCast(target, SPELL_BEAM_WICKED); - break; - case 3: - DoCast(target, SPELL_BEAM_SINFUL); - break; - } - ++BeamCount; - uint32 Beam = CurrentBeam; - if (BeamCount > 3) - while (CurrentBeam == Beam) - CurrentBeam = rand32() % 3; - - } else BeamTimer -= diff; - - // Random Prismatic Shield every 15 seconds. - if (PrismaticShieldTimer <= diff) - { - uint32 random = rand32() % 6; - if (PrismaticAuras[random]) - DoCast(me, PrismaticAuras[random]); - PrismaticShieldTimer = 15000; - } else PrismaticShieldTimer -= diff; - - // Select 3 random targets (can select same target more than once), teleport to a random location then make them cast explosions until they get away from each other. - if (FatalAttractionTimer <= diff) - { - ExplosionCount = 0; - - TeleportPlayers(); - - Talk(SAY_SPELL); - FatalAttractionExplodeTimer = 2000; - FatalAttractionTimer = urand(40, 71) * 1000; - } else FatalAttractionTimer -= diff; - - if (FatalAttractionExplodeTimer <= diff) + void ExecuteEvent(uint32 eventId) override + { + switch (eventId) { - // Just make them explode three times... they're supposed to keep exploding while they are in range, but it'll take too much code. I'll try to think of an efficient way for it later. - if (ExplosionCount < 3) - { - for (uint8 i = 0; i < 3; ++i) + case EVENT_RANDOM_BEAM: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) { - if (TargetGUID[i]) + switch (CurrentBeam) { - if (Unit* unit = ObjectAccessor::GetUnit(*me, TargetGUID[i])) - unit->CastSpell(unit, SPELL_ATTRACTION, true); - TargetGUID[i] = 0; + case SINISTER_BEAM: + DoCast(target, SPELL_BEAM_SINISTER); + break; + case VILE_BEAM: + DoCast(target, SPELL_BEAM_VILE); + break; + case WICKED_BEAM: + DoCast(target, SPELL_BEAM_WICKED); + break; + case SINFUL_BEAM: + DoCast(target, SPELL_BEAM_SINFUL); + break; + default: + break; } + + ++BeamCount; + uint32 Beam = CurrentBeam; + if (BeamCount > 3) + while (CurrentBeam == Beam) + CurrentBeam = urand(0, 3); } - - ++ExplosionCount; - FatalAttractionExplodeTimer = 1000; - } - else - { - FatalAttractionExplodeTimer = FatalAttractionTimer + 2000; + events.ScheduleEvent(EVENT_RANDOM_BEAM, 9000); + break; + case EVENT_PRISMATIC_SHIELD: + // Random Prismatic Shield every 15 seconds. + DoCast(me, PrismaticAuras[urand(0, 6)]); + events.ScheduleEvent(EVENT_PRISMATIC_SHIELD, 15000); + break; + case EVENT_FATAL_ATTRACTION: + // Select 3 random targets (can select same target more than once), teleport to a random location then make them cast explosions until they get away from each other. ExplosionCount = 0; - } - } else FatalAttractionExplodeTimer -= diff; - - if (ShriekTimer <= diff) - { - DoCastVictim(SPELL_SILENCING_SHRIEK); - ShriekTimer = 25000 + rand32() % 10 * 1000; - } else ShriekTimer -= diff; - - if (SaberTimer <= diff) - { - DoCastVictim(SPELL_SABER_LASH); - SaberTimer = 25000 + rand32() % 10 * 1000; - } else SaberTimer -= diff; - - //Enrage - if (!me->HasAura(SPELL_BERSERK)) - { - if (EnrageTimer <= diff) - { + TeleportPlayers(); + Talk(SAY_SPELL); + events.ScheduleEvent(EVENT_FATAL_ATTRACTION_EXPLOSION, 2000); + events.ScheduleEvent(EVENT_FATAL_ATTRACTION, 40000, 71000); + break; + case EVENT_FATAL_ATTRACTION_EXPLOSION: + // Just make them explode three times... they're supposed to keep exploding while they are in range, but it'll take too much code. I'll try to think of an efficient way for it later. + if (ExplosionCount < 3) + { + for (uint8 i = 0; i < 3; ++i) + { + if (TargetGUID[i]) + { + if (Unit* unit = ObjectAccessor::GetUnit(*me, TargetGUID[i])) + unit->CastSpell(unit, SPELL_ATTRACTION, true); + TargetGUID[i] = 0; + } + } + ++ExplosionCount; + } + else + ExplosionCount = 0; + events.ScheduleEvent(EVENT_FATAL_ATTRACTION_EXPLOSION, ExplosionCount < 3 ? 1000 : events.GetTimeUntilEvent(EVENT_FATAL_ATTRACTION) + 2000); + break; + case EVENT_SILENCING_SHRIEK: + DoCastVictim(SPELL_SILENCING_SHRIEK); + events.ScheduleEvent(EVENT_SILENCING_SHRIEK, urand(25000, 35000)); + break; + case EVENT_SABER_SLASH: + DoCastVictim(SPELL_SABER_LASH); + events.ScheduleEvent(EVENT_SABER_SLASH, urand(25000, 35000)); + break; + case EVENT_RANDOM_TAUNT: + Talk(SAY_TAUNT); + events.ScheduleEvent(EVENT_RANDOM_TAUNT, urand(60000, 151000)); + break; + case EVENT_BERSERK: DoCast(me, SPELL_BERSERK); Talk(SAY_ENRAGE); - } else EnrageTimer -= diff; + break; + default: + break; } - - //Random taunts - if (RandomYellTimer <= diff) - { - Talk(SAY_TAUNT); - RandomYellTimer = urand(60, 151) * 1000; - } else RandomYellTimer -= diff; - - DoMeleeAttackIfReady(); } + + private: + uint64 TargetGUID[3]; + uint32 BeamCount; + uint32 CurrentBeam; + uint32 ExplosionCount; + bool Enraged; }; + CreatureAI* GetAI(Creature* creature) const override + { + return GetBlackTempleAI<boss_shahrazAI>(creature); + } }; void AddSC_boss_mother_shahraz() |