#W# Added FarmController to spawn farms. Auto harvest crops on walking over.

This commit is contained in:
WarrentyExpired 2026-08-18 18:53:37 -04:00
parent 4a466009a0
commit eb7d215ba3
4 changed files with 132 additions and 3 deletions

View file

@ -16,7 +16,29 @@ namespace Server.Items
{
Movable = false;
}
public override bool HandlesOnMovement { get { return true; } }
public override void OnMovement( Mobile m, Point3D oldLocation )
{
if ( m_Picked || !m.Alive || !m.Player )
return;
int harvestRange = (int)Server.ValidSettings.HarvestRange();
if ( m.InRange( this.Location, harvestRange ) )
{
Map map = this.Map;
Point3D loc = this.Location;
if ( Parent != null || Movable || IsLockedDown || IsSecure || map == null || map == Map.Internal )
return;
if ( m.InLOS( this ) )
{
OnPicked( m, loc, map );
}
}
}
public override void OnDoubleClick( Mobile from )
{
Map map = this.Map;
@ -31,14 +53,24 @@ namespace Server.Items
OnPicked( from, loc, map );
}
public virtual void OnPicked( Mobile from, Point3D loc, Map map )
public virtual void OnPicked( Mobile from, Point3D loc, Map map )
{
ItemID = GetPickedID();
Item spawn = GetCropObject();
if ( spawn != null )
spawn.MoveToWorld( loc, map );
{
if ( from.Backpack != null && from.Backpack.TryDropItem( from, spawn, false ) )
{
from.SendMessage( 0x35, "You harvest the crop and place it in your backpack." );
}
else
{
from.SendMessage( 0x22, "Your backpack is full, so the crop drops to the ground." );
spawn.MoveToWorld( loc, map );
}
}
m_Picked = true;
@ -91,4 +123,4 @@ namespace Server.Items
}
}
}
}
}