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
20 SDComment: Quest support: 863, 2742
21 SDCategory: The Hinterlands
29 #include "precompiled.h"
30 #include "escort_ai.h"
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(); }
56 void WaypointReached(uint32 uiPointId
)
61 DoScriptText(SAY_OOX_AMBUSH
, m_creature
);
64 DoScriptText(SAY_OOX_AMBUSH
, m_creature
);
67 DoScriptText(SAY_OOX_END
, m_creature
);
68 if (Player
* pPlayer
= GetPlayerForEscort())
69 pPlayer
->GroupEventHappens(QUEST_RESQUE_OOX_09
, m_creature
);
74 void WaypointStart(uint32 uiPointId
)
79 for(uint8 i
= 0; i
< 3; ++i
)
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);
88 for(uint8 i
= 0; i
< 3; ++i
)
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);
99 void Aggro(Unit
* pWho
)
101 if (pWho
->GetEntry() == NPC_MARAUDING_OWL
|| pWho
->GetEntry() == NPC_VILE_AMBUSHER
)
105 DoScriptText(SAY_OOX_AGGRO1
, m_creature
);
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
);
135 CreatureAI
* GetAI_npc_00x09hl(Creature
* pCreature
)
137 return new npc_00x09hlAI(pCreature
);
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,
156 NPC_OUTRUNNER
= 2691,
157 GO_RINJI_CAGE
= 142036
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;
186 bool m_bIsByOutrunner
;
187 uint32 m_uiPostEventCount
;
188 uint32 m_uiPostEventTimer
;
193 m_uiPostEventCount
= 0;
194 m_uiPostEventTimer
= 3000;
199 m_bIsByOutrunner
= false;
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;
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
)
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();
256 DoScriptText(SAY_RIN_FREE
, m_creature
, pPlayer
);
262 DoSpawnAmbush(false);
265 DoScriptText(SAY_RIN_COMPLETE
, m_creature
, pPlayer
);
266 pPlayer
->GroupEventHappens(QUEST_RINJI_TRAPPED
, m_creature
);
268 m_uiPostEventCount
= 1;
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
)
289 DoScriptText(SAY_RIN_PROGRESS_1
, m_creature
, pPlayer
);
290 ++m_uiPostEventCount
;
293 DoScriptText(SAY_RIN_PROGRESS_2
, m_creature
, pPlayer
);
294 m_uiPostEventCount
= 0;
300 m_creature
->ForcedDespawn();
305 m_uiPostEventTimer
-= uiDiff
;
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
);
328 CreatureAI
* GetAI_npc_rinji(Creature
* pCreature
)
330 return new npc_rinjiAI(pCreature
);
333 void AddSC_hinterlands()
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();