TrinityCore
Loading...
Searching...
No Matches
zone_hinterlands.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/* ScriptData
19SDName: Hinterlands
20SD%Complete: 100
21SDComment: Quest support: 2742
22SDCategory: The Hinterlands
23EndScriptData */
24
25/* ContentData
26npc_rinji
27EndContentData */
28
29#include "ScriptMgr.h"
30#include "GameObject.h"
31#include "MotionMaster.h"
32#include "Player.h"
33#include "ScriptedEscortAI.h"
34
35/*######
36## npc_rinji
37######*/
38
52
54{
55 { 191.296204f, -2839.329346f, 107.388f, 0.0f },
56 { 70.972466f, -2848.674805f, 109.459f, 0.0f }
57};
58
60{
61 { 166.630386f, -2824.780273f, 108.153f, 0.0f },
62 { 70.886589f, -2874.335449f, 116.675f, 0.0f }
63};
64
65static constexpr uint32 PATH_ESCORT_RINJI = 62242;
66
68{
69public:
70 npc_rinji() : CreatureScript("npc_rinji") { }
71
72 struct npc_rinjiAI : public EscortAI
73 {
74 npc_rinjiAI(Creature* creature) : EscortAI(creature)
75 {
76 Initialize();
77 _IsByOutrunner = false;
78 spawnId = 0;
79 }
80
82 {
84 postEventTimer = 3000;
85 }
86
87 void Reset() override
88 {
89 Initialize();
90 }
91
92 void JustAppeared() override
93 {
94 _IsByOutrunner = false;
95 spawnId = 0;
96
98 }
99
100 void JustEngagedWith(Unit* who) override
101 {
103 {
104 if (who->GetEntry() == NPC_OUTRUNNER && !_IsByOutrunner)
105 {
106 if (Creature* talker = who->ToCreature())
107 talker->AI()->Talk(SAY_RIN_BY_OUTRUNNER);
108 _IsByOutrunner = true;
109 }
110
111 if (rand32() % 4)
112 return;
113
114 //only if attacked and escorter is not in combat?
116 }
117 }
118
119 void DoSpawnAmbush(bool _first)
120 {
121 if (!_first)
122 spawnId = 1;
123
125
126 for (int i = 0; i < 2; ++i)
127 {
129 }
130 }
131
132 void JustSummoned(Creature* summoned) override
133 {
134 summoned->SetWalk(false);
136 }
137
138 void OnQuestAccept(Player* player, Quest const* quest) override
139 {
140 if (quest->GetQuestId() == QUEST_RINJI_TRAPPED)
141 {
143 go->UseDoorOrButton();
144
146 Start(false, player->GetGUID(), quest);
147 }
148 }
149
150 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
151 {
152 Player* player = GetPlayerForEscort();
153 if (!player)
154 return;
155
156 switch (waypointId)
157 {
158 case 1:
159 Talk(SAY_RIN_FREE, player);
160 break;
161 case 7:
162 DoSpawnAmbush(true);
163 break;
164 case 13:
165 DoSpawnAmbush(false);
166 break;
167 case 17:
168 Talk(SAY_RIN_COMPLETE, player);
170 postEventCount = 1;
171 break;
172 }
173 }
174
175 void UpdateEscortAI(uint32 diff) override
176 {
177 //Check if we have a current target
178 if (!UpdateVictim())
179 {
181 {
182 if (postEventTimer <= diff)
183 {
184 postEventTimer = 3000;
185
186 if (Player* player = GetPlayerForEscort())
187 {
188 switch (postEventCount)
189 {
190 case 1:
191 Talk(SAY_RIN_PROGRESS_1, player);
193 break;
194 case 2:
195 Talk(SAY_RIN_PROGRESS_2, player);
196 postEventCount = 0;
197 break;
198 }
199 }
200 else
201 {
203 return;
204 }
205 }
206 else
207 postEventTimer -= diff;
208 }
209 return;
210 }
212 }
213
214 private:
219 };
220
221 CreatureAI* GetAI(Creature* creature) const override
222 {
223 return new npc_rinjiAI(creature);
224 }
225};
226
228{
229 new npc_rinji();
230}
uint32_t uint32
Definition Define.h:133
@ TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN
#define INTERACTION_DISTANCE
uint32 rand32()
Definition Random.cpp:70
@ STATE_ESCORT_ESCORTING
virtual void JustAppeared()
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
static Creature * ToCreature(Object *o)
Definition Object.h:186
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition Player.cpp:16032
uint32 GetQuestId() const
Definition QuestDef.h:229
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
Definition Unit.h:769
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool SetWalk(bool enable)
Definition Unit.cpp:13268
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition Object.cpp:2121
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1992
CreatureAI * GetAI(Creature *creature) const override
void Start(bool isActiveAttacker=true, ObjectGuid playerGUID=ObjectGuid::Empty, Quest const *quest=nullptr, bool instantRespawn=false, bool canLoopPath=false)
bool HasEscortState(uint32 escortState)
void LoadPath(uint32 pathId)
Player * GetPlayerForEscort()
void JustSummoned(Creature *summoned) override
void UpdateEscortAI(uint32 diff) override
void OnQuestAccept(Player *player, Quest const *quest) override
npc_rinjiAI(Creature *creature)
void JustEngagedWith(Unit *who) override
void DoSpawnAmbush(bool _first)
void WaypointReached(uint32 waypointId, uint32) override
void AddSC_hinterlands()
Position const AmbushMoveTo[]
static constexpr uint32 PATH_ESCORT_RINJI
@ SAY_RIN_FREE
@ SAY_RIN_COMPLETE
@ SAY_RIN_BY_OUTRUNNER
@ GO_RINJI_CAGE
@ SAY_RIN_PROGRESS_1
@ SAY_RIN_PROGRESS_2
@ NPC_OUTRUNNER
@ QUEST_RINJI_TRAPPED
@ NPC_RANGER
@ SAY_RIN_HELP
Position const AmbushSpawn[]