Fixes several bugs and streamlines the BOD code. (#32)
This commit is contained in:
parent
a45094f2dc
commit
114dc1a16b
21 changed files with 500 additions and 777 deletions
|
|
@ -1179,14 +1179,14 @@ namespace Server.Commands
|
|||
html.WriteLine(" </table></td></tr></table>");
|
||||
}
|
||||
|
||||
private static void DocumentTailorBOD(StreamWriter html, List<Item> items, string amt, BulkMaterialType material,
|
||||
private static void DocumentTailorBOD(StreamWriter html, List<RewardItem> items, string amt, BulkMaterialType material,
|
||||
Type type)
|
||||
{
|
||||
bool[] rewards = new bool[20];
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item item = items[i];
|
||||
Item item = items[i].Construct();
|
||||
|
||||
if (item is Sandals)
|
||||
{
|
||||
|
|
@ -1456,13 +1456,13 @@ namespace Server.Commands
|
|||
html.WriteLine(" </table></td></tr></table>");
|
||||
}
|
||||
|
||||
private static void DocumentSmithBOD(StreamWriter html, List<Item> items, string amt, BulkMaterialType material)
|
||||
private static void DocumentSmithBOD(StreamWriter html, List<RewardItem> items, string amt, BulkMaterialType material)
|
||||
{
|
||||
bool[] rewards = new bool[24];
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item item = items[i];
|
||||
Item item = items[i].Construct();
|
||||
|
||||
if (item is SturdyPickaxe || item is SturdyShovel)
|
||||
{
|
||||
|
|
|
|||
28
Scripts/Engines/BulkOrders/BODTarget.cs
Normal file
28
Scripts/Engines/BulkOrders/BODTarget.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using Server.Targeting;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class BODTarget : Target
|
||||
{
|
||||
private BaseBOD m_Deed;
|
||||
|
||||
public BODTarget(BaseBOD deed) : base(18, false, TargetFlags.None)
|
||||
{
|
||||
m_Deed = deed;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (m_Deed.Deleted || !m_Deed.IsChildOf(from.Backpack))
|
||||
return;
|
||||
|
||||
if (!(targeted is Item item && item.IsChildOf(from.Backpack)))
|
||||
{
|
||||
from.SendLocalizedMessage( 1045158 ); // You must have the item in your backpack to target it.
|
||||
return;
|
||||
}
|
||||
|
||||
m_Deed.EndCombine(from, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
153
Scripts/Engines/BulkOrders/BaseBOD.cs
Normal file
153
Scripts/Engines/BulkOrders/BaseBOD.cs
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public abstract class BaseBOD : Item
|
||||
{
|
||||
private int m_AmountMax;
|
||||
private bool m_RequireExceptional;
|
||||
private BulkMaterialType m_Material;
|
||||
|
||||
public static BulkMaterialType GetRandomMaterial(BulkMaterialType start, double[] chances)
|
||||
{
|
||||
double random = Utility.RandomDouble();
|
||||
|
||||
for ( int i = 0; i < chances.Length; ++i )
|
||||
{
|
||||
if ( random < chances[i] )
|
||||
return i == 0 ? BulkMaterialType.None : start + (i - 1);
|
||||
|
||||
random -= chances[i];
|
||||
}
|
||||
|
||||
return BulkMaterialType.None;
|
||||
}
|
||||
|
||||
public BaseBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material) : this()
|
||||
{
|
||||
Hue = hue;
|
||||
AmountMax = amountMax;
|
||||
RequireExceptional = requireExeptional;
|
||||
Material = material;
|
||||
}
|
||||
|
||||
public BaseBOD() : base(Core.AOS ? 0x2258 : 0x14EF)
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public BaseBOD(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract bool Complete{ get; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public sealed override int Hue{ get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int AmountMax
|
||||
{
|
||||
get => m_AmountMax;
|
||||
set{ m_AmountMax = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool RequireExceptional
|
||||
{
|
||||
get => m_RequireExceptional;
|
||||
set{ m_RequireExceptional = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public BulkMaterialType Material
|
||||
{
|
||||
get => m_Material;
|
||||
set{ m_Material = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
public abstract RewardGroup GetRewardGroup();
|
||||
|
||||
public abstract int ComputeGold();
|
||||
public abstract int ComputeFame();
|
||||
public abstract void EndCombine(Mobile from, Item item);
|
||||
|
||||
public virtual void GetRewards(out Item reward, out int gold, out int fame)
|
||||
{
|
||||
gold = ComputeGold();
|
||||
fame = ComputeFame();
|
||||
|
||||
List<RewardItem> rewards = ComputeRewards(false);
|
||||
|
||||
reward = rewards.Count <= 0 ? null : rewards[Utility.Random(rewards.Count)].Construct();
|
||||
}
|
||||
|
||||
public virtual List<RewardItem> ComputeRewards(bool full)
|
||||
{
|
||||
RewardGroup rewardGroup = GetRewardGroup();
|
||||
|
||||
List<RewardItem> list = new List<RewardItem>();
|
||||
|
||||
if (full)
|
||||
{
|
||||
for (int i = 0; i < rewardGroup?.Items.Length; ++i)
|
||||
{
|
||||
RewardItem reward = rewardGroup.Items[i];
|
||||
|
||||
if (reward != null)
|
||||
list.Add(reward);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RewardItem reward = rewardGroup.AcquireItem();
|
||||
|
||||
if (reward != null)
|
||||
list.Add(reward);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public virtual void BeginCombine(Mobile from)
|
||||
{
|
||||
if (Complete)
|
||||
from.SendLocalizedMessage(1045166); // The maximum amount of requested items have already been combined to this deed.
|
||||
else
|
||||
from.Target = new BODTarget(this);
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
|
||||
writer.Write( m_AmountMax );
|
||||
writer.Write( m_RequireExceptional );
|
||||
writer.Write( (int) m_Material );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_AmountMax = reader.ReadInt();
|
||||
m_RequireExceptional = reader.ReadBool();
|
||||
m_Material = (BulkMaterialType)reader.ReadInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( Parent == null && Map == Map.Internal && Location == Point3D.Zero )
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -131,10 +131,8 @@ namespace Server.Engines.BulkOrders
|
|||
if (number == 0)
|
||||
continue;
|
||||
|
||||
bool isSelected = filters[i, 1] == filterValue;
|
||||
|
||||
if (!isSelected && i % xOffsets.Length == 0)
|
||||
isSelected = filterValue == 0;
|
||||
bool isSelected = filters[i, 1] == filterValue ||
|
||||
i % xOffsets.Length == 0 && filterValue == 0;
|
||||
|
||||
AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset,
|
||||
xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor);
|
||||
|
|
|
|||
|
|
@ -60,9 +60,7 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
int price = 0;
|
||||
|
||||
VendorItem vi = pv.GetVendorItem(m_Book);
|
||||
|
||||
if (vi?.IsForSale == false)
|
||||
if (pv.GetVendorItem(m_Book)?.IsForSale == false)
|
||||
price = m_Entry.Price;
|
||||
|
||||
if (price != m_Price)
|
||||
|
|
@ -89,6 +87,7 @@ namespace Server.Engines.BulkOrders
|
|||
{
|
||||
pv.SayTo(m_From, 503204); // You do not have room in your backpack for this
|
||||
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
|
||||
item.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,23 +64,18 @@ namespace Server.Engines.BulkOrders
|
|||
{
|
||||
from.SendGump( new BOBGump( (PlayerMobile)from, this ) );
|
||||
|
||||
SecureTradeContainer cont = GetSecureTradeCont();
|
||||
SecureTrade trade = GetSecureTradeCont()?.Trade;
|
||||
|
||||
if ( cont != null )
|
||||
{
|
||||
SecureTrade trade = cont.Trade;
|
||||
|
||||
if (trade?.From.Mobile == from )
|
||||
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) );
|
||||
else if (trade?.To.Mobile == from )
|
||||
trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) );
|
||||
}
|
||||
if (trade?.From.Mobile == from )
|
||||
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) );
|
||||
else if (trade?.To.Mobile == from )
|
||||
trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) );
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnDragDrop( Mobile from, Item dropped )
|
||||
{
|
||||
if ( dropped is LargeBOD || dropped is SmallBOD )
|
||||
if ( dropped is BaseBOD )
|
||||
{
|
||||
if ( !IsChildOf( from.Backpack ) )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,15 +30,11 @@ namespace Server.Engines.BulkOrders
|
|||
{
|
||||
public static BulkGenericType Classify(BODType deedType, Type itemType)
|
||||
{
|
||||
if (deedType == BODType.Tailor)
|
||||
{
|
||||
if (itemType == null || itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)))
|
||||
return BulkGenericType.Leather;
|
||||
if (deedType != BODType.Tailor)
|
||||
return BulkGenericType.Iron;
|
||||
|
||||
return BulkGenericType.Cloth;
|
||||
}
|
||||
|
||||
return BulkGenericType.Iron;
|
||||
return itemType == null || itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes))
|
||||
? BulkGenericType.Leather : BulkGenericType.Cloth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,102 +3,40 @@ using Server.Mobiles;
|
|||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
[TypeAlias( "Scripts.Engines.BulkOrders.LargeBOD" )]
|
||||
public abstract class LargeBOD : Item
|
||||
public abstract class LargeBOD : BaseBOD
|
||||
{
|
||||
private int m_AmountMax;
|
||||
private bool m_RequireExceptional;
|
||||
private BulkMaterialType m_Material;
|
||||
private LargeBulkEntry[] m_Entries;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int AmountMax{ get => m_AmountMax;
|
||||
set{ m_AmountMax = value; InvalidateProperties(); } }
|
||||
public LargeBulkEntry[] Entries
|
||||
{
|
||||
get => m_Entries;
|
||||
set{ m_Entries = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool RequireExceptional{ get => m_RequireExceptional;
|
||||
set{ m_RequireExceptional = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public BulkMaterialType Material{ get => m_Material;
|
||||
set{ m_Material = value; InvalidateProperties(); } }
|
||||
|
||||
public LargeBulkEntry[] Entries{ get => m_Entries;
|
||||
set{ m_Entries = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool Complete
|
||||
public override bool Complete
|
||||
{
|
||||
get
|
||||
{
|
||||
for ( int i = 0; i < m_Entries.Length; ++i )
|
||||
{
|
||||
if ( m_Entries[i].Amount < m_AmountMax )
|
||||
if ( m_Entries[i].Amount < AmountMax )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract List<Item> ComputeRewards( bool full );
|
||||
public abstract int ComputeGold();
|
||||
public abstract int ComputeFame();
|
||||
|
||||
public virtual void GetRewards( out Item reward, out int gold, out int fame )
|
||||
{
|
||||
reward = null;
|
||||
gold = ComputeGold();
|
||||
fame = ComputeFame();
|
||||
|
||||
List<Item> rewards = ComputeRewards( false );
|
||||
|
||||
if ( rewards.Count > 0 )
|
||||
{
|
||||
reward = rewards[Utility.Random( rewards.Count )];
|
||||
|
||||
for ( int i = 0; i < rewards.Count; ++i )
|
||||
{
|
||||
if ( rewards[i] != reward )
|
||||
rewards[i].Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static BulkMaterialType GetRandomMaterial( BulkMaterialType start, double[] chances )
|
||||
{
|
||||
double random = Utility.RandomDouble();
|
||||
|
||||
for ( int i = 0; i < chances.Length; ++i )
|
||||
{
|
||||
if ( random < chances[i] )
|
||||
return ( i == 0 ? BulkMaterialType.None : start + (i - 1) );
|
||||
|
||||
random -= chances[i];
|
||||
}
|
||||
|
||||
return BulkMaterialType.None;
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1045151; // a bulk order deed
|
||||
|
||||
public LargeBOD( int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries ) : base( Core.AOS ? 0x2258 : 0x14EF )
|
||||
public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) :
|
||||
base(hue, amountMax, requireExeptional, material)
|
||||
{
|
||||
Weight = 1.0;
|
||||
Hue = hue; // Blacksmith: 0x44E; Tailoring: 0x483
|
||||
LootType = LootType.Blessed;
|
||||
|
||||
m_AmountMax = amountMax;
|
||||
m_RequireExceptional = requireExeptional;
|
||||
m_Material = material;
|
||||
m_Entries = entries;
|
||||
}
|
||||
|
||||
public LargeBOD() : base( Core.AOS ? 0x2258 : 0x14EF )
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
public LargeBOD()
|
||||
{
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
|
|
@ -106,13 +44,13 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
list.Add( 1060655 ); // large bulk order
|
||||
|
||||
if ( m_RequireExceptional )
|
||||
if ( RequireExceptional )
|
||||
list.Add( 1045141 ); // All items must be exceptional.
|
||||
|
||||
if ( m_Material != BulkMaterialType.None )
|
||||
list.Add( LargeBODGump.GetMaterialNumberFor( m_Material ) ); // All items must be made with x material.
|
||||
if ( Material != BulkMaterialType.None )
|
||||
list.Add( LargeBODGump.GetMaterialNumberFor( Material ) ); // All items must be made with x material.
|
||||
|
||||
list.Add( 1060656, m_AmountMax.ToString() ); // amount to make: ~1_val~
|
||||
list.Add( 1060656, AmountMax.ToString() ); // amount to make: ~1_val~
|
||||
|
||||
for ( int i = 0; i < m_Entries.Length; ++i )
|
||||
list.Add( 1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount ); // ~1_val~: ~2_val~
|
||||
|
|
@ -136,81 +74,70 @@ namespace Server.Engines.BulkOrders
|
|||
from.SendLocalizedMessage( 1045156 ); // You must have the deed in your backpack to use it.
|
||||
}
|
||||
|
||||
public void BeginCombine( Mobile from )
|
||||
{
|
||||
if ( !Complete )
|
||||
from.Target = new LargeBODTarget( this );
|
||||
else
|
||||
from.SendLocalizedMessage( 1045166 ); // The maximum amount of requested items have already been combined to this deed.
|
||||
}
|
||||
public override void EndCombine(Mobile from, Item item)
|
||||
{
|
||||
if (!(item is SmallBOD small))
|
||||
{
|
||||
from.SendLocalizedMessage(1045159); // That is not a bulk order.
|
||||
return;
|
||||
}
|
||||
|
||||
public void EndCombine( Mobile from, object o )
|
||||
{
|
||||
if ( o is Item item && item.IsChildOf( from.Backpack ) )
|
||||
{
|
||||
if ( item is SmallBOD small )
|
||||
{
|
||||
LargeBulkEntry entry = null;
|
||||
LargeBulkEntry entry = null;
|
||||
|
||||
for ( int i = 0; entry == null && i < m_Entries.Length; ++i )
|
||||
{
|
||||
if ( m_Entries[i].Details.Type == small.Type )
|
||||
entry = m_Entries[i];
|
||||
}
|
||||
for (int i = 0; i < m_Entries.Length; ++i)
|
||||
{
|
||||
if (m_Entries[i].Details.Type == small.Type)
|
||||
{
|
||||
entry = m_Entries[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( entry == null )
|
||||
{
|
||||
from.SendLocalizedMessage( 1045160 ); // That is not a bulk order for this large request.
|
||||
}
|
||||
else if ( m_RequireExceptional && !small.RequireExceptional )
|
||||
{
|
||||
from.SendLocalizedMessage( 1045161 ); // Both orders must be of exceptional quality.
|
||||
}
|
||||
else if ( m_Material >= BulkMaterialType.DullCopper && m_Material <= BulkMaterialType.Valorite && small.Material != m_Material )
|
||||
{
|
||||
from.SendLocalizedMessage( 1045162 ); // Both orders must use the same ore type.
|
||||
}
|
||||
else if ( m_Material >= BulkMaterialType.Spined && m_Material <= BulkMaterialType.Barbed && small.Material != m_Material )
|
||||
{
|
||||
from.SendLocalizedMessage( 1049351 ); // Both orders must use the same leather type.
|
||||
}
|
||||
else if ( m_AmountMax != small.AmountMax )
|
||||
{
|
||||
from.SendLocalizedMessage( 1045163 ); // The two orders have different requested amounts and cannot be combined.
|
||||
}
|
||||
else if ( small.AmountCur < small.AmountMax )
|
||||
{
|
||||
from.SendLocalizedMessage( 1045164 ); // The order to combine with is not completed.
|
||||
}
|
||||
else if ( entry.Amount >= m_AmountMax )
|
||||
{
|
||||
from.SendLocalizedMessage( 1045166 ); // The maximum amount of requested items have already been combined to this deed.
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.Amount += small.AmountCur;
|
||||
small.Delete();
|
||||
if (entry == null)
|
||||
{
|
||||
from.SendLocalizedMessage(1045160); // That is not a bulk order for this large request.
|
||||
}
|
||||
else if (RequireExceptional && !small.RequireExceptional)
|
||||
{
|
||||
from.SendLocalizedMessage(1045161); // Both orders must be of exceptional quality.
|
||||
}
|
||||
else if (Material >= BulkMaterialType.DullCopper && Material <= BulkMaterialType.Valorite &&
|
||||
small.Material != Material)
|
||||
{
|
||||
from.SendLocalizedMessage(1045162); // Both orders must use the same ore type.
|
||||
}
|
||||
else if (Material >= BulkMaterialType.Spined && Material <= BulkMaterialType.Barbed &&
|
||||
small.Material != Material)
|
||||
{
|
||||
from.SendLocalizedMessage(1049351); // Both orders must use the same leather type.
|
||||
}
|
||||
else if (AmountMax != small.AmountMax)
|
||||
{
|
||||
from.SendLocalizedMessage(1045163); // The two orders have different requested amounts and cannot be combined.
|
||||
}
|
||||
else if (small.AmountCur < small.AmountMax)
|
||||
{
|
||||
from.SendLocalizedMessage(1045164); // The order to combine with is not completed.
|
||||
}
|
||||
else if (entry.Amount >= AmountMax)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1045166); // The maximum amount of requested items have already been combined to this deed.
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.Amount += small.AmountCur;
|
||||
small.Delete();
|
||||
|
||||
from.SendLocalizedMessage( 1045165 ); // The orders have been combined.
|
||||
from.SendLocalizedMessage(1045165); // The orders have been combined.
|
||||
from.SendGump(new LargeBODGump(from, this));
|
||||
|
||||
from.SendGump( new LargeBODGump( from, this ) );
|
||||
if (!Complete)
|
||||
BeginCombine(from);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !Complete )
|
||||
BeginCombine( from );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1045159 ); // That is not a bulk order.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1045158 ); // You must have the item in your backpack to target it.
|
||||
}
|
||||
}
|
||||
|
||||
public LargeBOD( Serial serial ) : base( serial )
|
||||
public LargeBOD(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -218,11 +145,7 @@ namespace Server.Engines.BulkOrders
|
|||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( 0 ); // version
|
||||
|
||||
writer.Write( m_AmountMax );
|
||||
writer.Write( m_RequireExceptional );
|
||||
writer.Write( (int) m_Material );
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
|
||||
writer.Write( m_Entries.Length );
|
||||
|
||||
|
|
@ -234,16 +157,12 @@ namespace Server.Engines.BulkOrders
|
|||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_AmountMax = reader.ReadInt();
|
||||
m_RequireExceptional = reader.ReadBool();
|
||||
m_Material = (BulkMaterialType)reader.ReadInt();
|
||||
|
||||
m_Entries = new LargeBulkEntry[reader.ReadInt()];
|
||||
|
||||
for ( int i = 0; i < m_Entries.Length; ++i )
|
||||
|
|
@ -252,15 +171,6 @@ namespace Server.Engines.BulkOrders
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( Weight == 0.0 )
|
||||
Weight = 1.0;
|
||||
|
||||
if ( Core.AOS && ItemID == 0x14EF )
|
||||
ItemID = 0x2258;
|
||||
|
||||
if ( Parent == null && Map == Map.Internal && Location == Point3D.Zero )
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,12 @@ namespace Server.Engines.BulkOrders
|
|||
}
|
||||
}
|
||||
|
||||
public override void OnServerClose(NetState owner)
|
||||
{
|
||||
if (m_Deed?.Deleted == false)
|
||||
m_Deed.Delete();
|
||||
}
|
||||
|
||||
public static int GetMaterialNumberFor(BulkMaterialType material)
|
||||
{
|
||||
if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite)
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
using Server.Targeting;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class LargeBODTarget : Target
|
||||
{
|
||||
private LargeBOD m_Deed;
|
||||
|
||||
public LargeBODTarget(LargeBOD deed) : base(18, false, TargetFlags.None)
|
||||
{
|
||||
m_Deed = deed;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (m_Deed.Deleted || !m_Deed.IsChildOf(from.Backpack))
|
||||
return;
|
||||
|
||||
m_Deed.EndCombine(from, targeted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,10 +9,11 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
public LargeBOD Owner { get; set; }
|
||||
|
||||
public int Amount{ get => m_Amount;
|
||||
set{ m_Amount = value;
|
||||
Owner?.InvalidateProperties();
|
||||
} }
|
||||
public int Amount
|
||||
{
|
||||
get => m_Amount;
|
||||
set{ m_Amount = value; Owner?.InvalidateProperties(); }
|
||||
}
|
||||
public SmallBulkEntry Details { get; }
|
||||
|
||||
public static SmallBulkEntry[] LargeRing => GetEntries( "Blacksmith", "largering" );
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ using Mat = Server.Engines.BulkOrders.BulkMaterialType;
|
|||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
[TypeAlias("Scripts.Engines.BulkOrders.LargeSmithBOD")]
|
||||
public class LargeSmithBOD : LargeBOD
|
||||
{
|
||||
public static double[] m_BlacksmithMaterialChances =
|
||||
|
|
@ -63,12 +62,8 @@ namespace Server.Engines.BulkOrders
|
|||
int amountMax = Utility.RandomList(10, 15, 20, 20);
|
||||
bool reqExceptional = 0.825 > Utility.RandomDouble();
|
||||
|
||||
BulkMaterialType material;
|
||||
|
||||
if (useMaterials)
|
||||
material = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances);
|
||||
else
|
||||
material = BulkMaterialType.None;
|
||||
BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances)
|
||||
: BulkMaterialType.None;
|
||||
|
||||
Hue = hue;
|
||||
AmountMax = amountMax;
|
||||
|
|
@ -78,60 +73,20 @@ namespace Server.Engines.BulkOrders
|
|||
}
|
||||
|
||||
public LargeSmithBOD(int amountMax, bool reqExceptional, BulkMaterialType mat, LargeBulkEntry[] entries)
|
||||
: base(0x44E, amountMax, reqExceptional, mat, entries)
|
||||
{
|
||||
Hue = 0x44E;
|
||||
AmountMax = amountMax;
|
||||
Entries = entries;
|
||||
RequireExceptional = reqExceptional;
|
||||
Material = mat;
|
||||
}
|
||||
|
||||
public LargeSmithBOD(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int ComputeFame()
|
||||
{
|
||||
return SmithRewardCalculator.Instance.ComputeFame(this);
|
||||
}
|
||||
public override int ComputeFame() => SmithRewardCalculator.Instance.ComputeFame(this);
|
||||
|
||||
public override int ComputeGold()
|
||||
{
|
||||
return SmithRewardCalculator.Instance.ComputeGold(this);
|
||||
}
|
||||
public override int ComputeGold() => SmithRewardCalculator.Instance.ComputeGold(this);
|
||||
|
||||
public override List<Item> ComputeRewards(bool full)
|
||||
{
|
||||
List<Item> list = new List<Item>();
|
||||
|
||||
RewardGroup rewardGroup =
|
||||
SmithRewardCalculator.Instance.LookupRewards(SmithRewardCalculator.Instance.ComputePoints(this));
|
||||
|
||||
if (rewardGroup != null)
|
||||
{
|
||||
if (full)
|
||||
{
|
||||
for (int i = 0; i < rewardGroup.Items.Length; ++i)
|
||||
{
|
||||
Item item = rewardGroup.Items[i].Construct();
|
||||
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RewardItem rewardItem = rewardGroup.AcquireItem();
|
||||
|
||||
Item item = rewardItem?.Construct();
|
||||
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
public override RewardGroup GetRewardGroup() =>
|
||||
SmithRewardCalculator.Instance.LookupRewards(SmithRewardCalculator.Instance.ComputePoints(this));
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
|
|
@ -147,4 +102,4 @@ namespace Server.Engines.BulkOrders
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,12 +75,8 @@ namespace Server.Engines.BulkOrders
|
|||
int amountMax = Utility.RandomList(10, 15, 20, 20);
|
||||
bool reqExceptional = 0.825 > Utility.RandomDouble();
|
||||
|
||||
BulkMaterialType material;
|
||||
|
||||
if (useMaterials)
|
||||
material = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances);
|
||||
else
|
||||
material = BulkMaterialType.None;
|
||||
BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances)
|
||||
: BulkMaterialType.None;
|
||||
|
||||
Hue = hue;
|
||||
AmountMax = amountMax;
|
||||
|
|
@ -90,12 +86,8 @@ namespace Server.Engines.BulkOrders
|
|||
}
|
||||
|
||||
public LargeTailorBOD(int amountMax, bool reqExceptional, BulkMaterialType mat, LargeBulkEntry[] entries)
|
||||
: base(0x483, amountMax, reqExceptional, mat, entries)
|
||||
{
|
||||
Hue = 0x483;
|
||||
AmountMax = amountMax;
|
||||
Entries = entries;
|
||||
RequireExceptional = reqExceptional;
|
||||
Material = mat;
|
||||
}
|
||||
|
||||
public LargeTailorBOD(Serial serial) : base(serial)
|
||||
|
|
@ -112,38 +104,8 @@ namespace Server.Engines.BulkOrders
|
|||
return TailorRewardCalculator.Instance.ComputeGold(this);
|
||||
}
|
||||
|
||||
public override List<Item> ComputeRewards(bool full)
|
||||
{
|
||||
List<Item> list = new List<Item>();
|
||||
|
||||
RewardGroup rewardGroup =
|
||||
TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this));
|
||||
|
||||
if (rewardGroup != null)
|
||||
{
|
||||
if (full)
|
||||
{
|
||||
for (int i = 0; i < rewardGroup.Items.Length; ++i)
|
||||
{
|
||||
Item item = rewardGroup.Items[i].Construct();
|
||||
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RewardItem rewardItem = rewardGroup.AcquireItem();
|
||||
|
||||
Item item = rewardItem?.Construct();
|
||||
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
public override RewardGroup GetRewardGroup() =>
|
||||
TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this));
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
|
|
@ -159,4 +121,4 @@ namespace Server.Engines.BulkOrders
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,14 +107,12 @@ namespace Server.Engines.BulkOrders
|
|||
public virtual int ComputeFame(SmallBOD bod)
|
||||
{
|
||||
int points = ComputePoints(bod) / 50;
|
||||
|
||||
return points * points;
|
||||
}
|
||||
|
||||
public virtual int ComputeFame(LargeBOD bod)
|
||||
{
|
||||
int points = ComputePoints(bod) / 50;
|
||||
|
||||
return points * points;
|
||||
}
|
||||
|
||||
|
|
@ -350,10 +348,10 @@ namespace Server.Engines.BulkOrders
|
|||
if (itemCount == 1)
|
||||
return 0;
|
||||
|
||||
int typeIdx;
|
||||
int typeIdx = 0;
|
||||
|
||||
// Loop through the RewardTypes defined earlier and find the correct one.
|
||||
for (typeIdx = 0; typeIdx < 7; ++typeIdx)
|
||||
for (; typeIdx < 7; ++typeIdx)
|
||||
if (m_Types[typeIdx].Contains(type))
|
||||
break;
|
||||
|
||||
|
|
@ -399,14 +397,17 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
private static Item CreateMiningGloves(int type)
|
||||
{
|
||||
if (type == 1)
|
||||
return new LeatherGlovesOfMining(1);
|
||||
if (type == 3)
|
||||
return new StuddedGlovesOfMining(3);
|
||||
if (type == 5)
|
||||
return new RingmailGlovesOfMining(5);
|
||||
|
||||
throw new InvalidOperationException();
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
return new LeatherGlovesOfMining(1);
|
||||
case 3:
|
||||
return new StuddedGlovesOfMining(3);
|
||||
case 5:
|
||||
return new RingmailGlovesOfMining(5);
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private static Item CreateGargoylesPickaxe(int type)
|
||||
|
|
|
|||
|
|
@ -5,34 +5,22 @@ using Server.Mobiles;
|
|||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
[TypeAlias("Scripts.Engines.BulkOrders.SmallBOD")]
|
||||
public abstract class SmallBOD : Item
|
||||
public abstract class SmallBOD : BaseBOD
|
||||
{
|
||||
private int m_AmountCur, m_AmountMax;
|
||||
private BulkMaterialType m_Material;
|
||||
private int m_AmountCur;
|
||||
private int m_Number;
|
||||
private bool m_RequireExceptional;
|
||||
|
||||
[Constructible]
|
||||
public SmallBOD(int hue, int amountMax, Type type, int number, int graphic, bool requireExeptional,
|
||||
BulkMaterialType material) : base(Core.AOS ? 0x2258 : 0x14EF)
|
||||
public SmallBOD(int hue, int amountCur, int amountMax, Type type, int number, int graphic, bool requireExeptional,
|
||||
BulkMaterialType material) : base(hue, amountMax, requireExeptional, material)
|
||||
{
|
||||
Weight = 1.0;
|
||||
Hue = hue; // Blacksmith: 0x44E; Tailoring: 0x483
|
||||
LootType = LootType.Blessed;
|
||||
|
||||
m_AmountMax = amountMax;
|
||||
Type = type;
|
||||
m_Number = number;
|
||||
Graphic = graphic;
|
||||
m_RequireExceptional = requireExeptional;
|
||||
m_Material = material;
|
||||
m_AmountCur = amountCur;
|
||||
m_Number = number;
|
||||
}
|
||||
|
||||
public SmallBOD() : base(Core.AOS ? 0x2258 : 0x14EF)
|
||||
public SmallBOD()
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public SmallBOD(Serial serial) : base(serial)
|
||||
|
|
@ -50,17 +38,6 @@ namespace Server.Engines.BulkOrders
|
|||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int AmountMax
|
||||
{
|
||||
get => m_AmountMax;
|
||||
set
|
||||
{
|
||||
m_AmountMax = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Type Type{ get; set; }
|
||||
|
||||
|
|
@ -79,60 +56,23 @@ namespace Server.Engines.BulkOrders
|
|||
public int Graphic{ get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool RequireExceptional
|
||||
{
|
||||
get => m_RequireExceptional;
|
||||
set
|
||||
{
|
||||
m_RequireExceptional = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BulkMaterialType Material
|
||||
{
|
||||
get => m_Material;
|
||||
set
|
||||
{
|
||||
m_Material = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Complete => m_AmountCur == m_AmountMax;
|
||||
public override bool Complete => m_AmountCur == AmountMax;
|
||||
|
||||
public override int LabelNumber => 1045151; // a bulk order deed
|
||||
|
||||
public static BulkMaterialType GetRandomMaterial(BulkMaterialType start, double[] chances)
|
||||
{
|
||||
double random = Utility.RandomDouble();
|
||||
|
||||
for (int i = 0; i < chances.Length; ++i)
|
||||
{
|
||||
if (random < chances[i])
|
||||
return i == 0 ? BulkMaterialType.None : start + (i - 1);
|
||||
|
||||
random -= chances[i];
|
||||
}
|
||||
|
||||
return BulkMaterialType.None;
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1060654); // small bulk order
|
||||
|
||||
if (m_RequireExceptional)
|
||||
if (RequireExceptional)
|
||||
list.Add(1045141); // All items must be exceptional.
|
||||
|
||||
if (m_Material != BulkMaterialType.None)
|
||||
list.Add(SmallBODGump.GetMaterialNumberFor(m_Material)); // All items must be made with x material.
|
||||
if (Material != BulkMaterialType.None)
|
||||
list.Add(SmallBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material.
|
||||
|
||||
list.Add(1060656, m_AmountMax.ToString()); // amount to make: ~1_val~
|
||||
list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~
|
||||
list.Add(1060658, "#{0}\t{1}", m_Number, m_AmountCur); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
||||
|
|
@ -154,37 +94,6 @@ namespace Server.Engines.BulkOrders
|
|||
OnDoubleClick(from);
|
||||
}
|
||||
|
||||
public void BeginCombine(Mobile from)
|
||||
{
|
||||
if (m_AmountCur < m_AmountMax)
|
||||
from.Target = new SmallBODTarget(this);
|
||||
else
|
||||
from.SendLocalizedMessage(
|
||||
1045166); // The maximum amount of requested items have already been combined to this deed.
|
||||
}
|
||||
|
||||
public abstract List<Item> ComputeRewards(bool full);
|
||||
public abstract int ComputeGold();
|
||||
public abstract int ComputeFame();
|
||||
|
||||
public virtual void GetRewards(out Item reward, out int gold, out int fame)
|
||||
{
|
||||
reward = null;
|
||||
gold = ComputeGold();
|
||||
fame = ComputeFame();
|
||||
|
||||
List<Item> rewards = ComputeRewards(false);
|
||||
|
||||
if (rewards.Count > 0)
|
||||
{
|
||||
reward = rewards[Utility.Random(rewards.Count)];
|
||||
|
||||
for (int i = 0; i < rewards.Count; ++i)
|
||||
if (rewards[i] != reward)
|
||||
rewards[i].Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static BulkMaterialType GetMaterial(CraftResource resource)
|
||||
{
|
||||
switch (resource)
|
||||
|
|
@ -205,13 +114,11 @@ namespace Server.Engines.BulkOrders
|
|||
return BulkMaterialType.None;
|
||||
}
|
||||
|
||||
public void EndCombine(Mobile from, object o)
|
||||
public override void EndCombine(Mobile from, Item item)
|
||||
{
|
||||
if (o is Item item && item.IsChildOf(from.Backpack))
|
||||
{
|
||||
Type objectType = item.GetType();
|
||||
Type objectType = item.GetType();
|
||||
|
||||
if (m_AmountCur >= m_AmountMax)
|
||||
if (m_AmountCur >= AmountMax)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1045166); // The maximum amount of requested items have already been combined to this deed.
|
||||
|
|
@ -228,13 +135,13 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
BulkMaterialType material = GetMaterial(armor?.Resource ?? clothing?.Resource ?? CraftResource.None);
|
||||
|
||||
if (m_Material >= BulkMaterialType.DullCopper && m_Material <= BulkMaterialType.Valorite &&
|
||||
material != m_Material)
|
||||
if (Material >= BulkMaterialType.DullCopper && Material <= BulkMaterialType.Valorite &&
|
||||
material != Material)
|
||||
{
|
||||
from.SendLocalizedMessage(1045168); // The item is not made from the requested ore.
|
||||
}
|
||||
else if (m_Material >= BulkMaterialType.Spined && m_Material <= BulkMaterialType.Barbed &&
|
||||
material != m_Material)
|
||||
else if (Material >= BulkMaterialType.Spined && Material <= BulkMaterialType.Barbed &&
|
||||
material != Material)
|
||||
{
|
||||
from.SendLocalizedMessage(1049352); // The item is not made from the requested leather type.
|
||||
}
|
||||
|
|
@ -249,7 +156,7 @@ namespace Server.Engines.BulkOrders
|
|||
else
|
||||
isExceptional = clothing.Quality == ClothingQuality.Exceptional;
|
||||
|
||||
if (m_RequireExceptional && !isExceptional)
|
||||
if (RequireExceptional && !isExceptional)
|
||||
{
|
||||
from.SendLocalizedMessage(1045167); // The item must be exceptional.
|
||||
}
|
||||
|
|
@ -259,19 +166,13 @@ namespace Server.Engines.BulkOrders
|
|||
++AmountCur;
|
||||
|
||||
from.SendLocalizedMessage(1045170); // The item has been combined with the deed.
|
||||
|
||||
from.SendGump(new SmallBODGump(from, this));
|
||||
|
||||
if (m_AmountCur < m_AmountMax)
|
||||
if (m_AmountCur < AmountMax)
|
||||
BeginCombine(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1045158); // You must have the item in your backpack to target it.
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -281,12 +182,9 @@ namespace Server.Engines.BulkOrders
|
|||
writer.Write(0); // version
|
||||
|
||||
writer.Write(m_AmountCur);
|
||||
writer.Write(m_AmountMax);
|
||||
writer.Write(Type == null ? null : Type.FullName);
|
||||
writer.Write(m_Number);
|
||||
writer.Write(Graphic);
|
||||
writer.Write(m_RequireExceptional);
|
||||
writer.Write((int)m_Material);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
|
|
@ -300,7 +198,6 @@ namespace Server.Engines.BulkOrders
|
|||
case 0:
|
||||
{
|
||||
m_AmountCur = reader.ReadInt();
|
||||
m_AmountMax = reader.ReadInt();
|
||||
|
||||
string type = reader.ReadString();
|
||||
|
||||
|
|
@ -309,21 +206,9 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
m_Number = reader.ReadInt();
|
||||
Graphic = reader.ReadInt();
|
||||
m_RequireExceptional = reader.ReadBool();
|
||||
m_Material = (BulkMaterialType)reader.ReadInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Weight == 0.0)
|
||||
Weight = 1.0;
|
||||
|
||||
if (Core.AOS && ItemID == 0x14EF)
|
||||
ItemID = 0x2258;
|
||||
|
||||
if (Parent == null && Map == Map.Internal && Location == Point3D.Zero)
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,12 @@ namespace Server.Engines.BulkOrders
|
|||
}
|
||||
}
|
||||
|
||||
public override void OnServerClose(NetState owner)
|
||||
{
|
||||
if (m_Deed?.Deleted == false)
|
||||
m_Deed.Delete();
|
||||
}
|
||||
|
||||
public static int GetMaterialNumberFor(BulkMaterialType material)
|
||||
{
|
||||
if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite)
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
using Server.Targeting;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class SmallBODTarget : Target
|
||||
{
|
||||
private SmallBOD m_Deed;
|
||||
|
||||
public SmallBODTarget(SmallBOD deed) : base(18, false, TargetFlags.None)
|
||||
{
|
||||
m_Deed = deed;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (m_Deed.Deleted || !m_Deed.IsChildOf(from.Backpack))
|
||||
return;
|
||||
|
||||
m_Deed.EndCombine(from, targeted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ using Mat = Server.Engines.BulkOrders.BulkMaterialType;
|
|||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
[TypeAlias("Scripts.Engines.BulkOrders.SmallSmithBOD")]
|
||||
public class SmallSmithBOD : SmallBOD
|
||||
{
|
||||
public static double[] m_BlacksmithMaterialChances =
|
||||
|
|
@ -21,9 +20,33 @@ namespace Server.Engines.BulkOrders
|
|||
0.001953125 // Valorite
|
||||
};
|
||||
|
||||
private SmallSmithBOD(SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional)
|
||||
private SmallSmithBOD(SmallBulkEntry entry, BulkMaterialType mat, int amountMax, bool reqExceptional)
|
||||
: base(0x44E, 0, amountMax, entry.Type, entry.Number, entry.Graphic, reqExceptional, mat)
|
||||
{
|
||||
Hue = 0x44E;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public SmallSmithBOD()
|
||||
{
|
||||
bool useMaterials = Utility.RandomBool();
|
||||
|
||||
SmallBulkEntry[] entries = useMaterials ? SmallBulkEntry.BlacksmithArmor :
|
||||
SmallBulkEntry.BlacksmithWeapons;
|
||||
|
||||
if (entries.Length <= 0)
|
||||
return;
|
||||
|
||||
int hue = 0x44E;
|
||||
int amountMax = Utility.RandomList(10, 15, 20);
|
||||
|
||||
BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances)
|
||||
: BulkMaterialType.None;
|
||||
|
||||
bool reqExceptional = Utility.RandomBool() || material == BulkMaterialType.None;
|
||||
|
||||
SmallBulkEntry entry = entries[Utility.Random(entries.Length)];
|
||||
|
||||
Hue = hue;
|
||||
AmountMax = amountMax;
|
||||
Type = entry.Type;
|
||||
Number = entry.Number;
|
||||
|
|
@ -32,216 +55,128 @@ namespace Server.Engines.BulkOrders
|
|||
Material = material;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public SmallSmithBOD()
|
||||
{
|
||||
SmallBulkEntry[] entries;
|
||||
bool useMaterials;
|
||||
|
||||
if (useMaterials = Utility.RandomBool())
|
||||
entries = SmallBulkEntry.BlacksmithArmor;
|
||||
else
|
||||
entries = SmallBulkEntry.BlacksmithWeapons;
|
||||
|
||||
if (entries.Length > 0)
|
||||
{
|
||||
int hue = 0x44E;
|
||||
int amountMax = Utility.RandomList(10, 15, 20);
|
||||
|
||||
BulkMaterialType material;
|
||||
|
||||
if (useMaterials)
|
||||
material = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances);
|
||||
else
|
||||
material = BulkMaterialType.None;
|
||||
|
||||
bool reqExceptional = Utility.RandomBool() || material == BulkMaterialType.None;
|
||||
|
||||
SmallBulkEntry entry = entries[Utility.Random(entries.Length)];
|
||||
|
||||
Hue = hue;
|
||||
AmountMax = amountMax;
|
||||
Type = entry.Type;
|
||||
Number = entry.Number;
|
||||
Graphic = entry.Graphic;
|
||||
RequireExceptional = reqExceptional;
|
||||
Material = material;
|
||||
}
|
||||
}
|
||||
|
||||
public SmallSmithBOD(int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional,
|
||||
BulkMaterialType mat)
|
||||
BulkMaterialType mat) : base(0x44E, amountCur, amountMax, type, number, graphic, reqExceptional, mat)
|
||||
{
|
||||
Hue = 0x44E;
|
||||
AmountMax = amountMax;
|
||||
AmountCur = amountCur;
|
||||
Type = type;
|
||||
Number = number;
|
||||
Graphic = graphic;
|
||||
RequireExceptional = reqExceptional;
|
||||
Material = mat;
|
||||
}
|
||||
|
||||
public SmallSmithBOD(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int ComputeFame()
|
||||
{
|
||||
return SmithRewardCalculator.Instance.ComputeFame(this);
|
||||
}
|
||||
public override int ComputeFame() => SmithRewardCalculator.Instance.ComputeFame(this);
|
||||
|
||||
public override int ComputeGold()
|
||||
{
|
||||
return SmithRewardCalculator.Instance.ComputeGold(this);
|
||||
}
|
||||
public override int ComputeGold() => SmithRewardCalculator.Instance.ComputeGold(this);
|
||||
|
||||
public override List<Item> ComputeRewards(bool full)
|
||||
{
|
||||
List<Item> list = new List<Item>();
|
||||
|
||||
RewardGroup rewardGroup =
|
||||
SmithRewardCalculator.Instance.LookupRewards(SmithRewardCalculator.Instance.ComputePoints(this));
|
||||
|
||||
if (rewardGroup != null)
|
||||
{
|
||||
if (full)
|
||||
{
|
||||
for (int i = 0; i < rewardGroup.Items.Length; ++i)
|
||||
{
|
||||
Item item = rewardGroup.Items[i].Construct();
|
||||
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RewardItem rewardItem = rewardGroup.AcquireItem();
|
||||
|
||||
Item item = rewardItem?.Construct();
|
||||
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
public override RewardGroup GetRewardGroup() =>
|
||||
SmithRewardCalculator.Instance.LookupRewards(SmithRewardCalculator.Instance.ComputePoints(this));
|
||||
|
||||
public static SmallSmithBOD CreateRandomFor(Mobile m)
|
||||
{
|
||||
SmallBulkEntry[] entries;
|
||||
bool useMaterials;
|
||||
bool useMaterials = Utility.RandomBool();
|
||||
|
||||
if (useMaterials = Utility.RandomBool())
|
||||
entries = SmallBulkEntry.BlacksmithArmor;
|
||||
SmallBulkEntry[] entries = useMaterials ? SmallBulkEntry.BlacksmithArmor :
|
||||
SmallBulkEntry.BlacksmithWeapons;
|
||||
|
||||
if (entries.Length <= 0)
|
||||
return null;
|
||||
|
||||
double theirSkill = m.Skills.Blacksmith.Base;
|
||||
int amountMax;
|
||||
|
||||
if (theirSkill >= 70.1)
|
||||
amountMax = Utility.RandomList(10, 15, 20, 20);
|
||||
else if (theirSkill >= 50.1)
|
||||
amountMax = Utility.RandomList(10, 15, 15, 20);
|
||||
else
|
||||
entries = SmallBulkEntry.BlacksmithWeapons;
|
||||
amountMax = Utility.RandomList(10, 10, 15, 20);
|
||||
|
||||
if (entries.Length > 0)
|
||||
{
|
||||
double theirSkill = m.Skills.Blacksmith.Base;
|
||||
int amountMax;
|
||||
BulkMaterialType material = BulkMaterialType.None;
|
||||
|
||||
if (theirSkill >= 70.1)
|
||||
amountMax = Utility.RandomList(10, 15, 20, 20);
|
||||
else if (theirSkill >= 50.1)
|
||||
amountMax = Utility.RandomList(10, 15, 15, 20);
|
||||
else
|
||||
amountMax = Utility.RandomList(10, 10, 15, 20);
|
||||
if (useMaterials && theirSkill >= 70.1)
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
BulkMaterialType check = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances);
|
||||
double skillReq = 0.0;
|
||||
|
||||
BulkMaterialType material = BulkMaterialType.None;
|
||||
|
||||
if (useMaterials && theirSkill >= 70.1)
|
||||
for (int i = 0; i < 20; ++i)
|
||||
switch (check)
|
||||
{
|
||||
BulkMaterialType check = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances);
|
||||
double skillReq = 0.0;
|
||||
|
||||
switch (check)
|
||||
{
|
||||
case BulkMaterialType.DullCopper:
|
||||
skillReq = 65.0;
|
||||
break;
|
||||
case BulkMaterialType.ShadowIron:
|
||||
skillReq = 70.0;
|
||||
break;
|
||||
case BulkMaterialType.Copper:
|
||||
skillReq = 75.0;
|
||||
break;
|
||||
case BulkMaterialType.Bronze:
|
||||
skillReq = 80.0;
|
||||
break;
|
||||
case BulkMaterialType.Gold:
|
||||
skillReq = 85.0;
|
||||
break;
|
||||
case BulkMaterialType.Agapite:
|
||||
skillReq = 90.0;
|
||||
break;
|
||||
case BulkMaterialType.Verite:
|
||||
skillReq = 95.0;
|
||||
break;
|
||||
case BulkMaterialType.Valorite:
|
||||
skillReq = 100.0;
|
||||
break;
|
||||
case BulkMaterialType.Spined:
|
||||
skillReq = 65.0;
|
||||
break;
|
||||
case BulkMaterialType.Horned:
|
||||
skillReq = 80.0;
|
||||
break;
|
||||
case BulkMaterialType.Barbed:
|
||||
skillReq = 99.0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (theirSkill >= skillReq)
|
||||
{
|
||||
material = check;
|
||||
case BulkMaterialType.DullCopper:
|
||||
skillReq = 65.0;
|
||||
break;
|
||||
case BulkMaterialType.ShadowIron:
|
||||
skillReq = 70.0;
|
||||
break;
|
||||
case BulkMaterialType.Copper:
|
||||
skillReq = 75.0;
|
||||
break;
|
||||
case BulkMaterialType.Bronze:
|
||||
skillReq = 80.0;
|
||||
break;
|
||||
case BulkMaterialType.Gold:
|
||||
skillReq = 85.0;
|
||||
break;
|
||||
case BulkMaterialType.Agapite:
|
||||
skillReq = 90.0;
|
||||
break;
|
||||
case BulkMaterialType.Verite:
|
||||
skillReq = 95.0;
|
||||
break;
|
||||
case BulkMaterialType.Valorite:
|
||||
skillReq = 100.0;
|
||||
break;
|
||||
case BulkMaterialType.Spined:
|
||||
skillReq = 65.0;
|
||||
break;
|
||||
case BulkMaterialType.Horned:
|
||||
skillReq = 80.0;
|
||||
break;
|
||||
case BulkMaterialType.Barbed:
|
||||
skillReq = 99.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double excChance = 0.0;
|
||||
|
||||
if (theirSkill >= 70.1)
|
||||
excChance = (theirSkill + 80.0) / 200.0;
|
||||
|
||||
bool reqExceptional = excChance > Utility.RandomDouble();
|
||||
|
||||
CraftSystem system = DefBlacksmithy.CraftSystem;
|
||||
|
||||
List<SmallBulkEntry> validEntries = new List<SmallBulkEntry>();
|
||||
|
||||
for (int i = 0; i < entries.Length; ++i)
|
||||
{
|
||||
CraftItem item = system.CraftItems.SearchFor(entries[i].Type);
|
||||
|
||||
if (item != null)
|
||||
if (theirSkill >= skillReq)
|
||||
{
|
||||
bool allRequiredSkills = true;
|
||||
double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills);
|
||||
|
||||
if (allRequiredSkills && chance >= 0.0)
|
||||
{
|
||||
if (reqExceptional)
|
||||
chance = item.GetExceptionalChance(system, chance, m);
|
||||
|
||||
if (chance > 0.0)
|
||||
validEntries.Add(entries[i]);
|
||||
}
|
||||
material = check;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (validEntries.Count > 0)
|
||||
double excChance = theirSkill >= 70.1 ? (theirSkill + 80.0) / 200.0 : 0.0;
|
||||
|
||||
bool reqExceptional = excChance > Utility.RandomDouble();
|
||||
|
||||
CraftSystem system = DefBlacksmithy.CraftSystem;
|
||||
|
||||
List<SmallBulkEntry> validEntries = new List<SmallBulkEntry>();
|
||||
|
||||
for (int i = 0; i < entries.Length; ++i)
|
||||
{
|
||||
CraftItem item = system.CraftItems.SearchFor(entries[i].Type);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];
|
||||
return new SmallSmithBOD(entry, material, amountMax, reqExceptional);
|
||||
bool allRequiredSkills = true;
|
||||
double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills);
|
||||
|
||||
if (allRequiredSkills && chance >= 0.0)
|
||||
{
|
||||
if (reqExceptional)
|
||||
chance = item.GetExceptionalChance(system, chance, m);
|
||||
|
||||
if (chance > 0.0)
|
||||
validEntries.Add(entries[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
if (validEntries.Count <= 0)
|
||||
return null;
|
||||
|
||||
SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];
|
||||
return new SmallSmithBOD(entry, material, amountMax, reqExceptional);
|
||||
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -258,4 +193,4 @@ namespace Server.Engines.BulkOrders
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,30 @@ namespace Server.Engines.BulkOrders
|
|||
0.001953125 // Barbed
|
||||
};
|
||||
|
||||
private SmallTailorBOD(SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional)
|
||||
private SmallTailorBOD(SmallBulkEntry entry, BulkMaterialType mat, int amountMax, bool reqExceptional)
|
||||
: base(0x483, 0, amountMax, entry.Type, entry.Number, entry.Graphic, reqExceptional, mat)
|
||||
{
|
||||
Hue = 0x483;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public SmallTailorBOD()
|
||||
{
|
||||
bool useMaterials = Utility.RandomBool();
|
||||
SmallBulkEntry[] entries = useMaterials ? SmallBulkEntry.TailorLeather : SmallBulkEntry.TailorCloth;
|
||||
|
||||
if (entries.Length <= 0)
|
||||
return;
|
||||
|
||||
int hue = 0x483;
|
||||
int amountMax = Utility.RandomList(10, 15, 20);
|
||||
|
||||
BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances)
|
||||
: BulkMaterialType.None;
|
||||
|
||||
bool reqExceptional = Utility.RandomBool() || material == BulkMaterialType.None;
|
||||
SmallBulkEntry entry = entries[Utility.Random(entries.Length)];
|
||||
|
||||
Hue = hue;
|
||||
AmountMax = amountMax;
|
||||
Type = entry.Type;
|
||||
Number = entry.Number;
|
||||
|
|
@ -25,102 +46,21 @@ namespace Server.Engines.BulkOrders
|
|||
Material = material;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public SmallTailorBOD()
|
||||
{
|
||||
SmallBulkEntry[] entries;
|
||||
bool useMaterials;
|
||||
|
||||
if (useMaterials = Utility.RandomBool())
|
||||
entries = SmallBulkEntry.TailorLeather;
|
||||
else
|
||||
entries = SmallBulkEntry.TailorCloth;
|
||||
|
||||
if (entries.Length > 0)
|
||||
{
|
||||
int hue = 0x483;
|
||||
int amountMax = Utility.RandomList(10, 15, 20);
|
||||
|
||||
BulkMaterialType material;
|
||||
|
||||
if (useMaterials)
|
||||
material = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances);
|
||||
else
|
||||
material = BulkMaterialType.None;
|
||||
|
||||
bool reqExceptional = Utility.RandomBool() || material == BulkMaterialType.None;
|
||||
|
||||
SmallBulkEntry entry = entries[Utility.Random(entries.Length)];
|
||||
|
||||
Hue = hue;
|
||||
AmountMax = amountMax;
|
||||
Type = entry.Type;
|
||||
Number = entry.Number;
|
||||
Graphic = entry.Graphic;
|
||||
RequireExceptional = reqExceptional;
|
||||
Material = material;
|
||||
}
|
||||
}
|
||||
|
||||
public SmallTailorBOD(int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional,
|
||||
BulkMaterialType mat)
|
||||
BulkMaterialType mat) : base(0x483, amountCur, amountMax, type, number, graphic, reqExceptional, mat)
|
||||
{
|
||||
Hue = 0x483;
|
||||
AmountMax = amountMax;
|
||||
AmountCur = amountCur;
|
||||
Type = type;
|
||||
Number = number;
|
||||
Graphic = graphic;
|
||||
RequireExceptional = reqExceptional;
|
||||
Material = mat;
|
||||
}
|
||||
|
||||
public SmallTailorBOD(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int ComputeFame()
|
||||
{
|
||||
return TailorRewardCalculator.Instance.ComputeFame(this);
|
||||
}
|
||||
public override int ComputeFame() => TailorRewardCalculator.Instance.ComputeFame(this);
|
||||
|
||||
public override int ComputeGold()
|
||||
{
|
||||
return TailorRewardCalculator.Instance.ComputeGold(this);
|
||||
}
|
||||
public override int ComputeGold() => TailorRewardCalculator.Instance.ComputeGold(this);
|
||||
|
||||
public override List<Item> ComputeRewards(bool full)
|
||||
{
|
||||
List<Item> list = new List<Item>();
|
||||
|
||||
RewardGroup rewardGroup =
|
||||
TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this));
|
||||
|
||||
if (rewardGroup != null)
|
||||
{
|
||||
if (full)
|
||||
{
|
||||
for (int i = 0; i < rewardGroup.Items.Length; ++i)
|
||||
{
|
||||
Item item = rewardGroup.Items[i].Construct();
|
||||
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RewardItem rewardItem = rewardGroup.AcquireItem();
|
||||
|
||||
Item item = rewardItem?.Construct();
|
||||
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
public override RewardGroup GetRewardGroup() =>
|
||||
TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this));
|
||||
|
||||
public static SmallTailorBOD CreateRandomFor(Mobile m)
|
||||
{
|
||||
|
|
@ -128,8 +68,9 @@ namespace Server.Engines.BulkOrders
|
|||
bool useMaterials = Utility.RandomBool();
|
||||
|
||||
double theirSkill = m.Skills.Tailoring.Base;
|
||||
if (useMaterials && theirSkill >= 6.2
|
||||
) // Ugly, but the easiest leather BOD is Leather Cap which requires at least 6.2 skill.
|
||||
|
||||
// Ugly, but the easiest leather BOD is Leather Cap which requires at least 6.2 skill.
|
||||
if (useMaterials && theirSkill >= 6.2)
|
||||
entries = SmallBulkEntry.TailorLeather;
|
||||
else
|
||||
entries = SmallBulkEntry.TailorCloth;
|
||||
|
|
@ -247,4 +188,4 @@ namespace Server.Engines.BulkOrders
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
|
@ -134,6 +134,7 @@
|
|||
<Compile Include="Context Menus\EjectPlayer.cs" />
|
||||
<Compile Include="Context Menus\OpenBankEntry.cs" />
|
||||
<Compile Include="Context Menus\TeachEntry.cs" />
|
||||
<Compile Include="Engines\BulkOrders\BaseBOD.cs" />
|
||||
<Compile Include="Engines\BulkOrders\Books\BOBFilter.cs" />
|
||||
<Compile Include="Engines\BulkOrders\Books\BOBFilterGump.cs" />
|
||||
<Compile Include="Engines\BulkOrders\Books\BOBGump.cs" />
|
||||
|
|
@ -148,7 +149,6 @@
|
|||
<Compile Include="Engines\BulkOrders\LargeBOD.cs" />
|
||||
<Compile Include="Engines\BulkOrders\LargeBODAcceptGump.cs" />
|
||||
<Compile Include="Engines\BulkOrders\LargeBODGump.cs" />
|
||||
<Compile Include="Engines\BulkOrders\LargeBODTarget.cs" />
|
||||
<Compile Include="Engines\BulkOrders\LargeBulkEntry.cs" />
|
||||
<Compile Include="Engines\BulkOrders\LargeSmithBOD.cs" />
|
||||
<Compile Include="Engines\BulkOrders\LargeTailorBOD.cs" />
|
||||
|
|
@ -156,7 +156,7 @@
|
|||
<Compile Include="Engines\BulkOrders\SmallBOD.cs" />
|
||||
<Compile Include="Engines\BulkOrders\SmallBODAcceptGump.cs" />
|
||||
<Compile Include="Engines\BulkOrders\SmallBODGump.cs" />
|
||||
<Compile Include="Engines\BulkOrders\SmallBODTarget.cs" />
|
||||
<Compile Include="Engines\BulkOrders\BODTarget.cs" />
|
||||
<Compile Include="Engines\BulkOrders\SmallBulkEntry.cs" />
|
||||
<Compile Include="Engines\BulkOrders\SmallSmithBOD.cs" />
|
||||
<Compile Include="Engines\BulkOrders\SmallTailorBOD.cs" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue