diff options
Diffstat (limited to 'src')
5 files changed, 378 insertions, 614 deletions
diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp index 432aa99af99..82b334de512 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp @@ -178,15 +178,15 @@ class instance_ahnkahet : public InstanceMapScript return 0; } - void SetData64(uint32 type, uint64 guid) OVERRIDE + void SetData64(uint32 type, uint64 data) OVERRIDE { switch (type) { case DATA_ADD_JEDOGA_OPFER: - JedogaSacrifices = guid; + JedogaSacrifices = data; break; case DATA_PL_JEDOGA_TARGET: - JedogaTarget = guid; + JedogaTarget = data; break; default: break; diff --git a/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp b/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp index 31f854803bc..0ae86f7c455 100644 --- a/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp +++ b/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp @@ -43,215 +43,217 @@ enum Spells { SPELL_GROWTH = 36300, SPELL_CAVE_IN = 36240, - SPELL_GROUND_SLAM = 33525, //AoE Ground Slam applying Ground Slam to everyone with a script effect (most likely the knock back, we can code it to a set knockback) + SPELL_GROUND_SLAM = 33525, // AoE Ground Slam applying Ground Slam to everyone with a script effect (most likely the knock back, we can code it to a set knockback) SPELL_REVERBERATION = 36297, SPELL_SHATTER = 33654, SPELL_SHATTER_EFFECT = 33671, SPELL_HURTFUL_STRIKE = 33813, - SPELL_STONED = 33652, //Spell is self cast by target + SPELL_STONED = 33652, // Spell is self cast by target SPELL_MAGNETIC_PULL = 28337, - SPELL_KNOCK_BACK = 24199, //Knockback spell until correct implementation is made + SPELL_KNOCK_BACK = 24199, // Knockback spell until correct implementation is made }; -class boss_gruul : public CreatureScript +enum Events { -public: - boss_gruul() : CreatureScript("boss_gruul") { } + EVENT_GROWTH = 1, + EVENT_CAVE_IN, + EVENT_CAVE_IN_STATIC, + EVENT_GROUND_SLAM, + EVENT_HURTFUL_STRIKE, + EVENT_REVERBERATION +}; - CreatureAI* GetAI(Creature* creature) const OVERRIDE - { - return new boss_gruulAI(creature); - } +class boss_gruul : public CreatureScript +{ + public: + boss_gruul() : CreatureScript("boss_gruul") { } - struct boss_gruulAI : public ScriptedAI - { - boss_gruulAI(Creature* creature) : ScriptedAI(creature) + struct boss_gruulAI : public BossAI { - instance = creature->GetInstanceScript(); - } - - InstanceScript* instance; - - uint32 m_uiGrowth_Timer; - uint32 m_uiCaveIn_Timer; - uint32 m_uiCaveIn_StaticTimer; - uint32 m_uiGroundSlamTimer; - uint32 m_uiHurtfulStrike_Timer; - uint32 m_uiReverberation_Timer; + boss_gruulAI(Creature* creature) : BossAI(creature, DATA_GRUUL) { } - bool m_bPerformingGroundSlam; + uint32 m_uiGrowth_Timer; + uint32 m_uiCaveIn_Timer; + uint32 m_uiCaveIn_StaticTimer; + uint32 m_uiGroundSlamTimer; + uint32 m_uiHurtfulStrike_Timer; + uint32 m_uiReverberation_Timer; - void Reset() OVERRIDE - { - m_uiGrowth_Timer= 30000; - m_uiCaveIn_Timer= 27000; - m_uiCaveIn_StaticTimer = 30000; - m_uiGroundSlamTimer= 35000; - m_bPerformingGroundSlam= false; - m_uiHurtfulStrike_Timer= 8000; - m_uiReverberation_Timer= 60000+45000; - - if (instance) - instance->SetData(DATA_GRUULEVENT, NOT_STARTED); - } + bool m_bPerformingGroundSlam; - void EnterCombat(Unit* /*who*/) OVERRIDE - { - Talk(SAY_AGGRO); - - if (instance) - instance->SetData(DATA_GRUULEVENT, IN_PROGRESS); - } + void Reset() OVERRIDE + { + _Reset(); + m_uiGrowth_Timer= 30000; + m_uiCaveIn_Timer= 27000; + m_uiCaveIn_StaticTimer = 30000; + m_uiGroundSlamTimer= 35000; + m_bPerformingGroundSlam= false; + m_uiHurtfulStrike_Timer= 8000; + m_uiReverberation_Timer= 60000+45000; + } - void KilledUnit(Unit* /*victim*/) OVERRIDE - { - Talk(SAY_SLAY); - } + void EnterCombat(Unit* /*who*/) OVERRIDE + { + _EnterCombat(); + Talk(SAY_AGGRO); + } - void JustDied(Unit* /*killer*/) OVERRIDE - { - Talk(SAY_DEATH); + void KilledUnit(Unit* who) OVERRIDE + { + if (who->GetTypeId() == TYPEID_PLAYER) + Talk(SAY_SLAY); + } - if (instance) + void JustDied(Unit* /*killer*/) OVERRIDE { - instance->SetData(DATA_GRUULEVENT, DONE); - instance->HandleGameObject(instance->GetData64(DATA_GRUULDOOR), true); // Open the encounter door + _JustDied(); + Talk(SAY_DEATH); } - } - void SpellHitTarget(Unit* target, const SpellInfo* pSpell) OVERRIDE - { - //This to emulate effect1 (77) of SPELL_GROUND_SLAM, knock back to any direction - //It's initially wrong, since this will cause fall damage, which is by comments, not intended. - if (pSpell->Id == SPELL_GROUND_SLAM) + void SpellHitTarget(Unit* target, const SpellInfo* pSpell) OVERRIDE { - if (target->GetTypeId() == TYPEID_PLAYER) + //This to emulate effect1 (77) of SPELL_GROUND_SLAM, knock back to any direction + //It's initially wrong, since this will cause fall damage, which is by comments, not intended. + if (pSpell->Id == SPELL_GROUND_SLAM) { - switch (urand(0, 1)) + if (target->GetTypeId() == TYPEID_PLAYER) { - case 0: - target->CastSpell(target, SPELL_MAGNETIC_PULL, true, NULL, NULL, me->GetGUID()); - break; - - case 1: - target->CastSpell(target, SPELL_KNOCK_BACK, true, NULL, NULL, me->GetGUID()); - break; + switch (urand(0, 1)) + { + case 0: + target->CastSpell(target, SPELL_MAGNETIC_PULL, true, NULL, NULL, me->GetGUID()); + break; + + case 1: + target->CastSpell(target, SPELL_KNOCK_BACK, true, NULL, NULL, me->GetGUID()); + break; + } } } - } - //this part should be in the core - if (pSpell->Id == SPELL_SHATTER) - { - /// @todo use eventmap to kill this stuff - //clear this, if we are still performing - if (m_bPerformingGroundSlam) + //this part should be in the core + if (pSpell->Id == SPELL_SHATTER) { - m_bPerformingGroundSlam = false; - - //and correct movement, if not already - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) + /// @todo use eventmap to kill this stuff + //clear this, if we are still performing + if (m_bPerformingGroundSlam) { - if (me->GetVictim()) - me->GetMotionMaster()->MoveChase(me->GetVictim()); + m_bPerformingGroundSlam = false; + + //and correct movement, if not already + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) + { + if (me->GetVictim()) + me->GetMotionMaster()->MoveChase(me->GetVictim()); + } } } } - } - - void UpdateAI(uint32 uiDiff) OVERRIDE - { - //Return since we have no target - if (!UpdateVictim()) - return; - // Growth - // Gruul can cast this spell up to 30 times - if (m_uiGrowth_Timer <= uiDiff) + void UpdateAI(uint32 diff) OVERRIDE { - Talk(EMOTE_GROW); - DoCast(me, SPELL_GROWTH); - m_uiGrowth_Timer = 30000; - } - else - m_uiGrowth_Timer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_bPerformingGroundSlam) - { - if (m_uiGroundSlamTimer <= uiDiff) - { - m_uiGroundSlamTimer =120000; - m_uiHurtfulStrike_Timer= 8000; + events.Update(diff); + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiReverberation_Timer < 10000) //Give a little time to the players to undo the damage from shatter - m_uiReverberation_Timer += 10000; + /// @todo: convert this shit to eventmap - DoCast(me, SPELL_SHATTER); + // Growth + // Gruul can cast this spell up to 30 times + if (m_uiGrowth_Timer <= diff) + { + Talk(EMOTE_GROW); + DoCast(me, SPELL_GROWTH); + m_uiGrowth_Timer = 30000; } else - m_uiGroundSlamTimer -= uiDiff; - } - else - { - // Hurtful Strike - if (m_uiHurtfulStrike_Timer <= uiDiff) + m_uiGrowth_Timer -= diff; + + if (m_bPerformingGroundSlam) { - Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); + if (m_uiGroundSlamTimer <= diff) + { + m_uiGroundSlamTimer =120000; + m_uiHurtfulStrike_Timer= 8000; - if (target && me->IsWithinMeleeRange(me->GetVictim())) - DoCast(target, SPELL_HURTFUL_STRIKE); - else - DoCastVictim(SPELL_HURTFUL_STRIKE); + if (m_uiReverberation_Timer < 10000) //Give a little time to the players to undo the damage from shatter + m_uiReverberation_Timer += 10000; - m_uiHurtfulStrike_Timer= 8000; + DoCast(me, SPELL_SHATTER); + } + else + m_uiGroundSlamTimer -= diff; } else - m_uiHurtfulStrike_Timer -= uiDiff; - - // Reverberation - if (m_uiReverberation_Timer <= uiDiff) { - DoCastVictim(SPELL_REVERBERATION, true); - m_uiReverberation_Timer = urand(15000, 25000); - } - else - m_uiReverberation_Timer -= uiDiff; + // Hurtful Strike + if (m_uiHurtfulStrike_Timer <= diff) + { + Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); - // Cave In - if (m_uiCaveIn_Timer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_CAVE_IN); + if (target && me->IsWithinMeleeRange(me->GetVictim())) + DoCast(target, SPELL_HURTFUL_STRIKE); + else + DoCastVictim(SPELL_HURTFUL_STRIKE); - if (m_uiCaveIn_StaticTimer >= 4000) - m_uiCaveIn_StaticTimer -= 2000; + m_uiHurtfulStrike_Timer= 8000; + } + else + m_uiHurtfulStrike_Timer -= diff; - m_uiCaveIn_Timer = m_uiCaveIn_StaticTimer; - } - else - m_uiCaveIn_Timer -= uiDiff; + // Reverberation + if (m_uiReverberation_Timer <= diff) + { + DoCastVictim(SPELL_REVERBERATION, true); + m_uiReverberation_Timer = urand(15000, 25000); + } + else + m_uiReverberation_Timer -= diff; - // Ground Slam, Gronn Lord's Grasp, Stoned, Shatter - if (m_uiGroundSlamTimer <= uiDiff) - { - me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveIdle(); + // Cave In + if (m_uiCaveIn_Timer <= diff) + { + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_CAVE_IN); - m_bPerformingGroundSlam= true; - m_uiGroundSlamTimer = 10000; + if (m_uiCaveIn_StaticTimer >= 4000) + m_uiCaveIn_StaticTimer -= 2000; - DoCast(me, SPELL_GROUND_SLAM); - } - else - m_uiGroundSlamTimer -= uiDiff; + m_uiCaveIn_Timer = m_uiCaveIn_StaticTimer; + } + else + m_uiCaveIn_Timer -= diff; + + // Ground Slam, Gronn Lord's Grasp, Stoned, Shatter + if (m_uiGroundSlamTimer <= diff) + { + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveIdle(); - DoMeleeAttackIfReady(); + m_bPerformingGroundSlam= true; + m_uiGroundSlamTimer = 10000; + + DoCast(me, SPELL_GROUND_SLAM); + } + else + m_uiGroundSlamTimer -= diff; + + DoMeleeAttackIfReady(); + } } - } - }; + }; + CreatureAI* GetAI(Creature* creature) const OVERRIDE + { + return GetGruulsLairAI<boss_gruulAI>(creature); + } }; class spell_gruul_shatter : public SpellScriptLoader diff --git a/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp b/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp index d216c0b02ee..dd44d764987 100644 --- a/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp +++ b/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp @@ -49,79 +49,35 @@ enum HighKingMaulgar SPELL_DEATH_COIL = 33130, SPELL_SUMMON_WFH = 33131, - //Kiggler the Craed + // Kiggler the Craed SPELL_GREATER_POLYMORPH = 33173, SPELL_LIGHTNING_BOLT = 36152, SPELL_ARCANE_SHOCK = 33175, SPELL_ARCANE_EXPLOSION = 33237, - //Blindeye the Seer + // Blindeye the Seer SPELL_GREATER_PW_SHIELD = 33147, SPELL_HEAL = 33144, SPELL_PRAYER_OH = 33152, - //Krosh Firehand + // Krosh Firehand SPELL_GREATER_FIREBALL = 33051, SPELL_SPELLSHIELD = 33054, - SPELL_BLAST_WAVE = 33061 -}; + SPELL_BLAST_WAVE = 33061, -bool CheckAllBossDied(InstanceScript* instance, Creature* me) -{ - if (!instance || !me) - return false; - - uint64 MaulgarGUID = 0; - uint64 KigglerGUID = 0; - uint64 BlindeyeGUID = 0; - uint64 OlmGUID = 0; - uint64 KroshGUID = 0; - - Creature* Maulgar = NULL; - Creature* Kiggler = NULL; - Creature* Blindeye = NULL; - Creature* Olm = NULL; - Creature* Krosh = NULL; - - MaulgarGUID = instance->GetData64(DATA_MAULGAR); - KigglerGUID = instance->GetData64(DATA_KIGGLERTHECRAZED); - BlindeyeGUID = instance->GetData64(DATA_BLINDEYETHESEER); - OlmGUID = instance->GetData64(DATA_OLMTHESUMMONER); - KroshGUID = instance->GetData64(DATA_KROSHFIREHAND); - - Maulgar = (Unit::GetCreature((*me), MaulgarGUID)); - Kiggler = (Unit::GetCreature((*me), KigglerGUID)); - Blindeye = (Unit::GetCreature((*me), BlindeyeGUID)); - Olm = (Unit::GetCreature((*me), OlmGUID)); - Krosh = (Unit::GetCreature((*me), KroshGUID)); - - if (!Maulgar || !Kiggler || !Blindeye || !Olm || !Krosh) - return false; - - if (!Maulgar->IsAlive() && !Kiggler->IsAlive() && !Blindeye->IsAlive() && !Olm->IsAlive() && !Krosh->IsAlive()) - return true; - - return false; -} + ACTION_ADD_DEATH = 1 +}; -//High King Maulgar AI class boss_high_king_maulgar : public CreatureScript { public: boss_high_king_maulgar() : CreatureScript("boss_high_king_maulgar") { } - CreatureAI* GetAI(Creature* creature) const OVERRIDE - { - return new boss_high_king_maulgarAI(creature); - } - struct boss_high_king_maulgarAI : public ScriptedAI { boss_high_king_maulgarAI(Creature* creature) : ScriptedAI(creature) { instance = creature->GetInstanceScript(); - for (uint8 i = 0; i < 4; ++i) - Council[i] = 0; } InstanceScript* instance; @@ -134,8 +90,6 @@ public: bool Phase2; - uint64 Council[4]; - void Reset() OVERRIDE { ArcingSmash_Timer = 10000; @@ -148,23 +102,7 @@ public: Phase2 = false; - Creature* creature = NULL; - for (uint8 i = 0; i < 4; ++i) - { - if (Council[i]) - { - creature = (Unit::GetCreature((*me), Council[i])); - if (creature && !creature->IsAlive()) - { - creature->Respawn(); - creature->AI()->EnterEvadeMode(); - } - } - } - - //reset encounter - if (instance) - instance->SetData(DATA_MAULGAREVENT, NOT_STARTED); + instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } void KilledUnit(Unit* /*victim*/) OVERRIDE @@ -176,72 +114,27 @@ public: { Talk(SAY_DEATH); - if (CheckAllBossDied(instance, me)) - instance->SetData(DATA_MAULGAREVENT, DONE); - } - - void AddDeath() - { - Talk(SAY_OGRE_DEATH); - } - - void EnterCombat(Unit* who) OVERRIDE - { - StartEvent(who); + instance->SetBossState(DATA_MAULGAR, DONE); } - void GetCouncil() + void DoAction(int32 actionId) { - if (instance) - { - //get council member's guid to respawn them if needed - Council[0] = instance->GetData64(DATA_KIGGLERTHECRAZED); - Council[1] = instance->GetData64(DATA_BLINDEYETHESEER); - Council[2] = instance->GetData64(DATA_OLMTHESUMMONER); - Council[3] = instance->GetData64(DATA_KROSHFIREHAND); - } + if (actionId == ACTION_ADD_DEATH) + Talk(SAY_OGRE_DEATH); } - void StartEvent(Unit* who) + void EnterCombat(Unit* /*who*/) OVERRIDE { - if (!instance) - return; - - GetCouncil(); - - Talk(SAY_AGGRO); - - instance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - instance->SetData(DATA_MAULGAREVENT, IN_PROGRESS); - DoZoneInCombat(); + instance->SetBossState(DATA_MAULGAR, IN_PROGRESS); + Talk(SAY_AGGRO); } void UpdateAI(uint32 diff) OVERRIDE { - //Only if not incombat check if the event is started - if (!me->IsInCombat() && instance && instance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_MAULGAREVENT_TANK)); - - if (target) - { - AttackStart(target); - GetCouncil(); - } - } - - //Return since we have no target if (!UpdateVictim()) return; - //someone evaded! - if (instance && !instance->GetData(DATA_MAULGAREVENT)) - { - EnterEvadeMode(); - return; - } - //ArcingSmash_Timer if (ArcingSmash_Timer <= diff) { @@ -301,19 +194,17 @@ public: } }; + CreatureAI* GetAI(Creature* creature) const OVERRIDE + { + return GetGruulsLairAI<boss_high_king_maulgarAI>(creature); + } }; -//Olm The Summoner AI class boss_olm_the_summoner : public CreatureScript { public: boss_olm_the_summoner() : CreatureScript("boss_olm_the_summoner") { } - CreatureAI* GetAI(Creature* creature) const OVERRIDE - { - return new boss_olm_the_summonerAI(creature); - } - struct boss_olm_the_summonerAI : public ScriptedAI { boss_olm_the_summonerAI(Creature* creature) : ScriptedAI(creature) @@ -333,9 +224,7 @@ public: Summon_Timer = 15000; DeathCoil_Timer = 20000; - //reset encounter - if (instance) - instance->SetData(DATA_MAULGAREVENT, NOT_STARTED); + instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } void AttackStart(Unit* who) OVERRIDE @@ -353,54 +242,25 @@ public: } } - void EnterCombat(Unit* who) OVERRIDE + void EnterCombat(Unit* /*who*/) OVERRIDE { - if (instance) - { - instance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - instance->SetData(DATA_MAULGAREVENT, IN_PROGRESS); - } + DoZoneInCombat(); + instance->SetBossState(DATA_MAULGAR, IN_PROGRESS); } void JustDied(Unit* /*killer*/) OVERRIDE { - if (instance) - { - Creature* Maulgar = NULL; - Maulgar = (Unit::GetCreature((*me), instance->GetData64(DATA_MAULGAR))); - - if (Maulgar) - CAST_AI(boss_high_king_maulgar::boss_high_king_maulgarAI, Maulgar->AI())->AddDeath(); + if (Creature* maulgar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_MAULGAR))) + maulgar->AI()->DoAction(ACTION_ADD_DEATH); - if (CheckAllBossDied(instance, me)) - instance->SetData(DATA_MAULGAREVENT, DONE); - } + instance->SetBossState(DATA_MAULGAR, DONE); } void UpdateAI(uint32 diff) OVERRIDE { - //Only if not incombat check if the event is started - if (!me->IsInCombat() && instance && instance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_MAULGAREVENT_TANK)); - - if (target) - { - AttackStart(target); - } - } - - //Return since we have no target if (!UpdateVictim()) return; - //someone evaded! - if (instance && !instance->GetData(DATA_MAULGAREVENT)) - { - EnterEvadeMode(); - return; - } - //DarkDecay_Timer if (DarkDecay_Timer <= diff) { @@ -429,6 +289,10 @@ public: } }; + CreatureAI* GetAI(Creature* creature) const OVERRIDE + { + return GetGruulsLairAI<boss_olm_the_summonerAI>(creature); + } }; //Kiggler The Crazed AI @@ -437,11 +301,6 @@ class boss_kiggler_the_crazed : public CreatureScript public: boss_kiggler_the_crazed() : CreatureScript("boss_kiggler_the_crazed") { } - CreatureAI* GetAI(Creature* creature) const OVERRIDE - { - return new boss_kiggler_the_crazedAI(creature); - } - struct boss_kiggler_the_crazedAI : public ScriptedAI { boss_kiggler_the_crazedAI(Creature* creature) : ScriptedAI(creature) @@ -463,59 +322,28 @@ public: ArcaneShock_Timer = 20000; ArcaneExplosion_Timer = 30000; - //reset encounter - if (instance) - instance->SetData(DATA_MAULGAREVENT, NOT_STARTED); + instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } - void EnterCombat(Unit* who) OVERRIDE + void EnterCombat(Unit* /*who*/) OVERRIDE { - if (instance) - { - instance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - instance->SetData(DATA_MAULGAREVENT, IN_PROGRESS); - } + DoZoneInCombat(); + instance->SetBossState(DATA_MAULGAR, IN_PROGRESS); } void JustDied(Unit* /*killer*/) OVERRIDE { - if (instance) - { - Creature* Maulgar = NULL; - Maulgar = (Unit::GetCreature((*me), instance->GetData64(DATA_MAULGAR))); - - if (Maulgar) - CAST_AI(boss_high_king_maulgar::boss_high_king_maulgarAI, Maulgar->AI())->AddDeath(); + if (Creature* maulgar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_MAULGAR))) + maulgar->AI()->DoAction(ACTION_ADD_DEATH); - if (CheckAllBossDied(instance, me)) - instance->SetData(DATA_MAULGAREVENT, DONE); - } + instance->SetBossState(DATA_MAULGAR, DONE); } void UpdateAI(uint32 diff) OVERRIDE { - //Only if not incombat check if the event is started - if (!me->IsInCombat() && instance && instance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_MAULGAREVENT_TANK)); - - if (target) - { - AttackStart(target); - } - } - - //Return since we have no target if (!UpdateVictim()) return; - //someone evaded! - if (instance && !instance->GetData(DATA_MAULGAREVENT)) - { - EnterEvadeMode(); - return; - } - //GreaterPolymorph_Timer if (GreaterPolymorph_Timer <= diff) { @@ -550,19 +378,17 @@ public: } }; + CreatureAI* GetAI(Creature* creature) const OVERRIDE + { + return GetGruulsLairAI<boss_kiggler_the_crazedAI>(creature); + } }; -//Blindeye The Seer AI class boss_blindeye_the_seer : public CreatureScript { public: boss_blindeye_the_seer() : CreatureScript("boss_blindeye_the_seer") { } - CreatureAI* GetAI(Creature* creature) const OVERRIDE - { - return new boss_blindeye_the_seerAI(creature); - } - struct boss_blindeye_the_seerAI : public ScriptedAI { boss_blindeye_the_seerAI(Creature* creature) : ScriptedAI(creature) @@ -582,59 +408,28 @@ public: Heal_Timer = urand(25000, 40000); PrayerofHealing_Timer = urand(45000, 55000); - //reset encounter - if (instance) - instance->SetData(DATA_MAULGAREVENT, NOT_STARTED); + instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } - void EnterCombat(Unit* who) OVERRIDE + void EnterCombat(Unit* /*who*/) OVERRIDE { - if (instance) - { - instance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - instance->SetData(DATA_MAULGAREVENT, IN_PROGRESS); - } + DoZoneInCombat(); + instance->SetBossState(DATA_MAULGAR, IN_PROGRESS); } void JustDied(Unit* /*killer*/) OVERRIDE { - if (instance) - { - Creature* Maulgar = NULL; - Maulgar = (Unit::GetCreature((*me), instance->GetData64(DATA_MAULGAR))); + if (Creature* maulgar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_MAULGAR))) + maulgar->AI()->DoAction(ACTION_ADD_DEATH); - if (Maulgar) - CAST_AI(boss_high_king_maulgar::boss_high_king_maulgarAI, Maulgar->AI())->AddDeath(); - - if (CheckAllBossDied(instance, me)) - instance->SetData(DATA_MAULGAREVENT, DONE); - } + instance->SetBossState(DATA_MAULGAR, DONE); } void UpdateAI(uint32 diff) OVERRIDE { - //Only if not incombat check if the event is started - if (!me->IsInCombat() && instance && instance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_MAULGAREVENT_TANK)); - - if (target) - { - AttackStart(target); - } - } - - //Return since we have no target if (!UpdateVictim()) return; - //someone evaded! - if (instance && !instance->GetData(DATA_MAULGAREVENT)) - { - EnterEvadeMode(); - return; - } - //GreaterPowerWordShield_Timer if (GreaterPowerWordShield_Timer <= diff) { @@ -660,19 +455,17 @@ public: } }; + CreatureAI* GetAI(Creature* creature) const OVERRIDE + { + return GetGruulsLairAI<boss_blindeye_the_seerAI>(creature); + } }; -//Krosh Firehand AI class boss_krosh_firehand : public CreatureScript { public: boss_krosh_firehand() : CreatureScript("boss_krosh_firehand") { } - CreatureAI* GetAI(Creature* creature) const OVERRIDE - { - return new boss_krosh_firehandAI(creature); - } - struct boss_krosh_firehandAI : public ScriptedAI { boss_krosh_firehandAI(Creature* creature) : ScriptedAI(creature) @@ -692,59 +485,28 @@ public: SpellShield_Timer = 5000; BlastWave_Timer = 20000; - //reset encounter - if (instance) - instance->SetData(DATA_MAULGAREVENT, NOT_STARTED); + instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } - void EnterCombat(Unit* who) OVERRIDE + void EnterCombat(Unit* /*who*/) OVERRIDE { - if (instance) - { - instance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - instance->SetData(DATA_MAULGAREVENT, IN_PROGRESS); - } + DoZoneInCombat(); + instance->SetBossState(DATA_MAULGAR, IN_PROGRESS); } void JustDied(Unit* /*killer*/) OVERRIDE { - if (instance) - { - Creature* Maulgar = NULL; - Maulgar = (Unit::GetCreature((*me), instance->GetData64(DATA_MAULGAR))); + if (Creature* maulgar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_MAULGAR))) + maulgar->AI()->DoAction(ACTION_ADD_DEATH); - if (Maulgar) - CAST_AI(boss_high_king_maulgar::boss_high_king_maulgarAI, Maulgar->AI())->AddDeath(); - - if (CheckAllBossDied(instance, me)) - instance->SetData(DATA_MAULGAREVENT, DONE); - } + instance->SetBossState(DATA_MAULGAR, DONE); } void UpdateAI(uint32 diff) OVERRIDE { - //Only if not incombat check if the event is started - if (!me->IsInCombat() && instance && instance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_MAULGAREVENT_TANK)); - - if (target) - { - AttackStart(target); - } - } - - //Return since we have no target if (!UpdateVictim()) return; - //someone evaded! - if (instance && !instance->GetData(DATA_MAULGAREVENT)) - { - EnterEvadeMode(); - return; - } - //GreaterFireball_Timer if (GreaterFireball_Timer < diff || me->IsWithinDist(me->GetVictim(), 30)) { @@ -783,6 +545,11 @@ public: } else BlastWave_Timer -= diff; } }; + + CreatureAI* GetAI(Creature* creature) const OVERRIDE + { + return GetGruulsLairAI<boss_krosh_firehandAI>(creature); + } }; void AddSC_boss_high_king_maulgar() diff --git a/src/server/scripts/Outland/GruulsLair/gruuls_lair.h b/src/server/scripts/Outland/GruulsLair/gruuls_lair.h index 69ddba8c274..1425a19aa47 100644 --- a/src/server/scripts/Outland/GruulsLair/gruuls_lair.h +++ b/src/server/scripts/Outland/GruulsLair/gruuls_lair.h @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2013 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 @@ -16,23 +15,39 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef DEF_GRUULS_LAIR_H -#define DEF_GRUULS_LAIR_H +#ifndef GRUULS_LAIR_H_ +#define GRUULS_LAIR_H_ + +#define GLScriptName "instance_gruuls_lair" + +uint32 const EncounterCount = 2; enum DataTypes { - DATA_BLINDEYETHESEER = 1, - DATA_GRUULEVENT = 2, - DATA_KIGGLERTHECRAZED = 3, - DATA_KROSHFIREHAND = 4, - DATA_MAULGAREVENT = 5, - DATA_MAULGAREVENT_TANK = 6, - DATA_OLMTHESUMMONER = 7, - DATA_MAULGARDOOR = 8, - DATA_GRUULDOOR = 9, - DATA_MAULGAR = 10 + // Encounter States/Boss GUIDs + DATA_MAULGAR = 0, + DATA_GRUUL = 1 +}; + +enum CreatureIds +{ + NPC_MAULGAR = 18831, + NPC_KROSH_FIREHAND = 18832, + NPC_OLM_THE_SUMMONER = 18834, + NPC_KIGGLER_THE_CRAZED = 18835, + NPC_BLINDEYE_THE_SEER = 18836 }; -#define ERROR_INST_DATA "TSCR Error: Instance Data not set properly for Gruul's Lair instance (map 565). Encounters will be buggy." -#endif +enum GameObjectIds +{ + GO_MAULGAR_DOOR = 184468, + GO_GRUUL_DOOR = 184662 +}; + +template<class AI> +AI* GetGruulsLairAI(Creature* creature) +{ + return GetInstanceAI<AI>(creature, GLScriptName); +} +#endif // GRUULS_LAIR_H_ diff --git a/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp b/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp index d8399793df4..aa8a8d01d8a 100644 --- a/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp +++ b/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2013 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 @@ -16,184 +15,165 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Instance_Gruuls_Lair -SD%Complete: 100 -SDComment: -SDCategory: Gruul's Lair -EndScriptData */ - #include "ScriptMgr.h" #include "InstanceScript.h" #include "gruuls_lair.h" -#define MAX_ENCOUNTER 2 +DoorData const doorData[] = +{ + { GO_MAULGAR_DOOR, DATA_MAULGAR, DOOR_TYPE_PASSAGE, BOUNDARY_NONE }, + { GO_GRUUL_DOOR, DATA_GRUUL, DOOR_TYPE_ROOM, BOUNDARY_NONE }, + { 0, 0, DOOR_TYPE_ROOM, BOUNDARY_NONE } // END +}; -/* Gruuls Lair encounters: -1 - High King Maulgar event -2 - Gruul event -*/ +MinionData const minionData[] = +{ + { NPC_MAULGAR, DATA_MAULGAR }, + { NPC_KROSH_FIREHAND, DATA_MAULGAR }, + { NPC_OLM_THE_SUMMONER, DATA_MAULGAR }, + { NPC_KIGGLER_THE_CRAZED, DATA_MAULGAR }, + { NPC_BLINDEYE_THE_SEER, DATA_MAULGAR } +}; class instance_gruuls_lair : public InstanceMapScript { -public: - instance_gruuls_lair() : InstanceMapScript("instance_gruuls_lair", 565) { } - - InstanceScript* GetInstanceScript(InstanceMap* map) const OVERRIDE - { - return new instance_gruuls_lair_InstanceMapScript(map); - } + public: + instance_gruuls_lair() : InstanceMapScript(GLScriptName, 565) { } - struct instance_gruuls_lair_InstanceMapScript : public InstanceScript - { - instance_gruuls_lair_InstanceMapScript(Map* map) : InstanceScript(map) {} - - uint32 m_auiEncounter[MAX_ENCOUNTER]; - - uint64 MaulgarEvent_Tank; - uint64 KigglerTheCrazed; - uint64 BlindeyeTheSeer; - uint64 OlmTheSummoner; - uint64 KroshFirehand; - uint64 Maulgar; - - uint64 MaulgarDoor; - uint64 GruulDoor; - - void Initialize() OVERRIDE + struct instance_gruuls_lair_InstanceMapScript : public InstanceScript { - memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - - MaulgarEvent_Tank = 0; - KigglerTheCrazed = 0; - BlindeyeTheSeer = 0; - OlmTheSummoner = 0; - KroshFirehand = 0; - Maulgar = 0; - - MaulgarDoor = 0; - GruulDoor = 0; - } - - bool IsEncounterInProgress() const OVERRIDE - { - for (uint8 i = 0; i < MAX_ENCOUNTER; ++i) - if (m_auiEncounter[i] == IN_PROGRESS) - return true; + instance_gruuls_lair_InstanceMapScript(Map* map) : InstanceScript(map) + { + SetBossNumber(EncounterCount); + LoadDoorData(doorData); + LoadMinionData(minionData); - return false; - } + MaulgarGUID = 0; + } - void OnCreatureCreate(Creature* creature) OVERRIDE - { - switch (creature->GetEntry()) + void OnCreatureCreate(Creature* creature) OVERRIDE { - case 18835: KigglerTheCrazed = creature->GetGUID(); break; - case 18836: BlindeyeTheSeer = creature->GetGUID(); break; - case 18834: OlmTheSummoner = creature->GetGUID(); break; - case 18832: KroshFirehand = creature->GetGUID(); break; - case 18831: Maulgar = creature->GetGUID(); break; + switch (creature->GetEntry()) + { + case NPC_MAULGAR: + MaulgarGUID = creature->GetGUID(); + // no break; + case NPC_KROSH_FIREHAND: + case NPC_OLM_THE_SUMMONER: + case NPC_KIGGLER_THE_CRAZED: + case NPC_BLINDEYE_THE_SEER: + AddMinion(creature, true); + break; + default: + break; + } } - } - void OnGameObjectCreate(GameObject* go) OVERRIDE - { - switch (go->GetEntry()) + void OnCreatureRemove(Creature* creature) OVERRIDE { - case 184468: - MaulgarDoor = go->GetGUID(); - if (m_auiEncounter[0] == DONE) - HandleGameObject(0, true, go); - break; - case 184662: - GruulDoor = go->GetGUID(); - break; + switch (creature->GetEntry()) + { + case NPC_MAULGAR: + case NPC_KROSH_FIREHAND: + case NPC_OLM_THE_SUMMONER: + case NPC_KIGGLER_THE_CRAZED: + case NPC_BLINDEYE_THE_SEER: + AddMinion(creature, false); + break; + default: + break; + } } - } - void SetData64(uint32 type, uint64 data) OVERRIDE - { - if (type == DATA_MAULGAREVENT_TANK) - MaulgarEvent_Tank = data; - } - - uint64 GetData64(uint32 identifier) const OVERRIDE - { - switch (identifier) + void OnGameObjectCreate(GameObject* go) OVERRIDE { - case DATA_MAULGAREVENT_TANK: return MaulgarEvent_Tank; - case DATA_KIGGLERTHECRAZED: return KigglerTheCrazed; - case DATA_BLINDEYETHESEER: return BlindeyeTheSeer; - case DATA_OLMTHESUMMONER: return OlmTheSummoner; - case DATA_KROSHFIREHAND: return KroshFirehand; - case DATA_MAULGARDOOR: return MaulgarDoor; - case DATA_GRUULDOOR: return GruulDoor; - case DATA_MAULGAR: return Maulgar; + switch (go->GetEntry()) + { + case GO_MAULGAR_DOOR: + case GO_GRUUL_DOOR: + AddDoor(go, true); + break; + default: + break; + } } - return 0; - } - void SetData(uint32 type, uint32 data) OVERRIDE - { - switch (type) + void OnGameObjectRemove(GameObject* go) OVERRIDE { - case DATA_MAULGAREVENT: - if (data == DONE) - HandleGameObject(MaulgarDoor, true); - m_auiEncounter[0] = data; - break; - - case DATA_GRUULEVENT: - if (data == IN_PROGRESS) - HandleGameObject(GruulDoor, false); - else - HandleGameObject(GruulDoor, true); - m_auiEncounter[1] = data; - break; + switch (go->GetEntry()) + { + case GO_MAULGAR_DOOR: + case GO_GRUUL_DOOR: + AddDoor(go, false); + break; + default: + break; + } } - if (data == DONE) - SaveToDB(); - } - - uint32 GetData(uint32 type) const OVERRIDE - { - switch (type) + uint64 GetData64(uint32 type) const OVERRIDE { - case DATA_MAULGAREVENT: return m_auiEncounter[0]; - case DATA_GRUULEVENT: return m_auiEncounter[1]; + switch (type) + { + case DATA_MAULGAR: + return MaulgarGUID; + default: + break; + } + return 0; } - return 0; - } - std::string GetSaveData() OVERRIDE - { - OUT_SAVE_INST_DATA; - std::ostringstream stream; - stream << m_auiEncounter[0] << ' ' << m_auiEncounter[1]; + std::string GetSaveData() OVERRIDE + { + OUT_SAVE_INST_DATA; - OUT_SAVE_INST_DATA_COMPLETE; - return stream.str(); - } + std::ostringstream saveStream; + saveStream << "G L " << GetBossSaveData(); - void Load(const char* in) OVERRIDE - { - if (!in) + OUT_SAVE_INST_DATA_COMPLETE; + return saveStream.str(); + } + + void Load(char const* str) OVERRIDE { - OUT_LOAD_INST_DATA_FAIL; - return; + if (!str) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(str); + + char dataHead1, dataHead2; + + std::istringstream loadStream(str); + loadStream >> dataHead1 >> dataHead2; + + if (dataHead1 == 'G' && dataHead2 == 'L') + { + for (uint32 i = 0; i < EncounterCount; ++i) + { + uint32 tmpState; + loadStream >> tmpState; + if (tmpState == IN_PROGRESS || tmpState > SPECIAL) + tmpState = NOT_STARTED; + SetBossState(i, EncounterState(tmpState)); + } + } + else + OUT_LOAD_INST_DATA_FAIL; + + OUT_LOAD_INST_DATA_COMPLETE; } - OUT_LOAD_INST_DATA(in); - std::istringstream stream(in); - stream >> m_auiEncounter[0] >> m_auiEncounter[1]; - for (uint8 i = 0; i < MAX_ENCOUNTER; ++i) - if (m_auiEncounter[i] == IN_PROGRESS) // Do not load an encounter as "In Progress" - reset it instead. - m_auiEncounter[i] = NOT_STARTED; - OUT_LOAD_INST_DATA_COMPLETE; - } - }; + protected: + uint64 MaulgarGUID; + }; + InstanceScript* GetInstanceScript(InstanceMap* map) const OVERRIDE + { + return new instance_gruuls_lair_InstanceMapScript(map); + } }; void AddSC_instance_gruuls_lair() |