2010-07-06 03:27:41 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
|
|
|
|
|
* Copyright (C) 2006-2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
|
2008-10-21 13:19:26 -05:00
|
|
|
*
|
2010-07-06 03:27:41 +02:00
|
|
|
* 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.
|
2008-10-21 13:19:26 -05:00
|
|
|
*
|
2010-07-06 03:27:41 +02:00
|
|
|
* 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/>.
|
2008-10-21 13:19:26 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* ScriptData
|
|
|
|
|
SDName: Test
|
|
|
|
|
SD%Complete: 100
|
|
|
|
|
SDComment: Script used for testing escortAI
|
|
|
|
|
SDCategory: Script Examples
|
|
|
|
|
EndScriptData */
|
|
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
2009-08-16 18:34:45 +02:00
|
|
|
#include "escort_ai.h"
|
2008-10-21 13:19:26 -05:00
|
|
|
|
2009-08-23 03:48:18 -04:00
|
|
|
#define SAY_WALK "Hmm a nice day for a walk alright"
|
|
|
|
|
#define SAY_ATTACK "Wild Felboar attack!"
|
|
|
|
|
#define SAY_TIME_TO_GO "Time for me to go! See ya around $N!"
|
|
|
|
|
#define SAY_BYE "Bye Bye!"
|
|
|
|
|
#define SAY_AGGRO1 "Help $N! I'm under attack!"
|
|
|
|
|
#define SAY_AGGRO2 "Die scum!"
|
|
|
|
|
#define WHISPER_TOO_FAR "How dare you leave me like that! I hate you! =*("
|
|
|
|
|
#define SAY_DIE1 "...no...how could you let me die $N"
|
|
|
|
|
#define SAY_DIE2 "ugh..."
|
|
|
|
|
#define SAY_DEATHCOIL "Taste death!"
|
|
|
|
|
#define SAY_FIREWORKS "Fireworks!"
|
|
|
|
|
#define SAY_BUFF "Hmm, I think I could use a buff"
|
|
|
|
|
|
|
|
|
|
#define GOSSIP_TEXT1 "Click to Test Escort(Attack, Defend, Run)"
|
|
|
|
|
#define GOSSIP_TEXT2 "Click to Test Escort(NoAttack, NoDefend, Walk)"
|
|
|
|
|
#define GOSSIP_TEXT3 "Click to Test Escort(NoAttack, Defend, Walk)"
|
|
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
struct TRINITY_DLL_DECL npc_testAI : public npc_escortAI
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// CreatureAI functions
|
2009-03-31 18:12:49 -06:00
|
|
|
npc_testAI(Creature *c) : npc_escortAI(c) {}
|
2008-10-21 13:19:26 -05:00
|
|
|
|
|
|
|
|
uint32 DeathCoilTimer;
|
|
|
|
|
uint32 ChatTimer;
|
|
|
|
|
|
|
|
|
|
// Pure Virtual Functions
|
|
|
|
|
void WaypointReached(uint32 i)
|
|
|
|
|
{
|
|
|
|
|
switch (i)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
2010-05-01 02:59:48 +02:00
|
|
|
me->Say(SAY_WALK, LANG_UNIVERSAL, 0);
|
2008-10-21 13:19:26 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
{
|
2010-05-01 02:59:48 +02:00
|
|
|
me->Say(SAY_ATTACK, LANG_UNIVERSAL, 0);
|
|
|
|
|
Creature* temp = me->SummonCreature(21878, me->GetPositionX()+5, me->GetPositionY()+7, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000);
|
2009-08-14 00:02:13 +02:00
|
|
|
if (temp)
|
2010-05-01 02:59:48 +02:00
|
|
|
temp->AI()->AttackStart(me);
|
2008-10-21 13:19:26 -05:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
{
|
2010-05-01 02:59:48 +02:00
|
|
|
me->Say(SAY_TIME_TO_GO, LANG_UNIVERSAL, PlayerGUID);
|
|
|
|
|
me->HandleEmoteCommand(EMOTE_ONESHOT_WAVE);
|
2008-10-21 13:19:26 -05:00
|
|
|
|
2010-05-01 02:59:48 +02:00
|
|
|
Unit* temp = Unit::GetUnit(*me, PlayerGUID);
|
2008-10-21 13:19:26 -05:00
|
|
|
if (temp)
|
|
|
|
|
{
|
2009-08-23 03:48:18 -04:00
|
|
|
temp->MonsterSay(SAY_BYE, LANG_UNIVERSAL, 0);
|
2008-10-21 13:19:26 -05:00
|
|
|
temp->HandleEmoteCommand(EMOTE_ONESHOT_WAVE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 14:17:30 +02:00
|
|
|
void EnterCombat(Unit*)
|
2008-10-21 13:19:26 -05:00
|
|
|
{
|
2009-10-11 18:03:59 +02:00
|
|
|
if (HasEscortState(STATE_ESCORT_ESCORTING))
|
2010-05-01 02:59:48 +02:00
|
|
|
me->Say(SAY_AGGRO1, LANG_UNIVERSAL, PlayerGUID);
|
|
|
|
|
else me->Say(SAY_AGGRO2, LANG_UNIVERSAL, 0);
|
2008-10-21 13:19:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Reset()
|
|
|
|
|
{
|
|
|
|
|
DeathCoilTimer = 4000;
|
|
|
|
|
ChatTimer = 4000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void JustDied(Unit* killer)
|
|
|
|
|
{
|
2009-10-11 18:03:59 +02:00
|
|
|
if (HasEscortState(STATE_ESCORT_ESCORTING))
|
2008-10-21 13:19:26 -05:00
|
|
|
{
|
2010-05-01 02:59:48 +02:00
|
|
|
//killer = me when player got to far from creature
|
|
|
|
|
if (killer == me)
|
2008-10-21 13:19:26 -05:00
|
|
|
{
|
2010-05-01 02:59:48 +02:00
|
|
|
Unit *pTemp = Unit::GetUnit(*me,PlayerGUID);
|
2009-08-14 00:02:13 +02:00
|
|
|
if (pTemp)
|
2009-08-23 03:48:18 -04:00
|
|
|
DoWhisper(WHISPER_TOO_FAR, pTemp);
|
2008-10-21 13:19:26 -05:00
|
|
|
}
|
2010-05-01 02:59:48 +02:00
|
|
|
else me->Say(SAY_DIE1, LANG_UNIVERSAL, PlayerGUID);
|
2008-10-21 13:19:26 -05:00
|
|
|
}
|
2010-05-01 02:59:48 +02:00
|
|
|
else me->Say(SAY_DIE2, LANG_UNIVERSAL, 0);
|
2008-10-21 13:19:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UpdateAI(const uint32 diff)
|
|
|
|
|
{
|
|
|
|
|
//Must update npc_escortAI
|
|
|
|
|
npc_escortAI::UpdateAI(diff);
|
|
|
|
|
|
|
|
|
|
//Combat check
|
2010-05-01 02:59:48 +02:00
|
|
|
if (me->isInCombat() && me->getVictim())
|
2008-10-21 13:19:26 -05:00
|
|
|
{
|
|
|
|
|
if (DeathCoilTimer < diff)
|
|
|
|
|
{
|
2010-05-01 02:59:48 +02:00
|
|
|
me->Say(SAY_DEATHCOIL, LANG_UNIVERSAL, 0);
|
|
|
|
|
me->CastSpell(me->getVictim(), 33130, false);
|
2008-10-21 13:19:26 -05:00
|
|
|
|
|
|
|
|
DeathCoilTimer = 4000;
|
|
|
|
|
}else DeathCoilTimer -= diff;
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
//Out of combat but being escorted
|
2009-10-11 18:03:59 +02:00
|
|
|
if (HasEscortState(STATE_ESCORT_ESCORTING))
|
2008-10-21 13:19:26 -05:00
|
|
|
if (ChatTimer < diff)
|
|
|
|
|
{
|
2010-05-01 02:59:48 +02:00
|
|
|
if (me->HasAura(3593, 0))
|
2008-10-21 13:19:26 -05:00
|
|
|
{
|
2010-05-01 02:59:48 +02:00
|
|
|
me->Say(SAY_FIREWORKS, LANG_UNIVERSAL, 0);
|
|
|
|
|
me->CastSpell(me, 11540, false);
|
2008-10-21 13:19:26 -05:00
|
|
|
}else
|
|
|
|
|
{
|
2010-05-01 02:59:48 +02:00
|
|
|
me->Say(SAY_BUFF, LANG_UNIVERSAL, 0);
|
|
|
|
|
me->CastSpell(me, 3593, false);
|
2008-10-21 13:19:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChatTimer = 12000;
|
|
|
|
|
}else ChatTimer -= diff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2010-08-08 22:54:58 +06:00
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
class test : public CreatureScript
|
2010-08-08 22:54:58 +06:00
|
|
|
{
|
|
|
|
|
public:
|
2008-10-21 13:19:26 -05:00
|
|
|
test() : CreatureScript("test") { }
|
2010-08-08 22:54:58 +06:00
|
|
|
|
|
|
|
|
bool GossipSelect_npc(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
|
|
|
|
|
{
|
|
|
|
|
if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
|
|
|
|
|
{
|
|
|
|
|
pPlayer->CLOSE_GOSSIP_MENU();
|
2008-10-21 13:19:26 -05:00
|
|
|
((npc_escortAI*)(pCreature->AI()))->Start(true, true, pPlayer->GetGUID());
|
2010-08-08 22:54:58 +06:00
|
|
|
|
|
|
|
|
return true; // prevent Trinity core handling
|
2008-10-21 13:19:26 -05:00
|
|
|
}
|
2010-08-08 22:54:58 +06:00
|
|
|
|
|
|
|
|
if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
|
|
|
|
|
{
|
|
|
|
|
pPlayer->CLOSE_GOSSIP_MENU();
|
2008-10-21 13:19:26 -05:00
|
|
|
((npc_escortAI*)(pCreature->AI()))->Start(false, false, pPlayer->GetGUID());
|
2010-08-08 22:54:58 +06:00
|
|
|
|
|
|
|
|
return true; // prevent Trinity core handling
|
2008-10-21 13:19:26 -05:00
|
|
|
}
|
2010-08-08 22:54:58 +06:00
|
|
|
|
|
|
|
|
if (uiAction == GOSSIP_ACTION_INFO_DEF+3)
|
|
|
|
|
{
|
|
|
|
|
pPlayer->CLOSE_GOSSIP_MENU();
|
2008-10-21 13:19:26 -05:00
|
|
|
((npc_escortAI*)(pCreature->AI()))->Start(false, false, pPlayer->GetGUID());
|
2010-08-08 22:54:58 +06:00
|
|
|
|
|
|
|
|
return true; // prevent Trinity core handling
|
|
|
|
|
}
|
2008-10-21 13:19:26 -05:00
|
|
|
return false;
|
|
|
|
|
}
|
2010-08-08 22:54:58 +06:00
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
bool GossipHello_npc(Player* pPlayer, Creature* pCreature)
|
2010-08-08 22:54:58 +06:00
|
|
|
{
|
|
|
|
|
pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
|
2008-10-21 13:19:26 -05:00
|
|
|
pCreature->prepareGossipMenu(pPlayer,0);
|
2010-08-08 22:54:58 +06:00
|
|
|
|
|
|
|
|
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
|
|
|
|
|
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
|
|
|
|
|
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
|
|
|
|
|
|
|
|
|
|
pCreature->sendPreparedGossip(pPlayer);
|
2008-10-21 13:19:26 -05:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-08-08 22:54:58 +06:00
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
CreatureAI* GetAI(Creature* pCreature)
|
2010-08-08 22:54:58 +06:00
|
|
|
{
|
|
|
|
|
npcAI* testAI = new npcAI(pCreature);
|
|
|
|
|
|
|
|
|
|
testAI->AddWaypoint(0, 1231, -4419, 23);
|
|
|
|
|
testAI->AddWaypoint(1, 1198, -4440, 23, 0);
|
|
|
|
|
testAI->AddWaypoint(2, 1208, -4392, 23);
|
|
|
|
|
testAI->AddWaypoint(3, 1231, -4419, 23, 5000);
|
2008-10-21 13:19:26 -05:00
|
|
|
testAI->AddWaypoint(4, 1208, -4392, 23, 5000);
|
2010-08-08 22:54:58 +06:00
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
return (CreatureAI*)testAI;
|
2010-08-08 22:54:58 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void AddSC_test()
|
2010-08-08 22:54:58 +06:00
|
|
|
{
|
2008-10-21 13:19:26 -05:00
|
|
|
new test();
|