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
|
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* 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_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 "ScriptMgr.h"
#include "GameObject.h"
#include "Item.h"
#include "Map.h"
#include "Player.h"
#include "ScriptedCreature.h"
#include "Spell.h"
#include "SpellMgr.h"
#include "TemporarySummon.h"
/*#####
# item_only_for_flight
#####*/
enum OnlyForFlight
{
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*/, ObjectGuid castId) override
{
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 (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_ARCANE_CHARGES, player->GetMap()->GetDifficultyID()))
Spell::SendCastResult(player, spellInfo, {}, castId, SPELL_FAILED_NOT_ON_GROUND);
break;
}
// allow use in flight only
if (player->IsInFlight() && !disabled)
return false;
// error
player->SendEquipError(EQUIP_ERR_CLIENT_LOCKED_OUT, item, nullptr);
return true;
}
};
/*#####
# 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, ObjectGuid /*castId*/) override
{
if (targets.GetUnitTarget() && targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT &&
targets.GetUnitTarget()->GetEntry() == 20748 && !targets.GetUnitTarget()->HasAura(32578))
return false;
player->SendEquipError(EQUIP_ERR_CLIENT_LOCKED_OUT, item, nullptr);
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*/) override
{
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, GenerateItemRandomBonusListId(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*/) override
{
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, GenerateItemRandomBonusListId(44718));
return true;
}
};
/*#####
# item_petrov_cluster_bombs
#####*/
enum PetrovClusterBombs
{
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*/, SpellCastTargets const& /*targets*/, ObjectGuid castId) override
{
if (player->GetZoneId() != ZONE_ID_HOWLING)
return false;
if (!player->GetTransport() || player->GetAreaId() != AREA_ID_SHATTERED_STRAITS)
{
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_PETROV_BOMB, DIFFICULTY_NONE))
Spell::SendCastResult(player, spellInfo, {}, castId, SPELL_FAILED_NOT_HERE);
return true;
}
return false;
}
};
enum CapturedFrog
{
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*/, ObjectGuid /*castId*/) override
{
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, nullptr);
}
else
player->SendEquipError(EQUIP_ERR_CLIENT_LOCKED_OUT, item, nullptr);
return true;
}
};
// Only used currently for
// 19169: Nightfall
class item_generic_limit_chance_above_60 : public ItemScript
{
public:
item_generic_limit_chance_above_60() : ItemScript("item_generic_limit_chance_above_60") { }
bool OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo const* /*spellInfo*/, Item* /*item*/) override
{
// spell proc chance gets severely reduced on victims > 60 (formula unknown)
if (victim->GetLevel() > 60)
{
// gives ~0.1% proc chance at lvl 70
float const lvlPenaltyFactor = 9.93f;
float const failureChance = (victim->GetLevelForTarget(player) - 60) * lvlPenaltyFactor;
// base ppm chance was already rolled, only roll success chance
return !roll_chance_f(failureChance);
}
return true;
}
};
void AddSC_item_scripts()
{
new item_only_for_flight();
new item_gor_dreks_ointment();
new item_mysterious_egg();
new item_disgusting_jar();
new item_petrov_cluster_bombs();
new item_captured_frog();
new item_generic_limit_chance_above_60();
}
|