Compare commits
2 commits
a181e313cd
...
a90694300e
| Author | SHA1 | Date | |
|---|---|---|---|
| a90694300e | |||
| edce93bba8 |
6 changed files with 126 additions and 30 deletions
|
|
@ -14,6 +14,36 @@ public abstract partial class FarmableCrop : Item
|
||||||
public abstract Item GetCropObject();
|
public abstract Item GetCropObject();
|
||||||
public abstract int GetPickedID();
|
public abstract int GetPickedID();
|
||||||
|
|
||||||
|
public override void AddNameProperties(IPropertyList list)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool HandlesOnMovement => true;
|
||||||
|
|
||||||
|
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||||
|
{
|
||||||
|
if (m.Player && m.Alive && !_picked && m.InRange(this.Location, 2))
|
||||||
|
{
|
||||||
|
Timer.DelayCall(TimeSpan.FromMilliseconds(100), () =>
|
||||||
|
{
|
||||||
|
if (m.InRange(this.Location, 2) && !_picked)
|
||||||
|
{
|
||||||
|
OnPicked(m, Location, Map);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
base.OnMovement(m, oldLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnMoveOver(Mobile from)
|
||||||
|
{
|
||||||
|
if (from != null && from.Alive && from.Player && !_picked)
|
||||||
|
{
|
||||||
|
OnPicked(from, this.Location, this.Map);
|
||||||
|
}
|
||||||
|
return base.OnMoveOver(from);
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnDoubleClick(Mobile from)
|
public override void OnDoubleClick(Mobile from)
|
||||||
{
|
{
|
||||||
var map = Map;
|
var map = Map;
|
||||||
|
|
@ -40,7 +70,20 @@ public abstract partial class FarmableCrop : Item
|
||||||
|
|
||||||
var spawn = GetCropObject();
|
var spawn = GetCropObject();
|
||||||
|
|
||||||
spawn?.MoveToWorld(loc, map);
|
//spawn?.MoveToWorld(loc, map);
|
||||||
|
if (spawn != null)
|
||||||
|
{
|
||||||
|
if (from.Backpack == null || !from.Backpack.CheckHold(from, spawn, true, true))
|
||||||
|
{
|
||||||
|
spawn.MoveToWorld(loc, map);
|
||||||
|
from.SendMessage("Your backpack is full, the crop was placed on the ground.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
from.AddToBackpack(spawn);
|
||||||
|
from.PlaySound(0x13E); // Harvest sound
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_picked = true;
|
_picked = true;
|
||||||
|
|
||||||
|
|
@ -59,11 +102,11 @@ public abstract partial class FarmableCrop : Item
|
||||||
}
|
}
|
||||||
|
|
||||||
[AfterDeserialization]
|
[AfterDeserialization]
|
||||||
private void AfterDeserialization()
|
public void AfterDeserialization()
|
||||||
{
|
{
|
||||||
if (_picked)
|
if (_picked)
|
||||||
{
|
{
|
||||||
Unlink();
|
//Unlink();
|
||||||
Delete();
|
Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,10 @@ namespace Server.Items;
|
||||||
public partial class FarmableFlax : FarmableCrop
|
public partial class FarmableFlax : FarmableCrop
|
||||||
{
|
{
|
||||||
[Constructible]
|
[Constructible]
|
||||||
public FarmableFlax() : base(GetCropID())
|
public FarmableFlax() : base(6810)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
public static int GetCropID() => 6810;
|
||||||
public static int GetCropID() => Utility.Random(6809, 3);
|
|
||||||
|
|
||||||
public override Item GetCropObject() =>
|
public override Item GetCropObject() =>
|
||||||
new Flax
|
new Flax
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,17 @@ public partial class Cotton : Item, IDyable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Cotton.Consume();
|
int amountToProcess = m_Cotton.Amount;
|
||||||
wheel.BeginSpin(m_Cotton.OnSpun, from, m_Cotton.Hue);
|
int cottonHue = m_Cotton.Hue;
|
||||||
|
m_Cotton.Delete();
|
||||||
|
wheel.BeginSpin((w, mobile, h) =>
|
||||||
|
{
|
||||||
|
mobile.AddToBackpack(new SpoolOfThread(6 * amountToProcess)
|
||||||
|
{
|
||||||
|
Hue = h
|
||||||
|
});
|
||||||
|
mobile.SendLocalizedMessage(1010577); // You put the spools of thread in your backpack.
|
||||||
|
}, from, cottonHue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,17 @@ public partial class Flax : Item
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Flax.Consume();
|
int amountToProcess = m_Flax.Amount;
|
||||||
wheel.BeginSpin(m_Flax.OnSpun, from, m_Flax.Hue);
|
int flaxHue = m_Flax.Hue;
|
||||||
|
m_Flax.Delete();
|
||||||
|
wheel.BeginSpin((w, mobile, h) =>
|
||||||
|
{
|
||||||
|
mobile.AddToBackpack(new SpoolOfThread(6 * amountToProcess)
|
||||||
|
{
|
||||||
|
Hue = h
|
||||||
|
});
|
||||||
|
mobile.SendLocalizedMessage(1010577); // You put the spools of thread in your backpack.
|
||||||
|
}, from, flaxHue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ public partial class Wool : Item, IDyable
|
||||||
}
|
}
|
||||||
|
|
||||||
public override double DefaultWeight => 4.0;
|
public override double DefaultWeight => 4.0;
|
||||||
|
public virtual int YarnMultiplier => 3;
|
||||||
|
|
||||||
public bool Dye(Mobile from, DyeTub sender)
|
public bool Dye(Mobile from, DyeTub sender)
|
||||||
{
|
{
|
||||||
|
|
@ -81,8 +82,21 @@ public partial class Wool : Item, IDyable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Wool.Consume();
|
int amountToProcess = m_Wool.Amount;
|
||||||
wheel.BeginSpin(m_Wool.OnSpun, from, m_Wool.Hue);
|
int woolHue = m_Wool.Hue;
|
||||||
|
int multiplier = m_Wool.YarnMultiplier;
|
||||||
|
m_Wool.Delete();
|
||||||
|
wheel.BeginSpin((w, mobile, h) =>
|
||||||
|
{
|
||||||
|
int totalYarnEarned = multiplier * amountToProcess;
|
||||||
|
|
||||||
|
mobile.AddToBackpack(new DarkYarn(totalYarnEarned)
|
||||||
|
{
|
||||||
|
Hue = h
|
||||||
|
});
|
||||||
|
|
||||||
|
mobile.SendLocalizedMessage(totalYarnEarned > 1 ? 1010576 : 1010574);
|
||||||
|
}, from, woolHue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -104,7 +118,7 @@ public partial class TaintedWool : Wool
|
||||||
}
|
}
|
||||||
|
|
||||||
public override double DefaultWeight => 4.0;
|
public override double DefaultWeight => 4.0;
|
||||||
|
public override int YarnMultiplier => 1;
|
||||||
public override void OnSpun(ISpinningWheel wheel, Mobile from, int hue)
|
public override void OnSpun(ISpinningWheel wheel, Mobile from, int hue)
|
||||||
{
|
{
|
||||||
from.AddToBackpack(new DarkYarn
|
from.AddToBackpack(new DarkYarn
|
||||||
|
|
|
||||||
|
|
@ -65,26 +65,48 @@ public abstract partial class BaseClothMaterial : Item, IDyable
|
||||||
{
|
{
|
||||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||||
}
|
}
|
||||||
else if (loom.Phase < 4)
|
|
||||||
{
|
|
||||||
m_Material.Consume();
|
|
||||||
|
|
||||||
if (targeted is Item item)
|
|
||||||
{
|
|
||||||
item.SendLocalizedMessageTo(from, 1010001 + loom.Phase++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var create = new BoltOfCloth
|
// 1. Capture stack values and current loom state before deletion
|
||||||
{
|
int totalThreads = m_Material.Amount;
|
||||||
Hue = m_Material.Hue
|
int currentPhase = loom.Phase;
|
||||||
};
|
int materialHue = m_Material.Hue;
|
||||||
|
|
||||||
m_Material.Consume();
|
// 2. Combine the loom's current contents with the incoming stack
|
||||||
loom.Phase = 0;
|
int totalEffectiveThreads = currentPhase + totalThreads;
|
||||||
from.SendLocalizedMessage(500368); // You create some cloth and put it in your backpack.
|
|
||||||
from.AddToBackpack(create);
|
// 3. Calculate bolts earned (5 threads per bolt) and the leftover phase remainder
|
||||||
|
int boltsToMake = totalEffectiveThreads / 5;
|
||||||
|
int newPhase = totalEffectiveThreads % 5;
|
||||||
|
|
||||||
|
// 4. Safely delete the resource stack up front to prevent any anti-duping movement exploits
|
||||||
|
m_Material.Delete();
|
||||||
|
|
||||||
|
// 5. Commit the new leftover phase back to the loom structure
|
||||||
|
loom.Phase = newPhase;
|
||||||
|
|
||||||
|
// 6. Award the bulk bolts of cloth if thresholds were met
|
||||||
|
if (boltsToMake > 0)
|
||||||
|
{
|
||||||
|
var create = new BoltOfCloth
|
||||||
|
{
|
||||||
|
Hue = materialHue,
|
||||||
|
Amount = boltsToMake
|
||||||
|
};
|
||||||
|
|
||||||
|
from.SendLocalizedMessage(500368); // You create some cloth and put it in your backpack.
|
||||||
|
from.AddToBackpack(create);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. If no bolts were finished but progress was added, send the proper progression message
|
||||||
|
if (boltsToMake == 0 && newPhase > 0)
|
||||||
|
{
|
||||||
|
if (targeted is Item item)
|
||||||
|
{
|
||||||
|
// Matches the original localization offsets (Phase 1 = 1010001, Phase 4 = 1010004)
|
||||||
|
item.SendLocalizedMessageTo(from, 1010000 + newPhase);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue