-
Notifications
You must be signed in to change notification settings - Fork 522
/
AOS.cs
3341 lines (2860 loc) · 93.8 KB
/
AOS.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
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using Server.Engines.CityLoyalty;
using Server.Engines.SphynxFortune;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Services.Virtues;
using Server.SkillHandlers;
using Server.Spells;
using Server.Spells.Bushido;
using Server.Spells.Chivalry;
using Server.Spells.Fifth;
using Server.Spells.Necromancy;
using Server.Spells.Ninjitsu;
using Server.Spells.Seventh;
using Server.Spells.SkillMasteries;
using Server.Spells.Spellweaving;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Server
{
public enum DamageType
{
Melee,
Ranged,
Spell,
SpellAOE
}
public class AOS
{
public static void DisableStatInfluences()
{
for (int i = 0; i < SkillInfo.Table.Length; ++i)
{
SkillInfo info = SkillInfo.Table[i];
info.StrScale = 0.0;
info.DexScale = 0.0;
info.IntScale = 0.0;
info.StatTotal = 0.0;
}
}
public static int Damage(IDamageable m, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy)
{
return Damage(m, null, damage, ignoreArmor, phys, fire, cold, pois, nrgy);
}
public static int Damage(IDamageable m, int damage, int phys, int fire, int cold, int pois, int nrgy)
{
return Damage(m, null, damage, phys, fire, cold, pois, nrgy);
}
public static int Damage(IDamageable m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, 0, 0, false);
}
public static int Damage(IDamageable m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy, int chaos)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, chaos, 0, false);
}
public static int Damage(IDamageable m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy, int chaos, int direct)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, chaos, direct, false);
}
public static int Damage(IDamageable m, Mobile from, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy)
{
return Damage(m, from, damage, ignoreArmor, phys, fire, cold, pois, nrgy, 0, 0, false);
}
public static int Damage(IDamageable m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy, bool keepAlive)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, 0, 0, keepAlive);
}
public static int Damage(IDamageable m, Mobile from, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy, int chaos, int direct, bool keepAlive, bool archer, bool deathStrike)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, chaos, direct, keepAlive, archer ? DamageType.Ranged : DamageType.Melee); // old deathStrike damage, kept for compatibility
}
public static int Damage(IDamageable m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy, DamageType type)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, 0, 0, false, type);
}
public static int Damage(IDamageable m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy, int chaos, int direct, DamageType type)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, chaos, direct, false, type);
}
public static int Damage(IDamageable damageable, Mobile from, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy, int chaos, int direct, bool keepAlive, DamageType type = DamageType.Melee)
{
Mobile m = damageable as Mobile;
if (damageable == null || damageable.Deleted || !damageable.Alive || damage <= 0)
return 0;
if (m != null && phys == 0 && fire == 100 && cold == 0 && pois == 0 && nrgy == 0)
MeerMage.StopEffect(m, true);
if (m != null)
{
m.Items.ForEach(i =>
{
ITalismanProtection prot = i as ITalismanProtection;
if (prot != null)
damage = prot.Protection.ScaleDamage(from, damage);
});
}
Fix(ref phys);
Fix(ref fire);
Fix(ref cold);
Fix(ref pois);
Fix(ref nrgy);
Fix(ref chaos);
Fix(ref direct);
if (chaos > 0)
{
switch (Utility.Random(5))
{
case 0:
phys += chaos;
break;
case 1:
fire += chaos;
break;
case 2:
cold += chaos;
break;
case 3:
pois += chaos;
break;
case 4:
nrgy += chaos;
break;
}
}
bool ranged = type == DamageType.Ranged;
BaseQuiver quiver = null;
if (ranged && from.Race != Race.Gargoyle)
quiver = from.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
int totalDamage;
if (!ignoreArmor)
{
int physDamage = damage * phys * (100 - damageable.PhysicalResistance);
int fireDamage = damage * fire * (100 - damageable.FireResistance);
int coldDamage = damage * cold * (100 - damageable.ColdResistance);
int poisonDamage = damage * pois * (100 - damageable.PoisonResistance);
int energyDamage = damage * nrgy * (100 - damageable.EnergyResistance);
totalDamage = physDamage + fireDamage + coldDamage + poisonDamage + energyDamage;
totalDamage /= 10000;
totalDamage += damage * direct / 100;
if (quiver != null)
totalDamage += totalDamage * quiver.DamageIncrease / 100;
if (m != null)
BaseFishPie.ScaleDamage(from, m, ref totalDamage, phys, fire, cold, pois, nrgy, direct);
if (ArmorPierce.IsUnderEffects(m))
{
totalDamage += (int)(totalDamage * .1);
}
if (totalDamage < 1)
totalDamage = 1;
}
else if (m is PlayerMobile)
{
if (quiver != null)
damage += damage * quiver.DamageIncrease / 100;
totalDamage = Math.Min(damage, ranged ? 30 : 35); // Direct Damage cap of 30/35
}
else
{
totalDamage = damage;
if (quiver != null)
totalDamage += totalDamage * quiver.DamageIncrease / 100;
}
// object being damaged is not a mobile, so we will end here
if (damageable is Item)
{
return damageable.Damage(totalDamage, from);
}
#region Evil Omen, Blood Oath and reflect physical
if (EvilOmenSpell.TryEndEffect(m))
{
totalDamage = (int)(totalDamage * 1.25);
}
var fromCreature = from as BaseCreature;
var toCreature = m as BaseCreature;
if (from != null && !from.Deleted && from.Alive && !from.IsDeadBondedPet)
{
Mobile oath = BloodOathSpell.GetBloodOath(from);
/* Per EA's UO Herald Pub48 (ML):
* ((resist spellsx10)/20 + 10=percentage of damage resisted)
*
* Tested 12/29/2017-
* No cap, also, above forumula is only in effect vs. creatures
*/
if (oath == m)
{
int originalDamage = totalDamage;
totalDamage = (int)(totalDamage * 1.2);
if (toCreature != null)
{
from.Damage((int)(originalDamage * (1 - (((from.Skills.MagicResist.Value * .5) + 10) / 100))), m);
}
else
{
from.Damage(originalDamage, m);
}
}
else if (!ignoreArmor && from != m)
{
int reflectPhys = Math.Min(105, AosAttributes.GetValue(m, AosAttribute.ReflectPhysical));
if (reflectPhys != 0)
{
if (from is ExodusMinion && ((ExodusMinion)from).FieldActive || from is ExodusOverseer && ((ExodusOverseer)from).FieldActive)
{
from.FixedParticles(0x376A, 20, 10, 0x2530, EffectLayer.Waist);
from.PlaySound(0x2F4);
m.SendAsciiMessage("Your weapon cannot penetrate the creature's magical barrier");
}
else
{
from.Damage(Scale((damage * phys * (100 - (ignoreArmor ? 0 : m.PhysicalResistance))) / 10000, reflectPhys), m);
}
}
}
}
#endregion
//SHould this go in after or before dragon barding absorb?
if (ignoreArmor)
DamageEaterContext.CheckDamage(m, totalDamage, 0, 0, 0, 0, 0, 100);
else
DamageEaterContext.CheckDamage(m, totalDamage, phys, fire, cold, pois, nrgy, direct);
if (fire > 0 && totalDamage > 0)
SwarmContext.CheckRemove(m);
SpiritualityVirtue.GetDamageReduction(m, ref totalDamage);
BestialSetHelper.OnDamage(m, from, ref totalDamage);
EpiphanyHelper.OnHit(m, totalDamage);
if (type == DamageType.Spell && m != null && Feint.Registry.ContainsKey(m) && Feint.Registry[m].Enemy == from)
totalDamage -= (int)(damage * ((double)Feint.Registry[m].DamageReduction / 100));
if (m.Hidden && type >= DamageType.Spell)
{
int chance = (int)Math.Min(33, 100 - (ShadowSpell.GetDifficultyFactor(m) * 100));
if (Utility.Random(100) < chance)
{
m.RevealingAction();
m.NextSkillTime = Core.TickCount + (12000 - ((int)m.Skills[SkillName.Hiding].Value) * 100);
}
}
SkillMasterySpell.OnDamage(m, from, type, ref totalDamage);
if (fromCreature != null || toCreature != null)
{
SpecialAbility.CheckCombatTrigger(from, m, ref totalDamage, type);
if (fromCreature != null && toCreature != null)
{
TrainingProfile profile = PetTrainingHelper.GetTrainingProfile((BaseCreature)from);
if (profile != null)
{
profile.CheckProgress(toCreature);
}
profile = PetTrainingHelper.GetTrainingProfile(toCreature);
if (profile != null && 0.3 > Utility.RandomDouble())
{
profile.CheckProgress((BaseCreature)from);
}
}
if (fromCreature != null)
{
if (fromCreature.Controlled && m.Player)
{
totalDamage /= 2; // Controlled creatures do 50% less damage to players.
}
else if (toCreature != null && toCreature.Controlled && !toCreature.Summoned && !toCreature.Allured) // Tamed pets only.
{
totalDamage += (int)(totalDamage * 0.25); // How much extra damage will monsters do to tamed pets?
}
}
}
if (type <= DamageType.Ranged)
{
AttuneWeaponSpell.TryAbsorb(m, ref totalDamage);
}
if (keepAlive && totalDamage > m.Hits)
{
totalDamage = m.Hits;
}
if (fromCreature != null && type <= DamageType.Ranged)
{
fromCreature.AlterMeleeDamageTo(m, ref totalDamage);
}
if (toCreature != null && type <= DamageType.Ranged)
{
toCreature.AlterMeleeDamageFrom(from, ref totalDamage);
toCreature.OnBeforeDamage(from, ref totalDamage, type);
}
if (totalDamage <= 0)
{
return 0;
}
if (from != null)
{
DoLeech(totalDamage, from, m);
}
totalDamage = m.Damage(totalDamage, from, true, false);
ExplodingTarPotion.RemoveEffects(m);
if (type == DamageType.Melee && fromCreature != null &&
(m is PlayerMobile || (toCreature != null && !toCreature.IsMonster)))
{
from.RegisterDamage(totalDamage / 4, m);
}
SpiritSpeak.CheckDisrupt(m);
if (m.Spell != null)
((Spell)m.Spell).CheckCasterDisruption(true, phys, fire, cold, pois, nrgy);
BattleLust.IncreaseBattleLust(m, totalDamage);
if (ManaPhasingOrb.IsInManaPhase(m))
ManaPhasingOrb.RemoveFromTable(m);
SoulChargeContext.CheckHit(from, m, totalDamage);
Spells.Mysticism.SleepSpell.OnDamage(m);
Spells.Mysticism.PurgeMagicSpell.OnMobileDoDamage(from);
BaseCostume.OnDamaged(m);
return totalDamage;
}
public static void Fix(ref int val)
{
if (val < 0)
val = 0;
}
public static int Scale(int input, int percent)
{
return (input * percent) / 100;
}
public static void DoLeech(int damageGiven, Mobile from, Mobile target)
{
TransformContext context = TransformationSpellHelper.GetContext(from);
if (context != null)
{
if (context.Type == typeof(WraithFormSpell))
{
int manaLeech = Scale(damageGiven, Math.Min(target.Mana, Math.Max(8, 5 + (int)(0.16 * from.Skills.SpiritSpeak.Value))));
if (manaLeech != 0)
{
from.Mana += manaLeech;
from.PlaySound(0x44D);
target.Mana -= manaLeech;
}
}
else if (context.Type == typeof(VampiricEmbraceSpell))
{
var bc = target as BaseCreature;
if (bc != null && bc.TaintedLifeAura)
{
Damage(from, target, Scale(damageGiven, 20), false, 0, 0, 0, 0, 0, 0, 100, false, false, false);
from.SendLocalizedMessage(1116778); //The tainted life force energy damages you as your body tries to absorb it.
}
else
{
from.Hits += Scale(damageGiven, 20);
from.PlaySound(0x44D);
}
}
}
}
#region AOS Status Bar
public static int GetStatus(Mobile from, int index)
{
switch (index)
{
case 0: return from.GetMaxResistance(ResistanceType.Physical);
case 1: return from.GetMaxResistance(ResistanceType.Fire);
case 2: return from.GetMaxResistance(ResistanceType.Cold);
case 3: return from.GetMaxResistance(ResistanceType.Poison);
case 4: return from.GetMaxResistance(ResistanceType.Energy);
case 5: return Math.Min(45 + BaseArmor.GetRefinedDefenseChance(from), AosAttributes.GetValue(from, AosAttribute.DefendChance));
case 6: return 45 + BaseArmor.GetRefinedDefenseChance(from) + WhiteTigerFormSpell.GetDefenseCap(from);
case 7: return Math.Min(from.Race == Race.Gargoyle ? 50 : 45, AosAttributes.GetValue(from, AosAttribute.AttackChance));
case 8: return Math.Min(60, AosAttributes.GetValue(from, AosAttribute.WeaponSpeed));
case 9: return Math.Min(100, AosAttributes.GetValue(from, AosAttribute.WeaponDamage));
case 10: return Math.Min(100, AosAttributes.GetValue(from, AosAttribute.LowerRegCost));
case 11: return AosAttributes.GetValue(from, AosAttribute.SpellDamage);
case 12: return Math.Min(6, AosAttributes.GetValue(from, AosAttribute.CastRecovery));
case 13: return Math.Min(4, AosAttributes.GetValue(from, AosAttribute.CastSpeed));
case 14: return Math.Min(40, AosAttributes.GetValue(from, AosAttribute.LowerManaCost)) + BaseArmor.GetInherentLowerManaCost(from);
case 15: return (int)RegenRates.HitPointRegen(from); // HP REGEN
case 16: return (int)RegenRates.StamRegen(from); // Stam REGEN
case 17: return (int)RegenRates.ManaRegen(from); // MANA REGEN
case 18: return Math.Min(105, AosAttributes.GetValue(from, AosAttribute.ReflectPhysical)); // reflect phys
case 19: return Math.Min(50, AosAttributes.GetValue(from, AosAttribute.EnhancePotions)); // enhance pots
case 20: return AosAttributes.GetValue(from, AosAttribute.BonusStr) + from.GetStatOffset(StatType.Str); // str inc
case 21: return AosAttributes.GetValue(from, AosAttribute.BonusDex) + from.GetStatOffset(StatType.Dex); // dex inc
case 22: return AosAttributes.GetValue(from, AosAttribute.BonusInt) + from.GetStatOffset(StatType.Int); // int inc
case 23: return 0; // hits neg
case 24: return 0; // stam neg
case 25: return 0; // mana neg
case 26: return AosAttributes.GetValue(from, AosAttribute.BonusHits); // hits inc
case 27: return AosAttributes.GetValue(from, AosAttribute.BonusStam); // stam inc
case 28: return AosAttributes.GetValue(from, AosAttribute.BonusMana); // mana inc
default: return 0;
}
}
#endregion
}
[Flags]
public enum AosAttribute
{
RegenHits = 0x00000001,
RegenStam = 0x00000002,
RegenMana = 0x00000004,
DefendChance = 0x00000008,
AttackChance = 0x00000010,
BonusStr = 0x00000020,
BonusDex = 0x00000040,
BonusInt = 0x00000080,
BonusHits = 0x00000100,
BonusStam = 0x00000200,
BonusMana = 0x00000400,
WeaponDamage = 0x00000800,
WeaponSpeed = 0x00001000,
SpellDamage = 0x00002000,
CastRecovery = 0x00004000,
CastSpeed = 0x00008000,
LowerManaCost = 0x00010000,
LowerRegCost = 0x00020000,
ReflectPhysical = 0x00040000,
EnhancePotions = 0x00080000,
Luck = 0x00100000,
SpellChanneling = 0x00200000,
NightSight = 0x00400000,
IncreasedKarmaLoss = 0x00800000,
Brittle = 0x01000000,
LowerAmmoCost = 0x02000000,
BalancedWeapon = 0x04000000
}
public sealed class AosAttributes : BaseAttributes
{
public static bool IsValid(AosAttribute attribute)
{
return true;
}
public static int[] GetValues(Mobile m, params AosAttribute[] attributes)
{
return EnumerateValues(m, attributes).ToArray();
}
public static int[] GetValues(Mobile m, IEnumerable<AosAttribute> attributes)
{
return EnumerateValues(m, attributes).ToArray();
}
public static IEnumerable<int> EnumerateValues(Mobile m, IEnumerable<AosAttribute> attributes)
{
return attributes.Select(a => GetValue(m, a));
}
public static int GetValue(Mobile m, AosAttribute attribute)
{
if (World.Loading || !IsValid(attribute))
{
return 0;
}
int value = 0;
if (attribute == AosAttribute.Luck || attribute == AosAttribute.RegenMana || attribute == AosAttribute.DefendChance || attribute == AosAttribute.EnhancePotions)
value += SphynxFortune.GetAosAttributeBonus(m, attribute);
value += Enhancement.GetValue(m, attribute);
for (int i = 0; i < m.Items.Count; ++i)
{
Item obj = m.Items[i];
AosAttributes attrs = RunicReforging.GetAosAttributes(obj);
if (attrs != null)
value += attrs[attribute];
if (attribute == AosAttribute.Luck)
{
if (obj is BaseWeapon)
value += ((BaseWeapon)obj).GetLuckBonus();
if (obj is BaseArmor)
value += ((BaseArmor)obj).GetLuckBonus();
if (obj is FishingPole)
value += ((FishingPole)obj).GetLuckBonus();
}
if (obj is ISetItem)
{
ISetItem item = (ISetItem)obj;
attrs = item.SetAttributes;
if (attrs != null && item.LastEquipped)
value += attrs[attribute];
}
}
#region Malus/Buff Handler
value += SkillMasterySpell.GetAttributeBonus(m, attribute);
if (attribute == AosAttribute.WeaponDamage)
{
if (BaseMagicalFood.IsUnderInfluence(m, MagicalFood.GrapesOfWrath))
value += 35;
// attacker gets 10% bonus when they're under divine fury
if (DivineFurySpell.UnderEffect(m))
value += DivineFurySpell.GetDamageBonus(m);
// Horrific Beast transformation gives a +25% bonus to damage.
if (TransformationSpellHelper.UnderTransformation(m, typeof(HorrificBeastSpell)))
value += 25;
int defenseMasteryMalus = 0;
int discordanceEffect = 0;
// Defense Mastery gives a -50%/-80% malus to damage.
if (DefenseMastery.GetMalus(m, ref defenseMasteryMalus))
value -= defenseMasteryMalus;
// Discordance gives a -2%/-48% malus to damage.
if (Discordance.GetEffect(m, ref discordanceEffect))
value -= discordanceEffect * 2;
if (Block.IsBlocking(m))
value -= 30;
if (m is PlayerMobile && m.Race == Race.Gargoyle)
{
value += ((PlayerMobile)m).GetRacialBerserkBuff(false);
}
if (BaseFishPie.IsUnderEffects(m, FishPieEffect.WeaponDam))
value += 5;
}
else if (attribute == AosAttribute.SpellDamage)
{
if (BaseMagicalFood.IsUnderInfluence(m, MagicalFood.GrapesOfWrath))
value += 15;
if (PsychicAttack.Registry.ContainsKey(m))
value -= PsychicAttack.Registry[m].SpellDamageMalus;
TransformContext context = TransformationSpellHelper.GetContext(m);
if (context != null && context.Spell is ReaperFormSpell)
value += ((ReaperFormSpell)context.Spell).SpellDamageBonus;
value += ArcaneEmpowermentSpell.GetSpellBonus(m, true);
if (m is PlayerMobile && m.Race == Race.Gargoyle)
{
value += ((PlayerMobile)m).GetRacialBerserkBuff(true);
}
if (CityLoyaltySystem.HasTradeDeal(m, TradeDeal.GuildOfArcaneArts))
value += 5;
if (BaseFishPie.IsUnderEffects(m, FishPieEffect.SpellDamage))
value += 5;
}
else if (attribute == AosAttribute.CastSpeed)
{
if (HowlOfCacophony.IsUnderEffects(m) || AuraOfNausea.UnderNausea(m))
value -= 5;
if (EssenceOfWindSpell.IsDebuffed(m))
value -= EssenceOfWindSpell.GetFCMalus(m);
if (CityLoyaltySystem.HasTradeDeal(m, TradeDeal.BardicCollegium))
value += 1;
if (Spells.Mysticism.SleepSpell.IsUnderSleepEffects(m))
value -= 2;
if (TransformationSpellHelper.UnderTransformation(m, typeof(Spells.Mysticism.StoneFormSpell)))
value -= 2;
}
else if (attribute == AosAttribute.CastRecovery)
{
if (HowlOfCacophony.IsUnderEffects(m))
value -= 5;
value -= ThunderstormSpell.GetCastRecoveryMalus(m);
if (Spells.Mysticism.SleepSpell.IsUnderSleepEffects(m))
value -= 3;
}
else if (attribute == AosAttribute.WeaponSpeed)
{
if (HowlOfCacophony.IsUnderEffects(m) || AuraOfNausea.UnderNausea(m))
value -= 60;
if (DivineFurySpell.UnderEffect(m))
value += DivineFurySpell.GetWeaponSpeedBonus(m);
value += HonorableExecution.GetSwingBonus(m);
TransformContext context = TransformationSpellHelper.GetContext(m);
if (context != null && context.Spell is ReaperFormSpell)
value += ((ReaperFormSpell)context.Spell).SwingSpeedBonus;
int discordanceEffect = 0;
// Discordance gives a malus of -0/-28% to swing speed.
if (Discordance.GetEffect(m, ref discordanceEffect))
value -= discordanceEffect;
if (EssenceOfWindSpell.IsDebuffed(m))
value -= EssenceOfWindSpell.GetSSIMalus(m);
if (CityLoyaltySystem.HasTradeDeal(m, TradeDeal.GuildOfAssassins))
value += 5;
if (Spells.Mysticism.SleepSpell.IsUnderSleepEffects(m))
value -= 45;
if (TransformationSpellHelper.UnderTransformation(m, typeof(Spells.Mysticism.StoneFormSpell)))
value -= 10;
if (StickySkin.IsUnderEffects(m))
value -= 30;
}
else if (attribute == AosAttribute.AttackChance)
{
if (AuraOfNausea.UnderNausea(m))
value -= 60;
if (DivineFurySpell.UnderEffect(m))
value += DivineFurySpell.GetAttackBonus(m);
if (BaseWeapon.CheckAnimal(m, typeof(GreyWolf)) || BaseWeapon.CheckAnimal(m, typeof(BakeKitsune)))
value += 20; // attacker gets 20% bonus when under Wolf or Bake Kitsune form
if (HitLower.IsUnderAttackEffect(m))
value -= 25; // Under Hit Lower Attack effect -> 25% malus
WeaponAbility ability = WeaponAbility.GetCurrentAbility(m);
if (ability != null)
value += ability.AccuracyBonus;
SpecialMove move = SpecialMove.GetCurrentMove(m);
if (move != null)
value += move.GetAccuracyBonus(m);
if (CityLoyaltySystem.HasTradeDeal(m, TradeDeal.WarriorsGuild))
value += 5;
if (Spells.Mysticism.SleepSpell.IsUnderSleepEffects(m))
value -= 45;
if (m.Race == Race.Gargoyle)
value += 5; //Gargoyles get a +5 HCI
if (BaseFishPie.IsUnderEffects(m, FishPieEffect.HitChance))
value += 8;
}
else if (attribute == AosAttribute.DefendChance)
{
if (AuraOfNausea.UnderNausea(m))
value -= 60;
if (DivineFurySpell.UnderEffect(m))
value -= DivineFurySpell.GetDefendMalus(m);
value -= HitLower.GetDefenseMalus(m);
int discordanceEffect = 0;
int surpriseMalus = 0;
value += Block.GetBonus(m);
if (SurpriseAttack.GetMalus(m, ref surpriseMalus))
value -= surpriseMalus;
// Defender loses -0/-28% if under the effect of Discordance.
if (Discordance.GetEffect(m, ref discordanceEffect))
value -= discordanceEffect;
if (BaseFishPie.IsUnderEffects(m, FishPieEffect.DefChance))
value += 8;
}
else if (attribute == AosAttribute.RegenHits)
{
if (CityLoyaltySystem.HasTradeDeal(m, TradeDeal.MaritimeGuild))
value += 2;
if (m is PlayerMobile && BaseFishPie.IsUnderEffects(m, FishPieEffect.HitsRegen))
value += 3;
if (SurgeShield.IsUnderEffects(m, SurgeType.Hits))
value += 10;
if (SearingWeaponContext.HasContext(m))
value -= m is PlayerMobile ? 20 : 60;
//Virtue Artifacts
value += AnkhPendant.GetHitsRegenModifier(m);
}
else if (attribute == AosAttribute.RegenStam)
{
if (m is PlayerMobile && BaseFishPie.IsUnderEffects(m, FishPieEffect.StamRegen))
value += 3;
if (SurgeShield.IsUnderEffects(m, SurgeType.Stam))
value += 10;
//Virtue Artifacts
value += AnkhPendant.GetStamRegenModifier(m);
}
else if (attribute == AosAttribute.RegenMana)
{
if (CityLoyaltySystem.HasTradeDeal(m, TradeDeal.MerchantsAssociation))
value += 1;
if (m is PlayerMobile && BaseFishPie.IsUnderEffects(m, FishPieEffect.ManaRegen))
value += 3;
if (SurgeShield.IsUnderEffects(m, SurgeType.Mana))
value += 10;
//Virtue Artifacts
value += AnkhPendant.GetManaRegenModifier(m);
}
#endregion
return value;
}
public override void SetValue(int bitmask, int value)
{
if (bitmask == (int)AosAttribute.WeaponSpeed && Owner is BaseWeapon)
{
((BaseWeapon)Owner).WeaponAttributes.ScaleLeech(value);
}
base.SetValue(bitmask, value);
}
public AosAttributes(Item owner)
: base(owner)
{
}
public AosAttributes(Item owner, AosAttributes other)
: base(owner, other)
{
}
public AosAttributes(Item owner, GenericReader reader)
: base(owner, reader)
{
}
public int this[AosAttribute attribute]
{
get
{
return GetValue((int)attribute);
}
set
{
SetValue((int)attribute, value);
}
}
public override string ToString()
{
return "...";
}
public void AddStatBonuses(Mobile to)
{
int strBonus = BonusStr;
int dexBonus = BonusDex;
int intBonus = BonusInt;
if (strBonus != 0 || dexBonus != 0 || intBonus != 0)
{
string modName = Owner.Serial.ToString();
if (strBonus != 0)
to.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
to.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
to.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
}
to.CheckStatTimers();
}
public void RemoveStatBonuses(Mobile from)
{
string modName = Owner.Serial.ToString();
from.RemoveStatMod(modName + "Str");
from.RemoveStatMod(modName + "Dex");
from.RemoveStatMod(modName + "Int");
from.CheckStatTimers();
}
[CommandProperty(AccessLevel.GameMaster)]
public int RegenHits
{
get
{
return this[AosAttribute.RegenHits];
}
set
{
this[AosAttribute.RegenHits] = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int RegenStam
{
get
{
return this[AosAttribute.RegenStam];
}
set
{
this[AosAttribute.RegenStam] = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int RegenMana
{
get
{
return this[AosAttribute.RegenMana];
}
set
{
this[AosAttribute.RegenMana] = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int DefendChance
{
get
{
return this[AosAttribute.DefendChance];
}
set
{
this[AosAttribute.DefendChance] = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int AttackChance
{
get
{
return this[AosAttribute.AttackChance];
}
set
{
this[AosAttribute.AttackChance] = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int BonusStr
{
get
{
return this[AosAttribute.BonusStr];
}
set
{
this[AosAttribute.BonusStr] = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int BonusDex
{
get
{
return this[AosAttribute.BonusDex];
}
set
{
this[AosAttribute.BonusDex] = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int BonusInt
{
get
{
return this[AosAttribute.BonusInt];
}
set
{
this[AosAttribute.BonusInt] = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int BonusHits
{
get
{
return this[AosAttribute.BonusHits];
}
set
{
this[AosAttribute.BonusHits] = value;