Code cleanup (#188)

This commit is contained in:
Kamron Batman 2020-08-01 08:40:06 -07:00 committed by GitHub
parent df53c16620
commit 010fd9402a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
185 changed files with 1052 additions and 1271 deletions

View file

@ -79,15 +79,8 @@ namespace Server.Spells
public virtual double GetResistPercent(Mobile target) => GetResistPercentForCircle(target, Circle);
public override TimeSpan GetCastDelay()
{
if (!Core.ML && Scroll is BaseWand)
return TimeSpan.Zero;
if (!Core.AOS)
return TimeSpan.FromSeconds(0.5 + 0.25 * (int)Circle);
return base.GetCastDelay();
}
public override TimeSpan GetCastDelay() =>
!Core.ML && Scroll is BaseWand ? TimeSpan.Zero :
!Core.AOS ? TimeSpan.FromSeconds(0.5 + 0.25 * (int)Circle) : base.GetCastDelay();
}
}

View file

@ -164,11 +164,10 @@ namespace Server.Spells
public virtual int GetNewAosDamage(int bonus, uint dice, uint sides, bool playerVsPlayer, double scalar)
{
int damage = Utility.Dice(dice, sides, bonus) * 100;
int damageBonus = 0;
int inscribeSkill = GetInscribeFixed(Caster);
int inscribeBonus = (inscribeSkill + 1000 * (inscribeSkill / 1000)) / 200;
damageBonus += inscribeBonus;
int damageBonus = inscribeBonus;
int intBonus = Caster.Int / 10;
damageBonus += intBonus;
@ -197,27 +196,10 @@ namespace Server.Spells
return damage / 100;
}
public virtual bool ConsumeReagents()
{
if (Scroll != null || !Caster.Player)
return true;
if (AosAttributes.GetValue(Caster, AosAttribute.LowerRegCost) > Utility.Random(100))
return true;
if (DuelContext.IsFreeConsume(Caster))
return true;
Container pack = Caster.Backpack;
if (pack == null)
return false;
if (pack.ConsumeTotal(Info.Reagents, Info.Amounts) == -1)
return true;
return false;
}
public virtual bool ConsumeReagents() =>
Scroll != null || !Caster.Player ||
AosAttributes.GetValue(Caster, AosAttribute.LowerRegCost) > Utility.Random(100) ||
DuelContext.IsFreeConsume(Caster) || Caster.Backpack?.ConsumeTotal(Info.Reagents, Info.Amounts) == -1;
public virtual double GetInscribeSkill(Mobile m) => m.Skills.Inscribe.Value;
@ -541,10 +523,7 @@ namespace Server.Spells
if (Core.AOS)
return TimeSpan.Zero;
double delay = 1.0 - Math.Sqrt((Core.TickCount - StartCastTime) / 1000.0 / GetCastDelay().TotalSeconds);
if (delay < 0.2)
delay = 0.2;
double delay = Math.Max(1.0 - Math.Sqrt((Core.TickCount - StartCastTime) / 1000.0 / GetCastDelay().TotalSeconds), 0.2);
return TimeSpan.FromSeconds(delay);
}
@ -554,9 +533,7 @@ namespace Server.Spells
if (!Core.AOS)
return NextSpellDelay;
int fcr = AosAttributes.GetValue(Caster, AosAttribute.CastRecovery);
fcr -= ThunderstormSpell.GetCastRecoveryMalus(Caster);
int fcr = AosAttributes.GetValue(Caster, AosAttribute.CastRecovery) - ThunderstormSpell.GetCastRecoveryMalus(Caster);
int fcrDelay = -(CastRecoveryFastScalar * fcr);
@ -585,13 +562,10 @@ namespace Server.Spells
int fcMax = 4;
if (CastSkill == SkillName.Magery || CastSkill == SkillName.Necromancy ||
(CastSkill == SkillName.Chivalry && Caster.Skills.Magery.Value >= 70.0))
CastSkill == SkillName.Chivalry && Caster.Skills.Magery.Value >= 70.0)
fcMax = 2;
int fc = AosAttributes.GetValue(Caster, AosAttribute.CastSpeed);
if (fc > fcMax)
fc = fcMax;
int fc = Math.Min(AosAttributes.GetValue(Caster, AosAttribute.CastSpeed), fcMax);
if (ProtectionSpell.Registry.ContainsKey(Caster))
fc -= 2;
@ -599,18 +573,9 @@ namespace Server.Spells
if (EssenceOfWindSpell.IsDebuffed(Caster))
fc -= EssenceOfWindSpell.GetFCMalus(Caster);
TimeSpan baseDelay = CastDelayBase;
TimeSpan fcDelay = TimeSpan.FromSeconds(-(CastDelayFastScalar * fc * CastDelaySecondsPerTick));
// int delay = CastDelayBase + circleDelay + fcDelay;
TimeSpan delay = baseDelay + fcDelay;
if (delay < CastDelayMinimum)
delay = CastDelayMinimum;
// return TimeSpan.FromSeconds( (double)delay / CastDelayPerSecond );
return delay;
return (CastDelayBase + fcDelay).Max(CastDelayMinimum);
}
public virtual void FinishSequence()
@ -632,8 +597,8 @@ namespace Server.Spells
DoFizzle();
}
else if (Scroll != null && !(Scroll is Runebook) &&
(Scroll.Amount <= 0 || Scroll.Deleted || Scroll.RootParent != Caster || (Scroll is BaseWand baseWand &&
(baseWand.Charges <= 0 || baseWand.Parent != Caster))))
(Scroll.Amount <= 0 || Scroll.Deleted || Scroll.RootParent != Caster || Scroll is BaseWand baseWand &&
(baseWand.Charges <= 0 || baseWand.Parent != Caster)))
{
DoFizzle();
}

View file

@ -148,13 +148,8 @@ namespace Server.Spells
public static bool DisableSkillCheck { get; set; }
public static TimeSpan GetDamageDelayForSpell(Spell sp)
{
if (!sp.DelayedDamage)
return TimeSpan.Zero;
return Core.AOS ? AosDamageDelay : OldDamageDelay;
}
public static TimeSpan GetDamageDelayForSpell(Spell sp) =>
!sp.DelayedDamage ? TimeSpan.Zero : Core.AOS ? AosDamageDelay : OldDamageDelay;
public static bool CheckMulti(Point3D p, Map map, bool houses = true, int housingrange = 0)
{
@ -169,7 +164,7 @@ namespace Server.Spells
if (multi is BaseHouse bh)
{
if ((houses && bh.IsInside(p, 16)) || (housingrange > 0 && bh.InRange(p, housingrange)))
if (houses && bh.IsInside(p, 16) || housingrange > 0 && bh.InRange(p, housingrange))
return true;
}
else if (multi.Contains(p))
@ -260,15 +255,10 @@ namespace Server.Spells
}
}
public static bool AddStatOffset(Mobile m, StatType type, int offset, TimeSpan duration)
{
if (offset > 0)
return AddStatBonus(m, m, type, offset, duration);
if (offset < 0)
return AddStatCurse(m, m, type, -offset, duration);
return true;
}
public static bool AddStatOffset(Mobile m, StatType type, int offset, TimeSpan duration) =>
offset > 0
? AddStatBonus(m, m, type, offset, duration)
: offset >= 0 || AddStatCurse(m, m, type, -offset, duration);
public static bool AddStatBonus(Mobile caster, Mobile target, StatType type) => AddStatBonus(caster, target, type, GetOffset(caster, target, type, false), GetDuration(caster, target));
@ -318,13 +308,8 @@ namespace Server.Spells
return false;
}
public static TimeSpan GetDuration(Mobile caster, Mobile target)
{
if (Core.AOS)
return TimeSpan.FromSeconds(6 * caster.Skills.EvalInt.Fixed / 50 + 1);
return TimeSpan.FromSeconds(caster.Skills.Magery.Value * 1.2);
}
public static TimeSpan GetDuration(Mobile caster, Mobile target) =>
Core.AOS ? TimeSpan.FromSeconds(6 * caster.Skills.EvalInt.Fixed / 50 + 1) : TimeSpan.FromSeconds(caster.Skills.Magery.Value * 1.2);
public static double GetOffsetScalar(Mobile caster, Mobile target, bool curse)
{
@ -337,10 +322,7 @@ namespace Server.Spells
percent *= 0.01;
if (percent < 0)
percent = 0;
return percent;
return Math.Max(percent, 0);
}
public static int GetOffset(Mobile caster, Mobile target, StatType type, bool curse)
@ -453,7 +435,7 @@ namespace Server.Spells
return false;
}
return (bcTarg?.Controlled == false && bcTarg.InitialInnocent) ||
return bcTarg?.Controlled == false && bcTarg.InitialInnocent ||
Notoriety.Compute(from, to) != Notoriety.Innocent || from.Kills >= 5;
}
@ -672,10 +654,10 @@ namespace Server.Spells
int x = loc.X, y = loc.Y;
return (x >= 1182 && y >= 437 && x < 1211 && y < 470)
|| (x >= 1156 && y >= 470 && x < 1211 && y < 503)
|| (x >= 1176 && y >= 503 && x < 1208 && y < 509)
|| (x >= 1188 && y >= 509 && x < 1201 && y < 513);
return x >= 1182 && y >= 437 && x < 1211 && y < 470
|| x >= 1156 && y >= 470 && x < 1211 && y < 503
|| x >= 1176 && y >= 503 && x < 1208 && y < 509
|| x >= 1188 && y >= 509 && x < 1201 && y < 513;
}
public static bool IsSafeZone(Map map, Point3D loc) =>
@ -694,13 +676,7 @@ namespace Server.Spells
int x = loc.X, y = loc.Y;
if (x >= 426 && y >= 314 && x <= 430 && y <= 331)
return true;
if (x >= 406 && y >= 247 && x <= 410 && y <= 264)
return true;
return false;
return x >= 426 && y >= 314 && x <= 430 && y <= 331 || x >= 406 && y >= 247 && x <= 410 && y <= 264;
}
public static bool IsTokunoDungeon(Map map, Point3D loc)
@ -1132,7 +1108,7 @@ namespace Server.Spells
{
caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form.
}
else if (!caster.CanBeginAction<IncognitoSpell>() || (caster.IsBodyMod && GetContext(caster) == null))
else if (!caster.CanBeginAction<IncognitoSpell>() || caster.IsBodyMod && GetContext(caster) == null)
{
spell.DoFizzle();
}

View file

@ -42,7 +42,7 @@ namespace Server.Spells.Bushido
attacker.Hits += 20 + (int)(bushido * bushido / 480.0);
int swingBonus = Math.Max(1, (int)(bushido * bushido / 720.0));
int swingBonus = Math.Max((int)(bushido * bushido / 720.0), 1);
info = new HonorableExecutionInfo(attacker, swingBonus);
info.m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(20.0), RemovePenalty, info.m_Mobile);

View file

@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Server.Items;
namespace Server.Spells.Bushido
{
@ -19,7 +18,7 @@ namespace Server.Spells.Bushido
ClearCurrentMove(attacker);
BaseWeapon weapon = attacker.Weapon as BaseWeapon;
IWeapon weapon = attacker.Weapon;
List<Mobile> targets = attacker.GetMobilesInRange(weapon.MaxRange)
.Where(m => m != defender).Where(m => m.Combatant == attacker).ToList();

View file

@ -42,7 +42,7 @@ namespace Server.Spells.Bushido
if (Caster.Skills[CastSkill].Value < RequiredSkill)
{
string args = $"{RequiredSkill.ToString("F1")}\t{CastSkill.ToString()}\t ";
string args = $"{RequiredSkill:F1}\t{CastSkill.ToString()}\t ";
Caster.SendLocalizedMessage(1063013,
args); // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability.
return false;

View file

@ -88,13 +88,7 @@ namespace Server.Spells.Chivalry
Caster.PlaySound(0x208);
Caster.FixedParticles(0x3709, 1, 30, 9934, 0, 7, EffectLayer.Waist);
int damage = 50 - ComputePowerValue(4);
// TODO: Should caps be applied?
if (damage < 13)
damage = 13;
else if (damage > 55)
damage = 55;
int damage = Math.Clamp(50 - ComputePowerValue(4), 13, 55);
AOS.Damage(Caster, Caster, damage, 0, 100, 0, 0, 0, true);
}

View file

@ -65,7 +65,7 @@ namespace Server.Spells.Chivalry
*/
// TODO: Should caps be applied?
int toHeal = Math.Min(Math.Max(ComputePowerValue(6) + Utility.RandomMinMax(0, 2), 7), 39);
int toHeal = Math.Clamp(ComputePowerValue(6) + Utility.RandomMinMax(0, 2), 7, 39);
if (m.Hits + toHeal > m.HitsMax)
toHeal = m.HitsMax - m.Hits;

View file

@ -66,13 +66,7 @@ namespace Server.Spells.Chivalry
Effects.SendMovingParticles(from, to, itemID, 1, 0, false, false, 33, 3, 9501, 1, 0, EffectLayer.Head,
0x100);
double seconds = ComputePowerValue(20);
// TODO: Should caps be applied?
if (seconds < 3.0)
seconds = 3.0;
else if (seconds > 11.0)
seconds = 11.0;
double seconds = Math.Clamp(ComputePowerValue(20), 3.0, 11.0);
TimeSpan duration = TimeSpan.FromSeconds(seconds);

View file

@ -38,13 +38,7 @@ namespace Server.Spells.Chivalry
m_Table.TryGetValue(Caster, out Timer timer);
timer?.Stop();
int delay = ComputePowerValue(10);
// TODO: Should caps be applied?
if (delay < 7)
delay = 7;
else if (delay > 24)
delay = 24;
int delay = Math.Clamp(ComputePowerValue(10), 7, 24);
m_Table[Caster] = Timer.DelayCall(TimeSpan.FromSeconds(delay), Expire_Callback, Caster);
Caster.Delta(MobileDelta.WeaponDamage);

View file

@ -37,13 +37,7 @@ namespace Server.Spells.Chivalry
m_Table.TryGetValue(Caster, out Timer timer);
timer?.Stop();
double delay = (double)ComputePowerValue(1) / 60;
// TODO: Should caps be applied?
if (delay < 1.5)
delay = 1.5;
else if (delay > 3.5)
delay = 3.5;
double delay = Math.Clamp(ComputePowerValue(1) / 60.0, 1.5, 3.5);
m_Table[Caster] = Timer.DelayCall(TimeSpan.FromMinutes(delay), Expire_Callback, Caster);

View file

@ -45,13 +45,7 @@ namespace Server.Spells.Chivalry
foreach (Mobile m in targets)
{
int damage = ComputePowerValue(10) + Utility.RandomMinMax(0, 2);
// TODO: Should caps be applied?
if (damage < 8)
damage = 8;
else if (damage > 24)
damage = 24;
int damage = Math.Clamp(ComputePowerValue(10) + Utility.RandomMinMax(0, 2), 8, 24);
Caster.DoHarmful(m);
SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 100);

View file

@ -92,13 +92,7 @@ namespace Server.Spells.Chivalry
if (m.Hits < m.HitsMax)
{
int toHeal = ComputePowerValue(10) + Utility.RandomMinMax(0, 2);
// TODO: Should caps be applied?
if (toHeal < 8)
toHeal = 8;
else if (toHeal > 24)
toHeal = 24;
int toHeal = Math.Clamp(ComputePowerValue(10) + Utility.RandomMinMax(0, 2), 8, 24);
Caster.DoBeneficial(m);
m.Heal(toHeal, Caster);

View file

@ -48,7 +48,8 @@ namespace Server.Spells.Eighth
damage = m.Hits / 2;
if (!m.Player)
damage = Math.Max(Math.Min(damage, 100), 15);
damage = Math.Clamp(damage, 15, 100);
damage += Utility.RandomMinMax(0, 15);
}
else

View file

@ -56,10 +56,7 @@ namespace Server.Spells.Fifth
if (!m.Player)
secs *= 3;
if (secs < 0)
secs = 0;
duration = secs;
duration = Math.Max(secs, 0);
}
else
{

View file

@ -1,3 +1,4 @@
using System;
using Server.Targeting;
namespace Server.Spells.First
@ -37,15 +38,13 @@ namespace Server.Spells.First
if (targ.BeginAction<LightCycle>())
{
new LightCycle.NightSightTimer(targ).Start();
int level = (int)(LightCycle.DungeonLevel *
((Core.AOS
? targ.Skills.Magery.Value
: from.Skills.Magery.Value) / 100));
int level =
(int)(LightCycle.DungeonLevel *
((Core.AOS
? targ.Skills.Magery.Value
: from.Skills.Magery.Value) / 100));
if (level < 0)
level = 0;
targ.LightLevel = level;
targ.LightLevel = Math.Max(level, 0);
targ.FixedParticles(0x376A, 9, 32, 5007, EffectLayer.Waist);
targ.PlaySound(0x1E3);

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
namespace Server.Spells.First
@ -111,14 +112,10 @@ namespace Server.Spells.First
{
if (Caster.BeginAction<DefensiveSpell>())
{
int value = (int)(Caster.Skills.Magery.Value + Caster.Skills.Meditation.Value +
Caster.Skills.Inscribe.Value);
value /= 3;
if (value < 0)
value = 1;
else if (value > 75)
value = 75;
int value = Math.Clamp(
(int)(Caster.Skills.Magery.Value + Caster.Skills.Meditation.Value +
Caster.Skills.Inscribe.Value) / 3, 1, 75
);
Caster.MeleeDamageAbsorb = value;

View file

@ -99,9 +99,7 @@ namespace Server.Spells.Fourth
{
_Table.Remove(m);
m.EndAction<ArchProtectionSpell>();
m.VirtualArmorMod -= v;
if (m.VirtualArmorMod < 0)
m.VirtualArmorMod = 0;
m.VirtualArmorMod -= Math.Min(v, m.VirtualArmorMod);
}
}

View file

@ -59,12 +59,7 @@ namespace Server.Spells.Fourth
if (Core.AOS)
{
int toDrain = 40 + (int)(GetDamageSkill(Caster) - GetResistSkill(m));
if (toDrain < 0)
toDrain = 0;
else if (toDrain > m.Mana)
toDrain = m.Mana;
int toDrain = Math.Clamp(40 + (int)(GetDamageSkill(Caster) - GetResistSkill(m)), 0, m.Mana);
if (m_Table.Contains(m))
toDrain = 0;
@ -77,7 +72,7 @@ namespace Server.Spells.Fourth
m.Mana -= toDrain;
m_Table.Add(m);
Timer.DelayCall(TimeSpan.FromSeconds(5.0), () => AosDelay_Callback(m, toDrain));
Timer.DelayCall(TimeSpan.FromSeconds(5.0), AosDelay_Callback, m, toDrain);
}
}
else

View file

@ -34,13 +34,8 @@ namespace Server.Spells
Disturb(DisturbType.Hurt, false);
}
public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable)
{
if (type == DisturbType.EquipRequest || type == DisturbType.UseRequest /* || type == DisturbType.Hurt*/)
return false;
return true;
}
public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) =>
type != DisturbType.EquipRequest && type != DisturbType.UseRequest;
public override void DoHurtFizzle()
{
@ -67,4 +62,4 @@ namespace Server.Spells
FinishSequence();
}
}
}
}

View file

@ -163,8 +163,8 @@ namespace Server.Spells.Necromancy
if (c.Owner != null) type = c.Owner.GetType();
if (c.ItemID != 0x2006 || c.Animated || type == typeof(PlayerMobile) || type == null ||
(c.Owner != null && c.Owner.Fame < 100) ||
(c.Owner is BaseCreature creature && (creature.Summoned || creature.IsBonded)))
c.Owner != null && c.Owner.Fame < 100 ||
c.Owner is BaseCreature creature && (creature.Summoned || creature.IsBonded))
{
Caster.SendLocalizedMessage(1061085); // There's not enough life force there to animate.
}
@ -236,7 +236,7 @@ namespace Server.Spells.Necromancy
list.Add(summoned);
if (list.Count > 3)
Timer.DelayCall(TimeSpan.Zero, list[0].Kill);
Timer.DelayCall(list[0].Kill);
Timer.DelayCall(TimeSpan.FromSeconds(2.0), TimeSpan.FromSeconds(2.0), Summoned_Damage, summoned);
}
@ -262,18 +262,8 @@ namespace Server.Spells.Necromancy
double necromancy = caster.Skills.Necromancy.Value;
double spiritSpeak = caster.Skills.SpiritSpeak.Value;
int casterAbility = 0;
casterAbility += (int)(necromancy * 30);
casterAbility += (int)(spiritSpeak * 70);
casterAbility /= 10;
casterAbility *= 18;
if (casterAbility > owner.Fame)
casterAbility = owner.Fame;
if (casterAbility < 0)
casterAbility = 0;
int casterAbility = (int)(necromancy * 30) + (int)(spiritSpeak * 70);
casterAbility = Math.Clamp(casterAbility / 10 * 18, 0, owner.Fame);
Type toSummon = null;
SummonEntry[] entries = group.m_Entries;
@ -287,8 +277,7 @@ namespace Server.Spells.Necromancy
Type[] animates = entry.m_ToSummon;
if (animates.Length >= 0)
toSummon = animates[Utility.Random(animates.Length)];
toSummon = animates[Utility.Random(animates.Length)];
}
if (toSummon == null)

View file

@ -41,17 +41,8 @@ namespace Server.Spells.Necromancy
max = Scroll != null ? min : RequiredSkill + 40.0;
}
public override bool ConsumeReagents()
{
if (base.ConsumeReagents())
return true;
if (ArcaneGem.ConsumeCharges(Caster, 1))
return true;
return false;
}
public override bool ConsumeReagents() => base.ConsumeReagents() || ArcaneGem.ConsumeCharges(Caster, 1);
public override int GetMana() => RequiredMana;
}
}
}

View file

@ -52,12 +52,9 @@ namespace Server.Spells.Necromancy
m.FixedParticles(0x37C4, 1, 8, 9502, 39, 4, EffectLayer.Head);
m.PlaySound(0x210);
double damage = (GetDamageSkill(Caster) - GetResistSkill(m)) / 10 + (m.Player ? 18 : 30);
double damage = Math.Max((GetDamageSkill(Caster) - GetResistSkill(m)) / 10 + (m.Player ? 18 : 30), 1);
m.CheckSkill(SkillName.MagicResist, 0.0, 120.0); // Skill check for gain
if (damage < 1)
damage = 1;
TimeSpan buffTime = TimeSpan.FromSeconds(10.0);
if (!m_Table.TryGetValue(m, out InternalTimer timer))

View file

@ -30,13 +30,7 @@ namespace Server.Spells.Necromancy
{
}
public override bool CheckCast()
{
if (!TransformationSpellHelper.CheckCast(Caster, this))
return false;
return base.CheckCast();
}
public override bool CheckCast() => TransformationSpellHelper.CheckCast(Caster, this) && base.CheckCast();
public override void OnCast()
{
@ -45,4 +39,4 @@ namespace Server.Spells.Necromancy
FinishSequence();
}
}
}
}

View file

@ -114,7 +114,7 @@ namespace Server.Spells.Ninjitsu
double baseDamage = ninjitsu / divisor * 10;
int maxDamage = info.m_Steps >= 5 ? 62 : 22;
damage = Math.Max(0, Math.Min(maxDamage, (int)(baseDamage + stalkingBonus))) + info.m_DamageBonus;
damage = Math.Clamp((int)(baseDamage + stalkingBonus), 0, maxDamage) + info.m_DamageBonus;
}
if (Core.ML)

View file

@ -12,7 +12,7 @@ namespace Server.Spells.Ninjitsu
public override bool Validate(Mobile from)
{
if (from.FindItemOnLayer(Layer.TwoHanded) as BaseShield != null)
if (from.FindItemOnLayer(Layer.TwoHanded) is BaseShield)
{
from.SendLocalizedMessage(1063096); // You cannot use this ability while holding a shield.
return false;
@ -60,4 +60,4 @@ namespace Server.Spells.Ninjitsu
CheckGain(attacker);
}
}
}
}

View file

@ -34,7 +34,7 @@ namespace Server.Spells.Second
}
else if (cont.TrapType != TrapType.None && cont.TrapType != TrapType.MagicTrap)
{
this.DoFizzle();
DoFizzle();
}
else if (CheckSequence())
{

View file

@ -131,12 +131,7 @@ namespace Server.Spells.Second
Caster.Skills.Inscribe.Value);
value /= 4;
if (value < 0)
value = 0;
else if (value > 75)
value = 75.0;
Registry.Add(Caster, value);
Registry.Add(Caster, Math.Clamp(value, 0.0, 75.0));
new InternalTimer(Caster).Start();
Caster.FixedParticles(0x375A, 9, 20, 5016, EffectLayer.Waist);
@ -158,11 +153,7 @@ namespace Server.Spells.Second
public InternalTimer(Mobile caster) : base(TimeSpan.FromSeconds(0))
{
double val = caster.Skills.Magery.Value * 2.0;
if (val < 15)
val = 15;
else if (val > 240)
val = 240;
double val = Math.Clamp(caster.Skills.Magery.Value * 2.0, 15, 240);
m_Caster = caster;
Delay = TimeSpan.FromSeconds(val);

View file

@ -34,7 +34,7 @@ namespace Server.Spells.Second
}
else if (cont.TrapType != TrapType.None && cont.TrapType != TrapType.MagicTrap)
{
this.DoFizzle();
DoFizzle();
}
else if (CheckSequence())
{

View file

@ -1,3 +1,4 @@
using System;
using Server.Targeting;
namespace Server.Spells.Seventh
@ -49,11 +50,6 @@ namespace Server.Spells.Seventh
if (!m.Player)
toDrain /= 2;
if (toDrain < 0)
toDrain = 0;
else if (toDrain > m.Mana)
toDrain = m.Mana;
}
else
{
@ -63,10 +59,7 @@ namespace Server.Spells.Seventh
toDrain = m.Mana;
}
if (toDrain > Caster.ManaMax - Caster.Mana)
toDrain = Caster.ManaMax - Caster.Mana;
m.Mana -= toDrain;
m.Mana -= Math.Clamp(toDrain, 0, Math.Min(m.Mana, Caster.ManaMax - Caster.Mana));
Caster.Mana += toDrain;
if (Core.AOS)

View file

@ -169,14 +169,11 @@ namespace Server.Spells.Sixth
if (Core.AOS)
{
duration = 2.0 + ((int)(m_Caster.Skills.EvalInt.Value / 10) -
(int)(m.Skills.MagicResist.Value / 10));
duration = Math.Max(
2.0 + ((int)(m_Caster.Skills.EvalInt.Value / 10) - (int)(m.Skills.MagicResist.Value / 10)), 0.0);
if (!m.Player)
duration *= 3.0;
if (duration < 0.0)
duration = 0.0;
}
else
{

View file

@ -55,7 +55,7 @@ namespace Server.Mobiles
public override void MoveToWorld(Point3D loc, Map map)
{
base.MoveToWorld(loc, map);
Timer.DelayCall(TimeSpan.Zero, DoEffects);
Timer.DelayCall(DoEffects);
}
public void DoEffects()
@ -82,4 +82,4 @@ namespace Server.Mobiles
Delete();
}
}
}
}

View file

@ -33,14 +33,9 @@ namespace Server.Spells.Spellweaving
int sdiBonus = AosAttributes.GetValue(Caster, AosAttribute.SpellDamage);
int pvmDamage = damage * (100 + sdiBonus);
pvmDamage /= 100;
int pvmDamage = damage * (100 + sdiBonus) / 100;
if (sdiBonus > 15)
sdiBonus = 15;
int pvpDamage = damage * (100 + sdiBonus);
pvpDamage /= 100;
int pvpDamage = damage * (100 + Math.Min(sdiBonus, 15)) / 100;
int range = 2 + FocusLevel;
TimeSpan duration = TimeSpan.FromSeconds(5 + FocusLevel);