Inital Commit
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Targeting;
|
||||
using Server.Engines.XmlSpawner2;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class OilOfRestoration : Item
|
||||
{
|
||||
[Constructable]
|
||||
public OilOfRestoration() : base(0x1C18) // Bottle graphic
|
||||
{
|
||||
Name = "Oil of Restoration";
|
||||
Weight = 1.0;
|
||||
Hue = 241;
|
||||
}
|
||||
|
||||
public OilOfRestoration(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendMessage("This must be in your pack to use.");
|
||||
return;
|
||||
}
|
||||
|
||||
from.SendMessage("Select an oil cloth to apply the oil to.");
|
||||
from.Target = new OilClothTarget(this);
|
||||
}
|
||||
|
||||
private class OilClothTarget : Target
|
||||
{
|
||||
private OilOfRestoration m_Oil;
|
||||
|
||||
public OilClothTarget(OilOfRestoration oil)
|
||||
: base(1, false, TargetFlags.None)
|
||||
{
|
||||
m_Oil = oil;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (m_Oil.Deleted)
|
||||
return;
|
||||
|
||||
if (!(targeted is OilCloth cloth))
|
||||
{
|
||||
from.SendMessage("You must target an oil cloth.");
|
||||
return;
|
||||
}
|
||||
|
||||
from.SendMessage("Select the item you wish to restore.");
|
||||
from.Target = new RestoreItemTarget(m_Oil, cloth);
|
||||
}
|
||||
}
|
||||
|
||||
private class RestoreItemTarget : Target
|
||||
{
|
||||
private OilOfRestoration m_Oil;
|
||||
private OilCloth m_Cloth;
|
||||
|
||||
public RestoreItemTarget(OilOfRestoration oil, OilCloth cloth)
|
||||
: base(1, false, TargetFlags.None)
|
||||
{
|
||||
m_Oil = oil;
|
||||
m_Cloth = cloth;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (m_Oil.Deleted || m_Cloth.Deleted)
|
||||
return;
|
||||
|
||||
if (!(targeted is Item item))
|
||||
{
|
||||
from.SendMessage("That is not a valid item.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get durability attachment
|
||||
var dura = XmlAttach.FindAttachment(item, typeof(Server.Custom.DurabilityAttachment))
|
||||
as Server.Custom.DurabilityAttachment;
|
||||
|
||||
if (dura == null || !dura.RepairLocked)
|
||||
{
|
||||
from.SendMessage("That item is not tempered and does not require restoration.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove repair lock
|
||||
dura.RepairLocked = false;
|
||||
|
||||
// Refresh tooltip
|
||||
item.InvalidateProperties();
|
||||
|
||||
// Consume both items
|
||||
m_Oil.Delete();
|
||||
m_Cloth.Delete();
|
||||
|
||||
from.SendMessage("The oil soaks in and restores the malleability of your item.");
|
||||
from.PlaySound(0x240);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user