PDA

View Full Version : [SkyFireEmu] BurningBerserk NPC Script ( 85% Finished )



Dr.Core
09-11-15, 05:36 PM
/*
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
*
* 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 "ObjectMgr.h"
#include "ScriptMgr.h"
#include "Object.h"
#include "Player.h"
#include "GameObject.h"
#include "GameObjectAI.h"
#include "Unit.h"
#include "UnitAI.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
#include "Spell.h"

enum Spells
{
SPELL_FORAGE = 149463,
SPELL_FIERY_CHARGE = 147704,
SPELL_BLAZING_CLEAVE = 147702,
SPELL_BURNING_FURY = 66721,
};

enum Events
{
EVENT_FORAGE = 1,
EVENT_FIERY_CHARGE = 2,
EVENT_BLAZING_CLEAVE = 3,
EVENT_BURNING_FURY = 4,
};

class npc_burning_berserker : public CreatureScript
{
public:
npc_burning_berserker() : CreatureScript("npc_burning_berserker") { }

struct npc_burning_berserkerAI : public ScriptedAI
{
npc_burning_berserkerAI(Creature* creature) : ScriptedAI(creature) { }

void Reset() override
{
_events.Reset();
_events.ScheduleEvent(EVENT_FORAGE, 5000);
}

void EnterCombat(Unit* /*who*/) override
{
_events.ScheduleEvent(EVENT_FIERY_CHARGE, 1000);
}

void UpdateAI(uint32 diff) override
{
_events.Update(diff);

if (!InCombat)

DoCast(SPELL_FORAGE, urand(2000, 8000));
return;

if (Unit* unit = SelectTarget(SELECT_TARGET_NEAREST, 0, 0.0f, true))
{
if (me->IsWithinMeleeRange(unit) && unit->isInFront(me))
DoCast(unit, SPELL_FIERY_CHARGE);
else
return;
}

while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_FIERY_CHARGE:
DoCast(SPELL_FIERY_CHARGE);
_events.ScheduleEvent(EVENT_FIERY_CHARGE, 30000);
break;
case EVENT_BLAZING_CLEAVE:
DoCast(SPELL_BLAZING_CLEAVE);
_events.ScheduleEvent(EVENT_BLAZING_CLEAVE, 5000);
break;
case EVENT_BURNING_FURY:
DoCast(SPELL_BURNING_FURY);
_events.ScheduleEvent(EVENT_BURNING_FURY, 30000);
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}

private:
bool InCombat;
EventMap _events;
};

CreatureAI* GetAI(Creature* creature) const override
{
return new npc_burning_berserkerAI(creature);
}
};

void AddSC_npc_burning_berserker()
{
new npc_burning_berserker();
}


Todo :

Cast FORAGE between 2 and 8 seconds out of combat
Cast Spell Charge if aggro is taken
Remove BURNING_FURY after 5 seconds and recast it after 10 seconds