2026-06-19 00:00:16 -04:00
|
|
|
using System;
|
|
|
|
|
using Server.Network;
|
|
|
|
|
using Server.Targeting;
|
2026-07-07 13:40:15 -04:00
|
|
|
using Server.Custom; // Required for durability extension methods
|
2026-06-19 00:00:16 -04:00
|
|
|
|
|
|
|
|
namespace Server.Items
|
|
|
|
|
{
|
|
|
|
|
public class PowderOfTemperament : Item, IUsesRemaining
|
|
|
|
|
{
|
|
|
|
|
private int m_UsesRemaining;
|
|
|
|
|
|
|
|
|
|
[Constructable]
|
2026-07-07 13:40:15 -04:00
|
|
|
public PowderOfTemperament() : this(10)
|
2026-06-19 00:00:16 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Constructable]
|
2026-07-07 13:40:15 -04:00
|
|
|
public PowderOfTemperament(int charges) : base(4102)
|
2026-06-19 00:00:16 -04:00
|
|
|
{
|
|
|
|
|
Weight = 1.0;
|
|
|
|
|
Hue = 2419;
|
|
|
|
|
UsesRemaining = charges;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-07 13:40:15 -04:00
|
|
|
public PowderOfTemperament(Serial serial) : base(serial)
|
2026-06-19 00:00:16 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
|
|
|
public int UsesRemaining
|
|
|
|
|
{
|
2026-07-07 13:40:15 -04:00
|
|
|
get { return m_UsesRemaining; }
|
2026-06-19 00:00:16 -04:00
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
m_UsesRemaining = value;
|
|
|
|
|
InvalidateProperties();
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-07-07 13:40:15 -04:00
|
|
|
|
2026-06-19 00:00:16 -04:00
|
|
|
public bool ShowUsesRemaining
|
|
|
|
|
{
|
2026-07-07 13:40:15 -04:00
|
|
|
get { return true; }
|
|
|
|
|
set { }
|
2026-06-19 00:00:16 -04:00
|
|
|
}
|
2026-07-07 13:40:15 -04:00
|
|
|
|
2026-06-19 00:00:16 -04:00
|
|
|
public override int LabelNumber
|
|
|
|
|
{
|
2026-07-07 13:40:15 -04:00
|
|
|
get { return 1049082; } // powder of fortifying
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 00:00:16 -04:00
|
|
|
public override void Serialize(GenericWriter writer)
|
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
|
|
|
|
|
writer.Write((int)0);
|
|
|
|
|
writer.Write((int)m_UsesRemaining);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Deserialize(GenericReader reader)
|
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
|
|
|
|
|
int version = reader.ReadInt();
|
|
|
|
|
|
2026-07-07 13:40:15 -04:00
|
|
|
if (version == 0)
|
|
|
|
|
m_UsesRemaining = reader.ReadInt();
|
2026-06-19 00:00:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void AddUsesRemainingProperties(ObjectPropertyList list)
|
|
|
|
|
{
|
2026-07-07 13:40:15 -04:00
|
|
|
list.Add(1060584, m_UsesRemaining.ToString());
|
2026-06-19 00:00:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
|
|
|
{
|
|
|
|
|
if (IsChildOf(from.Backpack))
|
|
|
|
|
from.Target = new InternalTarget(this);
|
|
|
|
|
else
|
2026-07-07 13:40:15 -04:00
|
|
|
from.SendLocalizedMessage(1042001); // Must be in pack
|
2026-06-19 00:00:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class InternalTarget : Target
|
|
|
|
|
{
|
2026-07-07 13:40:15 -04:00
|
|
|
private PowderOfTemperament m_Powder;
|
|
|
|
|
|
2026-06-19 00:00:16 -04:00
|
|
|
public InternalTarget(PowderOfTemperament powder)
|
|
|
|
|
: base(2, false, TargetFlags.None)
|
|
|
|
|
{
|
|
|
|
|
m_Powder = powder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnTarget(Mobile from, object targeted)
|
|
|
|
|
{
|
|
|
|
|
if (m_Powder.Deleted || m_Powder.UsesRemaining <= 0)
|
|
|
|
|
{
|
2026-07-07 13:40:15 -04:00
|
|
|
from.SendLocalizedMessage(1049086); // used up
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item item = targeted as Item;
|
|
|
|
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
from.SendLocalizedMessage(1042001);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Jewelry cannot be fortified (OSI)
|
|
|
|
|
if (item is BaseJewel)
|
|
|
|
|
{
|
|
|
|
|
from.SendLocalizedMessage(1049083);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Brittle or Antique items cannot be fortified (OSI)
|
|
|
|
|
if (IsBrittle(item) || IsAntique(item))
|
|
|
|
|
{
|
|
|
|
|
from.SendLocalizedMessage(1049083);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IDurability wearable = targeted as IDurability;
|
|
|
|
|
|
|
|
|
|
if (wearable == null || !wearable.CanFortify)
|
|
|
|
|
{
|
|
|
|
|
from.SendLocalizedMessage(1049083);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(item.IsChildOf(from.Backpack) || (Core.ML && item.Parent == from)) || !m_Powder.IsChildOf(from.Backpack))
|
|
|
|
|
{
|
|
|
|
|
from.SendLocalizedMessage(1049085);
|
2026-06-19 00:00:16 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-07 13:40:15 -04:00
|
|
|
// ===============================
|
|
|
|
|
// HARD CAP CHECK — OSI ACCURATE
|
|
|
|
|
// ===============================
|
|
|
|
|
int oldMax = wearable.MaxHitPoints;
|
|
|
|
|
|
|
|
|
|
if (oldMax >= 255)
|
2026-06-19 00:00:16 -04:00
|
|
|
{
|
2026-07-07 13:40:15 -04:00
|
|
|
from.SendMessage("This item cannot be fortified any further.");
|
|
|
|
|
return;
|
2026-06-19 00:00:16 -04:00
|
|
|
}
|
2026-07-07 13:40:15 -04:00
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// APPLY +10 DURABILITY (CAPPED)
|
|
|
|
|
// ===============================
|
|
|
|
|
int delta = 10;
|
|
|
|
|
|
|
|
|
|
if (oldMax + delta > 255)
|
|
|
|
|
delta = 255 - oldMax;
|
|
|
|
|
|
|
|
|
|
if (delta <= 0)
|
2026-06-19 00:00:16 -04:00
|
|
|
{
|
2026-07-07 13:40:15 -04:00
|
|
|
from.SendMessage("This item cannot be fortified any further.");
|
|
|
|
|
return;
|
2026-06-19 00:00:16 -04:00
|
|
|
}
|
2026-07-07 13:40:15 -04:00
|
|
|
|
|
|
|
|
int newMax = oldMax + delta;
|
|
|
|
|
|
|
|
|
|
wearable.MaxHitPoints = newMax;
|
|
|
|
|
wearable.HitPoints += delta;
|
|
|
|
|
|
|
|
|
|
if (wearable.HitPoints > wearable.MaxHitPoints)
|
|
|
|
|
wearable.HitPoints = wearable.MaxHitPoints;
|
|
|
|
|
|
|
|
|
|
// ===============================================
|
|
|
|
|
// REMOVE SELF REPAIR ON FIRST PoF USE
|
|
|
|
|
// ===============================================
|
|
|
|
|
if (item is BaseWeapon bw)
|
|
|
|
|
{
|
|
|
|
|
bw.WeaponAttributes.SelfRepair = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item is BaseArmor ba)
|
|
|
|
|
{
|
|
|
|
|
ba.ArmorAttributes.SelfRepair = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item is BaseShield bs)
|
|
|
|
|
{
|
|
|
|
|
bs.ArmorAttributes.SelfRepair = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item is BaseClothing bc)
|
|
|
|
|
{
|
|
|
|
|
bc.ClothingAttributes.SelfRepair = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// TRACK POF USES
|
|
|
|
|
// ===============================
|
|
|
|
|
item.SetPoFUses(item.GetPoFUses() + 1);
|
|
|
|
|
// ===============================
|
|
|
|
|
// APPLY REPAIR LOCK
|
|
|
|
|
// ===============================
|
|
|
|
|
item.SetRepairLocked(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from.SendMessage("You successfully fortify the item.");
|
|
|
|
|
from.PlaySound(0x247);
|
|
|
|
|
|
|
|
|
|
m_Powder.UsesRemaining--;
|
|
|
|
|
|
|
|
|
|
if (m_Powder.UsesRemaining <= 0)
|
|
|
|
|
{
|
|
|
|
|
from.SendLocalizedMessage(1049086);
|
|
|
|
|
m_Powder.Delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsBrittle(Item item)
|
|
|
|
|
{
|
|
|
|
|
BaseWeapon bw = item as BaseWeapon;
|
|
|
|
|
if (bw != null && (bw.Attributes.Brittle > 0 || bw.NegativeAttributes.Brittle > 0))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
BaseArmor ba = item as BaseArmor;
|
|
|
|
|
if (ba != null && (ba.Attributes.Brittle > 0 || ba.NegativeAttributes.Brittle > 0))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
BaseClothing bc = item as BaseClothing;
|
|
|
|
|
if (bc != null && (bc.Attributes.Brittle > 0 || bc.NegativeAttributes.Brittle > 0))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
BaseJewel bj = item as BaseJewel;
|
|
|
|
|
if (bj != null && (bj.Attributes.Brittle > 0 || bj.NegativeAttributes.Brittle > 0))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
BaseTalisman bt = item as BaseTalisman;
|
|
|
|
|
if (bt != null && bt.Attributes.Brittle > 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsAntique(Item item)
|
|
|
|
|
{
|
|
|
|
|
BaseWeapon bw = item as BaseWeapon;
|
|
|
|
|
if (bw != null && bw.NegativeAttributes.Antique > 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
BaseArmor ba = item as BaseArmor;
|
|
|
|
|
if (ba != null && ba.NegativeAttributes.Antique > 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
BaseClothing bc = item as BaseClothing;
|
|
|
|
|
if (bc != null && bc.NegativeAttributes.Antique > 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
BaseJewel bj = item as BaseJewel;
|
|
|
|
|
if (bj != null && bj.NegativeAttributes.Antique > 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
2026-06-19 00:00:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|