From edce93bba823222d18d41e8cb3ffa4a81004cc61 Mon Sep 17 00:00:00 2001 From: WarrentyExpired Date: Fri, 28 Aug 2026 21:18:35 -0400 Subject: [PATCH] #W# Change: Walking over farmable crops auto harvests them and puts it in your backpack. --- .../UOContent/Items/Farming/FarmableCrop.cs | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/Projects/UOContent/Items/Farming/FarmableCrop.cs b/Projects/UOContent/Items/Farming/FarmableCrop.cs index db07588cd..7144396be 100644 --- a/Projects/UOContent/Items/Farming/FarmableCrop.cs +++ b/Projects/UOContent/Items/Farming/FarmableCrop.cs @@ -14,6 +14,36 @@ public abstract partial class FarmableCrop : Item public abstract Item GetCropObject(); 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) { var map = Map; @@ -40,7 +70,20 @@ public abstract partial class FarmableCrop : Item 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; @@ -59,11 +102,11 @@ public abstract partial class FarmableCrop : Item } [AfterDeserialization] - private void AfterDeserialization() + public void AfterDeserialization() { if (_picked) { - Unlink(); + //Unlink(); Delete(); } }