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

@ -42,7 +42,7 @@ namespace Server.Items
{
ItemID = 0xA57;
if (!from.HasGump(typeof(LogoutGump)))
if (!from.HasGump<LogoutGump>())
{
CampfireEntry entry = Campfire.GetEntry(from);
@ -123,7 +123,7 @@ namespace Server.Items
private void CloseGump()
{
Campfire.RemoveEntry(m_Entry);
m_Entry.Player.CloseGump(typeof(LogoutGump));
m_Entry.Player.CloseGump<LogoutGump>();
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Server.Mobiles;
using Server.Network;
@ -16,9 +17,9 @@ namespace Server.Items
{
public static readonly int SecureRange = 7;
private static readonly Hashtable m_Table = new Hashtable();
private static readonly Dictionary<Mobile, CampfireEntry> m_Table = new Dictionary<Mobile, CampfireEntry>();
private ArrayList m_Entries;
private List<CampfireEntry> m_Entries;
private Timer m_Timer;
@ -27,7 +28,7 @@ namespace Server.Items
Movable = false;
Light = LightType.Circle300;
m_Entries = new ArrayList();
m_Entries = new List<CampfireEntry>();
Created = DateTime.UtcNow;
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnTick);
@ -85,7 +86,7 @@ namespace Server.Items
public static CampfireEntry GetEntry(Mobile player)
{
return (CampfireEntry)m_Table[player];
return m_Table[player];
}
public static void RemoveEntry(CampfireEntry entry)
@ -109,11 +110,9 @@ namespace Server.Items
if (Status == CampfireStatus.Off || Deleted)
return;
foreach (CampfireEntry entry in new ArrayList(m_Entries))
foreach (CampfireEntry entry in m_Entries.ToList())
if (!entry.Valid || entry.Player.NetState == null)
{
RemoveEntry(entry);
}
else if (!entry.Safe && now - entry.Start >= TimeSpan.FromSeconds(30.0))
{
entry.Safe = true;
@ -141,7 +140,8 @@ namespace Server.Items
if (m_Entries == null)
return;
foreach (CampfireEntry entry in new ArrayList(m_Entries)) RemoveEntry(entry);
foreach (CampfireEntry entry in m_Entries.ToList())
RemoveEntry(entry);
}
public override void OnAfterDelete()

View file

@ -1,4 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using Server.Network;
using Server.Regions;
@ -72,13 +72,13 @@ namespace Server.Items
private Point3D GetFireLocation(Mobile from)
{
if (from.Region.IsPartOf(typeof(DungeonRegion)))
if (from.Region.IsPartOf<DungeonRegion>())
return Point3D.Zero;
if (Parent == null)
return Location;
ArrayList list = new ArrayList(4);
List<Point3D> list = new List<Point3D>(4);
AddOffsetLocation(from, 0, -1, list);
AddOffsetLocation(from, -1, 0, list);
@ -89,10 +89,10 @@ namespace Server.Items
return Point3D.Zero;
int idx = Utility.Random(list.Count);
return (Point3D)list[idx];
return list[idx];
}
private void AddOffsetLocation(Mobile from, int offsetX, int offsetY, ArrayList list)
private void AddOffsetLocation(Mobile from, int offsetX, int offsetY, List<Point3D> list)
{
Map map = from.Map;

View file

@ -51,7 +51,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (from.Skills[SkillName.Carpentry].Base < 90.0)
else if (from.Skills.Carpentry.Base < 90.0)
{
from.SendLocalizedMessage(1042594); // You do not understand how to use this.
}
@ -108,7 +108,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (from.Skills[SkillName.Carpentry].Base < 90.0)
else if (from.Skills.Carpentry.Base < 90.0)
{
from.SendLocalizedMessage(1042603); // You would not understand how to use the kit.
}

View file

@ -86,10 +86,7 @@ namespace Server.Items
if (map == null || map == Map.Internal)
return Point3D.Zero;
int xCenter, yCenter;
int xWidth, yHeight;
if (!ComputeMapDetails(map, 0, 0, out xCenter, out yCenter, out xWidth, out yHeight))
if (!ComputeMapDetails(map, 0, 0, out int xCenter, out int yCenter, out int xWidth, out int yHeight))
return Point3D.Zero;
double absLong = xLong + (double)xMins / 60;
@ -101,10 +98,8 @@ namespace Server.Items
if (!ySouth)
absLat = 360.0 - absLat;
int x, y, z;
x = xCenter + (int)(absLong * xWidth / 360);
y = yCenter + (int)(absLat * yHeight / 360);
int x = xCenter + (int)(absLong * xWidth / 360);
int y = yCenter + (int)(absLat * yHeight / 360);
if (x < 0)
x += xWidth;
@ -116,7 +111,7 @@ namespace Server.Items
else if (y >= yHeight)
y -= yHeight;
z = map.GetAverageZ(x, y);
int z = map.GetAverageZ(x, y);
return new Point3D(x, y, z);
}
@ -128,10 +123,8 @@ namespace Server.Items
return false;
int x = p.X, y = p.Y;
int xCenter, yCenter;
int xWidth, yHeight;
if (!ComputeMapDetails(map, x, y, out xCenter, out yCenter, out xWidth, out yHeight))
if (!ComputeMapDetails(map, x, y, out int xCenter, out int yCenter, out int xWidth, out int yHeight))
return false;
double absLong = (double)((x - xCenter) * 360) / xWidth;

View file

@ -38,7 +38,7 @@ namespace Server.Items
#region IShipwreckedItem Members
public bool IsShipwreckedItem
bool IShipwreckedItem.IsShipwreckedItem
{
get => true;
set { }

View file

@ -163,8 +163,10 @@ namespace Server.Items
Effects.SendLocationEffect(p, map, 0x352D, 16, 4);
Effects.PlaySound(p, map, 0x364);
Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.25), 14, new TimerStateCallback(DoEffect),
new object[] { p, 0, from });
int index = 0;
Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.25), 14,
() => DoEffect(from, p, index++));
from.SendLocalizedMessage(RequireDeepWater
? 1010487
@ -178,19 +180,11 @@ namespace Server.Items
}
}
private void DoEffect(object state)
private void DoEffect(Mobile from, Point3D p, int index)
{
if (Deleted)
return;
object[] states = (object[])state;
Point3D p = (Point3D)states[0];
int index = (int)states[1];
Mobile from = (Mobile)states[2];
states[1] = ++index;
if (index == 1)
{
Effects.SendLocationEffect(p, Map, 0x352D, 16, 4);

View file

@ -86,7 +86,7 @@ namespace Server.Items
}
}
public bool ShowUsesRemaining
bool IUsesRemaining.ShowUsesRemaining
{
get => true;
set { }
@ -215,7 +215,7 @@ namespace Server.Items
m_Mobile = mobile;
m_Value = value;
bool stoneMining = mobile.StoneMining && mobile.Skills[SkillName.Mining].Base >= 100.0;
bool stoneMining = mobile.StoneMining && mobile.Skills.Mining.Base >= 100.0;
if (mobile.ToggleMiningStone == value || value && !stoneMining)
Flags |= CMEFlags.Disabled;
@ -231,7 +231,7 @@ namespace Server.Items
{
m_Mobile.SendLocalizedMessage(1054023); // You are already set to mine both ore and stone!
}
else if (!m_Mobile.StoneMining || m_Mobile.Skills[SkillName.Mining].Base < 100.0)
else if (!m_Mobile.StoneMining || m_Mobile.Skills.Mining.Base < 100.0)
{
m_Mobile.SendLocalizedMessage(
1054024); // You have not learned how to mine stone or you do not have enough skill!

View file

@ -45,7 +45,7 @@ namespace Server.Items
}
}
public bool ShowUsesRemaining
bool IUsesRemaining.ShowUsesRemaining
{
get => true;
set { }
@ -69,11 +69,7 @@ namespace Server.Items
HarvestSystem system = Mining.System;
int tileID;
Map map;
Point3D loc;
if (!system.GetHarvestDetails(from, this, toProspect, out tileID, out map, out loc))
if (!system.GetHarvestDetails(from, this, toProspect, out int tileID, out Map map, out Point3D loc))
{
from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that.
return;

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)
{

View file

@ -253,7 +253,7 @@ namespace Server.Items
healerNumber = 501042; // Target can not be resurrected at that location.
patientNumber = 502391; // Thou can not be resurrected there!
}
else if (Patient.Region != null && Patient.Region.IsPartOf("Khaldun"))
else if (Patient.Region?.IsPartOf("Khaldun") == true)
{
healerNumber =
1010395; // The veil of death in this area is too strong and resists thy efforts to restore life.
@ -281,7 +281,7 @@ namespace Server.Items
{
healerNumber = 503255; // You are able to resurrect the creature.
master.CloseGump(typeof(PetResurrectGump));
master.CloseGump<PetResurrectGump>();
master.SendGump(new PetResurrectGump(Healer, petPatient));
}
else
@ -298,7 +298,7 @@ namespace Server.Items
{
healerNumber = 503255; // You are able to resurrect the creature.
friend.CloseGump(typeof(PetResurrectGump));
friend.CloseGump<PetResurrectGump>();
friend.SendGump(new PetResurrectGump(Healer, petPatient));
found = true;
@ -312,7 +312,7 @@ namespace Server.Items
}
else
{
Patient.CloseGump(typeof(ResurrectGump));
Patient.CloseGump<ResurrectGump>();
Patient.SendGump(new ResurrectGump(Patient, Healer));
}
}

View file

@ -32,7 +32,7 @@ namespace Server.Items
return false;
}
if (!from.CanBeginAction(typeof(FireHorn)))
if (!from.CanBeginAction<FireHorn>())
{
from.SendLocalizedMessage(1049615); // You must take a moment to catch your breath.
return false;
@ -62,11 +62,10 @@ namespace Server.Items
if (!CheckUse(from))
return;
from.BeginAction(typeof(FireHorn));
Timer.DelayCall(Core.AOS ? TimeSpan.FromSeconds(6.0) : TimeSpan.FromSeconds(12.0),
new TimerStateCallback(EndAction), from);
from.BeginAction<FireHorn>();
Timer.DelayCall(Core.AOS ? TimeSpan.FromSeconds(6.0) : TimeSpan.FromSeconds(12.0), EndAction, from);
int music = from.Skills[SkillName.Musicianship].Fixed;
int music = from.Skills.Musicianship.Fixed;
int sucChance = 500 + (music - 775) * 2;
double dSucChance = sucChance / 1000.0;
@ -107,9 +106,9 @@ namespace Server.Items
if (targets.Count > 0)
{
int prov = from.Skills[SkillName.Provocation].Fixed;
int disc = from.Skills[SkillName.Discordance].Fixed;
int peace = from.Skills[SkillName.Peacemaking].Fixed;
int prov = from.Skills.Provocation.Fixed;
int disc = from.Skills.Discordance.Fixed;
int peace = from.Skills.Peacemaking.Fixed;
int minDamage, maxDamage;
@ -176,12 +175,10 @@ namespace Server.Items
}
}
private static void EndAction(object state)
private static void EndAction(Mobile m)
{
Mobile m = (Mobile)state;
m.EndAction(typeof(FireHorn));
m.SendLocalizedMessage(1049621); // You catch your breath.
m?.EndAction<FireHorn>();
m?.SendLocalizedMessage(1049621); // You catch your breath.
}
public override void Serialize(GenericWriter writer)

View file

@ -172,11 +172,7 @@ namespace Server.Items
public bool VerifyRegion(Mobile m)
{
//TODO: When the entire region system data is in, convert to that instead of a proximity thing.
if (!m.Region.IsPartOf(typeof(TownRegion)))
return false;
return Faction.IsNearType(m, RepairSkillInfo.GetInfo(m_Skill).NearbyTypes, 6);
return m.Region.IsPartOf<TownRegion>() && Faction.IsNearType(m, RepairSkillInfo.GetInfo(m_Skill).NearbyTypes, 6);
}
public override void Serialize(GenericWriter writer)

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Engines.Craft;
using Server.Mobiles;
using Server.Network;
@ -18,7 +19,7 @@ namespace Server.Items
public abstract class BaseInstrument : Item, ICraftable, ISlayer
{
private static Hashtable m_Instruments = new Hashtable();
private static Dictionary<Mobile, BaseInstrument> m_Instruments = new Dictionary<Mobile, BaseInstrument>();
private Mobile m_Crafter;
private DateTime m_LastReplenished;
@ -150,12 +151,7 @@ namespace Server.Items
}
}
public void CheckReplenishUses()
{
CheckReplenishUses(true);
}
public void CheckReplenishUses(bool invalidate)
public void CheckReplenishUses(bool invalidate = true)
{
if (!m_ReplenishesCharges || m_UsesRemaining >= InitMaxUses)
return;
@ -186,10 +182,7 @@ namespace Server.Items
public int GetUsesScalar()
{
if (m_Quality == InstrumentQuality.Exceptional)
return 200;
return 100;
return m_Quality == InstrumentQuality.Exceptional ? 200 : 100;
}
public void ConsumeUse(Mobile from)
@ -210,16 +203,15 @@ namespace Server.Items
public static BaseInstrument GetInstrument(Mobile from)
{
if (!(m_Instruments[from] is BaseInstrument item))
BaseInstrument item = m_Instruments[from];
if (item == null)
return null;
if (!item.IsChildOf(from.Backpack))
{
m_Instruments.Remove(from);
return null;
}
if (item.IsChildOf(from.Backpack))
return item;
return item;
m_Instruments.Remove(from);
return null;
}
public static int GetBardRange(Mobile bard, SkillName skill)
@ -238,11 +230,11 @@ namespace Server.Items
else
{
from.SendLocalizedMessage(500617); // What instrument shall you play?
from.BeginTarget(1, false, TargetFlags.None, new TargetStateCallback(OnPickedInstrument), callback);
from.BeginTarget(1, false, TargetFlags.None, OnPickedInstrument, callback);
}
}
public static void OnPickedInstrument(Mobile from, object targeted, object state)
public static void OnPickedInstrument(Mobile from, object targeted, InstrumentPickedCallback callback)
{
if (!(targeted is BaseInstrument instrument))
{
@ -251,24 +243,18 @@ namespace Server.Items
else
{
SetInstrument(from, instrument);
InstrumentPickedCallback callback = state as InstrumentPickedCallback;
callback?.Invoke(from, instrument);
}
}
public static bool IsMageryCreature(BaseCreature bc)
{
return bc != null && bc.AI == AIType.AI_Mage && bc.Skills[SkillName.Magery].Base > 5.0;
return bc?.AI == AIType.AI_Mage && bc.Skills.Magery.Base > 5.0;
}
public static bool IsFireBreathingCreature(BaseCreature bc)
{
if (bc == null)
return false;
return bc.HasBreath;
return bc?.HasBreath == true;
}
public static bool IsPoisonImmune(BaseCreature bc)
@ -278,12 +264,7 @@ namespace Server.Items
public static int GetPoisonLevel(BaseCreature bc)
{
Poison p = bc?.HitPoison;
if (p == null)
return 0;
return p.Level + 1;
return (bc?.HitPoison.Level ?? -1) + 1;
}
public static double GetBaseDifficulty(Mobile targ)
@ -295,7 +276,7 @@ namespace Server.Items
double val = targ.HitsMax * 1.6 + targ.StamMax + targ.ManaMax;
val += targ.SkillsTotal / 10;
val += targ.SkillsTotal / 10.0;
if (val > 700)
val = 700 + (int)((val - 700) * (3.0 / 11));
@ -406,7 +387,7 @@ namespace Server.Items
public override void OnSingleClick(Mobile from)
{
ArrayList attrs = new ArrayList();
List<EquipInfoAttribute> attrs = new List<EquipInfoAttribute>();
if (DisplayLootType)
{
@ -453,7 +434,7 @@ namespace Server.Items
return;
EquipmentInfo eqInfo = new EquipmentInfo(number, m_Crafter, false,
(EquipInfoAttribute[])attrs.ToArray(typeof(EquipInfoAttribute)));
attrs.ToArray());
from.Send(new DisplayEquipmentInfo(this, eqInfo));
}
@ -546,7 +527,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(500446); // That is too far away.
}
else if (from.BeginAction(typeof(BaseInstrument)))
else if (from.BeginAction<BaseInstrument>())
{
SetInstrument(from, this);
@ -568,7 +549,7 @@ namespace Server.Items
{
m.CheckSkill(SkillName.Musicianship, 0.0, 120.0);
return m.Skills[SkillName.Musicianship].Value / 100 > Utility.RandomDouble();
return m.Skills.Musicianship.Value / 100 > Utility.RandomDouble();
}
public void PlayInstrumentWell(Mobile from)
@ -593,8 +574,8 @@ namespace Server.Items
protected override void OnTick()
{
m_From.EndAction(typeof(BaseInstrument));
m_From.EndAction<BaseInstrument>();
}
}
}
}
}

View file

@ -70,7 +70,7 @@ namespace Server.Items
}
}
public bool ShowUsesRemaining
bool IUsesRemaining.ShowUsesRemaining
{
get => true;
set { }

View file

@ -68,7 +68,7 @@ namespace Server.Items
}
}
public bool ShowUsesRemaining
bool IUsesRemaining.ShowUsesRemaining
{
get => true;
set { }

View file

@ -69,7 +69,7 @@ namespace Server.Items
}
}
public bool ShowUsesRemaining
bool IUsesRemaining.ShowUsesRemaining
{
get => true;
set { }

View file

@ -38,7 +38,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (pm == null || from.Skills[SkillName.Alchemy].Base < 100.0)
else if (pm == null || from.Skills.Alchemy.Base < 100.0)
{
pm.SendMessage("Only a Grandmaster Alchemist can learn from this book.");
}

View file

@ -38,7 +38,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (pm == null || from.Skills[SkillName.Carpentry].Base < 100.0)
else if (pm == null || from.Skills.Carpentry.Base < 100.0)
{
pm.SendMessage("Only a Grandmaster Carpenter can learn from this book.");
}

View file

@ -38,7 +38,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (pm == null || from.Skills[SkillName.Mining].Base < 100.0)
else if (pm == null || from.Skills.Mining.Base < 100.0)
{
pm.SendMessage("Only a Grandmaster Miner can learn from this book.");
}

View file

@ -38,7 +38,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (pm == null || from.Skills[SkillName.Mining].Base < 100.0)
else if (pm == null || from.Skills.Mining.Base < 100.0)
{
from.SendMessage("Only a Grandmaster Miner can learn from this book.");
}

View file

@ -103,16 +103,16 @@ namespace Server.Items
public string TitleString{ get; }
}
public delegate void CustomHuePickerCallback(Mobile from, object state, int hue);
public delegate void CustomHuePickerCallback<in T>(Mobile from, T state, int hue);
public class CustomHuePickerGump : Gump
public class CustomHuePickerGump<T> : Gump
{
private CustomHuePickerCallback m_Callback;
private CustomHuePickerCallback<T> m_Callback;
private CustomHuePicker m_Definition;
private Mobile m_From;
private object m_State;
private T m_State;
public CustomHuePickerGump(Mobile from, CustomHuePicker definition, CustomHuePickerCallback callback, object state) :
public CustomHuePickerGump(Mobile from, CustomHuePicker definition, CustomHuePickerCallback<T> callback, T state) :
base(50, 50)
{
m_From = from;

View file

@ -2,17 +2,15 @@ using Server.Gumps;
using Server.Network;
namespace Server.Items
{
public class MetallicHuePicker : Gump
{
public class MetallicHuePicker<T> : Gump
{
public delegate void MetallicHuePickerCallback(Mobile from, object state, int hue);
private MetallicHuePickerCallback m_Callback;
private CustomHuePickerCallback<T> m_Callback;
private Mobile m_From;
private object m_State;
private T m_State;
public MetallicHuePicker(Mobile from, MetallicHuePickerCallback callback, object state)
public MetallicHuePicker(Mobile from, CustomHuePickerCallback<T> callback, T state)
: base(450, 450)
{
m_From = from;

View file

@ -59,9 +59,9 @@ namespace Server.Items
{
}
public virtual void SetTubHue(Mobile from, object state, int hue)
public virtual void SetTubHue(Mobile from, DyeTub tub, int hue)
{
if (state is DyeTub tub) tub.DyedHue = hue;
tub.DyedHue = hue;
}
protected override void OnTarget(Mobile from, object targeted)
@ -71,9 +71,9 @@ namespace Server.Items
if (tub.Redyable)
{
if (tub.MetallicHues) /* OSI has three metallic tubs now */
from.SendGump(new MetallicHuePicker(from, SetTubHue, tub));
from.SendGump(new MetallicHuePicker<DyeTub>(from, SetTubHue, tub));
else if (tub.CustomHuePicker != null)
from.SendGump(new CustomHuePickerGump(from, tub.CustomHuePicker, SetTubHue, tub));
from.SendGump(new CustomHuePickerGump<DyeTub>(from, tub.CustomHuePicker, SetTubHue, tub));
else
from.SendHuePicker(new InternalPicker(tub));
}

View file

@ -49,7 +49,7 @@ namespace Server.Items
from.SendLocalizedMessage(501702);
else if (Stealing.SuspendOnMurder && pm.Kills > 0)
from.SendLocalizedMessage(501703);
else if (!from.CanBeginAction(typeof(IncognitoSpell)))
else if (!from.CanBeginAction<IncognitoSpell>())
from.SendLocalizedMessage(501704);
else if (Sigil.ExistsOn(from))
from.SendLocalizedMessage(1010465); // You cannot disguise yourself while holding a sigil
@ -57,7 +57,7 @@ namespace Server.Items
from.SendLocalizedMessage(1061634);
else if (from.BodyMod == 183 || from.BodyMod == 184)
from.SendLocalizedMessage(1040002);
else if (!from.CanBeginAction(typeof(PolymorphSpell)) || from.IsBodyMod)
else if (!from.CanBeginAction<PolymorphSpell>() || from.IsBodyMod)
from.SendLocalizedMessage(501705);
else
return true;
@ -110,7 +110,7 @@ namespace Server.Items
m_Kit = kit;
m_Used = used;
from.CloseGump(typeof(DisguiseGump));
from.CloseGump<DisguiseGump>();
AddPage(0);

View file

@ -138,7 +138,7 @@ namespace Server.Items
return;
}
if (m_From.Skills[SkillName.Lockpicking].Value < m_Item.RequiredSkill)
if (m_From.Skills.Lockpicking.Value < m_Item.RequiredSkill)
{
/*
// Do some training to gain skills

View file

@ -46,9 +46,7 @@ namespace Server.Items
public static MoonPhase GetMoonPhase(Map map, int x, int y)
{
int hours, minutes, totalMinutes;
GetTime(map, x, y, out hours, out minutes, out totalMinutes);
GetTime(map, x, y, out _, out _, out int totalMinutes);
if (map != null)
totalMinutes /= 10 + map.MapIndex * 20;
@ -58,9 +56,7 @@ namespace Server.Items
public static void GetTime(Map map, int x, int y, out int hours, out int minutes)
{
int totalMinutes;
GetTime(map, x, y, out hours, out minutes, out totalMinutes);
GetTime(map, x, y, out hours, out minutes, out _);
}
public static void GetTime(Map map, int x, int y, out int hours, out int minutes, out int totalMinutes)
@ -91,9 +87,7 @@ namespace Server.Items
public static void GetTime(Map map, int x, int y, out int generalNumber, out string exactTime)
{
int hours, minutes;
GetTime(map, x, y, out hours, out minutes);
GetTime(map, x, y, out int hours, out int minutes);
// 00:00 AM - 00:59 AM : Witching hour
// 01:00 AM - 03:59 AM : Middle of night
@ -131,10 +125,7 @@ namespace Server.Items
public override void OnDoubleClick(Mobile from)
{
int genericNumber;
string exactTime;
GetTime(from, out genericNumber, out exactTime);
GetTime(from, out int genericNumber, out string exactTime);
SendLocalizedMessageTo(from, genericNumber);
SendLocalizedMessageTo(from, 1042958, exactTime); // ~1_TIME~ to be exact
@ -152,9 +143,6 @@ namespace Server.Items
base.Deserialize(reader);
int version = reader.ReadInt();
if (Weight == 2.0)
Weight = 3.0;
}
}

View file

@ -32,25 +32,28 @@ namespace Server.Items
{
QuestSystem qs = player.Quest;
if (qs is WitchApprenticeQuest)
if (qs.FindObjective(typeof(FindIngredientObjective)) is FindIngredientObjective obj && !obj.Completed &&
obj.Ingredient == Ingredient.StarChart)
if (!(qs is WitchApprenticeQuest))
return;
FindIngredientObjective obj = qs.FindObjective<FindIngredientObjective>();
if (obj?.Completed == false && obj.Ingredient == Ingredient.StarChart)
{
Clock.GetTime(from.Map, from.X, from.Y, out int hours, out int _);
if (hours < 5 || hours > 17)
{
Clock.GetTime(from.Map, from.X, from.Y, out int hours, out int _);
player.SendLocalizedMessage(
1055040); // You gaze up into the glittering night sky. With great care, you compose a chart of the most prominent star patterns.
if (hours < 5 || hours > 17)
{
player.SendLocalizedMessage(
1055040); // You gaze up into the glittering night sky. With great care, you compose a chart of the most prominent star patterns.
obj.Complete();
}
else
{
player.SendLocalizedMessage(
1055039); // You gaze up into the sky, but it is not dark enough to see any stars.
}
obj.Complete();
}
else
{
player.SendLocalizedMessage(
1055039); // You gaze up into the sky, but it is not dark enough to see any stars.
}
}
}
}

View file

@ -196,8 +196,7 @@ namespace Server.Items
new List<SkillName>(attrs.Owner is Spellbook ? m_PossibleSpellbookSkills : m_PossibleBonusSkills);
int count = Core.SE ? possibleSkills.Count : possibleSkills.Count - 2;
SkillName sk, check;
double bonus;
SkillName sk;
bool found;
do
@ -207,7 +206,7 @@ namespace Server.Items
possibleSkills.Remove(sk);
for (int i = 0; !found && i < 5; ++i)
found = attrs.GetValues(i, out check, out bonus) && check == sk;
found = attrs.GetValues(i, out SkillName check, out _) && check == sk;
} while (found && count > 0);
attrs.SetValues(index, sk, Scale(min, max, low, high));
@ -431,7 +430,7 @@ namespace Server.Items
public static void GetElementalDamages(BaseWeapon weapon, bool randomizeOrder)
{
weapon.GetDamageTypes(null, out int phys, out int fire, out int cold, out int pois, out int nrgy, out int chaos, out int direct);
weapon.GetDamageTypes(null, out int phys, out _, out _, out _, out _, out _, out _);
int totalDamage = phys;

View file

@ -85,10 +85,12 @@ namespace Server.Items
}
}
public bool ShowUsesRemaining
private bool ShowUsesRemaining{ get; set; } = true;
bool IUsesRemaining.ShowUsesRemaining
{
get => true;
set { }
get => ShowUsesRemaining;
set => ShowUsesRemaining = value;
}
public void ScaleUses()