#WW# Looms and Spinning wheels now process entire stacks.

This commit is contained in:
WarrentyExpired 2026-08-07 19:37:23 -04:00
parent f0bb877f6a
commit d07e5931a8
4 changed files with 116 additions and 31 deletions

View file

@ -77,7 +77,7 @@ namespace Server.Items
m_Cotton = cotton;
}
protected override void OnTarget( Mobile from, object targeted )
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Cotton.Deleted )
return;
@ -101,8 +101,28 @@ namespace Server.Items
}
else
{
m_Cotton.Consume();
wheel.BeginSpin( new SpinCallback( Cotton.OnSpun ), from, m_Cotton.Hue );
int amount = m_Cotton.Amount;
int hue = m_Cotton.Hue;
m_Cotton.Delete();
wheel.BeginSpin( ( w, m, h ) =>
{
int totalThread = 6 * amount;
while ( totalThread > 0 )
{
int threadToGive = Math.Min( totalThread, 60000 );
Item spools = new SpoolOfThread( threadToGive );
spools.Hue = h;
m.AddToBackpack( spools );
totalThread -= threadToGive;
}
m.SendLocalizedMessage( 1010577 ); // You put the spools of thread in your backpack.
}, from, hue );
}
}
else

View file

@ -66,8 +66,7 @@ namespace Server.Items
{
m_Flax = flax;
}
protected override void OnTarget( Mobile from, object targeted )
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Flax.Deleted )
return;
@ -91,8 +90,28 @@ namespace Server.Items
}
else
{
m_Flax.Consume();
wheel.BeginSpin( new SpinCallback( Flax.OnSpun ), from, m_Flax.Hue );
int amount = m_Flax.Amount;
int hue = m_Flax.Hue;
m_Flax.Delete();
wheel.BeginSpin( ( w, m, h ) =>
{
int totalThread = 6 * amount;
while ( totalThread > 0 )
{
int threadToGive = Math.Min( totalThread, 60000 );
Item spools = new SpoolOfThread( threadToGive );
spools.Hue = h;
m.AddToBackpack( spools );
totalThread -= threadToGive;
}
m.SendLocalizedMessage( 1010577 ); // You put the spools of thread in your backpack.
}, from, hue );
}
}
else

View file

@ -77,7 +77,7 @@ namespace Server.Items
m_Wool = wool;
}
protected override void OnTarget( Mobile from, object targeted )
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Wool.Deleted )
return;
@ -101,9 +101,34 @@ namespace Server.Items
}
else
{
m_Wool.Consume();
if ( m_Wool is TaintedWool ) wheel.BeginSpin( new SpinCallback( TaintedWool.OnSpun ), from, m_Wool.Hue );
else wheel.BeginSpin( new SpinCallback( Wool.OnSpun ), from, m_Wool.Hue );
// 1. Capture the total stack amount and its hue
int amount = m_Wool.Amount;
int hue = m_Wool.Hue;
// 2. Destroy the entire pile of wool at once
m_Wool.Delete();
// 3. Start the spin cycle and use a lambda for the multiplied yield
wheel.BeginSpin( ( w, m, h ) =>
{
// 1 wool = 3 balls of yarn. Calculate total yield.
int totalYarn = 3 * amount;
// 4. Safely loop the creation to prevent going over the 60,000 item limit
while ( totalYarn > 0 )
{
int yarnToGive = Math.Min( totalYarn, 60000 );
// In RunUO, "DarkYarn" is the core class used for all balls of yarn
Item yarn = new DarkYarn( yarnToGive );
yarn.Hue = h;
m.AddToBackpack( yarn );
totalYarn -= yarnToGive;
}
m.SendLocalizedMessage( 1010576 ); // You put the balls of yarn in your backpack.
}, from, hue );
}
}
else

View file

@ -67,7 +67,7 @@ namespace Server.Items
m_Material = material;
}
protected override void OnTarget( Mobile from, object targeted )
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Material.Deleted )
return;
@ -83,22 +83,43 @@ namespace Server.Items
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
else if ( loom.Phase < 4 )
else
{
m_Material.Consume();
int currentPhase = loom.Phase;
if ( targeted is Item )
((Item)targeted).SendLocalizedMessageTo( from, 1010001 + loom.Phase++ );
}
else
{
Item create = new BoltOfCloth();
create.Hue = m_Material.Hue;
int neededToFinish = 5 - currentPhase;
m_Material.Consume();
loom.Phase = 0;
from.SendLocalizedMessage( 500368 ); // You create some cloth and put it in your backpack.
from.AddToBackpack( create );
if ( m_Material.Amount >= neededToFinish )
{
m_Material.Consume( neededToFinish );
Item bolt1 = new BoltOfCloth();
bolt1.Hue = m_Material.Hue;
from.AddToBackpack( bolt1 );
loom.Phase = 0; // Reset loom to empty
int remainingThread = m_Material.Amount;
int extraBolts = remainingThread / 5;
if ( extraBolts > 0 )
{
m_Material.Consume( extraBolts * 5 );
Item extraBolt = new BoltOfCloth();
extraBolt.Hue = m_Material.Hue;
extraBolt.Amount = extraBolts; // Stack them if possible
from.AddToBackpack( extraBolt );
}
from.SendLocalizedMessage( 500368 ); // You create some cloth and put it in your backpack.
}
else
{
m_Material.Consume();
((Item)targeted).SendLocalizedMessageTo( from, 1010001 + currentPhase );
loom.Phase++;
}
}
}
else