Files
TCPlayerbotCore/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp
T

210 lines
5.6 KiB
C++
Raw Normal View History

/* Copyright (C) 2008 - 2010 Trinity <http://www.trinitycore.org/>
2010-07-02 16:02:40 +02:00
* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
* 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.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
2009-10-17 15:51:44 -07:00
/* ScriptData
SDName: Tirisfal_Glades
SD%Complete: 100
2008-12-22 21:20:04 +01:00
SDComment: Quest support: 590, 1819
SDCategory: Tirisfal Glades
EndScriptData */
2009-10-17 15:51:44 -07:00
/* ContentData
npc_calvin_montague
2008-12-22 21:20:04 +01:00
go_mausoleum_door
go_mausoleum_trigger
EndContentData */
2009-10-17 15:51:44 -07:00
#include "ScriptPCH.h"
2009-10-17 15:51:44 -07:00
/*######
## npc_calvin_montague
######*/
2009-10-17 15:51:44 -07:00
2009-10-17 07:42:48 -07:00
enum eCalvin
2009-08-07 02:03:27 +02:00
{
SAY_COMPLETE = -1000431,
SPELL_DRINK = 2639, // possibly not correct spell (but iconId is correct)
QUEST_590 = 590,
FACTION_HOSTILE = 168
};
2009-10-17 15:51:44 -07:00
2010-02-05 00:31:28 +01:00
struct npc_calvin_montagueAI : public ScriptedAI
{
2009-08-07 02:03:27 +02:00
npc_calvin_montagueAI(Creature* pCreature) : ScriptedAI(pCreature) { }
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
uint32 m_uiPhase;
uint32 m_uiPhaseTimer;
uint64 m_uiPlayerGUID;
2009-10-17 15:51:44 -07:00
void Reset()
{
2009-08-07 02:03:27 +02:00
m_uiPhase = 0;
m_uiPhaseTimer = 5000;
m_uiPlayerGUID = 0;
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
me->RestoreFaction();
2009-10-17 15:51:44 -07:00
2010-04-14 23:07:41 +02:00
if (!me->HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_OOC_NOT_ATTACKABLE))
me->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_OOC_NOT_ATTACKABLE);
}
2009-10-17 15:51:44 -07:00
2010-04-19 09:26:37 +02:00
void EnterCombat(Unit* /*who*/) {}
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
void AttackedBy(Unit* pAttacker)
{
2010-04-14 23:07:41 +02:00
if (me->getVictim() || me->IsFriendlyTo(pAttacker))
2009-08-07 02:03:27 +02:00
return;
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
AttackStart(pAttacker);
}
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
{
2010-04-14 23:07:41 +02:00
if (uiDamage > me->GetHealth() || ((me->GetHealth() - uiDamage)*100 / me->GetMaxHealth() < 15))
2009-08-07 02:03:27 +02:00
{
uiDamage = 0;
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
me->RestoreFaction();
2010-04-14 23:07:41 +02:00
me->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_OOC_NOT_ATTACKABLE);
me->CombatStop(true);
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
m_uiPhase = 1;
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
if (pDoneBy->GetTypeId() == TYPEID_PLAYER)
m_uiPlayerGUID = pDoneBy->GetGUID();
}
}
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
void UpdateAI(const uint32 uiDiff)
{
if (m_uiPhase)
{
2009-10-27 21:28:20 -07:00
if (m_uiPhaseTimer <= uiDiff)
2009-08-07 02:03:27 +02:00
m_uiPhaseTimer = 7500;
else
{
m_uiPhaseTimer -= uiDiff;
return;
}
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
switch(m_uiPhase)
{
case 1:
2010-04-14 23:07:41 +02:00
DoScriptText(SAY_COMPLETE, me);
2009-08-07 02:03:27 +02:00
++m_uiPhase;
break;
case 2:
if (Player *pPlayer = Unit::GetPlayer(m_uiPlayerGUID))
pPlayer->AreaExploredOrEventHappens(QUEST_590);
2009-10-17 15:51:44 -07:00
2010-04-14 23:07:41 +02:00
DoCast(me, SPELL_DRINK, true);
2009-08-07 02:03:27 +02:00
++m_uiPhase;
break;
case 3:
EnterEvadeMode();
break;
}
2009-10-17 15:51:44 -07:00
2009-08-07 02:03:27 +02:00
return;
}
2009-10-17 15:51:44 -07:00
2009-01-30 18:10:05 -06:00
if (!UpdateVictim())
return;
2009-10-17 15:51:44 -07:00
DoMeleeAttackIfReady();
}
};
2009-08-14 00:39:07 +02:00
CreatureAI* GetAI_npc_calvin_montague(Creature* pCreature)
{
2009-08-14 00:39:07 +02:00
return new npc_calvin_montagueAI (pCreature);
}
2009-10-17 15:51:44 -07:00
bool QuestAccept_npc_calvin_montague(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
{
if (pQuest->GetQuestId() == QUEST_590)
{
2009-08-07 02:03:27 +02:00
pCreature->setFaction(FACTION_HOSTILE);
pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
2009-08-07 02:03:27 +02:00
CAST_AI(npc_calvin_montagueAI, pCreature->AI())->AttackStart(pPlayer);
}
return true;
}
2009-10-17 15:51:44 -07:00
2008-12-22 21:20:04 +01:00
/*######
## go_mausoleum_door
## go_mausoleum_trigger
######*/
2009-10-17 15:51:44 -07:00
2009-10-17 07:42:48 -07:00
enum eMausoleum
2008-12-22 21:20:04 +01:00
{
2009-06-29 06:31:05 +02:00
QUEST_ULAG = 1819,
NPC_ULAG = 6390,
GO_TRIGGER = 104593,
GO_DOOR = 176594
};
2009-10-17 15:51:44 -07:00
2010-04-19 09:26:37 +02:00
bool GOHello_go_mausoleum_door(Player* pPlayer, GameObject* /*pGo*/)
2008-12-22 21:20:04 +01:00
{
2009-06-29 06:31:05 +02:00
if (pPlayer->GetQuestStatus(QUEST_ULAG) != QUEST_STATUS_INCOMPLETE)
2008-12-22 21:20:04 +01:00
return false;
2009-10-17 15:51:44 -07:00
2009-06-29 06:31:05 +02:00
if (GameObject* pTrigger = pPlayer->FindNearestGameObject(GO_TRIGGER, 30.0f))
2008-12-22 21:20:04 +01:00
{
2009-06-29 06:31:05 +02:00
pTrigger->SetGoState(GO_STATE_READY);
pPlayer->SummonCreature(NPC_ULAG, 2390.26, 336.47, 40.01, 2.26, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 300000);
2008-12-22 21:20:04 +01:00
return false;
}
2009-10-17 15:51:44 -07:00
2008-12-22 21:20:04 +01:00
return false;
}
2009-10-17 15:51:44 -07:00
2009-06-29 06:31:05 +02:00
bool GOHello_go_mausoleum_trigger(Player* pPlayer, GameObject* pGo)
2008-12-22 21:20:04 +01:00
{
2009-06-29 06:31:05 +02:00
if (pPlayer->GetQuestStatus(QUEST_ULAG) != QUEST_STATUS_INCOMPLETE)
2008-12-22 21:20:04 +01:00
return false;
2009-10-17 15:51:44 -07:00
2009-06-29 06:31:05 +02:00
if (GameObject* pDoor = pPlayer->FindNearestGameObject(GO_DOOR, 30.0f))
2008-12-22 21:20:04 +01:00
{
2009-06-29 06:31:05 +02:00
pGo->SetGoState(GO_STATE_ACTIVE);
pDoor->RemoveFlag(GAMEOBJECT_FLAGS,GO_FLAG_INTERACT_COND);
2008-12-22 21:20:04 +01:00
return true;
}
2009-10-17 15:51:44 -07:00
2008-12-22 21:20:04 +01:00
return false;
}
2009-10-17 15:51:44 -07:00
void AddSC_tirisfal_glades()
{
Script *newscript;
2009-10-17 15:51:44 -07:00
newscript = new Script;
newscript->Name = "npc_calvin_montague";
newscript->GetAI = &GetAI_npc_calvin_montague;
newscript->pQuestAccept = &QuestAccept_npc_calvin_montague;
2008-12-22 21:20:04 +01:00
newscript->RegisterSelf();
2009-10-17 15:51:44 -07:00
2009-02-09 08:16:34 -05:00
newscript = new Script;
2008-12-22 21:20:04 +01:00
newscript->Name = "go_mausoleum_door";
newscript->pGOHello = &GOHello_go_mausoleum_door;
newscript->RegisterSelf();
2009-10-17 15:51:44 -07:00
2008-12-22 21:20:04 +01:00
newscript = new Script;
newscript->Name = "go_mausoleum_trigger";
newscript->pGOHello = &GOHello_go_mausoleum_trigger;
newscript->RegisterSelf();
}