[Archive] [3.3.5] Mini Boss C ++ Tutorial
[Archive] [3.3.5] Mini Boss C ++ Tutorial
Quote: #include "ScriptMgr.h"In the type enums Spells we will take some easy to use spell, a cleave, and an enrage, nothing more simple.
enum Spells
{
};
class World_Boss : public CreatureScript
{
public:
World_Boss() : CreatureScript("World_Boss") { } // script name onto the DB
struct World_BossAI : public ScriptedAI
{
World_BossAI(Creature* creature) : ScriptedAI(creature) {}
void JustEngagedWith(Unit* /*who*/) override
{
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new World_BossAI(creature);
}
};
void AddSC_World_Boss()
{
new World_Boss();
}
Click to expand...
Quote: enum SpellsThen there are several functions available like the one we are going to use:
{
SPELL_CLEAVE = 15284,
SPELL_ENRAGE = 27680
};
Click to expand...
Quote: void JustEngagedWith (Unit * / * who * /) // Function called when combat is engagedWe will start by using the main function.
void JustDied (Unit * / * killer * /) // Function called when the creature is dead
void KilledUnit (Unit * / * victim * /) // Function called when the creature kills someone
Click to expand...
Quote: void UpdateAI(uint32 diff)This function is performed approximately every 100ms or more. This is where the script will take place.
Click to expand...
Quote: void UpdateAI (uint32 diff) overrideAs the void UpdateAI (uint32 diff) function is "a timer" we will use it to create "a timer / counter" to tell when I want to cast a spell.
{
if (! UpdateVictim ()) // Required, otherwise the creature will not catch you
return;
DoMeleeAttackIfReady (); // To have the creature perform melee attacks
}
Click to expand...
Quote: if (HealthBelowPct (20)) // IF 20% lifeWarning ! We must add a condition otherwise the creature cast the spell without stopping.
{
DoCast (me, SPELL_ENRAGE); // He casts a spell on him
}
Click to expand...
Quote: bool enraged;
void JustEngagedWith(Unit* /*who*/) override
{
enraged = false;
}
Click to expand...
Quote: void UpdateAI(uint32 diff) overrideThen we will ask the creature to do some technique. We start by creating a new variable that will contain a value in milliseconds.
{
if (!UpdateVictim())
return;
if(HealthBelowPct(20) && !enraged)
{
DoCast(me,SPELL_ENRAGE);
enraged = true;
}
DoMeleeAttackIfReady();
}
Click to expand...
Quote: uint32 spell_cleave_timer;As we all know 1000ms = 1 sec, so 10000ms = 10 sec. So the moment the fight begins the creature will cast the spell about 10 sec later.
bool enraged;
void JustEngagedWith(Unit* /*who*/) override
{
spell_cleave_timer = 10000; //10sec
enraged = false;
}
Click to expand...
Quote: void UpdateAI(uint32 diff) overrideWe use here, simply the function:
{
if (!UpdateVictim())
return;
if(spell_cleave_timer <= diff)
{
DoCastVictim(SPELL_CLEAVE);
spell_cleave_timer = 10000;
}
else spell_cleave_timer -= diff;
if(HealthBelowPct(20) && !enraged)
{
DoCast(me,SPELL_ENRAGE);
enraged = true;
}
DoMeleeAttackIfReady();
}
Click to expand...
Quote: DoCastVictim(SPELL_CLEAVE);The technique will be launched on that target.
Click to expand...
Quote: Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);Here he selects a target at random, but there is another possibility:
DoCast(target,SPELL_ENRAGE);
Click to expand...
Quote: SELECT_TARGET_RANDOM, // choose a random targetOf course the "0" next to SELECT_TARGET_RANDOM is not insignificant, example:
SELECT_TARGET_MAXTHREAT, // Choose a target with a high threat level
SELECT_TARGET_MINTHREAT, // Choose a target with a low threat level
SELECT_TARGET_MAXDISTANCE, // Choose a target further
SELECT_TARGET_MINDISTANCE // Choose a closer target
Click to expand...
Quote: (SELECT_TARGET_RANDOM, 0) // Choose a random targetalso complete this script by calling a new creature during combat.
(SELECT_TARGET_RANDOM, 1) // Choose a random target at close range
(SELECT_TARGET_RANDOM, 2) // Choose a random target at medium distance
(SELECT_TARGET_RANDOM, 3) // Choose a random target over long distances
(SELECT_TARGET_RANDOM, 4) // Choose a random target with mana
(SELECT_TARGET_RANDOM, 5) // Choose a random target with rage
(SELECT_TARGET_RANDOM, 6) // Choose a random target with energy
Click to expand...
Quote: uint32 Spawn_Timer;the TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT function allows the creature to disappear 1 sec after the end of the fight. We also have another proposal:
Spawn_Timer = 25000;//25sec
if(Spawn_Timer <= diff)
{
me->SummonCreature(17895, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000);
Spawn_Timer = 25000;
}
else Spawn_Timer -= diff;
Click to expand...
Quote: TEMPSUMMON_TIMED_OR_DEAD_DESPAWN // Despawns after a specific time or when the boss disappearsWe can finish this tutorial by expanding it all with some word using the "Talk (ID)" function, as follows:
TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN // Despawns after a specific time or when the creature dies
TEMPSUMMON_TIMED_DESPAWN // Despawns after a specific time
TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT // Despawns after a specific time or when the fight ends
TEMPSUMMON_CORPSE_DESPAWN // Despawns after death
TEMPSUMMON_CORPSE_TIMED_DESPAWN // Despawns after a specific time after death
TEMPSUMMON_DEAD_DESPAWN // Despawns when the creature disappears
TEMPSUMMON_MANUAL_DESPAWN // Despawns when the UnSummon () function is used
Click to expand...
Quote: SETWe just need to put our function in the script.
@CreatureID = 45000,
@Text = "Que trépasse si je faiblis !",
@comment = "Boos Tutoriel";
INSERT INTO `creature_text` (`CreatureID`, `GroupID`, `ID`, `Text`, `Type`, `Language`, `Probability`, `Emote`, `Duration`, `Sound`, `BroadcastTextId`, `TextRange`, `comment`) VALUES
(@CreatureID, '0', '0', @Text, '12', '0', '100', '0', '0', '0', '0', '0', @comment);
Click to expand...
Quote: void JustEngagedWith(Unit* /*who*/) overrideIn the end, we have this little code:
{
Spawn_Timer = 25000;
spell_cleave_timer = 10000; //10sec
enraged = false;
Talk(0);
}
Click to expand...
Quote: #include "ScriptMgr.h"Credit to : Killit from Open-Wow
enum Spells
{
SPELL_CLEAVE = 15284,
SPELL_ENRAGE = 27680
};
class World_Boss : public CreatureScript
{
public:
World_Boss() : CreatureScript("World_Boss") { } // script name onto the DB
struct World_BossAI : public ScriptedAI
{
World_BossAI(Creature* creature) : ScriptedAI(creature) {}
uint32 spell_cleave_timer;
uint32 Spawn_Timer;
bool enraged;
void JustEngagedWith(Unit* /*who*/) override
{
Spawn_Timer = 25000;
spell_cleave_timer = 10000; //10sec
enraged = false;
Talk(0);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
if(spell_cleave_timer <= diff)
{
DoCastVictim(SPELL_CLEAVE);
spell_cleave_timer = 10000;
}
else spell_cleave_timer -= diff;
if(Spawn_Timer <= diff)
{
me->SummonCreature(17895, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000);
Spawn_Timer = 25000;
}
else Spawn_Timer -= diff;
if(HealthBelowPct(20) && !enraged)
{
DoCast(me,SPELL_ENRAGE);
enraged = true;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new World_BossAI(creature);
}
};
void AddSC_World_Boss()
{
new World_Boss();
}
Click to expand...
Archived author: dokuro • Posted: 2025-11-04T18:04:36.158568
Original source
[3.3.5] Mini Boss C ++ Tutorial
In this tutorial we will then see how to just create a little boss.
The start script is as follows:
Quote: #include "ScriptMgr.h"In the type enums Spells we will take some easy to use spell, a cleave, and an enrage, nothing more simple.
enum Spells
{
};
class World_Boss : public CreatureScript
{
public:
World_Boss() : CreatureScript("World_Boss") { } // script name onto the DB
struct World_BossAI : public ScriptedAI
{
World_BossAI(Creature* creature) : ScriptedAI(creature) {}
void JustEngagedWith(Unit* /*who*/) override
{
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new World_BossAI(creature);
}
};
void AddSC_World_Boss()
{
new World_Boss();
}
Click to expand...
Quote: enum SpellsThen there are several functions available like the one we are going to use:
{
SPELL_CLEAVE = 15284,
SPELL_ENRAGE = 27680
};
Click to expand...
Quote: void JustEngagedWith (Unit * / * who * /) // Function called when combat is engagedWe will start by using the main function.
void JustDied (Unit * / * killer * /) // Function called when the creature is dead
void KilledUnit (Unit * / * victim * /) // Function called when the creature kills someone
Click to expand...
Quote: void UpdateAI(uint32 diff)This function is performed approximately every 100ms or more. This is where the script will take place.
Click to expand...
Quote: void UpdateAI (uint32 diff) overrideAs the void UpdateAI (uint32 diff) function is "a timer" we will use it to create "a timer / counter" to tell when I want to cast a spell.
{
if (! UpdateVictim ()) // Required, otherwise the creature will not catch you
return;
DoMeleeAttackIfReady (); // To have the creature perform melee attacks
}
Click to expand...
Quote: if (HealthBelowPct (20)) // IF 20% lifeWarning ! We must add a condition otherwise the creature cast the spell without stopping.
{
DoCast (me, SPELL_ENRAGE); // He casts a spell on him
}
Click to expand...
Quote: bool enraged;
void JustEngagedWith(Unit* /*who*/) override
{
enraged = false;
}
Click to expand...
Quote: void UpdateAI(uint32 diff) overrideThen we will ask the creature to do some technique. We start by creating a new variable that will contain a value in milliseconds.
{
if (!UpdateVictim())
return;
if(HealthBelowPct(20) && !enraged)
{
DoCast(me,SPELL_ENRAGE);
enraged = true;
}
DoMeleeAttackIfReady();
}
Click to expand...
Quote: uint32 spell_cleave_timer;As we all know 1000ms = 1 sec, so 10000ms = 10 sec. So the moment the fight begins the creature will cast the spell about 10 sec later.
bool enraged;
void JustEngagedWith(Unit* /*who*/) override
{
spell_cleave_timer = 10000; //10sec
enraged = false;
}
Click to expand...
Quote: void UpdateAI(uint32 diff) overrideWe use here, simply the function:
{
if (!UpdateVictim())
return;
if(spell_cleave_timer <= diff)
{
DoCastVictim(SPELL_CLEAVE);
spell_cleave_timer = 10000;
}
else spell_cleave_timer -= diff;
if(HealthBelowPct(20) && !enraged)
{
DoCast(me,SPELL_ENRAGE);
enraged = true;
}
DoMeleeAttackIfReady();
}
Click to expand...
Quote: DoCastVictim(SPELL_CLEAVE);The technique will be launched on that target.
Click to expand...
Quote: Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);Here he selects a target at random, but there is another possibility:
DoCast(target,SPELL_ENRAGE);
Click to expand...
Quote: SELECT_TARGET_RANDOM, // choose a random targetOf course the "0" next to SELECT_TARGET_RANDOM is not insignificant, example:
SELECT_TARGET_MAXTHREAT, // Choose a target with a high threat level
SELECT_TARGET_MINTHREAT, // Choose a target with a low threat level
SELECT_TARGET_MAXDISTANCE, // Choose a target further
SELECT_TARGET_MINDISTANCE // Choose a closer target
Click to expand...
Quote: (SELECT_TARGET_RANDOM, 0) // Choose a random targetalso complete this script by calling a new creature during combat.
(SELECT_TARGET_RANDOM, 1) // Choose a random target at close range
(SELECT_TARGET_RANDOM, 2) // Choose a random target at medium distance
(SELECT_TARGET_RANDOM, 3) // Choose a random target over long distances
(SELECT_TARGET_RANDOM, 4) // Choose a random target with mana
(SELECT_TARGET_RANDOM, 5) // Choose a random target with rage
(SELECT_TARGET_RANDOM, 6) // Choose a random target with energy
Click to expand...
Quote: uint32 Spawn_Timer;the TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT function allows the creature to disappear 1 sec after the end of the fight. We also have another proposal:
Spawn_Timer = 25000;//25sec
if(Spawn_Timer <= diff)
{
me->SummonCreature(17895, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000);
Spawn_Timer = 25000;
}
else Spawn_Timer -= diff;
Click to expand...
Quote: TEMPSUMMON_TIMED_OR_DEAD_DESPAWN // Despawns after a specific time or when the boss disappearsWe can finish this tutorial by expanding it all with some word using the "Talk (ID)" function, as follows:
TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN // Despawns after a specific time or when the creature dies
TEMPSUMMON_TIMED_DESPAWN // Despawns after a specific time
TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT // Despawns after a specific time or when the fight ends
TEMPSUMMON_CORPSE_DESPAWN // Despawns after death
TEMPSUMMON_CORPSE_TIMED_DESPAWN // Despawns after a specific time after death
TEMPSUMMON_DEAD_DESPAWN // Despawns when the creature disappears
TEMPSUMMON_MANUAL_DESPAWN // Despawns when the UnSummon () function is used
Click to expand...
Quote: SETWe just need to put our function in the script.
@CreatureID = 45000,
@Text = "Que trépasse si je faiblis !",
@comment = "Boos Tutoriel";
INSERT INTO `creature_text` (`CreatureID`, `GroupID`, `ID`, `Text`, `Type`, `Language`, `Probability`, `Emote`, `Duration`, `Sound`, `BroadcastTextId`, `TextRange`, `comment`) VALUES
(@CreatureID, '0', '0', @Text, '12', '0', '100', '0', '0', '0', '0', '0', @comment);
Click to expand...
Quote: void JustEngagedWith(Unit* /*who*/) overrideIn the end, we have this little code:
{
Spawn_Timer = 25000;
spell_cleave_timer = 10000; //10sec
enraged = false;
Talk(0);
}
Click to expand...
Quote: #include "ScriptMgr.h"Credit to : Killit from Open-Wow
enum Spells
{
SPELL_CLEAVE = 15284,
SPELL_ENRAGE = 27680
};
class World_Boss : public CreatureScript
{
public:
World_Boss() : CreatureScript("World_Boss") { } // script name onto the DB
struct World_BossAI : public ScriptedAI
{
World_BossAI(Creature* creature) : ScriptedAI(creature) {}
uint32 spell_cleave_timer;
uint32 Spawn_Timer;
bool enraged;
void JustEngagedWith(Unit* /*who*/) override
{
Spawn_Timer = 25000;
spell_cleave_timer = 10000; //10sec
enraged = false;
Talk(0);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
if(spell_cleave_timer <= diff)
{
DoCastVictim(SPELL_CLEAVE);
spell_cleave_timer = 10000;
}
else spell_cleave_timer -= diff;
if(Spawn_Timer <= diff)
{
me->SummonCreature(17895, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000);
Spawn_Timer = 25000;
}
else Spawn_Timer -= diff;
if(HealthBelowPct(20) && !enraged)
{
DoCast(me,SPELL_ENRAGE);
enraged = true;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new World_BossAI(creature);
}
};
void AddSC_World_Boss()
{
new World_Boss();
}
Click to expand...
Archived author: dokuro • Posted: 2025-11-04T18:04:36.158568
Original source
Thank you for this, i was looking on how to make boss scripts.