diff --git a/Scripts/Items/Resources/Tailor/Cotton.cs b/Scripts/Items/Resources/Tailor/Cotton.cs index a167d4e..319368d 100644 --- a/Scripts/Items/Resources/Tailor/Cotton.cs +++ b/Scripts/Items/Resources/Tailor/Cotton.cs @@ -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 @@ -112,4 +132,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/Flax.cs b/Scripts/Items/Resources/Tailor/Flax.cs index e4ce574..6de1eae 100644 --- a/Scripts/Items/Resources/Tailor/Flax.cs +++ b/Scripts/Items/Resources/Tailor/Flax.cs @@ -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 @@ -102,4 +121,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/Wool.cs b/Scripts/Items/Resources/Tailor/Wool.cs index 3286d6c..b8aaca4 100644 --- a/Scripts/Items/Resources/Tailor/Wool.cs +++ b/Scripts/Items/Resources/Tailor/Wool.cs @@ -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 @@ -155,4 +180,4 @@ namespace Server.Items from.SendLocalizedMessage( 1010574 ); // You put a ball of yarn in your backpack. } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs b/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs index e27e6f2..3884fd9 100644 --- a/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs +++ b/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs @@ -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(); - - if ( targeted is Item ) - ((Item)targeted).SendLocalizedMessageTo( from, 1010001 + loom.Phase++ ); - } - else - { - Item create = new BoltOfCloth(); - create.Hue = m_Material.Hue; - - m_Material.Consume(); - loom.Phase = 0; - from.SendLocalizedMessage( 500368 ); // You create some cloth and put it in your backpack. - from.AddToBackpack( create ); + int currentPhase = loom.Phase; + + int neededToFinish = 5 - currentPhase; + + 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 @@ -232,4 +253,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +}