• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

My First Script - World Boss.

Portals

Banned
Code:
#include "ScriptPCH.h"
#include "ScriptedCreature.h"

enum Spells
{
	SPELL_1			= SPELL ID, //This is the first spell the boss will cast.
	SPELL_2			= SPELL ID, //This is the first spell the boss will cast.
	SPELL_3			= SPELL ID, //This is the first spell the boss will cast.
	SPELL_4			= SPELL ID  //This is the frenzy spell the boss will cast.
};

class Boss_Segacedi: public CreatureScript
{
public:
	Boss_Segacedi() : CreatureScript("Boss_Segacedi") { } //Make a creature in your DB, and set Boss_Segacedi in the script collumn.

	CreatureAI* GetAI(Creature* creature) const
	{
		return new Boss_SegacediAI (creature);
	}
	struct Boss_SegacediAI : public ScriptedAI
	{
		uint32 SPELL1Timer;
		uint32 SPELL2Timer;
		uint32 SPELL3Timer;
		bool IsEnraged;

		void Reset()
		{
			SPELL1Timer = 6000;   // This is in milliseconds, 1000 milliseconds = 1 second. At the moment this spell will be casted every 6 seconds.
			SPELL2Timer = 12000;  // This is in milliseconds, 1000 milliseconds = 1 second. At the moment this spell will be casted every 12 seconds.
			SPELL3Timer = 18000;  // This is in milliseconds, 1000 milliseconds = 1 second. At the moment this spell will be casted every 18 seconds.
			isEnraged = false;
		}

		void EnterCombat(Unit* /*who*/)
		{
			me->MonsterSay("Who dare enters my lake?", LANG_UNIVERSAL, NULL); // When you enter combat with the creature he will say this. Edit in between the "" with your desired message.
		}

		void UpdateAI(uint32 diff)
		{
			if (!UpdateVictim())
				return;

			if (SPELL1Timer < diff)
			{
				DoCastVictim(SPELL_1);
				SPELL1Timer = 6000;
			} else SPELL1Timer -= diff;

			if (SPELL2Timer < diff)
			{
				DoCastVictim(SPELL_2);
				SPELL2Timer = 12000;
			} else SPELL2Timer -= diff;
			
			if (SPELL3Timer < diff)
			{
				DoCastVictim(SPELL_3);
				SPELL3Timer = 18000;
			} else SPELL3Timer -= diff;

			if (!IsEnraged && HealthBelowPct(20))
			{
				DoCast(me, SPELL_FRENZY);
				isEnraged = true;
			}

			DoMeleeAttackIfReady();
		}
	};
};

void AddSC_Boss_Segacedi ()
{
	new Boss_Segacedi();
}

This is NOT a copy and paste script you need to edit the SPELL ID and the timers. Should compile fine though just let me know if there are any errors, also remember this is my first C++ script.
 

Tommy

Founder
Good for a first try.

Little things to note:

You don't need to include those header files, considering TrinityCore changed some stuff up where you don't need them anymore.
Watch out for the bad indentation! That makes it hard for humans to read, but it is fine as it is being a first.

Other than that, it is great.
 

Portals

Banned
Good for a first try.

Little things to note:

You don't need to include those header files, considering TrinityCore changed some stuff up where you don't need them anymore.
Watch out for the bad indentation! That makes it hard for humans to read, but it is fine as it is being a first.

Other than that, it is great.

Thanks for the tips! Making a healer npc next!
 

Hamar

BETA Tester
For starter it's pretty great, when i started i had difficulties understanding pretty much everything and the code wasn't readable at all.
 
Top