aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/World
diff options
context:
space:
mode:
authoroffl <11556157+offl@users.noreply.github.com>2021-11-10 16:49:33 +0200
committerShauren <shauren.trinity@gmail.com>2022-03-21 23:12:00 +0100
commit7698203122a0f5e2e0e138b6dcaa93d383dce31a (patch)
tree24a25ad17cb957594e9860a3342b1bcba7c36388 /src/server/scripts/World
parent726489201ea0c89b5e742ff17d217bc722700411 (diff)
Scripts/Creature: Replace trigger_periodic with unique scripts (#27240)
(cherry picked from commit 7a307ebb6d08f614f11020418fa1c697f084a6bc)
Diffstat (limited to 'src/server/scripts/World')
-rw-r--r--src/server/scripts/World/mob_generic_creature.cpp64
-rw-r--r--src/server/scripts/World/npcs_special.cpp32
-rw-r--r--src/server/scripts/World/world_script_loader.cpp2
3 files changed, 32 insertions, 66 deletions
diff --git a/src/server/scripts/World/mob_generic_creature.cpp b/src/server/scripts/World/mob_generic_creature.cpp
deleted file mode 100644
index b4817c81523..00000000000
--- a/src/server/scripts/World/mob_generic_creature.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "ScriptMgr.h"
-#include "Creature.h"
-#include "Map.h"
-#include "PassiveAI.h"
-#include "SpellInfo.h"
-#include "SpellMgr.h"
-
-class trigger_periodic : public CreatureScript
-{
-public:
- trigger_periodic() : CreatureScript("trigger_periodic") { }
-
- struct trigger_periodicAI : public NullCreatureAI
- {
- trigger_periodicAI(Creature* creature) : NullCreatureAI(creature)
- {
- spell = me->m_spells[0] ? sSpellMgr->GetSpellInfo(me->m_spells[0], me->GetMap()->GetDifficultyID()) : nullptr;
- interval = me->GetBaseAttackTime(BASE_ATTACK);
- timer = interval;
- }
-
- uint32 timer, interval;
- SpellInfo const* spell;
-
- void UpdateAI(uint32 diff) override
- {
- if (timer <= diff)
- {
- if (spell)
- me->CastSpell(me, spell->Id, CastSpellExtraArgs(TRIGGERED_FULL_MASK).SetCastDifficulty(spell->Difficulty));
- timer = interval;
- }
- else
- timer -= diff;
- }
- };
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new trigger_periodicAI(creature);
- }
-};
-
-void AddSC_generic_creature()
-{
- new trigger_periodic();
-}
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index 4ebe7e96499..32f6c9bde6f 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -2598,6 +2598,37 @@ public:
}
};
+enum VoidZone
+{
+ SPELL_CONSUMPTION = 28874
+};
+
+struct npc_gen_void_zone : public ScriptedAI
+{
+ npc_gen_void_zone(Creature* creature) : ScriptedAI(creature) { }
+
+ void InitializeAI() override
+ {
+ me->SetReactState(REACT_PASSIVE);
+ }
+
+ void JustAppeared() override
+ {
+ _scheduler.Schedule(2s, [this](TaskContext /*task*/)
+ {
+ DoCastSelf(SPELL_CONSUMPTION);
+ });
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ _scheduler.Update(diff);
+ }
+
+private:
+ TaskScheduler _scheduler;
+};
+
void AddSC_npcs_special()
{
new npc_air_force_bots();
@@ -2622,4 +2653,5 @@ void AddSC_npcs_special()
new npc_train_wrecker();
new npc_argent_squire_gruntling();
new npc_bountiful_table();
+ RegisterCreatureAI(npc_gen_void_zone);
}
diff --git a/src/server/scripts/World/world_script_loader.cpp b/src/server/scripts/World/world_script_loader.cpp
index ea930bd7529..3e28250d381 100644
--- a/src/server/scripts/World/world_script_loader.cpp
+++ b/src/server/scripts/World/world_script_loader.cpp
@@ -22,7 +22,6 @@
void AddSC_areatrigger_scripts();
void AddSC_conversation_scripts();
void AddSC_emerald_dragons();
-void AddSC_generic_creature();
void AddSC_go_scripts();
void AddSC_npc_guard();
void AddSC_item_scripts();
@@ -44,7 +43,6 @@ void AddWorldScripts()
AddSC_areatrigger_scripts();
AddSC_conversation_scripts();
AddSC_emerald_dragons();
- AddSC_generic_creature();
AddSC_go_scripts();
AddSC_npc_guard();
AddSC_item_scripts();