fix: Optimizes items to use default weights. (Part 4) (#2243)

This commit is contained in:
Kamron Batman 2025-07-24 23:29:29 -07:00 • committed by GitHub
parent 40ba85d7b8
commit fa0b67ec29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
109 changed files with 250 additions and 391 deletions

View file

@ -9,10 +9,11 @@ public partial class BlankScroll : Item, ICommodity
public BlankScroll(int amount = 1) : base(0xEF3)
{
Stackable = true;
Weight = 1.0;
Amount = amount;
}
public override double DefaultWeight => 1.0;
int ICommodity.DescriptionNumber => LabelNumber;
bool ICommodity.IsDeedable => Core.ML;
}

View file

@ -9,10 +9,11 @@ public partial class Bottle : Item, ICommodity
public Bottle(int amount = 1) : base(0xF0E)
{
Stackable = true;
Weight = 1.0;
Amount = amount;
}
public override double DefaultWeight => 1.0;
int ICommodity.DescriptionNumber => LabelNumber;
bool ICommodity.IsDeedable => Core.ML;
}

View file

@ -16,7 +16,11 @@ public partial class PotionKeg : Item
private PotionEffect _type;
[Constructible]
public PotionKeg() : base(0x1940) => UpdateWeight();
public PotionKeg() : base(0x1940)
{
}
public override double DefaultWeight => 20 + Math.Clamp(_held, 0, 100) * 0.8;
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
@ -28,7 +32,6 @@ public partial class PotionKeg : Item
if (_held != value)
{
_held = value;
UpdateWeight();
InvalidateProperties();
this.MarkDirty();
}
@ -48,13 +51,6 @@ public partial class PotionKeg : Item
}
}
public virtual void UpdateWeight()
{
var held = Math.Max(0, Math.Min(_held, 100));
Weight = 20 + held * 80 / 100;
}
private void Deserialize(IGenericReader reader, int version)
{
_type = (PotionEffect)reader.ReadInt();

View file

@ -21,10 +21,11 @@ public partial class RecallRune : Item
[Constructible]
public RecallRune() : base(0x1F14)
{
Weight = 1.0;
CalculateHue();
}
public override double DefaultWeight => 1.0;
[SerializableProperty(0)]
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
public BaseHouse House

View file

@ -50,9 +50,10 @@ public abstract partial class BasePotion : Item, ICraftable, ICommodity
_potionEffect = effect;
Stackable = Core.ML;
Weight = 1.0;
}
public override double DefaultWeight => 1.0;
public override int LabelNumber => 1041314 + (int)_potionEffect;
public virtual bool RequireFreeHand => true;

View file

@ -60,7 +60,6 @@ public partial class Runebook : Item, ISecurable, ICraftable
[Constructible]
public Runebook(int maxCharges) : base(Core.AOS ? 0x22C5 : 0xEFA)
{
Weight = Core.SE ? 1.0 : 3.0;
LootType = LootType.Blessed;
Hue = 0x461;
@ -72,6 +71,8 @@ public partial class Runebook : Item, ISecurable, ICraftable
_level = SecureLevel.CoOwners;
}
public override double DefaultWeight => Core.SE ? 1.0 : 3.0;
[CommandProperty(AccessLevel.GameMaster)]
public DateTime NextUse { get; set; }

View file

@ -16,12 +16,13 @@ public partial class SpellScroll : Item, ICommodity
public SpellScroll(int spellID, int itemID, int amount = 1) : base(itemID)
{
Stackable = true;
Weight = 1.0;
Amount = amount;
_spellID = spellID;
}
public override double DefaultWeight => 1.0;
int ICommodity.DescriptionNumber => LabelNumber;
bool ICommodity.IsDeedable => Core.ML;

View file

@ -116,7 +116,6 @@ public partial class Spellbook : Item, ICraftable, ISlayer, IAosItem
_attributes = new AosAttributes(this);
_skillBonuses = new AosSkillBonuses(this);
Weight = 3.0;
Layer = Layer.OneHanded;
LootType = LootType.Blessed;
@ -124,6 +123,8 @@ public partial class Spellbook : Item, ICraftable, ISlayer, IAosItem
Content = content;
}
public override double DefaultWeight => 3.0;
public override bool DisplayWeight => false;
public virtual SpellbookType SpellbookType => SpellbookType.Regular;