Inital Commit
This commit is contained in:
@@ -1,65 +1,53 @@
|
||||
using System;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
using Server.Custom; // Required for durability extension methods
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class PowderOfTemperament : Item, IUsesRemaining
|
||||
{
|
||||
public static bool CanPOFJewelry = Config.Get("Loot.CanPOFJewelry", false);
|
||||
|
||||
private int m_UsesRemaining;
|
||||
|
||||
[Constructable]
|
||||
public PowderOfTemperament()
|
||||
: this(10)
|
||||
public PowderOfTemperament() : this(10)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public PowderOfTemperament(int charges)
|
||||
: base(4102)
|
||||
public PowderOfTemperament(int charges) : base(4102)
|
||||
{
|
||||
Weight = 1.0;
|
||||
Hue = 2419;
|
||||
UsesRemaining = charges;
|
||||
}
|
||||
|
||||
public PowderOfTemperament(Serial serial)
|
||||
: base(serial)
|
||||
public PowderOfTemperament(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int UsesRemaining
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UsesRemaining;
|
||||
}
|
||||
get { return m_UsesRemaining; }
|
||||
set
|
||||
{
|
||||
m_UsesRemaining = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowUsesRemaining
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
get { return true; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1049082;
|
||||
}
|
||||
}// powder of fortifying
|
||||
get { return 1049082; } // powder of fortifying
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
@@ -74,31 +62,13 @@ namespace Server.Items
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_UsesRemaining = reader.ReadInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (version == 0)
|
||||
m_UsesRemaining = reader.ReadInt();
|
||||
}
|
||||
|
||||
public override void AddUsesRemainingProperties(ObjectPropertyList list)
|
||||
{
|
||||
list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~
|
||||
}
|
||||
|
||||
public virtual void DisplayDurabilityTo(Mobile m)
|
||||
{
|
||||
LabelToAffix(m, 1017323, AffixType.Append, ": " + m_UsesRemaining.ToString()); // Durability
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
DisplayDurabilityTo(from);
|
||||
|
||||
base.OnSingleClick(from);
|
||||
list.Add(1060584, m_UsesRemaining.ToString());
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
@@ -106,12 +76,13 @@ namespace Server.Items
|
||||
if (IsChildOf(from.Backpack))
|
||||
from.Target = new InternalTarget(this);
|
||||
else
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
from.SendLocalizedMessage(1042001); // Must be in pack
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly PowderOfTemperament m_Powder;
|
||||
private PowderOfTemperament m_Powder;
|
||||
|
||||
public InternalTarget(PowderOfTemperament powder)
|
||||
: base(2, false, TargetFlags.None)
|
||||
{
|
||||
@@ -122,153 +93,169 @@ namespace Server.Items
|
||||
{
|
||||
if (m_Powder.Deleted || m_Powder.UsesRemaining <= 0)
|
||||
{
|
||||
from.SendLocalizedMessage(1049086); // You have used up your powder of temperament.
|
||||
from.SendLocalizedMessage(1049086); // used up
|
||||
return;
|
||||
}
|
||||
|
||||
if (targeted is Item)
|
||||
Item item = targeted as Item;
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
Item item = (Item)targeted;
|
||||
bool noGo = false;
|
||||
int antique = 0;
|
||||
|
||||
if (!Server.Engines.Craft.Repair.AllowsRepair(item, null) || (item is BaseJewel && !CanPOFJewelry))
|
||||
{
|
||||
from.SendLocalizedMessage(1049083); // You cannot use the powder on that item.
|
||||
return;
|
||||
}
|
||||
|
||||
#region SA
|
||||
if (item is BaseWeapon)
|
||||
{
|
||||
if (((BaseWeapon)item).Attributes.Brittle > 0 || ((BaseWeapon)item).NegativeAttributes.Brittle > 0)
|
||||
noGo = true;
|
||||
antique = ((BaseWeapon)item).NegativeAttributes.Antique;
|
||||
}
|
||||
else if (item is BaseArmor)
|
||||
{
|
||||
if (((BaseArmor)item).Attributes.Brittle > 0 || ((BaseArmor)item).NegativeAttributes.Brittle > 0)
|
||||
noGo = true;
|
||||
antique = ((BaseArmor)item).NegativeAttributes.Antique;
|
||||
}
|
||||
else if (item is BaseClothing)
|
||||
{
|
||||
if (((BaseClothing)item).Attributes.Brittle > 0 || ((BaseClothing)item).NegativeAttributes.Brittle > 0)
|
||||
noGo = true;
|
||||
antique = ((BaseClothing)item).NegativeAttributes.Antique;
|
||||
}
|
||||
else if (item is BaseJewel)
|
||||
{
|
||||
if (((BaseJewel)item).Attributes.Brittle > 0 || ((BaseJewel)item).NegativeAttributes.Brittle > 0)
|
||||
noGo = true;
|
||||
antique = ((BaseJewel)item).NegativeAttributes.Antique;
|
||||
}
|
||||
else if (item is BaseTalisman && ((BaseTalisman)item).Attributes.Brittle > 0)
|
||||
{
|
||||
noGo = true;
|
||||
}
|
||||
if (noGo)
|
||||
{
|
||||
from.SendLocalizedMessage(1149799); //That cannot be used on brittle items.
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (targeted is IDurability)
|
||||
{
|
||||
IDurability wearable = (IDurability)targeted;
|
||||
|
||||
if (!wearable.CanFortify)
|
||||
{
|
||||
from.SendLocalizedMessage(1049083); // You cannot use the powder on that item.
|
||||
return;
|
||||
}
|
||||
|
||||
if ((item.IsChildOf(from.Backpack) || (Core.ML && item.Parent == from)) && m_Powder.IsChildOf(from.Backpack))
|
||||
{
|
||||
int origMaxHP = wearable.MaxHitPoints;
|
||||
int origCurHP = wearable.HitPoints;
|
||||
|
||||
if (origMaxHP > 0)
|
||||
{
|
||||
int initMaxHP = antique <= 0 ? 255 : antique == 1 ? 250 : antique == 2 ? 200 : 150;
|
||||
|
||||
wearable.UnscaleDurability();
|
||||
|
||||
if (wearable.MaxHitPoints < initMaxHP)
|
||||
{
|
||||
if (antique > 0)
|
||||
{
|
||||
wearable.MaxHitPoints = initMaxHP;
|
||||
wearable.HitPoints += initMaxHP;
|
||||
}
|
||||
else
|
||||
{
|
||||
int bonus = initMaxHP - wearable.MaxHitPoints;
|
||||
|
||||
if (bonus > 10)
|
||||
bonus = 10;
|
||||
|
||||
wearable.MaxHitPoints += bonus;
|
||||
wearable.HitPoints += bonus;
|
||||
}
|
||||
|
||||
wearable.ScaleDurability();
|
||||
|
||||
if (wearable.MaxHitPoints > 255)
|
||||
wearable.MaxHitPoints = 255;
|
||||
if (wearable.HitPoints > 255)
|
||||
wearable.HitPoints = 255;
|
||||
|
||||
if (wearable.MaxHitPoints > origMaxHP)
|
||||
{
|
||||
from.SendLocalizedMessage(1049084); // You successfully use the powder on the item.
|
||||
from.PlaySound(0x247);
|
||||
|
||||
--m_Powder.UsesRemaining;
|
||||
|
||||
if (m_Powder.UsesRemaining <= 0)
|
||||
{
|
||||
from.SendLocalizedMessage(1049086); // You have used up your powder of fortifying.
|
||||
m_Powder.Delete();
|
||||
}
|
||||
|
||||
if (antique > 0)
|
||||
{
|
||||
if (item is BaseWeapon) ((BaseWeapon)item).NegativeAttributes.Antique++;
|
||||
if (item is BaseArmor) ((BaseArmor)item).NegativeAttributes.Antique++;
|
||||
if (item is BaseJewel) ((BaseJewel)item).NegativeAttributes.Antique++;
|
||||
if (item is BaseClothing) ((BaseClothing)item).NegativeAttributes.Antique++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wearable.MaxHitPoints = origMaxHP;
|
||||
wearable.HitPoints = origCurHP;
|
||||
from.SendLocalizedMessage(1049085); // The item cannot be improved any further.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1049085); // The item cannot be improved any further.
|
||||
wearable.ScaleDurability();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1049083); // You cannot use the powder on that item.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
from.SendLocalizedMessage(1042001);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
// Jewelry cannot be fortified (OSI)
|
||||
if (item is BaseJewel)
|
||||
{
|
||||
from.SendLocalizedMessage(1049083); // You cannot use the powder on that item.
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
// ===============================
|
||||
// HARD CAP CHECK — OSI ACCURATE
|
||||
// ===============================
|
||||
int oldMax = wearable.MaxHitPoints;
|
||||
|
||||
if (oldMax >= 255)
|
||||
{
|
||||
from.SendMessage("This item cannot be fortified any further.");
|
||||
return;
|
||||
}
|
||||
|
||||
// ===============================
|
||||
// APPLY +10 DURABILITY (CAPPED)
|
||||
// ===============================
|
||||
int delta = 10;
|
||||
|
||||
if (oldMax + delta > 255)
|
||||
delta = 255 - oldMax;
|
||||
|
||||
if (delta <= 0)
|
||||
{
|
||||
from.SendMessage("This item cannot be fortified any further.");
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user