Files
TCPlayerbotCore/src/scripts/eastern_kingdoms/hinterlands.cpp
T

351 lines
9.8 KiB
C++
Raw Normal View History

2009-08-14 17:14:08 +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
2009-08-14 17:14:08 +02:00
/* ScriptData
SDName: Hinterlands
SD%Complete: 100
2009-08-16 22:21:57 +02:00
SDComment: Quest support: 863, 2742
2009-08-14 17:14:08 +02:00
SDCategory: The Hinterlands
EndScriptData */
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
/* ContentData
2009-08-16 22:21:57 +02:00
npc_00x09hl
2009-08-14 17:14:08 +02:00
npc_rinji
EndContentData */
2009-10-17 15:51:44 -07:00
2010-01-19 11:36:05 +01:00
#include "ScriptedPch.h"
#include "ScriptedEscortAI.h"
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
/*######
## npc_00x09hl
######*/
2009-10-17 15:51:44 -07:00
2009-10-17 07:42:48 -07:00
enum eOOX
2009-08-16 22:21:57 +02:00
{
2009-08-17 02:06:52 +02:00
SAY_OOX_START = -1000287,
SAY_OOX_AGGRO1 = -1000288,
SAY_OOX_AGGRO2 = -1000289,
SAY_OOX_AMBUSH = -1000290,
SAY_OOX_END = -1000292,
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
QUEST_RESQUE_OOX_09 = 836,
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
NPC_MARAUDING_OWL = 7808,
NPC_VILE_AMBUSHER = 7809,
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
FACTION_ESCORTEE_A = 774,
FACTION_ESCORTEE_H = 775
};
2009-10-17 15:51:44 -07:00
2010-02-05 00:31:28 +01:00
struct npc_00x09hlAI : public npc_escortAI
2009-08-16 22:21:57 +02:00
{
npc_00x09hlAI(Creature* pCreature) : npc_escortAI(pCreature) { }
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
void Reset() { }
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
void WaypointReached(uint32 uiPointId)
{
switch(uiPointId)
{
case 26:
2009-08-17 02:06:52 +02:00
DoScriptText(SAY_OOX_AMBUSH, m_creature);
2009-08-16 22:21:57 +02:00
break;
case 43:
2009-08-17 02:06:52 +02:00
DoScriptText(SAY_OOX_AMBUSH, m_creature);
2009-08-16 22:21:57 +02:00
break;
case 64:
2009-08-17 02:06:52 +02:00
DoScriptText(SAY_OOX_END, m_creature);
2009-08-17 00:29:53 +02:00
if (Player* pPlayer = GetPlayerForEscort())
2009-08-16 22:21:57 +02:00
pPlayer->GroupEventHappens(QUEST_RESQUE_OOX_09, m_creature);
break;
}
}
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
void WaypointStart(uint32 uiPointId)
{
switch(uiPointId)
{
case 27:
2009-10-17 16:20:24 -07:00
for (uint8 i = 0; i < 3; ++i)
2009-08-16 22:21:57 +02:00
{
2009-08-29 23:20:16 -05:00
const Position src = {147.927444f, -3851.513428f, 130.893f, 0};
Position pos;
me->GetRandomNearPosition(pos, 7.0f);
DoSummon(NPC_MARAUDING_OWL, pos, 25000, TEMPSUMMON_CORPSE_TIMED_DESPAWN);
2009-08-16 22:21:57 +02:00
}
break;
case 44:
2009-10-17 16:20:24 -07:00
for (uint8 i = 0; i < 3; ++i)
2009-08-16 22:21:57 +02:00
{
2009-08-29 23:20:16 -05:00
const Position src = {-141.151581f, -4291.213867f, 120.130f, 0};
Position dst;
m_creature->GetRandomPoint(src, 7.0f, dst);
m_creature->SummonCreature(NPC_VILE_AMBUSHER, dst, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 25000);
2009-08-16 22:21:57 +02:00
}
break;
}
}
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
void Aggro(Unit* pWho)
{
if (pWho->GetEntry() == NPC_MARAUDING_OWL || pWho->GetEntry() == NPC_VILE_AMBUSHER)
return;
2009-10-17 15:51:44 -07:00
2009-08-17 02:06:52 +02:00
if (rand()%1)
DoScriptText(SAY_OOX_AGGRO1, m_creature);
else
DoScriptText(SAY_OOX_AGGRO2, m_creature);
2009-08-16 22:21:57 +02:00
}
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
void JustSummoned(Creature* pSummoned)
{
pSummoned->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());
}
};
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
bool QuestAccept_npc_00x09hl(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
{
if (pQuest->GetQuestId() == QUEST_RESQUE_OOX_09)
{
pCreature->SetStandState(UNIT_STAND_STATE_STAND);
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
if (pPlayer->GetTeam() == ALLIANCE)
pCreature->setFaction(FACTION_ESCORTEE_A);
else if (pPlayer->GetTeam() == HORDE)
pCreature->setFaction(FACTION_ESCORTEE_H);
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
DoScriptText(SAY_OOX_START, pCreature, pPlayer);
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
if (npc_00x09hlAI* pEscortAI = CAST_AI(npc_00x09hlAI, pCreature->AI()))
pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
}
return true;
}
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
CreatureAI* GetAI_npc_00x09hl(Creature* pCreature)
{
return new npc_00x09hlAI(pCreature);
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
/*######
## npc_rinji
######*/
2009-10-17 15:51:44 -07:00
2009-10-17 07:42:48 -07:00
enum eRinji
2009-08-14 17:14:08 +02:00
{
SAY_RIN_FREE = -1000403, //from here
2009-08-14 17:14:08 +02:00
SAY_RIN_BY_OUTRUNNER = -1000404,
SAY_RIN_HELP_1 = -1000405,
SAY_RIN_HELP_2 = -1000406, //to here, are used also by 6182 but this is wrong...
2009-08-14 17:14:08 +02:00
SAY_RIN_COMPLETE = -1000407,
SAY_RIN_PROGRESS_1 = -1000408,
SAY_RIN_PROGRESS_2 = -1000409,
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
QUEST_RINJI_TRAPPED = 2742,
NPC_RANGER = 2694,
NPC_OUTRUNNER = 2691,
GO_RINJI_CAGE = 142036
};
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
struct Location
{
float m_fX, m_fY, m_fZ;
};
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
Location m_afAmbushSpawn[] =
{
{191.296204, -2839.329346, 107.388},
{70.972466, -2848.674805, 109.459}
};
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
Location m_afAmbushMoveTo[] =
{
{166.630386, -2824.780273, 108.153},
{70.886589, -2874.335449, 116.675}
};
2009-10-17 15:51:44 -07:00
2010-02-05 00:31:28 +01:00
struct npc_rinjiAI : public npc_escortAI
2009-08-14 17:14:08 +02:00
{
npc_rinjiAI(Creature* pCreature) : npc_escortAI(pCreature)
{
m_bIsByOutrunner = false;
m_iSpawnId = 0;
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
bool m_bIsByOutrunner;
uint32 m_uiPostEventCount;
uint32 m_uiPostEventTimer;
int m_iSpawnId;
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
void Reset()
{
m_uiPostEventCount = 0;
m_uiPostEventTimer = 3000;
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
void JustRespawned()
{
m_bIsByOutrunner = false;
m_iSpawnId = 0;
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
npc_escortAI::JustRespawned();
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
void EnterCombat(Unit* pWho)
{
2009-10-11 18:03:59 +02:00
if (HasEscortState(STATE_ESCORT_ESCORTING))
2009-08-14 17:14:08 +02:00
{
if (pWho->GetEntry() == NPC_OUTRUNNER && !m_bIsByOutrunner)
{
DoScriptText(SAY_RIN_BY_OUTRUNNER, pWho);
m_bIsByOutrunner = true;
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
if (rand()%4)
return;
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
//only if attacked and escorter is not in combat?
DoScriptText(RAND(SAY_RIN_HELP_1,SAY_RIN_HELP_2), m_creature);
2009-08-14 17:14:08 +02:00
}
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
void DoSpawnAmbush(bool bFirst)
{
if (!bFirst)
m_iSpawnId = 1;
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
m_creature->SummonCreature(NPC_RANGER,
m_afAmbushSpawn[m_iSpawnId].m_fX, m_afAmbushSpawn[m_iSpawnId].m_fY, m_afAmbushSpawn[m_iSpawnId].m_fZ, 0.0f,
TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for (int i = 0; i < 2; ++i)
2009-08-14 17:14:08 +02:00
{
m_creature->SummonCreature(NPC_OUTRUNNER,
m_afAmbushSpawn[m_iSpawnId].m_fX, m_afAmbushSpawn[m_iSpawnId].m_fY, m_afAmbushSpawn[m_iSpawnId].m_fZ, 0.0f,
TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
}
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
void JustSummoned(Creature* pSummoned)
{
pSummoned->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
pSummoned->GetMotionMaster()->MovePoint(0, m_afAmbushMoveTo[m_iSpawnId].m_fX, m_afAmbushMoveTo[m_iSpawnId].m_fY, m_afAmbushMoveTo[m_iSpawnId].m_fZ);
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
void WaypointReached(uint32 uiPointId)
{
2009-08-17 00:29:53 +02:00
Player* pPlayer = GetPlayerForEscort();
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
if (!pPlayer)
return;
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
switch(uiPointId)
{
case 1:
DoScriptText(SAY_RIN_FREE, m_creature, pPlayer);
break;
case 7:
DoSpawnAmbush(true);
break;
case 13:
DoSpawnAmbush(false);
break;
case 17:
DoScriptText(SAY_RIN_COMPLETE, m_creature, pPlayer);
pPlayer->GroupEventHappens(QUEST_RINJI_TRAPPED, m_creature);
SetRun();
m_uiPostEventCount = 1;
break;
}
}
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
void UpdateEscortAI(const uint32 uiDiff)
2009-08-14 17:14:08 +02:00
{
2009-08-16 22:21:57 +02:00
//Check if we have a current target
if (!UpdateVictim())
2009-08-14 17:14:08 +02:00
{
2009-10-11 18:03:59 +02:00
if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPostEventCount)
2009-08-14 17:14:08 +02:00
{
2009-10-27 21:28:20 -07:00
if (m_uiPostEventTimer <= uiDiff)
2009-08-14 17:14:08 +02:00
{
2009-08-16 22:21:57 +02:00
m_uiPostEventTimer = 3000;
2009-10-17 15:51:44 -07:00
2009-08-17 00:29:53 +02:00
if (Unit* pPlayer = GetPlayerForEscort())
2009-08-16 22:21:57 +02:00
{
switch(m_uiPostEventCount)
{
case 1:
DoScriptText(SAY_RIN_PROGRESS_1, m_creature, pPlayer);
++m_uiPostEventCount;
break;
case 2:
DoScriptText(SAY_RIN_PROGRESS_2, m_creature, pPlayer);
m_uiPostEventCount = 0;
break;
}
}
else
2009-08-14 17:14:08 +02:00
{
2009-08-16 22:21:57 +02:00
m_creature->ForcedDespawn();
return;
2009-08-14 17:14:08 +02:00
}
}
else
2009-08-16 22:21:57 +02:00
m_uiPostEventTimer -= uiDiff;
2009-08-14 17:14:08 +02:00
}
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
return;
2009-08-14 17:14:08 +02:00
}
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
DoMeleeAttackIfReady();
2009-08-14 17:14:08 +02:00
}
};
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
bool QuestAccept_npc_rinji(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
{
if (pQuest->GetQuestId() == QUEST_RINJI_TRAPPED)
{
if (GameObject* pGo = pCreature->FindNearestGameObject(GO_RINJI_CAGE, INTERACTION_DISTANCE))
pGo->UseDoorOrButton();
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
if (npc_rinjiAI* pEscortAI = CAST_AI(npc_rinjiAI, pCreature->AI()))
pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
}
return true;
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
CreatureAI* GetAI_npc_rinji(Creature* pCreature)
{
2009-08-16 02:12:14 +02:00
return new npc_rinjiAI(pCreature);
2009-08-14 17:14:08 +02:00
}
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
void AddSC_hinterlands()
{
Script* newscript;
2009-10-17 15:51:44 -07:00
2009-08-16 22:21:57 +02:00
newscript = new Script;
newscript->Name = "npc_00x09hl";
newscript->GetAI = &GetAI_npc_00x09hl;
newscript->pQuestAccept = &QuestAccept_npc_00x09hl;
newscript->RegisterSelf();
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
newscript = new Script;
newscript->Name = "npc_rinji";
newscript->GetAI = &GetAI_npc_rinji;
newscript->pQuestAccept = &QuestAccept_npc_rinji;
newscript->RegisterSelf();
}