Compare commits
No commits in common. "a90694300e6edcdc87b759a18eb3ce842e20afd3" and "a181e313cd3b6ef05bd24f9997274a32eaac59e2" have entirely different histories.
a90694300e
...
a181e313cd
6 changed files with 29 additions and 125 deletions
|
|
@ -14,36 +14,6 @@ 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;
|
||||||
|
|
@ -70,20 +40,7 @@ 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;
|
||||||
|
|
||||||
|
|
@ -102,11 +59,11 @@ public abstract partial class FarmableCrop : Item
|
||||||
}
|
}
|
||||||
|
|
||||||
[AfterDeserialization]
|
[AfterDeserialization]
|
||||||
public void AfterDeserialization()
|
private void AfterDeserialization()
|
||||||
{
|
{
|
||||||
if (_picked)
|
if (_picked)
|
||||||
{
|
{
|
||||||
//Unlink();
|
Unlink();
|
||||||
Delete();
|
Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@ namespace Server.Items;
|
||||||
public partial class FarmableFlax : FarmableCrop
|
public partial class FarmableFlax : FarmableCrop
|
||||||
{
|
{
|
||||||
[Constructible]
|
[Constructible]
|
||||||
public FarmableFlax() : base(6810)
|
public FarmableFlax() : base(GetCropID())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
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,17 +85,8 @@ public partial class Cotton : Item, IDyable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int amountToProcess = m_Cotton.Amount;
|
m_Cotton.Consume();
|
||||||
int cottonHue = m_Cotton.Hue;
|
wheel.BeginSpin(m_Cotton.OnSpun, from, 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,17 +85,8 @@ public partial class Flax : Item
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int amountToProcess = m_Flax.Amount;
|
m_Flax.Consume();
|
||||||
int flaxHue = m_Flax.Hue;
|
wheel.BeginSpin(m_Flax.OnSpun, from, 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,7 +14,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
|
@ -82,21 +81,8 @@ public partial class Wool : Item, IDyable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int amountToProcess = m_Wool.Amount;
|
m_Wool.Consume();
|
||||||
int woolHue = m_Wool.Hue;
|
wheel.BeginSpin(m_Wool.OnSpun, from, 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
|
||||||
|
|
@ -118,7 +104,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,48 +65,26 @@ 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
|
||||||
{
|
{
|
||||||
// 1. Capture stack values and current loom state before deletion
|
var create = new BoltOfCloth
|
||||||
int totalThreads = m_Material.Amount;
|
|
||||||
int currentPhase = loom.Phase;
|
|
||||||
int materialHue = m_Material.Hue;
|
|
||||||
|
|
||||||
// 2. Combine the loom's current contents with the incoming stack
|
|
||||||
int totalEffectiveThreads = currentPhase + totalThreads;
|
|
||||||
|
|
||||||
// 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 = m_Material.Hue
|
||||||
{
|
};
|
||||||
Hue = materialHue,
|
|
||||||
Amount = boltsToMake
|
|
||||||
};
|
|
||||||
|
|
||||||
from.SendLocalizedMessage(500368); // You create some cloth and put it in your backpack.
|
m_Material.Consume();
|
||||||
from.AddToBackpack(create);
|
loom.Phase = 0;
|
||||||
}
|
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