TrinityCore
hyjal.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: Hyjal
20SD%Complete: 80
21SDComment: gossip text id's unknown
22SDCategory: Caverns of Time, Mount Hyjal
23EndScriptData */
24
25/* ContentData
26npc_jaina_proudmoore
27npc_thrall
28npc_tyrande_whisperwind
29EndContentData */
30
31#include "ScriptMgr.h"
32#include "hyjalAI.h"
33#include "InstanceScript.h"
34#include "Log.h"
35#include "Player.h"
36#include "ScriptedGossip.h"
37
39{
40 GOSSIP_ITEM_BEGIN_ALLY_MID = 7552, // My companions and I are with you, Lady Proudmoore.
42 GOSSIP_ITEM_ANETHERON_MID = 7552, // We are ready for whatever Archimonde might send our way, Lady Proudmoore.
44 GOSSIP_ITEM_ALLY_RETREAT_MID = 7552, // Until we meet again, Lady Proudmoore.
46 GOSSIP_ITEM_BEGIN_HORDE_MID = 7581, // I am with you, Thrall.
48 GOSSIP_ITEM_AZGALOR_MID = 7581, // We have nothing to fear.
50 GOSSIP_ITEM_HORDE_RETREAT_MID = 7581, //Until we meet again, Thrall.
52 GOSSIP_ITEM_TYRANDE_MID = 7706, // I would be grateful for any aid you can provide, Priestess.
54};
55
57{
59};
60
61#define ITEM_TEAR_OF_GODDESS 24494
62
63#define GOSSIP_ITEM_GM1 "[GM] Toggle Debug Timers"
64
66{
67 public:
68 npc_jaina_proudmoore() : CreatureScript("npc_jaina_proudmoore") { }
69
71 {
73 {
74 Spells[0].SpellId = SPELL_BLIZZARD;
75 Spells[0].Cooldown = urand(15000, 35000);
76 Spells[0].TargetType = TARGETTYPE_RANDOM;
77
78 Spells[1].SpellId = SPELL_PYROBLAST;
79 Spells[1].Cooldown = urand(5500, 9500);
80 Spells[1].TargetType = TARGETTYPE_RANDOM;
81
83 Spells[2].Cooldown = urand(15000, 45000);
84 Spells[2].TargetType = TARGETTYPE_SELF;
85 }
86
87 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
88 {
89 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
90 ClearGossipMenuFor(player);
91 switch (action)
92 {
94 StartEvent(player);
95 break;
97 FirstBossDead = true;
98 WaveCount = 9;
99 StartEvent(player);
100 break;
101 case GOSSIP_ACTION_INFO_DEF + 3:
103 Retreat();
104 break;
106 Debug = !Debug;
107 TC_LOG_DEBUG("scripts", "HyjalAI - Debug mode has been toggled");
108 break;
109 }
110 return true;
111 }
112
113 bool OnGossipHello(Player* player) override
114 {
115 if (EventBegun)
116 return false;
117
119 uint32 AnetheronEncounter = instance->GetBossState(DATA_ANETHERON);
120 if (RageEncounter != DONE && RageEncounter != IN_PROGRESS)
121 {
124 SendGossipMenuFor(player, 9168, me->GetGUID());
125 }
126 else if (RageEncounter == DONE && AnetheronEncounter != DONE && AnetheronEncounter != IN_PROGRESS)
127 {
130 SendGossipMenuFor(player, 9380, me->GetGUID());
131 }
132 else if (RageEncounter == DONE && AnetheronEncounter == DONE)
133 {
136 SendGossipMenuFor(player, 9387, me->GetGUID());
137 }
138 if (player->IsGameMaster())
140
141 return true;
142 }
143 };
144
145 CreatureAI* GetAI(Creature* creature) const override
146 {
147 return GetHyjalAI<npc_jaina_proudmooreAI>(creature);
148 }
149};
150
152{
153 public:
154 npc_thrall() : CreatureScript("npc_thrall") { }
155
156 struct npc_thrallAI : public hyjalAI
157 {
158 npc_thrallAI(Creature* creature) : hyjalAI(creature)
159 {
160 Spells[0].SpellId = SPELL_CHAIN_LIGHTNING;
161 Spells[0].Cooldown = urand(3000, 8000);
162 Spells[0].TargetType = TARGETTYPE_VICTIM;
163
164 Spells[1].SpellId = SPELL_SUMMON_DIRE_WOLF;
165 Spells[1].Cooldown = urand(6000, 41000);
166 Spells[1].TargetType = TARGETTYPE_RANDOM;
167 }
168
169 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
170 {
171 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
172 ClearGossipMenuFor(player);
173 DeSpawnVeins(); //despawn the alliance veins
174 switch (action)
175 {
176 case GOSSIP_ACTION_INFO_DEF + 1:
177 StartEvent(player);
178 break;
179 case GOSSIP_ACTION_INFO_DEF + 2:
180 FirstBossDead = true;
181 WaveCount = 9;
182 StartEvent(player);
183 break;
184 case GOSSIP_ACTION_INFO_DEF + 3:
185 Retreat();
186 break;
188 Debug = !Debug;
189 TC_LOG_DEBUG("scripts", "HyjalAI - Debug mode has been toggled");
190 break;
191 }
192 return true;
193 }
194
195 bool OnGossipHello(Player* player) override
196 {
197 if (EventBegun)
198 return false;
199
200 uint32 AnetheronEvent = instance->GetBossState(DATA_ANETHERON);
201 // Only let them start the Horde phases if Anetheron is dead.
202 if (AnetheronEvent == DONE && GetInstanceData(DATA_ALLIANCE_RETREAT))
203 {
204 uint32 KazrogalEvent = instance->GetBossState(DATA_KAZROGAL);
205 uint32 AzgalorEvent = instance->GetBossState(DATA_AZGALOR);
206 if (KazrogalEvent != DONE && AzgalorEvent != IN_PROGRESS)
207 {
210 SendGossipMenuFor(player, 9225, me->GetGUID());
211 }
212 else if (KazrogalEvent == DONE && AzgalorEvent != DONE && AzgalorEvent != IN_PROGRESS)
213 {
216 SendGossipMenuFor(player, 9396, me->GetGUID());
217 }
218 else if (AzgalorEvent == DONE)
219 {
222 SendGossipMenuFor(player, 9398, me->GetGUID());
223 }
224 }
225
226 if (player->IsGameMaster())
228
229 return true;
230 }
231 };
232
233 CreatureAI* GetAI(Creature* creature) const override
234 {
235 return GetHyjalAI<npc_thrallAI>(creature);
236 }
237};
238
240{
241 public:
242 npc_tyrande_whisperwind() : CreatureScript("npc_tyrande_whisperwind") { }
243
245 {
247 {
248 }
249
250 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
251 {
252 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
253 ClearGossipMenuFor(player);
254 if (action == GOSSIP_ACTION_INFO_DEF)
255 {
256 ItemPosCountVec dest;
258 if (msg == EQUIP_ERR_OK)
259 if (Item* item = player->StoreNewItem(dest, ITEM_TEAR_OF_GODDESS, true))
260 player->SendNewItem(item, 1, true, false, true);
261
262 SendGossipMenuFor(player, 907, me->GetGUID());
263 }
264 return true;
265 }
266
267 bool OnGossipHello(Player* player) override
268 {
270 uint32 AzgalorEvent = instance->GetBossState(DATA_AZGALOR);
271
272 // Only let them get item if Azgalor is dead.
273 if (AzgalorEvent == DONE && !player->HasItemCount(ITEM_TEAR_OF_GODDESS))
275 SendGossipMenuFor(player, 9410, me->GetGUID());
276 return true;
277 }
278 };
279
280 CreatureAI* GetAI(Creature* creature) const override
281 {
282 return GetHyjalAI<npc_tyrande_whisperwindAI>(creature);
283 }
284};
285
287{
289 new npc_thrall();
291}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ IN_PROGRESS
@ DONE
@ EQUIP_ERR_OK
Definition: ItemDefines.h:26
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
Spells
Definition: PlayerAI.cpp:32
@ SPELL_PYROBLAST
Definition: PlayerAI.cpp:303
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:750
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
void AddGossipItemFor(Player *player, GossipOptionNpc optionNpc, std::string text, uint32 sender, uint32 action)
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
void ClearGossipMenuFor(Player *player)
void InitGossipMenuFor(Player *player, uint32 menuId)
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INFO_DEF
@ NULL_BAG
Definition: Unit.h:62
@ NULL_SLOT
Definition: Unit.h:63
#define SPELL_CHAIN_LIGHTNING
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
Creature *const me
Definition: CreatureAI.h:61
CreatureAI * AI() const
Definition: Creature.h:214
EncounterState GetBossState(uint32 id) const
Definition: Item.h:170
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 itemId, bool update, ItemRandomBonusListId randomBonusListId=0, GuidSet const &allowedLooters=GuidSet(), ItemContext context=ItemContext::NONE, std::vector< int32 > const *bonusListIDs=nullptr, bool addToCollection=true)
Definition: Player.cpp:11537
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition: Player.cpp:9888
bool IsGameMaster() const
Definition: Player.h:1178
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition: Player.cpp:10032
std::unique_ptr< PlayerMenu > PlayerTalkClass
Definition: Player.h:2380
void SendNewItem(Item *item, uint32 quantity, bool received, bool created, bool broadcast=false, uint32 dungeonEncounterId=0)
Definition: Player.cpp:13990
CreatureAI * GetAI(Creature *creature) const override
Definition: hyjal.cpp:145
npc_thrall()
Definition: hyjal.cpp:154
CreatureAI * GetAI(Creature *creature) const override
Definition: hyjal.cpp:233
CreatureAI * GetAI(Creature *creature) const override
Definition: hyjal.cpp:280
@ TARGETTYPE_RANDOM
Definition: hyjalAI.h:106
@ TARGETTYPE_SELF
Definition: hyjalAI.h:105
@ TARGETTYPE_VICTIM
Definition: hyjalAI.h:107
@ SPELL_SUMMON_ELEMENTALS
Definition: hyjalAI.h:35
@ SPELL_SUMMON_DIRE_WOLF
Definition: hyjalAI.h:39
void AddSC_hyjal()
Definition: hyjal.cpp:286
#define GOSSIP_ITEM_GM1
Definition: hyjal.cpp:63
#define ITEM_TEAR_OF_GODDESS
Definition: hyjal.cpp:61
NPCTEXTS
Definition: hyjal.cpp:57
@ JAINA_RETREAT_ALLIANCE_BASE
Definition: hyjal.cpp:58
GOSSIPS
Definition: hyjal.cpp:39
@ GOSSIP_ITEM_ALLY_RETREAT_MID
Definition: hyjal.cpp:44
@ GOSSIP_ITEM_ALLY_RETREAT_OID
Definition: hyjal.cpp:45
@ GOSSIP_ITEM_AZGALOR_MID
Definition: hyjal.cpp:48
@ GOSSIP_ITEM_HORDE_RETREAT_MID
Definition: hyjal.cpp:50
@ GOSSIP_ITEM_HORDE_RETREAT_OID
Definition: hyjal.cpp:51
@ GOSSIP_ITEM_ANETHERON_MID
Definition: hyjal.cpp:42
@ GOSSIP_ITEM_TYRANDE_OID
Definition: hyjal.cpp:53
@ GOSSIP_ITEM_BEGIN_ALLY_MID
Definition: hyjal.cpp:40
@ GOSSIP_ITEM_BEGIN_HORDE_OID
Definition: hyjal.cpp:47
@ GOSSIP_ITEM_BEGIN_ALLY_OID
Definition: hyjal.cpp:41
@ GOSSIP_ITEM_TYRANDE_MID
Definition: hyjal.cpp:52
@ GOSSIP_ITEM_ANETHERON_OID
Definition: hyjal.cpp:43
@ GOSSIP_ITEM_AZGALOR_OID
Definition: hyjal.cpp:49
@ GOSSIP_ITEM_BEGIN_HORDE_MID
Definition: hyjal.cpp:46
@ DATA_RAGEWINTERCHILL
Definition: hyjal.h:30
@ DATA_KAZROGAL
Definition: hyjal.h:32
@ DATA_AZGALOR
Definition: hyjal.h:33
@ DATA_ANETHERON
Definition: hyjal.h:31
@ DATA_ALLIANCE_RETREAT
Definition: hyjal.h:41
bool Debug
Definition: hyjalAI.h:182
bool FirstBossDead
Definition: hyjalAI.h:178
void StartEvent(Player *player)
Definition: hyjalAI.cpp:592
void DeSpawnVeins()
Definition: hyjalAI.cpp:679
bool EventBegun
Definition: hyjalAI.h:177
void Retreat()
Definition: hyjalAI.cpp:620
uint32 GetInstanceData(uint32 Event)
Definition: hyjalAI.cpp:615
uint32 WaveCount
Definition: hyjalAI.h:171
InstanceScript * instance
Definition: hyjalAI.h:164
bool OnGossipHello(Player *player) override
Definition: hyjal.cpp:113
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
Definition: hyjal.cpp:87
npc_jaina_proudmooreAI(Creature *creature)
Definition: hyjal.cpp:72
npc_thrallAI(Creature *creature)
Definition: hyjal.cpp:158
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
Definition: hyjal.cpp:169
bool OnGossipHello(Player *player) override
Definition: hyjal.cpp:195
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
Definition: hyjal.cpp:250
bool OnGossipHello(Player *player) override
Definition: hyjal.cpp:267