forked from TrinityCore/TrinityCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem_scripts.cpp
More file actions
426 lines (368 loc) · 14.1 KB
/
item_scripts.cpp
File metadata and controls
426 lines (368 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* 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.
*
* 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/>.
*/
/* ScriptData
SDName: Item_Scripts
SD%Complete: 100
SDComment: Items for a range of different items. See content below (in script)
SDCategory: Items
EndScriptData */
/* ContentData
item_nether_wraith_beacon(i31742) Summons creatures for quest Becoming a Spellfire Tailor (q10832)
item_flying_machine(i34060, i34061) Engineering crafted flying machines
item_gor_dreks_ointment(i30175) Protecting Our Own(q10488)
item_only_for_flight Items which should only useable while flying
EndContentData */
#include "ScriptPCH.h"
#include "Spell.h"
/*#####
# item_only_for_flight
#####*/
enum eOnlyForFlight
{
SPELL_ARCANE_CHARGES = 45072
};
class item_only_for_flight : public ItemScript
{
public:
item_only_for_flight() : ItemScript("item_only_for_flight") { }
bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/)
{
uint32 itemId = item->GetEntry();
bool disabled = false;
//for special scripts
switch (itemId)
{
case 24538:
if (player->GetAreaId() != 3628)
disabled = true;
break;
case 34489:
if (player->GetZoneId() != 4080)
disabled = true;
break;
case 34475:
if (const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(SPELL_ARCANE_CHARGES))
Spell::SendCastResult(player, spellInfo, 1, SPELL_FAILED_NOT_ON_GROUND);
break;
}
// allow use in flight only
if (player->isInFlight() && !disabled)
return false;
// error
player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, NULL);
return true;
}
};
/*#####
# item_nether_wraith_beacon
#####*/
class item_nether_wraith_beacon : public ItemScript
{
public:
item_nether_wraith_beacon() : ItemScript("item_nether_wraith_beacon") { }
bool OnUse(Player* player, Item* /*item*/, SpellCastTargets const& /*targets*/)
{
if (player->GetQuestStatus(10832) == QUEST_STATUS_INCOMPLETE)
{
if (Creature* nether = player->SummonCreature(22408, player->GetPositionX(), player->GetPositionY()+20, player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 180000))
nether->AI()->AttackStart(player);
if (Creature* nether = player->SummonCreature(22408, player->GetPositionX(), player->GetPositionY()-20, player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 180000))
nether->AI()->AttackStart(player);
}
return false;
}
};
/*#####
# item_gor_dreks_ointment
#####*/
class item_gor_dreks_ointment : public ItemScript
{
public:
item_gor_dreks_ointment() : ItemScript("item_gor_dreks_ointment") { }
bool OnUse(Player* player, Item* item, SpellCastTargets const& targets)
{
if (targets.GetUnitTarget() && targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT &&
targets.GetUnitTarget()->GetEntry() == 20748 && !targets.GetUnitTarget()->HasAura(32578))
return false;
player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, NULL);
return true;
}
};
/*#####
# item_incendiary_explosives
#####*/
class item_incendiary_explosives : public ItemScript
{
public:
item_incendiary_explosives() : ItemScript("item_incendiary_explosives") { }
bool OnUse(Player* player, Item* item, SpellCastTargets const & /*targets*/)
{
if (player->FindNearestCreature(26248, 15) || player->FindNearestCreature(26249, 15))
return false;
else
{
player->SendEquipError(EQUIP_ERR_OUT_OF_RANGE, item, NULL);
return true;
}
}
};
/*#####
# item_mysterious_egg
#####*/
class item_mysterious_egg : public ItemScript
{
public:
item_mysterious_egg() : ItemScript("item_mysterious_egg") { }
bool OnExpire(Player* player, ItemTemplate const* /*pItemProto*/)
{
ItemPosCountVec dest;
uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 39883, 1); // Cracked Egg
if (msg == EQUIP_ERR_OK)
player->StoreNewItem(dest, 39883, true, Item::GenerateItemRandomPropertyId(39883));
return true;
}
};
/*#####
# item_disgusting_jar
#####*/
class item_disgusting_jar : public ItemScript
{
public:
item_disgusting_jar() : ItemScript("item_disgusting_jar") {}
bool OnExpire(Player* player, ItemTemplate const* /*pItemProto*/)
{
ItemPosCountVec dest;
uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 44718, 1); // Ripe Disgusting Jar
if (msg == EQUIP_ERR_OK)
player->StoreNewItem(dest, 44718, true, Item::GenerateItemRandomPropertyId(44718));
return true;
}
};
/*#####
# item_pile_fake_furs
#####*/
enum ePileFakeFur
{
GO_CARIBOU_TRAP_1 = 187982,
GO_CARIBOU_TRAP_2 = 187995,
GO_CARIBOU_TRAP_3 = 187996,
GO_CARIBOU_TRAP_4 = 187997,
GO_CARIBOU_TRAP_5 = 187998,
GO_CARIBOU_TRAP_6 = 187999,
GO_CARIBOU_TRAP_7 = 188000,
GO_CARIBOU_TRAP_8 = 188001,
GO_CARIBOU_TRAP_9 = 188002,
GO_CARIBOU_TRAP_10 = 188003,
GO_CARIBOU_TRAP_11 = 188004,
GO_CARIBOU_TRAP_12 = 188005,
GO_CARIBOU_TRAP_13 = 188006,
GO_CARIBOU_TRAP_14 = 188007,
GO_CARIBOU_TRAP_15 = 188008,
GO_HIGH_QUALITY_FUR = 187983,
NPC_NESINGWARY_TRAPPER = 25835
};
#define CaribouTrapsNum 15
const uint32 CaribouTraps[CaribouTrapsNum] =
{
GO_CARIBOU_TRAP_1, GO_CARIBOU_TRAP_2, GO_CARIBOU_TRAP_3, GO_CARIBOU_TRAP_4, GO_CARIBOU_TRAP_5,
GO_CARIBOU_TRAP_6, GO_CARIBOU_TRAP_7, GO_CARIBOU_TRAP_8, GO_CARIBOU_TRAP_9, GO_CARIBOU_TRAP_10,
GO_CARIBOU_TRAP_11, GO_CARIBOU_TRAP_12, GO_CARIBOU_TRAP_13, GO_CARIBOU_TRAP_14, GO_CARIBOU_TRAP_15,
};
class item_pile_fake_furs : public ItemScript
{
public:
item_pile_fake_furs() : ItemScript("item_pile_fake_furs") { }
bool OnUse(Player* player, Item* /*item*/, SpellCastTargets const & /*targets*/)
{
GameObject* go = NULL;
for (uint8 i = 0; i < CaribouTrapsNum; ++i)
{
go = player->FindNearestGameObject(CaribouTraps[i], 5.0f);
if (go)
break;
}
if (!go)
return false;
if (go->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, true) || go->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, false) || go->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 2.0f))
return true;
float x, y, z;
go->GetClosePoint(x, y, z, go->GetObjectSize() / 3, 7.0f);
go->SummonGameObject(GO_HIGH_QUALITY_FUR, go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), 0, 0, 0, 0, 0, 1000);
if (TempSummon* summon = player->SummonCreature(NPC_NESINGWARY_TRAPPER, x, y, z, go->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000))
{
summon->SetVisible(false);
summon->SetReactState(REACT_PASSIVE);
summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
}
return false;
}
};
/*#####
# item_petrov_cluster_bombs
#####*/
enum ePetrovClusterBombs
{
SPELL_PETROV_BOMB = 42406,
AREA_ID_SHATTERED_STRAITS = 4064,
ZONE_ID_HOWLING = 495
};
class item_petrov_cluster_bombs : public ItemScript
{
public:
item_petrov_cluster_bombs() : ItemScript("item_petrov_cluster_bombs") { }
bool OnUse(Player* player, Item* item, const SpellCastTargets & /*targets*/)
{
if (player->GetZoneId() != ZONE_ID_HOWLING)
return false;
if (!player->GetTransport() || player->GetAreaId() != AREA_ID_SHATTERED_STRAITS)
{
player->SendEquipError(EQUIP_ERR_NONE, item, NULL);
if (const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(SPELL_PETROV_BOMB))
Spell::SendCastResult(player, spellInfo, 1, SPELL_FAILED_NOT_HERE);
return true;
}
return false;
}
};
/*######
# item_dehta_trap_smasher
# For quest 11876, Help Those That Cannot Help Themselves
######*/
enum eHelpThemselves
{
QUEST_CANNOT_HELP_THEMSELVES = 11876,
NPC_TRAPPED_MAMMOTH_CALF = 25850,
GO_MAMMOTH_TRAP_1 = 188022,
GO_MAMMOTH_TRAP_2 = 188024,
GO_MAMMOTH_TRAP_3 = 188025,
GO_MAMMOTH_TRAP_4 = 188026,
GO_MAMMOTH_TRAP_5 = 188027,
GO_MAMMOTH_TRAP_6 = 188028,
GO_MAMMOTH_TRAP_7 = 188029,
GO_MAMMOTH_TRAP_8 = 188030,
GO_MAMMOTH_TRAP_9 = 188031,
GO_MAMMOTH_TRAP_10 = 188032,
GO_MAMMOTH_TRAP_11 = 188033,
GO_MAMMOTH_TRAP_12 = 188034,
GO_MAMMOTH_TRAP_13 = 188035,
GO_MAMMOTH_TRAP_14 = 188036,
GO_MAMMOTH_TRAP_15 = 188037,
GO_MAMMOTH_TRAP_16 = 188038,
GO_MAMMOTH_TRAP_17 = 188039,
GO_MAMMOTH_TRAP_18 = 188040,
GO_MAMMOTH_TRAP_19 = 188041,
GO_MAMMOTH_TRAP_20 = 188042,
GO_MAMMOTH_TRAP_21 = 188043,
GO_MAMMOTH_TRAP_22 = 188044,
};
#define MammothTrapsNum 22
const uint32 MammothTraps[MammothTrapsNum] =
{
GO_MAMMOTH_TRAP_1, GO_MAMMOTH_TRAP_2, GO_MAMMOTH_TRAP_3, GO_MAMMOTH_TRAP_4, GO_MAMMOTH_TRAP_5,
GO_MAMMOTH_TRAP_6, GO_MAMMOTH_TRAP_7, GO_MAMMOTH_TRAP_8, GO_MAMMOTH_TRAP_9, GO_MAMMOTH_TRAP_10,
GO_MAMMOTH_TRAP_11, GO_MAMMOTH_TRAP_12, GO_MAMMOTH_TRAP_13, GO_MAMMOTH_TRAP_14, GO_MAMMOTH_TRAP_15,
GO_MAMMOTH_TRAP_16, GO_MAMMOTH_TRAP_17, GO_MAMMOTH_TRAP_18, GO_MAMMOTH_TRAP_19, GO_MAMMOTH_TRAP_20,
GO_MAMMOTH_TRAP_21, GO_MAMMOTH_TRAP_22
};
class item_dehta_trap_smasher : public ItemScript
{
public:
item_dehta_trap_smasher() : ItemScript("item_dehta_trap_smasher") { }
bool OnUse(Player* player, Item* /*item*/, const SpellCastTargets & /*targets*/)
{
if (player->GetQuestStatus(QUEST_CANNOT_HELP_THEMSELVES) != QUEST_STATUS_INCOMPLETE)
return false;
Creature* pMammoth = player->FindNearestCreature(NPC_TRAPPED_MAMMOTH_CALF, 5.0f);
if (!pMammoth)
return false;
GameObject* pTrap = NULL;
for (uint8 i = 0; i < MammothTrapsNum; ++i)
{
pTrap = player->FindNearestGameObject(MammothTraps[i], 11.0f);
if (pTrap)
{
pMammoth->AI()->DoAction(1);
pTrap->SetGoState(GO_STATE_READY);
player->KilledMonsterCredit(NPC_TRAPPED_MAMMOTH_CALF, 0);
return true;
}
}
return false;
}
};
enum TheEmissary
{
QUEST_THE_EMISSARY = 11626,
NPC_LEVIROTH = 26452
};
class item_trident_of_nazjan : public ItemScript
{
public:
item_trident_of_nazjan() : ItemScript("item_Trident_of_Nazjan") { }
bool OnUse(Player* player, Item* item, const SpellCastTargets & /*targets*/)
{
if (player->GetQuestStatus(QUEST_THE_EMISSARY) == QUEST_STATUS_INCOMPLETE)
{
if (Creature* pLeviroth = player->FindNearestCreature(NPC_LEVIROTH, 10.0f)) // spell range
{
pLeviroth->AI()->AttackStart(player);
return false;
} else
player->SendEquipError(EQUIP_ERR_OUT_OF_RANGE, item, NULL);
} else
player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, NULL);
return true;
}
};
enum eCapturedFrog
{
QUEST_THE_PERFECT_SPIES = 25444,
NPC_VANIRAS_SENTRY_TOTEM = 40187
};
class item_captured_frog : public ItemScript
{
public:
item_captured_frog() : ItemScript("item_captured_frog") { }
bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/)
{
if (player->GetQuestStatus(QUEST_THE_PERFECT_SPIES) == QUEST_STATUS_INCOMPLETE)
{
if (player->FindNearestCreature(NPC_VANIRAS_SENTRY_TOTEM, 10.0f))
return false;
else
player->SendEquipError(EQUIP_ERR_OUT_OF_RANGE, item, NULL);
}
else
player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, NULL);
return true;
}
};
void AddSC_item_scripts()
{
new item_only_for_flight();
new item_nether_wraith_beacon();
new item_gor_dreks_ointment();
new item_incendiary_explosives();
new item_mysterious_egg();
new item_disgusting_jar();
new item_pile_fake_furs();
new item_petrov_cluster_bombs();
new item_dehta_trap_smasher();
new item_trident_of_nazjan();
new item_captured_frog();
}