mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
* Converted example scripts to the new format.
--HG-- branch : trunk
This commit is contained in:
@@ -77,218 +77,217 @@ enum eEnums
|
||||
//List of gossip item texts. Items will appear in the gossip window.
|
||||
#define GOSSIP_ITEM "I'm looking for a fight"
|
||||
|
||||
struct example_creatureAI : public ScriptedAI
|
||||
class example_creature : public CreatureScript
|
||||
{
|
||||
//*** HANDLED FUNCTION ***
|
||||
//This is the constructor, called only once when the Creature is first created
|
||||
example_creatureAI(Creature *c) : ScriptedAI(c) {}
|
||||
public:
|
||||
|
||||
//*** CUSTOM VARIABLES ****
|
||||
//These variables are for use only by this individual script.
|
||||
//Nothing else will ever call them but us.
|
||||
|
||||
uint32 m_uiSayTimer; // Timer for random chat
|
||||
uint32 m_uiRebuffTimer; // Timer for rebuffing
|
||||
uint32 m_uiSpell1Timer; // Timer for spell 1 when in combat
|
||||
uint32 m_uiSpell2Timer; // Timer for spell 1 when in combat
|
||||
uint32 m_uiSpell3Timer; // Timer for spell 1 when in combat
|
||||
uint32 m_uiBeserkTimer; // Timer until we go into Beserk (enraged) mode
|
||||
uint32 m_uiPhase; // The current battle phase we are in
|
||||
uint32 m_uiPhaseTimer; // Timer until phase transition
|
||||
|
||||
//*** HANDLED FUNCTION ***
|
||||
//This is called after spawn and whenever the core decides we need to evade
|
||||
void Reset()
|
||||
{
|
||||
m_uiPhase = 1; // Start in phase 1
|
||||
m_uiPhaseTimer = 60000; // 60 seconds
|
||||
m_uiSpell1Timer = 5000; // 5 seconds
|
||||
m_uiSpell2Timer = urand(10000,20000); // between 10 and 20 seconds
|
||||
m_uiSpell3Timer = 19000; // 19 seconds
|
||||
m_uiBeserkTimer = 120000; // 2 minutes
|
||||
|
||||
me->RestoreFaction();
|
||||
}
|
||||
|
||||
//*** HANDLED FUNCTION ***
|
||||
// Enter Combat called once per combat
|
||||
void EnterCombat(Unit* pWho)
|
||||
{
|
||||
//Say some stuff
|
||||
DoScriptText(SAY_AGGRO, me, pWho);
|
||||
}
|
||||
|
||||
//*** 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, me);
|
||||
}
|
||||
|
||||
//*** HANDLED FUNCTION ***
|
||||
//Our Receive emote function
|
||||
void ReceiveEmote(Player* /*pPlayer*/, uint32 uiTextEmote)
|
||||
{
|
||||
me->HandleEmoteCommand(uiTextEmote);
|
||||
|
||||
switch(uiTextEmote)
|
||||
example_creature()
|
||||
: CreatureScript("example_creature")
|
||||
{
|
||||
case TEXTEMOTE_DANCE:
|
||||
DoScriptText(SAY_DANCE, me);
|
||||
break;
|
||||
case TEXTEMOTE_SALUTE:
|
||||
DoScriptText(SAY_SALUTE, me);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//*** HANDLED FUNCTION ***
|
||||
//Update AI is called Every single map update (roughly once every 50ms if a player is within the grid)
|
||||
void UpdateAI(const uint32 uiDiff)
|
||||
{
|
||||
//Out of combat timers
|
||||
if (!me->getVictim())
|
||||
struct example_creatureAI : public ScriptedAI
|
||||
{
|
||||
//Random Say timer
|
||||
if (m_uiSayTimer <= uiDiff)
|
||||
//*** HANDLED FUNCTION ***
|
||||
//This is the constructor, called only once when the Creature is first created
|
||||
example_creatureAI(Creature *c) : ScriptedAI(c) {}
|
||||
|
||||
//*** CUSTOM VARIABLES ****
|
||||
//These variables are for use only by this individual script.
|
||||
//Nothing else will ever call them but us.
|
||||
|
||||
uint32 m_uiSayTimer; // Timer for random chat
|
||||
uint32 m_uiRebuffTimer; // Timer for rebuffing
|
||||
uint32 m_uiSpell1Timer; // Timer for spell 1 when in combat
|
||||
uint32 m_uiSpell2Timer; // Timer for spell 1 when in combat
|
||||
uint32 m_uiSpell3Timer; // Timer for spell 1 when in combat
|
||||
uint32 m_uiBeserkTimer; // Timer until we go into Beserk (enraged) mode
|
||||
uint32 m_uiPhase; // The current battle phase we are in
|
||||
uint32 m_uiPhaseTimer; // Timer until phase transition
|
||||
|
||||
//*** HANDLED FUNCTION ***
|
||||
//This is called after spawn and whenever the core decides we need to evade
|
||||
void Reset()
|
||||
{
|
||||
//Random switch between 5 outcomes
|
||||
DoScriptText(RAND(SAY_RANDOM_0,SAY_RANDOM_1,SAY_RANDOM_2,SAY_RANDOM_3,SAY_RANDOM_4), me);
|
||||
m_uiPhase = 1; // Start in phase 1
|
||||
m_uiPhaseTimer = 60000; // 60 seconds
|
||||
m_uiSpell1Timer = 5000; // 5 seconds
|
||||
m_uiSpell2Timer = urand(10000,20000); // between 10 and 20 seconds
|
||||
m_uiSpell3Timer = 19000; // 19 seconds
|
||||
m_uiBeserkTimer = 120000; // 2 minutes
|
||||
|
||||
m_uiSayTimer = 45000; //Say something agian in 45 seconds
|
||||
me->RestoreFaction();
|
||||
}
|
||||
else
|
||||
m_uiSayTimer -= uiDiff;
|
||||
|
||||
//Rebuff timer
|
||||
if (m_uiRebuffTimer <= uiDiff)
|
||||
//*** HANDLED FUNCTION ***
|
||||
// Enter Combat called once per combat
|
||||
void EnterCombat(Unit* pWho)
|
||||
{
|
||||
DoCast(me, SPELL_BUFF);
|
||||
m_uiRebuffTimer = 900000; //Rebuff agian in 15 minutes
|
||||
//Say some stuff
|
||||
DoScriptText(SAY_AGGRO, me, pWho);
|
||||
}
|
||||
else
|
||||
m_uiRebuffTimer -= uiDiff;
|
||||
}
|
||||
|
||||
//Return since we have no target
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
//*** 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);
|
||||
//}
|
||||
|
||||
//Spell 1 timer
|
||||
if (m_uiSpell1Timer <= uiDiff)
|
||||
{
|
||||
//Cast spell one on our current target.
|
||||
if (rand()%50 > 10)
|
||||
DoCast(me->getVictim(), SPELL_ONE_ALT);
|
||||
else if (me->IsWithinDist(me->getVictim(), 25.0f))
|
||||
DoCast(me->getVictim(), SPELL_ONE);
|
||||
|
||||
m_uiSpell1Timer = 5000;
|
||||
}
|
||||
else
|
||||
m_uiSpell1Timer -= uiDiff;
|
||||
|
||||
//Spell 2 timer
|
||||
if (m_uiSpell2Timer <= uiDiff)
|
||||
{
|
||||
//Cast spell two on our current target.
|
||||
DoCast(me->getVictim(), SPELL_TWO);
|
||||
m_uiSpell2Timer = 37000;
|
||||
}
|
||||
else
|
||||
m_uiSpell2Timer -= uiDiff;
|
||||
|
||||
//Beserk timer
|
||||
if (m_uiPhase > 1)
|
||||
{
|
||||
//Spell 3 timer
|
||||
if (m_uiSpell3Timer <= uiDiff)
|
||||
//*** HANDLED FUNCTION ***
|
||||
// Called when going out of combat. Reset is called just after.
|
||||
void EnterEvadeMode()
|
||||
{
|
||||
//Cast spell one on our current target.
|
||||
DoCast(me->getVictim(), SPELL_THREE);
|
||||
|
||||
m_uiSpell3Timer = 19000;
|
||||
DoScriptText(SAY_EVADE, me);
|
||||
}
|
||||
else
|
||||
m_uiSpell3Timer -= uiDiff;
|
||||
|
||||
if (m_uiBeserkTimer <= uiDiff)
|
||||
//*** HANDLED FUNCTION ***
|
||||
//Our Receive emote function
|
||||
void ReceiveEmote(Player* /*pPlayer*/, uint32 uiTextEmote)
|
||||
{
|
||||
//Say our line then cast uber death spell
|
||||
DoScriptText(SAY_BERSERK, me, me->getVictim());
|
||||
DoCast(me->getVictim(), SPELL_BERSERK);
|
||||
me->HandleEmoteCommand(uiTextEmote);
|
||||
|
||||
//Cast our beserk spell agian in 12 seconds if we didn't kill everyone
|
||||
m_uiBeserkTimer = 12000;
|
||||
switch(uiTextEmote)
|
||||
{
|
||||
case TEXTEMOTE_DANCE:
|
||||
DoScriptText(SAY_DANCE, me);
|
||||
break;
|
||||
case TEXTEMOTE_SALUTE:
|
||||
DoScriptText(SAY_SALUTE, me);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//*** HANDLED FUNCTION ***
|
||||
//Update AI is called Every single map update (roughly once every 50ms if a player is within the grid)
|
||||
void UpdateAI(const uint32 uiDiff)
|
||||
{
|
||||
//Out of combat timers
|
||||
if (!me->getVictim())
|
||||
{
|
||||
//Random Say timer
|
||||
if (m_uiSayTimer <= uiDiff)
|
||||
{
|
||||
//Random switch between 5 outcomes
|
||||
DoScriptText(RAND(SAY_RANDOM_0,SAY_RANDOM_1,SAY_RANDOM_2,SAY_RANDOM_3,SAY_RANDOM_4), me);
|
||||
|
||||
m_uiSayTimer = 45000; //Say something agian in 45 seconds
|
||||
}
|
||||
else
|
||||
m_uiSayTimer -= uiDiff;
|
||||
|
||||
//Rebuff timer
|
||||
if (m_uiRebuffTimer <= uiDiff)
|
||||
{
|
||||
DoCast(me, SPELL_BUFF);
|
||||
m_uiRebuffTimer = 900000; //Rebuff agian in 15 minutes
|
||||
}
|
||||
else
|
||||
m_uiRebuffTimer -= uiDiff;
|
||||
}
|
||||
|
||||
//Return since we have no target
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
//Spell 1 timer
|
||||
if (m_uiSpell1Timer <= uiDiff)
|
||||
{
|
||||
//Cast spell one on our current target.
|
||||
if (rand()%50 > 10)
|
||||
DoCast(me->getVictim(), SPELL_ONE_ALT);
|
||||
else if (me->IsWithinDist(me->getVictim(), 25.0f))
|
||||
DoCast(me->getVictim(), SPELL_ONE);
|
||||
|
||||
m_uiSpell1Timer = 5000;
|
||||
}
|
||||
else
|
||||
m_uiSpell1Timer -= uiDiff;
|
||||
|
||||
//Spell 2 timer
|
||||
if (m_uiSpell2Timer <= uiDiff)
|
||||
{
|
||||
//Cast spell two on our current target.
|
||||
DoCast(me->getVictim(), SPELL_TWO);
|
||||
m_uiSpell2Timer = 37000;
|
||||
}
|
||||
else
|
||||
m_uiSpell2Timer -= uiDiff;
|
||||
|
||||
//Beserk timer
|
||||
if (m_uiPhase > 1)
|
||||
{
|
||||
//Spell 3 timer
|
||||
if (m_uiSpell3Timer <= uiDiff)
|
||||
{
|
||||
//Cast spell one on our current target.
|
||||
DoCast(me->getVictim(), SPELL_THREE);
|
||||
|
||||
m_uiSpell3Timer = 19000;
|
||||
}
|
||||
else
|
||||
m_uiSpell3Timer -= uiDiff;
|
||||
|
||||
if (m_uiBeserkTimer <= uiDiff)
|
||||
{
|
||||
//Say our line then cast uber death spell
|
||||
DoScriptText(SAY_BERSERK, me, me->getVictim());
|
||||
DoCast(me->getVictim(), SPELL_BERSERK);
|
||||
|
||||
//Cast our beserk spell agian in 12 seconds if we didn't kill everyone
|
||||
m_uiBeserkTimer = 12000;
|
||||
}
|
||||
else
|
||||
m_uiBeserkTimer -= uiDiff;
|
||||
}
|
||||
else if (m_uiPhase == 1) //Phase timer
|
||||
{
|
||||
if (m_uiPhaseTimer <= uiDiff)
|
||||
{
|
||||
//Go to next phase
|
||||
++m_uiPhase;
|
||||
DoScriptText(SAY_PHASE, me);
|
||||
DoCast(me, SPELL_FRENZY);
|
||||
}
|
||||
else
|
||||
m_uiPhaseTimer -= uiDiff;
|
||||
}
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
else
|
||||
m_uiBeserkTimer -= uiDiff;
|
||||
}
|
||||
else if (m_uiPhase == 1) //Phase timer
|
||||
};
|
||||
|
||||
CreatureAI* OnGetAI(Creature* creature) const
|
||||
{
|
||||
if (m_uiPhaseTimer <= uiDiff)
|
||||
{
|
||||
//Go to next phase
|
||||
++m_uiPhase;
|
||||
DoScriptText(SAY_PHASE, me);
|
||||
DoCast(me, SPELL_FRENZY);
|
||||
}
|
||||
else
|
||||
m_uiPhaseTimer -= uiDiff;
|
||||
return new example_creatureAI(creature);
|
||||
}
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
bool OnGossipHello(Player* player, Creature* creature)
|
||||
{
|
||||
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
|
||||
player->SEND_GOSSIP_MENU(907, creature->GetGUID());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
|
||||
{
|
||||
if (action == GOSSIP_ACTION_INFO_DEF+1)
|
||||
{
|
||||
player->CLOSE_GOSSIP_MENU();
|
||||
//Set our faction to hostile towards all
|
||||
creature->setFaction(FACTION_WORGEN);
|
||||
creature->AI()->AttackStart(player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//This is the GetAI method used by all scripts that involve AI
|
||||
//It is called every time a new Creature using this script is created
|
||||
CreatureAI* GetAI_example_creature(Creature* pCreature)
|
||||
{
|
||||
return new example_creatureAI (pCreature);
|
||||
}
|
||||
|
||||
//This function is called when the player clicks an option on the gossip menu
|
||||
bool GossipSelect_example_creature(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
|
||||
{
|
||||
if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
|
||||
{
|
||||
pPlayer->CLOSE_GOSSIP_MENU();
|
||||
//Set our faction to hostile towards all
|
||||
pCreature->setFaction(FACTION_WORGEN);
|
||||
pCreature->AI()->AttackStart(pPlayer);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//This function is called when the player opens the gossip menu
|
||||
bool GossipHello_example_creature(Player* pPlayer, Creature* pCreature)
|
||||
{
|
||||
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
|
||||
pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//This is the actual function called only once durring InitScripts()
|
||||
//It must define all handled functions that are to be run in this script
|
||||
void AddSC_example_creature()
|
||||
{
|
||||
Script* newscript;
|
||||
|
||||
newscript = new Script;
|
||||
newscript->Name = "example_creature";
|
||||
newscript->GetAI = &GetAI_example_creature;
|
||||
newscript->pGossipHello = &GossipHello_example_creature;
|
||||
newscript->pGossipSelect = &GossipSelect_example_creature;
|
||||
newscript->RegisterSelf();
|
||||
new example_creature();
|
||||
}
|
||||
|
||||
@@ -52,180 +52,184 @@ enum eEnums
|
||||
#define GOSSIP_ITEM_2 "Click to Test Escort(NoAttack, Walk)"
|
||||
#define GOSSIP_ITEM_3 "Click to Test Escort(NoAttack, Run)"
|
||||
|
||||
struct example_escortAI : public npc_escortAI
|
||||
class example_escort : public CreatureScript
|
||||
{
|
||||
// CreatureAI functions
|
||||
example_escortAI(Creature* pCreature) : npc_escortAI(pCreature) { }
|
||||
public:
|
||||
|
||||
uint32 m_uiDeathCoilTimer;
|
||||
uint32 m_uiChatTimer;
|
||||
|
||||
void JustSummoned(Creature* pSummoned)
|
||||
{
|
||||
pSummoned->AI()->AttackStart(me);
|
||||
}
|
||||
|
||||
// Pure Virtual Functions (Have to be implemented)
|
||||
void WaypointReached(uint32 uiWP)
|
||||
{
|
||||
switch (uiWP)
|
||||
example_escort()
|
||||
: CreatureScript("example_escort")
|
||||
{
|
||||
case 1:
|
||||
DoScriptText(SAY_WP_1, me);
|
||||
break;
|
||||
case 3:
|
||||
DoScriptText(SAY_WP_2, me);
|
||||
me->SummonCreature(NPC_FELBOAR, me->GetPositionX()+5.0f, me->GetPositionY()+7.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000);
|
||||
break;
|
||||
case 4:
|
||||
if (Player* pPlayer = GetPlayerForEscort())
|
||||
{
|
||||
//pTmpPlayer is the target of the text
|
||||
DoScriptText(SAY_WP_3, me, pPlayer);
|
||||
//pTmpPlayer is the source of the text
|
||||
DoScriptText(SAY_WP_4, pPlayer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EnterCombat(Unit* /*pWho*/)
|
||||
{
|
||||
if (HasEscortState(STATE_ESCORT_ESCORTING))
|
||||
struct example_escortAI : public npc_escortAI
|
||||
{
|
||||
if (Player* pPlayer = GetPlayerForEscort())
|
||||
DoScriptText(SAY_AGGRO1, me, pPlayer);
|
||||
}
|
||||
else
|
||||
DoScriptText(SAY_AGGRO2, me);
|
||||
}
|
||||
// CreatureAI functions
|
||||
example_escortAI(Creature* pCreature) : npc_escortAI(pCreature) { }
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_uiDeathCoilTimer = 4000;
|
||||
m_uiChatTimer = 4000;
|
||||
}
|
||||
uint32 m_uiDeathCoilTimer;
|
||||
uint32 m_uiChatTimer;
|
||||
|
||||
void JustDied(Unit* pKiller)
|
||||
{
|
||||
if (HasEscortState(STATE_ESCORT_ESCORTING))
|
||||
{
|
||||
if (Player* pPlayer = GetPlayerForEscort())
|
||||
void JustSummoned(Creature* pSummoned)
|
||||
{
|
||||
// not a likely case, code here for the sake of example
|
||||
if (pKiller == me)
|
||||
pSummoned->AI()->AttackStart(me);
|
||||
}
|
||||
|
||||
// Pure Virtual Functions (Have to be implemented)
|
||||
void WaypointReached(uint32 uiWP)
|
||||
{
|
||||
switch (uiWP)
|
||||
{
|
||||
DoScriptText(SAY_DEATH_1, me, pPlayer);
|
||||
case 1:
|
||||
DoScriptText(SAY_WP_1, me);
|
||||
break;
|
||||
case 3:
|
||||
DoScriptText(SAY_WP_2, me);
|
||||
me->SummonCreature(NPC_FELBOAR, me->GetPositionX()+5.0f, me->GetPositionY()+7.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000);
|
||||
break;
|
||||
case 4:
|
||||
if (Player* pPlayer = GetPlayerForEscort())
|
||||
{
|
||||
//pTmpPlayer is the target of the text
|
||||
DoScriptText(SAY_WP_3, me, pPlayer);
|
||||
//pTmpPlayer is the source of the text
|
||||
DoScriptText(SAY_WP_4, pPlayer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EnterCombat(Unit* /*pWho*/)
|
||||
{
|
||||
if (HasEscortState(STATE_ESCORT_ESCORTING))
|
||||
{
|
||||
if (Player* pPlayer = GetPlayerForEscort())
|
||||
DoScriptText(SAY_AGGRO1, me, pPlayer);
|
||||
}
|
||||
else
|
||||
DoScriptText(SAY_DEATH_2, me, pPlayer);
|
||||
DoScriptText(SAY_AGGRO2, me);
|
||||
}
|
||||
}
|
||||
else
|
||||
DoScriptText(SAY_DEATH_3, me);
|
||||
}
|
||||
|
||||
void UpdateAI(const uint32 uiDiff)
|
||||
{
|
||||
//Must update npc_escortAI
|
||||
npc_escortAI::UpdateAI(uiDiff);
|
||||
|
||||
//Combat check
|
||||
if (me->getVictim())
|
||||
{
|
||||
if (m_uiDeathCoilTimer <= uiDiff)
|
||||
void Reset()
|
||||
{
|
||||
DoScriptText(SAY_SPELL, me);
|
||||
DoCast(me->getVictim(), SPELL_DEATH_COIL, false);
|
||||
m_uiDeathCoilTimer = 4000;
|
||||
m_uiChatTimer = 4000;
|
||||
}
|
||||
else
|
||||
m_uiDeathCoilTimer -= uiDiff;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Out of combat but being escorted
|
||||
if (HasEscortState(STATE_ESCORT_ESCORTING))
|
||||
|
||||
void JustDied(Unit* pKiller)
|
||||
{
|
||||
if (m_uiChatTimer <= uiDiff)
|
||||
if (HasEscortState(STATE_ESCORT_ESCORTING))
|
||||
{
|
||||
if (me->HasAura(SPELL_ELIXIR_OF_FORTITUDE, 0))
|
||||
if (Player* pPlayer = GetPlayerForEscort())
|
||||
{
|
||||
DoScriptText(SAY_RAND_1, me);
|
||||
DoCast(me, SPELL_BLUE_FIREWORK, false);
|
||||
// not a likely case, code here for the sake of example
|
||||
if (pKiller == me)
|
||||
{
|
||||
DoScriptText(SAY_DEATH_1, me, pPlayer);
|
||||
}
|
||||
else
|
||||
DoScriptText(SAY_DEATH_2, me, pPlayer);
|
||||
}
|
||||
}
|
||||
else
|
||||
DoScriptText(SAY_DEATH_3, me);
|
||||
}
|
||||
|
||||
void UpdateAI(const uint32 uiDiff)
|
||||
{
|
||||
//Must update npc_escortAI
|
||||
npc_escortAI::UpdateAI(uiDiff);
|
||||
|
||||
//Combat check
|
||||
if (me->getVictim())
|
||||
{
|
||||
if (m_uiDeathCoilTimer <= uiDiff)
|
||||
{
|
||||
DoScriptText(SAY_SPELL, me);
|
||||
DoCast(me->getVictim(), SPELL_DEATH_COIL, false);
|
||||
m_uiDeathCoilTimer = 4000;
|
||||
}
|
||||
else
|
||||
{
|
||||
DoScriptText(SAY_RAND_2, me);
|
||||
DoCast(me, SPELL_ELIXIR_OF_FORTITUDE, false);
|
||||
}
|
||||
|
||||
m_uiChatTimer = 12000;
|
||||
m_uiDeathCoilTimer -= uiDiff;
|
||||
}
|
||||
else
|
||||
m_uiChatTimer -= uiDiff;
|
||||
{
|
||||
//Out of combat but being escorted
|
||||
if (HasEscortState(STATE_ESCORT_ESCORTING))
|
||||
{
|
||||
if (m_uiChatTimer <= uiDiff)
|
||||
{
|
||||
if (me->HasAura(SPELL_ELIXIR_OF_FORTITUDE, 0))
|
||||
{
|
||||
DoScriptText(SAY_RAND_1, me);
|
||||
DoCast(me, SPELL_BLUE_FIREWORK, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoScriptText(SAY_RAND_2, me);
|
||||
DoCast(me, SPELL_ELIXIR_OF_FORTITUDE, false);
|
||||
}
|
||||
|
||||
m_uiChatTimer = 12000;
|
||||
}
|
||||
else
|
||||
m_uiChatTimer -= uiDiff;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* OnGetAI(Creature* creature) const
|
||||
{
|
||||
return new example_escortAI(creature);
|
||||
}
|
||||
|
||||
bool OnGossipHello(Player* player, Creature* creature)
|
||||
{
|
||||
player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
|
||||
player->PrepareGossipMenu(creature, 0);
|
||||
|
||||
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
|
||||
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
|
||||
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
|
||||
|
||||
player->SendPreparedGossip(creature);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
|
||||
{
|
||||
npc_escortAI* pEscortAI = CAST_AI(example_escortAI, creature->AI());
|
||||
|
||||
switch(action)
|
||||
{
|
||||
case GOSSIP_ACTION_INFO_DEF+1:
|
||||
player->CLOSE_GOSSIP_MENU();
|
||||
|
||||
if (pEscortAI)
|
||||
pEscortAI->Start(true, true, player->GetGUID());
|
||||
break;
|
||||
case GOSSIP_ACTION_INFO_DEF+2:
|
||||
player->CLOSE_GOSSIP_MENU();
|
||||
|
||||
if (pEscortAI)
|
||||
pEscortAI->Start(false, false, player->GetGUID());
|
||||
break;
|
||||
case GOSSIP_ACTION_INFO_DEF+3:
|
||||
player->CLOSE_GOSSIP_MENU();
|
||||
|
||||
if (pEscortAI)
|
||||
pEscortAI->Start(false, true, player->GetGUID());
|
||||
break;
|
||||
default:
|
||||
return false; // nothing defined -> trinity core handling
|
||||
}
|
||||
|
||||
return true; // no default handling -> prevent trinity core handling
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI_example_escort(Creature* pCreature)
|
||||
{
|
||||
return new example_escortAI(pCreature);
|
||||
}
|
||||
|
||||
bool GossipHello_example_escort(Player* pPlayer, Creature* pCreature)
|
||||
{
|
||||
pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
|
||||
pPlayer->PrepareGossipMenu(pCreature, 0);
|
||||
|
||||
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
|
||||
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
|
||||
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
|
||||
|
||||
pPlayer->SendPreparedGossip(pCreature);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GossipSelect_example_escort(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
|
||||
{
|
||||
npc_escortAI* pEscortAI = CAST_AI(example_escortAI, pCreature->AI());
|
||||
|
||||
switch(uiAction)
|
||||
{
|
||||
case GOSSIP_ACTION_INFO_DEF+1:
|
||||
pPlayer->CLOSE_GOSSIP_MENU();
|
||||
|
||||
if (pEscortAI)
|
||||
pEscortAI->Start(true, true, pPlayer->GetGUID());
|
||||
break;
|
||||
case GOSSIP_ACTION_INFO_DEF+2:
|
||||
pPlayer->CLOSE_GOSSIP_MENU();
|
||||
|
||||
if (pEscortAI)
|
||||
pEscortAI->Start(false, false, pPlayer->GetGUID());
|
||||
break;
|
||||
case GOSSIP_ACTION_INFO_DEF+3:
|
||||
pPlayer->CLOSE_GOSSIP_MENU();
|
||||
|
||||
if (pEscortAI)
|
||||
pEscortAI->Start(false, true, pPlayer->GetGUID());
|
||||
break;
|
||||
default:
|
||||
return false; // nothing defined -> trinity core handling
|
||||
}
|
||||
|
||||
return true; // no default handling -> prevent trinity core handling
|
||||
}
|
||||
|
||||
void AddSC_example_escort()
|
||||
{
|
||||
Script *newscript;
|
||||
newscript = new Script;
|
||||
newscript->Name = "example_escort";
|
||||
newscript->GetAI = &GetAI_example_escort;
|
||||
newscript->pGossipHello = &GossipHello_example_escort;
|
||||
newscript->pGossipSelect = &GossipSelect_example_escort;
|
||||
newscript->RegisterSelf();
|
||||
new example_escort();
|
||||
}
|
||||
|
||||
@@ -39,63 +39,64 @@ enum eEnums
|
||||
#define GOSSIP_ITEM_1 "A quiz: what's your name?"
|
||||
#define GOSSIP_ITEM_2 "I'm not interested"
|
||||
|
||||
//This function is called when the player opens the gossip menubool
|
||||
bool GossipHello_example_gossip_codebox(Player* pPlayer, Creature* pCreature)
|
||||
class example_gossip_codebox : public CreatureScript
|
||||
{
|
||||
pPlayer->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
|
||||
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
|
||||
public:
|
||||
|
||||
pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//This function is called when the player clicks an option on the gossip menubool
|
||||
bool GossipSelect_example_gossip_codebox(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
|
||||
{
|
||||
if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
|
||||
{
|
||||
DoScriptText(SAY_NOT_INTERESTED, pCreature);
|
||||
pPlayer->CLOSE_GOSSIP_MENU();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GossipSelectWithCode_example_gossip_codebox(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction, const char* sCode)
|
||||
{
|
||||
if (uiSender == GOSSIP_SENDER_MAIN)
|
||||
{
|
||||
switch (uiAction)
|
||||
example_gossip_codebox()
|
||||
: CreatureScript("example_gossip_codebox")
|
||||
{
|
||||
case GOSSIP_ACTION_INFO_DEF+1:
|
||||
if (std::strcmp(sCode, pPlayer->GetName()) != 0)
|
||||
{
|
||||
DoScriptText(SAY_WRONG, pCreature);
|
||||
pCreature->CastSpell(pPlayer, SPELL_POLYMORPH, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoScriptText(SAY_CORRECT, pCreature);
|
||||
pCreature->CastSpell(pPlayer, SPELL_MARK_OF_THE_WILD, true);
|
||||
}
|
||||
pPlayer->CLOSE_GOSSIP_MENU();
|
||||
}
|
||||
|
||||
bool OnGossipHello(Player* player, Creature* creature)
|
||||
{
|
||||
player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
|
||||
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
|
||||
|
||||
player->PlayerTalkClass->SendGossipMenu(907, creature->GetGUID());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
|
||||
{
|
||||
if (action == GOSSIP_ACTION_INFO_DEF+2)
|
||||
{
|
||||
DoScriptText(SAY_NOT_INTERESTED, creature);
|
||||
player->CLOSE_GOSSIP_MENU();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code)
|
||||
{
|
||||
if (sender == GOSSIP_SENDER_MAIN)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case GOSSIP_ACTION_INFO_DEF+1:
|
||||
if (std::strcmp(code, player->GetName()) != 0)
|
||||
{
|
||||
DoScriptText(SAY_WRONG, creature);
|
||||
creature->CastSpell(player, SPELL_POLYMORPH, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoScriptText(SAY_CORRECT, creature);
|
||||
creature->CastSpell(player, SPELL_MARK_OF_THE_WILD, true);
|
||||
}
|
||||
player->CLOSE_GOSSIP_MENU();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_example_gossip_codebox()
|
||||
{
|
||||
Script* newscript;
|
||||
|
||||
newscript = new Script;
|
||||
newscript->Name = "example_gossip_codebox";
|
||||
newscript->pGossipHello = &GossipHello_example_gossip_codebox;
|
||||
newscript->pGossipSelect = &GossipSelect_example_gossip_codebox;
|
||||
newscript->pGossipSelectWithCode = &GossipSelectWithCode_example_gossip_codebox;
|
||||
newscript->RegisterSelf();
|
||||
new example_gossip_codebox();
|
||||
}
|
||||
|
||||
@@ -31,41 +31,57 @@ enum eSay
|
||||
SAY_HI = -1999925
|
||||
};
|
||||
|
||||
bool AT_example_areatrigger(Player* pPlayer, const AreaTriggerEntry * /*pAt*/)
|
||||
class AT_example_areatrigger : public AreaTriggerScript
|
||||
{
|
||||
DoScriptText(SAY_HI, pPlayer);
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
|
||||
extern void LoadDatabase();
|
||||
bool ItemUse_example_item(Player* /*pPlayer*/, Item* /*pItem*/, SpellCastTargets const& /*scTargets*/)
|
||||
{
|
||||
sScriptMgr.LoadDatabase();
|
||||
return true;
|
||||
}
|
||||
AT_example_areatrigger()
|
||||
: AreaTriggerScript("example_areatrigger")
|
||||
{
|
||||
}
|
||||
|
||||
bool GOHello_example_go_teleporter(Player* pPlayer, GameObject* /*pGo*/)
|
||||
bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)
|
||||
{
|
||||
DoScriptText(SAY_HI, player);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class ItemUse_example_item : public ItemScript
|
||||
{
|
||||
pPlayer->TeleportTo(0, 1807.07f, 336.105f, 70.3975f, 0.0f);
|
||||
return false;
|
||||
}
|
||||
public:
|
||||
|
||||
ItemUse_example_item()
|
||||
: ItemScript("example_item")
|
||||
{
|
||||
}
|
||||
|
||||
bool OnUse(Player* player, Item* item, SpellCastTargets const& targets)
|
||||
{
|
||||
sScriptMgr.LoadDatabase();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class GOHello_example_go_teleporter : public GameObjectScript
|
||||
{
|
||||
public:
|
||||
|
||||
GOHello_example_go_teleporter()
|
||||
: GameObjectScript("example_go_teleporter")
|
||||
{
|
||||
}
|
||||
|
||||
bool OnGossipHello(Player* player, GameObject* go)
|
||||
{
|
||||
player->TeleportTo(0, 1807.07f, 336.105f, 70.3975f, 0.0f);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_example_misc()
|
||||
{
|
||||
Script* newscript;
|
||||
|
||||
newscript = new Script;
|
||||
newscript->Name = "example_areatrigger";
|
||||
newscript->pAreaTrigger = &AT_example_areatrigger;
|
||||
newscript->RegisterSelf();
|
||||
|
||||
newscript = new Script;
|
||||
newscript->Name = "example_item";
|
||||
newscript->pItemUse = &ItemUse_example_item;
|
||||
newscript->RegisterSelf();
|
||||
|
||||
newscript = new Script;
|
||||
newscript->Name = "example_go_teleporter";
|
||||
newscript->pGOHello = &GOHello_example_go_teleporter;
|
||||
newscript->RegisterSelf();
|
||||
new AT_example_areatrigger();
|
||||
new ItemUse_example_item();
|
||||
new GOHello_example_go_teleporter();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user