diff options
author | jackpoz <giacomopoz@gmail.com> | 2014-09-04 23:05:03 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2014-09-05 22:44:24 +0200 |
commit | 6df2ff5efa0a84c5423804d713acd0e8952db86e (patch) | |
tree | 75e8fa91a6ea2ceb502356e7ee804fc6993a2ef0 /src | |
parent | d3a50ffb59f315d43c9ba93d5909887c6abe3685 (diff) |
Core/Misc: Refactor scripts to fix static analysis warnings
Third batch of fixes targeting 100 issues reported by Coverity
Diffstat (limited to 'src')
70 files changed, 1268 insertions, 552 deletions
diff --git a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp index dbcf5998bdb..d242d17806c 100644 --- a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp @@ -319,19 +319,24 @@ public: struct npc_anchorite_truuenAI : public npc_escortAI { - npc_anchorite_truuenAI(Creature* creature) : npc_escortAI(creature) { } + npc_anchorite_truuenAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + UghostGUID = 0; + } + + void Initialize() + { + m_uiChatTimer = 7000; + } uint32 m_uiChatTimer; uint64 UghostGUID; - uint64 TheldanisGUID; - - Creature* Ughost; - Creature* Theldanis; void Reset() override { - m_uiChatTimer = 7000; + Initialize(); } void JustSummoned(Creature* summoned) override @@ -364,26 +369,25 @@ public: Talk(SAY_WP_2); break; case 21: - Theldanis = GetClosestCreatureWithEntry(me, NPC_THEL_DANIS, 150); - if (Theldanis) + if (Creature* Theldanis = GetClosestCreatureWithEntry(me, NPC_THEL_DANIS, 150)) Theldanis->AI()->Talk(SAY_WP_3); break; case 23: - Ughost = me->SummonCreature(NPC_GHOST_UTHER, 971.86f, -1825.42f, 81.99f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); - if (Ughost) + if (Creature* Ughost = me->SummonCreature(NPC_GHOST_UTHER, 971.86f, -1825.42f, 81.99f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)) { + UghostGUID = Ughost->GetGUID(); Ughost->SetDisableGravity(true); Ughost->AI()->Talk(SAY_WP_4, me); } m_uiChatTimer = 4000; break; case 24: - if (Ughost) + if (Creature* Ughost = ObjectAccessor::GetCreature(*me, UghostGUID)) Ughost->AI()->Talk(SAY_WP_5, me); m_uiChatTimer = 4000; break; case 25: - if (Ughost) + if (Creature* Ughost = ObjectAccessor::GetCreature(*me, UghostGUID)) Ughost->AI()->Talk(SAY_WP_6, me); m_uiChatTimer = 4000; break; diff --git a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp index e6c844b1b1e..94cea417b04 100644 --- a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp @@ -59,14 +59,22 @@ public: struct npc_tapoke_slim_jahnAI : public npc_escortAI { - npc_tapoke_slim_jahnAI(Creature* creature) : npc_escortAI(creature) { } + npc_tapoke_slim_jahnAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + IsFriendSummoned = false; + } bool IsFriendSummoned; void Reset() override { if (!HasEscortState(STATE_ESCORT_ESCORTING)) - IsFriendSummoned = false; + Initialize(); } void WaypointReached(uint32 waypointId) override diff --git a/src/server/scripts/Events/childrens_week.cpp b/src/server/scripts/Events/childrens_week.cpp index 683b8d36011..6a338c2f03a 100644 --- a/src/server/scripts/Events/childrens_week.cpp +++ b/src/server/scripts/Events/childrens_week.cpp @@ -150,9 +150,12 @@ class npc_winterfin_playmate : public CreatureScript struct npc_winterfin_playmateAI : public ScriptedAI { - npc_winterfin_playmateAI(Creature* creature) : ScriptedAI(creature) { } + npc_winterfin_playmateAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() + void Initialize() { timer = 0; phase = 0; @@ -160,6 +163,11 @@ class npc_winterfin_playmate : public CreatureScript orphanGUID = 0; } + void Reset() + { + Initialize(); + } + void MoveInLineOfSight(Unit* who) override { @@ -249,9 +257,12 @@ class npc_snowfall_glade_playmate : public CreatureScript struct npc_snowfall_glade_playmateAI : public ScriptedAI { - npc_snowfall_glade_playmateAI(Creature* creature) : ScriptedAI(creature) { } + npc_snowfall_glade_playmateAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() + void Initialize() { timer = 0; phase = 0; @@ -259,6 +270,11 @@ class npc_snowfall_glade_playmate : public CreatureScript orphanGUID = 0; } + void Reset() + { + Initialize(); + } + void MoveInLineOfSight(Unit* who) override { @@ -349,10 +365,11 @@ class npc_the_biggest_tree : public CreatureScript { npc_the_biggest_treeAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); me->SetDisplayId(DISPLAY_INVISIBLE); } - void Reset() + void Initialize() { timer = 1000; phase = 0; @@ -360,8 +377,12 @@ class npc_the_biggest_tree : public CreatureScript orphanGUID = 0; } - void MoveInLineOfSight(Unit* who) override + void Reset() + { + Initialize(); + } + void MoveInLineOfSight(Unit* who) override { if (!phase && who && who->GetDistance2d(me) < 10.0f) if (Player* player = who->ToPlayer()) @@ -437,9 +458,12 @@ class npc_high_oracle_soo_roo : public CreatureScript struct npc_high_oracle_soo_rooAI : public ScriptedAI { - npc_high_oracle_soo_rooAI(Creature* creature) : ScriptedAI(creature) { } + npc_high_oracle_soo_rooAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() + void Initialize() { timer = 0; phase = 0; @@ -447,6 +471,11 @@ class npc_high_oracle_soo_roo : public CreatureScript orphanGUID = 0; } + void Reset() + { + Initialize(); + } + void MoveInLineOfSight(Unit* who) override { @@ -526,9 +555,12 @@ class npc_elder_kekek : public CreatureScript struct npc_elder_kekekAI : public ScriptedAI { - npc_elder_kekekAI(Creature* creature) : ScriptedAI(creature) { } + npc_elder_kekekAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() + void Initialize() { timer = 0; phase = 0; @@ -536,6 +568,11 @@ class npc_elder_kekek : public CreatureScript orphanGUID = 0; } + void Reset() + { + Initialize(); + } + void MoveInLineOfSight(Unit* who) override { @@ -615,9 +652,12 @@ class npc_the_etymidian : public CreatureScript struct npc_the_etymidianAI : public ScriptedAI { - npc_the_etymidianAI(Creature* creature) : ScriptedAI(creature) { } + npc_the_etymidianAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() + void Initialize() { timer = 0; phase = 0; @@ -625,8 +665,12 @@ class npc_the_etymidian : public CreatureScript orphanGUID = 0; } - void MoveInLineOfSight(Unit* who) override + void Reset() + { + Initialize(); + } + void MoveInLineOfSight(Unit* who) override { if (!phase && who && who->GetDistance2d(me) < 10.0f) if (Player* player = who->ToPlayer()) @@ -711,9 +755,12 @@ class npc_alexstraza_the_lifebinder : public CreatureScript struct npc_alexstraza_the_lifebinderAI : public ScriptedAI { - npc_alexstraza_the_lifebinderAI(Creature* creature) : ScriptedAI(creature) { } + npc_alexstraza_the_lifebinderAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() + void Initialize() { timer = 0; phase = 0; @@ -721,6 +768,11 @@ class npc_alexstraza_the_lifebinder : public CreatureScript orphanGUID = 0; } + void Reset() + { + Initialize(); + } + void SetData(uint32 type, uint32 data) override { // Existing SmartAI diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp index e7beb4cf454..f8ba2ab6646 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp @@ -80,6 +80,7 @@ public: { npc_blackfathom_deeps_eventAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); if (creature->IsSummon()) { creature->SetHomePosition(HomePosition); @@ -89,6 +90,15 @@ public: instance = creature->GetInstanceScript(); } + void Initialize() + { + Flee = false; + + ravageTimer = urand(5000, 8000); + frostNovaTimer = urand(9000, 12000); + frostBoltVolleyTimer = urand(2000, 4000); + } + InstanceScript* instance; uint32 ravageTimer; @@ -99,11 +109,7 @@ public: void Reset() override { - Flee = false; - - ravageTimer = urand(5000, 8000); - frostNovaTimer = urand(9000, 12000); - frostBoltVolleyTimer = urand(2000, 4000); + Initialize(); } void AttackPlayer() diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_aku_mai.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_aku_mai.cpp index f6c34c6b555..b510a84b949 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_aku_mai.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_aku_mai.cpp @@ -38,11 +38,19 @@ public: struct boss_aku_maiAI : public BossAI { - boss_aku_maiAI(Creature* creature) : BossAI(creature, TYPE_AKU_MAI) { } + boss_aku_maiAI(Creature* creature) : BossAI(creature, TYPE_AKU_MAI) + { + Initialize(); + } - void Reset() override + void Initialize() { IsEnraged = false; + } + + void Reset() override + { + Initialize(); _Reset(); } diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_gelihast.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_gelihast.cpp index 9e25de817fa..0eba1a14fa5 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_gelihast.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_gelihast.cpp @@ -38,16 +38,22 @@ public: { boss_gelihastAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + netTimer = urand(2000, 4000); + } + uint32 netTimer; InstanceScript* instance; void Reset() override { - netTimer = urand(2000, 4000); + Initialize(); instance->SetData(TYPE_GELIHAST, NOT_STARTED); } diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_kelris.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_kelris.cpp index 37fac0fa7de..d5860e4dbf7 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_kelris.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_kelris.cpp @@ -43,9 +43,16 @@ public: { boss_kelrisAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + mindBlastTimer = urand(2000, 5000); + sleepTimer = urand(9000, 12000); + } + uint32 mindBlastTimer; uint32 sleepTimer; @@ -53,8 +60,7 @@ public: void Reset() override { - mindBlastTimer = urand(2000, 5000); - sleepTimer = urand(9000, 12000); + Initialize(); instance->SetData(TYPE_KELRIS, NOT_STARTED); } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp index 7aaa2239745..782632602b3 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp @@ -54,10 +54,20 @@ public: { boss_anetheronAI(Creature* creature) : hyjal_trashAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); go = false; } + void Initialize() + { + SwarmTimer = 45000; + SleepTimer = 60000; + AuraTimer = 5000; + InfernoTimer = 45000; + damageTaken = 0; + } + uint32 SwarmTimer; uint32 SleepTimer; uint32 AuraTimer; @@ -66,11 +76,7 @@ public: void Reset() override { - damageTaken = 0; - SwarmTimer = 45000; - SleepTimer = 60000; - AuraTimer = 5000; - InfernoTimer = 45000; + Initialize(); if (IsEvent) instance->SetData(DATA_ANETHERONEVENT, NOT_STARTED); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp index 576b3dbdb39..2885a838cee 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp @@ -90,7 +90,13 @@ public: { npc_ancient_wispAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); + } + + void Initialize() + { + CheckTimer = 1000; ArchimondeGUID = 0; } @@ -100,7 +106,7 @@ public: void Reset() override { - CheckTimer = 1000; + Initialize(); ArchimondeGUID = instance->GetData64(DATA_ARCHIMONDE); @@ -174,15 +180,23 @@ public: struct npc_doomfire_targettingAI : public ScriptedAI { - npc_doomfire_targettingAI(Creature* creature) : ScriptedAI(creature) { } + npc_doomfire_targettingAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + TargetGUID = 0; + ChangeTargetTimer = 5000; + } uint64 TargetGUID; uint32 ChangeTargetTimer; void Reset() override { - TargetGUID = 0; - ChangeTargetTimer = 5000; + Initialize(); } void MoveInLineOfSight(Unit* who) override @@ -244,9 +258,36 @@ public: { boss_archimondeAI(Creature* creature) : hyjal_trashAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + DoomfireSpiritGUID = 0; + damageTaken = 0; + WorldTreeGUID = 0; + + DrainNordrassilTimer = 0; + FearTimer = 42000; + AirBurstTimer = 30000; + GripOfTheLegionTimer = urand(5000, 25000); + DoomfireTimer = 20000; + SoulChargeTimer = urand(2000, 30000); + SoulChargeCount = 0; + MeleeRangeCheckTimer = 15000; + HandOfDeathTimer = 2000; + WispCount = 0; // When ~30 wisps are summoned, Archimonde dies + EnrageTimer = 600000; // 10 minutes + CheckDistanceTimer = 30000; // This checks if he's too close to the World Tree (75 yards from a point on the tree), if true then he will enrage + SummonWispTimer = 0; + + Enraged = false; + BelowTenPercent = false; + HasProtected = false; + IsChanneling = false; + } + InstanceScript* instance; uint64 DoomfireSpiritGUID; @@ -275,28 +316,7 @@ public: { instance->SetData(DATA_ARCHIMONDEEVENT, NOT_STARTED); - DoomfireSpiritGUID = 0; - damageTaken = 0; - WorldTreeGUID = 0; - - DrainNordrassilTimer = 0; - FearTimer = 42000; - AirBurstTimer = 30000; - GripOfTheLegionTimer = urand(5000, 25000); - DoomfireTimer = 20000; - SoulChargeTimer = urand(2000, 30000); - SoulChargeCount = 0; - MeleeRangeCheckTimer = 15000; - HandOfDeathTimer = 2000; - WispCount = 0; // When ~30 wisps are summoned, Archimonde dies - EnrageTimer = 600000; // 10 minutes - CheckDistanceTimer = 30000; // This checks if he's too close to the World Tree (75 yards from a point on the tree), if true then he will enrage - SummonWispTimer = 0; - - Enraged = false; - BelowTenPercent = false; - HasProtected = false; - IsChanneling = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp index 38e398f3d5b..7e50fd7b775 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp @@ -55,10 +55,22 @@ public: { boss_azgalorAI(Creature* creature) : hyjal_trashAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); go = false; } + void Initialize() + { + damageTaken = 0; + RainTimer = 20000; + DoomTimer = 50000; + HowlTimer = 30000; + CleaveTimer = 10000; + EnrageTimer = 600000; + enraged = false; + } + uint32 RainTimer; uint32 DoomTimer; uint32 HowlTimer; @@ -70,13 +82,7 @@ public: void Reset() override { - damageTaken = 0; - RainTimer = 20000; - DoomTimer = 50000; - HowlTimer = 30000; - CleaveTimer = 10000; - EnrageTimer = 600000; - enraged = false; + Initialize(); if (IsEvent) instance->SetData(DATA_AZGALOREVENT, NOT_STARTED); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp index c5fcb150d3f..d3c137b67e8 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp @@ -56,10 +56,20 @@ public: { boss_kazrogalAI(Creature* creature) : hyjal_trashAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); go = false; } + void Initialize() + { + damageTaken = 0; + CleaveTimer = 5000; + WarStompTimer = 15000; + MarkTimer = 45000; + MarkTimerBase = 45000; + } + uint32 CleaveTimer; uint32 WarStompTimer; uint32 MarkTimer; @@ -68,11 +78,7 @@ public: void Reset() override { - damageTaken = 0; - CleaveTimer = 5000; - WarStompTimer = 15000; - MarkTimer = 45000; - MarkTimerBase = 45000; + Initialize(); if (IsEvent) instance->SetData(DATA_KAZROGALEVENT, NOT_STARTED); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp index c37b9d910e7..5ce9b30eb58 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp @@ -51,10 +51,20 @@ public: { boss_rage_winterchillAI(Creature* creature) : hyjal_trashAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); go = false; } + void Initialize() + { + damageTaken = 0; + FrostArmorTimer = 37000; + DecayTimer = 45000; + NovaTimer = 15000; + IceboltTimer = 10000; + } + uint32 FrostArmorTimer; uint32 DecayTimer; uint32 NovaTimer; @@ -63,11 +73,7 @@ public: void Reset() override { - damageTaken = 0; - FrostArmorTimer = 37000; - DecayTimer = 45000; - NovaTimer = 15000; - IceboltTimer = 10000; + Initialize(); if (IsEvent) instance->SetData(DATA_RAGEWINTERCHILLEVENT, NOT_STARTED); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp index b9c6025b91c..34b55da72de 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp @@ -317,6 +317,7 @@ float HordeFirePos[65][8]=//spawn points for the fire visuals (GO) in the horde hyjalAI::hyjalAI(Creature* creature) : npc_escortAI(creature), Summons(me) { + Initialize(); instance = creature->GetInstanceScript(); VeinsSpawned[0] = false; VeinsSpawned[1] = false; @@ -332,25 +333,14 @@ hyjalAI::hyjalAI(Creature* creature) : npc_escortAI(creature), Summons(me) InfernalPoint = 0; RespawnTimer = 10000; DoRespawn = false; - DoHide = false; MassTeleportTimer = 0; DoMassTeleport = false; } -void hyjalAI::JustSummoned(Creature* summoned) -{ - Summons.Summon(summoned); -} - -void hyjalAI::SummonedCreatureDespawn(Creature* summoned) -{ - Summons.Despawn(summoned); -} - -void hyjalAI::Reset() +void hyjalAI::Initialize() { IsDummy = false; - me->setActive(true); + // GUIDs PlayerGUID = 0; BossGUID[0] = 0; @@ -365,6 +355,39 @@ void hyjalAI::Reset() WaveCount = 0; EnemyCount = 0; + //Bools + EventBegun = false; + FirstBossDead = false; + SecondBossDead = false; + Summon = false; + bRetreat = false; + Debug = false; + + //Visibility + DoHide = true; + + //Initialize spells + memset(Spells, 0, sizeof(Spell) * HYJAL_AI_MAX_SPELLS); + + Faction = 0; +} + +void hyjalAI::JustSummoned(Creature* summoned) +{ + Summons.Summon(summoned); +} + +void hyjalAI::SummonedCreatureDespawn(Creature* summoned) +{ + Summons.Despawn(summoned); +} + +void hyjalAI::Reset() +{ + me->setActive(true); + + Initialize(); + // Set faction properly based on Creature entry switch (me->GetEntry()) { @@ -382,20 +405,9 @@ void hyjalAI::Reset() break; } - //Bools - EventBegun = false; - FirstBossDead = false; - SecondBossDead = false; - Summon = false; - bRetreat = false; - Debug = false; - //Flags me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - //Initialize spells - memset(Spells, 0, sizeof(Spell) * HYJAL_AI_MAX_SPELLS); - //Reset Instance Data for trash count if ((!instance->GetData(DATA_ALLIANCE_RETREAT) && me->GetEntry() == JAINA) || (instance->GetData(DATA_ALLIANCE_RETREAT) && me->GetEntry() == THRALL)) { @@ -405,9 +417,6 @@ void hyjalAI::Reset() instance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0); instance->SetData(DATA_RESET_TRASH_COUNT, 0); } - - //Visibility - DoHide = true; } void hyjalAI::EnterEvadeMode() diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.h b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.h index c91414eba9d..43afc58879c 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.h +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.h @@ -119,6 +119,8 @@ struct hyjalAI : public npc_escortAI { hyjalAI(Creature* creature); + void Initialize(); + void Reset(); // Generically used to reset our variables. Do *not* call in EnterEvadeMode as this may make problems if the raid is still in combat void EnterEvadeMode(); // Send creature back to spawn location and evade. diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp index 7537654c09c..8e1a78ea5f2 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp @@ -1135,9 +1135,15 @@ public: { npc_frost_wyrmAI(Creature* creature) : hyjal_trashAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); go = false; - Reset(); + } + + void Initialize() + { + FrostBreathTimer = 5000; + MoveTimer = 0; } bool go; @@ -1146,8 +1152,7 @@ public: void Reset() override { - FrostBreathTimer = 5000; - MoveTimer = 0; + Initialize(); me->SetDisableGravity(true); } @@ -1388,9 +1393,15 @@ public: { alliance_riflemanAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); SetCombatMovement(false); } + void Initialize() + { + ExplodeTimer = 5000 + rand32() % 5000; + } + uint32 ExplodeTimer; void JustDied(Unit* /*killer*/) override @@ -1399,7 +1410,7 @@ public: void Reset() override { - ExplodeTimer = 5000 + rand32() % 5000; + Initialize(); } void MoveInLineOfSight(Unit* who) override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp index 44e1067498d..0a666488e84 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp @@ -59,9 +59,20 @@ public: { boss_epochAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + uiStep = 1; + uiStepTimer = 26000; + uiCurseOfExertionTimer = 9300; + uiTimeWarpTimer = 25300; + uiTimeStopTimer = 21300; + uiWoundingStrikeTimer = 5300; + } + uint8 uiStep; uint32 uiStepTimer; @@ -74,12 +85,7 @@ public: void Reset() override { - uiStep = 1; - uiStepTimer = 26000; - uiCurseOfExertionTimer = 9300; - uiTimeWarpTimer = 25300; - uiTimeStopTimer = 21300; - uiWoundingStrikeTimer = 5300; + Initialize(); instance->SetData(DATA_EPOCH_EVENT, NOT_STARTED); } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp index 6d36a933687..d9356b724c0 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp @@ -73,7 +73,21 @@ public: { boss_mal_ganisAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); + uiOutroStep = 0; + } + + void Initialize() + { + bYelled = false; + bYelled2 = false; + Phase = COMBAT; + uiCarrionSwarmTimer = 6000; + uiMindBlastTimer = 11000; + uiVampiricTouchTimer = urand(10000, 15000); + uiSleepTimer = urand(15000, 20000); + uiOutroTimer = 1000; } uint32 uiCarrionSwarmTimer; @@ -93,16 +107,9 @@ public: void Reset() override { - bYelled = false; - bYelled2 = false; - Phase = COMBAT; - uiCarrionSwarmTimer = 6000; - uiMindBlastTimer = 11000; - uiVampiricTouchTimer = urand(10000, 15000); - uiSleepTimer = urand(15000, 20000); - uiOutroTimer = 1000; - - instance->SetData(DATA_MAL_GANIS_EVENT, NOT_STARTED); + Initialize(); + + instance->SetData(DATA_MAL_GANIS_EVENT, NOT_STARTED); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp index 4c26b30947f..c961bf9b2c6 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp @@ -58,10 +58,18 @@ public: { boss_meathookAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); Talk(SAY_SPAWN); } + void Initialize() + { + uiChainTimer = urand(12000, 17000); //seen on video 13, 17, 15, 12, 16 + uiDiseaseTimer = urand(2000, 4000); //approx 3s + uiFrenzyTimer = urand(21000, 26000); //made it up + } + uint32 uiChainTimer; uint32 uiDiseaseTimer; uint32 uiFrenzyTimer; @@ -70,9 +78,7 @@ public: void Reset() override { - uiChainTimer = urand(12000, 17000); //seen on video 13, 17, 15, 12, 16 - uiDiseaseTimer = urand(2000, 4000); //approx 3s - uiFrenzyTimer = urand(21000, 26000); //made it up + Initialize(); instance->SetData(DATA_MEATHOOK_EVENT, NOT_STARTED); } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp index 7c299b1feaa..1c35a38a5e3 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp @@ -63,10 +63,20 @@ public: { boss_salrammAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); Talk(SAY_SPAWN); } + void Initialize() + { + uiCurseFleshTimer = 30000; //30s DBM + uiExplodeGhoulTimer = urand(25000, 28000); //approx 6 sec after summon ghouls + uiShadowBoltTimer = urand(8000, 12000); // approx 10s + uiStealFleshTimer = 12345; + uiSummonGhoulsTimer = urand(19000, 24000); //on a video approx 24s after aggro + } + uint32 uiCurseFleshTimer; uint32 uiExplodeGhoulTimer; uint32 uiShadowBoltTimer; @@ -77,13 +87,9 @@ public: void Reset() override { - uiCurseFleshTimer = 30000; //30s DBM - uiExplodeGhoulTimer = urand(25000, 28000); //approx 6 sec after summon ghouls - uiShadowBoltTimer = urand(8000, 12000); // approx 10s - uiStealFleshTimer = 12345; - uiSummonGhoulsTimer = urand(19000, 24000); //on a video approx 24s after aggro + Initialize(); - instance->SetData(DATA_SALRAMM_EVENT, NOT_STARTED); + instance->SetData(DATA_SALRAMM_EVENT, NOT_STARTED); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp index fd832051421..b8a9b295161 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp @@ -351,8 +351,37 @@ public: { npc_arthasAI(Creature* creature) : npc_escortAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); - Reset(); + bStepping = false; + step = 0; + gossipStep = 0; + bossEvent = 0; + } + + void Initialize() + { + utherGUID = 0; + jainaGUID = 0; + + for (uint8 i = 0; i < 2; ++i) + citymenGUID[i] = 0; + + for (uint8 i = 0; i < ENCOUNTER_WAVES_MAX_SPAWNS; ++i) + waveGUID[i] = 0; + + for (uint8 i = 0; i < ENCOUNTER_DRACONIAN_NUMBER; ++i) + infiniteDraconianGUID[i] = 0; + + stalkerGUID = 0; + bossGUID = 0; + epochGUID = 0; + malganisGUID = 0; + infiniteGUID = 0; + + phaseTimer = 1000; + exorcismTimer = 7300; + wave = 0; } InstanceScript* instance; @@ -361,7 +390,6 @@ public: uint32 step; uint32 phaseTimer; uint32 gossipStep; - uint32 playerFaction; uint32 bossEvent; uint32 wave; @@ -381,23 +409,7 @@ public: void Reset() override { - utherGUID = 0; - jainaGUID = 0; - - for (uint8 i = 0; i < 2; ++i) - citymenGUID[i] = 0; - - for (uint8 i = 0; i < ENCOUNTER_WAVES_MAX_SPAWNS; ++i) - waveGUID[i] = 0; - - for (uint8 i = 0; i < ENCOUNTER_DRACONIAN_NUMBER; ++i) - infiniteDraconianGUID[i] = 0; - - stalkerGUID = 0; - bossGUID = 0; - epochGUID = 0; - malganisGUID = 0; - infiniteGUID = 0; + Initialize(); instance->SetData(DATA_ARTHAS_EVENT, NOT_STARTED); switch (instance->GetData(DATA_ARTHAS_EVENT)) @@ -410,9 +422,6 @@ public: gossipStep = 0; break; } - phaseTimer = 1000; - exorcismTimer = 7300; - wave = 0; } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp index b63075b681a..611ef38d626 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp @@ -61,9 +61,20 @@ public: { boss_captain_skarlocAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + Holy_Light_Timer = urand(20000, 30000); + Cleanse_Timer = 10000; + HammerOfJustice_Timer = urand(20000, 35000); + HolyShield_Timer = 240000; + DevotionAura_Timer = 3000; + Consecration_Timer = 8000; + } + InstanceScript* instance; uint32 Holy_Light_Timer; @@ -75,12 +86,7 @@ public: void Reset() override { - Holy_Light_Timer = urand(20000, 30000); - Cleanse_Timer = 10000; - HammerOfJustice_Timer = urand(20000, 35000); - HolyShield_Timer = 240000; - DevotionAura_Timer = 3000; - Consecration_Timer = 8000; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp index e27dec09802..1916e184dbb 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp @@ -59,9 +59,18 @@ public: { boss_epoch_hunterAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + SandBreath_Timer = urand(8000, 16000); + ImpendingDeath_Timer = urand(25000, 30000); + WingBuffet_Timer = 35000; + Mda_Timer = 40000; + } + InstanceScript* instance; uint32 SandBreath_Timer; @@ -71,10 +80,7 @@ public: void Reset() override { - SandBreath_Timer = urand(8000, 16000); - ImpendingDeath_Timer = urand(25000, 30000); - WingBuffet_Timer = 35000; - Mda_Timer = 40000; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_leutenant_drake.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_leutenant_drake.cpp index 2cf5169b530..8d23cf0a3e4 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_leutenant_drake.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_leutenant_drake.cpp @@ -114,7 +114,21 @@ public: struct boss_lieutenant_drakeAI : public ScriptedAI { - boss_lieutenant_drakeAI(Creature* creature) : ScriptedAI(creature) { } + boss_lieutenant_drakeAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + CanPatrol = true; + wpId = 0; + + Whirlwind_Timer = 20000; + Fear_Timer = 30000; + MortalStrike_Timer = 45000; + ExplodingShout_Timer = 25000; + } bool CanPatrol; uint32 wpId; @@ -126,13 +140,7 @@ public: void Reset() override { - CanPatrol = true; - wpId = 0; - - Whirlwind_Timer = 20000; - Fear_Timer = 30000; - MortalStrike_Timer = 45000; - ExplodingShout_Timer = 25000; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp index 1dc86cd4ad4..56e95fafece 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp @@ -276,11 +276,17 @@ public: { npc_thrall_old_hillsbradAI(Creature* creature) : npc_escortAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); HadMount = false; me->setActive(true); } + void Initialize() + { + LowHp = false; + } + InstanceScript* instance; bool LowHp; @@ -451,7 +457,7 @@ public: void Reset() override { - LowHp = false; + Initialize(); if (HadMount) DoMount(); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp index a1c4f057161..1fa104ada00 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp @@ -77,9 +77,19 @@ public: { npc_medivh_bmAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + SpellCorrupt_Timer = 0; + Check_Timer = 0; + Life75 = true; + Life50 = true; + Life25 = true; + } + InstanceScript* instance; uint32 SpellCorrupt_Timer; @@ -91,11 +101,7 @@ public: void Reset() override { - SpellCorrupt_Timer = 0; - Check_Timer = 0; - Life75 = true; - Life50 = true; - Life25 = true; + Initialize(); if (instance->GetData(TYPE_MEDIVH) == IN_PROGRESS) DoCast(me, SPELL_CHANNEL, true); @@ -265,23 +271,28 @@ public: { npc_time_riftAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + TimeRiftWave_Timer = 15000; + mRiftWaveCount = 0; + mWaveId = 0; + } + InstanceScript* instance; uint32 TimeRiftWave_Timer; uint8 mRiftWaveCount; - uint8 mPortalCount; uint8 mWaveId; void Reset() override { + Initialize(); - TimeRiftWave_Timer = 15000; - mRiftWaveCount = 0; - - mPortalCount = instance->GetData(DATA_PORTAL_COUNT); + uint8 mPortalCount = instance->GetData(DATA_PORTAL_COUNT); if (mPortalCount < 6) mWaveId = 0; diff --git a/src/server/scripts/Kalimdor/Maraudon/boss_celebras_the_cursed.cpp b/src/server/scripts/Kalimdor/Maraudon/boss_celebras_the_cursed.cpp index 15330643bd3..b8eb489461c 100644 --- a/src/server/scripts/Kalimdor/Maraudon/boss_celebras_the_cursed.cpp +++ b/src/server/scripts/Kalimdor/Maraudon/boss_celebras_the_cursed.cpp @@ -45,7 +45,17 @@ public: struct celebras_the_cursedAI : public ScriptedAI { - celebras_the_cursedAI(Creature* creature) : ScriptedAI(creature) { } + celebras_the_cursedAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + WrathTimer = 8000; + EntanglingRootsTimer = 2000; + CorruptForcesTimer = 30000; + } uint32 WrathTimer; uint32 EntanglingRootsTimer; @@ -53,9 +63,7 @@ public: void Reset() override { - WrathTimer = 8000; - EntanglingRootsTimer = 2000; - CorruptForcesTimer = 30000; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Kalimdor/Maraudon/boss_landslide.cpp b/src/server/scripts/Kalimdor/Maraudon/boss_landslide.cpp index 12016d2223a..59bcdc89171 100644 --- a/src/server/scripts/Kalimdor/Maraudon/boss_landslide.cpp +++ b/src/server/scripts/Kalimdor/Maraudon/boss_landslide.cpp @@ -45,7 +45,17 @@ public: struct boss_landslideAI : public ScriptedAI { - boss_landslideAI(Creature* creature) : ScriptedAI(creature) { } + boss_landslideAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + KnockAwayTimer = 8000; + TrampleTimer = 2000; + LandslideTimer = 0; + } uint32 KnockAwayTimer; uint32 TrampleTimer; @@ -53,9 +63,7 @@ public: void Reset() override { - KnockAwayTimer = 8000; - TrampleTimer = 2000; - LandslideTimer = 0; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/Maraudon/boss_noxxion.cpp b/src/server/scripts/Kalimdor/Maraudon/boss_noxxion.cpp index 8c7197b2942..a7aa487db90 100644 --- a/src/server/scripts/Kalimdor/Maraudon/boss_noxxion.cpp +++ b/src/server/scripts/Kalimdor/Maraudon/boss_noxxion.cpp @@ -44,7 +44,19 @@ public: struct boss_noxxionAI : public ScriptedAI { - boss_noxxionAI(Creature* creature) : ScriptedAI(creature) { } + boss_noxxionAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + ToxicVolleyTimer = 7000; + UppercutTimer = 16000; + AddsTimer = 19000; + InvisibleTimer = 15000; //Too much too low? + Invisible = false; + } uint32 ToxicVolleyTimer; uint32 UppercutTimer; @@ -54,11 +66,7 @@ public: void Reset() override { - ToxicVolleyTimer = 7000; - UppercutTimer = 16000; - AddsTimer = 19000; - InvisibleTimer = 15000; //Too much too low? - Invisible = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Kalimdor/Maraudon/boss_princess_theradras.cpp b/src/server/scripts/Kalimdor/Maraudon/boss_princess_theradras.cpp index 0d48d8f43c6..a36e8f09d21 100644 --- a/src/server/scripts/Kalimdor/Maraudon/boss_princess_theradras.cpp +++ b/src/server/scripts/Kalimdor/Maraudon/boss_princess_theradras.cpp @@ -47,7 +47,18 @@ public: struct boss_ptheradrasAI : public ScriptedAI { - boss_ptheradrasAI(Creature* creature) : ScriptedAI(creature) { } + boss_ptheradrasAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + DustfieldTimer = 8000; + BoulderTimer = 2000; + ThrashTimer = 5000; + RepulsiveGazeTimer = 23000; + } uint32 DustfieldTimer; uint32 BoulderTimer; @@ -56,10 +67,7 @@ public: void Reset() override { - DustfieldTimer = 8000; - BoulderTimer = 2000; - ThrashTimer = 5000; - RepulsiveGazeTimer = 23000; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp index e0a30eba2c9..ba7934e18a3 100644 --- a/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp +++ b/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp @@ -50,14 +50,22 @@ public: struct boss_amnennar_the_coldbringerAI : public BossAI { - boss_amnennar_the_coldbringerAI(Creature* creature) : BossAI(creature, DATA_AMNENNAR_THE_COLD_BRINGER) { } + boss_amnennar_the_coldbringerAI(Creature* creature) : BossAI(creature, DATA_AMNENNAR_THE_COLD_BRINGER) + { + Initialize(); + } - void Reset() override + void Initialize() { - _Reset(); hp60Spectrals = false; hp30Spectrals = false; - hp50 = false; + hp50 = false; + } + + void Reset() override + { + _Reset(); + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp index 162ce9b5359..19cc5316fa4 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp @@ -80,13 +80,19 @@ class boss_ayamiss : public CreatureScript { boss_ayamissAI(Creature* creature) : BossAI(creature, DATA_AYAMISS) { + Initialize(); } - void Reset() override + void Initialize() { - _Reset(); _phase = PHASE_AIR; _enraged = false; + } + + void Reset() override + { + _Reset(); + Initialize(); SetCombatMovement(false); } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp index ac490b1440d..cf6703a01f5 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp @@ -69,6 +69,7 @@ class boss_buru : public CreatureScript { boss_buruAI(Creature* creature) : BossAI(creature, DATA_BURU) { + _phase = 0; } void EnterEvadeMode() override diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp index f0e582dee95..adb6723d2af 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp @@ -53,12 +53,18 @@ class boss_kurinnaxx : public CreatureScript { boss_kurinnaxxAI(Creature* creature) : BossAI(creature, DATA_KURINNAXX) { + Initialize(); + } + + void Initialize() + { + _enraged = false; } void Reset() override { _Reset(); - _enraged = false; + Initialize(); events.ScheduleEvent(EVENT_MORTAL_WOUND, 8000); events.ScheduleEvent(EVENT_SANDTRAP, urand(5000, 15000)); events.ScheduleEvent(EVENT_TRASH, 1000); diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp index e123a84f88e..65de64fe6c5 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp @@ -60,13 +60,19 @@ class boss_moam : public CreatureScript { boss_moamAI(Creature* creature) : BossAI(creature, DATA_MOAM) { + Initialize(); + } + + void Initialize() + { + _isStonePhase = false; } void Reset() override { _Reset(); me->SetPower(POWER_MANA, 0); - _isStonePhase = false; + Initialize(); events.ScheduleEvent(EVENT_STONE_PHASE, 90000); //events.ScheduleEvent(EVENT_WIDE_SLASH, 11000); } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp index 256f76337b4..0180bbeddac 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp @@ -88,9 +88,17 @@ class boss_ossirian : public CreatureScript { boss_ossirianAI(Creature* creature) : BossAI(creature, DATA_OSSIRIAN) { + Initialize(); SaidIntro = false; } + void Initialize() + { + CrystalIterator = 0; + TriggerGUID = 0; + CrystalGUID = 0; + } + uint64 TriggerGUID; uint64 CrystalGUID; uint8 CrystalIterator; @@ -99,9 +107,7 @@ class boss_ossirian : public CreatureScript void Reset() override { _Reset(); - CrystalIterator = 0; - TriggerGUID = 0; - CrystalGUID = 0; + Initialize(); } void SpellHit(Unit* caster, SpellInfo const* spell) override diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_rajaxx.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_rajaxx.cpp index 0bb35f3842a..8369c343de4 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_rajaxx.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_rajaxx.cpp @@ -65,12 +65,18 @@ class boss_rajaxx : public CreatureScript { boss_rajaxxAI(Creature* creature) : BossAI(creature, DATA_RAJAXX) { + Initialize(); + } + + void Initialize() + { + enraged = false; } void Reset() override { _Reset(); - enraged = false; + Initialize(); events.ScheduleEvent(EVENT_DISARM, 10000); events.ScheduleEvent(EVENT_THUNDERCRASH, 12000); } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp index 189cb7854ad..be103541989 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp @@ -55,9 +55,20 @@ public: { boss_kriAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + Cleave_Timer = urand(4000, 8000); + ToxicVolley_Timer = urand(6000, 12000); + Check_Timer = 2000; + + VemDead = false; + Death = false; + } + InstanceScript* instance; uint32 Cleave_Timer; @@ -69,12 +80,7 @@ public: void Reset() override { - Cleave_Timer = urand(4000, 8000); - ToxicVolley_Timer = urand(6000, 12000); - Check_Timer = 2000; - - VemDead = false; - Death = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override @@ -148,9 +154,19 @@ public: { boss_vemAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + Charge_Timer = urand(15000, 27000); + KnockBack_Timer = urand(8000, 20000); + Enrage_Timer = 120000; + + Enraged = false; + } + InstanceScript* instance; uint32 Charge_Timer; @@ -161,11 +177,7 @@ public: void Reset() override { - Charge_Timer = urand(15000, 27000); - KnockBack_Timer = urand(8000, 20000); - Enrage_Timer = 120000; - - Enraged = false; + Initialize(); } void JustDied(Unit* /*killer*/) override @@ -237,9 +249,19 @@ public: { boss_yaujAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + Heal_Timer = urand(25000, 40000); + Fear_Timer = urand(12000, 24000); + Check_Timer = 2000; + + VemDead = false; + } + InstanceScript* instance; uint32 Heal_Timer; @@ -250,11 +272,7 @@ public: void Reset() override { - Heal_Timer = urand(25000, 40000); - Fear_Timer = urand(12000, 24000); - Check_Timer = 2000; - - VemDead = false; + Initialize(); } void JustDied(Unit* /*killer*/) override diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index 2cfd977fe99..c9795133d14 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -160,11 +160,29 @@ public: { eye_of_cthunAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); SetCombatMovement(false); } + void Initialize() + { + //Phase information + PhaseTimer = 50000; //First dark glare in 50 seconds + + //Eye beam phase 50 seconds + BeamTimer = 3000; + EyeTentacleTimer = 45000; //Always spawns 5 seconds before Dark Beam + ClawTentacleTimer = 12500; //4 per Eye beam phase (unsure if they spawn during Dark beam) + + //Dark Beam phase 35 seconds (each tick = 1 second, 35 ticks) + DarkGlareTick = 0; + DarkGlareTickTimer = 1000; + DarkGlareAngle = 0; + ClockWise = false; + } + InstanceScript* instance; //Global variables @@ -183,19 +201,7 @@ public: void Reset() override { - //Phase information - PhaseTimer = 50000; //First dark glare in 50 seconds - - //Eye beam phase 50 seconds - BeamTimer = 3000; - EyeTentacleTimer = 45000; //Always spawns 5 seconds before Dark Beam - ClawTentacleTimer = 12500; //4 per Eye beam phase (unsure if they spawn during Dark beam) - - //Dark Beam phase 35 seconds (each tick = 1 second, 35 ticks) - DarkGlareTick = 0; - DarkGlareTickTimer = 1000; - DarkGlareAngle = 0; - ClockWise = false; + Initialize(); //Reset flags me->RemoveAurasDueToSpell(SPELL_RED_COLORATION); @@ -454,11 +460,34 @@ public: { cthunAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); SetCombatMovement(false); instance = creature->GetInstanceScript(); } + void Initialize() + { + //One random wisper every 90 - 300 seconds + WisperTimer = 90000; + + //Phase information + PhaseTimer = 10000; //Emerge in 10 seconds + + //No hold player for transition + HoldPlayer = 0; + + //Body Phase + EyeTentacleTimer = 30000; + FleshTentaclesKilled = 0; + GiantClawTentacleTimer = 15000; //15 seconds into body phase (1 min repeat) + GiantEyeTentacleTimer = 45000; //15 seconds into body phase (1 min repeat) + StomachAcidTimer = 4000; //Every 4 seconds + StomachEnterTimer = 10000; //Every 10 seconds + StomachEnterVisTimer = 0; //Always 3.5 seconds after Stomach Enter Timer + StomachEnterTarget = 0; //Target to be teleported to stomach + } + InstanceScript* instance; //Out of combat whisper timer @@ -487,24 +516,7 @@ public: void Reset() override { - //One random wisper every 90 - 300 seconds - WisperTimer = 90000; - - //Phase information - PhaseTimer = 10000; //Emerge in 10 seconds - - //No hold player for transition - HoldPlayer = 0; - - //Body Phase - EyeTentacleTimer = 30000; - FleshTentaclesKilled = 0; - GiantClawTentacleTimer = 15000; //15 seconds into body phase (1 min repeat) - GiantEyeTentacleTimer = 45000; //15 seconds into body phase (1 min repeat) - StomachAcidTimer = 4000; //Every 4 seconds - StomachEnterTimer = 10000; //Every 10 seconds - StomachEnterVisTimer = 0; //Always 3.5 seconds after Stomach Enter Timer - StomachEnterTarget = 0; //Target to be teleported to stomach + Initialize(); //Clear players in stomach and outside Stomach_Map.clear(); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_fankriss.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_fankriss.cpp index 5947c9860ec..a98f3843d97 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_fankriss.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_fankriss.cpp @@ -53,23 +53,28 @@ public: struct boss_fankrissAI : public ScriptedAI { - boss_fankrissAI(Creature* creature) : ScriptedAI(creature) { } + boss_fankrissAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + MortalWound_Timer = urand(10000, 15000); + SpawnHatchlings_Timer = urand(6000, 12000); + SpawnSpawns_Timer = urand(15000, 45000); + } uint32 MortalWound_Timer; uint32 SpawnHatchlings_Timer; uint32 SpawnSpawns_Timer; - int Rand; - float RandX; - float RandY; Creature* Hatchling; Creature* Spawn; void Reset() override { - MortalWound_Timer = urand(10000, 15000); - SpawnHatchlings_Timer = urand(6000, 12000); - SpawnSpawns_Timer = urand(15000, 45000); + Initialize(); } void SummonSpawn(Unit* victim) @@ -77,7 +82,10 @@ public: if (!victim) return; - Rand = 10 + (rand32() % 10); + int Rand = 10 + (rand32() % 10); + float RandX = 0.f; + float RandY = 0.f; + switch (rand32() % 2) { case 0: RandX = 0.0f - Rand; break; diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_huhuran.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_huhuran.cpp index 5cc1670d8fb..b5512f29589 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_huhuran.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_huhuran.cpp @@ -51,7 +51,23 @@ public: struct boss_huhuranAI : public ScriptedAI { - boss_huhuranAI(Creature* creature) : ScriptedAI(creature) { } + boss_huhuranAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + Frenzy_Timer = urand(25000, 35000); + Wyvern_Timer = urand(18000, 28000); + Spit_Timer = 8000; + PoisonBolt_Timer = 4000; + NoxiousPoison_Timer = urand(10000, 20000); + FrenzyBack_Timer = 15000; + + Frenzy = false; + Berserk = false; + } uint32 Frenzy_Timer; uint32 Wyvern_Timer; @@ -65,15 +81,7 @@ public: void Reset() override { - Frenzy_Timer = urand(25000, 35000); - Wyvern_Timer = urand(18000, 28000); - Spit_Timer = 8000; - PoisonBolt_Timer = 4000; - NoxiousPoison_Timer = urand(10000, 20000); - FrenzyBack_Timer = 15000; - - Frenzy = false; - Berserk = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp index 26866de9aa8..092d7ed2a3b 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp @@ -48,7 +48,23 @@ public: struct boss_ouroAI : public ScriptedAI { - boss_ouroAI(Creature* creature) : ScriptedAI(creature) { } + boss_ouroAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + Sweep_Timer = urand(5000, 10000); + SandBlast_Timer = urand(20000, 35000); + Submerge_Timer = urand(90000, 150000); + Back_Timer = urand(30000, 45000); + ChangeTarget_Timer = urand(5000, 8000); + Spawn_Timer = urand(10000, 20000); + + Enrage = false; + Submerged = false; + } uint32 Sweep_Timer; uint32 SandBlast_Timer; @@ -62,15 +78,7 @@ public: void Reset() override { - Sweep_Timer = urand(5000, 10000); - SandBlast_Timer = urand(20000, 35000); - Submerge_Timer = urand(90000, 150000); - Back_Timer = urand(30000, 45000); - ChangeTarget_Timer = urand(5000, 8000); - Spawn_Timer = urand(10000, 20000); - - Enrage = false; - Submerged = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp index e9eb9d58ca8..b73a79506a9 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp @@ -53,7 +53,25 @@ public: struct boss_sarturaAI : public ScriptedAI { - boss_sarturaAI(Creature* creature) : ScriptedAI(creature) { } + boss_sarturaAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + WhirlWind_Timer = 30000; + WhirlWindRandom_Timer = urand(3000, 7000); + WhirlWindEnd_Timer = 15000; + AggroReset_Timer = urand(45000, 55000); + AggroResetEnd_Timer = 5000; + EnrageHard_Timer = 10 * 60000; + + WhirlWind = false; + AggroReset = false; + Enraged = false; + EnragedHard = false; + } uint32 WhirlWind_Timer; uint32 WhirlWindRandom_Timer; @@ -69,18 +87,7 @@ public: void Reset() override { - WhirlWind_Timer = 30000; - WhirlWindRandom_Timer = urand(3000, 7000); - WhirlWindEnd_Timer = 15000; - AggroReset_Timer = urand(45000, 55000); - AggroResetEnd_Timer = 5000; - EnrageHard_Timer = 10*60000; - - WhirlWind = false; - AggroReset = false; - Enraged = false; - EnragedHard = false; - + Initialize(); } void EnterCombat(Unit* /*who*/) override @@ -196,7 +203,23 @@ public: struct npc_sartura_royal_guardAI : public ScriptedAI { - npc_sartura_royal_guardAI(Creature* creature) : ScriptedAI(creature) { } + npc_sartura_royal_guardAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + WhirlWind_Timer = 30000; + WhirlWindRandom_Timer = urand(3000, 7000); + WhirlWindEnd_Timer = 15000; + AggroReset_Timer = urand(45000, 55000); + AggroResetEnd_Timer = 5000; + KnockBack_Timer = 10000; + + WhirlWind = false; + AggroReset = false; + } uint32 WhirlWind_Timer; uint32 WhirlWindRandom_Timer; @@ -210,15 +233,7 @@ public: void Reset() override { - WhirlWind_Timer = 30000; - WhirlWindRandom_Timer = urand(3000, 7000); - WhirlWindEnd_Timer = 15000; - AggroReset_Timer = urand(45000, 55000); - AggroResetEnd_Timer = 5000; - KnockBack_Timer = 10000; - - WhirlWind = false; - AggroReset = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp index 51384cc117d..62de8fbd607 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp @@ -55,12 +55,20 @@ class boss_skeram : public CreatureScript struct boss_skeramAI : public BossAI { - boss_skeramAI(Creature* creature) : BossAI(creature, DATA_SKERAM) { } + boss_skeramAI(Creature* creature) : BossAI(creature, DATA_SKERAM) + { + Initialize(); + } - void Reset() override + void Initialize() { _flag = 0; _hpct = 75.0f; + } + + void Reset() override + { + Initialize(); me->SetVisible(true); } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp index 3e02406b93d..cd250a50fb7 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp @@ -69,9 +69,24 @@ struct boss_twinemperorsAI : public ScriptedAI { boss_twinemperorsAI(Creature* creature): ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + Heal_Timer = 0; // first heal immediately when they get close together + Teleport_Timer = TELEPORTTIME; + AfterTeleport = false; + tspellcast = false; + AfterTeleportTimer = 0; + Abuse_Bug_Timer = urand(10000, 17000); + BugsTimer = 2000; + + DontYellWhenDead = false; + EnrageTimer = 15 * 60000; + } + InstanceScript* instance; uint32 Heal_Timer; @@ -89,16 +104,8 @@ struct boss_twinemperorsAI : public ScriptedAI void TwinReset() { - Heal_Timer = 0; // first heal immediately when they get close together - Teleport_Timer = TELEPORTTIME; - AfterTeleport = false; - tspellcast = false; - AfterTeleportTimer = 0; - Abuse_Bug_Timer = urand(10000, 17000); - BugsTimer = 2000; + Initialize(); me->ClearUnitState(UNIT_STATE_STUNNED); - DontYellWhenDead = false; - EnrageTimer = 15*60000; } Creature* GetOtherBoss() @@ -394,24 +401,28 @@ public: struct boss_veknilashAI : public boss_twinemperorsAI { bool IAmVeklor() {return false;} - boss_veknilashAI(Creature* creature) : boss_twinemperorsAI(creature) { } + boss_veknilashAI(Creature* creature) : boss_twinemperorsAI(creature) + { + Initialize(); + } + + void Initialize() + { + UpperCut_Timer = urand(14000, 29000); + UnbalancingStrike_Timer = urand(8000, 18000); + Scarabs_Timer = urand(7000, 14000); + } uint32 UpperCut_Timer; uint32 UnbalancingStrike_Timer; uint32 Scarabs_Timer; - int Rand; - int RandX; - int RandY; Creature* Summoned; void Reset() override { TwinReset(); - UpperCut_Timer = urand(14000, 29000); - UnbalancingStrike_Timer = urand(8000, 18000); - Scarabs_Timer = urand(7000, 14000); - + Initialize(); //Added. Can be removed if its included in DB. me->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, true); } @@ -480,25 +491,30 @@ public: struct boss_veklorAI : public boss_twinemperorsAI { bool IAmVeklor() {return true;} - boss_veklorAI(Creature* creature) : boss_twinemperorsAI(creature) { } + boss_veklorAI(Creature* creature) : boss_twinemperorsAI(creature) + { + Initialize(); + } + + void Initialize() + { + ShadowBolt_Timer = 0; + Blizzard_Timer = urand(15000, 20000); + ArcaneBurst_Timer = 1000; + Scorpions_Timer = urand(7000, 14000); + } uint32 ShadowBolt_Timer; uint32 Blizzard_Timer; uint32 ArcaneBurst_Timer; uint32 Scorpions_Timer; - int Rand; - int RandX; - int RandY; Creature* Summoned; void Reset() override { TwinReset(); - ShadowBolt_Timer = 0; - Blizzard_Timer = urand(15000, 20000); - ArcaneBurst_Timer = 1000; - Scorpions_Timer = urand(7000, 14000); + Initialize(); //Added. Can be removed if its included in DB. me->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, true); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp index a9ec3007e5d..7f223f21269 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp @@ -91,15 +91,23 @@ class boss_viscidus : public CreatureScript struct boss_viscidusAI : public BossAI { - boss_viscidusAI(Creature* creature) : BossAI(creature, DATA_VISCIDUS) { } + boss_viscidusAI(Creature* creature) : BossAI(creature, DATA_VISCIDUS) + { + Initialize(); + } - void Reset() override + void Initialize() { - _Reset(); _hitcounter = 0; _phase = PHASE_FROST; } + void Reset() override + { + _Reset(); + Initialize(); + } + void DamageTaken(Unit* attacker, uint32& /*damage*/) override { if (_phase != PHASE_MELEE) diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp index a0d57481c75..b8f6c0ed80e 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp @@ -92,8 +92,15 @@ public: aqsentinelAI(Creature* creature) : ScriptedAI(creature) { - ClearBuddyList(); + Initialize(); abselected = 0; // just initialization of variable + ability = 0; + } + + void Initialize() + { + ClearBuddyList(); + gatherOthersWhenAggro = true; } uint64 NearbyGUID[3]; @@ -183,8 +190,8 @@ public: void GetOtherSentinels(Unit* who) { - bool *chosenAbilities = new bool[9]; - memset(chosenAbilities, 0, 9*sizeof(bool)); + bool chosenAbilities[9]; + memset(chosenAbilities, 0, sizeof(chosenAbilities)); selectAbility(pickAbilityRandom(chosenAbilities)); ClearBuddyList(); @@ -207,8 +214,6 @@ public: DoYell("I dont have enough buddies.", LANG_NEUTRAL, 0);*/ SendMyListToBuddies(); CallBuddiesToAttack(who); - - delete[] chosenAbilities; } bool gatherOthersWhenAggro; @@ -228,8 +233,7 @@ public: } } } - ClearBuddyList(); - gatherOthersWhenAggro = true; + Initialize(); } void GainSentinelAbility(uint32 id) diff --git a/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp b/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp index f0035cc921c..4a2425d879f 100644 --- a/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp +++ b/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp @@ -59,16 +59,24 @@ public: struct boss_zum_rahAI : public BossAI { - boss_zum_rahAI(Creature* creature) : BossAI(creature, DATA_ZUM_RAH) { } + boss_zum_rahAI(Creature* creature) : BossAI(creature, DATA_ZUM_RAH) + { + Initialize(); + } - void Reset() override + void Initialize() { - me->setFaction(ZUMRAH_FRIENDLY_FACTION); // areatrigger sets faction to enemy _ward80 = false; _ward40 = false; _heal30 = false; } + void Reset() override + { + me->setFaction(ZUMRAH_FRIENDLY_FACTION); // areatrigger sets faction to enemy + Initialize(); + } + void EnterCombat(Unit* /*who*/) override { Talk(SAY_SANCT_INVADE); diff --git a/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp b/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp index 7c02ecdb8f2..47d269a00ff 100644 --- a/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp +++ b/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp @@ -104,8 +104,17 @@ public: { npc_sergeant_blyAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); postGossipStep = 0; + Text_Timer = 0; + PlayerGUID = 0; + } + + void Initialize() + { + ShieldBash_Timer = 5000; + Revenge_Timer = 8000; } InstanceScript* instance; @@ -118,8 +127,7 @@ public: void Reset() override { - ShieldBash_Timer = 5000; - Revenge_Timer = 8000; + Initialize(); me->setFaction(FACTION_FRIENDLY); } diff --git a/src/server/scripts/Kalimdor/boss_azuregos.cpp b/src/server/scripts/Kalimdor/boss_azuregos.cpp index db41213e94e..df0c9a9c16c 100644 --- a/src/server/scripts/Kalimdor/boss_azuregos.cpp +++ b/src/server/scripts/Kalimdor/boss_azuregos.cpp @@ -58,7 +58,10 @@ class boss_azuregos : public CreatureScript struct boss_azuregosAI : public WorldBossAI { - boss_azuregosAI(Creature* creature) : WorldBossAI(creature) { } + boss_azuregosAI(Creature* creature) : WorldBossAI(creature) + { + _enraged = false; + } void Reset() override { diff --git a/src/server/scripts/Kalimdor/zone_ashenvale.cpp b/src/server/scripts/Kalimdor/zone_ashenvale.cpp index 2b8dbdaab6c..500739b9404 100644 --- a/src/server/scripts/Kalimdor/zone_ashenvale.cpp +++ b/src/server/scripts/Kalimdor/zone_ashenvale.cpp @@ -61,13 +61,21 @@ public: struct npc_torekAI : public npc_escortAI { - npc_torekAI(Creature* creature) : npc_escortAI(creature) { } + npc_torekAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { - rend_Timer = 5000; + rend_Timer = 5000; thunderclap_Timer = 8000; - _completed = false; + _completed = false; + } + + void Reset() override + { + Initialize(); } void EnterCombat(Unit* /*who*/) override { } @@ -298,15 +306,23 @@ public: struct npc_muglashAI : public npc_escortAI { - npc_muglashAI(Creature* creature) : npc_escortAI(creature) { } + npc_muglashAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { eventTimer = 10000; waveId = 0; _isBrazierExtinguished = false; } + void Reset() override + { + Initialize(); + } + void EnterCombat(Unit* /*who*/) override { if (Player* player = GetPlayerForEscort()) diff --git a/src/server/scripts/Kalimdor/zone_azshara.cpp b/src/server/scripts/Kalimdor/zone_azshara.cpp index e62e17593ba..cec94617454 100644 --- a/src/server/scripts/Kalimdor/zone_azshara.cpp +++ b/src/server/scripts/Kalimdor/zone_azshara.cpp @@ -58,15 +58,23 @@ public: struct npc_spitelashesAI : public ScriptedAI { - npc_spitelashesAI(Creature* creature) : ScriptedAI(creature) { } + npc_spitelashesAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + morphtimer = 0; + spellhit = false; + } uint32 morphtimer; bool spellhit; void Reset() override { - morphtimer = 0; - spellhit = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } @@ -292,9 +300,12 @@ public: struct npc_rizzle_sprysprocketAI : public ScriptedAI { - npc_rizzle_sprysprocketAI(Creature* creature) : ScriptedAI(creature) { } + npc_rizzle_sprysprocketAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { SpellEscapeTimer = 1300; TeleportTimer = 3500; @@ -311,6 +322,11 @@ public: Reached = false; } + void Reset() override + { + Initialize(); + } + void EnterCombat(Unit* /*who*/) override { } void AttackStart(Unit* who) override @@ -475,7 +491,16 @@ public: struct npc_depth_chargeAI : public ScriptedAI { - npc_depth_chargeAI(Creature* creature) : ScriptedAI(creature) { } + npc_depth_chargeAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + WeMustDie = false; + WeMustDieTimer = 1000; + } bool WeMustDie; uint32 WeMustDieTimer; @@ -485,8 +510,7 @@ public: me->SetHover(true); me->SetSwim(true); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - WeMustDie = false; - WeMustDieTimer = 1000; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp index 6f02752d2fb..e6869dbf0f5 100644 --- a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp @@ -61,7 +61,21 @@ public: struct npc_draenei_survivorAI : public ScriptedAI { - npc_draenei_survivorAI(Creature* creature) : ScriptedAI(creature) { } + npc_draenei_survivorAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + pCaster = 0; + + SayThanksTimer = 0; + RunAwayTimer = 0; + SayHelpTimer = 10000; + + CanSayHelp = true; + } uint64 pCaster; @@ -73,13 +87,7 @@ public: void Reset() override { - pCaster = 0; - - SayThanksTimer = 0; - RunAwayTimer = 0; - SayHelpTimer = 10000; - - CanSayHelp = true; + Initialize(); DoCast(me, SPELL_IRRIDATION, true); @@ -193,22 +201,28 @@ public: { npc_engineer_spark_overgrindAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); NormFaction = creature->getFaction(); NpcFlags = creature->GetUInt32Value(UNIT_NPC_FLAGS); + } - if (creature->GetAreaId() == AREA_COVE || creature->GetAreaId() == AREA_ISLE) + void Initialize() + { + DynamiteTimer = 8000; + EmoteTimer = urand(120000, 150000); + + if (me->GetAreaId() == AREA_COVE || me->GetAreaId() == AREA_ISLE) IsTreeEvent = true; + else + IsTreeEvent = false; } void Reset() override { - DynamiteTimer = 8000; - EmoteTimer = urand(120000, 150000); + Initialize(); me->setFaction(NormFaction); me->SetUInt32Value(UNIT_NPC_FLAGS, NpcFlags); - - IsTreeEvent = false; } void EnterCombat(Unit* who) override @@ -410,7 +424,18 @@ public: struct npc_geezleAI : public ScriptedAI { - npc_geezleAI(Creature* creature) : ScriptedAI(creature) { } + npc_geezleAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + SparkGUID = 0; + Step = 0; + EventStarted = false; + SayTimer = 0; + } uint64 SparkGUID; @@ -421,8 +446,7 @@ public: void Reset() override { - SparkGUID = 0; - Step = 0; + Initialize(); StartEvent(); } @@ -582,15 +606,23 @@ public: struct npc_death_ravagerAI : public ScriptedAI { - npc_death_ravagerAI(Creature* creature) : ScriptedAI(creature){ } + npc_death_ravagerAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + RendTimer = 30000; + EnragingBiteTimer = 20000; + } uint32 RendTimer; uint32 EnragingBiteTimer; void Reset() override { - RendTimer = 30000; - EnragingBiteTimer = 20000; + Initialize(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->SetReactState(REACT_PASSIVE); @@ -648,7 +680,16 @@ class npc_stillpine_capitive : public CreatureScript struct npc_stillpine_capitiveAI : public ScriptedAI { - npc_stillpine_capitiveAI(Creature* creature) : ScriptedAI(creature) { } + npc_stillpine_capitiveAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + _playerGUID = 0; + _movementComplete = false; + } void Reset() override { @@ -658,8 +699,7 @@ class npc_stillpine_capitive : public CreatureScript cage->SetGoState(GO_STATE_READY); } _events.Reset(); - _player = NULL; - _movementComplete = false; + Initialize(); } void StartMoving(Player* owner) @@ -667,7 +707,7 @@ class npc_stillpine_capitive : public CreatureScript if (owner) { Talk(CAPITIVE_SAY, owner); - _player = owner; + _playerGUID = owner->GetGUID(); } Position pos = me->GetNearPosition(3.0f, 0.0f); me->GetMotionMaster()->MovePoint(POINT_INIT, pos); @@ -678,7 +718,7 @@ class npc_stillpine_capitive : public CreatureScript if (type != POINT_MOTION_TYPE || id != POINT_INIT) return; - if (_player) + if (Player* _player = ObjectAccessor::GetPlayer(*me, _playerGUID)) _player->KilledMonsterCredit(me->GetEntry(), me->GetGUID()); _movementComplete = true; @@ -697,7 +737,7 @@ class npc_stillpine_capitive : public CreatureScript } private: - Player* _player; + uint64 _playerGUID; EventMap _events; bool _movementComplete; }; diff --git a/src/server/scripts/Kalimdor/zone_darkshore.cpp b/src/server/scripts/Kalimdor/zone_darkshore.cpp index 43a533ada01..22c619f9a90 100644 --- a/src/server/scripts/Kalimdor/zone_darkshore.cpp +++ b/src/server/scripts/Kalimdor/zone_darkshore.cpp @@ -65,13 +65,21 @@ public: struct npc_kerlonianAI : public FollowerAI { - npc_kerlonianAI(Creature* creature) : FollowerAI(creature) { } + npc_kerlonianAI(Creature* creature) : FollowerAI(creature) + { + Initialize(); + } + + void Initialize() + { + FallAsleepTimer = urand(10000, 45000); + } uint32 FallAsleepTimer; void Reset() override { - FallAsleepTimer = urand(10000, 45000); + Initialize(); } void MoveInLineOfSight(Unit* who) override diff --git a/src/server/scripts/Kalimdor/zone_durotar.cpp b/src/server/scripts/Kalimdor/zone_durotar.cpp index a1df70522a8..e2f8dd0854d 100644 --- a/src/server/scripts/Kalimdor/zone_durotar.cpp +++ b/src/server/scripts/Kalimdor/zone_durotar.cpp @@ -51,7 +51,17 @@ public: struct npc_lazy_peonAI : public ScriptedAI { - npc_lazy_peonAI(Creature* creature) : ScriptedAI(creature) { } + npc_lazy_peonAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + PlayerGUID = 0; + RebuffTimer = 0; + work = false; + } uint64 PlayerGUID; @@ -60,9 +70,7 @@ public: void Reset() override { - PlayerGUID = 0; - RebuffTimer = 0; - work = false; + Initialize(); } void MovementInform(uint32 /*type*/, uint32 id) override @@ -360,6 +368,13 @@ class npc_troll_volunteer : public CreatureScript { npc_troll_volunteerAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); + _mountModel = 0; + } + + void Initialize() + { + _complete = false; } void InitializeAI() override @@ -391,7 +406,7 @@ class npc_troll_volunteer : public CreatureScript void Reset() override { - _complete = false; + Initialize(); me->AddAura(SPELL_VOLUNTEER_AURA, me); me->AddAura(SPELL_MOUNTING_CHECK, me); DoCast(me, SPELL_PETACT_AURA); diff --git a/src/server/scripts/Kalimdor/zone_moonglade.cpp b/src/server/scripts/Kalimdor/zone_moonglade.cpp index 0c07d5dc6df..268db8da779 100644 --- a/src/server/scripts/Kalimdor/zone_moonglade.cpp +++ b/src/server/scripts/Kalimdor/zone_moonglade.cpp @@ -298,9 +298,20 @@ public: public: npc_clintar_spiritAI(Creature* creature) : npc_escortAI(creature) { + Initialize(); PlayerGUID = 0; } + void Initialize() + { + Step = 0; + CurrWP = 0; + EventTimer = 0; + PlayerGUID = 0; + checkPlayerTimer = 1000; + EventOnWait = false; + } + uint8 Step; uint32 CurrWP; uint32 EventTimer; @@ -313,14 +324,7 @@ public: void Reset() override { if (!PlayerGUID) - { - Step = 0; - CurrWP = 0; - EventTimer = 0; - PlayerGUID = 0; - checkPlayerTimer = 1000; - EventOnWait = false; - } + Initialize(); } void IsSummonedBy(Unit* /*summoner*/) override diff --git a/src/server/scripts/Kalimdor/zone_mulgore.cpp b/src/server/scripts/Kalimdor/zone_mulgore.cpp index fa35371f3f2..289d7282ac6 100644 --- a/src/server/scripts/Kalimdor/zone_mulgore.cpp +++ b/src/server/scripts/Kalimdor/zone_mulgore.cpp @@ -62,7 +62,19 @@ public: struct npc_kyle_frenziedAI : public ScriptedAI { - npc_kyle_frenziedAI(Creature* creature) : ScriptedAI(creature) { } + npc_kyle_frenziedAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + EventActive = false; + IsMovingToLunch = false; + PlayerGUID = 0; + EventTimer = 5000; + EventPhase = 0; + } bool EventActive; bool IsMovingToLunch; @@ -72,11 +84,7 @@ public: void Reset() override { - EventActive = false; - IsMovingToLunch = false; - PlayerGUID = 0; - EventTimer = 5000; - EventPhase = 0; + Initialize(); if (me->GetEntry() == NPC_KYLE_FRIENDLY) me->UpdateEntry(NPC_KYLE_FRENZIED); @@ -235,7 +243,17 @@ public: struct npc_plains_visionAI : public ScriptedAI { - npc_plains_visionAI(Creature* creature) : ScriptedAI(creature) { } + npc_plains_visionAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + WayPointId = 0; + newWaypoint = true; + amountWP = 49; + } bool newWaypoint; uint8 WayPointId; @@ -243,9 +261,7 @@ public: void Reset() override { - WayPointId = 0; - newWaypoint = true; - amountWP = 49; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Kalimdor/zone_orgrimmar.cpp b/src/server/scripts/Kalimdor/zone_orgrimmar.cpp index 5ae50ff7c8e..fd666b7fcd7 100644 --- a/src/server/scripts/Kalimdor/zone_orgrimmar.cpp +++ b/src/server/scripts/Kalimdor/zone_orgrimmar.cpp @@ -64,7 +64,19 @@ public: struct npc_shenthulAI : public ScriptedAI { - npc_shenthulAI(Creature* creature) : ScriptedAI(creature) { } + npc_shenthulAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + CanTalk = false; + CanEmote = false; + SaluteTimer = 6000; + ResetTimer = 0; + PlayerGUID = 0; + } bool CanTalk; bool CanEmote; @@ -74,11 +86,7 @@ public: void Reset() override { - CanTalk = false; - CanEmote = false; - SaluteTimer = 6000; - ResetTimer = 0; - PlayerGUID = 0; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } @@ -211,15 +219,23 @@ public: struct npc_thrall_warchiefAI : public ScriptedAI { - npc_thrall_warchiefAI(Creature* creature) : ScriptedAI(creature) { } + npc_thrall_warchiefAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + ChainLightningTimer = 2000; + ShockTimer = 8000; + } uint32 ChainLightningTimer; uint32 ShockTimer; void Reset() override { - ChainLightningTimer = 2000; - ShockTimer = 8000; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Kalimdor/zone_silithus.cpp b/src/server/scripts/Kalimdor/zone_silithus.cpp index 3ddf97c164d..55f36779145 100644 --- a/src/server/scripts/Kalimdor/zone_silithus.cpp +++ b/src/server/scripts/Kalimdor/zone_silithus.cpp @@ -422,7 +422,23 @@ public: struct npc_anachronos_the_ancientAI : public ScriptedAI { - npc_anachronos_the_ancientAI(Creature* creature) : ScriptedAI(creature) { } + npc_anachronos_the_ancientAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + AnimationTimer = 1500; + AnimationCount = 0; + AnachronosQuestTriggerGUID = 0; + MerithraGUID = 0; + ArygosGUID = 0; + CaelestraszGUID = 0; + FandralGUID = 0; + PlayerGUID = 0; + eventEnd = false; + } uint32 AnimationTimer; uint8 AnimationCount; @@ -437,15 +453,7 @@ public: void Reset() override { - AnimationTimer = 1500; - AnimationCount = 0; - AnachronosQuestTriggerGUID = 0; - MerithraGUID = 0; - ArygosGUID = 0; - CaelestraszGUID = 0; - FandralGUID = 0; - PlayerGUID = 0; - eventEnd = false; + Initialize(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } @@ -750,7 +758,22 @@ public: struct npc_qiraj_war_spawnAI : public ScriptedAI { - npc_qiraj_war_spawnAI(Creature* creature) : ScriptedAI(creature) { } + npc_qiraj_war_spawnAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + SpellTimer1 = 0; + SpellTimer2 = 0; + SpellTimer3 = 0; + SpellTimer4 = 0; + } + + void Initialize() + { + MobGUID = 0; + PlayerGUID = 0; + Timers = false; + hasTarget = false; + } uint64 MobGUID; uint64 PlayerGUID; @@ -760,10 +783,7 @@ public: void Reset() override { - MobGUID = 0; - PlayerGUID = 0; - Timers = false; - hasTarget = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } @@ -863,7 +883,24 @@ public: struct npc_anachronos_quest_triggerAI : public ScriptedAI { - npc_anachronos_quest_triggerAI(Creature* creature) : ScriptedAI(creature) { } + npc_anachronos_quest_triggerAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + PlayerGUID = 0; + + WaveTimer = 2000; + AnnounceTimer = 1000; + LiveCount = 0; + WaveCount = 0; + + EventStarted = false; + Announced = false; + Failed = false; + } uint64 PlayerGUID; @@ -879,16 +916,7 @@ public: void Reset() override { - PlayerGUID = 0; - - WaveTimer = 2000; - AnnounceTimer = 1000; - LiveCount = 0; - WaveCount = 0; - - EventStarted = false; - Announced = false; - Failed = false; + Initialize(); me->SetVisible(false); } diff --git a/src/server/scripts/Kalimdor/zone_tanaris.cpp b/src/server/scripts/Kalimdor/zone_tanaris.cpp index 23e8e2f26ff..fce0608faaf 100644 --- a/src/server/scripts/Kalimdor/zone_tanaris.cpp +++ b/src/server/scripts/Kalimdor/zone_tanaris.cpp @@ -64,7 +64,21 @@ public: struct npc_aquementasAI : public ScriptedAI { - npc_aquementasAI(Creature* creature) : ScriptedAI(creature) { } + npc_aquementasAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + SendItemTimer = 0; + SwitchFactionTimer = 10000; + + isFriendly = true; + + AquaJetTimer = 5000; + FrostShockTimer = 1000; + } uint32 SendItemTimer; uint32 SwitchFactionTimer; @@ -75,13 +89,8 @@ public: void Reset() override { - SendItemTimer = 0; - SwitchFactionTimer = 10000; + Initialize(); me->setFaction(35); - isFriendly = true; - - AquaJetTimer = 5000; - FrostShockTimer = 1000; } void SendItem(Unit* receiver) @@ -526,7 +535,19 @@ public: struct npc_toogaAI : public FollowerAI { - npc_toogaAI(Creature* creature) : FollowerAI(creature) { } + npc_toogaAI(Creature* creature) : FollowerAI(creature) + { + Initialize(); + } + + void Initialize() + { + CheckSpeechTimer = 2500; + PostEventTimer = 1000; + PhasePostEvent = 0; + + TortaGUID = 0; + } uint32 CheckSpeechTimer; uint32 PostEventTimer; @@ -536,11 +557,7 @@ public: void Reset() override { - CheckSpeechTimer = 2500; - PostEventTimer = 1000; - PhasePostEvent = 0; - - TortaGUID = 0; + Initialize(); } void MoveInLineOfSight(Unit* who) override diff --git a/src/server/scripts/Kalimdor/zone_the_barrens.cpp b/src/server/scripts/Kalimdor/zone_the_barrens.cpp index b158422054f..ced964048c2 100644 --- a/src/server/scripts/Kalimdor/zone_the_barrens.cpp +++ b/src/server/scripts/Kalimdor/zone_the_barrens.cpp @@ -200,9 +200,17 @@ public: { npc_taskmaster_fizzuleAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); factionNorm = creature->getFaction(); } + void Initialize() + { + IsFriend = false; + ResetTimer = 120000; + FlareCount = 0; + } + uint32 factionNorm; bool IsFriend; uint32 ResetTimer; @@ -210,9 +218,7 @@ public: void Reset() override { - IsFriend = false; - ResetTimer = 120000; - FlareCount = 0; + Initialize(); me->setFaction(factionNorm); } @@ -314,20 +320,12 @@ public: struct npc_twiggy_flatheadAI : public ScriptedAI { - npc_twiggy_flatheadAI(Creature* creature) : ScriptedAI(creature) { } - - bool EventInProgress; - bool EventGrate; - bool EventBigWill; - bool ChallengerDown[6]; - uint8 Wave; - uint32 WaveTimer; - uint32 ChallengerChecker; - uint64 PlayerGUID; - uint64 AffrayChallenger[6]; - uint64 BigWill; + npc_twiggy_flatheadAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { EventInProgress = false; EventGrate = false; @@ -345,6 +343,22 @@ public: BigWill = 0; } + bool EventInProgress; + bool EventGrate; + bool EventBigWill; + bool ChallengerDown[6]; + uint8 Wave; + uint32 WaveTimer; + uint32 ChallengerChecker; + uint64 PlayerGUID; + uint64 AffrayChallenger[6]; + uint64 BigWill; + + void Reset() override + { + Initialize(); + } + void MoveInLineOfSight(Unit* who) override { if (!who || !who->IsAlive() || EventInProgress) diff --git a/src/server/scripts/Kalimdor/zone_thousand_needles.cpp b/src/server/scripts/Kalimdor/zone_thousand_needles.cpp index b36037d9995..9092d4e06e5 100644 --- a/src/server/scripts/Kalimdor/zone_thousand_needles.cpp +++ b/src/server/scripts/Kalimdor/zone_thousand_needles.cpp @@ -324,14 +324,23 @@ public: struct npc_pluckyAI : public ScriptedAI { - npc_pluckyAI(Creature* creature) : ScriptedAI(creature) { NormFaction = creature->getFaction(); } + npc_pluckyAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + NormFaction = creature->getFaction(); + } + + void Initialize() + { + ResetTimer = 120000; + } uint32 NormFaction; uint32 ResetTimer; void Reset() override { - ResetTimer = 120000; + Initialize(); if (me->getFaction() != NormFaction) me->setFaction(NormFaction); diff --git a/src/server/scripts/Kalimdor/zone_thunder_bluff.cpp b/src/server/scripts/Kalimdor/zone_thunder_bluff.cpp index 3b303ffa463..40b68270c9d 100644 --- a/src/server/scripts/Kalimdor/zone_thunder_bluff.cpp +++ b/src/server/scripts/Kalimdor/zone_thunder_bluff.cpp @@ -79,7 +79,19 @@ public: struct npc_cairne_bloodhoofAI : public ScriptedAI { - npc_cairne_bloodhoofAI(Creature* creature) : ScriptedAI(creature) { } + npc_cairne_bloodhoofAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + BerserkerChargeTimer = 30000; + CleaveTimer = 5000; + MortalStrikeTimer = 10000; + ThunderclapTimer = 15000; + UppercutTimer = 10000; + } uint32 BerserkerChargeTimer; uint32 CleaveTimer; @@ -89,11 +101,7 @@ public: void Reset() override { - BerserkerChargeTimer = 30000; - CleaveTimer = 5000; - MortalStrikeTimer = 10000; - ThunderclapTimer = 15000; - UppercutTimer = 10000; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Kalimdor/zone_ungoro_crater.cpp b/src/server/scripts/Kalimdor/zone_ungoro_crater.cpp index a1e4467e9fb..ea4c743b8a5 100644 --- a/src/server/scripts/Kalimdor/zone_ungoro_crater.cpp +++ b/src/server/scripts/Kalimdor/zone_ungoro_crater.cpp @@ -77,7 +77,15 @@ public: struct npc_ameAI : public npc_escortAI { - npc_ameAI(Creature* creature) : npc_escortAI(creature) { } + npc_ameAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + DemoralizingShoutTimer = 5000; + } uint32 DemoralizingShoutTimer; @@ -112,7 +120,7 @@ public: void Reset() override { - DemoralizingShoutTimer = 5000; + Initialize(); } void JustSummoned(Creature* summoned) override @@ -194,7 +202,18 @@ public: struct npc_ringoAI : public FollowerAI { - npc_ringoAI(Creature* creature) : FollowerAI(creature) { } + npc_ringoAI(Creature* creature) : FollowerAI(creature) + { + Initialize(); + } + + void Initialize() + { + FaintTimer = urand(30000, 60000); + EndEventProgress = 0; + EndEventTimer = 1000; + SpraggleGUID = 0; + } uint32 FaintTimer; uint32 EndEventProgress; @@ -204,10 +223,7 @@ public: void Reset() override { - FaintTimer = urand(30000, 60000); - EndEventProgress = 0; - EndEventTimer = 1000; - SpraggleGUID = 0; + Initialize(); } void MoveInLineOfSight(Unit* who) override diff --git a/src/server/scripts/Kalimdor/zone_winterspring.cpp b/src/server/scripts/Kalimdor/zone_winterspring.cpp index 11b720ad8d5..58d9b115398 100644 --- a/src/server/scripts/Kalimdor/zone_winterspring.cpp +++ b/src/server/scripts/Kalimdor/zone_winterspring.cpp @@ -317,7 +317,17 @@ public: npc_ranshallaAI(Creature* creature) : npc_escortAI(creature), DialogueHelper(introDialogue) { - Reset(); + Initialize(); + _firstPriestessGUID = 0; + _secondPriestessGUID = 0; + _guardEluneGUID = 0; + _voiceEluneGUID = 0; + _altarGUID = 0; + } + + void Initialize() + { + _delayTimer = 0; } uint32 _delayTimer; @@ -330,7 +340,7 @@ public: void Reset() override { - _delayTimer = 0; + Initialize(); } // Called when the player activates the torch / altar diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp index d4dc5efb6d5..79449723a16 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp @@ -61,15 +61,23 @@ class boss_elder_nadox : public CreatureScript struct boss_elder_nadoxAI : public BossAI { - boss_elder_nadoxAI(Creature* creature) : BossAI(creature, DATA_ELDER_NADOX) { } + boss_elder_nadoxAI(Creature* creature) : BossAI(creature, DATA_ELDER_NADOX) + { + Initialize(); + } - void Reset() override + void Initialize() { - _Reset(); GuardianSummoned = false; GuardianDied = false; } + void Reset() override + { + _Reset(); + Initialize(); + } + void EnterCombat(Unit* /*who*/) override { _EnterCombat(); diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp index 1c042f4d185..b200a4e9825 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp @@ -63,9 +63,19 @@ public: { boss_volazjAI(Creature* creature) : ScriptedAI(creature), Summons(me) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + uiMindFlayTimer = 8 * IN_MILLISECONDS; + uiShadowBoltVolleyTimer = 5 * IN_MILLISECONDS; + uiShiverTimer = 15 * IN_MILLISECONDS; + // Used for Insanity handling + insanityHandled = 0; + } + InstanceScript* instance; uint32 uiMindFlayTimer; @@ -145,17 +155,13 @@ public: void Reset() override { - uiMindFlayTimer = 8*IN_MILLISECONDS; - uiShadowBoltVolleyTimer = 5*IN_MILLISECONDS; - uiShiverTimer = 15*IN_MILLISECONDS; + Initialize(); instance->SetBossState(DATA_HERALD_VOLAZJ, NOT_STARTED); instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_QUICK_DEMISE_START_EVENT); // Visible for all players in insanity me->SetPhaseMask((1|16|32|64|128|256), true); - // Used for Insanity handling - insanityHandled = 0; ResetPlayersPhaseMask(); diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp index 905761ce359..7ae8730d57b 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp @@ -64,11 +64,27 @@ public: { boss_jedoga_shadowseekerAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); bFirstTime = true; bPreDone = false; } + void Initialize() + { + uiOpFerTimer = urand(15 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + + uiCycloneTimer = 3 * IN_MILLISECONDS; + uiBoltTimer = 7 * IN_MILLISECONDS; + uiThunderTimer = 12 * IN_MILLISECONDS; + + bOpFerok = false; + bOpFerokFail = false; + bOnGround = false; + bCanDown = false; + volunteerWork = true; + } + InstanceScript* instance; uint32 uiOpFerTimer; @@ -86,17 +102,7 @@ public: void Reset() override { - uiOpFerTimer = urand(15*IN_MILLISECONDS, 20*IN_MILLISECONDS); - - uiCycloneTimer = 3*IN_MILLISECONDS; - uiBoltTimer = 7*IN_MILLISECONDS; - uiThunderTimer = 12*IN_MILLISECONDS; - - bOpFerok = false; - bOpFerokFail = false; - bOnGround = false; - bCanDown = false; - volunteerWork = true; + Initialize(); if (!bFirstTime) instance->SetBossState(DATA_JEDOGA_SHADOWSEEKER, FAIL); @@ -331,9 +337,16 @@ public: { npc_jedoga_initiandAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + bWalking = false; + bCheckTimer = 2 * IN_MILLISECONDS; + } + InstanceScript* instance; uint32 bCheckTimer; @@ -342,8 +355,7 @@ public: void Reset() override { - bWalking = false; - bCheckTimer = 2*IN_MILLISECONDS; + Initialize(); if (instance->GetBossState(DATA_JEDOGA_SHADOWSEEKER) != IN_PROGRESS) { diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp index bf5855c3318..49d0840f08a 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp @@ -87,7 +87,29 @@ public: { boss_anub_arakAI(Creature* creature) : ScriptedAI(creature), Summons(me) { + Initialize(); instance = creature->GetInstanceScript(); + GuardianSummoned = false; + VenomancerSummoned = false; + DatterSummoned = false; + UndergroundTimer = 0; + VenomancerTimer = 0; + DatterTimer = 0; + DelayTimer = 0; + ImpaleTarget = 0; + } + + void Initialize() + { + CarrionBeetlesTimer = 8 * IN_MILLISECONDS; + LeechingSwarmTimer = 20 * IN_MILLISECONDS; + ImpaleTimer = 9 * IN_MILLISECONDS; + PoundTimer = 15 * IN_MILLISECONDS; + + Phase = PHASE_MELEE; + UndergroundPhase = 0; + Channeling = false; + ImpalePhase = IMPALE_PHASE_TARGET; } InstanceScript* instance; @@ -101,7 +123,6 @@ public: uint32 CarrionBeetlesTimer; uint32 LeechingSwarmTimer; uint32 PoundTimer; - uint32 SubmergeTimer; uint32 UndergroundTimer; uint32 VenomancerTimer; uint32 DatterTimer; @@ -115,15 +136,7 @@ public: void Reset() override { - CarrionBeetlesTimer = 8*IN_MILLISECONDS; - LeechingSwarmTimer = 20*IN_MILLISECONDS; - ImpaleTimer = 9*IN_MILLISECONDS; - PoundTimer = 15*IN_MILLISECONDS; - - Phase = PHASE_MELEE; - UndergroundPhase = 0; - Channeling = false; - ImpalePhase = IMPALE_PHASE_TARGET; + Initialize(); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE); me->RemoveAura(SPELL_SUBMERGE); diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp index 10d34be46b6..f8c5c63cf91 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp @@ -54,11 +54,22 @@ public: { boss_hadronoxAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); fMaxDistance = 50.0f; bFirstTime = true; } + void Initialize() + { + uiAcidTimer = urand(10 * IN_MILLISECONDS, 14 * IN_MILLISECONDS); + uiLeechTimer = urand(3 * IN_MILLISECONDS, 9 * IN_MILLISECONDS); + uiPierceTimer = urand(1 * IN_MILLISECONDS, 3 * IN_MILLISECONDS); + uiGrabTimer = urand(15 * IN_MILLISECONDS, 19 * IN_MILLISECONDS); + uiDoorsTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); + uiCheckDistanceTimer = 2 * IN_MILLISECONDS; + } + InstanceScript* instance; uint32 uiAcidTimer; @@ -77,12 +88,7 @@ public: me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 9.0f); me->SetFloatValue(UNIT_FIELD_COMBATREACH, 9.0f); - uiAcidTimer = urand(10*IN_MILLISECONDS, 14*IN_MILLISECONDS); - uiLeechTimer = urand(3*IN_MILLISECONDS, 9*IN_MILLISECONDS); - uiPierceTimer = urand(1*IN_MILLISECONDS, 3*IN_MILLISECONDS); - uiGrabTimer = urand(15*IN_MILLISECONDS, 19*IN_MILLISECONDS); - uiDoorsTimer = urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS); - uiCheckDistanceTimer = 2*IN_MILLISECONDS; + Initialize(); if (instance->GetBossState(DATA_HADRONOX) != DONE && !bFirstTime) instance->SetBossState(DATA_HADRONOX, FAIL); diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp index 4c3ca322574..77ced6acef1 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp @@ -130,14 +130,22 @@ public: struct boss_sartharionAI : public BossAI { - boss_sartharionAI(Creature* creature) : BossAI(creature, DATA_SARTHARION) { } + boss_sartharionAI(Creature* creature) : BossAI(creature, DATA_SARTHARION) + { + Initialize(); + } - void Reset() override + void Initialize() { - _isBerserk = false; + _isBerserk = false; _isSoftEnraged = false; _isHardEnraged = false; - drakeCount = 0; + drakeCount = 0; + } + + void Reset() override + { + Initialize(); if (me->HasAura(SPELL_TWILIGHT_REVENGE)) me->RemoveAurasDueToSpell(SPELL_TWILIGHT_REVENGE); |