/
SetItem.cs
385 lines (305 loc) · 14.6 KB
/
SetItem.cs
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
using System;
using Server.Items;
using System.Linq;
namespace Server
{
public enum SetItem
{
None,
Acolyte,
Assassin,
Darkwood,
Grizzle,
Hunter,
Juggernaut,
Mage,
Marksman,
Myrmidon,
Necromancer,
Paladin,
Virtue,
Luck,
Knights,
Scout,
Sorcerer,
Initiation,
Fisherman,
Luck2,
Bestial,
Virtuoso,
Aloron,
Darden
}
public interface ISetItem
{
SetItem SetID { get; }
int Pieces { get; }
bool BardMasteryBonus { get; }
int SetHue { get; set; }
bool IsSetItem { get; }
bool SetEquipped { get; set; }
bool LastEquipped { get; set; }
AosAttributes SetAttributes { get; }
AosSkillBonuses SetSkillBonuses { get; }
int SetPhysicalBonus { get; }
int SetFireBonus { get; }
int SetColdBonus { get; }
int SetPoisonBonus { get; }
int SetEnergyBonus { get; }
int SetResistBonus(ResistanceType type);
}
public static class SetHelper
{
public static void GetSetProperties(ObjectPropertyList list, ISetItem setItem)
{
AosAttributes attrs;
if (setItem is BaseWeapon)
attrs = ((BaseWeapon)setItem).Attributes;
else if (setItem is BaseArmor)
attrs = ((BaseArmor)setItem).Attributes;
else if (setItem is BaseClothing)
attrs = ((BaseClothing)setItem).Attributes;
else if (setItem is BaseQuiver)
attrs = ((BaseQuiver)setItem).Attributes;
else if (setItem is BaseJewel)
attrs = ((BaseJewel)setItem).Attributes;
else
attrs = new AosAttributes(setItem as Item);
bool full = setItem.SetEquipped;
int pieces = setItem.Pieces;
bool beserk = setItem.SetID == SetItem.Bestial;
bool bardmasterybonus = setItem.BardMasteryBonus;
int prop;
if (setItem is IFishingAttire)
{
IFishingAttire attire = (IFishingAttire)setItem;
if (setItem.SetEquipped && attire.SetBonus > 0)
list.Add(1151573, attire.SetBonus.ToString()); //Fish Bait Strength +~1_VAL~% (total)
else if (((IFishingAttire)setItem).BaitBonus > 0)
list.Add(1151572, attire.BaitBonus.ToString()); //Fish Bait Strength +~1_VAL~%
}
if (beserk)
list.Add(1151542, "5");// Berserk ~1_VAL~ (total)
if (setItem.BardMasteryBonus)
list.Add(1151571); //Mastery Bonus Cooldown: 15 min.
if ((prop = setItem.SetAttributes.RegenHits) != 0)
list.Add(full ? 1080244 : 1154369, (full ? prop + (attrs.RegenHits * pieces) : prop).ToString()); // hit point regeneration ~1_val~ (total)
/*if ( (prop = setItem.SetAttributes.RegenStam) != 0 )
list.Add(full ? 1154365 : 1154370, (full ? prop + (attrs.ReganStam * pieces) : prop).ToString()); // stamina regeneration ~1_val~ (total)*/
if ((prop = setItem.SetAttributes.RegenMana) != 0)
list.Add(full ? 1080245 : 1080250, (full ? prop + (attrs.RegenMana * pieces) : prop).ToString()); // mana regeneration ~1_val~ (total)
if ((prop = setItem.SetAttributes.DefendChance) != 0)
list.Add(full ? 1073493 : 1060408, (full ? prop + (attrs.DefendChance * pieces) : prop).ToString()); // defense chance increase ~1_val~% (total)
if ((prop = setItem.SetAttributes.AttackChance) != 0)
list.Add(full ? 1073490 : 1154366, (full ? prop + (attrs.AttackChance * pieces) : prop).ToString()); // hit chance increase ~1_val~% (total)
if ((prop = setItem.SetAttributes.BonusStr) != 0)
list.Add(full ? 1072514 : 1060485, (full ? prop + (attrs.BonusStr * pieces) : prop).ToString()); // strength bonus ~1_val~ (total)
if ((prop = setItem.SetAttributes.BonusDex) != 0)
list.Add(full ? 1072503 : 1080447, (full ? prop + (attrs.BonusDex * pieces) : prop).ToString());// dexterity bonus ~1_val~ (total)
if ((prop = setItem.SetAttributes.BonusInt) != 0)
list.Add(full ? 1072381 : 1080439, (full ? prop + (attrs.BonusInt * pieces) : prop).ToString());// intelligence bonus ~1_val~ (total)
if ((prop = setItem.SetAttributes.BonusHits) != 0)
list.Add(full ? 1080360 : 1080358, (full ? prop + (attrs.BonusHits * pieces) : prop).ToString());// hit point increase ~1_val~ (total)
if ((prop = setItem.SetAttributes.BonusStam) != 0)
list.Add(full ? 1060484 : 1060484, (full ? prop + (attrs.BonusStam * pieces) : prop).ToString()); // stamina increase ~1_val~ (total)
if ((prop = setItem.SetAttributes.BonusMana) != 0)
list.Add(full ? 1060439 : 1060439, (full ? prop + (attrs.BonusMana * pieces) : prop).ToString()); // mana increase ~1_val~ (total)
if ((prop = setItem.SetAttributes.WeaponDamage) != 0)
list.Add(full ? 1151216 : 1154367, (full ? prop + (attrs.WeaponDamage * pieces) : prop).ToString()); // damage increase ~1_val~% (total)
if ((prop = setItem.SetAttributes.WeaponSpeed) != 0)
list.Add(full ? 1074323 : 1154368, (full ? prop + (attrs.WeaponSpeed * pieces) : prop).ToString()); // swing speed increase ~1_val~% (total)
if ((prop = setItem.SetAttributes.SpellDamage) != 0)
list.Add(full ? 1072380 : 1060483, (full ? prop + (attrs.SpellDamage * pieces) : prop).ToString()); // spell damage increase ~1_val~% (total)
if ((prop = setItem.SetAttributes.CastRecovery) != 0)
list.Add(full ? 1080242 : 1080248, (full ? prop + (attrs.CastRecovery * pieces) : prop).ToString()); // faster cast recovery ~1_val~ (total)
if ((prop = setItem.SetAttributes.CastSpeed) != 0)
list.Add(full ? 1080243 : 1080247, (full ? prop + (attrs.CastSpeed * pieces) : prop).ToString()); // faster casting ~1_val~ (total)
if ((prop = setItem.SetAttributes.LowerManaCost) != 0)
list.Add(full ? 1073488 : 1060433, (full ? prop + (attrs.LowerManaCost * pieces) : prop).ToString());// lower mana cost ~1_val~% (total)
if ((prop = setItem.SetAttributes.LowerRegCost) != 0)
list.Add(full ? 1080441 : 1080440, (full ? prop + (attrs.LowerRegCost * pieces) : prop).ToString()); // lower reagent cost ~1_val~% (total)
if ((prop = setItem.SetAttributes.ReflectPhysical) != 0)
list.Add(full ? 1072513 : 1060442, (prop + attrs.ReflectPhysical).ToString()); // reflect physical damage ~1_val~% (total)
/*if ( (prop = setItem.SetAttributes.EnhancePotions) != 0 )
list.Add( , (full ? prop + (attrs.EnhancePotions * pieces) : prop).ToString()); enhance potions ~1_val~% (total)*/
if ((prop = setItem.SetAttributes.Luck) != 0)
list.Add(full ? 1073489 : 1080246, (full ? prop + (attrs.Luck * pieces) : prop).ToString()); // luck ~1_val~% (total)
if (!setItem.SetEquipped && setItem.SetAttributes.NightSight != 0)
list.Add(1060441); // night sight
if (setItem.SetSkillBonuses.Skill_1_Value != 0)
list.Add(1072502, "{0}\t{1}", "#" + (1044060 + (int)setItem.SetSkillBonuses.Skill_1_Name), setItem.SetSkillBonuses.Skill_1_Value); // ~1_skill~ ~2_val~ (total)
}
public static void RemoveSetBonus(Mobile from, SetItem setID, Item item)
{
bool self = false;
for (int i = 0; i < from.Items.Count; i++)
{
if (from.Items[i] == item)
self = true;
Remove(from, setID, from.Items[i]);
}
if (!self)
Remove(from, setID, item);
from.UpdateResistances();
}
public static void Remove(Mobile from, SetItem setID, Item item)
{
if (item is ISetItem)
{
ISetItem setItem = (ISetItem)item;
if (setItem.IsSetItem && setItem.SetID == setID)
{
if (setItem.LastEquipped)
{
if (from != null)
RemoveStatBonuses(from, item);
setItem.SetSkillBonuses.Remove();
}
if (setID != SetItem.Bestial)
{
int temp = item.Hue;
item.Hue = setItem.SetHue;
setItem.SetHue = temp;
}
setItem.SetEquipped = false;
setItem.LastEquipped = false;
item.InvalidateProperties();
}
}
}
public static void AddSetBonus(Mobile to, SetItem setID)
{
int temp;
for (int i = 0; i < to.Items.Count; i++)
{
if (to.Items[i] is ISetItem)
{
ISetItem setItem = (ISetItem)to.Items[i];
if (setItem.IsSetItem && setItem.SetID == setID)
{
if (setItem.LastEquipped)
{
AddStatBonuses(to, to.Items[i], setItem.SetAttributes.BonusStr, setItem.SetAttributes.BonusDex, setItem.SetAttributes.BonusInt);
setItem.SetSkillBonuses.AddTo(to);
}
if (setID != SetItem.Bestial)
{
temp = to.Items[i].Hue;
to.Items[i].Hue = setItem.SetHue;
setItem.SetHue = temp;
}
setItem.SetEquipped = true;
Timer.DelayCall<Item>(item => item.InvalidateProperties(), to.Items[i]);
}
}
}
to.UpdateResistances();
Effects.PlaySound(to.Location, to.Map, 0x1F7);
to.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist);
to.SendLocalizedMessage(1072391); // The magic of your armor combines to assist you!
}
public static bool FullSetEquipped(Mobile from, SetItem setID, int pieces)
{
int equipped = 0;
for (int i = 0; i < from.Items.Count && equipped < pieces; i++)
{
if (from.Items[i] is ISetItem)
{
ISetItem setItem = (ISetItem)from.Items[i];
if (setItem.IsSetItem && setItem.SetID == setID)
equipped += 1;
}
}
if (equipped == pieces)
return true;
return false;
}
public static void RemoveStatBonuses(Mobile from, Item item)
{
string modName = item.Serial.ToString();
from.RemoveStatMod(modName + "SetStr");
from.RemoveStatMod(modName + "SetDex");
from.RemoveStatMod(modName + "SetInt");
from.Delta(MobileDelta.Armor);
from.CheckStatTimers();
}
public static void AddStatBonuses(Mobile to, Item item, int str, int dex, int intel)
{
if ((str != 0 || dex != 0 || intel != 0))
{
string modName = item.Serial.ToString();
if (str != 0)
to.AddStatMod(new StatMod(StatType.Str, modName + "SetStr", str, TimeSpan.Zero));
if (dex != 0)
to.AddStatMod(new StatMod(StatType.Dex, modName + "SetDex", dex, TimeSpan.Zero));
if (intel != 0)
to.AddStatMod(new StatMod(StatType.Int, modName + "SetInt", intel, TimeSpan.Zero));
}
to.CheckStatTimers();
}
public static bool SetCraftedWith(Mobile from, ISetItem setItem, CraftResource resource)
{
int count = 0;
for (int i = 0; i < from.Items.Count && count < setItem.Pieces; i++)
{
if (from.Items[i] is BaseArmor)
{
BaseArmor armor = (BaseArmor)from.Items[i];
if (armor.IsSetItem && armor.SetID == setItem.SetID && armor.Resource == resource)
count += 1;
}
else if (from.Items[i] is BaseWeapon)
{
BaseWeapon weapon = (BaseWeapon)from.Items[i];
if (weapon.IsSetItem && weapon.SetID == setItem.SetID && weapon.Resource == resource)
count += 1;
}
}
if (count == setItem.Pieces)
return true;
return false;
}
public static SlayerName GetSetSlayer(Mobile m)
{
foreach (ISetItem item in m.Items.OfType<ISetItem>())
{
if (item.SetID == SetItem.Aloron && item.SetEquipped)
{
return SlayerName.Dinosaur;
}
if (item.SetID == SetItem.Darden && item.SetEquipped)
{
return SlayerName.Myrmidex;
}
}
return SlayerName.None;
}
public static bool ResistsBonusPerPiece(ISetItem item)
{
switch (item.SetID)
{
default: return false;
case SetItem.Virtue:
case SetItem.Aloron:
case SetItem.Darden: return true;
}
}
public static int GetSetTotalResist(Mobile m, ResistanceType resist)
{
int total = 0;
foreach (Item item in m.Items.Where(i => i is ISetItem && ((ISetItem)i).IsSetItem && ((ISetItem)i).SetEquipped))
{
ISetItem sItem = item as ISetItem;
switch (resist)
{
case ResistanceType.Physical: total += item.PhysicalResistance + sItem.SetPhysicalBonus; break;
case ResistanceType.Fire: total += item.FireResistance + sItem.SetFireBonus; break;
case ResistanceType.Cold: total += item.ColdResistance + sItem.SetColdBonus; break;
case ResistanceType.Poison: total += item.PoisonResistance + sItem.SetPoisonBonus; break;
case ResistanceType.Energy: total += item.EnergyResistance + sItem.SetEnergyBonus; break;
}
}
return total;
}
}
}