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

@ -172,7 +172,7 @@ namespace Server.Items
{
if (from.AccessLevel == AccessLevel.Player || !from.Hidden)
from.Send(new PlaySound(0x20E, from.Location));
from.CloseGump(typeof(MoongateConfirmGump));
from.CloseGump<MoongateConfirmGump>();
from.SendGump(new MoongateConfirmGump(from, this));
}
else
@ -205,7 +205,7 @@ namespace Server.Items
if (map == null)
return false;
GuardedRegion reg = (GuardedRegion)Region.Find(p, map).GetRegion(typeof(GuardedRegion));
GuardedRegion reg = Region.Find(p, map).GetRegion<GuardedRegion>();
return reg != null && !reg.IsDisabled();
}
@ -267,7 +267,7 @@ namespace Server.Items
[CommandProperty(AccessLevel.GameMaster)]
public string MessageString{ get; set; }
public virtual void Warning_Callback(Mobile from, bool okay, object state)
public virtual void Warning_Callback(Mobile from, bool okay)
{
if (okay)
EndConfirmation(from);
@ -277,10 +277,10 @@ namespace Server.Items
{
if (GumpWidth > 0 && GumpHeight > 0 && TitleNumber > 0 && (MessageNumber > 0 || MessageString != null))
{
from.CloseGump(typeof(WarningGump));
from.CloseGump<WarningGump>();
from.SendGump(new WarningGump(TitleNumber, TitleColor,
MessageString == null ? MessageNumber : (object)MessageString, MessageColor, GumpWidth, GumpHeight,
Warning_Callback, from));
okay => Warning_Callback(from, okay)));
}
else
{

View file

@ -66,13 +66,6 @@ namespace Server.Items
int version = reader.ReadInt();
}
public void Explode_Callback(object state)
{
object[] states = (object[])state;
Explode((Mobile)states[0], (Point3D)states[1], (Map)states[2]);
}
public virtual void Explode(Mobile from, Point3D loc, Map map)
{
if (Deleted || map == null)
@ -129,9 +122,8 @@ namespace Server.Items
else
to = new Entity(Serial.Zero, new Point3D(p), from.Map);
Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue, 0);
Timer.DelayCall(TimeSpan.FromSeconds(1.5), new TimerStateCallback(Potion.Explode_Callback),
new object[] { from, new Point3D(p), from.Map });
Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue);
Timer.DelayCall(TimeSpan.FromSeconds(1.5), () => Potion.Explode(from, new Point3D(p), from.Map));
}
}
@ -292,33 +284,28 @@ namespace Server.Items
#region Delay
private static Hashtable m_Delay = new Hashtable();
private static Dictionary<Mobile, Timer> m_Delay = new Dictionary<Mobile, Timer>();
public static void AddDelay(Mobile m)
{
if (m_Delay[m] is Timer timer)
timer.Stop();
m_Delay[m] = Timer.DelayCall(TimeSpan.FromSeconds(30), new TimerStateCallback(EndDelay_Callback), m);
m_Delay[m]?.Stop();
m_Delay[m] = Timer.DelayCall(TimeSpan.FromSeconds(30), EndDelay, m);
}
public static int GetDelay(Mobile m)
{
if (m_Delay[m] is Timer timer && timer.Next > DateTime.UtcNow)
Timer timer = m_Delay[m];
if (timer?.Next > DateTime.UtcNow)
return (int)(timer.Next - DateTime.UtcNow).TotalSeconds;
return 0;
}
private static void EndDelay_Callback(object obj)
{
if (obj is Mobile mobile)
EndDelay(mobile);
}
public static void EndDelay(Mobile m)
{
if (m_Delay[m] is Timer timer)
Timer timer = m_Delay[m];
if (timer != null)
{
timer.Stop();
m_Delay.Remove(m);
@ -327,4 +314,4 @@ namespace Server.Items
#endregion
}
}
}

View file

@ -67,13 +67,6 @@ namespace Server.Items
int version = reader.ReadInt();
}
public void Explode_Callback(object state)
{
object[] states = (object[])state;
Explode((Mobile)states[0], (Point3D)states[1], (Map)states[2]);
}
public virtual void Explode(Mobile from, Point3D loc, Map map)
{
if (Deleted || map == null)
@ -91,7 +84,7 @@ namespace Server.Items
Geometry.Circle2D(loc, map, Radius, BlastEffect, 270, 90);
Timer.DelayCall(TimeSpan.FromSeconds(0.3), new TimerStateCallback(CircleEffect2), new object[] { loc, map });
Timer.DelayCall(TimeSpan.FromSeconds(0.3), () => CircleEffect2(loc, map));
foreach (Mobile mobile in map.GetMobilesInRange(loc, Radius))
if (mobile is BaseCreature mon)
@ -134,9 +127,8 @@ namespace Server.Items
else
to = new Entity(Serial.Zero, new Point3D(p), from.Map);
Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue, 0);
Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(Potion.Explode_Callback),
new object[] { from, new Point3D(p), from.Map });
Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue);
Timer.DelayCall(TimeSpan.FromSeconds(1.0), () => Potion.Explode(from, new Point3D(p), from.Map));
}
}
@ -148,44 +140,36 @@ namespace Server.Items
Effects.SendLocationEffect(p, map, 0x376A, 4, 9);
}
public void CircleEffect2(object state)
public void CircleEffect2(Point3D p, Map m)
{
object[] states = (object[])state;
Geometry.Circle2D((Point3D)states[0], (Map)states[1], Radius, BlastEffect, 90, 270);
Geometry.Circle2D(p, m, Radius, BlastEffect, 90, 270);
}
#endregion
#region Delay
private static Hashtable m_Delay = new Hashtable();
private static Dictionary<Mobile, Timer> m_Delay = new Dictionary<Mobile, Timer>();
public static void AddDelay(Mobile m)
{
if (m_Delay[m] is Timer timer)
timer.Stop();
m_Delay[m] = Timer.DelayCall(TimeSpan.FromSeconds(60), new TimerStateCallback(EndDelay_Callback), m);
m_Delay[m]?.Stop();
m_Delay[m] = Timer.DelayCall(TimeSpan.FromSeconds(60), EndDelay, m);
}
public static int GetDelay(Mobile m)
{
if (m_Delay[m] is Timer timer && timer.Next > DateTime.UtcNow)
Timer timer = m_Delay[m];
if (timer?.Next > DateTime.UtcNow)
return (int)(timer.Next - DateTime.UtcNow).TotalSeconds;
return 0;
}
private static void EndDelay_Callback(object obj)
{
if (obj is Mobile mobile)
EndDelay(mobile);
}
public static void EndDelay(Mobile m)
{
if (m_Delay[m] is Timer timer)
Timer timer = m_Delay[m];
if (timer != null)
{
timer.Stop();
m_Delay.Remove(m);
@ -194,4 +178,4 @@ namespace Server.Items
#endregion
}
}
}

View file

@ -91,24 +91,22 @@ namespace Server.Items
{
from.SendLocalizedMessage(500236); // You should throw it now!
int timer = 3;
if (Core.ML)
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.25), 5,
new TimerStateCallback(Detonate_OnTick), new object[] { from, 3 }); // 3.6 seconds explosion delay
() => Detonate_OnTick(from, timer--)); // 3.6 seconds explosion delay
else
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(0.75), TimeSpan.FromSeconds(1.0), 4,
new TimerStateCallback(Detonate_OnTick), new object[] { from, 3 }); // 2.6 seconds explosion delay
() => Detonate_OnTick(from, timer--)); // 2.6 seconds explosion delay
}
}
private void Detonate_OnTick(object state)
private void Detonate_OnTick(Mobile from, int timer)
{
if (Deleted)
return;
object[] states = (object[])state;
Mobile from = (Mobile)states[0];
int timer = (int)states[1];
object parent = FindParent(from);
if (timer == 0)
@ -140,23 +138,14 @@ namespace Server.Items
item.PublicOverheadMessage(MessageType.Regular, 0x22, false, timer.ToString());
else if (parent is Mobile mobile)
mobile.PublicOverheadMessage(MessageType.Regular, 0x22, false, timer.ToString());
states[1] = timer - 1;
}
}
private void Reposition_OnTick(object state)
private void Reposition_OnTick(Mobile from, Point3D loc, Map map)
{
if (Deleted)
return;
object[] states = (object[])state;
Mobile from = (Mobile)states[0];
IPoint3D p = (IPoint3D)states[1];
Map map = (Map)states[2];
Point3D loc = new Point3D(p);
if (InstantExplosion)
Explode(from, true, loc, map);
else
@ -189,7 +178,7 @@ namespace Server.Items
if (direct)
alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10));
IPooledEnumerable<IEntity> eable = map.GetObjectsInRange(loc, ExplosionRange, LeveledExplosion, true);
IPooledEnumerable<IEntity> eable = map.GetObjectsInRange(loc, ExplosionRange, LeveledExplosion);
List<IEntity> toExplode = new List<IEntity>();
int toDamage = 0;
@ -274,13 +263,12 @@ namespace Server.Items
to = m;
}
Effects.SendMovingEffect(from, to, Potion.ItemID, 7, 0, false, false, Potion.Hue, 0);
Effects.SendMovingEffect(from, to, Potion.ItemID, 7, 0, false, false, Potion.Hue);
if (Potion.Amount > 1) Mobile.LiftItemDupe(Potion, 1);
Potion.Internalize();
Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(Potion.Reposition_OnTick),
new object[] { from, p, map });
Timer.DelayCall(TimeSpan.FromSeconds(1.0), () => Potion.Reposition_OnTick(from, new Point3D(p), map));
}
}
}

View file

@ -51,7 +51,7 @@ namespace Server.Items
}
else
{
if (from.BeginAction(typeof(BaseHealPotion)))
if (from.BeginAction<BaseHealPotion>())
{
DoHeal(from);
@ -60,7 +60,7 @@ namespace Server.Items
if (!DuelContext.IsFreeConsume(from))
Consume();
Timer.DelayCall(TimeSpan.FromSeconds(Delay), new TimerStateCallback(ReleaseHealLock), from);
Timer.DelayCall(TimeSpan.FromSeconds(Delay), from.EndAction<BaseHealPotion>);
}
else
{
@ -75,10 +75,5 @@ namespace Server.Items
1049547); // You decide against drinking this potion, as you are already at full health.
}
}
private static void ReleaseHealLock(object state)
{
((Mobile)state).EndAction(typeof(BaseHealPotion));
}
}
}

View file

@ -1,11 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Server.Items
{
public class InvisibilityPotion : BasePotion
{
private static Hashtable m_Table = new Hashtable();
private static Dictionary<Mobile, Timer> m_Table = new Dictionary<Mobile, Timer>();
[Constructible]
public InvisibilityPotion() : base(0xF0A, PotionEffect.Invisibility)
@ -34,16 +35,10 @@ namespace Server.Items
}
Consume();
m_Table[from] = Timer.DelayCall(TimeSpan.FromSeconds(2), new TimerStateCallback(Hide_Callback), from);
m_Table[from] = Timer.DelayCall(TimeSpan.FromSeconds(2), Hide, from);
PlayDrinkEffect(from);
}
private static void Hide_Callback(object obj)
{
if (obj is Mobile mobile)
Hide(mobile);
}
public static void Hide(Mobile m)
{
Effects.SendLocationParticles(
@ -57,13 +52,7 @@ namespace Server.Items
RemoveTimer(m);
Timer.DelayCall(TimeSpan.FromSeconds(30), new TimerStateCallback(EndHide_Callback), m);
}
private static void EndHide_Callback(object obj)
{
if (obj is Mobile mobile)
EndHide(mobile);
Timer.DelayCall(TimeSpan.FromSeconds(30), EndHide, m);
}
public static void EndHide(Mobile m)
@ -79,11 +68,11 @@ namespace Server.Items
public static void RemoveTimer(Mobile m)
{
Timer t = (Timer)m_Table[m];
Timer timer = m_Table[m];
if (t != null)
if (timer != null)
{
t.Stop();
timer.Stop();
m_Table.Remove(m);
}
}
@ -108,4 +97,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -29,7 +29,7 @@ namespace Server.Items
public override void Drink(Mobile from)
{
if (from.BeginAction(typeof(LightCycle)))
if (from.BeginAction<LightCycle>())
{
new LightCycle.NightSightTimer(from).Start();
from.LightLevel = LightCycle.DungeonLevel / 2;

View file

@ -119,7 +119,7 @@ namespace Server.Items
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
CraftItem craftItem, int resHue)
{
int charges = 5 + quality + (int)(from.Skills[SkillName.Inscribe].Value / 30);
int charges = 5 + quality + (int)(from.Skills.Inscribe.Value / 30);
if (charges > 10)
charges = 10;
@ -272,7 +272,7 @@ namespace Server.Items
public override bool OnDragLift(Mobile from)
{
if (from.HasGump(typeof(RunebookGump)))
if (from.HasGump<RunebookGump>())
{
from.SendLocalizedMessage(500169); // You cannot pick that up.
return false;
@ -280,7 +280,7 @@ namespace Server.Items
foreach (Mobile m in Openers)
if (IsOpen(m))
m.CloseGump(typeof(RunebookGump));
m.CloseGump<RunebookGump>();
Openers.Clear();
@ -314,7 +314,7 @@ namespace Server.Items
return;
}
from.CloseGump(typeof(RunebookGump));
from.CloseGump<RunebookGump>();
from.SendGump(new RunebookGump(from, this));
Openers.Add(from);

View file

@ -69,9 +69,6 @@ namespace Server.Items
1 // 1 property : 1/4 : 25%
};
private AosAttributes m_AosAttributes;
private AosSkillBonuses m_AosSkillBonuses;
private ulong m_Content;
private Mobile m_Crafter;
@ -94,8 +91,8 @@ namespace Server.Items
public Spellbook(ulong content, int itemID) : base(itemID)
{
m_AosAttributes = new AosAttributes(this);
m_AosSkillBonuses = new AosSkillBonuses(this);
Attributes = new AosAttributes(this);
SkillBonuses = new AosSkillBonuses(this);
Weight = 3.0;
Layer = Layer.OneHanded;
@ -133,18 +130,10 @@ namespace Server.Items
public override bool DisplayWeight => false;
[CommandProperty(AccessLevel.GameMaster)]
public AosAttributes Attributes
{
get => m_AosAttributes;
set { }
}
public AosAttributes Attributes{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public AosSkillBonuses SkillBonuses
{
get => m_AosSkillBonuses;
set { }
}
public AosSkillBonuses SkillBonuses{ get; private set; }
public virtual SpellbookType SpellbookType => SpellbookType.Regular;
public virtual int BookOffset => 0;
@ -535,7 +524,7 @@ namespace Server.Items
{
if (!Ethic.CheckEquip(from, this)) return false;
if (!from.CanBeginAction(typeof(BaseWeapon))) return false;
if (!from.CanBeginAction<BaseWeapon>()) return false;
return base.CanEquip(from);
}
@ -583,19 +572,19 @@ namespace Server.Items
if (!(newItem is Spellbook book))
return;
book.m_AosAttributes = new AosAttributes(newItem, m_AosAttributes);
book.m_AosSkillBonuses = new AosSkillBonuses(newItem, m_AosSkillBonuses);
book.Attributes = new AosAttributes(newItem, Attributes);
book.SkillBonuses = new AosSkillBonuses(newItem, SkillBonuses);
}
public override void OnAdded(IEntity parent)
{
if (Core.AOS && parent is Mobile from)
{
m_AosSkillBonuses.AddTo(from);
SkillBonuses.AddTo(from);
int strBonus = m_AosAttributes.BonusStr;
int dexBonus = m_AosAttributes.BonusDex;
int intBonus = m_AosAttributes.BonusInt;
int strBonus = Attributes.BonusStr;
int dexBonus = Attributes.BonusDex;
int intBonus = Attributes.BonusInt;
if (strBonus != 0 || dexBonus != 0 || intBonus != 0)
{
@ -619,7 +608,7 @@ namespace Server.Items
{
if (Core.AOS && parent is Mobile from)
{
m_AosSkillBonuses.Remove();
SkillBonuses.Remove();
string modName = Serial.ToString();
@ -706,7 +695,7 @@ namespace Server.Items
if (m_Crafter != null)
list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~
m_AosSkillBonuses.GetProperties(list);
SkillBonuses.GetProperties(list);
if (m_Slayer != SlayerName.None)
{
@ -724,76 +713,76 @@ namespace Server.Items
int prop;
if ((prop = m_AosAttributes.WeaponDamage) != 0)
if ((prop = Attributes.WeaponDamage) != 0)
list.Add(1060401, prop.ToString()); // damage increase ~1_val~%
if ((prop = m_AosAttributes.DefendChance) != 0)
if ((prop = Attributes.DefendChance) != 0)
list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~%
if ((prop = m_AosAttributes.BonusDex) != 0)
if ((prop = Attributes.BonusDex) != 0)
list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~
if ((prop = m_AosAttributes.EnhancePotions) != 0)
if ((prop = Attributes.EnhancePotions) != 0)
list.Add(1060411, prop.ToString()); // enhance potions ~1_val~%
if ((prop = m_AosAttributes.CastRecovery) != 0)
if ((prop = Attributes.CastRecovery) != 0)
list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~
if ((prop = m_AosAttributes.CastSpeed) != 0)
if ((prop = Attributes.CastSpeed) != 0)
list.Add(1060413, prop.ToString()); // faster casting ~1_val~
if ((prop = m_AosAttributes.AttackChance) != 0)
if ((prop = Attributes.AttackChance) != 0)
list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~%
if ((prop = m_AosAttributes.BonusHits) != 0)
if ((prop = Attributes.BonusHits) != 0)
list.Add(1060431, prop.ToString()); // hit point increase ~1_val~
if ((prop = m_AosAttributes.BonusInt) != 0)
if ((prop = Attributes.BonusInt) != 0)
list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~
if ((prop = m_AosAttributes.LowerManaCost) != 0)
if ((prop = Attributes.LowerManaCost) != 0)
list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~%
if ((prop = m_AosAttributes.LowerRegCost) != 0)
if ((prop = Attributes.LowerRegCost) != 0)
list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~%
if ((prop = m_AosAttributes.Luck) != 0)
if ((prop = Attributes.Luck) != 0)
list.Add(1060436, prop.ToString()); // luck ~1_val~
if ((prop = m_AosAttributes.BonusMana) != 0)
if ((prop = Attributes.BonusMana) != 0)
list.Add(1060439, prop.ToString()); // mana increase ~1_val~
if ((prop = m_AosAttributes.RegenMana) != 0)
if ((prop = Attributes.RegenMana) != 0)
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~
if ((prop = m_AosAttributes.NightSight) != 0)
if ((prop = Attributes.NightSight) != 0)
list.Add(1060441); // night sight
if ((prop = m_AosAttributes.ReflectPhysical) != 0)
if ((prop = Attributes.ReflectPhysical) != 0)
list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~%
if ((prop = m_AosAttributes.RegenStam) != 0)
if ((prop = Attributes.RegenStam) != 0)
list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~
if ((prop = m_AosAttributes.RegenHits) != 0)
if ((prop = Attributes.RegenHits) != 0)
list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~
if ((prop = m_AosAttributes.SpellChanneling) != 0)
if ((prop = Attributes.SpellChanneling) != 0)
list.Add(1060482); // spell channeling
if ((prop = m_AosAttributes.SpellDamage) != 0)
if ((prop = Attributes.SpellDamage) != 0)
list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~%
if ((prop = m_AosAttributes.BonusStam) != 0)
if ((prop = Attributes.BonusStam) != 0)
list.Add(1060484, prop.ToString()); // stamina increase ~1_val~
if ((prop = m_AosAttributes.BonusStr) != 0)
if ((prop = Attributes.BonusStr) != 0)
list.Add(1060485, prop.ToString()); // strength bonus ~1_val~
if ((prop = m_AosAttributes.WeaponSpeed) != 0)
if ((prop = Attributes.WeaponSpeed) != 0)
list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~%
if (Core.ML && (prop = m_AosAttributes.IncreasedKarmaLoss) != 0)
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
list.Add(1042886, SpellCount.ToString()); // ~1_NUMBERS_OF_SPELLS~ Spells
@ -835,8 +824,8 @@ namespace Server.Items
writer.Write((int)m_Slayer);
writer.Write((int)m_Slayer2);
m_AosAttributes.Serialize(writer);
m_AosSkillBonuses.Serialize(writer);
Attributes.Serialize(writer);
SkillBonuses.Serialize(writer);
writer.Write(m_Content);
writer.Write(SpellCount);
@ -875,8 +864,8 @@ namespace Server.Items
}
case 1:
{
m_AosAttributes = new AosAttributes(this, reader);
m_AosSkillBonuses = new AosSkillBonuses(this, reader);
Attributes = new AosAttributes(this, reader);
SkillBonuses = new AosSkillBonuses(this, reader);
goto case 0;
}
@ -889,18 +878,18 @@ namespace Server.Items
}
}
if (m_AosAttributes == null)
m_AosAttributes = new AosAttributes(this);
if (Attributes == null)
Attributes = new AosAttributes(this);
if (m_AosSkillBonuses == null)
m_AosSkillBonuses = new AosSkillBonuses(this);
if (SkillBonuses == null)
SkillBonuses = new AosSkillBonuses(this);
if (Core.AOS && Parent is Mobile mobile)
m_AosSkillBonuses.AddTo(mobile);
SkillBonuses.AddTo(mobile);
int strBonus = m_AosAttributes.BonusStr;
int dexBonus = m_AosAttributes.BonusDex;
int intBonus = m_AosAttributes.BonusInt;
int strBonus = Attributes.BonusStr;
int dexBonus = Attributes.BonusDex;
int intBonus = Attributes.BonusInt;
if (Parent is Mobile m)
{