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

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Network;
namespace Server.Items
@ -87,14 +88,14 @@ namespace Server.Items
}
}
private Hashtable m_Entries;
private Dictionary<Mobile, ScoreEntry> m_Entries;
private ScoreEntry GetEntryFor( Mobile from )
{
if ( m_Entries == null )
m_Entries = new Hashtable();
m_Entries = new Dictionary<Mobile, ScoreEntry>();
ScoreEntry e = (ScoreEntry)m_Entries[from];
ScoreEntry e = m_Entries[from];
if ( e == null )
m_Entries[from] = e = new ScoreEntry();

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using Server.Multis;
@ -140,11 +139,11 @@ namespace Server.Items
}
}
ArrayList doors = house.Doors;
List<BaseDoor> doors = house.Doors;
for (int i = 0; i < doors.Count; ++i)
{
BaseDoor door = doors[i] as BaseDoor;
BaseDoor door = doors[i];
Point3D doorLoc = door.GetWorldLocation();
int doorHeight = door.ItemData.CalcHeight;

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using Server.Multis;
@ -250,11 +249,11 @@ namespace Server.Items
if (house != null)
{
ArrayList doors = house.Doors;
List<BaseDoor> doors = house.Doors;
for (int i = 0; i < doors.Count; ++i)
{
BaseDoor door = doors[i] as BaseDoor;
BaseDoor door = doors[i];
if (door != null && door.Open)
return AddonFitResult.DoorsNotClosed;

View file

@ -71,11 +71,11 @@ namespace Server.Items
if (IsWorking)
return;
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerStateCallback(FinishWorking_Callback), from);
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), FinishWorking_Callback, from);
UpdateStage();
}
private void FinishWorking_Callback(object state)
private void FinishWorking_Callback(Mobile from)
{
if (m_Timer != null)
{
@ -83,11 +83,10 @@ namespace Server.Items
m_Timer = null;
}
if (state is Mobile from && !from.Deleted && !Deleted && IsFull)
if (from?.Deleted == false && !Deleted && IsFull)
{
SackFlour flour = new SackFlour();
SackFlour flour = new SackFlour { ItemID = Utility.RandomBool() ? 4153 : 4165 };
flour.ItemID = Utility.RandomBool() ? 4153 : 4165;
if (from.PlaceInBackpack(flour))
{

View file

@ -58,11 +58,11 @@ namespace Server.Items
if (IsWorking)
return;
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerStateCallback(FinishWorking_Callback), from);
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), FinishWorking_Callback, from);
UpdateStage();
}
private void FinishWorking_Callback(object state)
private void FinishWorking_Callback(Mobile from)
{
if (m_Timer != null)
{
@ -70,7 +70,7 @@ namespace Server.Items
m_Timer = null;
}
if (state is Mobile from && !from.Deleted && !Deleted && IsFull)
if (from?.Deleted == false && !Deleted && IsFull)
{
SackFlour flour = new SackFlour();

View file

@ -78,7 +78,7 @@ namespace Server.Items
SendLocalizedMessageTo(from, 501816); // You are too far away to do that.
else if (Swinging)
SendLocalizedMessageTo(from, 501815); // You have to wait until it stops swinging.
else if (from.Skills[SkillName.Stealing].Base >= MaxSkill)
else if (from.Skills.Stealing.Base >= MaxSkill)
SendLocalizedMessageTo(from,
501830); // Your ability to steal cannot improve any further by simply practicing on a dummy.
else if (from.Mounted)

View file

@ -14,7 +14,7 @@ namespace Server.Items
public override void OnDoubleClick(Mobile from)
{
if (from.BeginAction(typeof(RejuvinationAddonComponent)))
if (from.BeginAction<RejuvinationAddonComponent>())
{
from.FixedEffect(0x373A, 1, 16);
@ -38,19 +38,13 @@ namespace Server.Items
SendLocalizedMessageTo(from, 500803); // You feel as though you've slept for days!
}
Timer.DelayCall(TimeSpan.FromHours(2.0), new TimerStateCallback(ReleaseUseLock_Callback),
new object[] { from, random });
Timer.DelayCall(TimeSpan.FromHours(2.0), () => ReleaseUseLock_Callback(from, random));
}
}
public virtual void ReleaseUseLock_Callback(object state)
public virtual void ReleaseUseLock_Callback(Mobile from, int random)
{
object[] states = (object[])state;
Mobile from = (Mobile)states[0];
int random = (int)states[1];
from.EndAction(typeof(RejuvinationAddonComponent));
from.EndAction<RejuvinationAddonComponent>();
if (random == 4)
{

View file

@ -15,7 +15,7 @@ namespace Server.Items
public override BaseAddonDeed Deed => new WaterTroughEastDeed();
public int Quantity
int IHasQuantity.Quantity
{
get => 500;
set { }

View file

@ -15,7 +15,7 @@ namespace Server.Items
public override BaseAddonDeed Deed => new WaterTroughSouthDeed();
public int Quantity
int IHasQuantity.Quantity
{
get => 500;
set { }

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.ContextMenus;
using Server.Multis;
using Server.Network;
@ -253,7 +252,7 @@ namespace Server.Items
takeItem = false;
}
from.CloseGump(typeof(AquariumGump));
from.CloseGump<AquariumGump>();
InvalidateProperties();
@ -821,7 +820,7 @@ namespace Server.Items
return;
}
from.CloseGump(typeof(AquariumGump));
from.CloseGump<AquariumGump>();
from.SendGump(new AquariumGump(this, HasAccess(from)));
from.PlaySound(0x5A4);

View file

@ -13,7 +13,7 @@ namespace Server.Items
Closable = true;
Disposable = true;
Dragable = true;
Draggable = true;
Resizable = false;
AddPage(0);

View file

@ -12,11 +12,6 @@ namespace Server.Items
{
public abstract class BaseArmor : Item, IScissorable, IFactionItem, ICraftable, IWearableDurability
{
private AosArmorAttributes m_AosArmorAttributes;
private AosAttributes m_AosAttributes;
private AosSkillBonuses m_AosSkillBonuses;
// Overridable values. These values are provided to override the defaults which get defined in the individual armor scripts.
private int m_ArmorBase = -1;
private Mobile m_Crafter;
@ -67,9 +62,9 @@ namespace Server.Items
Layer = (Layer)ItemData.Quality;
m_AosAttributes = new AosAttributes(this);
m_AosArmorAttributes = new AosArmorAttributes(this);
m_AosSkillBonuses = new AosSkillBonuses(this);
Attributes = new AosAttributes(this);
ArmorAttributes = new AosArmorAttributes(this);
SkillBonuses = new AosSkillBonuses(this);
}
@ -357,25 +352,13 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.GameMaster)]
public AosAttributes Attributes
{
get => m_AosAttributes;
set { }
}
public AosAttributes Attributes{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public AosArmorAttributes ArmorAttributes
{
get => m_AosArmorAttributes;
set { }
}
public AosArmorAttributes ArmorAttributes{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public AosSkillBonuses SkillBonuses
{
get => m_AosSkillBonuses;
set { }
}
public AosSkillBonuses SkillBonuses{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public int PhysicalBonus
@ -664,7 +647,7 @@ namespace Server.Items
if (25 > Utility.Random(100)) // 25% chance to lower durability
{
if (Core.AOS && m_AosArmorAttributes.SelfRepair > Utility.Random(10))
if (Core.AOS && ArmorAttributes.SelfRepair > Utility.Random(10))
{
HitPoints += 2;
}
@ -717,9 +700,9 @@ namespace Server.Items
if (!(newItem is BaseArmor armor))
return;
armor.m_AosAttributes = new AosAttributes(newItem, m_AosAttributes);
armor.m_AosArmorAttributes = new AosArmorAttributes(newItem, m_AosArmorAttributes);
armor.m_AosSkillBonuses = new AosSkillBonuses(newItem, m_AosSkillBonuses);
armor.Attributes = new AosAttributes(newItem, Attributes);
armor.ArmorAttributes = new AosArmorAttributes(newItem, ArmorAttributes);
armor.SkillBonuses = new AosSkillBonuses(newItem, SkillBonuses);
}
public int ComputeStatReq(StatType type)
@ -821,7 +804,7 @@ namespace Server.Items
if (Core.AOS)
{
bonus += m_AosArmorAttributes.DurabilityBonus;
bonus += ArmorAttributes.DurabilityBonus;
CraftResourceInfo resInfo = CraftResources.GetInfo(m_Resource);
CraftAttributeInfo attrInfo = null;
@ -883,7 +866,7 @@ namespace Server.Items
if (!Core.AOS)
return 0;
int v = m_AosArmorAttributes.LowerStatReq;
int v = ArmorAttributes.LowerStatReq;
CraftResourceInfo info = CraftResources.GetInfo(m_Resource);
@ -903,7 +886,7 @@ namespace Server.Items
if (parent is Mobile from)
{
if (Core.AOS)
m_AosSkillBonuses.AddTo(from);
SkillBonuses.AddTo(from);
from.Delta(MobileDelta.Armor); // Tell them armor rating has changed
}
@ -943,8 +926,8 @@ namespace Server.Items
SaveFlag flags = SaveFlag.None;
SetSaveFlag(ref flags, SaveFlag.Attributes, !m_AosAttributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.ArmorAttributes, !m_AosArmorAttributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.Attributes, !Attributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.ArmorAttributes, !ArmorAttributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.PhysicalBonus, m_PhysicalBonus != 0);
SetSaveFlag(ref flags, SaveFlag.FireBonus, m_FireBonus != 0);
SetSaveFlag(ref flags, SaveFlag.ColdBonus, m_ColdBonus != 0);
@ -966,16 +949,16 @@ namespace Server.Items
SetSaveFlag(ref flags, SaveFlag.DexReq, m_DexReq != -1);
SetSaveFlag(ref flags, SaveFlag.IntReq, m_IntReq != -1);
SetSaveFlag(ref flags, SaveFlag.MedAllowance, m_Meditate != (AMA)(-1));
SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !m_AosSkillBonuses.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !SkillBonuses.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.PlayerConstructed, PlayerConstructed);
writer.WriteEncodedInt((int)flags);
if (GetSaveFlag(flags, SaveFlag.Attributes))
m_AosAttributes.Serialize(writer);
Attributes.Serialize(writer);
if (GetSaveFlag(flags, SaveFlag.ArmorAttributes))
m_AosArmorAttributes.Serialize(writer);
ArmorAttributes.Serialize(writer);
if (GetSaveFlag(flags, SaveFlag.PhysicalBonus))
writer.WriteEncodedInt(m_PhysicalBonus);
@ -1038,7 +1021,7 @@ namespace Server.Items
writer.WriteEncodedInt((int)m_Meditate);
if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
m_AosSkillBonuses.Serialize(writer);
SkillBonuses.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
@ -1056,14 +1039,14 @@ namespace Server.Items
SaveFlag flags = (SaveFlag)reader.ReadEncodedInt();
if (GetSaveFlag(flags, SaveFlag.Attributes))
m_AosAttributes = new AosAttributes(this, reader);
Attributes = new AosAttributes(this, reader);
else
m_AosAttributes = new AosAttributes(this);
Attributes = new AosAttributes(this);
if (GetSaveFlag(flags, SaveFlag.ArmorAttributes))
m_AosArmorAttributes = new AosArmorAttributes(this, reader);
ArmorAttributes = new AosArmorAttributes(this, reader);
else
m_AosArmorAttributes = new AosArmorAttributes(this);
ArmorAttributes = new AosArmorAttributes(this);
if (GetSaveFlag(flags, SaveFlag.PhysicalBonus))
m_PhysicalBonus = reader.ReadEncodedInt();
@ -1165,7 +1148,7 @@ namespace Server.Items
m_Meditate = (AMA)(-1);
if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
m_AosSkillBonuses = new AosSkillBonuses(this, reader);
SkillBonuses = new AosSkillBonuses(this, reader);
if (GetSaveFlag(flags, SaveFlag.PlayerConstructed))
PlayerConstructed = true;
@ -1174,8 +1157,8 @@ namespace Server.Items
}
case 4:
{
m_AosAttributes = new AosAttributes(this, reader);
m_AosArmorAttributes = new AosArmorAttributes(this, reader);
Attributes = new AosAttributes(this, reader);
ArmorAttributes = new AosArmorAttributes(this, reader);
goto case 3;
}
case 3:
@ -1213,8 +1196,8 @@ namespace Server.Items
if (version < 4)
{
m_AosAttributes = new AosAttributes(this);
m_AosArmorAttributes = new AosArmorAttributes(this);
Attributes = new AosAttributes(this);
ArmorAttributes = new AosArmorAttributes(this);
}
if (version < 3 && m_Quality == ArmorQuality.Exceptional)
@ -1314,13 +1297,13 @@ namespace Server.Items
}
}
if (m_AosSkillBonuses == null)
m_AosSkillBonuses = new AosSkillBonuses(this);
if (SkillBonuses == null)
SkillBonuses = new AosSkillBonuses(this);
Mobile m = Parent as Mobile;
if (Core.AOS && m != null)
m_AosSkillBonuses.AddTo(m);
SkillBonuses.AddTo(m);
int strBonus = ComputeStatBonus(StatType.Str);
int dexBonus = ComputeStatBonus(StatType.Dex);
@ -1467,7 +1450,7 @@ namespace Server.Items
m.RemoveStatMod(modName + "Int");
if (Core.AOS)
m_AosSkillBonuses.Remove();
SkillBonuses.Remove();
m.Delta(MobileDelta.Armor); // Tell them armor rating has changed
m.CheckStatTimers();
@ -1571,7 +1554,7 @@ namespace Server.Items
if (base.AllowEquippedCast(from))
return true;
return m_AosAttributes.SpellChanneling != 0;
return Attributes.SpellChanneling != 0;
}
public virtual int GetLuckBonus()
@ -1603,92 +1586,92 @@ namespace Server.Items
if (RequiredRace == Race.Elf)
list.Add(1075086); // Elves Only
m_AosSkillBonuses.GetProperties(list);
SkillBonuses.GetProperties(list);
int prop;
if ((prop = ArtifactRarity) > 0)
list.Add(1061078, prop.ToString()); // artifact rarity ~1_val~
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 = GetLowerStatReq()) != 0)
list.Add(1060435, prop.ToString()); // lower requirements ~1_val~%
if ((prop = GetLuckBonus() + m_AosAttributes.Luck) != 0)
if ((prop = GetLuckBonus() + Attributes.Luck) != 0)
list.Add(1060436, prop.ToString()); // luck ~1_val~
if ((prop = m_AosArmorAttributes.MageArmor) != 0)
if ((prop = ArmorAttributes.MageArmor) != 0)
list.Add(1060437); // mage armor
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_AosArmorAttributes.SelfRepair) != 0)
if ((prop = ArmorAttributes.SelfRepair) != 0)
list.Add(1060450, prop.ToString()); // self repair ~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~%
base.AddResistanceProperties(list);

View file

@ -2,13 +2,11 @@ namespace Server.Items
{
public class ElvenGlasses : BaseArmor
{
private AosWeaponAttributes m_AosWeaponAttributes;
[Constructible]
public ElvenGlasses() : base(0x2FB8)
{
Weight = 2;
m_AosWeaponAttributes = new AosWeaponAttributes(this);
WeaponAttributes = new AosWeaponAttributes(this);
}
public ElvenGlasses(Serial serial) : base(serial)
@ -36,11 +34,7 @@ namespace Server.Items
public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All;
[CommandProperty(AccessLevel.GameMaster)]
public AosWeaponAttributes WeaponAttributes
{
get => m_AosWeaponAttributes;
set { }
}
public AosWeaponAttributes WeaponAttributes{ get; private set; }
public override void AppendChildNameProperties(ObjectPropertyList list)
{
@ -48,49 +42,49 @@ namespace Server.Items
int prop;
if ((prop = m_AosWeaponAttributes.HitColdArea) != 0)
if ((prop = WeaponAttributes.HitColdArea) != 0)
list.Add(1060416, prop.ToString()); // hit cold area ~1_val~%
if ((prop = m_AosWeaponAttributes.HitDispel) != 0)
if ((prop = WeaponAttributes.HitDispel) != 0)
list.Add(1060417, prop.ToString()); // hit dispel ~1_val~%
if ((prop = m_AosWeaponAttributes.HitEnergyArea) != 0)
if ((prop = WeaponAttributes.HitEnergyArea) != 0)
list.Add(1060418, prop.ToString()); // hit energy area ~1_val~%
if ((prop = m_AosWeaponAttributes.HitFireArea) != 0)
if ((prop = WeaponAttributes.HitFireArea) != 0)
list.Add(1060419, prop.ToString()); // hit fire area ~1_val~%
if ((prop = m_AosWeaponAttributes.HitFireball) != 0)
if ((prop = WeaponAttributes.HitFireball) != 0)
list.Add(1060420, prop.ToString()); // hit fireball ~1_val~%
if ((prop = m_AosWeaponAttributes.HitHarm) != 0)
if ((prop = WeaponAttributes.HitHarm) != 0)
list.Add(1060421, prop.ToString()); // hit harm ~1_val~%
if ((prop = m_AosWeaponAttributes.HitLeechHits) != 0)
if ((prop = WeaponAttributes.HitLeechHits) != 0)
list.Add(1060422, prop.ToString()); // hit life leech ~1_val~%
if ((prop = m_AosWeaponAttributes.HitLightning) != 0)
if ((prop = WeaponAttributes.HitLightning) != 0)
list.Add(1060423, prop.ToString()); // hit lightning ~1_val~%
if ((prop = m_AosWeaponAttributes.HitLowerAttack) != 0)
if ((prop = WeaponAttributes.HitLowerAttack) != 0)
list.Add(1060424, prop.ToString()); // hit lower attack ~1_val~%
if ((prop = m_AosWeaponAttributes.HitLowerDefend) != 0)
if ((prop = WeaponAttributes.HitLowerDefend) != 0)
list.Add(1060425, prop.ToString()); // hit lower defense ~1_val~%
if ((prop = m_AosWeaponAttributes.HitMagicArrow) != 0)
if ((prop = WeaponAttributes.HitMagicArrow) != 0)
list.Add(1060426, prop.ToString()); // hit magic arrow ~1_val~%
if ((prop = m_AosWeaponAttributes.HitLeechMana) != 0)
if ((prop = WeaponAttributes.HitLeechMana) != 0)
list.Add(1060427, prop.ToString()); // hit mana leech ~1_val~%
if ((prop = m_AosWeaponAttributes.HitPhysicalArea) != 0)
if ((prop = WeaponAttributes.HitPhysicalArea) != 0)
list.Add(1060428, prop.ToString()); // hit physical area ~1_val~%
if ((prop = m_AosWeaponAttributes.HitPoisonArea) != 0)
if ((prop = WeaponAttributes.HitPoisonArea) != 0)
list.Add(1060429, prop.ToString()); // hit poison area ~1_val~%
if ((prop = m_AosWeaponAttributes.HitLeechStam) != 0)
if ((prop = WeaponAttributes.HitLeechStam) != 0)
list.Add(1060430, prop.ToString()); // hit stamina leech ~1_val~%
}
@ -113,12 +107,12 @@ namespace Server.Items
SaveFlag flags = SaveFlag.None;
SetSaveFlag(ref flags, SaveFlag.WeaponAttributes, !m_AosWeaponAttributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.WeaponAttributes, !WeaponAttributes.IsEmpty);
writer.Write((int)flags);
if (GetSaveFlag(flags, SaveFlag.WeaponAttributes))
m_AosWeaponAttributes.Serialize(writer);
WeaponAttributes.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
@ -130,9 +124,9 @@ namespace Server.Items
SaveFlag flags = (SaveFlag)reader.ReadInt();
if (GetSaveFlag(flags, SaveFlag.WeaponAttributes))
m_AosWeaponAttributes = new AosWeaponAttributes(this, reader);
WeaponAttributes = new AosWeaponAttributes(this, reader);
else
m_AosWeaponAttributes = new AosWeaponAttributes(this);
WeaponAttributes = new AosWeaponAttributes(this);
}
private enum SaveFlag

View file

@ -347,7 +347,7 @@ namespace Server.Items
{
Mobile from = state.Mobile;
if (!(World.FindItem(pvSrc.ReadInt32()) is BaseBook book) || !book.Writable ||
if (!(World.FindItem(pvSrc.ReadUInt32()) is BaseBook book) || !book.Writable ||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
return;
@ -364,7 +364,7 @@ namespace Server.Items
{
Mobile from = state.Mobile;
if (!(World.FindItem(pvSrc.ReadInt32()) is BaseBook book) || !book.Writable ||
if (!(World.FindItem(pvSrc.ReadUInt32()) is BaseBook book) || !book.Writable ||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
return;
@ -392,7 +392,7 @@ namespace Server.Items
{
Mobile from = state.Mobile;
if (!(World.FindItem(pvSrc.ReadInt32()) is BaseBook book) || !book.Writable ||
if (!(World.FindItem(pvSrc.ReadUInt32()) is BaseBook book) || !book.Writable ||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
return;

View file

@ -23,10 +23,6 @@ namespace Server.Items
public abstract class BaseClothing : Item, IDyable, IScissorable, IFactionItem, ICraftable, IWearableDurability
{
private AosAttributes m_AosAttributes;
private AosArmorAttributes m_AosClothingAttributes;
private AosElementAttributes m_AosResistances;
private AosSkillBonuses m_AosSkillBonuses;
private Mobile m_Crafter;
private int m_HitPoints;
@ -49,10 +45,10 @@ namespace Server.Items
m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits);
m_AosAttributes = new AosAttributes(this);
m_AosClothingAttributes = new AosArmorAttributes(this);
m_AosSkillBonuses = new AosSkillBonuses(this);
m_AosResistances = new AosElementAttributes(this);
Attributes = new AosAttributes(this);
ClothingAttributes = new AosArmorAttributes(this);
SkillBonuses = new AosSkillBonuses(this);
Resistances = new AosElementAttributes(this);
}
public BaseClothing(Serial serial) : base(serial)
@ -110,32 +106,16 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.GameMaster)]
public AosAttributes Attributes
{
get => m_AosAttributes;
set { }
}
public AosAttributes Attributes{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public AosArmorAttributes ClothingAttributes
{
get => m_AosClothingAttributes;
set { }
}
public AosArmorAttributes ClothingAttributes{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public AosSkillBonuses SkillBonuses
{
get => m_AosSkillBonuses;
set { }
}
public AosSkillBonuses SkillBonuses{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public AosElementAttributes Resistances
{
get => m_AosResistances;
set { }
}
public AosElementAttributes Resistances{ get; private set; }
public virtual int BasePhysicalResistance => 0;
public virtual int BaseFireResistance => 0;
@ -143,11 +123,11 @@ namespace Server.Items
public virtual int BasePoisonResistance => 0;
public virtual int BaseEnergyResistance => 0;
public override int PhysicalResistance => BasePhysicalResistance + m_AosResistances.Physical;
public override int FireResistance => BaseFireResistance + m_AosResistances.Fire;
public override int ColdResistance => BaseColdResistance + m_AosResistances.Cold;
public override int PoisonResistance => BasePoisonResistance + m_AosResistances.Poison;
public override int EnergyResistance => BaseEnergyResistance + m_AosResistances.Energy;
public override int PhysicalResistance => BasePhysicalResistance + Resistances.Physical;
public override int FireResistance => BaseFireResistance + Resistances.Fire;
public override int ColdResistance => BaseColdResistance + Resistances.Cold;
public override int PoisonResistance => BasePoisonResistance + Resistances.Poison;
public override int EnergyResistance => BaseEnergyResistance + Resistances.Energy;
public virtual int ArtifactRarity => 0;
@ -253,6 +233,7 @@ namespace Server.Items
}
catch
{
// ignored
}
from.SendLocalizedMessage(502440); // Scissors can not be used on that to produce anything.
@ -306,7 +287,7 @@ namespace Server.Items
if (25 > Utility.Random(100)) // 25% chance to lower durability
{
if (Core.AOS && m_AosClothingAttributes.SelfRepair > Utility.Random(10))
if (Core.AOS && ClothingAttributes.SelfRepair > Utility.Random(10))
{
HitPoints += 2;
}
@ -355,7 +336,7 @@ namespace Server.Items
public void UnscaleDurability()
{
int scale = 100 + m_AosClothingAttributes.DurabilityBonus;
int scale = 100 + ClothingAttributes.DurabilityBonus;
m_HitPoints = (m_HitPoints * 100 + (scale - 1)) / scale;
m_MaxHitPoints = (m_MaxHitPoints * 100 + (scale - 1)) / scale;
@ -365,7 +346,7 @@ namespace Server.Items
public void ScaleDurability()
{
int scale = 100 + m_AosClothingAttributes.DurabilityBonus;
int scale = 100 + ClothingAttributes.DurabilityBonus;
m_HitPoints = (m_HitPoints * scale + 99) / 100;
m_MaxHitPoints = (m_MaxHitPoints * scale + 99) / 100;
@ -521,7 +502,7 @@ namespace Server.Items
if (!Core.AOS)
return 0;
return m_AosClothingAttributes.LowerStatReq;
return ClothingAttributes.LowerStatReq;
}
public override void OnAdded(IEntity parent)
@ -529,7 +510,7 @@ namespace Server.Items
if (parent is Mobile mob)
{
if (Core.AOS)
m_AosSkillBonuses.AddTo(mob);
SkillBonuses.AddTo(mob);
AddStatBonuses(mob);
mob.CheckStatTimers();
@ -543,7 +524,7 @@ namespace Server.Items
if (parent is Mobile mob)
{
if (Core.AOS)
m_AosSkillBonuses.Remove();
SkillBonuses.Remove();
string modName = Serial.ToString();
@ -562,10 +543,10 @@ namespace Server.Items
if (!(newItem is BaseClothing clothing))
return;
clothing.m_AosAttributes = new AosAttributes(newItem, m_AosAttributes);
clothing.m_AosResistances = new AosElementAttributes(newItem, m_AosResistances);
clothing.m_AosSkillBonuses = new AosSkillBonuses(newItem, m_AosSkillBonuses);
clothing.m_AosClothingAttributes = new AosArmorAttributes(newItem, m_AosClothingAttributes);
clothing.Attributes = new AosAttributes(newItem, Attributes);
clothing.Resistances = new AosElementAttributes(newItem, Resistances);
clothing.SkillBonuses = new AosSkillBonuses(newItem, SkillBonuses);
clothing.ClothingAttributes = new AosArmorAttributes(newItem, ClothingAttributes);
}
public override bool AllowEquippedCast(Mobile from)
@ -573,7 +554,7 @@ namespace Server.Items
if (base.AllowEquippedCast(from))
return true;
return m_AosAttributes.SpellChanneling != 0;
return Attributes.SpellChanneling != 0;
}
public override bool CheckPropertyConfliction(Mobile m)
@ -690,97 +671,97 @@ namespace Server.Items
if (RequiredRace == Race.Elf)
list.Add(1075086); // Elves Only
m_AosSkillBonuses?.GetProperties(list);
SkillBonuses?.GetProperties(list);
int prop;
if ((prop = ArtifactRarity) > 0)
list.Add(1061078, prop.ToString()); // artifact rarity ~1_val~
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_AosClothingAttributes.LowerStatReq) != 0)
if ((prop = ClothingAttributes.LowerStatReq) != 0)
list.Add(1060435, prop.ToString()); // lower requirements ~1_val~%
if ((prop = m_AosAttributes.Luck) != 0)
if ((prop = Attributes.Luck) != 0)
list.Add(1060436, prop.ToString()); // luck ~1_val~
if ((prop = m_AosClothingAttributes.MageArmor) != 0)
if ((prop = ClothingAttributes.MageArmor) != 0)
list.Add(1060437); // mage armor
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_AosClothingAttributes.SelfRepair) != 0)
if ((prop = ClothingAttributes.SelfRepair) != 0)
list.Add(1060450, prop.ToString()); // self repair ~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~%
base.AddResistanceProperties(list);
if ((prop = m_AosClothingAttributes.DurabilityBonus) > 0)
if ((prop = ClothingAttributes.DurabilityBonus) > 0)
list.Add(1060410, prop.ToString()); // durability ~1_val~%
if ((prop = ComputeStatReq(StatType.Str)) > 0)
@ -843,19 +824,19 @@ namespace Server.Items
switch (Utility.Random(5))
{
case 0:
++m_AosResistances.Physical;
++Resistances.Physical;
break;
case 1:
++m_AosResistances.Fire;
++Resistances.Fire;
break;
case 2:
++m_AosResistances.Cold;
++Resistances.Cold;
break;
case 3:
++m_AosResistances.Poison;
++Resistances.Poison;
break;
case 4:
++m_AosResistances.Energy;
++Resistances.Energy;
break;
}
@ -921,10 +902,10 @@ namespace Server.Items
SaveFlag flags = SaveFlag.None;
SetSaveFlag(ref flags, SaveFlag.Resource, m_Resource != DefaultResource);
SetSaveFlag(ref flags, SaveFlag.Attributes, !m_AosAttributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.ClothingAttributes, !m_AosClothingAttributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !m_AosSkillBonuses.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.Resistances, !m_AosResistances.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.Attributes, !Attributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.ClothingAttributes, !ClothingAttributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !SkillBonuses.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.Resistances, !Resistances.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.MaxHitPoints, m_MaxHitPoints != 0);
SetSaveFlag(ref flags, SaveFlag.HitPoints, m_HitPoints != 0);
SetSaveFlag(ref flags, SaveFlag.PlayerConstructed, PlayerConstructed);
@ -938,16 +919,16 @@ namespace Server.Items
writer.WriteEncodedInt((int)m_Resource);
if (GetSaveFlag(flags, SaveFlag.Attributes))
m_AosAttributes.Serialize(writer);
Attributes.Serialize(writer);
if (GetSaveFlag(flags, SaveFlag.ClothingAttributes))
m_AosClothingAttributes.Serialize(writer);
ClothingAttributes.Serialize(writer);
if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
m_AosSkillBonuses.Serialize(writer);
SkillBonuses.Serialize(writer);
if (GetSaveFlag(flags, SaveFlag.Resistances))
m_AosResistances.Serialize(writer);
Resistances.Serialize(writer);
if (GetSaveFlag(flags, SaveFlag.MaxHitPoints))
writer.WriteEncodedInt(m_MaxHitPoints);
@ -983,24 +964,24 @@ namespace Server.Items
m_Resource = DefaultResource;
if (GetSaveFlag(flags, SaveFlag.Attributes))
m_AosAttributes = new AosAttributes(this, reader);
Attributes = new AosAttributes(this, reader);
else
m_AosAttributes = new AosAttributes(this);
Attributes = new AosAttributes(this);
if (GetSaveFlag(flags, SaveFlag.ClothingAttributes))
m_AosClothingAttributes = new AosArmorAttributes(this, reader);
ClothingAttributes = new AosArmorAttributes(this, reader);
else
m_AosClothingAttributes = new AosArmorAttributes(this);
ClothingAttributes = new AosArmorAttributes(this);
if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
m_AosSkillBonuses = new AosSkillBonuses(this, reader);
SkillBonuses = new AosSkillBonuses(this, reader);
else
m_AosSkillBonuses = new AosSkillBonuses(this);
SkillBonuses = new AosSkillBonuses(this);
if (GetSaveFlag(flags, SaveFlag.Resistances))
m_AosResistances = new AosElementAttributes(this, reader);
Resistances = new AosElementAttributes(this, reader);
else
m_AosResistances = new AosElementAttributes(this);
Resistances = new AosElementAttributes(this);
if (GetSaveFlag(flags, SaveFlag.MaxHitPoints))
m_MaxHitPoints = reader.ReadEncodedInt();
@ -1034,10 +1015,10 @@ namespace Server.Items
}
case 3:
{
m_AosAttributes = new AosAttributes(this, reader);
m_AosClothingAttributes = new AosArmorAttributes(this, reader);
m_AosSkillBonuses = new AosSkillBonuses(this, reader);
m_AosResistances = new AosElementAttributes(this, reader);
Attributes = new AosAttributes(this, reader);
ClothingAttributes = new AosArmorAttributes(this, reader);
SkillBonuses = new AosSkillBonuses(this, reader);
Resistances = new AosElementAttributes(this, reader);
goto case 2;
}
@ -1065,10 +1046,10 @@ namespace Server.Items
if (version < 3)
{
m_AosAttributes = new AosAttributes(this);
m_AosClothingAttributes = new AosArmorAttributes(this);
m_AosSkillBonuses = new AosSkillBonuses(this);
m_AosResistances = new AosElementAttributes(this);
Attributes = new AosAttributes(this);
ClothingAttributes = new AosArmorAttributes(this);
SkillBonuses = new AosSkillBonuses(this);
Resistances = new AosElementAttributes(this);
}
if (version < 4)
@ -1080,7 +1061,7 @@ namespace Server.Items
if (Parent is Mobile parent)
{
if (Core.AOS)
m_AosSkillBonuses.AddTo(parent);
SkillBonuses.AddTo(parent);
AddStatBonuses(parent);
parent.CheckStatTimers();

View file

@ -33,7 +33,7 @@ namespace Server.Items
}
else if (m.Map != null && m.Map.CanFit(m.Location, 16, false, false))
{
m.CloseGump(typeof(ResurrectGump));
m.CloseGump<ResurrectGump>();
m.SendGump(new ResurrectGump(m, ResurrectMessage.VirtueShrine));
}
else

View file

@ -144,18 +144,16 @@ namespace Server.Items
}
else
{
from.BeginTarget(-1, false, TargetFlags.None, new TargetStateCallback(Link_OnSecondTarget), door);
from.BeginTarget(-1, false, TargetFlags.None, Link_OnSecondTarget, door);
from.SendMessage("Target the second door to link.");
}
}
private static void Link_OnSecondTarget(Mobile from, object targeted, object state)
private static void Link_OnSecondTarget(Mobile from, object targeted, BaseDoor first)
{
BaseDoor first = (BaseDoor)state;
if (!(targeted is BaseDoor second))
{
from.BeginTarget(-1, false, TargetFlags.None, new TargetStateCallback(Link_OnSecondTarget), first);
from.BeginTarget(-1, false, TargetFlags.None, Link_OnSecondTarget, first);
from.SendMessage("That is not a door. Try again.");
}
else
@ -170,22 +168,19 @@ namespace Server.Items
[Description("Chain-links two or more targeted doors together.")]
private static void ChainLink_OnCommand(CommandEventArgs e)
{
e.Mobile.BeginTarget(-1, false, TargetFlags.None, new TargetStateCallback(ChainLink_OnTarget),
new List<BaseDoor>());
e.Mobile.BeginTarget(-1, false, TargetFlags.None, ChainLink_OnTarget, new List<BaseDoor>());
e.Mobile.SendMessage("Target the first of a sequence of doors to link.");
}
private static void ChainLink_OnTarget(Mobile from, object targeted, object state)
private static void ChainLink_OnTarget(Mobile from, object targeted, List<BaseDoor> list)
{
if (!(targeted is BaseDoor door))
{
from.BeginTarget(-1, false, TargetFlags.None, new TargetStateCallback(ChainLink_OnTarget), state);
from.BeginTarget(-1, false, TargetFlags.None, ChainLink_OnTarget, list);
from.SendMessage("That is not a door. Try again.");
}
else
{
List<BaseDoor> list = (List<BaseDoor>)state;
if (list.Count > 0 && list[0] == door)
{
if (list.Count >= 2)
@ -197,13 +192,13 @@ namespace Server.Items
}
else
{
from.BeginTarget(-1, false, TargetFlags.None, new TargetStateCallback(ChainLink_OnTarget), state);
from.BeginTarget(-1, false, TargetFlags.None, ChainLink_OnTarget, list);
from.SendMessage("You have not yet targeted two unique doors. Target the second door to link.");
}
}
else if (list.Contains(door))
{
from.BeginTarget(-1, false, TargetFlags.None, new TargetStateCallback(ChainLink_OnTarget), state);
from.BeginTarget(-1, false, TargetFlags.None, ChainLink_OnTarget, list);
from.SendMessage(
"You have already targeted that door. Target another door, or retarget the first door to complete the chain.");
}
@ -211,7 +206,7 @@ namespace Server.Items
{
list.Add(door);
from.BeginTarget(-1, false, TargetFlags.None, new TargetStateCallback(ChainLink_OnTarget), state);
from.BeginTarget(-1, false, TargetFlags.None, ChainLink_OnTarget, list);
if (list.Count == 1)
from.SendMessage("Target the second door to link.");

View file

@ -199,7 +199,7 @@ namespace Server.Items
if (item == null)
continue;
List<Item> list = Items;
for (int j = 0; j < list.Count; ++j)
@ -1430,7 +1430,7 @@ namespace Server.Items
new FillableEntry(1, typeof(Arrow))
});
private static Hashtable m_AcquireTable;
private static Dictionary<Type, FillableContent> m_AcquireTable;
private static FillableContent[] m_ContentTypes =
{
@ -1509,7 +1509,7 @@ namespace Server.Items
if (m_AcquireTable == null)
{
m_AcquireTable = new Hashtable();
m_AcquireTable = new Dictionary<Type, FillableContent>();
for (int i = 0; i < m_ContentTypes.Length; ++i)
{
@ -1539,4 +1539,4 @@ namespace Server.Items
return content;
}
}
}
}

View file

@ -38,7 +38,7 @@ namespace Server.Items
KeyValue = key.KeyValue;
DropItem(key);
double tinkering = from.Skills[SkillName.Tinkering].Value;
double tinkering = from.Skills.Tinkering.Value;
int level = (int)(tinkering * 0.8);
RequiredSkill = level - 4;

View file

@ -100,7 +100,7 @@ namespace Server.Items
item is BaseWeapon weapon && weapon.PlayerConstructed ||
item is BaseClothing clothing && clothing.PlayerConstructed)
{
double mining = from.Skills[SkillName.Mining].Value;
double mining = from.Skills.Mining.Value;
if (mining > 100.0)
mining = 100.0;
double amount = ((4 + mining) * craftResource.Amount - 4) * 0.0068;
@ -114,7 +114,7 @@ namespace Server.Items
ingot.Amount = 2;
}
if (difficulty > from.Skills[SkillName.Mining].Value)
if (difficulty > from.Skills.Mining.Value)
{
m_Failure = true;
ingot.Delete();

View file

@ -488,7 +488,7 @@ namespace Server.Items
if (!from.Alive)
return;
from.CloseGump(typeof(RemoveGump));
from.CloseGump<RemoveGump>();
from.SendGump(new RemoveGump(from, this));
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Commands;
namespace Server.Items
@ -10,16 +11,17 @@ namespace Server.Items
private StealableInstance[] m_Artifacts;
private Timer m_RespawnTimer;
private Hashtable m_Table;
private Dictionary<Item, StealableInstance> m_Table;
private StealableArtifactsSpawner() : base(1)
{
Movable = false;
m_Artifacts = new StealableInstance[Entries.Length];
m_Table = new Hashtable(Entries.Length);
m_Table = new Dictionary<Item, StealableInstance>(Entries.Length);
for (int i = 0; i < Entries.Length; i++) m_Artifacts[i] = new StealableInstance(Entries[i]);
for (int i = 0; i < Entries.Length; i++)
m_Artifacts[i] = new StealableInstance(Entries[i]);
m_RespawnTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromMinutes(15.0), CheckRespawn);
}
@ -264,7 +266,7 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
m_Artifacts = new StealableInstance[Entries.Length];
m_Table = new Hashtable(Entries.Length);
m_Table = new Dictionary<Item, StealableInstance>(Entries.Length);
int length = reader.ReadEncodedInt();
@ -290,12 +292,7 @@ namespace Server.Items
public class StealableEntry
{
public StealableEntry(Map map, Point3D location, int minDelay, int maxDelay, Type type) : this(map, location,
minDelay, maxDelay, type, 0)
{
}
public StealableEntry(Map map, Point3D location, int minDelay, int maxDelay, Type type, int hue)
public StealableEntry(Map map, Point3D location, int minDelay, int maxDelay, Type type, int hue = 0)
{
Map = map;
Location = location;
@ -384,4 +381,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -66,8 +66,7 @@ namespace Server.Items
}
else
{
bool vendor, contract;
BaseHouse.IsThereVendor(from.Location, from.Map, out vendor, out contract);
BaseHouse.IsThereVendor(from.Location, from.Map, out bool vendor, out bool contract);
if (vendor)
{

View file

@ -100,7 +100,7 @@ namespace Server.Items
m_From = from;
m_Deed = deed;
from.CloseGump(typeof(InternalGump));
from.CloseGump<InternalGump>();
AddBackground(100, 10, 400, 385, 0xA28);

View file

@ -80,10 +80,10 @@ namespace Server.Items
public void BeginPlace(Mobile from, HolidayTreeType type)
{
from.BeginTarget(-1, true, TargetFlags.None, new TargetStateCallback(Placement_OnTarget), type);
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget, type);
}
public void Placement_OnTarget(Mobile from, object targeted, object state)
public void Placement_OnTarget(Mobile from, object targeted, HolidayTreeType type)
{
if (!(targeted is IPoint3D p))
return;
@ -98,7 +98,7 @@ namespace Server.Items
*/
if (ValidatePlacement(from, loc))
EndPlace(from, (HolidayTreeType)state, loc);
EndPlace(from, type, loc);
}
public void EndPlace(Mobile from, HolidayTreeType type, Point3D loc)
@ -110,7 +110,7 @@ namespace Server.Items
public override void OnDoubleClick(Mobile from)
{
from.CloseGump(typeof(HolidayTreeChoiceGump));
from.CloseGump<HolidayTreeChoiceGump>();
from.SendGump(new HolidayTreeChoiceGump(from, this));
}
}

View file

@ -36,7 +36,7 @@ namespace Server.Items
{
if (RootParent == from)
{
from.CloseGump(typeof(NameChangeDeedGump));
from.CloseGump<NameChangeDeedGump>();
from.SendGump(new NameChangeDeedGump(this));
}
else
@ -55,7 +55,7 @@ namespace Server.Items
m_Sender = sender;
Closable = true;
Dragable = true;
Draggable = true;
Resizable = false;
AddPage(0);

View file

@ -176,7 +176,7 @@ namespace Server.Items
{
if (from.InRange(this, 5))
{
from.CloseGump(typeof(VendorRentalContractGump));
from.CloseGump<VendorRentalContractGump>();
from.SendGump(new VendorRentalContractGump(this, from));
}
else
@ -236,7 +236,7 @@ namespace Server.Items
if (m_Contract.IsUsableBy(from, true, true, true, true))
{
from.CloseGump(typeof(VendorRentalContractGump));
from.CloseGump<VendorRentalContractGump>();
from.SendGump(new VendorRentalContractGump(m_Contract, from));
}
}
@ -339,7 +339,7 @@ namespace Server.Items
if (offeree != null)
{
offeree.CloseGump(typeof(VendorRentalOfferGump));
offeree.CloseGump<VendorRentalOfferGump>();
m_Contract.Offeree = null;
}

View file

@ -1,270 +1,14 @@
namespace Server.Items
{
public abstract class Beard : Item
public static class Beard
{
/*public static Beard CreateByID( int id, int hue )
{
switch ( id )
{
case 0x203E: return new LongBeard( hue );
case 0x203F: return new ShortBeard( hue );
case 0x2040: return new Goatee( hue );
case 0x2041: return new Mustache( hue );
case 0x204B: return new MediumShortBeard( hue );
case 0x204C: return new MediumLongBeard( hue );
case 0x204D: return new Vandyke( hue );
default: return new GenericBeard( id, hue );
}
}*/
protected Beard(int itemID, int hue = 0) : base(itemID)
{
LootType = LootType.Blessed;
Layer = Layer.FacialHair;
Hue = hue;
}
public Beard(Serial serial) : base(serial)
{
}
public override bool DisplayLootType => false;
public override bool VerifyMove(Mobile from)
{
return from.AccessLevel >= AccessLevel.GameMaster;
}
public override DeathMoveResult OnParentDeath(Mobile parent)
{
//Dupe( Amount );
parent.FacialHairItemID = ItemID;
parent.FacialHairHue = Hue;
return DeathMoveResult.MoveToCorpse;
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
LootType = LootType.Blessed;
int version = reader.ReadInt();
}
}
public class GenericBeard : Beard
{
private GenericBeard(int itemID, int hue = 0) : base(itemID, hue)
{
}
public GenericBeard(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class LongBeard : Beard
{
private LongBeard(int hue = 0)
: base(0x203E, hue)
{
}
public LongBeard(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class ShortBeard : Beard
{
private ShortBeard(int hue = 0)
: base(0x203f, hue)
{
}
public ShortBeard(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class Goatee : Beard
{
private Goatee(int hue = 0)
: base(0x2040, hue)
{
}
public Goatee(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class Mustache : Beard
{
private Mustache(int hue = 0)
: base(0x2041, hue)
{
}
public Mustache(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class MediumShortBeard : Beard
{
private MediumShortBeard(int hue = 0)
: base(0x204B, hue)
{
}
public MediumShortBeard(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class MediumLongBeard : Beard
{
private MediumLongBeard(int hue = 0)
: base(0x204C, hue)
{
}
public MediumLongBeard(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class Vandyke : Beard
{
private Vandyke(int hue = 0)
: base(0x204D, hue)
{
}
public Vandyke(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
public static int LongBeard = 0x203E;
public static int ShortBeard = 0x203f;
public static int Goatee = 0x2040;
public static int Mustache = 0x2041;
public static int MediumShortBeard = 0x204B;
public static int MediumLongBeard = 0x204C;
public static int Vandyke = 0x204D;
}
}

View file

@ -1,407 +1,31 @@
namespace Server.Items
{
public abstract class Hair : Item
public static class Hair
{
/*
public static Hair GetRandomHair( bool female )
{
return GetRandomHair( female, Utility.RandomHairHue() );
}
public static Hair GetRandomHair( bool female, int hairHue )
{
if ( female )
{
switch ( Utility.Random( 9 ) )
{
case 0: return new Afro( hairHue );
case 1: return new KrisnaHair( hairHue );
case 2: return new PageboyHair( hairHue );
case 3: return new PonyTail( hairHue );
case 4: return new ReceedingHair( hairHue );
case 5: return new TwoPigTails( hairHue );
case 6: return new ShortHair( hairHue );
case 7: return new LongHair( hairHue );
default: return new BunsHair( hairHue );
}
}
else
{
switch ( Utility.Random( 8 ) )
{
case 0: return new Afro( hairHue );
case 1: return new KrisnaHair( hairHue );
case 2: return new PageboyHair( hairHue );
case 3: return new PonyTail( hairHue );
case 4: return new ReceedingHair( hairHue );
case 5: return new TwoPigTails( hairHue );
case 6: return new ShortHair( hairHue );
default: return new LongHair( hairHue );
}
}
}
public static Hair CreateByID( int id, int hue )
{
switch ( id )
{
case 0x203B: return new ShortHair( hue );
case 0x203C: return new LongHair( hue );
case 0x203D: return new PonyTail( hue );
case 0x2044: return new Mohawk( hue );
case 0x2045: return new PageboyHair( hue );
case 0x2046: return new BunsHair( hue );
case 0x2047: return new Afro( hue );
case 0x2048: return new ReceedingHair( hue );
case 0x2049: return new TwoPigTails( hue );
case 0x204A: return new KrisnaHair( hue );
default: return new GenericHair( id, hue );
}
}
* */
protected Hair(int itemID, int hue = 0)
: base(itemID)
{
LootType = LootType.Blessed;
Layer = Layer.Hair;
Hue = hue;
}
public Hair(Serial serial)
: base(serial)
{
}
public override bool DisplayLootType => false;
public override bool VerifyMove(Mobile from)
{
return from.AccessLevel >= AccessLevel.GameMaster;
}
public override DeathMoveResult OnParentDeath(Mobile parent)
{
// Dupe( Amount );
parent.HairItemID = ItemID;
parent.HairHue = Hue;
return DeathMoveResult.MoveToCorpse;
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
LootType = LootType.Blessed;
int version = reader.ReadInt();
}
}
public class GenericHair : Hair
{
private GenericHair(int itemID, int hue = 0)
: base(itemID, hue)
{
}
public GenericHair(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class Mohawk : Hair
{
private Mohawk(int hue = 0)
: base(0x2044, hue)
{
}
public Mohawk(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class PageboyHair : Hair
{
private PageboyHair(int hue = 0)
: base(0x2045, hue)
{
}
public PageboyHair(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class BunsHair : Hair
{
private BunsHair(int hue = 0)
: base(0x2046, hue)
{
}
public BunsHair(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class LongHair : Hair
{
private LongHair(int hue = 0)
: base(0x203C, hue)
{
}
public LongHair(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class ShortHair : Hair
{
private ShortHair(int hue = 0)
: base(0x203B, hue)
{
}
public ShortHair(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class PonyTail : Hair
{
private PonyTail(int hue = 0)
: base(0x203D, hue)
{
}
public PonyTail(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class Afro : Hair
{
private Afro(int hue = 0)
: base(0x2047, hue)
{
}
public Afro(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class ReceedingHair : Hair
{
private ReceedingHair(int hue = 0)
: base(0x2048, hue)
{
}
public ReceedingHair(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class TwoPigTails : Hair
{
private TwoPigTails(int hue = 0)
: base(0x2049, hue)
{
}
public TwoPigTails(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class KrisnaHair : Hair
{
private KrisnaHair(int hue = 0)
: base(0x204A, hue)
{
}
public KrisnaHair(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
// Human
public static int Long = 0x203C;
public static int Shor = 0x203B;
public static int PonyTail = 0x203D;
public static int Mohawk = 0x2044;
public static int Pageboy = 0x2045;
public static int Bun = 0x2046; // Female Only
public static int Afro = 0x2047;
public static int Receding = 0x2048; // Male Only
public static int TwoPigTails = 0x2049;
public static int Krisna = 0x204A;
// Elf
public static int MidLongElf = 0x2FBF; // Male Only
public static int LongFeather = 0x2FC0;
public static int ShortElf = 0x2FC1;
public static int Mullet = 0x2FC2;
public static int Flower = 0x2FCC; // Female only
public static int LongElf = 0x2FCD; // Male Only
public static int Knob = 0x2FCE;
public static int Braided = 0x2FCF;
public static int BunElf = 0x2FD0; // Female Only
public static int Spiked = 0x2FD1;
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Engines.Plants;
using Server.Engines.Quests;
using Server.Engines.Quests.Hag;
@ -808,24 +809,27 @@ namespace Server.Items
{
QuestSystem qs = player.Quest;
if (qs is WitchApprenticeQuest)
if (qs.FindObjective(typeof(FindIngredientObjective)) is FindIngredientObjective obj &&
!obj.Completed && obj.Ingredient == Ingredient.SwampWater)
if (!(qs is WitchApprenticeQuest))
return;
FindIngredientObjective obj = qs.FindObjective<FindIngredientObjective>();
if (obj?.Completed == true && obj.Ingredient == Ingredient.SwampWater)
{
bool contains = false;
for (int i = 0; !contains && i < m_SwampTiles.Length; i += 2)
contains = tileID >= m_SwampTiles[i] && tileID <= m_SwampTiles[i + 1];
if (contains)
{
bool contains = false;
Delete();
for (int i = 0; !contains && i < m_SwampTiles.Length; i += 2)
contains = tileID >= m_SwampTiles[i] && tileID <= m_SwampTiles[i + 1];
if (contains)
{
Delete();
player.SendLocalizedMessage(
1055035); // You dip the container into the disgusting swamp water, collecting enough for the Hag's vile stew.
obj.Complete();
}
player.SendLocalizedMessage(
1055035); // You dip the container into the disgusting swamp water, collecting enough for the Hag's vile stew.
obj.Complete();
}
}
}
}
}
@ -942,9 +946,9 @@ namespace Server.Items
if (from is PlayerMobile player)
if (player.Quest is SolenMatriarchQuest qs)
{
QuestObjective obj = qs.FindObjective(typeof(GatherWaterObjective));
QuestObjective obj = qs.FindObjective<GatherWaterObjective>();
if (obj != null && !obj.Completed)
if (obj?.Completed == false)
{
BaseAddon vat = component.Addon;
@ -1086,7 +1090,7 @@ namespace Server.Items
#region Effects of achohol
private static Hashtable m_Table = new Hashtable();
private static Dictionary<Mobile, Timer> m_Table = new Dictionary<Mobile, Timer>();
public static void Initialize()
{
@ -1102,7 +1106,7 @@ namespace Server.Items
{
if (from.BAC > 0 && from.Map != Map.Internal && !from.Deleted)
{
Timer t = (Timer)m_Table[from];
Timer t = m_Table[from];
if (t == null)
{
@ -1117,7 +1121,7 @@ namespace Server.Items
}
else
{
Timer t = (Timer)m_Table[from];
Timer t = m_Table[from];
if (t != null)
{
@ -1189,4 +1193,4 @@ namespace Server.Items
#endregion
}
}
}

View file

@ -99,7 +99,7 @@ namespace Server.Items
if (IsHeatSource(targeted))
{
if (from.BeginAction(typeof(CookableFood)))
if (from.BeginAction<CookableFood>())
{
from.PlaySound(0x225);
@ -133,7 +133,7 @@ namespace Server.Items
protected override void OnTick()
{
m_From.EndAction(typeof(CookableFood));
m_From.EndAction<CookableFood>();
if (m_From.Map != m_Map || m_Point != null && m_From.GetDistanceToSqrt(m_Point) > 3)
{

View file

@ -548,7 +548,7 @@ namespace Server.Items
}
else if ( targeted is TribalBerry )
{
if ( from.Skills[SkillName.Cooking].Base >= 80.0 )
if ( from.Skills.Cooking.Base >= 80.0 )
{
m_Item.Delete();
((TribalBerry)targeted).Delete();

View file

@ -117,9 +117,9 @@ namespace Server.Engines.Mahjong
private void BuildWalls()
{
Tiles = new MahjongTile[17 * 8];
Tiles = new MahjongTile[136];
MahjongTileTypeGenerator typeGenerator = new MahjongTileTypeGenerator(4);
MahjongTileTypeGenerator typeGenerator = new MahjongTileTypeGenerator();
int i = 0;

View file

@ -40,7 +40,7 @@ namespace Server.Engines.Mahjong
public static void OnPacket(NetState state, PacketReader pvSrc)
{
MahjongGame game = World.FindItem(pvSrc.ReadInt32()) as MahjongGame;
MahjongGame game = World.FindItem(pvSrc.ReadUInt32()) as MahjongGame;
game?.Players.CheckPlayers();

View file

@ -1,4 +1,4 @@
using System.Collections;
using System.Collections.Generic;
namespace Server.Engines.Mahjong
{
@ -8,12 +8,12 @@ namespace Server.Engines.Mahjong
private Mobile[] m_Players;
private bool[] m_PublicHand;
private int[] m_Scores;
private ArrayList m_Spectators;
private List<Mobile> m_Spectators;
public MahjongPlayers(MahjongGame game, int maxPlayers, int baseScore)
{
Game = game;
m_Spectators = new ArrayList();
m_Spectators = new List<Mobile>();
m_Players = new Mobile[maxPlayers];
m_InGame = new bool[maxPlayers];
@ -27,7 +27,7 @@ namespace Server.Engines.Mahjong
public MahjongPlayers(MahjongGame game, GenericReader reader)
{
Game = game;
m_Spectators = new ArrayList();
m_Spectators = new List<Mobile>();
int version = reader.ReadInt();
@ -121,16 +121,17 @@ namespace Server.Engines.Mahjong
m_Players[index].SendLocalizedMessage(value ? 1062775 : 1062776); // Your hand is [not] publicly viewable.
}
public ArrayList GetInGameMobiles(bool players, bool spectators)
public List<Mobile> GetInGameMobiles(bool players, bool spectators)
{
ArrayList list = new ArrayList();
List<Mobile> list = new List<Mobile>();
if (players)
for (int i = 0; i < m_Players.Length; i++)
if (IsInGamePlayer(i))
list.Add(m_Players[i]);
if (spectators) list.AddRange(m_Spectators);
if (spectators)
list.AddRange(m_Spectators);
return list;
}
@ -429,7 +430,7 @@ namespace Server.Engines.Mahjong
public void SendGeneralPacket(bool players, bool spectators)
{
ArrayList mobiles = GetInGameMobiles(players, spectators);
List<Mobile> mobiles = GetInGameMobiles(players, spectators);
if (mobiles.Count == 0)
return;
@ -438,24 +439,27 @@ namespace Server.Engines.Mahjong
generalInfo.Acquire();
foreach (Mobile mobile in mobiles) mobile.Send(generalInfo);
foreach (Mobile mobile in mobiles)
mobile.Send(generalInfo);
generalInfo.Release();
}
public void SendTilesPacket(bool players, bool spectators)
{
foreach (Mobile mobile in GetInGameMobiles(players, spectators)) mobile.Send(new MahjongTilesInfo(Game, mobile));
foreach (Mobile mobile in GetInGameMobiles(players, spectators))
mobile.Send(new MahjongTilesInfo(Game, mobile));
}
public void SendTilePacket(MahjongTile tile, bool players, bool spectators)
{
foreach (Mobile mobile in GetInGameMobiles(players, spectators)) mobile.Send(new MahjongTileInfo(tile, mobile));
foreach (Mobile mobile in GetInGameMobiles(players, spectators))
mobile.Send(new MahjongTileInfo(tile, mobile));
}
public void SendRelievePacket(bool players, bool spectators)
{
ArrayList mobiles = GetInGameMobiles(players, spectators);
List<Mobile> mobiles = GetInGameMobiles(players, spectators);
if (mobiles.Count == 0)
return;
@ -464,19 +468,22 @@ namespace Server.Engines.Mahjong
relieve.Acquire();
foreach (Mobile mobile in mobiles) mobile.Send(relieve);
foreach (Mobile mobile in mobiles)
mobile.Send(relieve);
relieve.Release();
}
public void SendLocalizedMessage(int number)
{
foreach (Mobile mobile in GetInGameMobiles(true, true)) mobile.SendLocalizedMessage(number);
foreach (Mobile mobile in GetInGameMobiles(true, true))
mobile.SendLocalizedMessage(number);
}
public void SendLocalizedMessage(int number, string args)
{
foreach (Mobile mobile in GetInGameMobiles(true, true)) mobile.SendLocalizedMessage(number, args);
foreach (Mobile mobile in GetInGameMobiles(true, true))
mobile.SendLocalizedMessage(number, args);
}
public void Save(GenericWriter writer)

View file

@ -1,24 +1,29 @@
using System.Collections;
using System.Collections.Generic;
namespace Server.Engines.Mahjong
{
public class MahjongTileTypeGenerator
{
public MahjongTileTypeGenerator(int count)
public MahjongTileTypeGenerator()
{
LeftTileTypes = new ArrayList(34 * count);
LeftTileTypes = new List<MahjongTileType>(136);
for (int i = 1; i <= 34; i++)
for (int j = 0; j < count; j++)
LeftTileTypes.Add((MahjongTileType)i);
{
MahjongTileType tile = (MahjongTileType)i;
LeftTileTypes.Add(tile);
LeftTileTypes.Add(tile);
LeftTileTypes.Add(tile);
LeftTileTypes.Add(tile);
}
}
public ArrayList LeftTileTypes{ get; }
public List<MahjongTileType> LeftTileTypes{ get; }
public MahjongTileType Next()
{
int random = Utility.Random(LeftTileTypes.Count);
MahjongTileType next = (MahjongTileType)LeftTileTypes[random];
MahjongTileType next = LeftTileTypes[random];
LeftTileTypes.RemoveAt(random);
return next;

View file

@ -399,7 +399,7 @@ namespace Server.Items
if (house != null && house.IsOwner(from))
{
from.SendLocalizedMessage(1062838); // Where would you like to place this decoration?
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget, null);
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget);
}
else
{
@ -412,7 +412,7 @@ namespace Server.Items
}
}
public void Placement_OnTarget(Mobile from, object targeted, object state)
public void Placement_OnTarget(Mobile from, object targeted)
{
if (!(targeted is IPoint3D p) || Deleted)
return;

View file

@ -19,9 +19,6 @@ namespace Server.Items
public abstract class BaseJewel : Item, ICraftable
{
private AosAttributes m_AosAttributes;
private AosElementAttributes m_AosResistances;
private AosSkillBonuses m_AosSkillBonuses;
private GemType m_GemType;
private int m_HitPoints;
private int m_MaxHitPoints;
@ -29,9 +26,9 @@ namespace Server.Items
public BaseJewel(int itemID, Layer layer) : base(itemID)
{
m_AosAttributes = new AosAttributes(this);
m_AosResistances = new AosElementAttributes(this);
m_AosSkillBonuses = new AosSkillBonuses(this);
Attributes = new AosAttributes(this);
Resistances = new AosElementAttributes(this);
SkillBonuses = new AosSkillBonuses(this);
m_Resource = CraftResource.Iron;
m_GemType = GemType.None;
@ -76,25 +73,13 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.Player)]
public AosAttributes Attributes
{
get => m_AosAttributes;
set { }
}
public AosAttributes Attributes{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public AosElementAttributes Resistances
{
get => m_AosResistances;
set { }
}
public AosElementAttributes Resistances{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public AosSkillBonuses SkillBonuses
{
get => m_AosSkillBonuses;
set { }
}
public AosSkillBonuses SkillBonuses{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
@ -118,11 +103,11 @@ namespace Server.Items
}
}
public override int PhysicalResistance => m_AosResistances.Physical;
public override int FireResistance => m_AosResistances.Fire;
public override int ColdResistance => m_AosResistances.Cold;
public override int PoisonResistance => m_AosResistances.Poison;
public override int EnergyResistance => m_AosResistances.Energy;
public override int PhysicalResistance => Resistances.Physical;
public override int FireResistance => Resistances.Fire;
public override int ColdResistance => Resistances.Cold;
public override int PoisonResistance => Resistances.Poison;
public override int EnergyResistance => Resistances.Energy;
public virtual int BaseGemTypeNumber => 0;
public virtual int InitMinHits => 0;
@ -192,20 +177,20 @@ namespace Server.Items
if (!(newItem is BaseJewel jewel))
return;
jewel.m_AosAttributes = new AosAttributes(newItem, m_AosAttributes);
jewel.m_AosResistances = new AosElementAttributes(newItem, m_AosResistances);
jewel.m_AosSkillBonuses = new AosSkillBonuses(newItem, m_AosSkillBonuses);
jewel.Attributes = new AosAttributes(newItem, Attributes);
jewel.Resistances = new AosElementAttributes(newItem, Resistances);
jewel.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)
{
@ -229,7 +214,7 @@ namespace Server.Items
{
if (Core.AOS && parent is Mobile from)
{
m_AosSkillBonuses.Remove();
SkillBonuses.Remove();
string modName = Serial.ToString();
@ -245,83 +230,83 @@ namespace Server.Items
{
base.GetProperties(list);
m_AosSkillBonuses.GetProperties(list);
SkillBonuses.GetProperties(list);
int prop;
if ((prop = ArtifactRarity) > 0)
list.Add(1061078, prop.ToString()); // artifact rarity ~1_val~
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~%
base.AddResistanceProperties(list);
@ -342,9 +327,9 @@ namespace Server.Items
writer.WriteEncodedInt((int)m_Resource);
writer.WriteEncodedInt((int)m_GemType);
m_AosAttributes.Serialize(writer);
m_AosResistances.Serialize(writer);
m_AosSkillBonuses.Serialize(writer);
Attributes.Serialize(writer);
Resistances.Serialize(writer);
SkillBonuses.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
@ -371,18 +356,18 @@ namespace Server.Items
}
case 1:
{
m_AosAttributes = new AosAttributes(this, reader);
m_AosResistances = new AosElementAttributes(this, reader);
m_AosSkillBonuses = new AosSkillBonuses(this, reader);
Attributes = new AosAttributes(this, reader);
Resistances = new AosElementAttributes(this, reader);
SkillBonuses = new AosSkillBonuses(this, reader);
Mobile m = Parent as Mobile;
if (Core.AOS && m != null)
m_AosSkillBonuses.AddTo(m);
SkillBonuses.AddTo(m);
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 (m != null && (strBonus != 0 || dexBonus != 0 || intBonus != 0))
{
@ -404,9 +389,9 @@ namespace Server.Items
}
case 0:
{
m_AosAttributes = new AosAttributes(this);
m_AosResistances = new AosElementAttributes(this);
m_AosSkillBonuses = new AosSkillBonuses(this);
Attributes = new AosAttributes(this);
Resistances = new AosElementAttributes(this);
SkillBonuses = new AosSkillBonuses(this);
break;
}

View file

@ -16,7 +16,7 @@ namespace Server.Items
public override void CraftInit(Mobile from)
{
double skillValue = from.Skills[SkillName.Cartography].Value;
double skillValue = from.Skills.Cartography.Value;
int dist = 64 + (int)(skillValue * 4);
if (dist < 200)

View file

@ -16,7 +16,7 @@ namespace Server.Items
public override void CraftInit(Mobile from)
{
double skillValue = from.Skills[SkillName.Cartography].Value;
double skillValue = from.Skills.Cartography.Value;
int dist = 64 + (int)(skillValue * 2);
SetDisplay(from.X - dist, from.Y - dist, from.X + dist, from.Y + dist, 200, 200);

View file

@ -196,9 +196,7 @@ namespace Server.Items
public virtual void AddWorldPin(int x, int y)
{
int mapX, mapY;
ConvertToMap(x, y, out mapX, out mapY);
ConvertToMap(x, y, out int mapX, out int mapY);
AddPin(mapX, mapY);
}
@ -285,7 +283,7 @@ namespace Server.Items
{
Mobile from = state.Mobile;
if (!(World.FindItem(pvSrc.ReadInt32()) is MapItem map))
if (!(World.FindItem(pvSrc.ReadUInt32()) is MapItem map))
return;
int command = pvSrc.ReadByte();

View file

@ -16,7 +16,7 @@ namespace Server.Items
public override void CraftInit(Mobile from)
{
double skillValue = from.Skills[SkillName.Cartography].Value;
double skillValue = from.Skills.Cartography.Value;
int dist = 64 + (int)(skillValue * 10);
if (dist < 200)

View file

@ -326,7 +326,7 @@ namespace Server.Items
from.SendLocalizedMessage(
503031); // You did not decode this map and have no clue where to look for the treasure.
}
else if (!from.CanBeginAction(typeof(TreasureMap)))
else if (!from.CanBeginAction<TreasureMap>())
{
from.SendLocalizedMessage(503020); // You are already digging treasure.
}
@ -390,7 +390,7 @@ namespace Server.Items
private bool HasRequiredSkill(Mobile from)
{
return from.Skills[SkillName.Cartography].Value >= GetMinSkillLevel();
return from.Skills.Cartography.Value >= GetMinSkillLevel();
}
public void Decode(Mobile from)
@ -410,7 +410,7 @@ namespace Server.Items
{
double minSkill = GetMinSkillLevel();
if (from.Skills[SkillName.Cartography].Value < minSkill)
if (from.Skills.Cartography.Value < minSkill)
from.SendLocalizedMessage(503013); // The map is too difficult to attempt to decode.
double maxSkill = minSkill + 60.0;
@ -591,7 +591,7 @@ namespace Server.Items
from.SendLocalizedMessage(
503031); // You did not decode this map and have no clue where to look for the treasure.
}
else if (!from.CanBeginAction(typeof(TreasureMap)))
else if (!from.CanBeginAction<TreasureMap>())
{
from.SendLocalizedMessage(503020); // You are already digging treasure.
}
@ -610,7 +610,7 @@ namespace Server.Items
Point3D targ3D = (p as Item)?.GetWorldLocation() ?? new Point3D(p);
int maxRange;
double skillValue = from.Skills[SkillName.Mining].Value;
double skillValue = from.Skills.Mining.Value;
if (skillValue >= 100.0)
maxRange = 4;
@ -637,10 +637,10 @@ namespace Server.Items
{
int z = map.GetAverageZ(x, y);
if (!map.CanFit(x, y, z, 16, true, true))
if (!map.CanFit(x, y, z, 16, true))
from.SendLocalizedMessage(
503021); // You have found the treasure chest but something is keeping it from being dug up.
else if (from.BeginAction(typeof(TreasureMap)))
else if (from.BeginAction<TreasureMap>())
new DigTimer(from, m_Map, new Point3D(x, y, z), map).Start();
else
from.SendLocalizedMessage(503020); // You are already digging treasure.
@ -738,7 +738,7 @@ namespace Server.Items
private void Terminate()
{
Stop();
m_From.EndAction(typeof(TreasureMap));
m_From.EndAction<TreasureMap>();
m_Chest?.Delete();
@ -823,7 +823,7 @@ namespace Server.Items
if (m_Chest != null && m_Chest.Location.Z >= m_Location.Z)
{
Stop();
m_From.EndAction(typeof(TreasureMap));
m_From.EndAction<TreasureMap>();
m_Chest.Temporary = false;
m_TreasureMap.Completed = true;

View file

@ -18,7 +18,7 @@ namespace Server.Items
{
// Unlike the others, world map is not based on crafted location
double skillValue = from.Skills[SkillName.Cartography].Value;
double skillValue = from.Skills.Cartography.Value;
int x20 = (int)(skillValue * 20);
int size = 25 + (int)(skillValue * 6.6);

View file

@ -35,7 +35,7 @@ namespace Server.Items
public int GetChargesFor(Mobile m)
{
int v = (int)(m.Skills[SkillName.Tailoring].Value / 5);
int v = (int)(m.Skills.Tailoring.Value / 5);
if (v < 16)
return 16;
@ -104,7 +104,7 @@ namespace Server.Items
else Amount--;
}
}
else if (from.Skills[SkillName.Tailoring].Value >= 80.0)
else if (from.Skills.Tailoring.Value >= 80.0)
{
bool isExceptional = clothing?.Quality == ClothingQuality.Exceptional ||
armor?.Quality == ArmorQuality.Exceptional ||

View file

@ -233,16 +233,16 @@ namespace Server.Items
if (qs is DarkTidesQuest)
{
QuestObjective obj = qs.FindObjective(typeof(CashBankCheckObjective));
QuestObjective obj = qs.FindObjective<CashBankCheckObjective>();
if (obj != null && !obj.Completed) obj.Complete();
if (obj?.Completed == false) obj.Complete();
}
if (qs is UzeraanTurmoilQuest)
{
QuestObjective obj = qs.FindObjective(typeof(Engines.Quests.Haven.CashBankCheckObjective));
if (obj != null && !obj.Completed) obj.Complete();
if (obj?.Completed == false) obj.Complete();
}
}
}

View file

@ -31,7 +31,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(1040019); // The bola must be in your pack to use it.
}
else if (!from.CanBeginAction(typeof(Bola)))
else if (!from.CanBeginAction<Bola>())
{
from.SendLocalizedMessage(1049624); // You have to wait a few moments before you can use another bola!
}
@ -62,18 +62,8 @@ namespace Server.Items
}
}
private static void ReleaseBolaLock(object state)
private static void FinishThrow(Mobile from, Mobile to)
{
((Mobile)state).EndAction(typeof(Bola));
}
private static void FinishThrow(object state)
{
object[] states = (object[])state;
Mobile from = (Mobile)states[0];
Mobile to = (Mobile)states[1];
if (Core.AOS)
new Bola().MoveToWorld(to.Location, to.Map);
@ -99,7 +89,7 @@ namespace Server.Items
to.Damage(1);
Timer.DelayCall(TimeSpan.FromSeconds(2.0), new TimerStateCallback(ReleaseBolaLock), from);
Timer.DelayCall(TimeSpan.FromSeconds(2.0), () => from.EndAction<Bola>());
}
private static bool HasFreeHands(Mobile from)
@ -197,7 +187,7 @@ namespace Server.Items
else if (!from.CanBeHarmful(to))
{
}
else if (from.BeginAction(typeof(Bola)))
else if (from.BeginAction<Bola>())
{
EtherealMount.StopMounting(from);
@ -209,8 +199,7 @@ namespace Server.Items
from.Animate(11, 5, 1, true, false, 0);
from.MovingEffect(to, 0x26AC, 10, 0, false, false);
Timer.DelayCall(TimeSpan.FromSeconds(0.5), new TimerStateCallback(FinishThrow),
new object[] { from, to });
Timer.DelayCall(TimeSpan.FromSeconds(0.5), () => FinishThrow(from, to));
}
else
{

View file

@ -213,7 +213,7 @@ namespace Server.Items
int packetID = pvSrc.ReadByte();
if (!(World.FindItem(pvSrc.ReadInt32()) is BaseBulletinBoard board) || !board.CheckRange(from))
if (!(World.FindItem(pvSrc.ReadUInt32()) is BaseBulletinBoard board) || !board.CheckRange(from))
return;
switch (packetID)
@ -235,7 +235,7 @@ namespace Server.Items
public static void BBRequestContent(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
{
if (!(World.FindItem(pvSrc.ReadInt32()) is BulletinMessage msg) || msg.Parent != board)
if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board)
return;
from.Send(new BBMessageContent(board, msg));
@ -243,7 +243,7 @@ namespace Server.Items
public static void BBRequestHeader(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
{
if (!(World.FindItem(pvSrc.ReadInt32()) is BulletinMessage msg) || msg.Parent != board)
if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board)
return;
from.Send(new BBMessageHeader(board, msg));
@ -251,7 +251,7 @@ namespace Server.Items
public static void BBPostMessage(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
{
BulletinMessage thread = World.FindItem(pvSrc.ReadInt32()) as BulletinMessage;
BulletinMessage thread = World.FindItem(pvSrc.ReadUInt32()) as BulletinMessage;
if (thread != null && thread.Parent != board)
thread = null;
@ -292,7 +292,7 @@ namespace Server.Items
public static void BBRemoveMessage(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
{
if (!(World.FindItem(pvSrc.ReadInt32()) is BulletinMessage msg) || msg.Parent != board)
if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board)
return;
if (from.AccessLevel < AccessLevel.GameMaster && msg.Poster != from)

View file

@ -25,7 +25,7 @@ namespace Server.Items
return;
}
double tinkerSkill = from.Skills[SkillName.Tinkering].Value;
double tinkerSkill = from.Skills.Tinkering.Value;
if (tinkerSkill < 60.0)
{

View file

@ -861,10 +861,7 @@ namespace Server.Items
public bool GetRestoreInfo(Item item, ref Point3D loc)
{
if (m_RestoreTable == null || item == null)
return false;
return m_RestoreTable.TryGetValue(item, out loc);
return item != null && m_RestoreTable?.TryGetValue(item, out loc) == true;
}
public void SetRestoreInfo(Item item, Point3D loc)
@ -1026,8 +1023,8 @@ namespace Server.Items
if (qs is UzeraanTurmoilQuest)
{
if (qs.FindObjective(typeof(GetDaemonBoneObjective)) is GetDaemonBoneObjective obj &&
obj.CorpseWithBone == this && (!obj.Completed || UzeraanTurmoilQuest.HasLostDaemonBone(player)))
GetDaemonBoneObjective obj = qs.FindObjective<GetDaemonBoneObjective>();
if (obj?.CorpseWithBone == this && (!obj.Completed || UzeraanTurmoilQuest.HasLostDaemonBone(player)))
{
Item bone = new QuestDaemonBone();
@ -1052,8 +1049,8 @@ namespace Server.Items
}
else if (qs is TheSummoningQuest)
{
if (qs.FindObjective(typeof(VanquishDaemonObjective)) is VanquishDaemonObjective obj &&
obj.Completed && obj.CorpseWithSkull == this)
VanquishDaemonObjective obj = qs.FindObjective<VanquishDaemonObjective>();
if (obj?.Completed == true && obj.CorpseWithSkull == this)
{
GoldenSkull sk = new GoldenSkull();

View file

@ -216,7 +216,7 @@ namespace Server.Items
private IEntity ReadEntity(GenericReader reader)
{
return World.FindEntity(reader.ReadInt());
return World.FindEntity(reader.ReadUInt());
}
public override void Deserialize(GenericReader reader)

View file

@ -173,22 +173,17 @@ namespace Server.Items
IEntity to = p as IEntity ?? new Entity(Serial.Zero, new Point3D(p), Map);
Effects.SendMovingEffect(from, to, ItemID, 7, 0, false, false, Hue, 0);
Effects.SendMovingEffect(from, to, ItemID, 7, 0, false, false, Hue);
Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(FirebombReposition_OnTick),
new object[] { p, Map });
Timer.DelayCall(TimeSpan.FromSeconds(1.0), () => FirebombReposition_OnTick(p, Map));
Internalize();
}
private void FirebombReposition_OnTick(object state)
private void FirebombReposition_OnTick(IPoint3D p, Map map)
{
if (Deleted)
return;
object[] states = (object[])state;
IPoint3D p = (IPoint3D)states[0];
Map map = (Map)states[1];
MoveToWorld(new Point3D(p), map);
}

View file

@ -71,15 +71,17 @@ namespace Server.Items
int y = p.Y - 2 + Utility.Random(5);
int z = p.Z;
if (!f.CanFit(x, y, z, 1, false, false, true))
if (!f.CanFit(x, y, z, 1, false, false))
{
z = f.GetAverageZ(x, y);
if (!f.CanFit(x, y, z, 1, false, false, true))
if (!f.CanFit(x, y, z, 1, false, false))
continue;
}
new Blood().MoveToWorld(new Point3D(x, y, z), f);
Point3D loc = f.GetRandomNearbyLocation(p, 2, -2, 4, 1);
new Blood().MoveToWorld(loc, f);
}
}
@ -110,4 +112,4 @@ namespace Server.Items
ItemID = 4702;
}
}
}
}

View file

@ -35,7 +35,7 @@ namespace Server.Items
{
if (from.InRange(GetWorldLocation(), 1))
{
from.CloseGump(typeof(HairDyeGump));
from.CloseGump<HairDyeGump>();
from.SendGump(new HairDyeGump(this));
}
else

View file

@ -68,7 +68,7 @@ namespace Server.Items
if (!CheckUse(this, from))
return;
if (from.FindGump(typeof(InternalGump)) == null)
if (!from.HasGump<InternalGump>())
from.SendGump(new InternalGump(this));
if (m_Command != DecorateCommand.None)
@ -252,7 +252,7 @@ namespace Server.Items
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
{
if (cancelType == TargetCancelType.Canceled)
from.CloseGump(typeof(InternalGump));
from.CloseGump<InternalGump>();
}
private static void Turn(Item item, Mobile from)

View file

@ -523,7 +523,7 @@ namespace Server.Items
public PlayerBBGump( Mobile from, BaseHouse house, BasePlayerBB board, int page ) : base( 50, 10 )
{
from.CloseGump( typeof( PlayerBBGump ) );
from.CloseGump<PlayerBBGump>();
m_Page = page;
m_From = from;

View file

@ -76,8 +76,7 @@ namespace Server.Items
}
else
{
bool vendor, contract;
BaseHouse.IsThereVendor(from.Location, from.Map, out vendor, out contract);
BaseHouse.IsThereVendor(from.Location, from.Map, out bool vendor, out bool contract);
if (vendor)
{

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Network;
@ -57,7 +58,7 @@ namespace Server.Items
{
private static readonly TimeSpan m_UseTimeout = TimeSpan.FromMinutes(2.0);
private Hashtable m_DamageTable = new Hashtable();
private Dictionary<Mobile, DamageTimer> m_DamageTable = new Dictionary<Mobile, DamageTimer>();
private DateTime m_LastUse;
private int m_SideLength;
@ -167,7 +168,7 @@ namespace Server.Items
if (m_User != null)
{
m_User.CloseGump(typeof(GameGump));
m_User.CloseGump<GameGump>();
m_User = null;
}
}
@ -188,7 +189,7 @@ namespace Server.Items
if (m_User.Deleted || m_User.Map != Map || !m_User.InRange(this, 3)
|| m_User.NetState == null || DateTime.UtcNow - m_LastUse >= m_UseTimeout)
{
m_User.CloseGump(typeof(GameGump));
m_User.CloseGump<GameGump>();
}
else
{
@ -546,4 +547,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -37,7 +37,7 @@ namespace Server.Items
}
else
{
from.CloseGump( typeof( PromotionalTokenGump ) );
from.CloseGump<PromotionalTokenGump>();
from.SendGump( new PromotionalTokenGump( this ) );
}
}
@ -51,7 +51,7 @@ namespace Server.Items
else if ( parent is Mobile mobile )
m = mobile;
m?.CloseGump( typeof( PromotionalTokenGump ) );
m?.CloseGump<PromotionalTokenGump>();
}
public override void Serialize( GenericWriter writer )

View file

@ -50,7 +50,7 @@ namespace Server.Items
{
if (m is PlayerMobile)
if (!Utility.InRange(m.Location, Location, 1) && Utility.InRange(oldLocation, Location, 1))
m.CloseGump(typeof(MoongateGump));
m.CloseGump<MoongateGump>();
}
public bool UseGate(Mobile m)
@ -73,7 +73,7 @@ namespace Server.Items
return false;
}
m.CloseGump(typeof(MoongateGump));
m.CloseGump<MoongateGump>();
m.SendGump(new MoongateGump(m, this));
if (!m.Hidden || m.AccessLevel == AccessLevel.Player)

View file

@ -36,7 +36,7 @@ namespace Server.Items
{
if (from.InRange(GetWorldLocation(), 1))
{
from.CloseGump(typeof(SpecialBeardDyeGump));
from.CloseGump<SpecialBeardDyeGump>();
from.SendGump(new SpecialBeardDyeGump(this));
}
else

View file

@ -36,7 +36,7 @@ namespace Server.Items
{
if (from.InRange(GetWorldLocation(), 1))
{
from.CloseGump(typeof(SpecialHairDyeGump));
from.CloseGump<SpecialHairDyeGump>();
from.SendGump(new SpecialHairDyeGump(this));
}
else

View file

@ -392,11 +392,6 @@ namespace Server.Items
}
}
private void EndMessageLock(object state)
{
((Mobile)state).EndAction(this);
}
public override bool CanTeleport(Mobile m)
{
if (!base.CanTeleport(m))
@ -415,7 +410,7 @@ namespace Server.Items
m.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, m_MessageNumber, null,
""));
Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerStateCallback(EndMessageLock), m);
Timer.DelayCall(TimeSpan.FromSeconds(5.0), () => m.EndAction(this));
}
return false;

View file

@ -32,11 +32,11 @@ namespace Server.Items
{
from.SendLocalizedMessage(1010465); // You cannot disguise yourself while holding a sigil.
}
else if (!from.CanBeginAction(typeof(IncognitoSpell)))
else if (!from.CanBeginAction<IncognitoSpell>())
{
from.SendLocalizedMessage(501698); // You cannot disguise yourself while incognitoed.
}
else if (!from.CanBeginAction(typeof(PolymorphSpell)))
else if (!from.CanBeginAction<PolymorphSpell>())
{
from.SendLocalizedMessage(501699); // You cannot disguise yourself while polymorphed.
}

View file

@ -10,7 +10,6 @@ namespace Server.Items
typeof(Arrow), typeof(Bolt)
};
private AosAttributes m_Attributes;
private int m_Capacity;
private Mobile m_Crafter;
@ -29,7 +28,7 @@ namespace Server.Items
Capacity = 500;
Layer = Layer.Cloak;
m_Attributes = new AosAttributes(this);
Attributes = new AosAttributes(this);
DamageIncrease = 10;
}
@ -44,11 +43,7 @@ namespace Server.Items
public override double DefaultWeight => 2.0;
[CommandProperty(AccessLevel.GameMaster)]
public AosAttributes Attributes
{
get => m_Attributes;
set { }
}
public AosAttributes Attributes{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Capacity
@ -138,7 +133,7 @@ namespace Server.Items
if (!(newItem is BaseQuiver quiver))
return;
quiver.m_Attributes = new AosAttributes(newItem, m_Attributes);
quiver.Attributes = new AosAttributes(newItem, Attributes);
}
public override void UpdateTotal(Item sender, TotalType type, int delta)
@ -226,12 +221,12 @@ namespace Server.Items
public override void OnAdded(IEntity parent)
{
if (parent is Mobile mob) m_Attributes.AddStatBonuses(mob);
if (parent is Mobile mob) Attributes.AddStatBonuses(mob);
}
public override void OnRemoved(IEntity parent)
{
if (parent is Mobile mob) m_Attributes.RemoveStatBonuses(mob);
if (parent is Mobile mob) Attributes.RemoveStatBonuses(mob);
}
public override void GetProperties(ObjectPropertyList list)
@ -291,67 +286,67 @@ namespace Server.Items
list.Add(1075085); // Requirement: Mondain's Legacy
if ((prop = m_Attributes.DefendChance) != 0)
if ((prop = Attributes.DefendChance) != 0)
list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~%
if ((prop = m_Attributes.BonusDex) != 0)
if ((prop = Attributes.BonusDex) != 0)
list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~
if ((prop = m_Attributes.EnhancePotions) != 0)
if ((prop = Attributes.EnhancePotions) != 0)
list.Add(1060411, prop.ToString()); // enhance potions ~1_val~%
if ((prop = m_Attributes.CastRecovery) != 0)
if ((prop = Attributes.CastRecovery) != 0)
list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~
if ((prop = m_Attributes.CastSpeed) != 0)
if ((prop = Attributes.CastSpeed) != 0)
list.Add(1060413, prop.ToString()); // faster casting ~1_val~
if ((prop = m_Attributes.AttackChance) != 0)
if ((prop = Attributes.AttackChance) != 0)
list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~%
if ((prop = m_Attributes.BonusHits) != 0)
if ((prop = Attributes.BonusHits) != 0)
list.Add(1060431, prop.ToString()); // hit point increase ~1_val~
if ((prop = m_Attributes.BonusInt) != 0)
if ((prop = Attributes.BonusInt) != 0)
list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~
if ((prop = m_Attributes.LowerManaCost) != 0)
if ((prop = Attributes.LowerManaCost) != 0)
list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~%
if ((prop = m_Attributes.LowerRegCost) != 0)
if ((prop = Attributes.LowerRegCost) != 0)
list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~%
if ((prop = m_Attributes.Luck) != 0)
if ((prop = Attributes.Luck) != 0)
list.Add(1060436, prop.ToString()); // luck ~1_val~
if ((prop = m_Attributes.BonusMana) != 0)
if ((prop = Attributes.BonusMana) != 0)
list.Add(1060439, prop.ToString()); // mana increase ~1_val~
if ((prop = m_Attributes.RegenMana) != 0)
if ((prop = Attributes.RegenMana) != 0)
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~
if ((prop = m_Attributes.NightSight) != 0)
if ((prop = Attributes.NightSight) != 0)
list.Add(1060441); // night sight
if ((prop = m_Attributes.ReflectPhysical) != 0)
if ((prop = Attributes.ReflectPhysical) != 0)
list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~%
if ((prop = m_Attributes.RegenStam) != 0)
if ((prop = Attributes.RegenStam) != 0)
list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~
if ((prop = m_Attributes.RegenHits) != 0)
if ((prop = Attributes.RegenHits) != 0)
list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~
if ((prop = m_Attributes.SpellDamage) != 0)
if ((prop = Attributes.SpellDamage) != 0)
list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~%
if ((prop = m_Attributes.BonusStam) != 0)
if ((prop = Attributes.BonusStam) != 0)
list.Add(1060484, prop.ToString()); // stamina increase ~1_val~
if ((prop = m_Attributes.BonusStr) != 0)
if ((prop = Attributes.BonusStr) != 0)
list.Add(1060485, prop.ToString()); // strength bonus ~1_val~
if ((prop = m_Attributes.WeaponSpeed) != 0)
if ((prop = Attributes.WeaponSpeed) != 0)
list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~%
if ((prop = m_LowerAmmoCost) > 0)
@ -388,7 +383,7 @@ namespace Server.Items
SaveFlag flags = SaveFlag.None;
SetSaveFlag(ref flags, SaveFlag.Attributes, !m_Attributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.Attributes, !Attributes.IsEmpty);
SetSaveFlag(ref flags, SaveFlag.LowerAmmoCost, m_LowerAmmoCost != 0);
SetSaveFlag(ref flags, SaveFlag.WeightReduction, m_WeightReduction != 0);
SetSaveFlag(ref flags, SaveFlag.DamageIncrease, m_DamageIncrease != 0);
@ -399,7 +394,7 @@ namespace Server.Items
writer.WriteEncodedInt((int)flags);
if (GetSaveFlag(flags, SaveFlag.Attributes))
m_Attributes.Serialize(writer);
Attributes.Serialize(writer);
if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost))
writer.Write(m_LowerAmmoCost);
@ -429,9 +424,9 @@ namespace Server.Items
SaveFlag flags = (SaveFlag)reader.ReadEncodedInt();
if (GetSaveFlag(flags, SaveFlag.Attributes))
m_Attributes = new AosAttributes(this, reader);
Attributes = new AosAttributes(this, reader);
else
m_Attributes = new AosAttributes(this);
Attributes = new AosAttributes(this);
if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost))
m_LowerAmmoCost = reader.ReadInt();

View file

@ -342,7 +342,7 @@ namespace Server.Items
double minSkill = difficulty - 25.0;
double maxSkill = difficulty + 25.0;
if (difficulty > 50.0 && difficulty > from.Skills[SkillName.Mining].Value)
if (difficulty > 50.0 && difficulty > from.Skills.Mining.Value)
{
from.SendLocalizedMessage(501986); // You have no idea how to smelt this strange ore!
return;

View file

@ -22,7 +22,7 @@ namespace Server.Items
double ar = base.ArmorRating;
if (m != null)
return m.Skills[SkillName.Parry].Value * ar / 200.0 + 1.0;
return m.Skills.Parry.Value * ar / 200.0 + 1.0;
return ar;
}
}
@ -115,7 +115,7 @@ namespace Server.Items
return damage;
double ar = ArmorRating;
double chance = (owner.Skills[SkillName.Parry].Value - ar * 2.0) / 100.0;
double chance = (owner.Skills.Parry.Value - ar * 2.0) / 100.0;
if (chance < 0.01)
chance = 0.01;

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

Some files were not shown because too many files have changed in this diff Show more