Code cleanup (#188)
This commit is contained in:
parent
df53c16620
commit
010fd9402a
185 changed files with 1052 additions and 1271 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue