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

353 lines
10 KiB
C++
Raw Normal View History

/*
2012-12-31 23:15:50 +01:00
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
2009-08-14 17:14:08 +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.
2009-08-14 17:14:08 +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/>.
2009-08-14 17:14:08 +02:00
*/
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
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
2010-01-19 11:36:05 +01:00
#include "ScriptedEscortAI.h"
#include "Player.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
2013-07-06 01:00:05 +02:00
enum OOX
2009-08-16 22:21:57 +02:00
{
SAY_OOX_START = 0,
SAY_OOX_AGGRO = 1,
SAY_OOX_AMBUSH = 2,
SAY_OOX_AMBUSH_REPLY = 3,
SAY_OOX_END = 4,
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
};
class npc_00x09hl : public CreatureScript
2009-08-16 22:21:57 +02:00
{
2010-08-08 22:54:58 +06:00
public:
npc_00x09hl() : CreatureScript("npc_00x09hl") { }
2009-10-17 15:51:44 -07:00
bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest) OVERRIDE
2009-08-16 22:21:57 +02:00
{
2011-10-07 19:45:43 -05:00
if (quest->GetQuestId() == QUEST_RESQUE_OOX_09)
2009-08-16 22:21:57 +02:00
{
creature->SetStandState(UNIT_STAND_STATE_STAND);
2010-08-08 22:54:58 +06:00
if (player->GetTeam() == ALLIANCE)
creature->setFaction(FACTION_ESCORTEE_A);
else if (player->GetTeam() == HORDE)
creature->setFaction(FACTION_ESCORTEE_H);
2010-08-08 22:54:58 +06:00
2013-12-23 14:23:49 +01:00
creature->AI()->Talk(SAY_OOX_START, player);
2010-08-08 22:54:58 +06:00
if (npc_00x09hlAI* pEscortAI = CAST_AI(npc_00x09hl::npc_00x09hlAI, creature->AI()))
2011-10-07 19:45:43 -05:00
pEscortAI->Start(false, false, player->GetGUID(), quest);
2009-08-16 22:21:57 +02:00
}
2010-08-08 22:54:58 +06:00
return true;
2009-08-16 22:21:57 +02:00
}
2009-10-17 15:51:44 -07:00
CreatureAI* GetAI(Creature* creature) const OVERRIDE
2009-08-16 22:21:57 +02:00
{
return new npc_00x09hlAI(creature);
2009-08-16 22:21:57 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-08 22:54:58 +06:00
struct npc_00x09hlAI : public npc_escortAI
2009-08-16 22:21:57 +02:00
{
npc_00x09hlAI(Creature* creature) : npc_escortAI(creature) { }
2009-10-17 15:51:44 -07:00
void Reset() OVERRIDE { }
2009-10-17 15:51:44 -07:00
void WaypointReached(uint32 waypointId) OVERRIDE
2010-08-08 22:54:58 +06:00
{
2012-03-29 15:44:24 +08:00
switch (waypointId)
2010-08-08 22:54:58 +06:00
{
case 26:
Talk(SAY_OOX_AMBUSH);
2010-08-08 22:54:58 +06:00
break;
case 43:
Talk(SAY_OOX_AMBUSH);
2010-08-08 22:54:58 +06:00
break;
case 64:
Talk(SAY_OOX_END);
if (Player* player = GetPlayerForEscort())
player->GroupEventHappens(QUEST_RESQUE_OOX_09, me);
2010-08-08 22:54:58 +06:00
break;
}
}
2009-10-17 15:51:44 -07:00
void WaypointStart(uint32 uiPointId) OVERRIDE
2010-08-08 22:54:58 +06:00
{
2011-09-29 12:43:05 +02:00
switch (uiPointId)
2010-08-08 22:54:58 +06:00
{
case 27:
for (uint8 i = 0; i < 3; ++i)
{
const Position src = {147.927444f, -3851.513428f, 130.893f, 0};
Position dst;
me->GetRandomPoint(src, 7.0f, dst);
DoSummon(NPC_MARAUDING_OWL, dst, 25000, TEMPSUMMON_CORPSE_TIMED_DESPAWN);
}
break;
case 44:
for (uint8 i = 0; i < 3; ++i)
{
const Position src = {-141.151581f, -4291.213867f, 120.130f, 0};
Position dst;
me->GetRandomPoint(src, 7.0f, dst);
me->SummonCreature(NPC_VILE_AMBUSHER, dst, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 25000);
}
break;
}
}
2009-10-17 15:51:44 -07:00
void EnterCombat(Unit* who) OVERRIDE
2010-08-08 22:54:58 +06:00
{
if (who->GetEntry() == NPC_MARAUDING_OWL || who->GetEntry() == NPC_VILE_AMBUSHER)
2010-08-08 22:54:58 +06:00
return;
2009-10-17 15:51:44 -07:00
Talk(SAY_OOX_AGGRO);
2010-08-08 22:54:58 +06:00
}
void JustSummoned(Creature* summoned) OVERRIDE
2010-08-08 22:54:58 +06:00
{
summoned->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
2010-08-08 22:54:58 +06:00
}
};
};
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
2013-07-06 01:00:05 +02:00
enum Rinji
2009-08-14 17:14:08 +02:00
{
SAY_RIN_BY_OUTRUNNER = 0,
SAY_RIN_FREE = 0, //from here
SAY_RIN_HELP = 1,
SAY_RIN_COMPLETE = 2,
SAY_RIN_PROGRESS_1 = 3,
SAY_RIN_PROGRESS_2 = 4,
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[] =
{
2010-08-22 23:46:40 +06:00
{191.296204f, -2839.329346f, 107.388f},
{70.972466f, -2848.674805f, 109.459f}
2009-08-14 17:14:08 +02:00
};
2009-10-17 15:51:44 -07:00
2009-08-14 17:14:08 +02:00
Location m_afAmbushMoveTo[] =
{
2010-08-22 23:46:40 +06:00
{166.630386f, -2824.780273f, 108.153f},
{70.886589f, -2874.335449f, 116.675f}
2009-08-14 17:14:08 +02:00
};
class npc_rinji : public CreatureScript
2009-08-14 17:14:08 +02:00
{
2010-08-08 22:54:58 +06:00
public:
npc_rinji() : CreatureScript("npc_rinji") { }
bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest) OVERRIDE
2009-08-14 17:14:08 +02:00
{
2011-10-07 19:45:43 -05:00
if (quest->GetQuestId() == QUEST_RINJI_TRAPPED)
2010-08-08 22:54:58 +06:00
{
2011-10-07 19:45:43 -05:00
if (GameObject* go = creature->FindNearestGameObject(GO_RINJI_CAGE, INTERACTION_DISTANCE))
go->UseDoorOrButton();
2009-10-17 15:51:44 -07:00
if (npc_rinjiAI* pEscortAI = CAST_AI(npc_rinji::npc_rinjiAI, creature->AI()))
2011-10-07 19:45:43 -05:00
pEscortAI->Start(false, false, player->GetGUID(), quest);
2010-08-08 22:54:58 +06:00
}
return true;
}
2009-10-17 15:51:44 -07:00
CreatureAI* GetAI(Creature* creature) const OVERRIDE
2009-08-14 17:14:08 +02:00
{
return new npc_rinjiAI(creature);
2009-08-14 17:14:08 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-08 22:54:58 +06:00
struct npc_rinjiAI : public npc_escortAI
2009-08-14 17:14:08 +02:00
{
npc_rinjiAI(Creature* creature) : npc_escortAI(creature)
2010-08-08 22:54:58 +06:00
{
m_bIsByOutrunner = false;
m_iSpawnId = 0;
}
2009-10-17 15:51:44 -07:00
2010-08-08 22:54:58 +06:00
bool m_bIsByOutrunner;
uint32 m_uiPostEventCount;
uint32 m_uiPostEventTimer;
int m_iSpawnId;
2009-10-17 15:51:44 -07:00
void Reset() OVERRIDE
2009-08-14 17:14:08 +02:00
{
2010-08-08 22:54:58 +06:00
m_uiPostEventCount = 0;
m_uiPostEventTimer = 3000;
}
2009-10-17 15:51:44 -07:00
void JustRespawned() OVERRIDE
2010-08-08 22:54:58 +06:00
{
m_bIsByOutrunner = false;
m_iSpawnId = 0;
2009-10-17 15:51:44 -07:00
2010-08-08 22:54:58 +06:00
npc_escortAI::JustRespawned();
2009-08-14 17:14:08 +02:00
}
2009-10-17 15:51:44 -07:00
void EnterCombat(Unit* who) OVERRIDE
2010-08-08 22:54:58 +06:00
{
if (HasEscortState(STATE_ESCORT_ESCORTING))
{
if (who->GetEntry() == NPC_OUTRUNNER && !m_bIsByOutrunner)
2010-08-08 22:54:58 +06:00
{
if (Creature* talker = who->ToCreature())
talker->AI()->Talk(SAY_RIN_BY_OUTRUNNER);
2010-08-08 22:54:58 +06:00
m_bIsByOutrunner = true;
}
2009-10-17 15:51:44 -07:00
2010-08-08 22:54:58 +06:00
if (rand()%4)
return;
2009-10-17 15:51:44 -07:00
2010-08-08 22:54:58 +06:00
//only if attacked and escorter is not in combat?
Talk(SAY_RIN_HELP);
2010-08-08 22:54:58 +06:00
}
}
void DoSpawnAmbush(bool bFirst)
2009-08-14 17:14:08 +02:00
{
2010-08-08 22:54:58 +06:00
if (!bFirst)
m_iSpawnId = 1;
me->SummonCreature(NPC_RANGER,
2009-08-14 17:14:08 +02:00
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);
2010-08-08 22:54:58 +06:00
for (int i = 0; i < 2; ++i)
{
me->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-08-14 17:14:08 +02:00
}
2009-10-17 15:51:44 -07:00
void JustSummoned(Creature* summoned) OVERRIDE
2010-08-08 22:54:58 +06:00
{
summoned->SetWalk(false);
summoned->GetMotionMaster()->MovePoint(0, m_afAmbushMoveTo[m_iSpawnId].m_fX, m_afAmbushMoveTo[m_iSpawnId].m_fY, m_afAmbushMoveTo[m_iSpawnId].m_fZ);
2010-08-08 22:54:58 +06:00
}
2009-10-17 15:51:44 -07:00
void WaypointReached(uint32 waypointId) OVERRIDE
2010-08-08 22:54:58 +06:00
{
Player* player = GetPlayerForEscort();
if (!player)
2010-08-08 22:54:58 +06:00
return;
2009-10-17 15:51:44 -07:00
2012-03-29 15:44:24 +08:00
switch (waypointId)
2010-08-08 22:54:58 +06:00
{
case 1:
2013-12-23 14:23:49 +01:00
Talk(SAY_RIN_FREE, player);
2010-08-08 22:54:58 +06:00
break;
case 7:
DoSpawnAmbush(true);
break;
case 13:
DoSpawnAmbush(false);
break;
case 17:
2013-12-23 14:23:49 +01:00
Talk(SAY_RIN_COMPLETE, player);
player->GroupEventHappens(QUEST_RINJI_TRAPPED, me);
2010-08-08 22:54:58 +06:00
SetRun();
m_uiPostEventCount = 1;
break;
}
2009-08-14 17:14:08 +02:00
}
2009-10-17 15:51:44 -07:00
void UpdateEscortAI(const uint32 uiDiff) OVERRIDE
2009-08-14 17:14:08 +02:00
{
2010-08-08 22:54:58 +06:00
//Check if we have a current target
if (!UpdateVictim())
2009-08-14 17:14:08 +02:00
{
2010-08-08 22:54:58 +06:00
if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPostEventCount)
2009-08-14 17:14:08 +02:00
{
2010-08-08 22:54:58 +06:00
if (m_uiPostEventTimer <= uiDiff)
2009-08-16 22:21:57 +02:00
{
2010-08-08 22:54:58 +06:00
m_uiPostEventTimer = 3000;
if (Player* player = GetPlayerForEscort())
2010-08-08 22:54:58 +06:00
{
2011-09-29 12:43:05 +02:00
switch (m_uiPostEventCount)
2010-08-08 22:54:58 +06:00
{
case 1:
2013-12-23 14:23:49 +01:00
Talk(SAY_RIN_PROGRESS_1, player);
2010-08-08 22:54:58 +06:00
++m_uiPostEventCount;
break;
case 2:
2013-12-23 14:23:49 +01:00
Talk(SAY_RIN_PROGRESS_2, player);
2010-08-08 22:54:58 +06:00
m_uiPostEventCount = 0;
break;
}
}
else
2009-08-16 22:21:57 +02:00
{
me->DespawnOrUnsummon();
2010-08-08 22:54:58 +06:00
return;
2009-08-16 22:21:57 +02:00
}
}
else
2010-08-08 22:54:58 +06:00
m_uiPostEventTimer -= uiDiff;
2009-08-14 17:14:08 +02:00
}
2010-08-08 22:54:58 +06:00
return;
2009-08-14 17:14:08 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-08 22:54:58 +06:00
DoMeleeAttackIfReady();
2009-08-14 17:14:08 +02:00
}
2010-08-08 22:54:58 +06:00
};
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()
{
2010-08-08 22:54:58 +06:00
new npc_00x09hl();
new npc_rinji();
2009-08-14 17:14:08 +02:00
}