Fix creature script example to be conform to Trinity code standards.
--HG-- branch : trunk
This commit is contained in:
@@ -22,6 +22,7 @@ SDCategory: Script Examples
|
|||||||
EndScriptData */
|
EndScriptData */
|
||||||
|
|
||||||
#include "ScriptedPch.h"
|
#include "ScriptedPch.h"
|
||||||
|
#include "SpellId.h"
|
||||||
|
|
||||||
// **** This script is designed as an example for others to build on ****
|
// **** This script is designed as an example for others to build on ****
|
||||||
// **** Please modify whatever you'd like to as this script is only for developement ****
|
// **** Please modify whatever you'd like to as this script is only for developement ****
|
||||||
@@ -35,7 +36,7 @@ EndScriptData */
|
|||||||
// Functions with Handled Function marked above them are functions that are called automatically by the core
|
// Functions with Handled Function marked above them are functions that are called automatically by the core
|
||||||
// Functions that are marked Custom Function are functions I've created to simplify code
|
// Functions that are marked Custom Function are functions I've created to simplify code
|
||||||
|
|
||||||
enum eEnums
|
enum Yells
|
||||||
{
|
{
|
||||||
//List of text id's. The text is stored in database, also in a localized version
|
//List of text id's. The text is stored in database, also in a localized version
|
||||||
//(if translation not exist for the textId, default english text will be used)
|
//(if translation not exist for the textId, default english text will be used)
|
||||||
@@ -46,20 +47,29 @@ enum eEnums
|
|||||||
SAY_RANDOM_2 = -1999903,
|
SAY_RANDOM_2 = -1999903,
|
||||||
SAY_RANDOM_3 = -1999904,
|
SAY_RANDOM_3 = -1999904,
|
||||||
SAY_RANDOM_4 = -1999905,
|
SAY_RANDOM_4 = -1999905,
|
||||||
SAY_BESERK = -1999906,
|
SAY_BERSERK = -1999906,
|
||||||
SAY_PHASE = -1999907,
|
SAY_PHASE = -1999907,
|
||||||
SAY_DANCE = -1999908,
|
SAY_DANCE = -1999908,
|
||||||
SAY_SALUTE = -1999909,
|
SAY_SALUTE = -1999909,
|
||||||
|
SAY_EVADE = -1999910,
|
||||||
|
};
|
||||||
|
|
||||||
//List of spells. Not required to define them in this way, but will make it easier to maintain in case spellId change
|
enum Spells
|
||||||
SPELL_BUFF = 25661,
|
{
|
||||||
SPELL_ONE = 12555,
|
// List of spells.
|
||||||
SPELL_ONE_ALT = 24099,
|
// Not required to define them in this way, but will make it easier to maintain in case spellId change
|
||||||
SPELL_TWO = 10017,
|
SPELL_BUFF = SPELL_INCREASED_STAMINA_25661,
|
||||||
SPELL_THREE = 26027,
|
SPELL_ONE = SPELL_PUMMEL_12555,
|
||||||
SPELL_ENRAGE = 23537,
|
SPELL_ONE_ALT = SPELL_POISON_BOLT_VOLLEY_24099,
|
||||||
SPELL_BESERK = 32309,
|
SPELL_TWO = SPELL_FROST_HOLD_10017,
|
||||||
|
SPELL_THREE = SPELL_KNOCKBACK_26027,
|
||||||
|
SPELL_FRENZY = SPELL_FRENZY_23537,
|
||||||
|
SPELL_BERSERK = SPELL_BERSERK_32965,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eEnums
|
||||||
|
{
|
||||||
|
// any other constants
|
||||||
FACTION_WORGEN = 24
|
FACTION_WORGEN = 24
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,42 +80,60 @@ struct example_creatureAI : public ScriptedAI
|
|||||||
{
|
{
|
||||||
//*** HANDLED FUNCTION ***
|
//*** HANDLED FUNCTION ***
|
||||||
//This is the constructor, called only once when the Creature is first created
|
//This is the constructor, called only once when the Creature is first created
|
||||||
example_creatureAI(Creature *c) : ScriptedAI(c) {Reset();}
|
example_creatureAI(Creature *c) : ScriptedAI(c) {}
|
||||||
|
|
||||||
//*** CUSTOM VARIABLES ****
|
//*** CUSTOM VARIABLES ****
|
||||||
//These variables are for use only by this individual script.
|
//These variables are for use only by this individual script.
|
||||||
//Nothing else will ever call them but us.
|
//Nothing else will ever call them but us.
|
||||||
|
|
||||||
uint32 m_uiSay_Timer; //Timer for random chat
|
uint32 m_uiSayTimer; // Timer for random chat
|
||||||
uint32 m_uiRebuff_Timer; //Timer for rebuffing
|
uint32 m_uiRebuffTimer; // Timer for rebuffing
|
||||||
uint32 m_uiSpell_1_Timer; //Timer for spell 1 when in combat
|
uint32 m_uiSpell1Timer; // Timer for spell 1 when in combat
|
||||||
uint32 m_uiSpell_2_Timer; //Timer for spell 1 when in combat
|
uint32 m_uiSpell2Timer; // Timer for spell 1 when in combat
|
||||||
uint32 m_uiSpell_3_Timer; //Timer for spell 1 when in combat
|
uint32 m_uiSpell3Timer; // Timer for spell 1 when in combat
|
||||||
uint32 m_uiBeserk_Timer; //Timer until we go into Beserk (enraged) mode
|
uint32 m_uiBeserkTimer; // Timer until we go into Beserk (enraged) mode
|
||||||
uint32 m_uiPhase; //The current battle phase we are in
|
uint32 m_uiPhase; // The current battle phase we are in
|
||||||
uint32 m_uiPhase_Timer; //Timer until phase transition
|
uint32 m_uiPhaseTimer; // Timer until phase transition
|
||||||
|
|
||||||
//*** HANDLED FUNCTION ***
|
//*** HANDLED FUNCTION ***
|
||||||
//This is called whenever the core decides we need to evade
|
//This is called after spawn and whenever the core decides we need to evade
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
m_uiPhase = 1; //Start in phase 1
|
m_uiPhase = 1; // Start in phase 1
|
||||||
m_uiPhase_Timer = 60000; //60 seconds
|
m_uiPhaseTimer = 60000; // 60 seconds
|
||||||
m_uiSpell_1_Timer = 5000; //5 seconds
|
m_uiSpell1Timer = 5000; // 5 seconds
|
||||||
m_uiSpell_2_Timer = 37000; //37 seconds
|
m_uiSpell2Timer = urand(10000,20000); // between 10 and 20 seconds
|
||||||
m_uiSpell_3_Timer = 19000; //19 seconds
|
m_uiSpell3Timer = 19000; // 19 seconds
|
||||||
m_uiBeserk_Timer = 120000; //2 minutes
|
m_uiBeserkTimer = 120000; // 2 minutes
|
||||||
|
|
||||||
|
m_creature->RestoreFaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*** HANDLED FUNCTION ***
|
//*** HANDLED FUNCTION ***
|
||||||
//Attack Start is called whenever someone hits us.
|
// Enter Combat called once per combat
|
||||||
void EnterCombat(Unit* pWho)
|
void EnterCombat(Unit* pWho)
|
||||||
{
|
{
|
||||||
//Say some stuff
|
//Say some stuff
|
||||||
DoScriptText(SAY_AGGRO, m_creature, pWho);
|
DoScriptText(SAY_AGGRO, m_creature, pWho);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Our Recive emote function
|
//*** HANDLED FUNCTION ***
|
||||||
|
// Attack Start is called when victim change (including at start of combat)
|
||||||
|
// By default, attack pWho and start movement toward the victim.
|
||||||
|
//void AttackStart(Unit* pWho)
|
||||||
|
//{
|
||||||
|
// ScriptedAI::AttackStart(pWho);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//*** HANDLED FUNCTION ***
|
||||||
|
// Called when going out of combat. Reset is called just after.
|
||||||
|
void EnterEvadeMode()
|
||||||
|
{
|
||||||
|
DoScriptText(SAY_EVADE, m_creature);
|
||||||
|
}
|
||||||
|
|
||||||
|
//*** HANDLED FUNCTION ***
|
||||||
|
//Our Receive emote function
|
||||||
void ReceiveEmote(Player* pPlayer, uint32 uiTextEmote)
|
void ReceiveEmote(Player* pPlayer, uint32 uiTextEmote)
|
||||||
{
|
{
|
||||||
m_creature->HandleEmoteCommand(uiTextEmote);
|
m_creature->HandleEmoteCommand(uiTextEmote);
|
||||||
@@ -122,31 +150,31 @@ struct example_creatureAI : public ScriptedAI
|
|||||||
}
|
}
|
||||||
|
|
||||||
//*** HANDLED FUNCTION ***
|
//*** HANDLED FUNCTION ***
|
||||||
//Update AI is called Every single map update (roughly once every 100ms if a player is within the grid)
|
//Update AI is called Every single map update (roughly once every 50ms if a player is within the grid)
|
||||||
void UpdateAI(const uint32 uiDiff)
|
void UpdateAI(const uint32 uiDiff)
|
||||||
{
|
{
|
||||||
//Out of combat timers
|
//Out of combat timers
|
||||||
if (!m_creature->getVictim())
|
if (!m_creature->getVictim())
|
||||||
{
|
{
|
||||||
//Random Say timer
|
//Random Say timer
|
||||||
if (m_uiSay_Timer <= uiDiff)
|
if (m_uiSayTimer <= uiDiff)
|
||||||
{
|
{
|
||||||
//Random switch between 5 outcomes
|
//Random switch between 5 outcomes
|
||||||
DoScriptText(RAND(SAY_RANDOM_0,SAY_RANDOM_1,SAY_RANDOM_2,SAY_RANDOM_3,SAY_RANDOM_4), m_creature);
|
DoScriptText(RAND(SAY_RANDOM_0,SAY_RANDOM_1,SAY_RANDOM_2,SAY_RANDOM_3,SAY_RANDOM_4), m_creature);
|
||||||
|
|
||||||
m_uiSay_Timer = 45000; //Say something agian in 45 seconds
|
m_uiSayTimer = 45000; //Say something agian in 45 seconds
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_uiSay_Timer -= uiDiff;
|
m_uiSayTimer -= uiDiff;
|
||||||
|
|
||||||
//Rebuff timer
|
//Rebuff timer
|
||||||
if (m_uiRebuff_Timer <= uiDiff)
|
if (m_uiRebuffTimer <= uiDiff)
|
||||||
{
|
{
|
||||||
DoCast(m_creature, SPELL_BUFF);
|
DoCast(m_creature, SPELL_BUFF);
|
||||||
m_uiRebuff_Timer = 900000; //Rebuff agian in 15 minutes
|
m_uiRebuffTimer = 900000; //Rebuff agian in 15 minutes
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_uiRebuff_Timer -= uiDiff;
|
m_uiRebuffTimer -= uiDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return since we have no target
|
//Return since we have no target
|
||||||
@@ -154,7 +182,7 @@ struct example_creatureAI : public ScriptedAI
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//Spell 1 timer
|
//Spell 1 timer
|
||||||
if (m_uiSpell_1_Timer <= uiDiff)
|
if (m_uiSpell1Timer <= uiDiff)
|
||||||
{
|
{
|
||||||
//Cast spell one on our current target.
|
//Cast spell one on our current target.
|
||||||
if (rand()%50 > 10)
|
if (rand()%50 > 10)
|
||||||
@@ -162,58 +190,58 @@ struct example_creatureAI : public ScriptedAI
|
|||||||
else if (m_creature->IsWithinDist(m_creature->getVictim(), 25.0f))
|
else if (m_creature->IsWithinDist(m_creature->getVictim(), 25.0f))
|
||||||
DoCast(m_creature->getVictim(), SPELL_ONE);
|
DoCast(m_creature->getVictim(), SPELL_ONE);
|
||||||
|
|
||||||
m_uiSpell_1_Timer = 5000;
|
m_uiSpell1Timer = 5000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_uiSpell_1_Timer -= uiDiff;
|
m_uiSpell1Timer -= uiDiff;
|
||||||
|
|
||||||
//Spell 2 timer
|
//Spell 2 timer
|
||||||
if (m_uiSpell_2_Timer <= uiDiff)
|
if (m_uiSpell2Timer <= uiDiff)
|
||||||
{
|
{
|
||||||
//Cast spell one on our current target.
|
//Cast spell two on our current target.
|
||||||
DoCast(m_creature->getVictim(), SPELL_TWO);
|
DoCast(m_creature->getVictim(), SPELL_TWO);
|
||||||
m_uiSpell_2_Timer = 37000;
|
m_uiSpell2Timer = 37000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_uiSpell_2_Timer -= uiDiff;
|
m_uiSpell2Timer -= uiDiff;
|
||||||
|
|
||||||
//Beserk timer
|
//Beserk timer
|
||||||
if (m_uiPhase > 1)
|
if (m_uiPhase > 1)
|
||||||
{
|
{
|
||||||
//Spell 3 timer
|
//Spell 3 timer
|
||||||
if (m_uiSpell_3_Timer <= uiDiff)
|
if (m_uiSpell3Timer <= uiDiff)
|
||||||
{
|
{
|
||||||
//Cast spell one on our current target.
|
//Cast spell one on our current target.
|
||||||
DoCast(m_creature->getVictim(), SPELL_THREE);
|
DoCast(m_creature->getVictim(), SPELL_THREE);
|
||||||
|
|
||||||
m_uiSpell_3_Timer = 19000;
|
m_uiSpell3Timer = 19000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_uiSpell_3_Timer -= uiDiff;
|
m_uiSpell3Timer -= uiDiff;
|
||||||
|
|
||||||
if (m_uiBeserk_Timer <= uiDiff)
|
if (m_uiBeserkTimer <= uiDiff)
|
||||||
{
|
{
|
||||||
//Say our line then cast uber death spell
|
//Say our line then cast uber death spell
|
||||||
DoScriptText(SAY_BESERK, m_creature, m_creature->getVictim());
|
DoScriptText(SAY_BERSERK, m_creature, m_creature->getVictim());
|
||||||
DoCast(m_creature->getVictim(), SPELL_BESERK);
|
DoCast(m_creature->getVictim(), SPELL_BERSERK);
|
||||||
|
|
||||||
//Cast our beserk spell agian in 12 seconds if we didn't kill everyone
|
//Cast our beserk spell agian in 12 seconds if we didn't kill everyone
|
||||||
m_uiBeserk_Timer = 12000;
|
m_uiBeserkTimer = 12000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_uiBeserk_Timer -= uiDiff;
|
m_uiBeserkTimer -= uiDiff;
|
||||||
}
|
}
|
||||||
else if (m_uiPhase == 1) //Phase timer
|
else if (m_uiPhase == 1) //Phase timer
|
||||||
{
|
{
|
||||||
if (m_uiPhase_Timer <= uiDiff)
|
if (m_uiPhaseTimer <= uiDiff)
|
||||||
{
|
{
|
||||||
//Go to next phase
|
//Go to next phase
|
||||||
++m_uiPhase;
|
++m_uiPhase;
|
||||||
DoScriptText(SAY_PHASE, m_creature);
|
DoScriptText(SAY_PHASE, m_creature);
|
||||||
DoCast(m_creature, SPELL_ENRAGE);
|
DoCast(m_creature, SPELL_FRENZY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_uiPhase_Timer -= uiDiff;
|
m_uiPhaseTimer -= uiDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoMeleeAttackIfReady();
|
DoMeleeAttackIfReady();
|
||||||
@@ -233,7 +261,7 @@ bool GossipSelect_example_creature(Player* pPlayer, Creature* pCreature, uint32
|
|||||||
if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
|
if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
|
||||||
{
|
{
|
||||||
pPlayer->CLOSE_GOSSIP_MENU();
|
pPlayer->CLOSE_GOSSIP_MENU();
|
||||||
//Set our faction to hostile twoards all
|
//Set our faction to hostile towards all
|
||||||
pCreature->setFaction(FACTION_WORGEN);
|
pCreature->setFaction(FACTION_WORGEN);
|
||||||
pCreature->AI()->AttackStart(pPlayer);
|
pCreature->AI()->AttackStart(pPlayer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user