Modernization Fixes & Updates to Default Values (#3)

This commit is contained in:
Kamron Batman 2018-10-28 00:33:16 -07:00 committed by GitHub
parent 445eddff68
commit dcf64091b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
768 changed files with 10507 additions and 14196 deletions

View file

@ -140,7 +140,7 @@ namespace Server.Spells.Necromancy
if (qs is DarkTidesQuest)
{
QuestObjective objective = qs.FindObjective(typeof(AnimateMaabusCorpseObjective));
QuestObjective objective = qs.FindObjective<AnimateMaabusCorpseObjective>();
if (objective != null && !objective.Completed)
{
@ -189,8 +189,8 @@ namespace Server.Spells.Necromancy
Effects.SendLocationParticles(EffectItem.Create(p, map, EffectItem.DefaultDuration), 0x3789,
1, 40, 0x3F, 3, 9907, 0);
Timer.DelayCall(TimeSpan.FromSeconds(2.0), new TimerStateCallback(SummonDelay_Callback),
new object[] { Caster, c, p, map, group });
Timer.DelayCall(TimeSpan.FromSeconds(2.0),
() => SummonDelay_Callback(Caster, c, p, map, group));
}
}
}
@ -242,30 +242,19 @@ namespace Server.Spells.Necromancy
if (list.Count > 3)
Timer.DelayCall(TimeSpan.Zero, list[0].Kill);
Timer.DelayCall(TimeSpan.FromSeconds(2.0), TimeSpan.FromSeconds(2.0), new TimerStateCallback(Summoned_Damage),
summoned);
Timer.DelayCall(TimeSpan.FromSeconds(2.0), TimeSpan.FromSeconds(2.0), Summoned_Damage, summoned);
}
private static void Summoned_Damage(object state)
private static void Summoned_Damage(Mobile mob)
{
Mobile mob = (Mobile)state;
if (mob.Hits > 0)
--mob.Hits;
else
mob.Kill();
}
private static void SummonDelay_Callback(object state)
private static void SummonDelay_Callback(Mobile caster, Corpse corpse, Point3D loc, Map map, CreatureGroup group)
{
object[] states = (object[])state;
Mobile caster = (Mobile)states[0];
Corpse corpse = (Corpse)states[1];
Point3D loc = (Point3D)states[2];
Map map = (Map)states[3];
CreatureGroup group = (CreatureGroup)states[4];
if (corpse.Animated)
return;
@ -274,8 +263,8 @@ namespace Server.Spells.Necromancy
if (owner == null)
return;
double necromancy = caster.Skills[SkillName.Necromancy].Value;
double spiritSpeak = caster.Skills[SkillName.SpiritSpeak].Value;
double necromancy = caster.Skills.Necromancy.Value;
double spiritSpeak = caster.Skills.SpiritSpeak.Value;
int casterAbility = 0;

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Mobiles;
using Server.Targeting;
@ -14,8 +15,8 @@ namespace Server.Spells.Necromancy
Reagent.DaemonBlood
);
private static Hashtable m_OathTable = new Hashtable();
private static Hashtable m_Table = new Hashtable();
private static Dictionary<Mobile, Mobile> m_OathTable = new Dictionary<Mobile, Mobile>();
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>();
public BloodOathSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
{
@ -38,11 +39,11 @@ namespace Server.Spells.Necromancy
{
Caster.SendLocalizedMessage(1060508); // You can't curse that.
}
else if (m_OathTable.Contains(Caster))
else if (m_OathTable.ContainsKey(Caster))
{
Caster.SendLocalizedMessage(1061607); // You are already bonded in a Blood Oath.
}
else if (m_OathTable.Contains(m))
else if (m_OathTable.ContainsKey(m))
{
if (m.Player)
Caster.SendLocalizedMessage(1061608); // That player is already bonded in a Blood Oath.
@ -61,7 +62,7 @@ namespace Server.Spells.Necromancy
* ((ss-rm)/8)+8
*/
ExpireTimer timer = (ExpireTimer)m_Table[m];
ExpireTimer timer = m_Table[m];
timer?.DoExpire();
m_OathTable[Caster] = Caster;
@ -93,15 +94,10 @@ namespace Server.Spells.Necromancy
FinishSequence();
}
public static bool RemoveCurse(Mobile m)
public static void RemoveCurse(Mobile m)
{
ExpireTimer t = (ExpireTimer)m_Table[m];
if (t == null)
return false;
t.DoExpire();
return true;
ExpireTimer t = m_Table[m];
t?.DoExpire();
}
public static Mobile GetBloodOath(Mobile m)
@ -109,12 +105,8 @@ namespace Server.Spells.Necromancy
if (m == null)
return null;
Mobile oath = (Mobile)m_OathTable[m];
if (oath == m)
oath = null;
return oath;
Mobile oath = m_OathTable[m];
return oath == m ? null : oath;
}
private class ExpireTimer : Timer
@ -141,13 +133,13 @@ namespace Server.Spells.Necromancy
public void DoExpire()
{
if (m_OathTable.Contains(m_Caster))
if (m_OathTable.ContainsKey(m_Caster))
{
m_Caster.SendLocalizedMessage(1061620); // Your Blood Oath has been broken.
m_OathTable.Remove(m_Caster);
}
if (m_OathTable.Contains(m_Target))
if (m_OathTable.ContainsKey(m_Target))
{
m_Target.SendLocalizedMessage(1061620); // Your Blood Oath has been broken.
m_OathTable.Remove(m_Target);
@ -185,4 +177,4 @@ namespace Server.Spells.Necromancy
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Targeting;
namespace Server.Spells.Necromancy
@ -14,7 +15,7 @@ namespace Server.Spells.Necromancy
Reagent.GraveDust
);
private static Hashtable m_Table = new Hashtable();
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>();
public CorpseSkinSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
{
@ -48,7 +49,7 @@ namespace Server.Spells.Necromancy
* NOTE: Resistance is not checked if targeting yourself
*/
ExpireTimer timer = (ExpireTimer)m_Table[m];
ExpireTimer timer = m_Table[m];
if (timer != null)
timer.DoExpire();
@ -66,8 +67,7 @@ namespace Server.Spells.Necromancy
TimeSpan duration = TimeSpan.FromSeconds((ss - mr) / 2.5 + 40.0);
ResistanceMod[] mods = new ResistanceMod[4]
{
ResistanceMod[] mods = {
new ResistanceMod(ResistanceType.Fire, -15),
new ResistanceMod(ResistanceType.Poison, -15),
new ResistanceMod(ResistanceType.Cold, +10),
@ -92,7 +92,7 @@ namespace Server.Spells.Necromancy
public static bool RemoveCurse(Mobile m)
{
ExpireTimer t = (ExpireTimer)m_Table[m];
ExpireTimer t = m_Table[m];
if (t == null)
return false;
@ -151,4 +151,4 @@ namespace Server.Spells.Necromancy
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Items;
namespace Server.Spells.Necromancy
@ -13,7 +14,7 @@ namespace Server.Spells.Necromancy
Reagent.PigIron
);
private static Hashtable m_Table = new Hashtable();
private static Dictionary<BaseWeapon, ExpireTimer> m_Table = new Dictionary<BaseWeapon, ExpireTimer>();
public CurseWeaponSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
{
@ -47,18 +48,17 @@ namespace Server.Spells.Necromancy
Caster.FixedParticles(0x37B9, 1, 14, 9502, 32, 5, (EffectLayer)255);
new SoundEffectTimer(Caster).Start();
TimeSpan duration = TimeSpan.FromSeconds(Caster.Skills[SkillName.SpiritSpeak].Value / 3.4 + 1.0);
TimeSpan duration = TimeSpan.FromSeconds(Caster.Skills.SpiritSpeak.Value / 3.4 + 1.0);
Timer t = (Timer)m_Table[weapon];
t?.Stop();
ExpireTimer timer = m_Table[weapon];
timer?.Stop();
weapon.Cursed = true;
m_Table[weapon] = t = new ExpireTimer(weapon, duration);
m_Table[weapon] = timer = new ExpireTimer(weapon, duration);
t.Start();
timer.Start();
}
FinishSequence();
@ -78,7 +78,7 @@ namespace Server.Spells.Necromancy
{
m_Weapon.Cursed = false;
Effects.PlaySound(m_Weapon.GetWorldLocation(), m_Weapon.Map, 0xFA);
m_Table.Remove(this);
m_Table.Remove(m_Weapon);
}
}
@ -98,4 +98,4 @@ namespace Server.Spells.Necromancy
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Mobiles;
using Server.Targeting;
@ -15,7 +16,7 @@ namespace Server.Spells.Necromancy
Reagent.NoxCrystal
);
private static Hashtable m_Table = new Hashtable();
private static Dictionary<Mobile, DefaultSkillMod> m_Table = new Dictionary<Mobile, DefaultSkillMod>();
public EvilOmenSpell(Mobile caster, Item scroll)
: base(caster, scroll, m_Info)
@ -56,19 +57,19 @@ namespace Server.Spells.Necromancy
m.FixedParticles(0x3728, 1, 13, 9912, 1150, 7, EffectLayer.Head);
m.FixedParticles(0x3779, 1, 15, 9502, 67, 7, EffectLayer.Head);
if (!m_Table.Contains(m))
if (!m_Table.ContainsKey(m))
{
SkillMod mod = new DefaultSkillMod(SkillName.MagicResist, false, 50.0);
DefaultSkillMod mod = new DefaultSkillMod(SkillName.MagicResist, false, 50.0);
if (m.Skills[SkillName.MagicResist].Base > 50.0)
if (m.Skills.MagicResist.Base > 50.0)
m.AddSkillMod(mod);
m_Table[m] = mod;
}
TimeSpan duration = TimeSpan.FromSeconds(Caster.Skills[SkillName.SpiritSpeak].Value / 12 + 1.0);
TimeSpan duration = TimeSpan.FromSeconds(Caster.Skills.SpiritSpeak.Value / 12 + 1.0);
Timer.DelayCall(duration, new TimerStateCallback(EffectExpire_Callback), m);
Timer.DelayCall(duration, () => TryEndEffect(m));
HarmfulSpell(m);
@ -78,14 +79,9 @@ namespace Server.Spells.Necromancy
FinishSequence();
}
private static void EffectExpire_Callback(object state)
{
TryEndEffect((Mobile)state);
}
/*
* The naming here was confusing. Its a 1-off effect spell.
* So, we dont actually "checkeffect"; we endeffect with bool
* So, we don't actually "checkeffect"; we endeffect with bool
* return to determine external behaviors.
*
* -refactored.
@ -93,7 +89,7 @@ namespace Server.Spells.Necromancy
public static bool TryEndEffect(Mobile m)
{
SkillMod mod = (SkillMod)m_Table[m];
DefaultSkillMod mod = m_Table[m];
if (mod == null)
return false;
@ -128,4 +124,4 @@ namespace Server.Spells.Necromancy
}
}
}
}
}

View file

@ -87,7 +87,8 @@ namespace Server.Spells.Necromancy
public override void OnCast()
{
if (!(Caster.Region.GetRegion(typeof(ChampionSpawnRegion)) is ChampionSpawnRegion r) || !Caster.InRange(r.ChampionSpawn, Range))
ChampionSpawnRegion r = Caster.Region.GetRegion<ChampionSpawnRegion>();
if (r == null || !Caster.InRange(r.ChampionSpawn, Range))
{
Caster.SendLocalizedMessage(1072111); // You are not in a valid exorcism region.
}
@ -130,7 +131,7 @@ namespace Server.Spells.Necromancy
if (SpellHelper.IsAnyT2A(map, c.Location) && SpellHelper.IsAnyT2A(map, m.Location))
return false; //Same Map, both in T2A, ie, same 'sub server'.
if (m.Region.IsPartOf(typeof(DungeonRegion)) == Region.Find(c.Location, map).IsPartOf(typeof(DungeonRegion)))
if (m.Region.IsPartOf<DungeonRegion>() == Region.Find(c.Location, map).IsPartOf<DungeonRegion>())
return false; //Same Map, both in Dungeon region OR They're both NOT in a dungeon region.
//Just an approximation cause RunUO doens't divide up the world the same way OSI does ;p

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Targeting;
namespace Server.Spells.Necromancy
@ -15,7 +16,7 @@ namespace Server.Spells.Necromancy
Reagent.DaemonBlood
);
private static Hashtable m_Table = new Hashtable();
private static Dictionary<Mobile, MRBucket> m_Table = new Dictionary<Mobile, MRBucket>();
public MindRotSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
{
@ -70,13 +71,13 @@ namespace Server.Spells.Necromancy
public static void ClearMindRotScalar(Mobile m)
{
if (!m_Table.ContainsKey(m))
MRBucket tmpB = m_Table[m];
if (tmpB == null)
return;
BuffInfo.RemoveBuff(m, BuffIcon.Mindrot);
MRBucket tmpB = (MRBucket)m_Table[m];
MRExpireTimer tmpT = tmpB.m_MRExpireTimer;
tmpT.Stop();
tmpB.m_MRExpireTimer.Stop();
m_Table.Remove(m);
m.SendLocalizedMessage(1060872); // Your mind feels normal again.
}
@ -88,10 +89,11 @@ namespace Server.Spells.Necromancy
public static bool GetMindRotScalar(Mobile m, ref double scalar)
{
if (!m_Table.ContainsKey(m))
MRBucket tmpB = m_Table[m];
if (tmpB == null)
return false;
MRBucket tmpB = (MRBucket)m_Table[m];
scalar = tmpB.m_Scalar;
return true;
}
@ -100,11 +102,10 @@ namespace Server.Spells.Necromancy
{
if (!m_Table.ContainsKey(target))
{
m_Table.Add(target, new MRBucket(scalar, new MRExpireTimer(caster, target, duration)));
MRBucket tmpB = new MRBucket(scalar, new MRExpireTimer(caster, target, duration));
m_Table.Add(target, tmpB);
BuffInfo.AddBuff(target, new BuffInfo(BuffIcon.Mindrot, 1075665, duration, target));
MRBucket tmpB = (MRBucket)m_Table[target];
MRExpireTimer tmpT = tmpB.m_MRExpireTimer;
tmpT.Start();
tmpB.m_MRExpireTimer.Start();
target.SendLocalizedMessage(1074384);
}
}
@ -146,16 +147,6 @@ namespace Server.Spells.Necromancy
Priority = TimerPriority.TwoFiftyMS;
}
public void RenewDelay(TimeSpan delay)
{
m_End = DateTime.UtcNow + delay;
}
public void Halt()
{
Stop();
}
protected override void OnTick()
{
if (m_Target.Deleted || !m_Target.Alive || DateTime.UtcNow >= m_End)
@ -178,4 +169,4 @@ namespace Server.Spells.Necromancy
m_MRExpireTimer = theTimer;
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Misc;
using Server.Targeting;
@ -15,7 +16,7 @@ namespace Server.Spells.Necromancy
Reagent.PigIron
);
private static Hashtable m_Table = new Hashtable();
private static Dictionary<Mobile, InternalTimer> m_Table = new Dictionary<Mobile, InternalTimer>();
public PainSpikeSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
{
@ -58,20 +59,18 @@ namespace Server.Spells.Necromancy
TimeSpan buffTime = TimeSpan.FromSeconds(10.0);
if (m_Table.Contains(m))
InternalTimer timer = m_Table[m];
if (timer == null)
{
damage = Utility.RandomMinMax(3, 7);
if (m_Table[m] is Timer t)
{
t.Delay += TimeSpan.FromSeconds(2.0);
buffTime = t.Next - DateTime.UtcNow;
}
m_Table[m] = timer = new InternalTimer(m, damage);
timer.Start();
}
else
{
new InternalTimer(m, damage).Start();
damage = Utility.RandomMinMax(3, 7);
timer.Delay += TimeSpan.FromSeconds(2.0);
buffTime = timer.Next - DateTime.UtcNow;
}
BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.PainSpike, 1075667, buffTime, m, Convert.ToString((int)damage)));
@ -100,8 +99,6 @@ namespace Server.Spells.Necromancy
m_Mobile = m;
m_ToRestore = (int)toRestore;
m_Table[m] = this;
}
protected override void OnTick()
@ -136,4 +133,4 @@ namespace Server.Spells.Necromancy
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Targeting;
namespace Server.Spells.Necromancy
@ -14,7 +15,7 @@ namespace Server.Spells.Necromancy
Reagent.NoxCrystal
);
private static Hashtable m_Table = new Hashtable();
private static Dictionary<Mobile, InternalTimer> m_Table = new Dictionary<Mobile, InternalTimer>();
public StrangleSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
{
@ -58,19 +59,19 @@ namespace Server.Spells.Necromancy
m.FixedParticles(0x36CB, 1, 9, 9911, 67, 5, EffectLayer.Head);
m.FixedParticles(0x374A, 1, 17, 9502, 1108, 4, (EffectLayer)255);
if (!m_Table.Contains(m))
{
Timer t = new InternalTimer(m, Caster);
t.Start();
InternalTimer timer = m_Table[m];
m_Table[m] = t;
if (timer == null)
{
m_Table[m] = timer = new InternalTimer(m, Caster);
timer.Start();
}
HarmfulSpell(m);
}
//Calculations for the buff bar
double spiritlevel = Caster.Skills[SkillName.SpiritSpeak].Value / 10;
double spiritlevel = Caster.Skills.SpiritSpeak.Value / 10;
if (spiritlevel < 4)
spiritlevel = 4;
int d_MinDamage = 4;
@ -95,10 +96,7 @@ namespace Server.Spells.Necromancy
{
int delay = (int)Math.Ceiling((1.0 + 5 * i_Count) / i_MaxCount);
if (delay <= 5)
i_HitDelay = delay;
else
i_HitDelay = 5;
i_HitDelay = delay <= 5 ? delay : 5;
}
}
@ -113,12 +111,12 @@ namespace Server.Spells.Necromancy
public static bool RemoveCurse(Mobile m)
{
Timer t = (Timer)m_Table[m];
Timer timer = m_Table[m];
if (t == null)
if (timer == null)
return false;
t.Stop();
timer.Stop();
m.SendLocalizedMessage(1061687); // You can breath normally again.
m_Table.Remove(m);
@ -141,7 +139,7 @@ namespace Server.Spells.Necromancy
m_Target = target;
m_From = from;
double spiritLevel = from.Skills[SkillName.SpiritSpeak].Value / 10;
double spiritLevel = from.Skills.SpiritSpeak.Value / 10;
m_MinBaseDamage = spiritLevel - 2;
m_MaxBaseDamage = spiritLevel + 1;
@ -237,4 +235,4 @@ namespace Server.Spells.Necromancy
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
@ -26,7 +27,7 @@ namespace Server.Spells.Necromancy
public override double RequiredSkill => 30.0;
public override int RequiredMana => 17;
public static Hashtable Table{ get; } = new Hashtable();
public static Dictionary<Mobile, BaseCreature> Table{ get; } = new Dictionary<Mobile, BaseCreature>();
public static SummonFamiliarEntry[] Entries{ get; } =
{
@ -39,9 +40,9 @@ namespace Server.Spells.Necromancy
public override bool CheckCast()
{
BaseCreature check = (BaseCreature)Table[Caster];
BaseCreature check = Table[Caster];
if (check != null && !check.Deleted)
if (check?.Deleted == false)
{
Caster.SendLocalizedMessage(1061605); // You already have a familiar.
return false;
@ -54,7 +55,7 @@ namespace Server.Spells.Necromancy
{
if (CheckSequence())
{
Caster.CloseGump(typeof(SummonFamiliarGump));
Caster.CloseGump<SummonFamiliarGump>();
Caster.SendGump(new SummonFamiliarGump(Caster, Entries, this));
}
@ -89,7 +90,6 @@ namespace Server.Spells.Necromancy
private const int EnabledColor32 = 0x18CD00;
private const int DisabledColor32 = 0x4A8B52;
private static Hashtable m_Table = new Hashtable();
private SummonFamiliarEntry[] m_Entries;
private Mobile m_From;
@ -117,8 +117,8 @@ namespace Server.Spells.Necromancy
AddHtmlLocalized(30, 26, 200, 20, 1060147, EnabledColor16, false, false); // Chose thy familiar...
double necro = from.Skills[SkillName.Necromancy].Value;
double spirit = from.Skills[SkillName.SpiritSpeak].Value;
double necro = from.Skills.Necromancy.Value;
double spirit = from.Skills.SpiritSpeak.Value;
for (int i = 0; i < entries.Length; ++i)
{
@ -146,10 +146,10 @@ namespace Server.Spells.Necromancy
{
SummonFamiliarEntry entry = m_Entries[index];
double necro = m_From.Skills[SkillName.Necromancy].Value;
double spirit = m_From.Skills[SkillName.SpiritSpeak].Value;
double necro = m_From.Skills.Necromancy.Value;
double spirit = m_From.Skills.SpiritSpeak.Value;
BaseCreature check = (BaseCreature)SummonFamiliarSpell.Table[m_From];
BaseCreature check = SummonFamiliarSpell.Table[m_From];
#region Dueling
@ -160,7 +160,7 @@ namespace Server.Spells.Necromancy
#endregion
else if (check != null && !check.Deleted)
else if (check?.Deleted == false)
{
m_From.SendLocalizedMessage(1061605); // You already have a familiar.
}
@ -169,14 +169,14 @@ namespace Server.Spells.Necromancy
// That familiar requires ~1_NECROMANCY~ Necromancy and ~2_SPIRIT~ Spirit Speak.
m_From.SendLocalizedMessage(1061606, $"{entry.ReqNecromancy:F1}\t{entry.ReqSpiritSpeak:F1}");
m_From.CloseGump(typeof(SummonFamiliarGump));
m_From.CloseGump<SummonFamiliarGump>();
m_From.SendGump(new SummonFamiliarGump(m_From, SummonFamiliarSpell.Entries, m_Spell));
}
else if (entry.Type == null)
{
m_From.SendMessage("That familiar has not yet been defined.");
m_From.CloseGump(typeof(SummonFamiliarGump));
m_From.CloseGump<SummonFamiliarGump>();
m_From.SendGump(new SummonFamiliarGump(m_From, SummonFamiliarSpell.Entries, m_Spell));
}
else
@ -185,7 +185,8 @@ namespace Server.Spells.Necromancy
{
BaseCreature bc = (BaseCreature)Activator.CreateInstance(entry.Type);
bc.Skills.MagicResist = m_From.Skills.MagicResist;
// TODO: Is this right?
bc.Skills.MagicResist.Base = m_From.Skills.MagicResist.Base;
if (BaseCreature.Summon(bc, m_From, m_From.Location, -1, TimeSpan.FromDays(1.0)))
{
@ -196,6 +197,7 @@ namespace Server.Spells.Necromancy
}
catch
{
// ignored
}
}
}
@ -205,4 +207,4 @@ namespace Server.Spells.Necromancy
}
}
}
}
}