From cd48ee01c0b1465c5b07427bb6fe9baa57f053b9 Mon Sep 17 00:00:00 2001 From: Malcrom Date: Sun, 21 Sep 2014 10:46:49 -0230 Subject: Scripting/Shadowmoon Vally: Added scripting for Infernal Attackers. --- .../scripts/Outland/zone_shadowmoon_valley.cpp | 139 +++++++++++++++++++++ 1 file changed, 139 insertions(+) (limited to 'src') diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index 54a7455d3f8..fe323452c29 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -24,6 +24,8 @@ SDCategory: Shadowmoon Valley EndScriptData */ /* ContentData +npc_invis_infernal_caster +npc_infernal_attacker npc_mature_netherwing_drake npc_enslaved_netherwing_drake npc_drake_dealer_hurlunk @@ -47,6 +49,141 @@ EndContentData */ #include "Player.h" #include "WorldSession.h" +/*##### +# npc_invis_infernal_caster +#####*/ + +enum InvisInfernalCaster +{ + EVENT_CAST_SUMMON_INFERNAL = 1, + NPC_INFERNAL_ATTACKER = 21419, + MODEL_INVISIBLE = 20577, + MODEL_INFERNAL = 17312, + SPELL_SUMMON_INFERNAL = 37277, + TYPE_INFERNAL = 1, + DATA_DIED = 1 +}; + +class npc_invis_infernal_caster : public CreatureScript +{ +public: + npc_invis_infernal_caster() : CreatureScript("npc_invis_infernal_caster") { } + + struct npc_invis_infernal_casterAI : public ScriptedAI + { + npc_invis_infernal_casterAI(Creature* creature) : ScriptedAI(creature) { } + + void Reset() override + { + ground = me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZMinusOffset()); + SummonInfernal(); + events.ScheduleEvent(EVENT_CAST_SUMMON_INFERNAL, urand(1000, 3000)); + } + + void SetData(uint32 id, uint32 data) override + { + if (id == TYPE_INFERNAL && data == DATA_DIED) + SummonInfernal(); + } + + void SummonInfernal() + { + Creature* infernal = me->SummonCreature(NPC_INFERNAL_ATTACKER, me->GetPositionX(), me->GetPositionY(), ground + 0.05f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); + infernalGUID = infernal->GetGUID(); + } + + void UpdateAI(uint32 diff) override + { + events.Update(diff); + + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_CAST_SUMMON_INFERNAL: + { + if (Unit* infernal = ObjectAccessor::GetUnit(*me, infernalGUID)) + if (infernal->GetDisplayId() == MODEL_INVISIBLE) + me->CastSpell(infernal, SPELL_SUMMON_INFERNAL, true); + events.ScheduleEvent(EVENT_CAST_SUMMON_INFERNAL, 12000); + break; + } + default: + break; + } + } + } + + private: + EventMap events; + ObjectGuid infernalGUID; + float ground; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_invis_infernal_casterAI(creature); + } +}; + +/*##### +# npc_infernal_attacker +#####*/ + +class npc_infernal_attacker : public CreatureScript +{ +public: + npc_infernal_attacker() : CreatureScript("npc_infernal_attacker") { } + + struct npc_infernal_attackerAI : public ScriptedAI + { + npc_infernal_attackerAI(Creature* creature) : ScriptedAI(creature) { } + + void Reset() override + { + me->SetDisplayId(MODEL_INVISIBLE); + me->GetMotionMaster()->MoveRandom(5.0f); + } + + void IsSummonedBy(Unit* summoner) override + { + if (summoner->ToCreature()) + caster = summoner->ToCreature(); + } + + void JustDied(Unit* /*killer*/) override + { + if (caster) + caster->AI()->SetData(TYPE_INFERNAL, DATA_DIED); + } + + void SpellHit(Unit* /*caster*/, const SpellInfo* spell) override + { + if (spell->Id == SPELL_SUMMON_INFERNAL) + { + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_PACIFIED | UNIT_FLAG_NOT_SELECTABLE); + me->SetDisplayId(MODEL_INFERNAL); + } + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } + + private: + Creature* caster; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_infernal_attackerAI(creature); + } +}; + /*##### # npc_mature_netherwing_drake #####*/ @@ -1826,6 +1963,8 @@ public: void AddSC_shadowmoon_valley() { + new npc_invis_infernal_caster(); + new npc_infernal_attacker(); new npc_mature_netherwing_drake(); new npc_enslaved_netherwing_drake(); new npc_dragonmaw_peon(); -- cgit v1.2.3 From 4892408ed0ffb1dc1c0b075d939ffd010a859b78 Mon Sep 17 00:00:00 2001 From: ShinDarth Date: Sun, 21 Sep 2014 15:21:30 +0200 Subject: Core/ObjectMgr: corrected error labels --- src/server/game/Globals/ObjectMgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 48f544cba2b..f9774ac763e 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -647,13 +647,13 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) if (cInfo->minlevel > difficultyInfo->minlevel) { - TC_LOG_ERROR("sql.sql", "Creature (Entry: %u, minlevel %u) has different `minlevel` in difficulty %u mode (Entry: %u, minlevel %u).", + TC_LOG_ERROR("sql.sql", "Creature (Entry: %u, minlevel %u) has lower `minlevel` in difficulty %u mode (Entry: %u, minlevel %u).", cInfo->Entry, cInfo->minlevel, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->minlevel); } if (cInfo->maxlevel > difficultyInfo->maxlevel) { - TC_LOG_ERROR("sql.sql", "Creature (Entry: %u, maxlevel %u) has different `maxlevel` in difficulty %u mode (Entry: %u, maxlevel %u).", + TC_LOG_ERROR("sql.sql", "Creature (Entry: %u, maxlevel %u) has lower `maxlevel` in difficulty %u mode (Entry: %u, maxlevel %u).", cInfo->Entry, cInfo->maxlevel, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->maxlevel); } -- cgit v1.2.3 From b71f8367e495d27e1bade8202335ee6403d10032 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 21 Sep 2014 17:21:04 +0200 Subject: Scripts/Shadowmoon Valley: Fix static analysis issues added in cd48ee01c0b1465c5b07427bb6fe9baa57f053b9 Fix static analysis issues added in cd48ee01c0b1465c5b07427bb6fe9baa57f053b9 about uninitialized values and pointers possibly point to free'd memory being dereferenced. In memory of all the developers who got banned from IRC in the process of fixing these issues. --- src/server/scripts/Outland/zone_shadowmoon_valley.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index fe323452c29..9eba6fdef0b 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -71,7 +71,10 @@ public: struct npc_invis_infernal_casterAI : public ScriptedAI { - npc_invis_infernal_casterAI(Creature* creature) : ScriptedAI(creature) { } + npc_invis_infernal_casterAI(Creature* creature) : ScriptedAI(creature) + { + ground = 0.f; + } void Reset() override { @@ -148,12 +151,12 @@ public: void IsSummonedBy(Unit* summoner) override { if (summoner->ToCreature()) - caster = summoner->ToCreature(); + casterGUID = summoner->ToCreature()->GetGUID();; } void JustDied(Unit* /*killer*/) override { - if (caster) + if (Creature* caster = ObjectAccessor::GetCreature(*me, casterGUID)) caster->AI()->SetData(TYPE_INFERNAL, DATA_DIED); } @@ -175,7 +178,7 @@ public: } private: - Creature* caster; + ObjectGuid casterGUID; }; CreatureAI* GetAI(Creature* creature) const override -- cgit v1.2.3 From 1d8feb271c3c30858dd63bc9f402892d98a0458d Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Sun, 21 Sep 2014 17:45:31 +0200 Subject: Core:/SmartScript: Added log for item has credit spell blabla --- src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 27 ++++++++++++++++++++-- src/server/game/AI/SmartScripts/SmartScriptMgr.h | 2 ++ 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index a5caf154a98..0217a9c3fcd 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -883,10 +883,9 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) CacheSpellContainerBounds sBounds = GetSummonGameObjectSpellContainerBounds(e.action.summonGO.entry); for (CacheSpellContainer::const_iterator itr = sBounds.first; itr != sBounds.second; ++itr) TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u gameobject summon: There is a summon spell for gameobject entry %u (SpellId: %u, effect: %u)", - e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.summonGO.entry, itr->second.first, itr->second.second); + e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.summonGO.entry, itr->second.first, itr->second.second); break; } - case SMART_ACTION_ADD_ITEM: case SMART_ACTION_REMOVE_ITEM: if (!IsItemValid(e, e.action.item.entry)) return false; @@ -894,6 +893,20 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) if (!NotNULL(e, e.action.item.count)) return false; break; + case SMART_ACTION_ADD_ITEM: + { + if (!IsItemValid(e, e.action.item.entry)) + return false; + + if (!NotNULL(e, e.action.item.count)) + return false; + + CacheSpellContainerBounds sBounds = GetCreditItemSpellContainerBounds(e.action.item.entry); + for (CacheSpellContainer::const_iterator itr = sBounds.first; itr != sBounds.second; ++itr) + TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u Create Item: There is a create item spell for item %u (SpellId: %u effect: %u)", + e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.item.entry, itr->second.first, itr->second.second); + break; + } case SMART_ACTION_TELEPORT: if (!sMapStore.LookupEntry(e.action.teleport.mapID)) { @@ -1135,6 +1148,9 @@ void SmartAIMgr::LoadHelperStores() else if (spellInfo->Effects[j].IsEffect(SPELL_EFFECT_KILL_CREDIT) || spellInfo->Effects[j].IsEffect(SPELL_EFFECT_KILL_CREDIT2)) KillCreditSpellStore.insert(std::make_pair(uint32(spellInfo->Effects[j].MiscValue), std::make_pair(i, SpellEffIndex(j)))); + + else if (spellInfo->Effects[j].IsEffect(SPELL_EFFECT_CREATE_ITEM)) + CreateItemSpellStore.insert(std::make_pair(uint32(spellInfo->Effects[j].ItemType), std::make_pair(i, SpellEffIndex(j)))); } } @@ -1146,6 +1162,7 @@ void SmartAIMgr::UnLoadHelperStores() SummonCreatureSpellStore.clear(); SummonGameObjectSpellStore.clear(); KillCreditSpellStore.clear(); + CreateItemSpellStore.clear(); } CacheSpellContainerBounds SmartAIMgr::GetSummonCreatureSpellContainerBounds(uint32 creatureEntry) const @@ -1162,3 +1179,9 @@ CacheSpellContainerBounds SmartAIMgr::GetKillCreditSpellContainerBounds(uint32 k { return KillCreditSpellStore.equal_range(killCredit); } + +CacheSpellContainerBounds SmartAIMgr::GetCreditItemSpellContainerBounds(uint32 itemId) const +{ + return CreateItemSpellStore.equal_range(itemId); +} + diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index bd64db4bbd2..265581d65fd 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1615,10 +1615,12 @@ class SmartAIMgr CacheSpellContainerBounds GetSummonCreatureSpellContainerBounds(uint32 creatureEntry) const; CacheSpellContainerBounds GetSummonGameObjectSpellContainerBounds(uint32 gameObjectEntry) const; CacheSpellContainerBounds GetKillCreditSpellContainerBounds(uint32 killCredit) const; + CacheSpellContainerBounds GetCreditItemSpellContainerBounds(uint32 itemId) const; CacheSpellContainer SummonCreatureSpellStore; CacheSpellContainer SummonGameObjectSpellStore; CacheSpellContainer KillCreditSpellStore; + CacheSpellContainer CreateItemSpellStore; }; #define sSmartScriptMgr SmartAIMgr::instance() -- cgit v1.2.3 From 6e27841382dab8946e5cb9b6e280e693bc0e2908 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 21 Sep 2014 22:06:00 +0200 Subject: Core/Misc: Refactor scripts to fix static analysis warnings Seventh batch of fixes targeting 100 issues reported by Coverity --- .../game/Battlefield/Zones/BattlefieldWG.cpp | 1 + .../CullingOfStratholme/boss_mal_ganis.cpp | 1 + .../CullingOfStratholme/culling_of_stratholme.cpp | 1 + .../TrialOfTheChampion/boss_grand_champions.cpp | 1 - .../Northrend/Nexus/EyeOfEternity/boss_malygos.cpp | 1 + .../scripts/Northrend/zone_borean_tundra.cpp | 207 +++++++++++++++------ .../scripts/Northrend/zone_grizzly_hills.cpp | 50 ++++- .../scripts/Northrend/zone_howling_fjord.cpp | 27 ++- src/server/scripts/Northrend/zone_zuldrak.cpp | 12 +- .../AuchenaiCrypts/boss_exarch_maladaar.cpp | 24 ++- .../Outland/BlackTemple/boss_teron_gorefiend.cpp | 1 - .../SerpentShrine/boss_leotheras_the_blind.cpp | 69 ++++--- .../SerpentShrine/boss_lurker_below.cpp | 46 +++-- .../SerpentShrine/boss_morogrim_tidewalker.cpp | 47 +++-- .../SteamVault/boss_mekgineer_steamrigger.cpp | 28 ++- .../SteamVault/boss_warlord_kalithresh.cpp | 14 +- .../TheSlavePens/boss_rokmar_the_crackler.cpp | 12 +- .../TheUnderbog/boss_hungarfen.cpp | 28 ++- .../TheUnderbog/boss_the_black_stalker.cpp | 21 ++- .../scripts/Outland/GruulsLair/boss_gruul.cpp | 24 ++- .../Outland/GruulsLair/boss_high_king_maulgar.cpp | 72 ++++--- .../BloodFurnace/boss_kelidan_the_breaker.cpp | 34 +++- .../HellfireRamparts/boss_omor_the_unscarred.cpp | 12 +- .../HellfireRamparts/boss_vazruden_the_herald.cpp | 42 ++++- .../boss_watchkeeper_gargolmar.cpp | 16 +- .../instance_hellfire_ramparts.cpp | 5 +- .../MagtheridonsLair/boss_magtheridon.cpp | 52 ++++-- .../ShatteredHalls/boss_nethekurse.cpp | 16 +- .../ShatteredHalls/boss_warbringer_omrogg.cpp | 33 ++-- .../boss_warchief_kargath_bladefist.cpp | 23 ++- .../scripts/Outland/TempestKeep/Eye/boss_alar.cpp | 40 ++-- .../Outland/TempestKeep/Eye/boss_astromancer.cpp | 45 +++-- .../Outland/TempestKeep/Eye/boss_kaelthas.cpp | 148 +++++++++++---- .../Outland/TempestKeep/Eye/boss_void_reaver.cpp | 18 +- .../scripts/Outland/TempestKeep/Eye/the_eye.cpp | 14 +- .../Mechanar/boss_nethermancer_sepethrea.cpp | 14 +- .../Mechanar/boss_pathaleon_the_calculator.cpp | 18 +- .../Outland/TempestKeep/arcatraz/arcatraz.cpp | 36 ++-- .../arcatraz/boss_harbinger_skyriss.cpp | 24 ++- .../botanica/boss_commander_sarannis.cpp | 12 +- .../botanica/boss_high_botanist_freywinn.cpp | 20 +- .../Outland/TempestKeep/botanica/boss_laj.cpp | 20 +- .../botanica/boss_thorngrin_the_tender.cpp | 14 +- .../TempestKeep/botanica/boss_warp_splinter.cpp | 20 +- src/server/scripts/Outland/boss_doomwalker.cpp | 8 +- .../scripts/Outland/zone_blades_edge_mountains.cpp | 36 +++- .../scripts/Outland/zone_hellfire_peninsula.cpp | 24 ++- src/server/scripts/Outland/zone_nagrand.cpp | 30 ++- src/server/scripts/Outland/zone_netherstorm.cpp | 40 ++-- .../scripts/Outland/zone_shadowmoon_valley.cpp | 42 +++-- 50 files changed, 1112 insertions(+), 431 deletions(-) (limited to 'src') diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 3b3f6eb247a..4c5994f6b3a 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -1061,6 +1061,7 @@ BfWGGameObjectBuilding::BfWGGameObjectBuilding(BattlefieldWG* wg, WintergraspGam _type = type; _worldState = worldState; _state = BATTLEFIELD_WG_OBJECTSTATE_NONE; + _staticTowerInfo = nullptr; } void BfWGGameObjectBuilding::Rebuild() 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 3f74ed2eb88..a654a37e2f5 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp @@ -73,6 +73,7 @@ public: { Initialize(); instance = creature->GetInstanceScript(); + uiOutroStep = 0; } void Initialize() 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 ff104a28197..fd5e328b7f2 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp @@ -356,6 +356,7 @@ public: step = 0; gossipStep = 0; bossEvent = 0; + WavesCounter = 0; } void Initialize() diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp index 7e83c24e0dd..fa4627e443b 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp @@ -346,7 +346,6 @@ public: uint32 uiBladeStormTimer; uint32 uiInterceptTimer; uint32 uiMortalStrikeTimer; - uint32 uiAttackTimer; bool bDone; bool bHome; diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index bd1a345e55b..eb01dfab141 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -345,6 +345,7 @@ public: Initialize(); _despawned = false; // We determine if Malygos will be realocated to spawning position on reset triggered by boss despawn on evade _flySpeed = me->GetSpeed(MOVE_FLIGHT); // Get initial fly speed, otherwise on each wipe fly speed would add up if we get it + _phase = PHASE_NOT_STARTED; } void Initialize() diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp index 7824fe86c87..6af60b322a7 100644 --- a/src/server/scripts/Northrend/zone_borean_tundra.cpp +++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp @@ -67,7 +67,17 @@ public: struct npc_sinkhole_kill_creditAI : public ScriptedAI { - npc_sinkhole_kill_creditAI(Creature* creature) : ScriptedAI(creature){ } + npc_sinkhole_kill_creditAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + phaseTimer = 500; + phase = 0; + casterGuid.Clear(); + } uint32 phaseTimer; uint8 phase; @@ -75,9 +85,7 @@ public: void Reset() override { - phaseTimer = 500; - phase = 0; - casterGuid.Clear(); + Initialize(); } void SpellHit(Unit* caster, const SpellInfo* spell) override @@ -447,7 +455,18 @@ public: struct npc_nesingwary_trapperAI : public ScriptedAI { - npc_nesingwary_trapperAI(Creature* creature) : ScriptedAI(creature) { creature->SetVisible(false); } + npc_nesingwary_trapperAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + me->SetVisible(false); + phaseTimer = 2500; + phase = 1; + go_caribouGUID.Clear(); + } ObjectGuid go_caribouGUID; uint8 phase; @@ -455,10 +474,7 @@ public: void Reset() override { - me->SetVisible(false); - phaseTimer = 2500; - phase = 1; - go_caribouGUID.Clear(); + Initialize(); } void EnterCombat(Unit* /*who*/) override { } @@ -576,7 +592,16 @@ public: struct npc_lurgglbrAI : public npc_escortAI { - npc_lurgglbrAI(Creature* creature) : npc_escortAI(creature){ } + npc_lurgglbrAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + IntroTimer = 0; + IntroPhase = 0; + } uint32 IntroTimer; uint32 IntroPhase; @@ -584,10 +609,7 @@ public: void Reset() override { if (!HasEscortState(STATE_ESCORT_ESCORTING)) - { - IntroTimer = 0; - IntroPhase = 0; - } + Initialize(); } void WaypointReached(uint32 waypointId) override @@ -723,6 +745,12 @@ public: { npc_nexus_drake_hatchlingAI(Creature* creature) : FollowerAI(creature) { + Initialize(); + } + + void Initialize() + { + WithRedDragonBlood = false; } ObjectGuid HarpoonerGUID; @@ -730,7 +758,7 @@ public: void Reset() override { - WithRedDragonBlood = false; + Initialize(); } void EnterCombat(Unit* who) override @@ -862,7 +890,26 @@ public: struct npc_thassarianAI : public npc_escortAI { - npc_thassarianAI(Creature* creature) : npc_escortAI(creature) { } + npc_thassarianAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + arthasGUID.Clear(); + talbotGUID.Clear(); + leryssaGUID.Clear(); + arlosGUID.Clear(); + + arthasInPosition = false; + arlosInPosition = false; + leryssaInPosition = false; + talbotInPosition = false; + + phase = 0; + phaseTimer = 0; + } ObjectGuid arthasGUID; ObjectGuid talbotGUID; @@ -882,18 +929,7 @@ public: me->RestoreFaction(); me->RemoveStandFlags(UNIT_STAND_STATE_SIT); - arthasGUID.Clear(); - talbotGUID.Clear(); - leryssaGUID.Clear(); - arlosGUID.Clear(); - - arthasInPosition = false; - arlosInPosition = false; - leryssaInPosition = false; - talbotInPosition = false; - - phase = 0; - phaseTimer = 0; + Initialize(); } void WaypointReached(uint32 waypointId) override @@ -1239,7 +1275,20 @@ public: struct npc_counselor_talbotAI : public ScriptedAI { - npc_counselor_talbotAI(Creature* creature) : ScriptedAI(creature) { } + npc_counselor_talbotAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + leryssaGUID.Clear(); + arlosGUID.Clear(); + bCheck = false; + shadowBoltTimer = urand(5000, 12000); + deflectionTimer = urand(20000, 25000); + soulBlastTimer = urand(12000, 18000); + } ObjectGuid leryssaGUID; ObjectGuid arlosGUID; @@ -1252,12 +1301,7 @@ public: void Reset() override { - leryssaGUID.Clear(); - arlosGUID.Clear(); - bCheck = false; - shadowBoltTimer = urand(5000, 12000); - deflectionTimer = urand(20000, 25000); - soulBlastTimer = urand(12000, 18000); + Initialize(); } void MovementInform(uint32 uiType, uint32 /*uiId*/) override { @@ -1487,14 +1531,22 @@ public: struct npc_beryl_sorcererAI : public FollowerAI { - npc_beryl_sorcererAI(Creature* creature) : FollowerAI(creature) { } + npc_beryl_sorcererAI(Creature* creature) : FollowerAI(creature) + { + Initialize(); + } + + void Initialize() + { + bEnslaved = false; + } bool bEnslaved; void Reset() override { me->SetReactState(REACT_AGGRESSIVE); - bEnslaved = false; + Initialize(); } void EnterCombat(Unit* who) override @@ -1571,7 +1623,15 @@ public: struct npc_imprisoned_beryl_sorcererAI : public ScriptedAI { - npc_imprisoned_beryl_sorcererAI(Creature* creature) : ScriptedAI(creature) { } + npc_imprisoned_beryl_sorcererAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + rebuff = 0; + } uint32 rebuff; @@ -1580,7 +1640,7 @@ public: if (me->GetReactState() != REACT_PASSIVE) me->SetReactState(REACT_PASSIVE); - rebuff = 0; + Initialize(); } void UpdateAI(uint32 diff) override @@ -1775,12 +1835,21 @@ public: struct npc_bonker_togglevoltAI : public npc_escortAI { - npc_bonker_togglevoltAI(Creature* creature) : npc_escortAI(creature) { } + npc_bonker_togglevoltAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + Bonker_agro = 0; + } + uint32 Bonker_agro; void Reset() override { - Bonker_agro=0; + Initialize(); SetDespawnAtFar(false); } @@ -1873,15 +1942,23 @@ public: struct npc_trapped_mammoth_calfAI : public ScriptedAI { - npc_trapped_mammoth_calfAI(Creature* creature) : ScriptedAI(creature) { } + npc_trapped_mammoth_calfAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + uiTimer = 1500; + bStarted = false; + } uint32 uiTimer; bool bStarted; void Reset() override { - uiTimer = 1500; - bStarted = false; + Initialize(); GameObject* pTrap = NULL; for (uint8 i = 0; i < MammothTrapsNum; ++i) @@ -2003,13 +2080,21 @@ public: struct npc_valiance_keep_cannoneerAI : public ScriptedAI { - npc_valiance_keep_cannoneerAI(Creature* creature) : ScriptedAI(creature) { } + npc_valiance_keep_cannoneerAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + uiTimer = urand(13000, 18000); + } uint32 uiTimer; void Reset() override { - uiTimer = urand(13000, 18000); + Initialize(); } void UpdateAI(uint32 diff) override @@ -2061,13 +2146,21 @@ public: struct npc_warmage_coldarraAI : public ScriptedAI { - npc_warmage_coldarraAI(Creature* creature) : ScriptedAI(creature) { } + npc_warmage_coldarraAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + m_uiTimer = 0; + } uint32 m_uiTimer; //Timer until recast void Reset() override { - m_uiTimer = 0; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } @@ -2180,8 +2273,17 @@ public: { npc_hidden_cultistAI(Creature* creature) : ScriptedAI(creature) { - uiEmoteState = creature->GetUInt32Value(UNIT_NPC_EMOTESTATE); - uiNpcFlags = creature->GetUInt32Value(UNIT_NPC_FLAGS); + Initialize(); + uiEmoteState = creature->GetUInt32Value(UNIT_NPC_EMOTESTATE); + uiNpcFlags = creature->GetUInt32Value(UNIT_NPC_FLAGS); + } + + void Initialize() + { + uiEventTimer = 0; + uiEventPhase = 0; + + uiPlayerGUID.Clear(); } uint32 uiEmoteState; @@ -2200,10 +2302,7 @@ public: if (uiNpcFlags) me->SetUInt32Value(UNIT_NPC_FLAGS, uiNpcFlags); - uiEventTimer = 0; - uiEventPhase = 0; - - uiPlayerGUID.Clear(); + Initialize(); DoCast(SPELL_SHROUD_OF_THE_DEATH_CULTIST); diff --git a/src/server/scripts/Northrend/zone_grizzly_hills.cpp b/src/server/scripts/Northrend/zone_grizzly_hills.cpp index e60c2162339..198fd53438a 100644 --- a/src/server/scripts/Northrend/zone_grizzly_hills.cpp +++ b/src/server/scripts/Northrend/zone_grizzly_hills.cpp @@ -279,12 +279,20 @@ public: struct npc_outhouse_bunnyAI : public ScriptedAI { - npc_outhouse_bunnyAI(Creature* creature) : ScriptedAI(creature) { } + npc_outhouse_bunnyAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { _counter = 0; - _gender = 0; + _gender = 0; + } + + void Reset() override + { + Initialize(); } void SetData(uint32 Type, uint32 Data) override @@ -341,13 +349,21 @@ public: struct npc_tallhorn_stagAI : public ScriptedAI { - npc_tallhorn_stagAI(Creature* creature) : ScriptedAI(creature) { } + npc_tallhorn_stagAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { _phase = 1; } + void Reset() override + { + Initialize(); + } + void UpdateAI(uint32 /*diff*/) override { if (_phase == 1) @@ -459,13 +475,21 @@ public: struct npc_wounded_skirmisherAI : public ScriptedAI { - npc_wounded_skirmisherAI(Creature* creature) : ScriptedAI(creature) { } + npc_wounded_skirmisherAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { _despawnTimer = 5000; } + void Reset() override + { + Initialize(); + } + void MovementInform(uint32, uint32 id) override { if (id == 1) @@ -651,12 +675,20 @@ public: struct npc_lake_frogAI : public ScriptedAI { - npc_lake_frogAI(Creature* creature) : ScriptedAI(creature) { } + npc_lake_frogAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { _following = false; _runningScript = false; + } + + void Reset() override + { + Initialize(); if (me->GetEntry() == NPC_LAKE_FROG_QUEST) me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); } diff --git a/src/server/scripts/Northrend/zone_howling_fjord.cpp b/src/server/scripts/Northrend/zone_howling_fjord.cpp index 53dc2a62f90..adf2af50a8e 100644 --- a/src/server/scripts/Northrend/zone_howling_fjord.cpp +++ b/src/server/scripts/Northrend/zone_howling_fjord.cpp @@ -74,13 +74,22 @@ public: struct npc_Apothecary_HanesAI : public npc_escortAI { - npc_Apothecary_HanesAI(Creature* creature) : npc_escortAI(creature){ } + npc_Apothecary_HanesAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + PotTimer = 10000; //10 sec cooldown on potion + } + uint32 PotTimer; void Reset() override { SetDespawnAtFar(false); - PotTimer = 10000; //10 sec cooldown on potion + Initialize(); } void JustDied(Unit* /*killer*/) override @@ -318,15 +327,23 @@ public: /// @todo make prisoners help (unclear if summoned or using npc's from surrounding cages (summon inside small cages?)) struct npc_daegarnAI : public ScriptedAI { - npc_daegarnAI(Creature* creature) : ScriptedAI(creature) { } + npc_daegarnAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + bEventInProgress = false; + uiPlayerGUID.Clear(); + } bool bEventInProgress; ObjectGuid uiPlayerGUID; void Reset() override { - bEventInProgress = false; - uiPlayerGUID.Clear(); + Initialize(); } void StartEvent(ObjectGuid uiGUID) diff --git a/src/server/scripts/Northrend/zone_zuldrak.cpp b/src/server/scripts/Northrend/zone_zuldrak.cpp index 44f559bfa79..cde2cf94e3c 100644 --- a/src/server/scripts/Northrend/zone_zuldrak.cpp +++ b/src/server/scripts/Northrend/zone_zuldrak.cpp @@ -222,13 +222,21 @@ public: struct npc_crusade_recruitAI : public ScriptedAI { - npc_crusade_recruitAI(Creature* creature) : ScriptedAI(creature) { } + npc_crusade_recruitAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + _heading = me->GetOrientation(); + } void Reset() override { me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_COWER); - _heading = me->GetOrientation(); + Initialize(); } void UpdateAI(uint32 diff) override diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp index 99cda91b866..08d042582e5 100644 --- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp +++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp @@ -170,9 +170,23 @@ public: { boss_exarch_maladaarAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); HasTaunted = false; } + void Initialize() + { + soulmodel = 0; + soulholder.Clear(); + soulclass = 0; + + Fear_timer = 15000 + rand32() % 5000; + Ribbon_of_Souls_timer = 5000; + StolenSoul_Timer = 25000 + rand32() % 10000; + + Avatar_summoned = false; + } + uint32 soulmodel; ObjectGuid soulholder; uint8 soulclass; @@ -186,15 +200,7 @@ public: void Reset() override { - soulmodel = 0; - soulholder.Clear(); - soulclass = 0; - - Fear_timer = 15000 + rand32() % 5000; - Ribbon_of_Souls_timer = 5000; - StolenSoul_Timer = 25000 + rand32() % 10000; - - Avatar_summoned = false; + Initialize(); } void MoveInLineOfSight(Unit* who) override diff --git a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp index aa0f3daeef0..9e9f3f60a59 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp @@ -265,7 +265,6 @@ public: uint32 SummonDoomBlossomTimer; uint32 EnrageTimer; uint32 CrushingShadowsTimer; - uint32 ShadowOfDeathTimer; uint32 SummonShadowsTimer; uint32 RandomYellTimer; uint32 AggroTimer; diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 9f51155b334..94b75727d69 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -83,6 +83,13 @@ public: { npc_inner_demonAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); + } + + void Initialize() + { + ShadowBolt_Timer = 10000; + Link_Timer = 1000; } uint32 ShadowBolt_Timer; @@ -92,8 +99,7 @@ public: void Reset() override { - ShadowBolt_Timer = 10000; - Link_Timer = 1000; + Initialize(); } void SetGUID(ObjectGuid guid, int32 id/* = 0 */) override @@ -187,10 +193,30 @@ public: { boss_leotheras_the_blindAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); creature->GetPosition(x, y, z); instance = creature->GetInstanceScript(); } + void Initialize() + { + BanishTimer = 1000; + Whirlwind_Timer = 15000; + ChaosBlast_Timer = 1000; + SwitchToDemon_Timer = 45000; + SwitchToHuman_Timer = 60000; + Berserk_Timer = 600000; + InnerDemons_Timer = 30000; + + DealDamage = true; + DemonForm = false; + IsFinalForm = false; + NeedThreatReset = false; + EnrageUsed = false; + memset(InnderDemon, 0, sizeof(InnderDemon)); + InnerDemon_Count = 0; + } + InstanceScript* instance; uint32 Whirlwind_Timer; @@ -216,21 +242,8 @@ public: void Reset() override { CheckChannelers(); - BanishTimer = 1000; - Whirlwind_Timer = 15000; - ChaosBlast_Timer = 1000; - SwitchToDemon_Timer = 45000; - SwitchToHuman_Timer = 60000; - Berserk_Timer = 600000; - InnerDemons_Timer = 30000; + Initialize(); me->SetCanDualWield(true); - DealDamage = true; - DemonForm = false; - IsFinalForm = false; - NeedThreatReset = false; - EnrageUsed = false; - memset(InnderDemon, 0, sizeof(InnderDemon)); - InnerDemon_Count = 0; me->SetSpeed(MOVE_RUN, 2.0f, true); me->SetDisplayId(MODEL_NIGHTELF); me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID , 0); @@ -600,15 +613,23 @@ public: struct boss_leotheras_the_blind_demonformAI : public ScriptedAI { - boss_leotheras_the_blind_demonformAI(Creature* creature) : ScriptedAI(creature) { } + boss_leotheras_the_blind_demonformAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + ChaosBlast_Timer = 1000; + DealDamage = true; + } uint32 ChaosBlast_Timer; bool DealDamage; void Reset() override { - ChaosBlast_Timer = 1000; - DealDamage = true; + Initialize(); } void StartEvent() @@ -675,10 +696,17 @@ public: { npc_greyheart_spellbinderAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); AddedBanish = false; } + void Initialize() + { + Mindblast_Timer = urand(3000, 8000); + Earthshock_Timer = urand(5000, 10000); + } + InstanceScript* instance; ObjectGuid leotherasGUID; @@ -690,8 +718,7 @@ public: void Reset() override { - Mindblast_Timer = urand(3000, 8000); - Earthshock_Timer = urand(5000, 10000); + Initialize(); instance->SetGuidData(DATA_LEOTHERAS_EVENT_STARTER, ObjectGuid::Empty); Creature* leotheras = ObjectAccessor::GetCreature(*me, leotherasGUID); diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp index 83b8722ce47..0fffdaa0554 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp @@ -88,10 +88,30 @@ public: { boss_the_lurker_belowAI(Creature* creature) : ScriptedAI(creature), Summons(me) { + Initialize(); SetCombatMovement(false); instance = creature->GetInstanceScript(); } + void Initialize() + { + SpoutAnimTimer = 1000; + RotTimer = 0; + WaterboltTimer = 15000; // give time to get in range when fight starts + SpoutTimer = 45000; + WhirlTimer = 18000; // after avery spout + PhaseTimer = 120000; + GeyserTimer = rand32() % 5000 + 15000; + CheckTimer = 15000; // give time to get in range when fight starts + WaitTimer = 60000; // never reached + WaitTimer2 = 60000; // never reached + + Submerged = true; // will be false at combat start + Spawned = false; + InRange = false; + CanStartEvent = false; + } + InstanceScript* instance; SummonList Summons; @@ -121,21 +141,7 @@ public: { me->SetSwim(true); me->SetDisableGravity(true); - SpoutAnimTimer = 1000; - RotTimer = 0; - WaterboltTimer = 15000; // give time to get in range when fight starts - SpoutTimer = 45000; - WhirlTimer = 18000; // after avery spout - PhaseTimer = 120000; - GeyserTimer = rand32() % 5000 + 15000; - CheckTimer = 15000; // give time to get in range when fight starts - WaitTimer = 60000; // never reached - WaitTimer2 = 60000; // never reached - - Submerged = true; // will be false at combat start - Spawned = false; - InRange = false; - CanStartEvent = false; + Initialize(); Summons.DespawnAll(); @@ -374,16 +380,22 @@ public: { npc_coilfang_ambusherAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); SetCombatMovement(false); } + void Initialize() + { + MultiShotTimer = 10000; + ShootBowTimer = 4000; + } + uint32 MultiShotTimer; uint32 ShootBowTimer; void Reset() override { - MultiShotTimer = 10000; - ShootBowTimer = 4000; + Initialize(); } void MoveInLineOfSight(Unit* who) override diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp index 0a538ac0c39..ccf7903ebe3 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp @@ -98,12 +98,28 @@ public: { boss_morogrim_tidewalkerAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); + Playercount = 0; + counter = 0; } - InstanceScript* instance; + void Initialize() + { + TidalWave_Timer = 10000; + WateryGrave_Timer = 30000; + Earthquake_Timer = 40000; + WateryGlobules_Timer = 0; + globulespell[0] = SPELL_SUMMON_WATER_GLOBULE_1; + globulespell[1] = SPELL_SUMMON_WATER_GLOBULE_2; + globulespell[2] = SPELL_SUMMON_WATER_GLOBULE_3; + globulespell[3] = SPELL_SUMMON_WATER_GLOBULE_4; + + Earthquake = false; + Phase2 = false; + } - Map::PlayerList const* PlayerList; + InstanceScript* instance; uint32 TidalWave_Timer; uint32 WateryGrave_Timer; @@ -118,17 +134,7 @@ public: void Reset() override { - TidalWave_Timer = 10000; - WateryGrave_Timer = 30000; - Earthquake_Timer = 40000; - WateryGlobules_Timer = 0; - globulespell[0] = SPELL_SUMMON_WATER_GLOBULE_1; - globulespell[1] = SPELL_SUMMON_WATER_GLOBULE_2; - globulespell[2] = SPELL_SUMMON_WATER_GLOBULE_3; - globulespell[3] = SPELL_SUMMON_WATER_GLOBULE_4; - - Earthquake = false; - Phase2 = false; + Initialize(); instance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, NOT_STARTED); } @@ -154,8 +160,7 @@ public: void EnterCombat(Unit* /*who*/) override { - PlayerList = &me->GetMap()->GetPlayers(); - Playercount = PlayerList->getSize(); + Playercount = me->GetMap()->GetPlayers().getSize(); StartEvent(); } @@ -296,13 +301,21 @@ public: struct npc_water_globuleAI : public ScriptedAI { - npc_water_globuleAI(Creature* creature) : ScriptedAI(creature) { } + npc_water_globuleAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + Check_Timer = 1000; + } uint32 Check_Timer; void Reset() override { - Check_Timer = 1000; + Initialize(); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp index 3207727b5d1..745c44eebec 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp @@ -64,9 +64,21 @@ public: { boss_mekgineer_steamriggerAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + Shrink_Timer = 20000; + Saw_Blade_Timer = 15000; + Electrified_Net_Timer = 10000; + + Summon75 = false; + Summon50 = false; + Summon25 = false; + } + InstanceScript* instance; uint32 Shrink_Timer; @@ -78,13 +90,7 @@ public: void Reset() override { - Shrink_Timer = 20000; - Saw_Blade_Timer = 15000; - Electrified_Net_Timer = 10000; - - Summon75 = false; - Summon50 = false; - Summon25 = false; + Initialize(); instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, NOT_STARTED); } @@ -201,16 +207,22 @@ public: { npc_steamrigger_mechanicAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + Repair_Timer = 2000; + } + InstanceScript* instance; uint32 Repair_Timer; void Reset() override { - Repair_Timer = 2000; + Initialize(); } void MoveInLineOfSight(Unit* /*who*/) override diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp index 8024d5138eb..16b84e53cfd 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp @@ -110,9 +110,18 @@ public: { boss_warlord_kalithreshAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + Reflection_Timer = 10000; + Impale_Timer = 7000 + rand32() % 7000; + Rage_Timer = 45000; + CanRage = false; + } + InstanceScript* instance; uint32 Reflection_Timer; @@ -122,10 +131,7 @@ public: void Reset() override { - Reflection_Timer = 10000; - Impale_Timer = 7000 + rand32() % 7000; - Rage_Timer = 45000; - CanRage = false; + Initialize(); instance->SetBossState(DATA_WARLORD_KALITHRESH, NOT_STARTED); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_rokmar_the_crackler.cpp b/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_rokmar_the_crackler.cpp index 6fb41f2eab5..546ed38082f 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_rokmar_the_crackler.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_rokmar_the_crackler.cpp @@ -48,12 +48,20 @@ class boss_rokmar_the_crackler : public CreatureScript struct boss_rokmar_the_cracklerAI : public BossAI { - boss_rokmar_the_cracklerAI(Creature* creature) : BossAI(creature, DATA_MENNU_THE_BETRAYER) { } + boss_rokmar_the_cracklerAI(Creature* creature) : BossAI(creature, DATA_MENNU_THE_BETRAYER) + { + Initialize(); + } + + void Initialize() + { + rokmarFrenzy = false; + } void Reset() override { _Reset(); - rokmarFrenzy = false; + Initialize(); } void JustDied(Unit* /*killer*/) override diff --git a/src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_hungarfen.cpp b/src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_hungarfen.cpp index 90853138448..f097b2c1551 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_hungarfen.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_hungarfen.cpp @@ -50,6 +50,14 @@ public: { boss_hungarfenAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); + } + + void Initialize() + { + Root = false; + Mushroom_Timer = 5000; // 1 mushroom after 5s, then one per 10s. This should be different in heroic mode + AcidGeyser_Timer = 10000; } bool Root; @@ -58,9 +66,7 @@ public: void Reset() override { - Root = false; - Mushroom_Timer = 5000; // 1 mushroom after 5s, then one per 10s. This should be different in heroic mode - AcidGeyser_Timer = 10000; + Initialize(); } void EnterCombat(Unit* /*who*/) override @@ -116,7 +122,17 @@ public: struct npc_underbog_mushroomAI : public ScriptedAI { - npc_underbog_mushroomAI(Creature* creature) : ScriptedAI(creature) { } + npc_underbog_mushroomAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + Stop = false; + Grow_Timer = 0; + Shrink_Timer = 20000; + } bool Stop; uint32 Grow_Timer; @@ -124,9 +140,7 @@ public: void Reset() override { - Stop = false; - Grow_Timer = 0; - Shrink_Timer = 20000; + Initialize(); DoCast(me, SPELL_PUTRID_MUSHROOM, true); DoCast(me, SPELL_SPORE_CLOUD, true); diff --git a/src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_the_black_stalker.cpp b/src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_the_black_stalker.cpp index d3b11d481fb..e8ce29e9f1a 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_the_black_stalker.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_the_black_stalker.cpp @@ -56,6 +56,19 @@ public: { boss_the_black_stalkerAI(Creature* creature) : ScriptedAI(creature), Striders(creature) { + Initialize(); + InAir = false; + } + + void Initialize() + { + Levitate_Timer = 12000; + ChainLightning_Timer = 6000; + StaticCharge_Timer = 10000; + SporeStriders_Timer = 10000 + rand32() % 5000; + check_Timer = 5000; + LevitatedTarget.Clear(); + LevitatedTarget_Timer = 0; } uint32 SporeStriders_Timer; @@ -70,13 +83,7 @@ public: void Reset() override { - Levitate_Timer = 12000; - ChainLightning_Timer = 6000; - StaticCharge_Timer = 10000; - SporeStriders_Timer = 10000 + rand32() % 5000; - check_Timer = 5000; - LevitatedTarget.Clear(); - LevitatedTarget_Timer = 0; + Initialize(); Striders.DespawnAll(); } diff --git a/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp b/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp index 592ffc1f69e..2cee741cbf3 100644 --- a/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp +++ b/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp @@ -72,7 +72,21 @@ class boss_gruul : public CreatureScript struct boss_gruulAI : public BossAI { - boss_gruulAI(Creature* creature) : BossAI(creature, DATA_GRUUL) { } + boss_gruulAI(Creature* creature) : BossAI(creature, DATA_GRUUL) + { + Initialize(); + } + + void Initialize() + { + m_uiGrowth_Timer = 30000; + m_uiCaveIn_Timer = 27000; + m_uiCaveIn_StaticTimer = 30000; + m_uiGroundSlamTimer = 35000; + m_bPerformingGroundSlam = false; + m_uiHurtfulStrike_Timer = 8000; + m_uiReverberation_Timer = 60000 + 45000; + } uint32 m_uiGrowth_Timer; uint32 m_uiCaveIn_Timer; @@ -86,13 +100,7 @@ class boss_gruul : public CreatureScript void Reset() override { _Reset(); - m_uiGrowth_Timer= 30000; - m_uiCaveIn_Timer= 27000; - m_uiCaveIn_StaticTimer = 30000; - m_uiGroundSlamTimer= 35000; - m_bPerformingGroundSlam= false; - m_uiHurtfulStrike_Timer= 8000; - m_uiReverberation_Timer= 60000+45000; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp b/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp index 0fcc7310d07..4dcfe2be4cb 100644 --- a/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp +++ b/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp @@ -77,9 +77,21 @@ public: { boss_high_king_maulgarAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + ArcingSmash_Timer = 10000; + MightyBlow_Timer = 40000; + Whirlwind_Timer = 30000; + Charging_Timer = 0; + Roar_Timer = 0; + + Phase2 = false; + } + InstanceScript* instance; uint32 ArcingSmash_Timer; @@ -92,16 +104,10 @@ public: void Reset() override { - ArcingSmash_Timer = 10000; - MightyBlow_Timer = 40000; - Whirlwind_Timer = 30000; - Charging_Timer = 0; - Roar_Timer = 0; + Initialize(); DoCast(me, SPELL_DUAL_WIELD, false); - Phase2 = false; - instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } @@ -209,20 +215,26 @@ public: { boss_olm_the_summonerAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + DarkDecay_Timer = 10000; + Summon_Timer = 15000; + DeathCoil_Timer = 20000; + } + uint32 DarkDecay_Timer; uint32 Summon_Timer; - uint32 DeathCoil_Timer; + uint32 DeathCoil_Timer; InstanceScript* instance; void Reset() override { - DarkDecay_Timer = 10000; - Summon_Timer = 15000; - DeathCoil_Timer = 20000; + Initialize(); instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } @@ -305,9 +317,18 @@ public: { boss_kiggler_the_crazedAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + GreaterPolymorph_Timer = 5000; + LightningBolt_Timer = 10000; + ArcaneShock_Timer = 20000; + ArcaneExplosion_Timer = 30000; + } + uint32 GreaterPolymorph_Timer; uint32 LightningBolt_Timer; uint32 ArcaneShock_Timer; @@ -317,10 +338,7 @@ public: void Reset() override { - GreaterPolymorph_Timer = 5000; - LightningBolt_Timer = 10000; - ArcaneShock_Timer = 20000; - ArcaneExplosion_Timer = 30000; + Initialize(); instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } @@ -393,9 +411,17 @@ public: { boss_blindeye_the_seerAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + GreaterPowerWordShield_Timer = 5000; + Heal_Timer = urand(25000, 40000); + PrayerofHealing_Timer = urand(45000, 55000); + } + uint32 GreaterPowerWordShield_Timer; uint32 Heal_Timer; uint32 PrayerofHealing_Timer; @@ -404,9 +430,7 @@ public: void Reset() override { - GreaterPowerWordShield_Timer = 5000; - Heal_Timer = urand(25000, 40000); - PrayerofHealing_Timer = urand(45000, 55000); + Initialize(); instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } @@ -470,9 +494,17 @@ public: { boss_krosh_firehandAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + GreaterFireball_Timer = 1000; + SpellShield_Timer = 5000; + BlastWave_Timer = 20000; + } + uint32 GreaterFireball_Timer; uint32 SpellShield_Timer; uint32 BlastWave_Timer; @@ -481,9 +513,7 @@ public: void Reset() override { - GreaterFireball_Timer = 1000; - SpellShield_Timer = 5000; - BlastWave_Timer = 20000; + Initialize(); instance->SetBossState(DATA_MAULGAR, NOT_STARTED); } diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp index da7074b131f..1d9eb81b1e7 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp @@ -65,6 +65,17 @@ class boss_kelidan_the_breaker : public CreatureScript { boss_kelidan_the_breakerAI(Creature* creature) : BossAI(creature, DATA_KELIDAN_THE_BREAKER) { + Initialize(); + } + + void Initialize() + { + ShadowVolley_Timer = 1000; + BurningNova_Timer = 15000; + Corruption_Timer = 5000; + check_Timer = 0; + Firenova = false; + addYell = false; } uint32 ShadowVolley_Timer; @@ -79,12 +90,7 @@ class boss_kelidan_the_breaker : public CreatureScript void Reset() override { _Reset(); - ShadowVolley_Timer = 1000; - BurningNova_Timer = 15000; - Corruption_Timer = 5000; - check_Timer = 0; - Firenova = false; - addYell = false; + Initialize(); SummonChannelers(); me->SetReactState(REACT_PASSIVE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NON_ATTACKABLE); @@ -271,7 +277,17 @@ class npc_shadowmoon_channeler : public CreatureScript struct npc_shadowmoon_channelerAI : public ScriptedAI { - npc_shadowmoon_channelerAI(Creature* creature) : ScriptedAI(creature){ } + npc_shadowmoon_channelerAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + ShadowBolt_Timer = 1000 + rand32() % 1000; + MarkOfShadow_Timer = 5000 + rand32() % 2000; + check_Timer = 0; + } uint32 ShadowBolt_Timer; uint32 MarkOfShadow_Timer; @@ -279,9 +295,7 @@ class npc_shadowmoon_channeler : public CreatureScript void Reset() override { - ShadowBolt_Timer = 1000 + rand32() % 1000; - MarkOfShadow_Timer = 5000 + rand32() % 2000; - check_Timer = 0; + Initialize(); if (me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(true); } diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp index 061d6a6a9a8..831818a4c9a 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp @@ -60,13 +60,12 @@ class boss_omor_the_unscarred : public CreatureScript { boss_omor_the_unscarredAI(Creature* creature) : BossAI(creature, DATA_OMOR_THE_UNSCARRED) { + Initialize(); SetCombatMovement(false); } - void Reset() override + void Initialize() { - Talk(SAY_WIPE); - OrbitalStrike_Timer = 25000; ShadowWhip_Timer = 2000; Aura_Timer = 10000; @@ -76,6 +75,13 @@ class boss_omor_the_unscarred : public CreatureScript SummonedCount = 0; PlayerGUID.Clear(); CanPullBack = false; + } + + void Reset() override + { + Talk(SAY_WIPE); + + Initialize(); _Reset(); } diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp index 44c93dc77c9..566c6439893 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp @@ -70,16 +70,24 @@ class boss_nazan : public CreatureScript { boss_nazanAI(Creature* creature) : BossAI(creature, DATA_NAZAN) { + Initialize(); flight = true; + BellowingRoar_Timer = 0; + ConeOfFire_Timer = 0; } - void Reset() override + void Initialize() { Fireball_Timer = 4000; Fly_Timer = 45000; Turn_Timer = 0; } + void Reset() override + { + Initialize(); + } + void EnterCombat(Unit* /*who*/) override { } void IsSummonedBy(Unit* summoner) override @@ -198,13 +206,21 @@ class boss_vazruden : public CreatureScript struct boss_vazrudenAI : public BossAI { - boss_vazrudenAI(Creature* creature) : BossAI(creature, DATA_VAZRUDEN) { } + boss_vazrudenAI(Creature* creature) : BossAI(creature, DATA_VAZRUDEN) + { + Initialize(); + } - void Reset() override + void Initialize() { Revenge_Timer = 4000; UnsummonCheck = 2000; WipeSaid = false; + } + + void Reset() override + { + Initialize(); _Reset(); } @@ -278,16 +294,22 @@ class boss_vazruden_the_herald : public CreatureScript { boss_vazruden_the_heraldAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); summoned = false; sentryDown = false; lootSpawned = false; } - void Reset() override + void Initialize() { phase = 0; waypoint = 0; check = 0; + } + + void Reset() override + { + Initialize(); UnsummonAdds(); } @@ -451,13 +473,21 @@ class npc_hellfire_sentry : public CreatureScript struct npc_hellfire_sentryAI : public ScriptedAI { - npc_hellfire_sentryAI(Creature* creature) : ScriptedAI(creature) { } + npc_hellfire_sentryAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { KidneyShot_Timer = urand(3000, 7000); } + void Reset() override + { + Initialize(); + } + void EnterCombat(Unit* /*who*/) override { } void JustDied(Unit* killer) override diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_watchkeeper_gargolmar.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_watchkeeper_gargolmar.cpp index 5baaebc0d7b..2fbef051313 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_watchkeeper_gargolmar.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_watchkeeper_gargolmar.cpp @@ -58,13 +58,21 @@ class boss_watchkeeper_gargolmar : public CreatureScript struct boss_watchkeeper_gargolmarAI : public BossAI { - boss_watchkeeper_gargolmarAI(Creature* creature) : BossAI(creature, DATA_WATCHKEEPER_GARGOLMAR) { } + boss_watchkeeper_gargolmarAI(Creature* creature) : BossAI(creature, DATA_WATCHKEEPER_GARGOLMAR) + { + Initialize(); + } - void Reset() override + void Initialize() { - hasTaunted = false; + hasTaunted = false; yelledForHeal = false; - retaliation = false; + retaliation = false; + } + + void Reset() override + { + Initialize(); _Reset(); } diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp index 1c3eb6d8c34..7b8eeb8834d 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp @@ -34,7 +34,10 @@ class instance_ramparts : public InstanceMapScript struct instance_ramparts_InstanceMapScript : public InstanceScript { - instance_ramparts_InstanceMapScript(Map* map) : InstanceScript(map) { } + instance_ramparts_InstanceMapScript(Map* map) : InstanceScript(map) + { + spawned = false; + } void Initialize() override { diff --git a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp index 50cdcfe121b..e7c1e60e432 100644 --- a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp @@ -100,17 +100,23 @@ class npc_abyssal : public CreatureScript { npc_abyssalAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); trigger = 0; Despawn_Timer = 60000; } + void Initialize() + { + FireBlast_Timer = 6000; + } + uint32 FireBlast_Timer; uint32 Despawn_Timer; uint32 trigger; void Reset() override { - FireBlast_Timer = 6000; + Initialize(); } void SpellHit(Unit*, const SpellInfo* spell) override @@ -207,11 +213,26 @@ class boss_magtheridon : public CreatureScript { boss_magtheridonAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10); me->SetFloatValue(UNIT_FIELD_COMBATREACH, 10); } + void Initialize() + { + Berserk_Timer = 1320000; + Quake_Timer = 40000; + Debris_Timer = 10000; + Blaze_Timer = 10000 + rand32() % 20000; + BlastNova_Timer = 60000; + Cleave_Timer = 15000; + RandChat_Timer = 90000; + + Phase3 = false; + NeedCheckCube = false; + } + CubeMap Cube; InstanceScript* instance; @@ -229,16 +250,7 @@ class boss_magtheridon : public CreatureScript void Reset() override { - Berserk_Timer = 1320000; - Quake_Timer = 40000; - Debris_Timer = 10000; - Blaze_Timer = 10000 + rand32() % 20000; - BlastNova_Timer = 60000; - Cleave_Timer = 15000; - RandChat_Timer = 90000; - - Phase3 = false; - NeedCheckCube = false; + Initialize(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -468,9 +480,20 @@ class npc_hellfire_channeler : public CreatureScript { npc_hellfire_channelerAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + ShadowBoltVolley_Timer = urand(8000, 10000); + DarkMending_Timer = 10000; + Fear_Timer = urand(15000, 20000); + Infernal_Timer = urand(10000, 50000); + + Check_Timer = 5000; + } + InstanceScript* instance; uint32 ShadowBoltVolley_Timer; @@ -482,12 +505,7 @@ class npc_hellfire_channeler : public CreatureScript void Reset() override { - ShadowBoltVolley_Timer = urand(8000, 10000); - DarkMending_Timer = 10000; - Fear_Timer = urand(15000, 20000); - Infernal_Timer = urand(10000, 50000); - - Check_Timer = 5000; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp index 741d5b78285..59fb8b48e30 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp @@ -83,12 +83,13 @@ class boss_grand_warlock_nethekurse : public CreatureScript struct boss_grand_warlock_nethekurseAI : public BossAI { - boss_grand_warlock_nethekurseAI(Creature* creature) : BossAI(creature, DATA_NETHEKURSE) { } - - void Reset() override + boss_grand_warlock_nethekurseAI(Creature* creature) : BossAI(creature, DATA_NETHEKURSE) { - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Initialize(); + } + void Initialize() + { IsIntroEvent = false; IntroOnce = false; IsMainEvent = false; @@ -105,6 +106,13 @@ class boss_grand_warlock_nethekurse : public CreatureScript Cleave_Timer = 5000; } + void Reset() override + { + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + Initialize(); + } + void JustDied(Unit* /*killer*/) override { Talk(SAY_DIE); diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp index f60c65b0b7a..2d33bee4091 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp @@ -136,6 +136,26 @@ class boss_warbringer_omrogg : public CreatureScript { boss_warbringer_omroggAI(Creature* creature) : BossAI(creature, DATA_OMROGG) { + Initialize(); + iaggro = 0; + ithreat = 0; + ikilling = 0; + } + + void Initialize() + { + AggroYell = false; + ThreatYell = false; + ThreatYell2 = false; + KillingYell = false; + + Delay_Timer = 4000; + BlastWave_Timer = 0; + BlastCount = 0; + Fear_Timer = 8000; + BurningMaul_Timer = 25000; + ThunderClap_Timer = 15000; + ResetThreat_Timer = 30000; } void Reset() override @@ -152,18 +172,7 @@ class boss_warbringer_omrogg : public CreatureScript RightHeadGUID.Clear(); } - AggroYell = false; - ThreatYell = false; - ThreatYell2 = false; - KillingYell = false; - - Delay_Timer = 4000; - BlastWave_Timer = 0; - BlastCount = 0; - Fear_Timer = 8000; - BurningMaul_Timer = 25000; - ThunderClap_Timer = 15000; - ResetThreat_Timer = 30000; + Initialize(); instance->SetData(DATA_OMROGG, NOT_STARTED); //End boss can use this later. O'mrogg must be defeated(DONE) or he will come to aid. } diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp index 7145ebfd7aa..ff8bb84c397 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp @@ -65,15 +65,14 @@ class boss_warchief_kargath_bladefist : public CreatureScript struct boss_warchief_kargath_bladefistAI : public BossAI { - boss_warchief_kargath_bladefistAI(Creature* creature) : BossAI(creature, DATA_KARGATH) { } - - void Reset() override + boss_warchief_kargath_bladefistAI(Creature* creature) : BossAI(creature, DATA_KARGATH) { - removeAdds(); - - me->SetSpeed(MOVE_RUN, 2); - me->SetWalk(false); + Initialize(); + target_num = 0; + } + void Initialize() + { summoned = 2; InBlade = false; Wait_Timer = 0; @@ -85,6 +84,16 @@ class boss_warchief_kargath_bladefist : public CreatureScript resetcheck_timer = 5000; } + void Reset() override + { + removeAdds(); + + me->SetSpeed(MOVE_RUN, 2); + me->SetWalk(false); + + Initialize(); + } + void JustDied(Unit* /*killer*/) override { Talk(SAY_DEATH); diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp index 8dd1aad5d4d..0f9547a2b37 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp @@ -81,8 +81,28 @@ class boss_alar : public CreatureScript { boss_alarAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); DefaultMoveSpeedRate = creature->GetSpeedRate(MOVE_RUN); + DiveBomb_Timer = 0; + MeltArmor_Timer = 0; + Charge_Timer = 0; + FlamePatch_Timer = 0; + } + + void Initialize() + { + Berserk_Timer = 1200000; + Platforms_Move_Timer = 0; + + Phase1 = true; + WaitEvent = WE_NONE; + WaitTimer = 0; + AfterMoving = false; + ForceMove = false; + ForceTimer = 5000; + + cur_wp = 4; } InstanceScript* instance; @@ -111,17 +131,7 @@ class boss_alar : public CreatureScript { instance->SetData(DATA_ALAREVENT, NOT_STARTED); - Berserk_Timer = 1200000; - Platforms_Move_Timer = 0; - - Phase1 = true; - WaitEvent = WE_NONE; - WaitTimer = 0; - AfterMoving = false; - ForceMove = false; - ForceTimer = 5000; - - cur_wp = 4; + Initialize(); me->SetDisplayId(me->GetNativeDisplayId()); me->SetSpeed(MOVE_RUN, DefaultMoveSpeedRate); @@ -461,17 +471,23 @@ class npc_ember_of_alar : public CreatureScript { npc_ember_of_alarAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); creature->SetDisableGravity(true); creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); } + void Initialize() + { + toDie = false; + } + InstanceScript* instance; bool toDie; void Reset() override { - toDie = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp index 0a9e5665ec8..cd433000e8e 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp @@ -101,10 +101,29 @@ class boss_high_astromancer_solarian : public CreatureScript { boss_high_astromancer_solarianAI(Creature* creature) : ScriptedAI(creature), Summons(me) { + Initialize(); instance = creature->GetInstanceScript(); defaultarmor = creature->GetArmor(); defaultsize = creature->GetObjectScale(); + memset(Portals, 0, sizeof(Portals)); + } + + void Initialize() + { + ArcaneMissiles_Timer = 2000; + m_uiWrathOfTheAstromancer_Timer = 15000; + BlindingLight_Timer = 41000; + Fear_Timer = 20000; + VoidBolt_Timer = 10000; + Phase1_Timer = 50000; + Phase2_Timer = 10000; + Phase3_Timer = 15000; + AppearDelay_Timer = 2000; + BlindingLight = false; + AppearDelay = false; + Wrath_Timer = 20000 + rand32() % 5000;//twice in phase one + Phase = 1; } InstanceScript* instance; @@ -132,19 +151,7 @@ class boss_high_astromancer_solarian : public CreatureScript void Reset() override { - ArcaneMissiles_Timer = 2000; - m_uiWrathOfTheAstromancer_Timer = 15000; - BlindingLight_Timer = 41000; - Fear_Timer = 20000; - VoidBolt_Timer = 10000; - Phase1_Timer = 50000; - Phase2_Timer = 10000; - Phase3_Timer = 15000; - AppearDelay_Timer = 2000; - BlindingLight = false; - AppearDelay = false; - Wrath_Timer = 20000 + rand32() % 5000;//twice in phase one - Phase = 1; + Initialize(); instance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, NOT_STARTED); @@ -433,9 +440,17 @@ class npc_solarium_priest : public CreatureScript { npc_solarium_priestAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + healTimer = 9000; + holysmiteTimer = 1; + aoesilenceTimer = 15000; + } + InstanceScript* instance; uint32 healTimer; @@ -444,9 +459,7 @@ class npc_solarium_priest : public CreatureScript void Reset() override { - healTimer = 9000; - holysmiteTimer = 1; - aoesilenceTimer = 15000; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 8b23ee172af..961f07bd823 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -155,10 +155,18 @@ struct advisorbase_ai : public ScriptedAI { advisorbase_ai(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); m_bDoubled_Health = false; } + void Initialize() + { + FakeDeath = false; + DelayRes_Timer = 0; + DelayRes_Target.Clear(); + } + InstanceScript* instance; bool FakeDeath; bool m_bDoubled_Health; @@ -173,9 +181,7 @@ struct advisorbase_ai : public ScriptedAI m_bDoubled_Health = false; } - FakeDeath = false; - DelayRes_Timer = 0; - DelayRes_Target.Clear(); + Initialize(); me->SetStandState(UNIT_STAND_STATE_STAND); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -289,7 +295,29 @@ class boss_kaelthas : public CreatureScript { boss_kaelthasAI(Creature* creature) : ScriptedAI(creature), summons(me) { + Initialize(); instance = creature->GetInstanceScript(); + PhaseSubphase = 0; + Phase_Timer = 0; + } + + void Initialize() + { + Fireball_Timer = 5000 + rand32() % 10000; + ArcaneDisruption_Timer = 45000; + MindControl_Timer = 40000; + Phoenix_Timer = 50000; + ShockBarrier_Timer = 60000; + FlameStrike_Timer = 30000; + GravityLapse_Timer = 20000; + GravityLapse_Phase = 0; + NetherBeam_Timer = 8000; + NetherVapor_Timer = 10000; + PyrosCast = 0; + Phase = 0; + InGravityLapse = false; + IsCastingFireball = false; + ChainPyros = false; } InstanceScript* instance; @@ -319,21 +347,7 @@ class boss_kaelthas : public CreatureScript void Reset() override { - Fireball_Timer = 5000 + rand32() % 10000; - ArcaneDisruption_Timer = 45000; - MindControl_Timer = 40000; - Phoenix_Timer = 50000; - ShockBarrier_Timer = 60000; - FlameStrike_Timer = 30000; - GravityLapse_Timer = 20000; - GravityLapse_Phase = 0; - NetherBeam_Timer = 8000; - NetherVapor_Timer = 10000; - PyrosCast = 0; - Phase = 0; - InGravityLapse = false; - IsCastingFireball = false; - ChainPyros = false; + Initialize(); if (me->IsInCombat()) PrepareAdvisors(); @@ -1016,7 +1030,17 @@ class boss_thaladred_the_darkener : public CreatureScript } struct boss_thaladred_the_darkenerAI : public advisorbase_ai { - boss_thaladred_the_darkenerAI(Creature* creature) : advisorbase_ai(creature) { } + boss_thaladred_the_darkenerAI(Creature* creature) : advisorbase_ai(creature) + { + Initialize(); + } + + void Initialize() + { + Gaze_Timer = 100; + Silence_Timer = 20000; + PsychicBlow_Timer = 10000; + } uint32 Gaze_Timer; uint32 Silence_Timer; @@ -1024,9 +1048,7 @@ class boss_thaladred_the_darkener : public CreatureScript void Reset() override { - Gaze_Timer = 100; - Silence_Timer = 20000; - PsychicBlow_Timer = 10000; + Initialize(); advisorbase_ai::Reset(); } @@ -1114,13 +1136,21 @@ class boss_lord_sanguinar : public CreatureScript } struct boss_lord_sanguinarAI : public advisorbase_ai { - boss_lord_sanguinarAI(Creature* creature) : advisorbase_ai(creature) { } + boss_lord_sanguinarAI(Creature* creature) : advisorbase_ai(creature) + { + Initialize(); + } + + void Initialize() + { + Fear_Timer = 20000; + } uint32 Fear_Timer; void Reset() override { - Fear_Timer = 20000; + Initialize(); advisorbase_ai::Reset(); } @@ -1181,7 +1211,19 @@ class boss_grand_astromancer_capernian : public CreatureScript } struct boss_grand_astromancer_capernianAI : public advisorbase_ai { - boss_grand_astromancer_capernianAI(Creature* creature) : advisorbase_ai(creature) { } + boss_grand_astromancer_capernianAI(Creature* creature) : advisorbase_ai(creature) + { + Initialize(); + } + + void Initialize() + { + Fireball_Timer = 2000; + Conflagration_Timer = 20000; + ArcaneExplosion_Timer = 5000; + Yell_Timer = 2000; + Yell = false; + } uint32 Fireball_Timer; uint32 Conflagration_Timer; @@ -1191,11 +1233,7 @@ class boss_grand_astromancer_capernian : public CreatureScript void Reset() override { - Fireball_Timer = 2000; - Conflagration_Timer = 20000; - ArcaneExplosion_Timer = 5000; - Yell_Timer = 2000; - Yell = false; + Initialize(); advisorbase_ai::Reset(); } @@ -1326,15 +1364,23 @@ class boss_master_engineer_telonicus : public CreatureScript } struct boss_master_engineer_telonicusAI : public advisorbase_ai { - boss_master_engineer_telonicusAI(Creature* creature) : advisorbase_ai(creature) { } + boss_master_engineer_telonicusAI(Creature* creature) : advisorbase_ai(creature) + { + Initialize(); + } + + void Initialize() + { + Bomb_Timer = 10000; + RemoteToy_Timer = 5000; + } uint32 Bomb_Timer; uint32 RemoteToy_Timer; void Reset() override { - Bomb_Timer = 10000; - RemoteToy_Timer = 5000; + Initialize(); advisorbase_ai::Reset(); } @@ -1411,18 +1457,24 @@ class npc_kael_flamestrike : public CreatureScript { npc_kael_flamestrikeAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); SetCombatMovement(false); } + void Initialize() + { + Timer = 5000; + Casting = false; + KillSelf = false; + } + uint32 Timer; bool Casting; bool KillSelf; void Reset() override { - Timer = 5000; - Casting = false; - KillSelf = false; + Initialize(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->setFaction(14); @@ -1477,13 +1529,21 @@ class npc_phoenix_tk : public CreatureScript } struct npc_phoenix_tkAI : public ScriptedAI { - npc_phoenix_tkAI(Creature* creature) : ScriptedAI(creature) { } + npc_phoenix_tkAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + Cycle_Timer = 2000; + } uint32 Cycle_Timer; void Reset() override { - Cycle_Timer = 2000; + Initialize(); DoCast(me, SPELL_BURN, true); } @@ -1531,13 +1591,21 @@ class npc_phoenix_egg_tk : public CreatureScript } struct npc_phoenix_egg_tkAI : public ScriptedAI { - npc_phoenix_egg_tkAI(Creature* creature) : ScriptedAI(creature) { } + npc_phoenix_egg_tkAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + Rebirth_Timer = 15000; + } uint32 Rebirth_Timer; void Reset() override { - Rebirth_Timer = 15000; + Initialize(); } //ignore any diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp index b518eb1cb8b..dd97d10cfbe 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp @@ -56,9 +56,20 @@ class boss_void_reaver : public CreatureScript { boss_void_reaverAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + Pounding_Timer = 15000; + ArcaneOrb_Timer = 3000; + KnockAway_Timer = 30000; + Berserk_Timer = 600000; + + Enraged = false; + } + InstanceScript* instance; uint32 Pounding_Timer; @@ -70,12 +81,7 @@ class boss_void_reaver : public CreatureScript void Reset() override { - Pounding_Timer = 15000; - ArcaneOrb_Timer = 3000; - KnockAway_Timer = 30000; - Berserk_Timer = 600000; - - Enraged = false; + Initialize(); if (me->IsAlive()) instance->SetData(DATA_VOIDREAVEREVENT, NOT_STARTED); diff --git a/src/server/scripts/Outland/TempestKeep/Eye/the_eye.cpp b/src/server/scripts/Outland/TempestKeep/Eye/the_eye.cpp index 32af9f647ad..22526465283 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/the_eye.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/the_eye.cpp @@ -47,15 +47,23 @@ class npc_crystalcore_devastator : public CreatureScript } struct npc_crystalcore_devastatorAI : public ScriptedAI { - npc_crystalcore_devastatorAI(Creature* creature) : ScriptedAI(creature) { } + npc_crystalcore_devastatorAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + Countercharge_Timer = 9000; + Knockaway_Timer = 25000; + } uint32 Knockaway_Timer; uint32 Countercharge_Timer; void Reset() override { - Countercharge_Timer = 9000; - Knockaway_Timer = 25000; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp index 3e4e6a213bd..276b291e236 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp @@ -151,9 +151,18 @@ class npc_ragin_flames : public CreatureScript { npc_ragin_flamesAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + inferno_Timer = 10000; + flame_timer = 500; + Check_Timer = 2000; + onlyonce = false; + } + InstanceScript* instance; uint32 inferno_Timer; @@ -164,10 +173,7 @@ class npc_ragin_flames : public CreatureScript void Reset() override { - inferno_Timer = 10000; - flame_timer = 500; - Check_Timer = 2000; - onlyonce = false; + Initialize(); me->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, true); me->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, true); me->SetSpeed(MOVE_RUN, DUNGEON_MODE(0.5f, 0.7f)); diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_pathaleon_the_calculator.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_pathaleon_the_calculator.cpp index 3c6fe2040fc..8f416d3aa8c 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_pathaleon_the_calculator.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_pathaleon_the_calculator.cpp @@ -172,7 +172,18 @@ class npc_nether_wraith : public CreatureScript struct npc_nether_wraithAI : public ScriptedAI { - npc_nether_wraithAI(Creature* creature) : ScriptedAI(creature) { } + npc_nether_wraithAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + ArcaneMissiles_Timer = urand(1000, 4000); + Detonation_Timer = 20000; + Die_Timer = 2200; + Detonation = false; + } uint32 ArcaneMissiles_Timer; uint32 Detonation_Timer; @@ -181,10 +192,7 @@ class npc_nether_wraith : public CreatureScript void Reset() override { - ArcaneMissiles_Timer = urand(1000, 4000); - Detonation_Timer = 20000; - Die_Timer = 2200; - Detonation = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp index 1a8658c8fbc..cb875e26c42 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp @@ -75,9 +75,21 @@ class npc_millhouse_manastorm : public CreatureScript { npc_millhouse_manastormAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + EventProgress_Timer = 2000; + LowHp = false; + Init = false; + Phase = 1; + + Pyroblast_Timer = 1000; + Fireball_Timer = 2500; + } + InstanceScript* instance; uint32 EventProgress_Timer; @@ -90,13 +102,7 @@ class npc_millhouse_manastorm : public CreatureScript void Reset() override { - EventProgress_Timer = 2000; - LowHp = false; - Init = false; - Phase = 1; - - Pyroblast_Timer = 1000; - Fireball_Timer = 2500; + Initialize(); if (instance->GetData(DATA_WARDEN_2) == DONE) Init = true; @@ -271,9 +277,19 @@ class npc_warden_mellichar : public CreatureScript { npc_warden_mellicharAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); instance = creature->GetInstanceScript(); } + void Initialize() + { + IsRunning = false; + CanSpawn = false; + + EventProgress_Timer = 22000; + Phase = 1; + } + InstanceScript* instance; bool IsRunning; @@ -284,11 +300,7 @@ class npc_warden_mellichar : public CreatureScript void Reset() override { - IsRunning = false; - CanSpawn = false; - - EventProgress_Timer = 22000; - Phase = 1; + Initialize(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); DoCast(me, SPELL_TARGET_OMEGA); diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp index ec22baf2d4e..2d549e590c5 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp @@ -67,9 +67,23 @@ class boss_harbinger_skyriss : public CreatureScript { boss_harbinger_skyrissAI(Creature* creature) : BossAI(creature, DATA_HARBINGER_SKYRISS) { + Initialize(); Intro = false; } + void Initialize() + { + IsImage33 = false; + IsImage66 = false; + + Intro_Phase = 1; + Intro_Timer = 5000; + MindRend_Timer = 3000; + Fear_Timer = 15000; + Domination_Timer = 30000; + ManaBurn_Timer = 25000; + } + bool Intro; bool IsImage33; bool IsImage66; @@ -86,15 +100,7 @@ class boss_harbinger_skyriss : public CreatureScript if (!Intro) me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - IsImage33 = false; - IsImage66 = false; - - Intro_Phase = 1; - Intro_Timer = 5000; - MindRend_Timer = 3000; - Fear_Timer = 15000; - Domination_Timer = 30000; - ManaBurn_Timer = 25000; + Initialize(); } void MoveInLineOfSight(Unit* who) override diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_commander_sarannis.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_commander_sarannis.cpp index 7b831e82a75..e254d92bac8 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_commander_sarannis.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_commander_sarannis.cpp @@ -50,12 +50,20 @@ class boss_commander_sarannis : public CreatureScript struct boss_commander_sarannisAI : public BossAI { - boss_commander_sarannisAI(Creature* creature) : BossAI(creature, DATA_COMMANDER_SARANNIS) { } + boss_commander_sarannisAI(Creature* creature) : BossAI(creature, DATA_COMMANDER_SARANNIS) + { + Initialize(); + } + + void Initialize() + { + _phase = true; + } void Reset() override { _Reset(); - _phase = true; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp index c0591f7b874..ff336216954 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp @@ -64,7 +64,19 @@ class boss_high_botanist_freywinn : public CreatureScript struct boss_high_botanist_freywinnAI : public BossAI { - boss_high_botanist_freywinnAI(Creature* creature) : BossAI(creature, DATA_HIGH_BOTANIST_FREYWINN) { } + boss_high_botanist_freywinnAI(Creature* creature) : BossAI(creature, DATA_HIGH_BOTANIST_FREYWINN) + { + Initialize(); + } + + void Initialize() + { + SummonSeedling_Timer = 6000; + TreeForm_Timer = 30000; + MoveCheck_Timer = 1000; + DeadAddsCount = 0; + MoveFree = true; + } uint32 SummonSeedling_Timer; uint32 TreeForm_Timer; @@ -76,11 +88,7 @@ class boss_high_botanist_freywinn : public CreatureScript { summons.DespawnAll(); - SummonSeedling_Timer = 6000; - TreeForm_Timer = 30000; - MoveCheck_Timer = 1000; - DeadAddsCount = 0; - MoveFree = true; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_laj.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_laj.cpp index 768c9b5b8f1..0e25a6e0758 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_laj.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_laj.cpp @@ -62,7 +62,19 @@ class boss_laj : public CreatureScript struct boss_lajAI : public BossAI { - boss_lajAI(Creature* creature) : BossAI(creature, DATA_LAJ) { } + boss_lajAI(Creature* creature) : BossAI(creature, DATA_LAJ) + { + Initialize(); + } + + void Initialize() + { + CanSummon = false; + Teleport_Timer = 20000; + Summon_Timer = 2500; + Transform_Timer = 30000; + Allergic_Timer = 5000; + } bool CanSummon; uint32 Teleport_Timer; @@ -79,11 +91,7 @@ class boss_laj : public CreatureScript me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); - CanSummon = false; - Teleport_Timer = 20000; - Summon_Timer = 2500; - Transform_Timer = 30000; - Allergic_Timer = 5000; + Initialize(); } void DoTransform() diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_thorngrin_the_tender.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_thorngrin_the_tender.cpp index 9114027b9fb..906c6e187ce 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_thorngrin_the_tender.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_thorngrin_the_tender.cpp @@ -51,15 +51,23 @@ class boss_thorngrin_the_tender : public CreatureScript struct boss_thorngrin_the_tenderAI : public BossAI { - boss_thorngrin_the_tenderAI(Creature* creature) : BossAI(creature, DATA_THORNGRIN_THE_TENDER) { } + boss_thorngrin_the_tenderAI(Creature* creature) : BossAI(creature, DATA_THORNGRIN_THE_TENDER) + { + Initialize(); + } - void Reset() override + void Initialize() { - _Reset(); _phase1 = true; _phase2 = true; } + void Reset() override + { + _Reset(); + Initialize(); + } + void EnterCombat(Unit* /*who*/) override { _EnterCombat(); diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp index 56c62bbf50f..fbebe897477 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp @@ -74,6 +74,12 @@ class npc_warp_splinter_treant : public CreatureScript { npc_warp_splinter_treantAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); + } + + void Initialize() + { + check_Timer = 0; } ObjectGuid WarpGuid; @@ -81,7 +87,7 @@ class npc_warp_splinter_treant : public CreatureScript void Reset() override { - check_Timer = 0; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } @@ -138,10 +144,18 @@ class boss_warp_splinter : public CreatureScript { boss_warp_splinterAI(Creature* creature) : BossAI(creature, DATA_WARP_SPLINTER) { + Initialize(); Treant_Spawn_Pos_X = creature->GetPositionX(); Treant_Spawn_Pos_Y = creature->GetPositionY(); } + void Initialize() + { + War_Stomp_Timer = urand(25000, 40000); + Summon_Treants_Timer = 45000; + Arcane_Volley_Timer = urand(8000, 20000); + } + uint32 War_Stomp_Timer; uint32 Summon_Treants_Timer; uint32 Arcane_Volley_Timer; @@ -151,9 +165,7 @@ class boss_warp_splinter : public CreatureScript void Reset() override { - War_Stomp_Timer = urand(25000, 40000); - Summon_Treants_Timer = 45000; - Arcane_Volley_Timer = urand(8000, 20000); + Initialize(); me->SetSpeed(MOVE_RUN, 0.7f, true); } diff --git a/src/server/scripts/Outland/boss_doomwalker.cpp b/src/server/scripts/Outland/boss_doomwalker.cpp index 7b72da0b02e..05113520566 100644 --- a/src/server/scripts/Outland/boss_doomwalker.cpp +++ b/src/server/scripts/Outland/boss_doomwalker.cpp @@ -57,6 +57,12 @@ class boss_doomwalker : public CreatureScript { boss_doomwalkerAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); + } + + void Initialize() + { + _inEnrage = false; } void Reset() override @@ -67,7 +73,7 @@ class boss_doomwalker : public CreatureScript _events.ScheduleEvent(EVENT_CHAIN, urand(10000, 30000)); _events.ScheduleEvent(EVENT_QUAKE, urand(25000, 35000)); _events.ScheduleEvent(EVENT_OVERRUN, urand(30000, 45000)); - _inEnrage = false; + Initialize(); } void KilledUnit(Unit* victim) override diff --git a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp index 5c95376cdfc..5941bd3decf 100644 --- a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp +++ b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp @@ -242,7 +242,21 @@ public: struct npc_nether_drakeAI : public ScriptedAI { - npc_nether_drakeAI(Creature* creature) : ScriptedAI(creature) { } + npc_nether_drakeAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + IsNihil = false; + NihilSpeech_Timer = 3000; + NihilSpeech_Phase = 0; + + ArcaneBlast_Timer = 7500; + ManaBurn_Timer = 10000; + IntangiblePresence_Timer = 15000; + } bool IsNihil; uint32 NihilSpeech_Timer; @@ -254,13 +268,7 @@ public: void Reset() override { - IsNihil = false; - NihilSpeech_Timer = 3000; - NihilSpeech_Phase = 0; - - ArcaneBlast_Timer = 7500; - ManaBurn_Timer = 10000; - IntangiblePresence_Timer = 15000; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } @@ -602,7 +610,17 @@ class npc_simon_bunny : public CreatureScript struct npc_simon_bunnyAI : public ScriptedAI { - npc_simon_bunnyAI(Creature* creature) : ScriptedAI(creature) { } + npc_simon_bunnyAI(Creature* creature) : ScriptedAI(creature) + { + large = false; + listening = false; + gameLevel = 0; + fails = 0; + gameTicks = 0; + memset(clusterIds, 0, sizeof(clusterIds)); + zCoordCorrection = 0.f; + searchDistance = 0.f; + } bool large; bool listening; diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp index 01ad2ce334f..79e6649495b 100644 --- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp @@ -58,13 +58,21 @@ public: struct npc_aeranasAI : public ScriptedAI { - npc_aeranasAI(Creature* creature) : ScriptedAI(creature) { } + npc_aeranasAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { faction_Timer = 8000; envelopingWinds_Timer = 9000; shock_Timer = 5000; + } + + void Reset() override + { + Initialize(); me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); me->setFaction(FACTION_FRIENDLY); @@ -305,14 +313,22 @@ public: struct npc_fel_guard_houndAI : public ScriptedAI { - npc_fel_guard_houndAI(Creature* creature) : ScriptedAI(creature) { } + npc_fel_guard_houndAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } - void Reset() override + void Initialize() { checkTimer = 5000; //check for creature every 5 sec helboarGUID.Clear(); } + void Reset() override + { + Initialize(); + } + void MovementInform(uint32 type, uint32 id) override { if (type != POINT_MOTION_TYPE || id != 1) diff --git a/src/server/scripts/Outland/zone_nagrand.cpp b/src/server/scripts/Outland/zone_nagrand.cpp index b8dd1393600..c08f891d13f 100644 --- a/src/server/scripts/Outland/zone_nagrand.cpp +++ b/src/server/scripts/Outland/zone_nagrand.cpp @@ -338,15 +338,23 @@ public: struct npc_corkiAI : public ScriptedAI { - npc_corkiAI(Creature* creature) : ScriptedAI(creature) { } + npc_corkiAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + Say_Timer = 5000; + ReleasedFromCage = false; + } uint32 Say_Timer; bool ReleasedFromCage; void Reset() override { - Say_Timer = 5000; - ReleasedFromCage = false; + Initialize(); } void UpdateAI(uint32 diff) override @@ -441,7 +449,17 @@ public: struct npc_kurenai_captiveAI : public npc_escortAI { - npc_kurenai_captiveAI(Creature* creature) : npc_escortAI(creature) { } + npc_kurenai_captiveAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + ChainLightningTimer = 1000; + HealTimer = 0; + FrostShockTimer = 6000; + } uint32 ChainLightningTimer; uint32 HealTimer; @@ -449,9 +467,7 @@ public: void Reset() override { - ChainLightningTimer = 1000; - HealTimer = 0; - FrostShockTimer = 6000; + Initialize(); } void EnterCombat(Unit* /*who*/) override diff --git a/src/server/scripts/Outland/zone_netherstorm.cpp b/src/server/scripts/Outland/zone_netherstorm.cpp index eb2fae03202..8bc94663f30 100644 --- a/src/server/scripts/Outland/zone_netherstorm.cpp +++ b/src/server/scripts/Outland/zone_netherstorm.cpp @@ -81,7 +81,22 @@ public: struct npc_commander_dawnforgeAI : public ScriptedAI { - npc_commander_dawnforgeAI(Creature* creature) : ScriptedAI(creature) { } + npc_commander_dawnforgeAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + PlayerGUID.Clear(); + ardonisGUID.Clear(); + pathaleonGUID.Clear(); + + Phase = 1; + PhaseSubphase = 0; + Phase_Timer = 4000; + isEvent = false; + } ObjectGuid PlayerGUID; ObjectGuid ardonisGUID; @@ -94,14 +109,7 @@ public: void Reset() override { - PlayerGUID.Clear(); - ardonisGUID.Clear(); - pathaleonGUID.Clear(); - - Phase = 1; - PhaseSubphase = 0; - Phase_Timer = 4000; - isEvent = false; + Initialize(); } void EnterCombat(Unit* /*who*/) override { } @@ -623,15 +631,23 @@ public: struct npc_maxx_a_million_escortAI : public npc_escortAI { - npc_maxx_a_million_escortAI(Creature* creature) : npc_escortAI(creature) { } + npc_maxx_a_million_escortAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + bTake = false; + uiTakeTimer = 3000; + } bool bTake; uint32 uiTakeTimer; void Reset() override { - bTake=false; - uiTakeTimer=3000; + Initialize(); } void WaypointReached(uint32 waypointId) override diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index 9eba6fdef0b..a96cf3ac254 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -1026,13 +1026,21 @@ public: struct npc_earthmender_wildaAI : public npc_escortAI { - npc_earthmender_wildaAI(Creature* creature) : npc_escortAI(creature) { } + npc_earthmender_wildaAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + m_uiHealingTimer = 0; + } uint32 m_uiHealingTimer; void Reset() override { - m_uiHealingTimer = 0; + Initialize(); } void WaypointReached(uint32 waypointId) override @@ -1411,7 +1419,24 @@ public: struct npc_lord_illidan_stormrageAI : public ScriptedAI { - npc_lord_illidan_stormrageAI(Creature* creature) : ScriptedAI(creature) { } + npc_lord_illidan_stormrageAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + PlayerGUID.Clear(); + + WaveTimer = 10000; + AnnounceTimer = 7000; + LiveCount = 0; + WaveCount = 0; + + EventStarted = false; + Announced = false; + Failed = false; + } ObjectGuid PlayerGUID; @@ -1427,16 +1452,7 @@ public: void Reset() override { - PlayerGUID.Clear(); - - WaveTimer = 10000; - AnnounceTimer = 7000; - LiveCount = 0; - WaveCount = 0; - - EventStarted = false; - Announced = false; - Failed = false; + Initialize(); me->SetVisible(false); } -- cgit v1.2.3 From 84efd8b92bec4af04263eb7b86a598572164a20b Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 21 Sep 2014 22:42:50 +0200 Subject: Scripts/Examples: Remove outdated example scripts Remove outdated misleading example scripts not following anymore current TC codestyle and standards. Please refer to the wiki or forum for up to date examples and documentation. --- src/server/game/Scripting/ScriptLoader.cpp | 19 - src/server/game/Scripting/ScriptLoader.h | 1 - src/server/scripts/CMakeLists.txt | 2 - src/server/scripts/Examples/CMakeLists.txt | 21 - .../scripts/Examples/example_commandscript.cpp | 60 --- src/server/scripts/Examples/example_creature.cpp | 298 ------------- src/server/scripts/Examples/example_escort.cpp | 244 ---------- .../scripts/Examples/example_gossip_codebox.cpp | 114 ----- src/server/scripts/Examples/example_misc.cpp | 82 ---- src/server/scripts/Examples/example_spell.cpp | 491 --------------------- 10 files changed, 1332 deletions(-) delete mode 100644 src/server/scripts/Examples/CMakeLists.txt delete mode 100644 src/server/scripts/Examples/example_commandscript.cpp delete mode 100644 src/server/scripts/Examples/example_creature.cpp delete mode 100644 src/server/scripts/Examples/example_escort.cpp delete mode 100644 src/server/scripts/Examples/example_gossip_codebox.cpp delete mode 100644 src/server/scripts/Examples/example_misc.cpp delete mode 100644 src/server/scripts/Examples/example_spell.cpp (limited to 'src') diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index ed6c5430674..d3a43b375a0 100644 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -18,13 +18,6 @@ #include "ScriptLoader.h" #include "World.h" -//examples -void AddSC_example_creature(); -void AddSC_example_escort(); -void AddSC_example_gossip_codebox(); -void AddSC_example_misc(); -void AddSC_example_commandscript(); - // spells void AddSC_deathknight_spell_scripts(); void AddSC_druid_spell_scripts(); @@ -39,7 +32,6 @@ void AddSC_warlock_spell_scripts(); void AddSC_warrior_spell_scripts(); void AddSC_quest_spell_scripts(); void AddSC_item_spell_scripts(); -void AddSC_example_spell_scripts(); void AddSC_holiday_spell_scripts(); void AddSC_SmartScripts(); @@ -700,7 +692,6 @@ void AddSC_action_ip_logger(); void AddScripts() { - AddExampleScripts(); AddSpellScripts(); AddSC_SmartScripts(); AddCommandScripts(); @@ -718,15 +709,6 @@ void AddScripts() #endif } -void AddExampleScripts() -{ - AddSC_example_creature(); - AddSC_example_escort(); - AddSC_example_gossip_codebox(); - AddSC_example_misc(); - AddSC_example_commandscript(); -} - void AddSpellScripts() { AddSC_deathknight_spell_scripts(); @@ -742,7 +724,6 @@ void AddSpellScripts() AddSC_warrior_spell_scripts(); AddSC_quest_spell_scripts(); AddSC_item_spell_scripts(); - AddSC_example_spell_scripts(); AddSC_holiday_spell_scripts(); } diff --git a/src/server/game/Scripting/ScriptLoader.h b/src/server/game/Scripting/ScriptLoader.h index db4c5b0cf46..e4820f6ee6c 100644 --- a/src/server/game/Scripting/ScriptLoader.h +++ b/src/server/game/Scripting/ScriptLoader.h @@ -19,7 +19,6 @@ #define SC_SCRIPTLOADER_H void AddScripts(); -void AddExampleScripts(); void AddSpellScripts(); void AddCommandScripts(); void AddWorldScripts(); diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index 8c40a93e197..f11791ef72f 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -20,8 +20,6 @@ include(Spells/CMakeLists.txt) include(Commands/CMakeLists.txt) -include(Examples/CMakeLists.txt) - set(scripts_STAT_SRCS ${scripts_STAT_SRCS} ../game/AI/ScriptedAI/ScriptedEscortAI.cpp diff --git a/src/server/scripts/Examples/CMakeLists.txt b/src/server/scripts/Examples/CMakeLists.txt deleted file mode 100644 index 2688fe4174d..00000000000 --- a/src/server/scripts/Examples/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2008-2014 TrinityCore -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -set(scripts_STAT_SRCS - ${scripts_STAT_SRCS} - Examples/example_misc.cpp - Examples/example_gossip_codebox.cpp - Examples/example_escort.cpp - Examples/example_creature.cpp - Examples/example_spell.cpp - Examples/example_commandscript.cpp -) - -message(" -> Prepared: Examples") diff --git a/src/server/scripts/Examples/example_commandscript.cpp b/src/server/scripts/Examples/example_commandscript.cpp deleted file mode 100644 index 8b7003c6666..00000000000 --- a/src/server/scripts/Examples/example_commandscript.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore - * Copyright (C) 2006-2009 ScriptDev2 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -/* ScriptData -Name: Example_Commandscript -%Complete: 100 -Comment: Short custom scripting example -Category: Script Examples -EndScriptData */ - -#include "ScriptMgr.h" -#include "Chat.h" - -// **** This script is designed as an example for others to build on **** -// **** Please modify whatever you'd like to as this script is only for developement **** - -// **** Script Info* *** -// This script's primary purpose is to show just how much you can really do with commandscripts - -class example_commandscript : public CommandScript -{ - public: - example_commandscript() : CommandScript("example_commandscript") { } - - static bool HandleHelloWorldCommand(ChatHandler* handler, const char* /*args*/) - { - handler->PSendSysMessage("Hello World"); - return true; - } - - ChatCommand* GetCommands() const override - { - static ChatCommand HelloWorldCommandTable[] = - { - { "hello", SEC_PLAYER, true, &HandleHelloWorldCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - return HelloWorldCommandTable; - } -}; - -void AddSC_example_commandscript() -{ - new example_commandscript(); -} diff --git a/src/server/scripts/Examples/example_creature.cpp b/src/server/scripts/Examples/example_creature.cpp deleted file mode 100644 index 9fa2940a43f..00000000000 --- a/src/server/scripts/Examples/example_creature.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore - * Copyright (C) 2006-2009 ScriptDev2 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -/* ScriptData -SDName: Example_Creature -SD%Complete: 100 -SDComment: Short custom scripting example -SDCategory: Script Examples -EndScriptData */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "ScriptedGossip.h" -#include "Player.h" - -// **** This script is designed as an example for others to build on **** -// **** Please modify whatever you'd like to as this script is only for developement **** - -// **** Script Info* *** -// This script is written in a way that it can be used for both friendly and hostile monsters -// Its primary purpose is to show just how much you can really do with scripts -// I recommend trying it out on both an agressive NPC and on friendly npc - -// **** Quick Info* *** -// Functions with Handled Function marked above them are functions that are called automatically by the core -// Functions that are marked Custom Function are functions I've created to simplify code - -enum Yells -{ - //List of text id's. The text is stored in database, also in a localized version - //(if translation not exist for the textId, default english text will be used) - //Not required to define in this way, but simplify if changes are needed. - //These texts must be added to the creature texts of the npc for which the script is assigned. - SAY_AGGRO = 0, // "Let the games begin." - SAY_RANDOM = 1, // "I see endless suffering. I see torment. I see rage. I see everything.", - // "Muahahahaha", - // "These mortal infedels my lord, they have invaded your sanctum and seek to steal your secrets.", - // "You are already dead.", - // "Where to go? What to do? So many choices that all end in pain, end in death." - SAY_BERSERK = 2, // "$N, I sentance you to death!" - SAY_PHASE = 3, // "The suffering has just begun!" - SAY_DANCE = 4, // "I always thought I was a good dancer." - SAY_SALUTE = 5, // "Move out Soldier!" - SAY_EVADE = 6 // "Help $N! I'm under attack!" -}; - -enum Spells -{ - // List of spells. - // Not required to define them in this way, but will make it easier to maintain in case spellId change - SPELL_BUFF = 25661, - SPELL_ONE = 12555, - SPELL_ONE_ALT = 24099, - SPELL_TWO = 10017, - SPELL_THREE = 26027, - SPELL_FRENZY = 23537, - SPELL_BERSERK = 32965, -}; - -enum Factions -{ - // any other constants - FACTION_WORGEN = 24 -}; - -//List of gossip item texts. Items will appear in the gossip window. -#define GOSSIP_ITEM "I'm looking for a fight" - -class example_creature : public CreatureScript -{ - public: - - example_creature() - : CreatureScript("example_creature") - { - } - - struct example_creatureAI : public ScriptedAI - { - // *** HANDLED FUNCTION *** - //This is the constructor, called only once when the Creature is first created - example_creatureAI(Creature* creature) : ScriptedAI(creature) { } - - // *** CUSTOM VARIABLES **** - //These variables are for use only by this individual script. - //Nothing else will ever call them but us. - - uint32 m_uiSayTimer; // Timer for random chat - uint32 m_uiRebuffTimer; // Timer for rebuffing - uint32 m_uiSpell1Timer; // Timer for spell 1 when in combat - uint32 m_uiSpell2Timer; // Timer for spell 1 when in combat - uint32 m_uiSpell3Timer; // Timer for spell 1 when in combat - uint32 m_uiBeserkTimer; // Timer until we go into Beserk (enraged) mode - uint32 m_uiPhase; // The current battle phase we are in - uint32 m_uiPhaseTimer; // Timer until phase transition - - // *** HANDLED FUNCTION *** - //This is called after spawn and whenever the core decides we need to evade - void Reset() override - { - m_uiPhase = 1; // Start in phase 1 - m_uiPhaseTimer = 60000; // 60 seconds - m_uiSpell1Timer = 5000; // 5 seconds - m_uiSpell2Timer = urand(10000, 20000); // between 10 and 20 seconds - m_uiSpell3Timer = 19000; // 19 seconds - m_uiBeserkTimer = 120000; // 2 minutes - - me->RestoreFaction(); - } - - // *** HANDLED FUNCTION *** - // Enter Combat called once per combat - void EnterCombat(Unit* who) override - { - //Say some stuff - Talk(SAY_AGGRO, who); - } - - // *** HANDLED FUNCTION *** - // Attack Start is called when victim change (including at start of combat) - // By default, attack who and start movement toward the victim. - //void AttackStart(Unit* who) override - //{ - // ScriptedAI::AttackStart(who); - //} - - // *** HANDLED FUNCTION *** - // Called when going out of combat. Reset is called just after. - void EnterEvadeMode() override - { - Talk(SAY_EVADE); - } - - // *** HANDLED FUNCTION *** - //Our Receive emote function - void ReceiveEmote(Player* /*player*/, uint32 uiTextEmote) override - { - me->HandleEmoteCommand(uiTextEmote); - - switch (uiTextEmote) - { - case TEXT_EMOTE_DANCE: - Talk(SAY_DANCE); - break; - case TEXT_EMOTE_SALUTE: - Talk(SAY_SALUTE); - break; - } - } - - // *** HANDLED FUNCTION *** - //Update AI is called Every single map update (roughly once every 50ms if a player is within the grid) - void UpdateAI(uint32 uiDiff) override - { - //Out of combat timers - if (!me->GetVictim()) - { - //Random Say timer - if (m_uiSayTimer <= uiDiff) - { - //Random switch between 5 outcomes - Talk(SAY_RANDOM); - - m_uiSayTimer = 45000; //Say something agian in 45 seconds - } - else - m_uiSayTimer -= uiDiff; - - //Rebuff timer - if (m_uiRebuffTimer <= uiDiff) - { - DoCast(me, SPELL_BUFF); - m_uiRebuffTimer = 900000; //Rebuff agian in 15 minutes - } - else - m_uiRebuffTimer -= uiDiff; - } - - //Return since we have no target - if (!UpdateVictim()) - return; - - //Spell 1 timer - if (m_uiSpell1Timer <= uiDiff) - { - //Cast spell one on our current target. - if (rand32() % 50 > 10) - DoCastVictim(SPELL_ONE_ALT); - else if (me->IsWithinDist(me->GetVictim(), 25.0f)) - DoCastVictim(SPELL_ONE); - - m_uiSpell1Timer = 5000; - } - else - m_uiSpell1Timer -= uiDiff; - - //Spell 2 timer - if (m_uiSpell2Timer <= uiDiff) - { - //Cast spell two on our current target. - DoCastVictim(SPELL_TWO); - m_uiSpell2Timer = 37000; - } - else - m_uiSpell2Timer -= uiDiff; - - //Beserk timer - if (m_uiPhase > 1) - { - //Spell 3 timer - if (m_uiSpell3Timer <= uiDiff) - { - //Cast spell one on our current target. - DoCastVictim(SPELL_THREE); - - m_uiSpell3Timer = 19000; - } - else - m_uiSpell3Timer -= uiDiff; - - if (m_uiBeserkTimer <= uiDiff) - { - //Say our line then cast uber death spell - Talk(SAY_BERSERK, me->GetVictim()); - DoCastVictim(SPELL_BERSERK); - - //Cast our beserk spell agian in 12 seconds if we didn't kill everyone - m_uiBeserkTimer = 12000; - } - else - m_uiBeserkTimer -= uiDiff; - } - else if (m_uiPhase == 1) //Phase timer - { - if (m_uiPhaseTimer <= uiDiff) - { - //Go to next phase - ++m_uiPhase; - Talk(SAY_PHASE); - DoCast(me, SPELL_FRENZY); - } - else - m_uiPhaseTimer -= uiDiff; - } - - DoMeleeAttackIfReady(); - } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new example_creatureAI(creature); - } - - bool OnGossipHello(Player* player, Creature* creature) override - { - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(907, creature->GetGUID()); - - return true; - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override - { - player->PlayerTalkClass->ClearMenus(); - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - //Set our faction to hostile towards all - creature->setFaction(FACTION_WORGEN); - creature->AI()->AttackStart(player); - } - - return true; - } -}; - -//This is the actual function called only once durring InitScripts() -//It must define all handled functions that are to be run in this script -void AddSC_example_creature() -{ - new example_creature(); -} diff --git a/src/server/scripts/Examples/example_escort.cpp b/src/server/scripts/Examples/example_escort.cpp deleted file mode 100644 index 229d32e6c4a..00000000000 --- a/src/server/scripts/Examples/example_escort.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore - * Copyright (C) 2006-2009 ScriptDev2 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -/* ScriptData -SDName: Example_Escort -SD%Complete: 100 -SDComment: Script used for testing escortAI -SDCategory: Script Examples -EndScriptData */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "ScriptedGossip.h" -#include "ScriptedEscortAI.h" -#include "Player.h" -#include "CreatureTextMgr.h" - -enum Yells -{ - SAY_AGGRO1 = 0, - SAY_AGGRO2 = 1, - SAY_WP_1 = 2, - SAY_WP_2 = 3, - SAY_WP_3 = 4, - SAY_WP_4 = 5, - SAY_DEATH_1 = 6, - SAY_DEATH_2 = 7, - SAY_DEATH_3 = 8, - SAY_SPELL = 9, - SAY_RAND_1 = 10, - SAY_RAND_2 = 11 -}; - -enum Spells -{ - SPELL_DEATH_COIL = 33130, - SPELL_ELIXIR_OF_FORTITUDE = 3593, - SPELL_BLUE_FIREWORK = 11540 -}; - -enum Creatures -{ - NPC_FELBOAR = 21878 -}; - -#define GOSSIP_ITEM_1 "Click to Test Escort(Attack, Run)" -#define GOSSIP_ITEM_2 "Click to Test Escort(NoAttack, Walk)" -#define GOSSIP_ITEM_3 "Click to Test Escort(NoAttack, Run)" - -class example_escort : public CreatureScript -{ - public: - - example_escort() - : CreatureScript("example_escort") - { - } - - struct example_escortAI : public npc_escortAI - { - // CreatureAI functions - example_escortAI(Creature* creature) : npc_escortAI(creature) { } - - uint32 m_uiDeathCoilTimer; - uint32 m_uiChatTimer; - - void JustSummoned(Creature* summoned) override - { - summoned->AI()->AttackStart(me); - } - - // Pure Virtual Functions (Have to be implemented) - void WaypointReached(uint32 waypointId) override - { - switch (waypointId) - { - case 1: - Talk(SAY_WP_1); - break; - case 3: - Talk(SAY_WP_2); - me->SummonCreature(NPC_FELBOAR, me->GetPositionX()+5.0f, me->GetPositionY()+7.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000); - break; - case 4: - if (Player* player = GetPlayerForEscort()) - { - //pTmpPlayer is the target of the text - Talk(SAY_WP_3, player); - //pTmpPlayer is the source of the text - sCreatureTextMgr->SendChat(me, SAY_WP_4, NULL, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player); - } - break; - } - } - - void EnterCombat(Unit* /*who*/) override - { - if (HasEscortState(STATE_ESCORT_ESCORTING)) - { - if (Player* player = GetPlayerForEscort()) - Talk(SAY_AGGRO1, player); - } - else - Talk(SAY_AGGRO2); - } - - void Reset() override - { - m_uiDeathCoilTimer = 4000; - m_uiChatTimer = 4000; - } - - void JustDied(Unit* killer) override - { - if (HasEscortState(STATE_ESCORT_ESCORTING)) - { - if (Player* player = GetPlayerForEscort()) - { - // not a likely case, code here for the sake of example - if (killer == me) - Talk(SAY_DEATH_1, player); - else - Talk(SAY_DEATH_2, player); - } - } - else - Talk(SAY_DEATH_3); - } - - void UpdateAI(uint32 uiDiff) override - { - //Must update npc_escortAI - npc_escortAI::UpdateAI(uiDiff); - - //Combat check - if (me->GetVictim()) - { - if (m_uiDeathCoilTimer <= uiDiff) - { - Talk(SAY_SPELL); - DoCastVictim(SPELL_DEATH_COIL, false); - m_uiDeathCoilTimer = 4000; - } - else - m_uiDeathCoilTimer -= uiDiff; - } - else - { - //Out of combat but being escorted - if (HasEscortState(STATE_ESCORT_ESCORTING)) - { - if (m_uiChatTimer <= uiDiff) - { - if (me->HasAura(SPELL_ELIXIR_OF_FORTITUDE)) - { - Talk(SAY_RAND_1); - DoCast(me, SPELL_BLUE_FIREWORK, false); - } - else - { - Talk(SAY_RAND_2); - DoCast(me, SPELL_ELIXIR_OF_FORTITUDE, false); - } - - m_uiChatTimer = 12000; - } - else - m_uiChatTimer -= uiDiff; - } - } - } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new example_escortAI(creature); - } - - bool OnGossipHello(Player* player, Creature* creature) override - { - player->TalkedToCreature(creature->GetEntry(), creature->GetGUID()); - player->PrepareGossipMenu(creature, 0); - - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - - player->SendPreparedGossip(creature); - - return true; - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override - { - player->PlayerTalkClass->ClearMenus(); - npc_escortAI* pEscortAI = CAST_AI(example_escort::example_escortAI, creature->AI()); - - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->CLOSE_GOSSIP_MENU(); - - if (pEscortAI) - pEscortAI->Start(true, true, player->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->CLOSE_GOSSIP_MENU(); - - if (pEscortAI) - pEscortAI->Start(false, false, player->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->CLOSE_GOSSIP_MENU(); - - if (pEscortAI) - pEscortAI->Start(false, true, player->GetGUID()); - break; - default: - return false; // nothing defined -> trinity core handling - } - - return true; // no default handling -> prevent trinity core handling - } -}; - -void AddSC_example_escort() -{ - new example_escort(); -} diff --git a/src/server/scripts/Examples/example_gossip_codebox.cpp b/src/server/scripts/Examples/example_gossip_codebox.cpp deleted file mode 100644 index 801159ff6ae..00000000000 --- a/src/server/scripts/Examples/example_gossip_codebox.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore - * Copyright (C) 2006-2009 ScriptDev2 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -/* ScriptData -SDName: Example_Gossip_Codebox -SD%Complete: 100 -SDComment: Show a codebox in gossip option -SDCategory: Script Examples -EndScriptData */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "ScriptedGossip.h" -#include "Player.h" -#include - -enum Yells -{ - // These texts must be added to the creature texts of the npc for which the script is assigned. - SAY_NOT_INTERESTED = 0, // "Normal select, guess you're not interested." - SAY_WRONG = 1, // "Wrong!" - SAY_CORRECT = 2 // "You're right, you are allowed to see my inner secrets." -}; - -enum Spells -{ - SPELL_POLYMORPH = 12826, - SPELL_MARK_OF_THE_WILD = 26990 -}; - -#define GOSSIP_ITEM_1 "A quiz: what's your name?" -#define GOSSIP_ITEM_2 "I'm not interested" - -class example_gossip_codebox : public CreatureScript -{ - public: - - example_gossip_codebox() - : CreatureScript("example_gossip_codebox") - { - } - - bool OnGossipHello(Player* player, Creature* creature) override - { - player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true); - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - - player->PlayerTalkClass->SendGossipMenu(907, creature->GetGUID()); - - return true; - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override - { - player->PlayerTalkClass->ClearMenus(); - if (action == GOSSIP_ACTION_INFO_DEF+2) - { - //Read comment in enum - creature->AI()->Talk(SAY_NOT_INTERESTED); - player->CLOSE_GOSSIP_MENU(); - } - - return true; - } - - bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code) override - { - player->PlayerTalkClass->ClearMenus(); - if (sender == GOSSIP_SENDER_MAIN) - { - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - if (player->GetName() != code) - { - //Read comment in enum - creature->AI()->Talk(SAY_WRONG); - creature->CastSpell(player, SPELL_POLYMORPH, true); - } - else - { - //Read comment in enum - creature->AI()->Talk(SAY_CORRECT); - creature->CastSpell(player, SPELL_MARK_OF_THE_WILD, true); - } - player->CLOSE_GOSSIP_MENU(); - - return true; - } - } - - return false; - } -}; - -void AddSC_example_gossip_codebox() -{ - new example_gossip_codebox(); -} diff --git a/src/server/scripts/Examples/example_misc.cpp b/src/server/scripts/Examples/example_misc.cpp deleted file mode 100644 index 1cf0d1375be..00000000000 --- a/src/server/scripts/Examples/example_misc.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore - * Copyright (C) 2006-2009 ScriptDev2 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -/* ScriptData -SDName: Example_Misc -SD%Complete: 100 -SDComment: Item, Areatrigger and other small code examples -SDCategory: Script Examples -EndScriptData */ - -#include "ScriptMgr.h" -#include "Player.h" - -class AT_example_areatrigger : public AreaTriggerScript -{ - public: - - AT_example_areatrigger() - : AreaTriggerScript("example_areatrigger") - { - } - - bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) override - { - player->Kill(player); - return true; - } -}; - -class ItemUse_example_item : public ItemScript -{ - public: - - ItemUse_example_item() - : ItemScript("example_item") - { - } - - bool OnUse(Player* /*player*/, Item* /*item*/, SpellCastTargets const& /*targets*/) override - { - sScriptMgr->LoadDatabase(); - return true; - } -}; - -class GOHello_example_go_teleporter : public GameObjectScript -{ - public: - - GOHello_example_go_teleporter() - : GameObjectScript("example_go_teleporter") - { - } - - bool OnGossipHello(Player* player, GameObject* /*go*/) override - { - player->TeleportTo(0, 1807.07f, 336.105f, 70.3975f, 0.0f); - return false; - } -}; - -void AddSC_example_misc() -{ - new AT_example_areatrigger(); - new ItemUse_example_item(); - new GOHello_example_go_teleporter(); -} diff --git a/src/server/scripts/Examples/example_spell.cpp b/src/server/scripts/Examples/example_spell.cpp deleted file mode 100644 index f90cc069780..00000000000 --- a/src/server/scripts/Examples/example_spell.cpp +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -/* - * An example of a spell script file - * to bind a script to spell you have to add entry for it in `spell_script_names` - * where `spell_id` is id of the spell to bind - * and `ScriptName` is the name of a script assigned on registration - */ - -#include "ScriptMgr.h" -#include "SpellAuras.h" -#include "SpellAuraEffects.h" -#include "SpellScript.h" -#include "Player.h" - -enum Spells -{ - SPELL_TRIGGERED = 18282 -}; - -class spell_ex_5581 : public SpellScriptLoader -{ - public: - spell_ex_5581() : SpellScriptLoader("spell_ex_5581") { } - - class spell_ex_5581SpellScript : public SpellScript - { - // initialize script, this macro does compile time check for type of the function - prevents possible issues - // if you have assigned wrong type of function to a hook you'll receive type conversion error during build - // this line is required, otherwise you'll get XXXHandlerFunction - identifier not found errors - PrepareSpellScript(spell_ex_5581SpellScript); - - std::string localVariable; - char* localVariable2; - - // function called on server startup - // checks if script has data required for it to work - bool Validate(SpellInfo const* /*spellInfo*/) override - { - // check if spellid 70522 exists in dbc, we will trigger it later - if (!sSpellMgr->GetSpellInfo(SPELL_TRIGGERED)) - return false; - return true; - } - - // function called just after script is added to spell - // we initialize local variables if needed - bool Load() override - { - localVariable = "we're using local variable"; - localVariable2 = new char(); - return true; - // return false - script will be immediately removed from the spell - // for example - we don't want this script to be executed on a creature - // if (GetCaster()->GetTypeID() != TYPEID_PLAYER) - // return false; - } - - // function called just before script delete - // we free allocated memory - void Unload() override - { - delete localVariable2; - } - - void HandleBeforeCast() - { - // this hook is executed before anything about casting the spell is done - // after this hook is executed all the machinery starts - TC_LOG_INFO("misc", "Caster just finished preparing the spell (cast bar has expired)"); - } - - void HandleOnCast() - { - // cast is validated and spell targets are selected at this moment - // this is a last place when the spell can be safely interrupted - TC_LOG_INFO("misc", "Spell is about to do take reagents, power, launch missile, do visuals and instant spell effects"); - } - - void HandleAfterCast() - { - TC_LOG_INFO("misc", "All immediate Actions for the spell are finished now"); - // this is a safe for triggering additional effects for a spell without interfering - // with visuals or with other effects of the spell - //GetCaster()->CastSpell(target, SPELL_TRIGGERED, true); - } - - SpellCastResult CheckRequirement() - { - // in this hook you can add additional requirements for spell caster (and throw a client error if reqs're not passed) - // in this case we're disallowing to select non-player as a target of the spell - //if (!GetExplTargetUnit() || GetExplTargetUnit()->ToPlayer()) - //return SPELL_FAILED_BAD_TARGETS; - return SPELL_CAST_OK; - } - - - void HandleDummyLaunch(SpellEffIndex /*effIndex*/) - { - TC_LOG_INFO("misc", "Spell %u with SPELL_EFFECT_DUMMY is just launched!", GetSpellInfo()->Id); - } - - void HandleDummyLaunchTarget(SpellEffIndex /*effIndex*/) - { - ObjectGuid targetGUID; - if (Unit* unitTarget = GetHitUnit()) - targetGUID = unitTarget->GetGUID(); - // we're handling SPELL_EFFECT_DUMMY in effIndex 0 here - TC_LOG_INFO("misc", "Spell %u with SPELL_EFFECT_DUMMY is just launched at it's target: " UI64FMTD "!", GetSpellInfo()->Id, targetGUID.GetRawValue()); - } - - void HandleDummyHit(SpellEffIndex /*effIndex*/) - { - TC_LOG_INFO("misc", "Spell %u with SPELL_EFFECT_DUMMY has hit!", GetSpellInfo()->Id); - } - - void HandleDummyHitTarget(SpellEffIndex /*effIndex*/) - { - TC_LOG_INFO("misc", "SPELL_EFFECT_DUMMY is hits it's target!"); - // make caster cast a spell on a unit target of effect - if (Unit* target = GetHitUnit()) - GetCaster()->CastSpell(target, SPELL_TRIGGERED, true); - } - - void HandleBeforeHit() - { - TC_LOG_INFO("misc", "Spell is about to hit target!"); - } - - void HandleOnHit() - { - TC_LOG_INFO("misc", "Spell just hit target!"); - } - - void HandleAfterHit() - { - TC_LOG_INFO("misc", "Spell just finished hitting target!"); - } - - void FilterTargets(std::list& /*targetList*/) - { - // usually you want this call for Area Target spells - TC_LOG_INFO("misc", "Spell is about to add targets from targetList to final targets!"); - } - - // register functions used in spell script - names of these functions do not matter - void Register() override - { - // we're registering our functions here - BeforeCast += SpellCastFn(spell_ex_5581SpellScript::HandleBeforeCast); - OnCast += SpellCastFn(spell_ex_5581SpellScript::HandleOnCast); - AfterCast += SpellCastFn(spell_ex_5581SpellScript::HandleAfterCast); - OnCheckCast += SpellCheckCastFn(spell_ex_5581SpellScript::CheckRequirement); - // function HandleDummy will be called when spell is launched, independant from targets selected for spell, just before default effect 0 launch handler - OnEffectLaunch += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyLaunch, EFFECT_0, SPELL_EFFECT_DUMMY); - // function HandleDummy will be called when spell is launched at target, just before default effect 0 launch at target handler - OnEffectLaunchTarget += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyLaunchTarget, EFFECT_0, SPELL_EFFECT_DUMMY); - // function HandleDummy will be called when spell hits it's destination, independant from targets selected for spell, just before default effect 0 hit handler - OnEffectHit += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyHit, EFFECT_0, SPELL_EFFECT_DUMMY); - // function HandleDummy will be called when unit is hit by spell, just before default effect 0 hit target handler - OnEffectHitTarget += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyHitTarget, EFFECT_0, SPELL_EFFECT_DUMMY); - // this will prompt an error on startup because effect 0 of spell 49375 is set to SPELL_EFFECT_DUMMY, not SPELL_EFFECT_APPLY_AURA - //OnEffectHitTarget += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_APPLY_AURA); - // this will make HandleDummy function to be called on first != 0 effect of spell 49375 - //OnEffectHitTarget += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_FIRST_FOUND, SPELL_EFFECT_ANY); - // this will make HandleDummy function to be called on all != 0 effect of spell 49375 - //OnEffectHitTarget += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_ALL, SPELL_EFFECT_ANY); - // bind handler to BeforeHit event of the spell - BeforeHit += SpellHitFn(spell_ex_5581SpellScript::HandleBeforeHit); - // bind handler to OnHit event of the spell - OnHit += SpellHitFn(spell_ex_5581SpellScript::HandleOnHit); - // bind handler to AfterHit event of the spell - AfterHit += SpellHitFn(spell_ex_5581SpellScript::HandleAfterHit); - // bind handler to OnUnitTargetSelect event of the spell - //OnUnitTargetSelect += SpellUnitTargetFn(spell_ex_5581SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_CASTER); - } - }; - - // function which creates SpellScript - SpellScript* GetSpellScript() const override - { - return new spell_ex_5581SpellScript(); - } -}; - -class spell_ex_66244 : public SpellScriptLoader -{ - public: - spell_ex_66244() : SpellScriptLoader("spell_ex_66244") { } - - class spell_ex_66244AuraScript : public AuraScript - { - PrepareAuraScript(spell_ex_66244AuraScript); - // function called on server startup - // checks if script has data required for it to work - bool Validate(SpellInfo const* /*spellInfo*/) override - { - // check if spellid exists in dbc, we will trigger it later - if (!sSpellMgr->GetSpellInfo(SPELL_TRIGGERED)) - return false; - return true; - } - - // function called in aura constructor - // we initialize local variables if needed - bool Load() override - { - // do not load script if aura is cast by player or caster not avalible - if (Unit* caster = GetCaster()) - if (caster->GetTypeId() == TYPEID_PLAYER) - return true; - return false; - } - - - void HandleOnEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - TC_LOG_INFO("misc", "Aura Effect is about to be applied on target!"); - // this hook allows you to prevent execution of AuraEffect handler, or to replace it with your own handler - //PreventDefaultAction(); - } - void HandleOnEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - TC_LOG_INFO("misc", "Aura Effect is about to be removed from target!"); - // this hook allows you to prevent execution of AuraEffect handler, or to replace it with your own handler - //PreventDefaultAction(); - } - - void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - TC_LOG_INFO("misc", "Aura Effect has just been applied on target!"); - Unit* target = GetTarget(); - // cast spell on target on aura apply - target->CastSpell(target, SPELL_TRIGGERED, true); - } - - void HandleAfterEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - TC_LOG_INFO("misc", "Aura Effect has just been just removed from target!"); - Unit* target = GetTarget(); - Unit* caster = GetCaster(); - // caster may be not avalible (logged out for example) - if (!caster) - return; - // cast spell on caster on aura remove - target->CastSpell(caster, SPELL_TRIGGERED, true); - } - - void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) - { - TC_LOG_INFO("misc", "Perioidic Aura Effect is does a tick on target!"); - Unit* target = GetTarget(); - // aura targets damage self on tick - target->DealDamage(target, 100); - } - - void HandleEffectPeriodicUpdate(AuraEffect* aurEff) - { - TC_LOG_INFO("misc", "Perioidic Aura Effect is now updated!"); - // we're doubling aura amount every tick - aurEff->ChangeAmount(aurEff->GetAmount() * 2); - } - - void HandleEffectCalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) - { - TC_LOG_INFO("misc", "Amount of Aura Effect is being calculated now!"); - // we're setting amount to 100 - amount = 100; - // amount will be never recalculated due to applying passive aura - canBeRecalculated = false; - } - - void HandleEffectCalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude) - { - TC_LOG_INFO("misc", "Periodic data of Aura Effect is being calculated now!"); - // we're setting aura to be periodic and tick every 10 seconds - isPeriodic = true; - amplitude = 2 * IN_MILLISECONDS; - } - - void HandleEffectCalcSpellMod(AuraEffect const* /*aurEff*/, SpellModifier*& spellMod) - { - TC_LOG_INFO("misc", "SpellMod data of Aura Effect is being calculated now!"); - // we don't want spellmod for example - if (spellMod) - { - delete spellMod; - spellMod = NULL; - } - /* - // alternative: we want spellmod for spell which doesn't have it - if (!spellMod) - { - spellMod = new SpellModifier(GetAura()); - spellMod->op = SPELLMOD_DOT; - spellMod->type = SPELLMOD_PCT; - spellMod->spellId = GetId(); - spellMod->mask[1] = 0x00002000; - } - */ - } - - // function registering - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_ex_66244AuraScript::HandleOnEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - OnEffectRemove += AuraEffectRemoveFn(spell_ex_66244AuraScript::HandleOnEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - // AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK - makes handler to be called when aura is reapplied on target - AfterEffectApply += AuraEffectApplyFn(spell_ex_66244AuraScript::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - AfterEffectRemove += AuraEffectRemoveFn(spell_ex_66244AuraScript::HandleAfterEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - OnEffectPeriodic += AuraEffectPeriodicFn(spell_ex_66244AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_DUMMY); - OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_ex_66244AuraScript::HandleEffectPeriodicUpdate, EFFECT_0, SPELL_AURA_DUMMY); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ex_66244AuraScript::HandleEffectCalcAmount, EFFECT_0, SPELL_AURA_DUMMY); - DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_ex_66244AuraScript::HandleEffectCalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY); - DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_ex_66244AuraScript::HandleEffectCalcSpellMod, EFFECT_0, SPELL_AURA_DUMMY); - /*OnApply += AuraEffectApplyFn(); - OnRemove += AuraEffectRemoveFn(); - DoCheckAreaTarget += AuraCheckAreaTargetFn();*/ - } - /* - void OnApply() - { - } - - void OnRemove() - { - } - - bool DoCheckAreaTarget(Unit* proposedTarget) - { - }*/ - }; - - // function which creates AuraScript - AuraScript* GetAuraScript() const override - { - return new spell_ex_66244AuraScript(); - } -}; - -// example usage of OnEffectManaShield and AfterEffectManaShield hooks -// see spell_ex_absorb_aura, these hooks work the same as OnEffectAbsorb and AfterEffectAbsorb - -// example usage of OnEffectAbsorb and AfterEffectAbsorb hooks -class spell_ex_absorb_aura : public SpellScriptLoader -{ - public: - spell_ex_absorb_aura() : SpellScriptLoader("spell_ex_absorb_aura") { } - - class spell_ex_absorb_auraAuraScript : public AuraScript - { - PrepareAuraScript(spell_ex_absorb_auraAuraScript); - - void HandleOnEffectAbsorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) - { - TC_LOG_INFO("misc", "Our aura is now absorbing damage done to us!"); - // absorb whole damage done to us - absorbAmount = dmgInfo.GetDamage(); - } - - void HandleAfterEffectAbsorb(AuraEffect* /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount) - { - TC_LOG_INFO("misc", "Our aura has absorbed %u damage!", absorbAmount); - } - - // function registering - void Register() override - { - OnEffectAbsorb += AuraEffectAbsorbFn(spell_ex_absorb_auraAuraScript::HandleOnEffectAbsorb, EFFECT_0); - AfterEffectAbsorb += AuraEffectAbsorbFn(spell_ex_absorb_auraAuraScript::HandleAfterEffectAbsorb, EFFECT_0); - } - }; - - // function which creates AuraScript - AuraScript* GetAuraScript() const override - { - return new spell_ex_absorb_auraAuraScript(); - } -}; - -class spell_ex_463 : public SpellScriptLoader -{ - public: - spell_ex_463() : SpellScriptLoader("spell_ex_463") { } - - class spell_ex_463AuraScript : public AuraScript - { - PrepareAuraScript(spell_ex_463AuraScript); - - bool CheckAreaTarget(Unit* target) - { - TC_LOG_INFO("misc", "Area aura checks if unit is a valid target for it!"); - // in our script we allow only players to be affected - return target->GetTypeId() == TYPEID_PLAYER; - } - void Register() override - { - DoCheckAreaTarget += AuraCheckAreaTargetFn(spell_ex_463AuraScript::CheckAreaTarget); - } - }; - - // function which creates AuraScript - AuraScript* GetAuraScript() const override - { - return new spell_ex_463AuraScript(); - } -}; - -// this function has to be added to function set in ScriptLoader.cpp -void AddSC_example_spell_scripts() -{ - new spell_ex_5581; - new spell_ex_66244; - new spell_ex_absorb_aura; - new spell_ex_463; -} - -/* empty script for copypasting -class spell_ex : public SpellScriptLoader -{ - public: - spell_ex() : SpellScriptLoader("spell_ex") { } - - class spell_ex_SpellScript : public SpellScript - { - PrepareSpellScript(spell_ex_SpellScript); - - //bool Validate(SpellInfo const* spellEntry){return true;} override - //bool Load(){return true;} - //void Unload(){ } - - //void Function(SpellEffIndex effIndex) //OnEffect += SpellEffectFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_EFFECT_ANY); - //void Function() //OnHit += SpellEffectFn(spell_ex_SpellScript::Function); - void Register() override - { - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_ex_SpellScript(); - } -}; -*/ - -/* empty script for copypasting -class spell_ex : public SpellScriptLoader -{ - public: - spell_ex() : SpellScriptLoader("spell_ex") { } - - class spell_ex_AuraScript : public AuraScript - { - PrepareAuraScript(spell_ex) - //bool Validate(SpellInfo const* spellEntry){return true;} override - //bool Load(){return true;} - //void Unload(){ } - - //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, AuraEffectHandleModes mode) //OnEffectApply += AuraEffectApplyFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL); - //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, AuraEffectHandleModes mode) //OnEffectRemove += AuraEffectRemoveFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL); - //void spell_ex_SpellScript::Function(AuraEffect const* aurEff) //OnEffectPeriodic += AuraEffectPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); - //void spell_ex_SpellScript::Function(AuraEffect* aurEff) //OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); - //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) //DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); - //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude) //OnEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); - //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, SpellModifier*& spellMod) //OnEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); - void Register() override - { - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_ex_AuraScript(); - } -}; -*/ -- cgit v1.2.3 From ec59c3ab0377f4077a2d63e7b242f2a3693dd2d4 Mon Sep 17 00:00:00 2001 From: Morgoporc Date: Mon, 22 Sep 2014 01:05:13 +0100 Subject: Core/Players/DK: Implement Rune Grace Period mechanic Closes #11736 Fixes #6122 --- src/server/game/Entities/Player/Player.cpp | 51 +++++++++++++++++++++++++++--- src/server/game/Entities/Player/Player.h | 10 +++++- src/server/game/Entities/Unit/Unit.cpp | 12 ++++++- src/server/game/Spells/Spell.cpp | 4 +-- 4 files changed, 69 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index b0c844c82ba..0a2dc3366d7 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -735,6 +735,13 @@ Player::Player(WorldSession* session): Unit(true) m_DailyQuestChanged = false; m_lastDailyQuestTime = 0; + // Init rune flags + for (uint8 i = 0; i < MAX_RUNES; ++i) + { + SetRuneTimer(i, 0xFFFFFFFF); + SetLastRuneGraceTimer(i, 0); + } + for (uint8 i=0; i < MAX_TIMERS; i++) m_MirrorTimer[i] = DISABLED_MIRROR_TIMER; @@ -1846,6 +1853,26 @@ void Player::Update(uint32 p_time) } } + if (getClass() == CLASS_DEATH_KNIGHT) + { + // Update rune timers + for (uint8 i = 0; i < MAX_RUNES; ++i) + { + uint32 timer = GetRuneTimer(i); + + // Don't update timer if rune is disabled + if (GetRuneCooldown(i)) + continue; + + // Timer has began + if (timer < 0xFFFFFFFF) + { + timer += p_time; + SetRuneTimer(i, std::min(uint32(2500), timer)); + } + } + } + // group update SendUpdateToOutOfRangeGroupMembers(); @@ -24724,8 +24751,22 @@ uint32 Player::GetRuneBaseCooldown(uint8 index) return cooldown; } -void Player::SetRuneCooldown(uint8 index, uint32 cooldown) +void Player::SetRuneCooldown(uint8 index, uint32 cooldown, bool casted /*= false*/) { + uint32 gracePeriod = GetRuneTimer(index); + + if (casted && IsInCombat()) + { + if (gracePeriod < 0xFFFFFFFF && cooldown > 0) + { + uint32 lessCd = std::min(uint32(2500), gracePeriod); + cooldown = (cooldown > lessCd) ? (cooldown - lessCd) : 0; + SetLastRuneGraceTimer(index, lessCd); + } + + SetRuneTimer(index, 0); + } + m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); } @@ -24822,9 +24863,11 @@ void Player::InitRunes() for (uint8 i = 0; i < MAX_RUNES; ++i) { - SetBaseRune(i, runeSlotTypes[i]); // init base types - SetCurrentRune(i, runeSlotTypes[i]); // init current types - SetRuneCooldown(i, 0); // reset cooldowns + SetBaseRune(i, runeSlotTypes[i]); // init base types + SetCurrentRune(i, runeSlotTypes[i]); // init current types + SetRuneCooldown(i, 0); // reset cooldowns + SetRuneTimer(i, 0xFFFFFFFF); // Reset rune flags + SetLastRuneGraceTimer(i, 0); SetRuneConvertAura(i, NULL); m_runes->SetRuneState(i); } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 1deb21fb01b..8ed561bc95b 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1828,6 +1828,10 @@ class Player : public Unit, public GridObject void ApplyHealthRegenBonus(int32 amount, bool apply); void UpdateManaRegen(); void UpdateRuneRegen(RuneType rune); + uint32 GetRuneTimer(uint8 index) const { return m_runeGraceCooldown[index]; } + void SetRuneTimer(uint8 index, uint32 timer) { m_runeGraceCooldown[index] = timer; } + uint32 GetLastRuneGraceTimer(uint8 index) const { return m_lastRuneGraceTimers[index]; } + void SetLastRuneGraceTimer(uint8 index, uint32 timer) { m_lastRuneGraceTimers[index] = timer; } ObjectGuid GetLootGUID() const { return m_lootGuid; } void SetLootGUID(ObjectGuid guid) { m_lootGuid = guid; } @@ -2284,7 +2288,7 @@ class Player : public Unit, public GridObject void SetLastUsedRune(RuneType type) { m_runes->lastUsedRune = type; } void SetBaseRune(uint8 index, RuneType baseRune) { m_runes->runes[index].BaseRune = baseRune; } void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; } - void SetRuneCooldown(uint8 index, uint32 cooldown); + void SetRuneCooldown(uint8 index, uint32 cooldown, bool casted = false); void SetRuneConvertAura(uint8 index, AuraEffect const* aura); void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura); void RemoveRunesByAuraEffect(AuraEffect const* aura); @@ -2634,6 +2638,10 @@ class Player : public Unit, public GridObject uint8 m_MirrorTimerFlagsLast; bool m_isInWater; + // Rune type / Rune timer + uint32 m_runeGraceCooldown[MAX_RUNES]; + uint32 m_lastRuneGraceTimers[MAX_RUNES]; + // Current teleport data WorldLocation m_teleport_dest; uint32 m_teleport_options; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c4569887abf..a3b8adf85d0 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -7604,7 +7604,7 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp player->GetBaseRune(i) != RUNE_BLOOD) continue; } - if (player->GetRuneCooldown(i) != player->GetRuneBaseCooldown(i)) + if (player->GetRuneCooldown(i) != (player->GetRuneBaseCooldown(i) - player->GetLastRuneGraceTimer(i))) continue; --runesLeft; @@ -11760,6 +11760,16 @@ void Unit::ClearInCombat() m_CombatTimer = 0; RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + // Reset rune flags after combat + if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_DEATH_KNIGHT) + { + for (uint8 i = 0; i < MAX_RUNES; ++i) + { + ToPlayer()->SetRuneTimer(i, 0xFFFFFFFF); + ToPlayer()->SetLastRuneGraceTimer(i, 0); + } + } + // Player's state will be cleared in Player::UpdateContestedPvP if (Creature* creature = ToCreature()) { diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index aedfeb149eb..31aecbb65a0 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4445,7 +4445,7 @@ void Spell::TakeRunePower(bool didHit) RuneType rune = player->GetCurrentRune(i); if (!player->GetRuneCooldown(i) && runeCost[rune] > 0) { - player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN)); + player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN), true); player->SetLastUsedRune(rune); runeCost[rune]--; } @@ -4460,7 +4460,7 @@ void Spell::TakeRunePower(bool didHit) RuneType rune = player->GetCurrentRune(i); if (!player->GetRuneCooldown(i) && rune == RUNE_DEATH) { - player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN)); + player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN), true); player->SetLastUsedRune(rune); runeCost[rune]--; -- cgit v1.2.3