aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/scripts/World/mob_generic_creature.cpp180
1 files changed, 0 insertions, 180 deletions
diff --git a/src/server/scripts/World/mob_generic_creature.cpp b/src/server/scripts/World/mob_generic_creature.cpp
index 5a1a10cd677..6fee5b870b9 100644
--- a/src/server/scripts/World/mob_generic_creature.cpp
+++ b/src/server/scripts/World/mob_generic_creature.cpp
@@ -16,167 +16,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* ScriptData
-SDName: Generic_Creature
-SD%Complete: 80
-SDComment: Should be replaced with core based AI
-SDCategory: Creatures
-EndScriptData */
-
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "PassiveAI.h"
-#define GENERIC_CREATURE_COOLDOWN 5000
-
-class generic_creature : public CreatureScript
-{
-public:
- generic_creature() : CreatureScript("generic_creature") { }
-
- struct generic_creatureAI : public ScriptedAI
- {
- generic_creatureAI(Creature* creature) : ScriptedAI(creature)
- {
- Initialize();
- }
-
- void Initialize()
- {
- GlobalCooldown = 0;
- BuffTimer = 0; //Rebuff as soon as we can
- IsSelfRooted = false;
- }
-
- uint32 GlobalCooldown; //This variable acts like the global cooldown that players have (1.5 seconds)
- uint32 BuffTimer; //This variable keeps track of buffs
- bool IsSelfRooted;
-
- void Reset() override
- {
- Initialize();
- }
-
- void EnterCombat(Unit* who) override
- {
- if (!me->IsWithinMeleeRange(who))
- IsSelfRooted = true;
- }
-
- void UpdateAI(uint32 diff) override
- {
- //Always decrease our global cooldown first
- if (GlobalCooldown > diff)
- GlobalCooldown -= diff;
- else GlobalCooldown = 0;
-
- //Buff timer (only buff when we are alive and not in combat
- if (!me->IsInCombat() && me->IsAlive())
- {
- if (BuffTimer <= diff)
- {
- //Find a spell that targets friendly and applies an aura (these are generally buffs)
- SpellInfo const* info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, SELECT_EFFECT_AURA);
-
- if (info && !GlobalCooldown)
- {
- //Cast the buff spell
- DoCastSpell(me, info);
-
- //Set our global cooldown
- GlobalCooldown = GENERIC_CREATURE_COOLDOWN;
-
- //Set our timer to 10 minutes before rebuff
- BuffTimer = 600000;
- }//Try agian in 30 seconds
- else BuffTimer = 30000;
- } else BuffTimer -= diff;
- }
-
- //Return since we have no target
- if (!UpdateVictim())
- return;
-
- //If we are within range melee the target
- if (me->IsWithinMeleeRange(me->GetVictim()))
- {
- //Make sure our attack is ready and we arn't currently casting
- if (me->isAttackReady() && !me->IsNonMeleeSpellCast(false))
- {
- bool Healing = false;
- SpellInfo const* info = NULL;
-
- //Select a healing spell if less than 30% hp
- if (HealthBelowPct(30))
- info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, SELECT_EFFECT_HEALING);
-
- //No healing spell available, select a hostile spell
- if (info) Healing = true;
- else info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, 0, 0, SELECT_EFFECT_DONTCARE);
-
- //50% chance if elite or higher, 20% chance if not, to replace our white hit with a spell
- if (info && (rand32() % (me->GetCreatureTemplate()->rank > 1 ? 2 : 5) == 0) && !GlobalCooldown)
- {
- //Cast the spell
- if (Healing)DoCastSpell(me, info);
- else DoCastSpell(me->GetVictim(), info);
-
- //Set our global cooldown
- GlobalCooldown = GENERIC_CREATURE_COOLDOWN;
- }
- else me->AttackerStateUpdate(me->GetVictim());
-
- me->resetAttackTimer();
- }
- }
- else
- {
- //Only run this code if we arn't already casting
- if (!me->IsNonMeleeSpellCast(false))
- {
- bool Healing = false;
- SpellInfo const* info = NULL;
-
- //Select a healing spell if less than 30% hp ONLY 33% of the time
- if (HealthBelowPct(30) && rand32() % 3 == 0)
- info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, SELECT_EFFECT_HEALING);
-
- //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE)
- if (info) Healing = true;
- else info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE);
-
- //Found a spell, check if we arn't on cooldown
- if (info && !GlobalCooldown)
- {
- //If we are currently moving stop us and set the movement generator
- if (!IsSelfRooted)
- IsSelfRooted = true;
-
- //Cast spell
- if (Healing) DoCastSpell(me, info);
- else DoCastSpell(me->GetVictim(), info);
-
- //Set our global cooldown
- GlobalCooldown = GENERIC_CREATURE_COOLDOWN;
-
- }//If no spells available and we arn't moving run to target
- else if (IsSelfRooted)
- {
- //Cancel our current spell and then allow movement agian
- me->InterruptNonMeleeSpells(false);
- IsSelfRooted = false;
- }
- }
- }
- }
- };
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new generic_creatureAI(creature);
- }
-};
-
class trigger_periodic : public CreatureScript
{
public:
@@ -213,30 +56,7 @@ public:
}
};
-class trigger_death : public CreatureScript
-{
-public:
- trigger_death() : CreatureScript("trigger_death") { }
-
- struct trigger_deathAI : public NullCreatureAI
- {
- trigger_deathAI(Creature* creature) : NullCreatureAI(creature) { }
- void JustDied(Unit* killer) override
- {
- if (me->m_spells[0])
- me->CastSpell(killer, me->m_spells[0], true);
- }
- };
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new trigger_deathAI(creature);
- }
-};
-
void AddSC_generic_creature()
{
- //new generic_creature;
new trigger_periodic();
- //new trigger_death;
}