feat: Implement Oil Flask & Refueling (#1165)

This commit is contained in:
Ricky Taylor 2022-09-07 08:35:47 +01:00 committed by GitHub
parent 6b3a9f08e9
commit b5a06d0545
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 133 additions and 3 deletions

View file

@ -497,6 +497,9 @@ namespace Server.Commands
}
}
// Make light never run out of fuel.
light.Duration = TimeSpan.Zero;
if (!unlit)
{
light.Ignite();

View file

@ -493,6 +493,9 @@ namespace Server.Commands
}
}
// Make light never run out of fuel.
light.Duration = TimeSpan.Zero;
if (!unlit)
{
light.Ignite();

View file

@ -110,6 +110,7 @@ public class DefGlassblowing : CraftSystem
AddCraft(typeof(CurvedFlask), 1044050, 1044612, 55.0, 105.0, typeof(Sand), 1044625, 2, 1044627);
AddCraft(typeof(LongFlask), 1044050, 1044613, 57.5, 107.5, typeof(Sand), 1044625, 4, 1044627);
AddCraft(typeof(LargeFlask), 1044050, 1044623, 60.0, 110.0, typeof(Sand), 1044625, 5, 1044627);
AddCraft(typeof(EmptyOilFlask), 1044050, 1150866, 70.0, 120.0, typeof(Sand), 1044625, 5, 1044627);
AddCraft(typeof(AniSmallBlueFlask), 1044050, 1044614, 60.0, 110.0, typeof(Sand), 1044625, 5, 1044627);
AddCraft(typeof(AniLargeVioletFlask), 1044050, 1044615, 60.0, 110.0, typeof(Sand), 1044625, 5, 1044627);
AddCraft(typeof(AniRedRibbedFlask), 1044050, 1044624, 60.0, 110.0, typeof(Sand), 1044625, 7, 1044627);

View file

@ -6,10 +6,12 @@ namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class Lantern : BaseEquipableLight
{
public static TimeSpan FullDuration = TimeSpan.FromMinutes(20);
[Constructible]
public Lantern() : base(0xA25)
{
Duration = Burnout ? TimeSpan.FromMinutes(20) : TimeSpan.Zero;
Duration = Burnout ? FullDuration : TimeSpan.Zero;
Burning = false;
Light = LightType.Circle300;

View file

@ -0,0 +1,109 @@
using ModernUO.Serialization;
using Server.Targeting;
namespace Server.Items;
[SerializationGenerator(0)]
public partial class OilFlask : Item
{
[Constructible]
public OilFlask(int amount = 1) : base(0x1C18)
{
Stackable = true;
Amount = amount;
}
public override int LabelNumber => 1027199; // oil flask
public virtual int FilledMessageNumber => 1150864; // You fill the lamp with oil.
public virtual double FillMultiplier => 1;
public override void OnDoubleClick(Mobile from)
{
from.SendLocalizedMessage(501947); // Select lantern to refuel.
from.BeginTarget(2, true, TargetFlags.None, OnTargetPicked);
}
private void OnTargetPicked(Mobile from, object targeted)
{
if (targeted is Lantern lantern)
{
if (!lantern.Movable || lantern.Protected && from.AccessLevel == AccessLevel.Player)
{
from.SendLocalizedMessage(500685); // You can't use that, it belongs to someone else.
return;
}
var wasBurning = lantern.Burning;
lantern.Douse();
lantern.Duration = Lantern.FullDuration * FillMultiplier;
lantern.BurntOut = false;
if (wasBurning)
{
lantern.Ignite();
}
from.SendLocalizedMessage(FilledMessageNumber);
var emptyFlask = new EmptyOilFlask();
if (!from.PlaceInBackpack(emptyFlask))
{
var didStack = false;
var eable = from.GetItemsInRange(0);
foreach (var i in eable)
{
if (i.StackWith(from, this, false))
{
didStack = true;
break;
}
}
eable.Free();
if (!didStack)
{
emptyFlask.MoveToWorld(Location, Map);
}
}
Consume(1);
}
else
{
from.SendLocalizedMessage(502218); // You cannot use that.
}
}
}
[SerializationGenerator(0)]
public partial class FishOilFlask : OilFlask
{
[Constructible]
public FishOilFlask(int amount = 1) : base(amount)
{
}
public override int LabelNumber => 1150863; // fish oil flask
public override int FilledMessageNumber => 1150865; // You fill the lamp with fish oil. It should burn for a nice long time.
public override double FillMultiplier => 2;
}
[SerializationGenerator(0)]
public partial class EmptyOilFlask : Item
{
[Constructible]
public EmptyOilFlask(int amount = 1) : base(0x1C18)
{
Stackable = true;
Amount = amount;
}
public override int LabelNumber => 1150866; // empty oil flask
public override void OnDoubleClick(Mobile from)
{
from.SendLocalizedMessage(500318); // This flask is empty.
}
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.EmptyOilFlask"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.FishOilFlask"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.OilFlask"
}

View file

@ -34,8 +34,7 @@ namespace Server.Mobiles
Add(new GenericBuyInfo(typeof(Candle), 6, 20, 0xA28, 0));
Add(new GenericBuyInfo(typeof(Torch), 8, 20, 0xF6B, 0));
Add(new GenericBuyInfo(typeof(Lantern), 2, 20, 0xA25, 0));
// TODO: Oil Flask @ 8GP
Add(new GenericBuyInfo(typeof(OilFlask), 9, 20, 0x1C18, 0));
Add(new GenericBuyInfo(typeof(Lockpick), 12, 20, 0x14FC, 0));
@ -120,6 +119,7 @@ namespace Server.Mobiles
Add(typeof(Candle), 3);
Add(typeof(Torch), 4);
Add(typeof(Lantern), 1);
Add(typeof(OilFlask), 7);
Add(typeof(Lockpick), 6);
Add(typeof(FloppyHat), 3);
Add(typeof(WideBrimHat), 4);