#WW# Looms and Spinning wheels now process entire stacks.
This commit is contained in:
parent
f0bb877f6a
commit
d07e5931a8
4 changed files with 116 additions and 31 deletions
|
|
@ -77,7 +77,7 @@ namespace Server.Items
|
||||||
m_Cotton = cotton;
|
m_Cotton = cotton;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnTarget( Mobile from, object targeted )
|
protected override void OnTarget( Mobile from, object targeted )
|
||||||
{
|
{
|
||||||
if ( m_Cotton.Deleted )
|
if ( m_Cotton.Deleted )
|
||||||
return;
|
return;
|
||||||
|
|
@ -101,8 +101,28 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Cotton.Consume();
|
int amount = m_Cotton.Amount;
|
||||||
wheel.BeginSpin( new SpinCallback( Cotton.OnSpun ), from, m_Cotton.Hue );
|
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
|
else
|
||||||
|
|
@ -112,4 +132,4 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,7 @@ namespace Server.Items
|
||||||
{
|
{
|
||||||
m_Flax = flax;
|
m_Flax = flax;
|
||||||
}
|
}
|
||||||
|
protected override void OnTarget( Mobile from, object targeted )
|
||||||
protected override void OnTarget( Mobile from, object targeted )
|
|
||||||
{
|
{
|
||||||
if ( m_Flax.Deleted )
|
if ( m_Flax.Deleted )
|
||||||
return;
|
return;
|
||||||
|
|
@ -91,8 +90,28 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Flax.Consume();
|
int amount = m_Flax.Amount;
|
||||||
wheel.BeginSpin( new SpinCallback( Flax.OnSpun ), from, m_Flax.Hue );
|
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
|
else
|
||||||
|
|
@ -102,4 +121,4 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ namespace Server.Items
|
||||||
m_Wool = wool;
|
m_Wool = wool;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnTarget( Mobile from, object targeted )
|
protected override void OnTarget( Mobile from, object targeted )
|
||||||
{
|
{
|
||||||
if ( m_Wool.Deleted )
|
if ( m_Wool.Deleted )
|
||||||
return;
|
return;
|
||||||
|
|
@ -101,9 +101,34 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Wool.Consume();
|
// 1. Capture the total stack amount and its hue
|
||||||
if ( m_Wool is TaintedWool ) wheel.BeginSpin( new SpinCallback( TaintedWool.OnSpun ), from, m_Wool.Hue );
|
int amount = m_Wool.Amount;
|
||||||
else wheel.BeginSpin( new SpinCallback( Wool.OnSpun ), from, m_Wool.Hue );
|
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
|
else
|
||||||
|
|
@ -155,4 +180,4 @@ namespace Server.Items
|
||||||
from.SendLocalizedMessage( 1010574 ); // You put a ball of yarn in your backpack.
|
from.SendLocalizedMessage( 1010574 ); // You put a ball of yarn in your backpack.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ namespace Server.Items
|
||||||
m_Material = material;
|
m_Material = material;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnTarget( Mobile from, object targeted )
|
protected override void OnTarget( Mobile from, object targeted )
|
||||||
{
|
{
|
||||||
if ( m_Material.Deleted )
|
if ( m_Material.Deleted )
|
||||||
return;
|
return;
|
||||||
|
|
@ -83,22 +83,43 @@ namespace Server.Items
|
||||||
{
|
{
|
||||||
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 )
|
else
|
||||||
{
|
{
|
||||||
m_Material.Consume();
|
int currentPhase = loom.Phase;
|
||||||
|
|
||||||
if ( targeted is Item )
|
int neededToFinish = 5 - currentPhase;
|
||||||
((Item)targeted).SendLocalizedMessageTo( from, 1010001 + loom.Phase++ );
|
|
||||||
}
|
if ( m_Material.Amount >= neededToFinish )
|
||||||
else
|
{
|
||||||
{
|
m_Material.Consume( neededToFinish );
|
||||||
Item create = new BoltOfCloth();
|
|
||||||
create.Hue = m_Material.Hue;
|
Item bolt1 = new BoltOfCloth();
|
||||||
|
bolt1.Hue = m_Material.Hue;
|
||||||
m_Material.Consume();
|
from.AddToBackpack( bolt1 );
|
||||||
loom.Phase = 0;
|
|
||||||
from.SendLocalizedMessage( 500368 ); // You create some cloth and put it in your backpack.
|
loom.Phase = 0; // Reset loom to empty
|
||||||
from.AddToBackpack( create );
|
|
||||||
|
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
|
else
|
||||||
|
|
@ -232,4 +253,4 @@ namespace Server.Items
|
||||||
int version = reader.ReadInt();
|
int version = reader.ReadInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue