Small cleanup in boss Ouro script.
[scriptdev2-git.git] / scripts / eastern_kingdoms / hinterlands.cpp
blob477d3f4b99a47470aa607e2afbf00bec8cd4d2c7
1 /* Copyright (C) 2006 - 2010 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 /* ScriptData
18 SDName: Hinterlands
19 SD%Complete: 100
20 SDComment: Quest support: 863, 2742
21 SDCategory: The Hinterlands
22 EndScriptData */
24 /* ContentData
25 npc_00x09hl
26 npc_rinji
27 EndContentData */
29 #include "precompiled.h"
30 #include "escort_ai.h"
32 /*######
33 ## npc_00x09hl
34 ######*/
36 enum
38 SAY_OOX_START = -1000287,
39 SAY_OOX_AGGRO1 = -1000288,
40 SAY_OOX_AGGRO2 = -1000289,
41 SAY_OOX_AMBUSH = -1000290,
42 SAY_OOX_END = -1000292,
44 QUEST_RESQUE_OOX_09 = 836,
46 NPC_MARAUDING_OWL = 7808,
47 NPC_VILE_AMBUSHER = 7809
50 struct MANGOS_DLL_DECL npc_00x09hlAI : public npc_escortAI
52 npc_00x09hlAI(Creature* pCreature) : npc_escortAI(pCreature) { Reset(); }
54 void Reset() { }
56 void WaypointReached(uint32 uiPointId)
58 switch(uiPointId)
60 case 26:
61 DoScriptText(SAY_OOX_AMBUSH, m_creature);
62 break;
63 case 43:
64 DoScriptText(SAY_OOX_AMBUSH, m_creature);
65 break;
66 case 64:
67 DoScriptText(SAY_OOX_END, m_creature);
68 if (Player* pPlayer = GetPlayerForEscort())
69 pPlayer->GroupEventHappens(QUEST_RESQUE_OOX_09, m_creature);
70 break;
74 void WaypointStart(uint32 uiPointId)
76 switch(uiPointId)
78 case 27:
79 for(uint8 i = 0; i < 3; ++i)
81 float fX, fY, fZ;
82 m_creature->GetRandomPoint(147.927444f, -3851.513428f, 130.893f, 7.0f, fX, fY, fZ);
84 m_creature->SummonCreature(NPC_MARAUDING_OWL, fX, fY, fZ, 0.0f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 25000);
86 break;
87 case 44:
88 for(uint8 i = 0; i < 3; ++i)
90 float fX, fY, fZ;
91 m_creature->GetRandomPoint(-141.151581f, -4291.213867f, 120.130f, 7.0f, fX, fY, fZ);
93 m_creature->SummonCreature(NPC_VILE_AMBUSHER, fX, fY, fZ, 0.0f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 25000);
95 break;
99 void Aggro(Unit* pWho)
101 if (pWho->GetEntry() == NPC_MARAUDING_OWL || pWho->GetEntry() == NPC_VILE_AMBUSHER)
102 return;
104 if (urand(0, 1))
105 DoScriptText(SAY_OOX_AGGRO1, m_creature);
106 else
107 DoScriptText(SAY_OOX_AGGRO2, m_creature);
110 void JustSummoned(Creature* pSummoned)
112 pSummoned->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());
116 bool QuestAccept_npc_00x09hl(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
118 if (pQuest->GetQuestId() == QUEST_RESQUE_OOX_09)
120 pCreature->SetStandState(UNIT_STAND_STATE_STAND);
122 if (pPlayer->GetTeam() == ALLIANCE)
123 pCreature->setFaction(FACTION_ESCORT_A_PASSIVE);
124 else if (pPlayer->GetTeam() == HORDE)
125 pCreature->setFaction(FACTION_ESCORT_H_PASSIVE);
127 DoScriptText(SAY_OOX_START, pCreature, pPlayer);
129 if (npc_00x09hlAI* pEscortAI = dynamic_cast<npc_00x09hlAI*>(pCreature->AI()))
130 pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
132 return true;
135 CreatureAI* GetAI_npc_00x09hl(Creature* pCreature)
137 return new npc_00x09hlAI(pCreature);
140 /*######
141 ## npc_rinji
142 ######*/
144 enum
146 SAY_RIN_FREE = -1000403,
147 SAY_RIN_BY_OUTRUNNER = -1000404,
148 SAY_RIN_HELP_1 = -1000405,
149 SAY_RIN_HELP_2 = -1000406,
150 SAY_RIN_COMPLETE = -1000407,
151 SAY_RIN_PROGRESS_1 = -1000408,
152 SAY_RIN_PROGRESS_2 = -1000409,
154 QUEST_RINJI_TRAPPED = 2742,
155 NPC_RANGER = 2694,
156 NPC_OUTRUNNER = 2691,
157 GO_RINJI_CAGE = 142036
160 struct Location
162 float m_fX, m_fY, m_fZ;
165 Location m_afAmbushSpawn[] =
167 {191.29620f, -2839.329346f, 107.388f},
168 {70.972466f, -2848.674805f, 109.459f}
171 Location m_afAmbushMoveTo[] =
173 {166.63038f, -2824.780273f, 108.153f},
174 {70.886589f, -2874.335449f, 116.675f}
177 struct MANGOS_DLL_DECL npc_rinjiAI : public npc_escortAI
179 npc_rinjiAI(Creature* pCreature) : npc_escortAI(pCreature)
181 m_bIsByOutrunner = false;
182 m_iSpawnId = 0;
183 Reset();
186 bool m_bIsByOutrunner;
187 uint32 m_uiPostEventCount;
188 uint32 m_uiPostEventTimer;
189 int m_iSpawnId;
191 void Reset()
193 m_uiPostEventCount = 0;
194 m_uiPostEventTimer = 3000;
197 void JustRespawned()
199 m_bIsByOutrunner = false;
200 m_iSpawnId = 0;
202 npc_escortAI::JustRespawned();
205 void Aggro(Unit* pWho)
207 if (HasEscortState(STATE_ESCORT_ESCORTING))
209 if (pWho->GetEntry() == NPC_OUTRUNNER && !m_bIsByOutrunner)
211 DoScriptText(SAY_RIN_BY_OUTRUNNER, pWho);
212 m_bIsByOutrunner = true;
215 if (urand(0, 3))
216 return;
218 //only if attacked and escorter is not in combat?
219 DoScriptText(urand(0, 1) ? SAY_RIN_HELP_1 : SAY_RIN_HELP_2, m_creature);
223 void DoSpawnAmbush(bool bFirst)
225 if (!bFirst)
226 m_iSpawnId = 1;
228 m_creature->SummonCreature(NPC_RANGER,
229 m_afAmbushSpawn[m_iSpawnId].m_fX, m_afAmbushSpawn[m_iSpawnId].m_fY, m_afAmbushSpawn[m_iSpawnId].m_fZ, 0.0f,
230 TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
232 for(int i = 0; i < 2; ++i)
234 m_creature->SummonCreature(NPC_OUTRUNNER,
235 m_afAmbushSpawn[m_iSpawnId].m_fX, m_afAmbushSpawn[m_iSpawnId].m_fY, m_afAmbushSpawn[m_iSpawnId].m_fZ, 0.0f,
236 TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
240 void JustSummoned(Creature* pSummoned)
242 pSummoned->RemoveSplineFlag(SPLINEFLAG_WALKMODE);
243 pSummoned->GetMotionMaster()->MovePoint(0, m_afAmbushMoveTo[m_iSpawnId].m_fX, m_afAmbushMoveTo[m_iSpawnId].m_fY, m_afAmbushMoveTo[m_iSpawnId].m_fZ);
246 void WaypointReached(uint32 uiPointId)
248 Player* pPlayer = GetPlayerForEscort();
250 if (!pPlayer)
251 return;
253 switch(uiPointId)
255 case 1:
256 DoScriptText(SAY_RIN_FREE, m_creature, pPlayer);
257 break;
258 case 7:
259 DoSpawnAmbush(true);
260 break;
261 case 13:
262 DoSpawnAmbush(false);
263 break;
264 case 17:
265 DoScriptText(SAY_RIN_COMPLETE, m_creature, pPlayer);
266 pPlayer->GroupEventHappens(QUEST_RINJI_TRAPPED, m_creature);
267 SetRun();
268 m_uiPostEventCount = 1;
269 break;
273 void UpdateEscortAI(const uint32 uiDiff)
275 //Check if we have a current target
276 if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
278 if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPostEventCount)
280 if (m_uiPostEventTimer < uiDiff)
282 m_uiPostEventTimer = 3000;
284 if (Player* pPlayer = GetPlayerForEscort())
286 switch(m_uiPostEventCount)
288 case 1:
289 DoScriptText(SAY_RIN_PROGRESS_1, m_creature, pPlayer);
290 ++m_uiPostEventCount;
291 break;
292 case 2:
293 DoScriptText(SAY_RIN_PROGRESS_2, m_creature, pPlayer);
294 m_uiPostEventCount = 0;
295 break;
298 else
300 m_creature->ForcedDespawn();
301 return;
304 else
305 m_uiPostEventTimer -= uiDiff;
308 return;
311 DoMeleeAttackIfReady();
315 bool QuestAccept_npc_rinji(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
317 if (pQuest->GetQuestId() == QUEST_RINJI_TRAPPED)
319 if (GameObject* pGo = GetClosestGameObjectWithEntry(pCreature, GO_RINJI_CAGE, INTERACTION_DISTANCE))
320 pGo->UseDoorOrButton();
322 if (npc_rinjiAI* pEscortAI = dynamic_cast<npc_rinjiAI*>(pCreature->AI()))
323 pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
325 return true;
328 CreatureAI* GetAI_npc_rinji(Creature* pCreature)
330 return new npc_rinjiAI(pCreature);
333 void AddSC_hinterlands()
335 Script* newscript;
337 newscript = new Script;
338 newscript->Name = "npc_00x09hl";
339 newscript->GetAI = &GetAI_npc_00x09hl;
340 newscript->pQuestAccept = &QuestAccept_npc_00x09hl;
341 newscript->RegisterSelf();
343 newscript = new Script;
344 newscript->Name = "npc_rinji";
345 newscript->GetAI = &GetAI_npc_rinji;
346 newscript->pQuestAccept = &QuestAccept_npc_rinji;
347 newscript->RegisterSelf();