#W# Source and Scripts added. Added Scripts/Settings.cs to expose some basic tweak able settings.
This commit is contained in:
parent
b51c58f514
commit
3045c83799
3512 changed files with 627673 additions and 0 deletions
88
Scripts/Engines/BulkOrders/Books/BOBFilter.cs
Normal file
88
Scripts/Engines/BulkOrders/Books/BOBFilter.cs
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class BOBFilter
|
||||
{
|
||||
private int m_Type;
|
||||
private int m_Quality;
|
||||
private int m_Material;
|
||||
private int m_Quantity;
|
||||
|
||||
public bool IsDefault
|
||||
{
|
||||
get{ return ( m_Type == 0 && m_Quality == 0 && m_Material == 0 && m_Quantity == 0 ); }
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
m_Type = 0;
|
||||
m_Quality = 0;
|
||||
m_Material = 0;
|
||||
m_Quantity = 0;
|
||||
}
|
||||
|
||||
public int Type
|
||||
{
|
||||
get{ return m_Type; }
|
||||
set{ m_Type = value; }
|
||||
}
|
||||
|
||||
public int Quality
|
||||
{
|
||||
get{ return m_Quality; }
|
||||
set{ m_Quality = value; }
|
||||
}
|
||||
|
||||
public int Material
|
||||
{
|
||||
get{ return m_Material; }
|
||||
set{ m_Material = value; }
|
||||
}
|
||||
|
||||
public int Quantity
|
||||
{
|
||||
get{ return m_Quantity; }
|
||||
set{ m_Quantity = value; }
|
||||
}
|
||||
|
||||
public BOBFilter()
|
||||
{
|
||||
}
|
||||
|
||||
public BOBFilter( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Type = reader.ReadEncodedInt();
|
||||
m_Quality = reader.ReadEncodedInt();
|
||||
m_Material = reader.ReadEncodedInt();
|
||||
m_Quantity = reader.ReadEncodedInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
if ( IsDefault )
|
||||
{
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteEncodedInt( 1 ); // version
|
||||
|
||||
writer.WriteEncodedInt( m_Type );
|
||||
writer.WriteEncodedInt( m_Quality );
|
||||
writer.WriteEncodedInt( m_Material );
|
||||
writer.WriteEncodedInt( m_Quantity );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
215
Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs
Normal file
215
Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class BOBFilterGump : Gump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private BulkOrderBook m_Book;
|
||||
|
||||
private const int LabelColor = 0x7FFF;
|
||||
|
||||
private static int[,] m_MaterialFilters = new int[,]
|
||||
{
|
||||
{ 1044067, 1 }, // Blacksmithy
|
||||
{ 1062226, 3 }, // Iron
|
||||
{ 1018332, 4 }, // Dull Copper
|
||||
{ 1018333, 5 }, // Shadow Iron
|
||||
{ 1018334, 6 }, // Copper
|
||||
{ 1018335, 7 }, // Bronze
|
||||
|
||||
{ 0, 0 }, // --Blank--
|
||||
{ 1018336, 8 }, // Golden
|
||||
{ 1018337, 9 }, // Agapite
|
||||
{ 1018338, 10 }, // Verite
|
||||
{ 1018339, 11 }, // Valorite
|
||||
{ 0, 0 }, // --Blank--
|
||||
|
||||
{ 1044094, 2 }, // Tailoring
|
||||
{ 1044286, 12 }, // Cloth
|
||||
{ 1062235, 13 }, // Leather
|
||||
{ 1062236, 14 }, // Spined
|
||||
{ 1062237, 15 }, // Horned
|
||||
{ 1062238, 16 } // Barbed
|
||||
};
|
||||
|
||||
private static int[,] m_TypeFilters = new int[,]
|
||||
{
|
||||
{ 1062229, 0 }, // All
|
||||
{ 1062224, 1 }, // Small
|
||||
{ 1062225, 2 } // Large
|
||||
};
|
||||
|
||||
private static int[,] m_QualityFilters = new int[,]
|
||||
{
|
||||
{ 1062229, 0 }, // All
|
||||
{ 1011542, 1 }, // Normal
|
||||
{ 1060636, 2 } // Exceptional
|
||||
};
|
||||
|
||||
private static int[,] m_AmountFilters = new int[,]
|
||||
{
|
||||
{ 1062229, 0 }, // All
|
||||
{ 1049706, 1 }, // 10
|
||||
{ 1016007, 2 }, // 15
|
||||
{ 1062239, 3 } // 20
|
||||
};
|
||||
|
||||
private static int[][,] m_Filters = new int[][,]
|
||||
{
|
||||
m_TypeFilters,
|
||||
m_QualityFilters,
|
||||
m_MaterialFilters,
|
||||
m_AmountFilters
|
||||
};
|
||||
|
||||
private static int[] m_XOffsets_Type = new int[]{ 0, 75, 170 };
|
||||
private static int[] m_XOffsets_Quality = new int[]{ 0, 75, 170 };
|
||||
private static int[] m_XOffsets_Amount = new int[]{ 0, 75, 180, 275 };
|
||||
private static int[] m_XOffsets_Material = new int[]{ 0, 105, 210, 305, 390, 485 };
|
||||
|
||||
private static int[] m_XWidths_Small = new int[]{ 50, 50, 70, 50 };
|
||||
private static int[] m_XWidths_Large = new int[]{ 80, 50, 50, 50, 50, 50 };
|
||||
|
||||
private void AddFilterList( int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue, int filterIndex )
|
||||
{
|
||||
for ( int i = 0; i < filters.GetLength( 0 ); ++i )
|
||||
{
|
||||
int number = filters[i, 0];
|
||||
|
||||
if ( number == 0 )
|
||||
continue;
|
||||
|
||||
bool isSelected = ( filters[i, 1] == filterValue );
|
||||
|
||||
if ( !isSelected && (i % xOffsets.Length) == 0 )
|
||||
isSelected = ( filterValue == 0 );
|
||||
|
||||
AddHtmlLocalized( x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor, false, false );
|
||||
AddButton( x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + (i * 4), GumpButtonType.Reply, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
|
||||
{
|
||||
BOBFilter f = ( m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter );
|
||||
|
||||
int index = info.ButtonID;
|
||||
|
||||
switch ( index )
|
||||
{
|
||||
case 0: // Apply
|
||||
{
|
||||
m_From.SendGump( new BOBGump( m_From, m_Book ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // Set Book Filter
|
||||
{
|
||||
m_From.UseOwnFilter = false;
|
||||
m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Set Your Filter
|
||||
{
|
||||
m_From.UseOwnFilter = true;
|
||||
m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Clear Filter
|
||||
{
|
||||
f.Clear();
|
||||
m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
index -= 4;
|
||||
|
||||
int type = index % 4;
|
||||
index /= 4;
|
||||
|
||||
if ( type >= 0 && type < m_Filters.Length )
|
||||
{
|
||||
int[,] filters = m_Filters[type];
|
||||
|
||||
if ( index >= 0 && index < filters.GetLength( 0 ) )
|
||||
{
|
||||
if ( filters[index, 0] == 0 )
|
||||
break;
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case 0: f.Type = filters[index, 1]; break;
|
||||
case 1: f.Quality = filters[index, 1]; break;
|
||||
case 2: f.Material = filters[index, 1]; break;
|
||||
case 3: f.Quantity = filters[index, 1]; break;
|
||||
}
|
||||
|
||||
m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BOBFilterGump( PlayerMobile from, BulkOrderBook book ) : base( 12, 24 )
|
||||
{
|
||||
from.CloseGump( typeof( BOBGump ) );
|
||||
from.CloseGump( typeof( BOBFilterGump ) );
|
||||
|
||||
m_From = from;
|
||||
m_Book = book;
|
||||
|
||||
BOBFilter f = ( from.UseOwnFilter ? from.BOBFilter : book.Filter );
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 10, 10, 600, 439, 5054 );
|
||||
|
||||
AddImageTiled( 18, 20, 583, 420, 2624 );
|
||||
AddAlphaRegion( 18, 20, 583, 420 );
|
||||
|
||||
AddImage( 5, 5, 10460 );
|
||||
AddImage( 585, 5, 10460 );
|
||||
AddImage( 5, 424, 10460 );
|
||||
AddImage( 585, 424, 10460 );
|
||||
|
||||
AddHtmlLocalized( 270, 32, 200, 32, 1062223, LabelColor, false, false ); // Filter Preference
|
||||
|
||||
AddHtmlLocalized( 26, 64, 120, 32, 1062228, LabelColor, false, false ); // Bulk Order Type
|
||||
AddFilterList( 25, 96, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0 );
|
||||
|
||||
AddHtmlLocalized( 320, 64, 50, 32, 1062215, LabelColor, false, false ); // Quality
|
||||
AddFilterList( 320, 96, m_XOffsets_Quality, 40, m_QualityFilters, m_XWidths_Small, f.Quality, 1 );
|
||||
|
||||
AddHtmlLocalized( 26, 160, 120, 32, 1062232, LabelColor, false, false ); // Material Type
|
||||
AddFilterList( 25, 192, m_XOffsets_Material, 40, m_MaterialFilters, m_XWidths_Large, f.Material, 2 );
|
||||
|
||||
AddHtmlLocalized( 26, 320, 120, 32, 1062217, LabelColor, false, false ); // Amount
|
||||
AddFilterList( 25, 352, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 3 );
|
||||
|
||||
AddHtmlLocalized( 75, 416, 120, 32, 1062477, ( from.UseOwnFilter ? LabelColor : 16927 ), false, false ); // Set Book Filter
|
||||
AddButton( 40, 416, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 235, 416, 120, 32, 1062478, ( from.UseOwnFilter ? 16927 : LabelColor ), false, false ); // Set Your Filter
|
||||
AddButton( 200, 416, 4005, 4007, 2, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 405, 416, 120, 32, 1062231, LabelColor, false, false ); // Clear Filter
|
||||
AddButton( 370, 416, 4005, 4007, 3, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 540, 416, 50, 32, 1011046, LabelColor, false, false ); // APPLY
|
||||
AddButton( 505, 416, 4017, 4018, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
708
Scripts/Engines/BulkOrders/Books/BOBGump.cs
Normal file
708
Scripts/Engines/BulkOrders/Books/BOBGump.cs
Normal file
|
|
@ -0,0 +1,708 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Prompts;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class BOBGump : Gump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private BulkOrderBook m_Book;
|
||||
private ArrayList m_List;
|
||||
|
||||
private int m_Page;
|
||||
|
||||
private const int LabelColor = 0x7FFF;
|
||||
|
||||
public Item Reconstruct( object obj )
|
||||
{
|
||||
Item item = null;
|
||||
|
||||
if ( obj is BOBLargeEntry )
|
||||
item = ((BOBLargeEntry)obj).Reconstruct();
|
||||
else if ( obj is BOBSmallEntry )
|
||||
item = ((BOBSmallEntry)obj).Reconstruct();
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public bool CheckFilter( object obj )
|
||||
{
|
||||
if ( obj is BOBLargeEntry )
|
||||
{
|
||||
BOBLargeEntry e = (BOBLargeEntry)obj;
|
||||
|
||||
return CheckFilter( e.Material, e.AmountMax, true, e.RequireExceptional, e.DeedType, ( e.Entries.Length > 0 ? e.Entries[0].ItemType : null ) );
|
||||
}
|
||||
else if ( obj is BOBSmallEntry )
|
||||
{
|
||||
BOBSmallEntry e = (BOBSmallEntry)obj;
|
||||
|
||||
return CheckFilter( e.Material, e.AmountMax, false, e.RequireExceptional, e.DeedType, e.ItemType );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CheckFilter( BulkMaterialType mat, int amountMax, bool isLarge, bool reqExc, BODType deedType, Type itemType )
|
||||
{
|
||||
BOBFilter f = ( m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter );
|
||||
|
||||
if ( f.IsDefault )
|
||||
return true;
|
||||
|
||||
if ( f.Quality == 1 && reqExc )
|
||||
return false;
|
||||
else if ( f.Quality == 2 && !reqExc )
|
||||
return false;
|
||||
|
||||
if ( f.Quantity == 1 && amountMax != 10 )
|
||||
return false;
|
||||
else if ( f.Quantity == 2 && amountMax != 15 )
|
||||
return false;
|
||||
else if ( f.Quantity == 3 && amountMax != 20 )
|
||||
return false;
|
||||
|
||||
if ( f.Type == 1 && isLarge )
|
||||
return false;
|
||||
else if ( f.Type == 2 && !isLarge )
|
||||
return false;
|
||||
|
||||
switch ( f.Material )
|
||||
{
|
||||
default:
|
||||
case 0: return true;
|
||||
case 1: return ( deedType == BODType.Smith );
|
||||
case 2: return ( deedType == BODType.Tailor );
|
||||
|
||||
case 3: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Iron );
|
||||
case 4: return ( mat == BulkMaterialType.DullCopper );
|
||||
case 5: return ( mat == BulkMaterialType.ShadowIron );
|
||||
case 6: return ( mat == BulkMaterialType.Copper );
|
||||
case 7: return ( mat == BulkMaterialType.Bronze );
|
||||
case 8: return ( mat == BulkMaterialType.Gold );
|
||||
case 9: return ( mat == BulkMaterialType.Agapite );
|
||||
case 10: return ( mat == BulkMaterialType.Verite );
|
||||
case 11: return ( mat == BulkMaterialType.Valorite );
|
||||
|
||||
case 12: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Cloth );
|
||||
case 13: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Leather );
|
||||
case 14: return ( mat == BulkMaterialType.Spined );
|
||||
case 15: return ( mat == BulkMaterialType.Horned );
|
||||
case 16: return ( mat == BulkMaterialType.Barbed );
|
||||
}
|
||||
}
|
||||
|
||||
public int GetIndexForPage( int page )
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
while ( page-- > 0 )
|
||||
index += GetCountForIndex( index );
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
public int GetCountForIndex( int index )
|
||||
{
|
||||
int slots = 0;
|
||||
int count = 0;
|
||||
|
||||
ArrayList list = m_List;
|
||||
|
||||
for ( int i = index; i >= 0 && i < list.Count; ++i )
|
||||
{
|
||||
object obj = list[i];
|
||||
|
||||
if ( CheckFilter( obj ) )
|
||||
{
|
||||
int add;
|
||||
|
||||
if ( obj is BOBLargeEntry )
|
||||
add = ((BOBLargeEntry)obj).Entries.Length;
|
||||
else
|
||||
add = 1;
|
||||
|
||||
if ( (slots + add) > 10 )
|
||||
break;
|
||||
|
||||
slots += add;
|
||||
}
|
||||
|
||||
++count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public int GetPageForIndex(int index, int sizeDropped)
|
||||
{
|
||||
if (index <= 0)
|
||||
return 0;
|
||||
|
||||
int count = 0;
|
||||
int add = 0;
|
||||
int page = 0;
|
||||
ArrayList list = m_List;
|
||||
int i;
|
||||
object obj;
|
||||
|
||||
for (i=0; (i < index) && (i < list.Count); i++)
|
||||
{
|
||||
obj = list[i];
|
||||
if (CheckFilter(obj))
|
||||
{
|
||||
if (obj is BOBLargeEntry)
|
||||
add = ((BOBLargeEntry)obj).Entries.Length;
|
||||
else
|
||||
add = 1;
|
||||
count += add;
|
||||
if (count > 10)
|
||||
{
|
||||
page++;
|
||||
count = add;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* now we are on the page of the bod preceeding the dropped one.
|
||||
* next step: checking whether we have to remain where we are.
|
||||
* The counter i needs to be incremented as the bod to this very moment
|
||||
* has not yet been removed from m_List */
|
||||
i++;
|
||||
|
||||
/* if, for instance, a big bod of size 6 has been removed, smaller bods
|
||||
* might fall back into this page. Depending on their sizes, the page eeds
|
||||
* to be adjusted accordingly. This is done now.
|
||||
*/
|
||||
if (count + sizeDropped > 10)
|
||||
{
|
||||
while ((i < list.Count) && (count <= 10))
|
||||
{
|
||||
obj = list[i];
|
||||
if (CheckFilter(obj))
|
||||
{
|
||||
if (obj is BOBLargeEntry)
|
||||
count += ((BOBLargeEntry)obj).Entries.Length;
|
||||
else
|
||||
count += 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (count > 10)
|
||||
page++;
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public object GetMaterialName( BulkMaterialType mat, BODType type, Type itemType )
|
||||
{
|
||||
switch ( type )
|
||||
{
|
||||
case BODType.Smith:
|
||||
{
|
||||
switch ( mat )
|
||||
{
|
||||
case BulkMaterialType.None: return 1062226;
|
||||
case BulkMaterialType.DullCopper: return 1018332;
|
||||
case BulkMaterialType.ShadowIron: return 1018333;
|
||||
case BulkMaterialType.Copper: return 1018334;
|
||||
case BulkMaterialType.Bronze: return 1018335;
|
||||
case BulkMaterialType.Gold: return 1018336;
|
||||
case BulkMaterialType.Agapite: return 1018337;
|
||||
case BulkMaterialType.Verite: return 1018338;
|
||||
case BulkMaterialType.Valorite: return 1018339;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case BODType.Tailor:
|
||||
{
|
||||
switch ( mat )
|
||||
{
|
||||
case BulkMaterialType.None:
|
||||
{
|
||||
if ( itemType.IsSubclassOf( typeof( BaseArmor ) ) || itemType.IsSubclassOf( typeof( BaseShoes ) ) )
|
||||
return 1062235;
|
||||
|
||||
return 1044286;
|
||||
}
|
||||
case BulkMaterialType.Spined: return 1062236;
|
||||
case BulkMaterialType.Horned: return 1062237;
|
||||
case BulkMaterialType.Barbed: return 1062238;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
public BOBGump( PlayerMobile from, BulkOrderBook book ) : this( from, book, 0, null )
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
|
||||
{
|
||||
int index = info.ButtonID;
|
||||
|
||||
switch ( index )
|
||||
{
|
||||
case 0: // EXIT
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 1: // Set Filter
|
||||
{
|
||||
m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Previous page
|
||||
{
|
||||
if ( m_Page > 0 )
|
||||
m_From.SendGump( new BOBGump( m_From, m_Book, m_Page - 1, m_List ) );
|
||||
|
||||
return;
|
||||
}
|
||||
case 3: // Next page
|
||||
{
|
||||
if ( GetIndexForPage( m_Page + 1 ) < m_List.Count )
|
||||
m_From.SendGump( new BOBGump( m_From, m_Book, m_Page + 1, m_List ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Price all
|
||||
{
|
||||
if ( m_Book.IsChildOf( m_From.Backpack ) )
|
||||
{
|
||||
m_From.Prompt = new SetPricePrompt( m_Book, null, m_Page, m_List );
|
||||
m_From.SendMessage( "Type in a price for all deeds in the book:" );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
bool canDrop = m_Book.IsChildOf( m_From.Backpack );
|
||||
bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor);
|
||||
|
||||
index -= 5;
|
||||
|
||||
int type = index % 2;
|
||||
index /= 2;
|
||||
|
||||
if ( index < 0 || index >= m_List.Count )
|
||||
break;
|
||||
|
||||
object obj = m_List[index];
|
||||
|
||||
if ( !m_Book.Entries.Contains( obj ) )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1062382 ); // The deed selected is not available.
|
||||
break;
|
||||
}
|
||||
|
||||
if ( type == 0 ) // Drop
|
||||
{
|
||||
if ( m_Book.IsChildOf( m_From.Backpack ) )
|
||||
{
|
||||
Item item = Reconstruct( obj );
|
||||
|
||||
if ( item != null )
|
||||
{
|
||||
Container pack = m_From.Backpack;
|
||||
if ((pack == null) || ((pack != null) && (!pack.CheckHold(m_From, item, true, true, 0, item.PileWeight + item.TotalWeight))))
|
||||
{
|
||||
m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this
|
||||
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Book.IsChildOf(m_From.Backpack))
|
||||
{
|
||||
int sizeOfDroppedBod;
|
||||
if (obj is BOBLargeEntry)
|
||||
sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length;
|
||||
else
|
||||
sizeOfDroppedBod = 1;
|
||||
|
||||
m_From.AddToBackpack(item);
|
||||
m_From.SendLocalizedMessage(1045152); // The bulk order deed has been placed in your backpack.
|
||||
m_Book.Entries.Remove(obj);
|
||||
m_Book.InvalidateProperties();
|
||||
|
||||
if ( m_Book.Entries.Count / 5 < m_Book.ItemCount )
|
||||
{
|
||||
m_Book.ItemCount--;
|
||||
m_Book.InvalidateItems();
|
||||
}
|
||||
|
||||
if (m_Book.Entries.Count > 0)
|
||||
{
|
||||
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
|
||||
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null));
|
||||
}
|
||||
else
|
||||
m_From.SendLocalizedMessage(1062381); // The book is empty.
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendMessage( "Internal error. The bulk order deed could not be reconstructed." );
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Set Price | Buy
|
||||
{
|
||||
if ( m_Book.IsChildOf( m_From.Backpack ) )
|
||||
{
|
||||
m_From.Prompt = new SetPricePrompt( m_Book, obj, m_Page, m_List );
|
||||
m_From.SendLocalizedMessage( 1062383 ); // Type in a price for the deed:
|
||||
}
|
||||
else if ( m_Book.RootParent is PlayerVendor )
|
||||
{
|
||||
PlayerVendor pv = (PlayerVendor)m_Book.RootParent;
|
||||
VendorItem vi = pv.GetVendorItem( m_Book );
|
||||
|
||||
if (vi != null && !vi.IsForSale)
|
||||
{
|
||||
int sizeOfDroppedBod;
|
||||
int price = 0;
|
||||
if (obj is BOBLargeEntry)
|
||||
{
|
||||
price = ((BOBLargeEntry)obj).Price;
|
||||
sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
price = ((BOBSmallEntry)obj).Price;
|
||||
sizeOfDroppedBod = 1;
|
||||
}
|
||||
if (price == 0)
|
||||
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
|
||||
else
|
||||
{
|
||||
if (m_Book.Entries.Count > 0)
|
||||
{
|
||||
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
|
||||
m_From.SendGump(new BODBuyGump(m_From, m_Book, obj, m_Page, price));
|
||||
}
|
||||
else
|
||||
m_From.SendLocalizedMessage(1062381); // The book is emptz
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SetPricePrompt : Prompt
|
||||
{
|
||||
private BulkOrderBook m_Book;
|
||||
private object m_Object;
|
||||
private int m_Page;
|
||||
private ArrayList m_List;
|
||||
|
||||
public SetPricePrompt( BulkOrderBook book, object obj, int page, ArrayList list )
|
||||
{
|
||||
m_Book = book;
|
||||
m_Object = obj;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
public override void OnResponse( Mobile from, string text )
|
||||
{
|
||||
if ( m_Object != null && !m_Book.Entries.Contains( m_Object ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062382 ); // The deed selected is not available.
|
||||
return;
|
||||
}
|
||||
|
||||
int price = Utility.ToInt32( text );
|
||||
|
||||
if ( price < 0 || price > 250000000 )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062390 ); // The price you requested is outrageous!
|
||||
}
|
||||
else if ( m_Object == null )
|
||||
{
|
||||
for ( int i = 0; i < m_List.Count; ++i )
|
||||
{
|
||||
object obj = m_List[i];
|
||||
|
||||
if ( !m_Book.Entries.Contains( obj ) )
|
||||
continue;
|
||||
|
||||
if ( obj is BOBLargeEntry )
|
||||
((BOBLargeEntry)obj).Price = price;
|
||||
else if ( obj is BOBSmallEntry )
|
||||
((BOBSmallEntry)obj).Price = price;
|
||||
}
|
||||
|
||||
from.SendMessage( "Deed prices set." );
|
||||
|
||||
if ( from is PlayerMobile )
|
||||
from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
|
||||
}
|
||||
else if ( m_Object is BOBLargeEntry )
|
||||
{
|
||||
((BOBLargeEntry)m_Object).Price = price;
|
||||
|
||||
from.SendLocalizedMessage( 1062384 ); // Deed price set.
|
||||
|
||||
if ( from is PlayerMobile )
|
||||
from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
|
||||
}
|
||||
else if ( m_Object is BOBSmallEntry )
|
||||
{
|
||||
((BOBSmallEntry)m_Object).Price = price;
|
||||
|
||||
from.SendLocalizedMessage( 1062384 ); // Deed price set.
|
||||
|
||||
if ( from is PlayerMobile )
|
||||
from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BOBGump( PlayerMobile from, BulkOrderBook book, int page, ArrayList list ) : base( 12, 24 )
|
||||
{
|
||||
from.CloseGump( typeof( BOBGump ) );
|
||||
from.CloseGump( typeof( BOBFilterGump ) );
|
||||
|
||||
m_From = from;
|
||||
m_Book = book;
|
||||
m_Page = page;
|
||||
|
||||
if ( list == null )
|
||||
{
|
||||
list = new ArrayList( book.Entries.Count );
|
||||
|
||||
for ( int i = 0; i < book.Entries.Count; ++i )
|
||||
{
|
||||
object obj = book.Entries[i];
|
||||
|
||||
if ( CheckFilter( obj ) )
|
||||
list.Add( obj );
|
||||
}
|
||||
}
|
||||
|
||||
m_List = list;
|
||||
|
||||
int index = GetIndexForPage( page );
|
||||
int count = GetCountForIndex( index );
|
||||
|
||||
int tableIndex = 0;
|
||||
|
||||
PlayerVendor pv = book.RootParent as PlayerVendor;
|
||||
|
||||
bool canDrop = book.IsChildOf( from.Backpack );
|
||||
bool canBuy = ( pv != null );
|
||||
bool canPrice = ( canDrop || canBuy );
|
||||
|
||||
if ( canBuy )
|
||||
{
|
||||
VendorItem vi = pv.GetVendorItem( book );
|
||||
|
||||
canBuy = ( vi != null && !vi.IsForSale );
|
||||
}
|
||||
|
||||
int width = 600;
|
||||
|
||||
if ( !canPrice )
|
||||
width = 516;
|
||||
|
||||
X = (624 - width) / 2;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 10, 10, width, 439, 5054 );
|
||||
AddImageTiled( 18, 20, width - 17, 420, 2624 );
|
||||
|
||||
if ( canPrice )
|
||||
{
|
||||
AddImageTiled( 573, 64, 24, 352, 200 );
|
||||
AddImageTiled( 493, 64, 78, 352, 1416 );
|
||||
}
|
||||
|
||||
if ( canDrop )
|
||||
AddImageTiled( 24, 64, 32, 352, 1416 );
|
||||
|
||||
AddImageTiled( 58, 64, 36, 352, 200 );
|
||||
AddImageTiled( 96, 64, 133, 352, 1416 );
|
||||
AddImageTiled( 231, 64, 80, 352, 200 );
|
||||
AddImageTiled( 313, 64, 100, 352, 1416 );
|
||||
AddImageTiled( 415, 64, 76, 352, 200 );
|
||||
|
||||
for ( int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i )
|
||||
{
|
||||
object obj = list[i];
|
||||
|
||||
if ( !CheckFilter( obj ) )
|
||||
continue;
|
||||
|
||||
AddImageTiled( 24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624 );
|
||||
|
||||
if ( obj is BOBLargeEntry )
|
||||
tableIndex += ((BOBLargeEntry)obj).Entries.Length;
|
||||
else if ( obj is BOBSmallEntry )
|
||||
++tableIndex;
|
||||
}
|
||||
|
||||
AddAlphaRegion( 18, 20, width - 17, 420 );
|
||||
AddImage( 5, 5, 10460 );
|
||||
AddImage( width - 15, 5, 10460 );
|
||||
AddImage( 5, 424, 10460 );
|
||||
AddImage( width - 15, 424, 10460 );
|
||||
|
||||
AddHtmlLocalized( canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor, false, false ); // Bulk Order Book
|
||||
AddHtmlLocalized( 63, 64, 200, 32, 1062213, LabelColor, false, false ); // Type
|
||||
AddHtmlLocalized( 147, 64, 200, 32, 1062214, LabelColor, false, false ); // Item
|
||||
AddHtmlLocalized( 246, 64, 200, 32, 1062215, LabelColor, false, false ); // Quality
|
||||
AddHtmlLocalized( 336, 64, 200, 32, 1062216, LabelColor, false, false ); // Material
|
||||
AddHtmlLocalized( 429, 64, 200, 32, 1062217, LabelColor, false, false ); // Amount
|
||||
|
||||
AddButton( 35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 70, 32, 200, 32, 1062476, LabelColor, false, false ); // Set Filter
|
||||
|
||||
BOBFilter f = ( from.UseOwnFilter ? from.BOBFilter : book.Filter );
|
||||
|
||||
if ( f.IsDefault )
|
||||
AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false ); // Using No Filter
|
||||
else if ( from.UseOwnFilter )
|
||||
AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false ); // Using Your Filter
|
||||
else
|
||||
AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false ); // Using Book Filter
|
||||
|
||||
AddButton( 375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 410, 416, 120, 20, 1011441, LabelColor, false, false ); // EXIT
|
||||
|
||||
if ( canDrop )
|
||||
AddHtmlLocalized( 26, 64, 50, 32, 1062212, LabelColor, false, false ); // Drop
|
||||
|
||||
if ( canPrice )
|
||||
{
|
||||
AddHtmlLocalized( 516, 64, 200, 32, 1062218, LabelColor, false, false ); // Price
|
||||
|
||||
if ( canBuy )
|
||||
{
|
||||
AddHtmlLocalized( 576, 64, 200, 32, 1062219, LabelColor, false, false ); // Buy
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtmlLocalized( 576, 64, 200, 32, 1062227, LabelColor, false, false ); // Set
|
||||
|
||||
AddButton( 450, 416, 4005, 4007, 4, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 485, 416, 120, 20, "<BASEFONT COLOR=#FFFFFF>Price all</FONT>", false, false );
|
||||
}
|
||||
}
|
||||
|
||||
tableIndex = 0;
|
||||
|
||||
if ( page > 0 )
|
||||
{
|
||||
AddButton( 75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 110, 416, 150, 20, 1011067, LabelColor, false, false ); // Previous page
|
||||
}
|
||||
|
||||
if ( GetIndexForPage( page + 1 ) < list.Count )
|
||||
{
|
||||
AddButton( 225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 260, 416, 150, 20, 1011066, LabelColor, false, false ); // Next page
|
||||
}
|
||||
|
||||
for ( int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i )
|
||||
{
|
||||
object obj = list[i];
|
||||
|
||||
if ( !CheckFilter( obj ) )
|
||||
continue;
|
||||
|
||||
if ( obj is BOBLargeEntry )
|
||||
{
|
||||
BOBLargeEntry e = (BOBLargeEntry)obj;
|
||||
|
||||
int y = 96 + (tableIndex * 32);
|
||||
|
||||
if ( canDrop )
|
||||
AddButton( 35, y + 2, 5602, 5606, 5 + (i * 2), GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( canDrop || (canBuy && e.Price > 0) )
|
||||
{
|
||||
AddButton( 579, y + 2, 2117, 2118, 6 + (i * 2), GumpButtonType.Reply, 0 );
|
||||
AddLabel( 495, y, 1152, e.Price.ToString() );
|
||||
}
|
||||
|
||||
AddHtmlLocalized( 61, y, 50, 32, 1062225, LabelColor, false, false ); // Large
|
||||
|
||||
for ( int j = 0; j < e.Entries.Length; ++j )
|
||||
{
|
||||
BOBLargeSubEntry sub = e.Entries[j];
|
||||
|
||||
AddHtmlLocalized( 103, y, 130, 32, sub.Number, LabelColor, false, false );
|
||||
|
||||
if ( e.RequireExceptional )
|
||||
AddHtmlLocalized( 235, y, 80, 20, 1060636, LabelColor, false, false ); // exceptional
|
||||
else
|
||||
AddHtmlLocalized( 235, y, 80, 20, 1011542, LabelColor, false, false ); // normal
|
||||
|
||||
object name = GetMaterialName( e.Material, e.DeedType, sub.ItemType );
|
||||
|
||||
if ( name is int )
|
||||
AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false );
|
||||
else if ( name is string )
|
||||
AddLabel( 316, y, 1152, (string)name );
|
||||
|
||||
AddLabel( 421, y, 1152, String.Format( "{0} / {1}", sub.AmountCur, e.AmountMax ) );
|
||||
|
||||
++tableIndex;
|
||||
y += 32;
|
||||
}
|
||||
}
|
||||
else if ( obj is BOBSmallEntry )
|
||||
{
|
||||
BOBSmallEntry e = (BOBSmallEntry)obj;
|
||||
|
||||
int y = 96 + (tableIndex++ * 32);
|
||||
|
||||
if ( canDrop )
|
||||
AddButton( 35, y + 2, 5602, 5606, 5 + (i * 2), GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( canDrop || (canBuy && e.Price > 0) )
|
||||
{
|
||||
AddButton( 579, y + 2, 2117, 2118, 6 + (i * 2), GumpButtonType.Reply, 0 );
|
||||
AddLabel( 495, y, 1152, e.Price.ToString() );
|
||||
}
|
||||
|
||||
AddHtmlLocalized( 61, y, 50, 32, 1062224, LabelColor, false, false ); // Small
|
||||
|
||||
AddHtmlLocalized( 103, y, 130, 32, e.Number, LabelColor, false, false );
|
||||
|
||||
if ( e.RequireExceptional )
|
||||
AddHtmlLocalized( 235, y, 80, 20, 1060636, LabelColor, false, false ); // exceptional
|
||||
else
|
||||
AddHtmlLocalized( 235, y, 80, 20, 1011542, LabelColor, false, false ); // normal
|
||||
|
||||
object name = GetMaterialName( e.Material, e.DeedType, e.ItemType );
|
||||
|
||||
if ( name is int )
|
||||
AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false );
|
||||
else if ( name is string )
|
||||
AddLabel( 316, y, 1152, (string)name );
|
||||
|
||||
AddLabel( 421, y, 1152, String.Format( "{0} / {1}", e.AmountCur, e.AmountMax ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
110
Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs
Normal file
110
Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class BOBLargeEntry
|
||||
{
|
||||
private bool m_RequireExceptional;
|
||||
private BODType m_DeedType;
|
||||
private BulkMaterialType m_Material;
|
||||
private int m_AmountMax;
|
||||
private int m_Price;
|
||||
private BOBLargeSubEntry[] m_Entries;
|
||||
|
||||
public bool RequireExceptional{ get{ return m_RequireExceptional; } }
|
||||
public BODType DeedType{ get{ return m_DeedType; } }
|
||||
public BulkMaterialType Material{ get{ return m_Material; } }
|
||||
public int AmountMax{ get{ return m_AmountMax; } }
|
||||
public int Price{ get{ return m_Price; } set{ m_Price = value; } }
|
||||
public BOBLargeSubEntry[] Entries{ get{ return m_Entries; } }
|
||||
|
||||
public Item Reconstruct()
|
||||
{
|
||||
LargeBOD bod = null;
|
||||
|
||||
if ( m_DeedType == BODType.Smith )
|
||||
bod = new LargeSmithBOD( m_AmountMax, m_RequireExceptional, m_Material, ReconstructEntries() );
|
||||
else if ( m_DeedType == BODType.Tailor )
|
||||
bod = new LargeTailorBOD( m_AmountMax, m_RequireExceptional, m_Material, ReconstructEntries() );
|
||||
|
||||
for ( int i = 0; bod != null && i < bod.Entries.Length; ++i )
|
||||
bod.Entries[i].Owner = bod;
|
||||
|
||||
return bod;
|
||||
}
|
||||
|
||||
private LargeBulkEntry[] ReconstructEntries()
|
||||
{
|
||||
LargeBulkEntry[] entries = new LargeBulkEntry[m_Entries.Length];
|
||||
|
||||
for ( int i = 0; i < m_Entries.Length; ++i )
|
||||
{
|
||||
entries[i] = new LargeBulkEntry( null, new SmallBulkEntry( m_Entries[i].ItemType, m_Entries[i].Number, m_Entries[i].Graphic ) );
|
||||
entries[i].Amount = m_Entries[i].AmountCur;
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
public BOBLargeEntry( LargeBOD bod )
|
||||
{
|
||||
m_RequireExceptional = bod.RequireExceptional;
|
||||
|
||||
if ( bod is LargeTailorBOD )
|
||||
m_DeedType = BODType.Tailor;
|
||||
else if ( bod is LargeSmithBOD )
|
||||
m_DeedType = BODType.Smith;
|
||||
|
||||
m_Material = bod.Material;
|
||||
m_AmountMax = bod.AmountMax;
|
||||
|
||||
m_Entries = new BOBLargeSubEntry[bod.Entries.Length];
|
||||
|
||||
for ( int i = 0; i < m_Entries.Length; ++i )
|
||||
m_Entries[i] = new BOBLargeSubEntry( bod.Entries[i] );
|
||||
}
|
||||
|
||||
public BOBLargeEntry( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_RequireExceptional = reader.ReadBool();
|
||||
|
||||
m_DeedType = (BODType)reader.ReadEncodedInt();
|
||||
|
||||
m_Material = (BulkMaterialType)reader.ReadEncodedInt();
|
||||
m_AmountMax = reader.ReadEncodedInt();
|
||||
m_Price = reader.ReadEncodedInt();
|
||||
|
||||
m_Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()];
|
||||
|
||||
for ( int i = 0; i < m_Entries.Length; ++i )
|
||||
m_Entries[i] = new BOBLargeSubEntry( reader );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
|
||||
writer.Write( (bool) m_RequireExceptional );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_DeedType );
|
||||
writer.WriteEncodedInt( (int) m_Material );
|
||||
writer.WriteEncodedInt( (int) m_AmountMax );
|
||||
writer.WriteEncodedInt( (int) m_Price );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_Entries.Length );
|
||||
|
||||
for ( int i = 0; i < m_Entries.Length; ++i )
|
||||
m_Entries[i].Serialize( writer );
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Scripts/Engines/BulkOrders/Books/BOBLargeSubEntry.cs
Normal file
58
Scripts/Engines/BulkOrders/Books/BOBLargeSubEntry.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class BOBLargeSubEntry
|
||||
{
|
||||
private Type m_ItemType;
|
||||
private int m_AmountCur;
|
||||
private int m_Number;
|
||||
private int m_Graphic;
|
||||
|
||||
public Type ItemType{ get{ return m_ItemType; } }
|
||||
public int AmountCur{ get{ return m_AmountCur; } }
|
||||
public int Number{ get{ return m_Number; } }
|
||||
public int Graphic{ get{ return m_Graphic; } }
|
||||
|
||||
public BOBLargeSubEntry( LargeBulkEntry lbe )
|
||||
{
|
||||
m_ItemType = lbe.Details.Type;
|
||||
m_AmountCur = lbe.Amount;
|
||||
m_Number = lbe.Details.Number;
|
||||
m_Graphic = lbe.Details.Graphic;
|
||||
}
|
||||
|
||||
public BOBLargeSubEntry( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
string type = reader.ReadString();
|
||||
|
||||
if ( type != null )
|
||||
m_ItemType = ScriptCompiler.FindTypeByFullName( type );
|
||||
|
||||
m_AmountCur = reader.ReadEncodedInt();
|
||||
m_Number = reader.ReadEncodedInt();
|
||||
m_Graphic = reader.ReadEncodedInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
|
||||
writer.Write( m_ItemType == null ? null : m_ItemType.FullName );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_AmountCur );
|
||||
writer.WriteEncodedInt( (int) m_Number );
|
||||
writer.WriteEncodedInt( (int) m_Graphic );
|
||||
}
|
||||
}
|
||||
}
|
||||
101
Scripts/Engines/BulkOrders/Books/BOBSmallEntry.cs
Normal file
101
Scripts/Engines/BulkOrders/Books/BOBSmallEntry.cs
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class BOBSmallEntry
|
||||
{
|
||||
private Type m_ItemType;
|
||||
private bool m_RequireExceptional;
|
||||
private BODType m_DeedType;
|
||||
private BulkMaterialType m_Material;
|
||||
private int m_AmountCur, m_AmountMax;
|
||||
private int m_Number;
|
||||
private int m_Graphic;
|
||||
private int m_Price;
|
||||
|
||||
public Type ItemType{ get{ return m_ItemType; } }
|
||||
public bool RequireExceptional{ get{ return m_RequireExceptional; } }
|
||||
public BODType DeedType{ get{ return m_DeedType; } }
|
||||
public BulkMaterialType Material{ get{ return m_Material; } }
|
||||
public int AmountCur{ get{ return m_AmountCur; } }
|
||||
public int AmountMax{ get{ return m_AmountMax; } }
|
||||
public int Number{ get{ return m_Number; } }
|
||||
public int Graphic{ get{ return m_Graphic; } }
|
||||
public int Price{ get{ return m_Price; } set{ m_Price = value; } }
|
||||
|
||||
public Item Reconstruct()
|
||||
{
|
||||
SmallBOD bod = null;
|
||||
|
||||
if ( m_DeedType == BODType.Smith )
|
||||
bod = new SmallSmithBOD( m_AmountCur, m_AmountMax, m_ItemType, m_Number, m_Graphic, m_RequireExceptional, m_Material );
|
||||
else if ( m_DeedType == BODType.Tailor )
|
||||
bod = new SmallTailorBOD( m_AmountCur, m_AmountMax, m_ItemType, m_Number, m_Graphic, m_RequireExceptional, m_Material );
|
||||
|
||||
return bod;
|
||||
}
|
||||
|
||||
public BOBSmallEntry( SmallBOD bod )
|
||||
{
|
||||
m_ItemType = bod.Type;
|
||||
m_RequireExceptional = bod.RequireExceptional;
|
||||
|
||||
if ( bod is SmallTailorBOD )
|
||||
m_DeedType = BODType.Tailor;
|
||||
else if ( bod is SmallSmithBOD )
|
||||
m_DeedType = BODType.Smith;
|
||||
|
||||
m_Material = bod.Material;
|
||||
m_AmountCur = bod.AmountCur;
|
||||
m_AmountMax = bod.AmountMax;
|
||||
m_Number = bod.Number;
|
||||
m_Graphic = bod.Graphic;
|
||||
}
|
||||
|
||||
public BOBSmallEntry( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
string type = reader.ReadString();
|
||||
|
||||
if ( type != null )
|
||||
m_ItemType = ScriptCompiler.FindTypeByFullName( type );
|
||||
|
||||
m_RequireExceptional = reader.ReadBool();
|
||||
|
||||
m_DeedType = (BODType)reader.ReadEncodedInt();
|
||||
|
||||
m_Material = (BulkMaterialType)reader.ReadEncodedInt();
|
||||
m_AmountCur = reader.ReadEncodedInt();
|
||||
m_AmountMax = reader.ReadEncodedInt();
|
||||
m_Number = reader.ReadEncodedInt();
|
||||
m_Graphic = reader.ReadEncodedInt();
|
||||
m_Price = reader.ReadEncodedInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
|
||||
writer.Write( m_ItemType == null ? null : m_ItemType.FullName );
|
||||
|
||||
writer.Write( (bool) m_RequireExceptional );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_DeedType );
|
||||
writer.WriteEncodedInt( (int) m_Material );
|
||||
writer.WriteEncodedInt( (int) m_AmountCur );
|
||||
writer.WriteEncodedInt( (int) m_AmountMax );
|
||||
writer.WriteEncodedInt( (int) m_Number );
|
||||
writer.WriteEncodedInt( (int) m_Graphic );
|
||||
writer.WriteEncodedInt( (int) m_Price );
|
||||
}
|
||||
}
|
||||
}
|
||||
138
Scripts/Engines/BulkOrders/Books/BODBuyGump.cs
Normal file
138
Scripts/Engines/BulkOrders/Books/BODBuyGump.cs
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class BODBuyGump : Gump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private BulkOrderBook m_Book;
|
||||
private object m_Object;
|
||||
private int m_Price;
|
||||
private int m_Page;
|
||||
|
||||
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID == 2 )
|
||||
{
|
||||
PlayerVendor pv = m_Book.RootParent as PlayerVendor;
|
||||
|
||||
if ( m_Book.Entries.Contains( m_Object ) && pv != null )
|
||||
{
|
||||
int price = 0;
|
||||
|
||||
VendorItem vi = pv.GetVendorItem( m_Book );
|
||||
|
||||
if ( vi != null && !vi.IsForSale )
|
||||
{
|
||||
if ( m_Object is BOBLargeEntry )
|
||||
price = ((BOBLargeEntry)m_Object).Price;
|
||||
else if ( m_Object is BOBSmallEntry )
|
||||
price = ((BOBSmallEntry)m_Object).Price;
|
||||
}
|
||||
|
||||
if ( price != m_Price )
|
||||
{
|
||||
pv.SayTo( m_From, "The price has been been changed. If you like, you may offer to purchase the item again." );
|
||||
}
|
||||
else if ( price == 0 )
|
||||
{
|
||||
pv.SayTo( m_From, 1062382 ); // The deed selected is not available.
|
||||
}
|
||||
else
|
||||
{
|
||||
Item item = null;
|
||||
|
||||
if ( m_Object is BOBLargeEntry )
|
||||
item = ((BOBLargeEntry)m_Object).Reconstruct();
|
||||
else if ( m_Object is BOBSmallEntry )
|
||||
item = ((BOBSmallEntry)m_Object).Reconstruct();
|
||||
|
||||
if ( item == null )
|
||||
{
|
||||
m_From.SendMessage( "Internal error. The bulk order deed could not be reconstructed." );
|
||||
}
|
||||
else
|
||||
{
|
||||
pv.Say( m_From.Name );
|
||||
|
||||
Container pack = m_From.Backpack;
|
||||
|
||||
if ( (pack == null) || ((pack != null) && (!pack.CheckHold(m_From, item, true, true, 0, item.PileWeight + item.TotalWeight)) ) )
|
||||
{
|
||||
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, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((pack != null && pack.ConsumeTotal( typeof( Gold ), price )) || Banker.Withdraw( m_From, price ) )
|
||||
{
|
||||
m_Book.Entries.Remove( m_Object );
|
||||
m_Book.InvalidateProperties();
|
||||
pv.HoldGold += price;
|
||||
m_From.AddToBackpack( item );
|
||||
m_From.SendLocalizedMessage( 1045152 ); // The bulk order deed has been placed in your backpack.
|
||||
|
||||
if ( m_Book.Entries.Count / 5 < m_Book.ItemCount )
|
||||
{
|
||||
m_Book.ItemCount--;
|
||||
m_Book.InvalidateItems();
|
||||
}
|
||||
|
||||
if ( m_Book.Entries.Count > 0 )
|
||||
m_From.SendGump( new BOBGump( m_From, m_Book, m_Page, null ) );
|
||||
else
|
||||
m_From.SendLocalizedMessage( 1062381 ); // The book is empty.
|
||||
}
|
||||
else
|
||||
{
|
||||
pv.SayTo( m_From, 503205 ); // You cannot afford this item.
|
||||
item.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( pv == null )
|
||||
m_From.SendLocalizedMessage( 1062382 ); // The deed selected is not available.
|
||||
else
|
||||
pv.SayTo( m_From, 1062382 ); // The deed selected is not available.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendLocalizedMessage( 503207 ); // Cancelled purchase.
|
||||
}
|
||||
}
|
||||
|
||||
public BODBuyGump( PlayerMobile from, BulkOrderBook book, object obj, int page, int price ) : base( 100, 200 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Book = book;
|
||||
m_Object = obj;
|
||||
m_Price = price;
|
||||
m_Page = page;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 100, 10, 300, 150, 5054 );
|
||||
|
||||
AddHtmlLocalized( 125, 20, 250, 24, 1019070, false, false ); // You have agreed to purchase:
|
||||
AddHtmlLocalized( 125, 45, 250, 24, 1045151, false, false ); // a bulk order deed
|
||||
|
||||
AddHtmlLocalized( 125, 70, 250, 24, 1019071, false, false ); // for the amount of:
|
||||
AddLabel( 125, 95, 0, price.ToString() );
|
||||
|
||||
AddButton( 250, 130, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 282, 130, 100, 24, 1011012, false, false ); // CANCEL
|
||||
|
||||
AddButton( 120, 130, 4005, 4007, 2, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 152, 130, 100, 24, 1011036, false, false ); // OKAY
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Scripts/Engines/BulkOrders/Books/BODType.cs
Normal file
10
Scripts/Engines/BulkOrders/Books/BODType.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public enum BODType
|
||||
{
|
||||
Smith,
|
||||
Tailor
|
||||
}
|
||||
}
|
||||
344
Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs
Normal file
344
Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs
Normal file
|
|
@ -0,0 +1,344 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.Prompts;
|
||||
using Server.Mobiles;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class BulkOrderBook : Item, ISecurable
|
||||
{
|
||||
private ArrayList m_Entries;
|
||||
private BOBFilter m_Filter;
|
||||
private string m_BookName;
|
||||
private SecureLevel m_Level;
|
||||
private int m_ItemCount;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public string BookName
|
||||
{
|
||||
get{ return m_BookName; }
|
||||
set{ m_BookName = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public SecureLevel Level
|
||||
{
|
||||
get{ return m_Level; }
|
||||
set{ m_Level = value; }
|
||||
}
|
||||
|
||||
public ArrayList Entries
|
||||
{
|
||||
get{ return m_Entries; }
|
||||
}
|
||||
|
||||
public BOBFilter Filter
|
||||
{
|
||||
get{ return m_Filter; }
|
||||
}
|
||||
|
||||
public int ItemCount
|
||||
{
|
||||
get{ return m_ItemCount; }
|
||||
set{ m_ItemCount = value; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public BulkOrderBook() : base( 0x2259 )
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
|
||||
m_Entries = new ArrayList();
|
||||
m_Filter = new BOBFilter();
|
||||
|
||||
m_Level = SecureLevel.CoOwners;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( !from.InRange( GetWorldLocation(), 2 ) )
|
||||
from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
else if ( m_Entries.Count == 0 )
|
||||
from.SendLocalizedMessage( 1062381 ); // The book is empty.
|
||||
else if ( from is PlayerMobile )
|
||||
from.SendGump( new BOBGump( (PlayerMobile)from, this ) );
|
||||
}
|
||||
|
||||
public override void OnDoubleClickSecureTrade( Mobile from )
|
||||
{
|
||||
if ( !from.InRange( GetWorldLocation(), 2 ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 500446 ); // That is too far away.
|
||||
}
|
||||
else if ( m_Entries.Count == 0 )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062381 ); // The book is empty.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendGump( new BOBGump( (PlayerMobile)from, this ) );
|
||||
|
||||
SecureTradeContainer cont = GetSecureTradeCont();
|
||||
|
||||
if ( cont != null )
|
||||
{
|
||||
SecureTrade trade = cont.Trade;
|
||||
|
||||
if ( trade != null && trade.From.Mobile == from )
|
||||
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)(trade.To.Mobile), this ) );
|
||||
else if ( trade != null && 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 ( !IsChildOf( from.Backpack ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062385 ); // You must have the book in your backpack to add deeds to it.
|
||||
return false;
|
||||
}
|
||||
else if ( !from.Backpack.CheckHold( from, dropped, true, true ) )
|
||||
return false;
|
||||
else if ( m_Entries.Count < 500 )
|
||||
{
|
||||
if ( dropped is LargeBOD )
|
||||
m_Entries.Add( new BOBLargeEntry( (LargeBOD)dropped ) );
|
||||
else if ( dropped is SmallBOD ) // Sanity
|
||||
m_Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) );
|
||||
|
||||
InvalidateProperties();
|
||||
|
||||
if ( m_Entries.Count / 5 > m_ItemCount )
|
||||
{
|
||||
m_ItemCount++;
|
||||
InvalidateItems();
|
||||
}
|
||||
|
||||
from.SendSound(0x42, GetWorldLocation());
|
||||
from.SendLocalizedMessage( 1062386 ); // Deed added to book.
|
||||
|
||||
if ( from is PlayerMobile )
|
||||
from.SendGump( new BOBGump( (PlayerMobile)from, this ) );
|
||||
|
||||
dropped.Delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetTotal( TotalType type )
|
||||
{
|
||||
int total = base.GetTotal( type );
|
||||
|
||||
if ( type == TotalType.Items )
|
||||
total = m_ItemCount;
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public void InvalidateItems()
|
||||
{
|
||||
if ( RootParent is Mobile )
|
||||
{
|
||||
Mobile m = (Mobile) RootParent;
|
||||
|
||||
m.UpdateTotals();
|
||||
InvalidateContainers( Parent );
|
||||
}
|
||||
}
|
||||
|
||||
public void InvalidateContainers( object parent )
|
||||
{
|
||||
if ( parent != null && parent is Container )
|
||||
{
|
||||
Container c = (Container)parent;
|
||||
|
||||
c.InvalidateProperties();
|
||||
InvalidateContainers( c.Parent );
|
||||
}
|
||||
}
|
||||
|
||||
public BulkOrderBook( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 2 ); // version
|
||||
|
||||
writer.Write( (int) m_ItemCount );
|
||||
|
||||
writer.Write( (int) m_Level );
|
||||
|
||||
writer.Write( m_BookName );
|
||||
|
||||
m_Filter.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_Entries.Count );
|
||||
|
||||
for ( int i = 0; i < m_Entries.Count; ++i )
|
||||
{
|
||||
object obj = m_Entries[i];
|
||||
|
||||
if ( obj is BOBLargeEntry )
|
||||
{
|
||||
writer.WriteEncodedInt( 0 );
|
||||
((BOBLargeEntry)obj).Serialize( writer );
|
||||
}
|
||||
else if ( obj is BOBSmallEntry )
|
||||
{
|
||||
writer.WriteEncodedInt( 1 );
|
||||
((BOBSmallEntry)obj).Serialize( writer );
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteEncodedInt( -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
m_ItemCount = reader.ReadInt();
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
m_Level = (SecureLevel)reader.ReadInt();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_BookName = reader.ReadString();
|
||||
|
||||
m_Filter = new BOBFilter( reader );
|
||||
|
||||
int count = reader.ReadEncodedInt();
|
||||
|
||||
m_Entries = new ArrayList( count );
|
||||
|
||||
for ( int i = 0; i < count; ++i )
|
||||
{
|
||||
int v = reader.ReadEncodedInt();
|
||||
|
||||
switch ( v )
|
||||
{
|
||||
case 0: m_Entries.Add( new BOBLargeEntry( reader ) ); break;
|
||||
case 1: m_Entries.Add( new BOBSmallEntry( reader ) ); break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
list.Add( 1062344, m_Entries.Count.ToString() ); // Deeds in book: ~1_val~
|
||||
|
||||
if ( m_BookName != null && m_BookName.Length > 0 )
|
||||
list.Add( 1062481, m_BookName ); // Book Name: ~1_val~
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
LabelTo(from, 1062344, m_Entries.Count.ToString()); // Deeds in book: ~1_val~
|
||||
|
||||
if (!String.IsNullOrEmpty(m_BookName))
|
||||
LabelTo(from, 1062481, m_BookName);
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
|
||||
{
|
||||
base.GetContextMenuEntries( from, list );
|
||||
|
||||
if ( from.CheckAlive() && IsChildOf( from.Backpack ) )
|
||||
list.Add( new NameBookEntry( from, this ) );
|
||||
|
||||
SetSecureLevelEntry.AddTo( from, this, list );
|
||||
}
|
||||
|
||||
private class NameBookEntry : ContextMenuEntry
|
||||
{
|
||||
private Mobile m_From;
|
||||
private BulkOrderBook m_Book;
|
||||
|
||||
public NameBookEntry( Mobile from, BulkOrderBook book ) : base( 6216 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Book = book;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if ( m_From.CheckAlive() && m_Book.IsChildOf( m_From.Backpack ) )
|
||||
{
|
||||
m_From.Prompt = new NameBookPrompt( m_Book );
|
||||
m_From.SendLocalizedMessage( 1062479 ); // Type in the new name of the book:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class NameBookPrompt : Prompt
|
||||
{
|
||||
private BulkOrderBook m_Book;
|
||||
|
||||
public NameBookPrompt( BulkOrderBook book )
|
||||
{
|
||||
m_Book = book;
|
||||
}
|
||||
|
||||
public override void OnResponse( Mobile from, string text )
|
||||
{
|
||||
if ( text.Length > 40 )
|
||||
text = text.Substring( 0, 40 );
|
||||
|
||||
if ( from.CheckAlive() && m_Book.IsChildOf( from.Backpack ) )
|
||||
{
|
||||
m_Book.BookName = Utility.FixHtml( text.Trim() );
|
||||
|
||||
from.SendLocalizedMessage( 1062480 ); // The bulk order book's name has been changed.
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnCancel( Mobile from )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Scripts/Engines/BulkOrders/BulkMaterialType.cs
Normal file
45
Scripts/Engines/BulkOrders/BulkMaterialType.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public enum BulkMaterialType
|
||||
{
|
||||
None,
|
||||
DullCopper,
|
||||
ShadowIron,
|
||||
Copper,
|
||||
Bronze,
|
||||
Gold,
|
||||
Agapite,
|
||||
Verite,
|
||||
Valorite,
|
||||
Spined,
|
||||
Horned,
|
||||
Barbed
|
||||
}
|
||||
|
||||
public enum BulkGenericType
|
||||
{
|
||||
Iron,
|
||||
Cloth,
|
||||
Leather
|
||||
}
|
||||
|
||||
public class BGTClassifier
|
||||
{
|
||||
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;
|
||||
|
||||
return BulkGenericType.Cloth;
|
||||
}
|
||||
|
||||
return BulkGenericType.Iron;
|
||||
}
|
||||
}
|
||||
}
|
||||
268
Scripts/Engines/BulkOrders/LargeBOD.cs
Normal file
268
Scripts/Engines/BulkOrders/LargeBOD.cs
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
[TypeAlias( "Scripts.Engines.BulkOrders.LargeBOD" )]
|
||||
public abstract class LargeBOD : Item
|
||||
{
|
||||
private int m_AmountMax;
|
||||
private bool m_RequireExceptional;
|
||||
private BulkMaterialType m_Material;
|
||||
private LargeBulkEntry[] m_Entries;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int AmountMax{ get{ return m_AmountMax; } set{ m_AmountMax = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool RequireExceptional{ get{ return m_RequireExceptional; } set{ m_RequireExceptional = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public BulkMaterialType Material{ get{ return m_Material; } set{ m_Material = value; InvalidateProperties(); } }
|
||||
|
||||
public LargeBulkEntry[] Entries{ get{ return m_Entries; } set{ m_Entries = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool Complete
|
||||
{
|
||||
get
|
||||
{
|
||||
for ( int i = 0; i < m_Entries.Length; ++i )
|
||||
{
|
||||
if ( m_Entries[i].Amount < m_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{ get{ return 1045151; } } // a bulk order deed
|
||||
|
||||
public LargeBOD( int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries ) : base( Core.AOS ? 0x2258 : 0x14EF )
|
||||
{
|
||||
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 override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
list.Add( 1060655 ); // large bulk order
|
||||
|
||||
if ( m_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.
|
||||
|
||||
list.Add( 1060656, m_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~
|
||||
}
|
||||
|
||||
public override void OnDoubleClickNotAccessible( Mobile from )
|
||||
{
|
||||
OnDoubleClick( from );
|
||||
}
|
||||
|
||||
public override void OnDoubleClickSecureTrade( Mobile from )
|
||||
{
|
||||
OnDoubleClick( from );
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( IsChildOf( from.Backpack ) || InSecureTrade || RootParent is PlayerVendor )
|
||||
from.SendGump( new LargeBODGump( from, this ) );
|
||||
else
|
||||
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 void EndCombine( Mobile from, object o )
|
||||
{
|
||||
if ( o is Item && ((Item)o).IsChildOf( from.Backpack ) )
|
||||
{
|
||||
if ( o is SmallBOD )
|
||||
{
|
||||
SmallBOD small = (SmallBOD)o;
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
from.SendLocalizedMessage( 1045165 ); // The orders have been combined.
|
||||
|
||||
from.SendGump( new LargeBODGump( from, this ) );
|
||||
|
||||
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 override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_AmountMax );
|
||||
writer.Write( m_RequireExceptional );
|
||||
writer.Write( (int) m_Material );
|
||||
|
||||
writer.Write( (int) m_Entries.Length );
|
||||
|
||||
for ( int i = 0; i < m_Entries.Length; ++i )
|
||||
m_Entries[i].Serialize( writer );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
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 )
|
||||
m_Entries[i] = new LargeBulkEntry( this, reader );
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
106
Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs
Normal file
106
Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class LargeBODAcceptGump : Gump
|
||||
{
|
||||
private LargeBOD m_Deed;
|
||||
private Mobile m_From;
|
||||
|
||||
public LargeBODAcceptGump( Mobile from, LargeBOD deed ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Deed = deed;
|
||||
|
||||
m_From.CloseGump( typeof( LargeBODAcceptGump ) );
|
||||
m_From.CloseGump( typeof( SmallBODAcceptGump ) );
|
||||
|
||||
LargeBulkEntry[] entries = deed.Entries;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 25, 10, 430, 240 + (entries.Length * 24), 5054 );
|
||||
|
||||
AddImageTiled( 33, 20, 413, 221 + (entries.Length * 24), 2624 );
|
||||
AddAlphaRegion( 33, 20, 413, 221 + (entries.Length * 24) );
|
||||
|
||||
AddImage( 20, 5, 10460 );
|
||||
AddImage( 430, 5, 10460 );
|
||||
AddImage( 20, 225 + (entries.Length * 24), 10460 );
|
||||
AddImage( 430, 225 + (entries.Length * 24), 10460 );
|
||||
|
||||
AddHtmlLocalized( 180, 25, 120, 20, 1045134, 0x7FFF, false, false ); // A large bulk order
|
||||
|
||||
AddHtmlLocalized( 40, 48, 350, 20, 1045135, 0x7FFF, false, false ); // Ah! Thanks for the goods! Would you help me out?
|
||||
|
||||
AddHtmlLocalized( 40, 72, 210, 20, 1045138, 0x7FFF, false, false ); // Amount to make:
|
||||
AddLabel( 250, 72, 1152, deed.AmountMax.ToString() );
|
||||
|
||||
AddHtmlLocalized( 40, 96, 120, 20, 1045137, 0x7FFF, false, false ); // Items requested:
|
||||
|
||||
int y = 120;
|
||||
|
||||
for ( int i = 0; i < entries.Length; ++i, y += 24 )
|
||||
AddHtmlLocalized( 40, y, 210, 20, entries[i].Details.Number, 0x7FFF, false, false );
|
||||
|
||||
if ( deed.RequireExceptional || deed.Material != BulkMaterialType.None )
|
||||
{
|
||||
AddHtmlLocalized( 40, y, 210, 20, 1045140, 0x7FFF, false, false ); // Special requirements to meet:
|
||||
y += 24;
|
||||
|
||||
if ( deed.RequireExceptional )
|
||||
{
|
||||
AddHtmlLocalized( 40, y, 350, 20, 1045141, 0x7FFF, false, false ); // All items must be exceptional.
|
||||
y += 24;
|
||||
}
|
||||
|
||||
if ( deed.Material != BulkMaterialType.None )
|
||||
{
|
||||
AddHtmlLocalized( 40, y, 350, 20, GetMaterialNumberFor( deed.Material ), 0x7FFF, false, false ); // All items must be made with x material.
|
||||
y += 24;
|
||||
}
|
||||
}
|
||||
|
||||
AddHtmlLocalized( 40, 192 + (entries.Length * 24), 350, 20, 1045139, 0x7FFF, false, false ); // Do you want to accept this order?
|
||||
|
||||
AddButton( 100, 216 + (entries.Length * 24), 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 135, 216 + (entries.Length * 24), 120, 20, 1006044, 0x7FFF, false, false ); // Ok
|
||||
|
||||
AddButton( 275, 216 + (entries.Length * 24), 4005, 4007, 0, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 310, 216 + (entries.Length * 24), 120, 20, 1011012, 0x7FFF, false, false ); // CANCEL
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID == 1 ) // Ok
|
||||
{
|
||||
if ( m_From.PlaceInBackpack( m_Deed ) )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1045152 ); // The bulk order deed has been placed in your backpack.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1045150 ); // There is not enough room in your backpack for the deed.
|
||||
m_Deed.Delete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Deed.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetMaterialNumberFor( BulkMaterialType material )
|
||||
{
|
||||
if ( material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite )
|
||||
return 1045142 + (int)(material - BulkMaterialType.DullCopper);
|
||||
else if ( material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed )
|
||||
return 1049348 + (int)(material - BulkMaterialType.Spined);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
100
Scripts/Engines/BulkOrders/LargeBODGump.cs
Normal file
100
Scripts/Engines/BulkOrders/LargeBODGump.cs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class LargeBODGump : Gump
|
||||
{
|
||||
private LargeBOD m_Deed;
|
||||
private Mobile m_From;
|
||||
|
||||
public LargeBODGump( Mobile from, LargeBOD deed ) : base( 25, 25 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Deed = deed;
|
||||
|
||||
m_From.CloseGump( typeof( LargeBODGump ) );
|
||||
m_From.CloseGump( typeof( SmallBODGump ) );
|
||||
|
||||
LargeBulkEntry[] entries = deed.Entries;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 50, 10, 455, 236 + (entries.Length * 24), 5054 );
|
||||
|
||||
AddImageTiled( 58, 20, 438, 217 + (entries.Length * 24), 2624 );
|
||||
AddAlphaRegion( 58, 20, 438, 217 + (entries.Length * 24) );
|
||||
|
||||
AddImage( 45, 5, 10460 );
|
||||
AddImage( 480, 5, 10460 );
|
||||
AddImage( 45, 221 + (entries.Length * 24), 10460 );
|
||||
AddImage( 480, 221 + (entries.Length * 24), 10460 );
|
||||
|
||||
AddHtmlLocalized( 225, 25, 120, 20, 1045134, 0x7FFF, false, false ); // A large bulk order
|
||||
|
||||
AddHtmlLocalized( 75, 48, 250, 20, 1045138, 0x7FFF, false, false ); // Amount to make:
|
||||
AddLabel( 275, 48, 1152, deed.AmountMax.ToString() );
|
||||
|
||||
AddHtmlLocalized( 75, 72, 120, 20, 1045137, 0x7FFF, false, false ); // Items requested:
|
||||
AddHtmlLocalized( 275, 76, 200, 20, 1045153, 0x7FFF, false, false ); // Amount finished:
|
||||
|
||||
int y = 96;
|
||||
|
||||
for ( int i = 0; i < entries.Length; ++i )
|
||||
{
|
||||
LargeBulkEntry entry = entries[i];
|
||||
SmallBulkEntry details = entry.Details;
|
||||
|
||||
AddHtmlLocalized( 75, y, 210, 20, details.Number, 0x7FFF, false, false );
|
||||
AddLabel( 275, y, 0x480, entry.Amount.ToString() );
|
||||
|
||||
y += 24;
|
||||
}
|
||||
|
||||
if ( deed.RequireExceptional || deed.Material != BulkMaterialType.None )
|
||||
{
|
||||
AddHtmlLocalized( 75, y, 200, 20, 1045140, 0x7FFF, false, false ); // Special requirements to meet:
|
||||
y += 24;
|
||||
}
|
||||
|
||||
if ( deed.RequireExceptional )
|
||||
{
|
||||
AddHtmlLocalized( 75, y, 300, 20, 1045141, 0x7FFF, false, false ); // All items must be exceptional.
|
||||
y += 24;
|
||||
}
|
||||
|
||||
if ( deed.Material != BulkMaterialType.None )
|
||||
AddHtmlLocalized( 75, y, 300, 20, GetMaterialNumberFor( deed.Material ), 0x7FFF, false, false ); // All items must be made with x material.
|
||||
|
||||
AddButton( 125, 168 + (entries.Length * 24), 4005, 4007, 2, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 160, 168 + (entries.Length * 24), 300, 20, 1045155, 0x7FFF, false, false ); // Combine this deed with another deed.
|
||||
|
||||
AddButton( 125, 192 + (entries.Length * 24), 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 160, 192 + (entries.Length * 24), 120, 20, 1011441, 0x7FFF, false, false ); // EXIT
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( m_Deed.Deleted || !m_Deed.IsChildOf( m_From.Backpack ) )
|
||||
return;
|
||||
|
||||
if ( info.ButtonID == 2 ) // Combine
|
||||
{
|
||||
m_From.SendGump( new LargeBODGump( m_From, m_Deed ) );
|
||||
m_Deed.BeginCombine( m_From );
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetMaterialNumberFor( BulkMaterialType material )
|
||||
{
|
||||
if ( material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite )
|
||||
return 1045142 + (int)(material - BulkMaterialType.DullCopper);
|
||||
else if ( material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed )
|
||||
return 1049348 + (int)(material - BulkMaterialType.Spined);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Scripts/Engines/BulkOrders/LargeBODTarget.cs
Normal file
25
Scripts/Engines/BulkOrders/LargeBODTarget.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
189
Scripts/Engines/BulkOrders/LargeBulkEntry.cs
Normal file
189
Scripts/Engines/BulkOrders/LargeBulkEntry.cs
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class LargeBulkEntry
|
||||
{
|
||||
private LargeBOD m_Owner;
|
||||
private int m_Amount;
|
||||
private SmallBulkEntry m_Details;
|
||||
|
||||
public LargeBOD Owner{ get{ return m_Owner; } set{ m_Owner = value; } }
|
||||
public int Amount{ get{ return m_Amount; } set{ m_Amount = value; if ( m_Owner != null ) m_Owner.InvalidateProperties(); } }
|
||||
public SmallBulkEntry Details{ get{ return m_Details; } }
|
||||
|
||||
public static SmallBulkEntry[] LargeRing
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "largering" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] LargePlate
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "largeplate" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] LargeChain
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "largechain" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] LargeAxes
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "largeaxes" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] LargeFencing
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "largefencing" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] LargeMaces
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "largemaces" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] LargePolearms
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "largepolearms" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] LargeSwords
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "largeswords" ); }
|
||||
}
|
||||
|
||||
|
||||
public static SmallBulkEntry[] BoneSet
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "boneset" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] Farmer
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "farmer" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] FemaleLeatherSet
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "femaleleatherset" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] FisherGirl
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "fishergirl" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] Gypsy
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "gypsy" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] HatSet
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "hatset" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] Jester
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "jester" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] Lady
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "lady" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] MaleLeatherSet
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "maleleatherset" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] Pirate
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "pirate" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] ShoeSet
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "shoeset" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] StuddedSet
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "studdedset" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] TownCrier
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "towncrier" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] Wizard
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "wizard" ); }
|
||||
}
|
||||
|
||||
|
||||
private static Dictionary<string,Dictionary<string,SmallBulkEntry[]>> m_Cache;
|
||||
|
||||
public static SmallBulkEntry[] GetEntries( string type, string name )
|
||||
{
|
||||
if (m_Cache == null)
|
||||
m_Cache = new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>();
|
||||
|
||||
Dictionary<string, SmallBulkEntry[]> table = null;
|
||||
|
||||
if (!m_Cache.TryGetValue(type, out table))
|
||||
m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>();
|
||||
|
||||
SmallBulkEntry[] entries = null;
|
||||
|
||||
if (!table.TryGetValue(name, out entries))
|
||||
table[name] = entries = SmallBulkEntry.LoadEntries(type, name);
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
public static LargeBulkEntry[] ConvertEntries( LargeBOD owner, SmallBulkEntry[] small )
|
||||
{
|
||||
LargeBulkEntry[] large = new LargeBulkEntry[small.Length];
|
||||
|
||||
for ( int i = 0; i < small.Length; ++i )
|
||||
large[i] = new LargeBulkEntry( owner, small[i] );
|
||||
|
||||
return large;
|
||||
}
|
||||
|
||||
public LargeBulkEntry( LargeBOD owner, SmallBulkEntry details )
|
||||
{
|
||||
m_Owner = owner;
|
||||
m_Details = details;
|
||||
}
|
||||
|
||||
public LargeBulkEntry( LargeBOD owner, GenericReader reader )
|
||||
{
|
||||
m_Owner = owner;
|
||||
m_Amount = reader.ReadInt();
|
||||
|
||||
Type realType = null;
|
||||
|
||||
string type = reader.ReadString();
|
||||
|
||||
if ( type != null )
|
||||
realType = ScriptCompiler.FindTypeByFullName( type );
|
||||
|
||||
m_Details = new SmallBulkEntry( realType, reader.ReadInt(), reader.ReadInt() );
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.Write( m_Amount );
|
||||
writer.Write( m_Details.Type == null ? null : m_Details.Type.FullName );
|
||||
writer.Write( m_Details.Number );
|
||||
writer.Write( m_Details.Graphic );
|
||||
}
|
||||
}
|
||||
}
|
||||
140
Scripts/Engines/BulkOrders/LargeSmithBOD.cs
Normal file
140
Scripts/Engines/BulkOrders/LargeSmithBOD.cs
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Mat = Server.Engines.BulkOrders.BulkMaterialType;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
[TypeAlias( "Scripts.Engines.BulkOrders.LargeSmithBOD" )]
|
||||
public class LargeSmithBOD : LargeBOD
|
||||
{
|
||||
public static double[] m_BlacksmithMaterialChances = new double[]
|
||||
{
|
||||
0.501953125, // None
|
||||
0.250000000, // Dull Copper
|
||||
0.125000000, // Shadow Iron
|
||||
0.062500000, // Copper
|
||||
0.031250000, // Bronze
|
||||
0.015625000, // Gold
|
||||
0.007812500, // Agapite
|
||||
0.003906250, // Verite
|
||||
0.001953125 // Valorite
|
||||
};
|
||||
|
||||
public override int ComputeFame()
|
||||
{
|
||||
return SmithRewardCalculator.Instance.ComputeFame( this );
|
||||
}
|
||||
|
||||
public override int ComputeGold()
|
||||
{
|
||||
return SmithRewardCalculator.Instance.ComputeGold( this );
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public LargeSmithBOD()
|
||||
{
|
||||
LargeBulkEntry[] entries;
|
||||
bool useMaterials = true;
|
||||
|
||||
int rand = Utility.Random( 8 );
|
||||
|
||||
switch ( rand )
|
||||
{
|
||||
default:
|
||||
case 0: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargeRing ); break;
|
||||
case 1: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargePlate ); break;
|
||||
case 2: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargeChain ); break;
|
||||
case 3: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargeAxes ); break;
|
||||
case 4: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargeFencing ); break;
|
||||
case 5: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargeMaces ); break;
|
||||
case 6: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargePolearms ); break;
|
||||
case 7: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargeSwords ); break;
|
||||
}
|
||||
|
||||
if( rand > 2 && rand < 8 )
|
||||
useMaterials = false;
|
||||
|
||||
int hue = 0x44E;
|
||||
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;
|
||||
|
||||
this.Hue = hue;
|
||||
this.AmountMax = amountMax;
|
||||
this.Entries = entries;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = material;
|
||||
}
|
||||
|
||||
public LargeSmithBOD( int amountMax, bool reqExceptional, BulkMaterialType mat, LargeBulkEntry[] entries )
|
||||
{
|
||||
this.Hue = 0x44E;
|
||||
this.AmountMax = amountMax;
|
||||
this.Entries = entries;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = mat;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if ( rewardItem != null )
|
||||
{
|
||||
Item item = rewardItem.Construct();
|
||||
|
||||
if ( item != null )
|
||||
list.Add( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public LargeSmithBOD( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
135
Scripts/Engines/BulkOrders/LargeTailorBOD.cs
Normal file
135
Scripts/Engines/BulkOrders/LargeTailorBOD.cs
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Mat = Server.Engines.BulkOrders.BulkMaterialType;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class LargeTailorBOD : LargeBOD
|
||||
{
|
||||
public static double[] m_TailoringMaterialChances = new double[]
|
||||
{
|
||||
0.857421875, // None
|
||||
0.125000000, // Spined
|
||||
0.015625000, // Horned
|
||||
0.001953125 // Barbed
|
||||
};
|
||||
|
||||
public override int ComputeFame()
|
||||
{
|
||||
return TailorRewardCalculator.Instance.ComputeFame( this );
|
||||
}
|
||||
|
||||
public override int ComputeGold()
|
||||
{
|
||||
return TailorRewardCalculator.Instance.ComputeGold( this );
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public LargeTailorBOD()
|
||||
{
|
||||
LargeBulkEntry[] entries;
|
||||
bool useMaterials = false;
|
||||
|
||||
switch ( Utility.Random( 14 ) )
|
||||
{
|
||||
default:
|
||||
case 0: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.Farmer ); break;
|
||||
case 1: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.FemaleLeatherSet ); useMaterials = true; break;
|
||||
case 2: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.FisherGirl ); break;
|
||||
case 3: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.Gypsy ); break;
|
||||
case 4: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.HatSet ); break;
|
||||
case 5: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.Jester ); break;
|
||||
case 6: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.Lady ); break;
|
||||
case 7: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.MaleLeatherSet ); useMaterials = true; break;
|
||||
case 8: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.Pirate ); break;
|
||||
case 9: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.ShoeSet ); useMaterials = Core.ML; break;
|
||||
case 10: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.StuddedSet ); useMaterials = true; break;
|
||||
case 11: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.TownCrier ); break;
|
||||
case 12: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.Wizard ); break;
|
||||
case 13: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.BoneSet ); useMaterials = true; break;
|
||||
}
|
||||
|
||||
int hue = 0x483;
|
||||
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;
|
||||
|
||||
this.Hue = hue;
|
||||
this.AmountMax = amountMax;
|
||||
this.Entries = entries;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = material;
|
||||
}
|
||||
|
||||
public LargeTailorBOD( int amountMax, bool reqExceptional, BulkMaterialType mat, LargeBulkEntry[] entries )
|
||||
{
|
||||
this.Hue = 0x483;
|
||||
this.AmountMax = amountMax;
|
||||
this.Entries = entries;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = mat;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if ( rewardItem != null )
|
||||
{
|
||||
Item item = rewardItem.Construct();
|
||||
|
||||
if ( item != null )
|
||||
list.Add( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public LargeTailorBOD( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
739
Scripts/Engines/BulkOrders/Rewards.cs
Normal file
739
Scripts/Engines/BulkOrders/Rewards.cs
Normal file
|
|
@ -0,0 +1,739 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public delegate Item ConstructCallback( int type );
|
||||
|
||||
public sealed class RewardType
|
||||
{
|
||||
private int m_Points;
|
||||
private Type[] m_Types;
|
||||
|
||||
public int Points{ get{ return m_Points; } }
|
||||
public Type[] Types{ get{ return m_Types; } }
|
||||
|
||||
public RewardType( int points, params Type[] types )
|
||||
{
|
||||
m_Points = points;
|
||||
m_Types = types;
|
||||
}
|
||||
|
||||
public bool Contains( Type type )
|
||||
{
|
||||
for ( int i = 0; i < m_Types.Length; ++i )
|
||||
{
|
||||
if ( m_Types[i] == type )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RewardItem
|
||||
{
|
||||
private int m_Weight;
|
||||
private ConstructCallback m_Constructor;
|
||||
private int m_Type;
|
||||
|
||||
public int Weight{ get{ return m_Weight; } }
|
||||
public ConstructCallback Constructor{ get{ return m_Constructor; } }
|
||||
public int Type{ get{ return m_Type; } }
|
||||
|
||||
public RewardItem( int weight, ConstructCallback constructor ) : this( weight, constructor, 0 )
|
||||
{
|
||||
}
|
||||
|
||||
public RewardItem( int weight, ConstructCallback constructor, int type )
|
||||
{
|
||||
m_Weight = weight;
|
||||
m_Constructor = constructor;
|
||||
m_Type = type;
|
||||
}
|
||||
|
||||
public Item Construct()
|
||||
{
|
||||
try{ return m_Constructor( m_Type ); }
|
||||
catch{ return null; }
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RewardGroup
|
||||
{
|
||||
private int m_Points;
|
||||
private RewardItem[] m_Items;
|
||||
|
||||
public int Points{ get{ return m_Points; } }
|
||||
public RewardItem[] Items{ get{ return m_Items; } }
|
||||
|
||||
public RewardGroup( int points, params RewardItem[] items )
|
||||
{
|
||||
m_Points = points;
|
||||
m_Items = items;
|
||||
}
|
||||
|
||||
public RewardItem AcquireItem()
|
||||
{
|
||||
if ( m_Items.Length == 0 )
|
||||
return null;
|
||||
else if ( m_Items.Length == 1 )
|
||||
return m_Items[0];
|
||||
|
||||
int totalWeight = 0;
|
||||
|
||||
for ( int i = 0; i < m_Items.Length; ++i )
|
||||
totalWeight += m_Items[i].Weight;
|
||||
|
||||
int randomWeight = Utility.Random( totalWeight );
|
||||
|
||||
for ( int i = 0; i < m_Items.Length; ++i )
|
||||
{
|
||||
RewardItem item = m_Items[i];
|
||||
|
||||
if ( randomWeight < item.Weight )
|
||||
return item;
|
||||
|
||||
randomWeight -= item.Weight;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class RewardCalculator
|
||||
{
|
||||
private RewardGroup[] m_Groups;
|
||||
|
||||
public RewardGroup[] Groups{ get{ return m_Groups; } set{ m_Groups = value; } }
|
||||
|
||||
public abstract int ComputePoints( int quantity, bool exceptional, BulkMaterialType material, int itemCount, Type type );
|
||||
public abstract int ComputeGold( int quantity, bool exceptional, BulkMaterialType material, int itemCount, Type type );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public virtual int ComputePoints( SmallBOD bod )
|
||||
{
|
||||
return ComputePoints( bod.AmountMax, bod.RequireExceptional, bod.Material, 1, bod.Type );
|
||||
}
|
||||
|
||||
public virtual int ComputePoints( LargeBOD bod )
|
||||
{
|
||||
return ComputePoints( bod.AmountMax, bod.RequireExceptional, bod.Material, bod.Entries.Length, bod.Entries[0].Details.Type );
|
||||
}
|
||||
|
||||
public virtual int ComputeGold( SmallBOD bod )
|
||||
{
|
||||
return ComputeGold( bod.AmountMax, bod.RequireExceptional, bod.Material, 1, bod.Type );
|
||||
}
|
||||
|
||||
public virtual int ComputeGold( LargeBOD bod )
|
||||
{
|
||||
return ComputeGold( bod.AmountMax, bod.RequireExceptional, bod.Material, bod.Entries.Length, bod.Entries[0].Details.Type );
|
||||
}
|
||||
|
||||
public virtual RewardGroup LookupRewards( int points )
|
||||
{
|
||||
for ( int i = m_Groups.Length - 1; i >= 1; --i )
|
||||
{
|
||||
RewardGroup group = m_Groups[i];
|
||||
|
||||
if ( points >= group.Points )
|
||||
return group;
|
||||
}
|
||||
|
||||
return m_Groups[0];
|
||||
}
|
||||
|
||||
public virtual int LookupTypePoints( RewardType[] types, Type type )
|
||||
{
|
||||
for ( int i = 0; i < types.Length; ++i )
|
||||
{
|
||||
if ( types[i].Contains( type ) )
|
||||
return types[i].Points;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public RewardCalculator()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class SmithRewardCalculator : RewardCalculator
|
||||
{
|
||||
#region Constructors
|
||||
private static readonly ConstructCallback SturdyShovel = new ConstructCallback( CreateSturdyShovel );
|
||||
private static readonly ConstructCallback SturdyPickaxe = new ConstructCallback( CreateSturdyPickaxe );
|
||||
private static readonly ConstructCallback MiningGloves = new ConstructCallback( CreateMiningGloves );
|
||||
private static readonly ConstructCallback GargoylesPickaxe = new ConstructCallback( CreateGargoylesPickaxe );
|
||||
private static readonly ConstructCallback ProspectorsTool = new ConstructCallback( CreateProspectorsTool );
|
||||
private static readonly ConstructCallback PowderOfTemperament = new ConstructCallback( CreatePowderOfTemperament );
|
||||
private static readonly ConstructCallback RunicHammer = new ConstructCallback( CreateRunicHammer );
|
||||
private static readonly ConstructCallback PowerScroll = new ConstructCallback( CreatePowerScroll );
|
||||
private static readonly ConstructCallback ColoredAnvil = new ConstructCallback( CreateColoredAnvil );
|
||||
private static readonly ConstructCallback AncientHammer = new ConstructCallback( CreateAncientHammer );
|
||||
|
||||
private static Item CreateSturdyShovel( int type )
|
||||
{
|
||||
return new SturdyShovel();
|
||||
}
|
||||
|
||||
private static Item CreateSturdyPickaxe( int type )
|
||||
{
|
||||
return new SturdyPickaxe();
|
||||
}
|
||||
|
||||
private static Item CreateMiningGloves( int type )
|
||||
{
|
||||
if ( type == 1 )
|
||||
return new LeatherGlovesOfMining( 1 );
|
||||
else if ( type == 3 )
|
||||
return new StuddedGlovesOfMining( 3 );
|
||||
else if ( type == 5 )
|
||||
return new RingmailGlovesOfMining( 5 );
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
private static Item CreateGargoylesPickaxe( int type )
|
||||
{
|
||||
return new GargoylesPickaxe();
|
||||
}
|
||||
|
||||
private static Item CreateProspectorsTool( int type )
|
||||
{
|
||||
return new ProspectorsTool();
|
||||
}
|
||||
|
||||
private static Item CreatePowderOfTemperament( int type )
|
||||
{
|
||||
return new PowderOfTemperament();
|
||||
}
|
||||
|
||||
private static Item CreateRunicHammer( int type )
|
||||
{
|
||||
if ( type >= 1 && type <= 8 )
|
||||
return new RunicHammer( CraftResource.Iron + type, Core.AOS ? ( 55 - (type*5) ) : 50 );
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
private static Item CreatePowerScroll( int type )
|
||||
{
|
||||
if ( type == 5 || type == 10 || type == 15 || type == 20 )
|
||||
return new PowerScroll( SkillName.Blacksmith, 100 + type );
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
private static Item CreateColoredAnvil( int type )
|
||||
{
|
||||
// Generate an anvil deed, not an actual anvil.
|
||||
//return new ColoredAnvilDeed();
|
||||
|
||||
return new ColoredAnvil();
|
||||
}
|
||||
|
||||
private static Item CreateAncientHammer( int type )
|
||||
{
|
||||
if ( type == 10 || type == 15 || type == 30 || type == 60 )
|
||||
return new AncientSmithyHammer( type );
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static readonly SmithRewardCalculator Instance = new SmithRewardCalculator();
|
||||
|
||||
private RewardType[] m_Types = new RewardType[]
|
||||
{
|
||||
// Armors
|
||||
new RewardType( 200, typeof( RingmailGloves ), typeof( RingmailChest ), typeof( RingmailArms ), typeof( RingmailLegs ) ),
|
||||
new RewardType( 300, typeof( ChainCoif ), typeof( ChainLegs ), typeof( ChainChest ) ),
|
||||
new RewardType( 400, typeof( PlateArms ), typeof( PlateLegs ), typeof( PlateHelm ), typeof( PlateGorget ), typeof( PlateGloves ), typeof( PlateChest ) ),
|
||||
|
||||
// Weapons
|
||||
new RewardType( 200, typeof( Bardiche ), typeof( Halberd ) ),
|
||||
new RewardType( 300, typeof( Dagger ), typeof( ShortSpear ), typeof( Spear ), typeof( WarFork ), typeof( Kryss ) ), //OSI put the dagger in there. Odd, ain't it.
|
||||
new RewardType( 350, typeof( Axe ), typeof( BattleAxe ), typeof( DoubleAxe ), typeof( ExecutionersAxe ), typeof( LargeBattleAxe ), typeof( TwoHandedAxe ) ),
|
||||
new RewardType( 350, typeof( Broadsword ), typeof( Cutlass ), typeof( Katana ), typeof( Longsword ), typeof( Scimitar ), /*typeof( ThinLongsword ),*/ typeof( VikingSword ) ),
|
||||
new RewardType( 350, typeof( WarAxe ), typeof( HammerPick ), typeof( Mace ), typeof( Maul ), typeof( WarHammer ), typeof( WarMace ) )
|
||||
};
|
||||
|
||||
public override int ComputePoints( int quantity, bool exceptional, BulkMaterialType material, int itemCount, Type type )
|
||||
{
|
||||
int points = 0;
|
||||
|
||||
if ( quantity == 10 )
|
||||
points += 10;
|
||||
else if ( quantity == 15 )
|
||||
points += 25;
|
||||
else if ( quantity == 20 )
|
||||
points += 50;
|
||||
|
||||
if ( exceptional )
|
||||
points += 200;
|
||||
|
||||
if ( itemCount > 1 )
|
||||
points += LookupTypePoints( m_Types, type );
|
||||
|
||||
if ( material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite )
|
||||
points += 200 + (50 * (material - BulkMaterialType.DullCopper));
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
private static int[][][] m_GoldTable = new int[][][]
|
||||
{
|
||||
new int[][] // 1-part (regular)
|
||||
{
|
||||
new int[]{ 150, 250, 250, 400, 400, 750, 750, 1200, 1200 },
|
||||
new int[]{ 225, 375, 375, 600, 600, 1125, 1125, 1800, 1800 },
|
||||
new int[]{ 300, 500, 750, 800, 1050, 1500, 2250, 2400, 4000 }
|
||||
},
|
||||
new int[][] // 1-part (exceptional)
|
||||
{
|
||||
new int[]{ 250, 400, 400, 750, 750, 1500, 1500, 3000, 3000 },
|
||||
new int[]{ 375, 600, 600, 1125, 1125, 2250, 2250, 4500, 4500 },
|
||||
new int[]{ 500, 800, 1200, 1500, 2500, 3000, 6000, 6000, 12000 }
|
||||
},
|
||||
new int[][] // Ringmail (regular)
|
||||
{
|
||||
new int[]{ 3000, 5000, 5000, 7500, 7500, 10000, 10000, 15000, 15000 },
|
||||
new int[]{ 4500, 7500, 7500, 11250, 11500, 15000, 15000, 22500, 22500 },
|
||||
new int[]{ 6000, 10000, 15000, 15000, 20000, 20000, 30000, 30000, 50000 }
|
||||
},
|
||||
new int[][] // Ringmail (exceptional)
|
||||
{
|
||||
new int[]{ 5000, 10000, 10000, 15000, 15000, 25000, 25000, 50000, 50000 },
|
||||
new int[]{ 7500, 15000, 15000, 22500, 22500, 37500, 37500, 75000, 75000 },
|
||||
new int[]{ 10000, 20000, 30000, 30000, 50000, 50000, 100000, 100000, 200000 }
|
||||
},
|
||||
new int[][] // Chainmail (regular)
|
||||
{
|
||||
new int[]{ 4000, 7500, 7500, 10000, 10000, 15000, 15000, 25000, 25000 },
|
||||
new int[]{ 6000, 11250, 11250, 15000, 15000, 22500, 22500, 37500, 37500 },
|
||||
new int[]{ 8000, 15000, 20000, 20000, 30000, 30000, 50000, 50000, 100000 }
|
||||
},
|
||||
new int[][] // Chainmail (exceptional)
|
||||
{
|
||||
new int[]{ 7500, 15000, 15000, 25000, 25000, 50000, 50000, 100000, 100000 },
|
||||
new int[]{ 11250, 22500, 22500, 37500, 37500, 75000, 75000, 150000, 150000 },
|
||||
new int[]{ 15000, 30000, 50000, 50000, 100000, 100000, 200000, 200000, 200000 }
|
||||
},
|
||||
new int[][] // Platemail (regular)
|
||||
{
|
||||
new int[]{ 5000, 10000, 10000, 15000, 15000, 25000, 25000, 50000, 50000 },
|
||||
new int[]{ 7500, 15000, 15000, 22500, 22500, 37500, 37500, 75000, 75000 },
|
||||
new int[]{ 10000, 20000, 30000, 30000, 50000, 50000, 100000, 100000, 200000 }
|
||||
},
|
||||
new int[][] // Platemail (exceptional)
|
||||
{
|
||||
new int[]{ 10000, 25000, 25000, 50000, 50000, 100000, 100000, 100000, 100000 },
|
||||
new int[]{ 15000, 37500, 37500, 75000, 75000, 150000, 150000, 150000, 150000 },
|
||||
new int[]{ 20000, 50000, 100000, 100000, 200000, 200000, 200000, 200000, 200000 }
|
||||
},
|
||||
new int[][] // 2-part weapons (regular)
|
||||
{
|
||||
new int[]{ 3000, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 4500, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 6000, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
new int[][] // 2-part weapons (exceptional)
|
||||
{
|
||||
new int[]{ 5000, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 7500, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 10000, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
new int[][] // 5-part weapons (regular)
|
||||
{
|
||||
new int[]{ 4000, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 6000, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 8000, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
new int[][] // 5-part weapons (exceptional)
|
||||
{
|
||||
new int[]{ 7500, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 11250, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 15000, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
new int[][] // 6-part weapons (regular)
|
||||
{
|
||||
new int[]{ 4000, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 6000, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 10000, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
new int[][] // 6-part weapons (exceptional)
|
||||
{
|
||||
new int[]{ 7500, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 11250, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
new int[]{ 15000, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
}
|
||||
};
|
||||
|
||||
private int ComputeType( Type type, int itemCount )
|
||||
{
|
||||
// Item count of 1 means it's a small BOD.
|
||||
if ( itemCount == 1 )
|
||||
return 0;
|
||||
|
||||
int typeIdx;
|
||||
|
||||
// Loop through the RewardTypes defined earlier and find the correct one.
|
||||
for ( typeIdx = 0; typeIdx < 7; ++typeIdx )
|
||||
{
|
||||
if ( m_Types[typeIdx].Contains( type ) )
|
||||
break;
|
||||
}
|
||||
|
||||
// Types 5, 6 and 7 are Large Weapon BODs with the same rewards.
|
||||
if ( typeIdx > 5 )
|
||||
typeIdx = 5;
|
||||
|
||||
return ( typeIdx + 1 ) * 2;
|
||||
}
|
||||
|
||||
public override int ComputeGold( int quantity, bool exceptional, BulkMaterialType material, int itemCount, Type type )
|
||||
{
|
||||
int[][][] goldTable = m_GoldTable;
|
||||
|
||||
int typeIndex = ComputeType( type, itemCount );
|
||||
int quanIndex = ( quantity == 20 ? 2 : quantity == 15 ? 1 : 0 );
|
||||
int mtrlIndex = ( material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite ) ? 1 + (int)(material - BulkMaterialType.DullCopper) : 0;
|
||||
|
||||
if ( exceptional )
|
||||
typeIndex++;
|
||||
|
||||
int gold = goldTable[typeIndex][quanIndex][mtrlIndex];
|
||||
|
||||
int min = (gold * 9) / 10;
|
||||
int max = (gold * 10) / 9;
|
||||
|
||||
return Utility.RandomMinMax( min, max );
|
||||
}
|
||||
|
||||
public SmithRewardCalculator()
|
||||
{
|
||||
Groups = new RewardGroup[]
|
||||
{
|
||||
new RewardGroup( 0, new RewardItem( 1, SturdyShovel ) ),
|
||||
new RewardGroup( 25, new RewardItem( 1, SturdyPickaxe ) ),
|
||||
new RewardGroup( 50, new RewardItem( 45, SturdyShovel ), new RewardItem( 45, SturdyPickaxe ), new RewardItem( 10, MiningGloves, 1 ) ),
|
||||
new RewardGroup( 200, new RewardItem( 45, GargoylesPickaxe ), new RewardItem( 45, ProspectorsTool ), new RewardItem( 10, MiningGloves, 3 ) ),
|
||||
new RewardGroup( 400, new RewardItem( 2, GargoylesPickaxe ), new RewardItem( 2, ProspectorsTool ), new RewardItem( 1, PowderOfTemperament ) ),
|
||||
new RewardGroup( 450, new RewardItem( 9, PowderOfTemperament ), new RewardItem( 1, MiningGloves, 5 ) ),
|
||||
new RewardGroup( 500, new RewardItem( 1, RunicHammer, 1 ) ),
|
||||
new RewardGroup( 550, new RewardItem( 3, RunicHammer, 1 ), new RewardItem( 2, RunicHammer, 2 ) ),
|
||||
new RewardGroup( 600, new RewardItem( 1, RunicHammer, 2 ) ),
|
||||
new RewardGroup( 625, new RewardItem( 3, RunicHammer, 2 ), new RewardItem( 6, PowerScroll, 5 ), new RewardItem( 1, ColoredAnvil ) ),
|
||||
new RewardGroup( 650, new RewardItem( 1, RunicHammer, 3 ) ),
|
||||
new RewardGroup( 675, new RewardItem( 1, ColoredAnvil ), new RewardItem( 6, PowerScroll, 10 ), new RewardItem( 3, RunicHammer, 3 ) ),
|
||||
new RewardGroup( 700, new RewardItem( 1, RunicHammer, 4 ) ),
|
||||
new RewardGroup( 750, new RewardItem( 1, AncientHammer, 10 ) ),
|
||||
new RewardGroup( 800, new RewardItem( 1, PowerScroll, 15 ) ),
|
||||
new RewardGroup( 850, new RewardItem( 1, AncientHammer, 15 ) ),
|
||||
new RewardGroup( 900, new RewardItem( 1, PowerScroll, 20 ) ),
|
||||
new RewardGroup( 950, new RewardItem( 1, RunicHammer, 5 ) ),
|
||||
new RewardGroup( 1000, new RewardItem( 1, AncientHammer, 30 ) ),
|
||||
new RewardGroup( 1050, new RewardItem( 1, RunicHammer, 6 ) ),
|
||||
new RewardGroup( 1100, new RewardItem( 1, AncientHammer, 60 ) ),
|
||||
new RewardGroup( 1150, new RewardItem( 1, RunicHammer, 7 ) ),
|
||||
new RewardGroup( 1200, new RewardItem( 1, RunicHammer, 8 ) )
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TailorRewardCalculator : RewardCalculator
|
||||
{
|
||||
#region Constructors
|
||||
private static readonly ConstructCallback Cloth = new ConstructCallback( CreateCloth );
|
||||
private static readonly ConstructCallback Sandals = new ConstructCallback( CreateSandals );
|
||||
private static readonly ConstructCallback StretchedHide = new ConstructCallback( CreateStretchedHide );
|
||||
private static readonly ConstructCallback RunicKit = new ConstructCallback( CreateRunicKit );
|
||||
private static readonly ConstructCallback Tapestry = new ConstructCallback( CreateTapestry );
|
||||
private static readonly ConstructCallback PowerScroll = new ConstructCallback( CreatePowerScroll );
|
||||
private static readonly ConstructCallback BearRug = new ConstructCallback( CreateBearRug );
|
||||
private static readonly ConstructCallback ClothingBlessDeed = new ConstructCallback( CreateCBD );
|
||||
|
||||
private static int[][] m_ClothHues = new int[][]
|
||||
{
|
||||
new int[]{ 0x483, 0x48C, 0x488, 0x48A },
|
||||
new int[]{ 0x495, 0x48B, 0x486, 0x485 },
|
||||
new int[]{ 0x48D, 0x490, 0x48E, 0x491 },
|
||||
new int[]{ 0x48F, 0x494, 0x484, 0x497 },
|
||||
new int[]{ 0x489, 0x47F, 0x482, 0x47E }
|
||||
};
|
||||
|
||||
private static Item CreateCloth( int type )
|
||||
{
|
||||
if ( type >= 0 && type < m_ClothHues.Length )
|
||||
{
|
||||
UncutCloth cloth = new UncutCloth( 100 );
|
||||
cloth.Hue = m_ClothHues[type][Utility.Random( m_ClothHues[type].Length )];
|
||||
return cloth;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
private static int[] m_SandalHues = new int[]
|
||||
{
|
||||
0x489, 0x47F, 0x482,
|
||||
0x47E, 0x48F, 0x494,
|
||||
0x484, 0x497
|
||||
};
|
||||
|
||||
private static Item CreateSandals( int type )
|
||||
{
|
||||
return new Sandals( m_SandalHues[Utility.Random( m_SandalHues.Length )] );
|
||||
}
|
||||
|
||||
private static Item CreateStretchedHide( int type )
|
||||
{
|
||||
switch ( Utility.Random( 4 ) )
|
||||
{
|
||||
default:
|
||||
case 0: return new SmallStretchedHideEastDeed();
|
||||
case 1: return new SmallStretchedHideSouthDeed();
|
||||
case 2: return new MediumStretchedHideEastDeed();
|
||||
case 3: return new MediumStretchedHideSouthDeed();
|
||||
}
|
||||
}
|
||||
|
||||
private static Item CreateTapestry( int type )
|
||||
{
|
||||
switch ( Utility.Random( 4 ) )
|
||||
{
|
||||
default:
|
||||
case 0: return new LightFlowerTapestryEastDeed();
|
||||
case 1: return new LightFlowerTapestrySouthDeed();
|
||||
case 2: return new DarkFlowerTapestryEastDeed();
|
||||
case 3: return new DarkFlowerTapestrySouthDeed();
|
||||
}
|
||||
}
|
||||
|
||||
private static Item CreateBearRug( int type )
|
||||
{
|
||||
switch ( Utility.Random( 4 ) )
|
||||
{
|
||||
default:
|
||||
case 0: return new BrownBearRugEastDeed();
|
||||
case 1: return new BrownBearRugSouthDeed();
|
||||
case 2: return new PolarBearRugEastDeed();
|
||||
case 3: return new PolarBearRugSouthDeed();
|
||||
}
|
||||
}
|
||||
|
||||
private static Item CreateRunicKit( int type )
|
||||
{
|
||||
if ( type >= 1 && type <= 3 )
|
||||
return new RunicSewingKit( CraftResource.RegularLeather + type, 60 - (type*15) );
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
private static Item CreatePowerScroll( int type )
|
||||
{
|
||||
if ( type == 5 || type == 10 || type == 15 || type == 20 )
|
||||
return new PowerScroll( SkillName.Tailoring, 100 + type );
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
private static Item CreateCBD( int type )
|
||||
{
|
||||
return new ClothingBlessDeed();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static readonly TailorRewardCalculator Instance = new TailorRewardCalculator();
|
||||
|
||||
public override int ComputePoints( int quantity, bool exceptional, BulkMaterialType material, int itemCount, Type type )
|
||||
{
|
||||
int points = 0;
|
||||
|
||||
if ( quantity == 10 )
|
||||
points += 10;
|
||||
else if ( quantity == 15 )
|
||||
points += 25;
|
||||
else if ( quantity == 20 )
|
||||
points += 50;
|
||||
|
||||
if ( exceptional )
|
||||
points += 100;
|
||||
|
||||
if ( itemCount == 4 )
|
||||
points += 300;
|
||||
else if ( itemCount == 5 )
|
||||
points += 400;
|
||||
else if ( itemCount == 6 )
|
||||
points += 500;
|
||||
|
||||
if ( material == BulkMaterialType.Spined )
|
||||
points += 50;
|
||||
else if ( material == BulkMaterialType.Horned )
|
||||
points += 100;
|
||||
else if ( material == BulkMaterialType.Barbed )
|
||||
points += 150;
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
private static int[][][] m_AosGoldTable = new int[][][]
|
||||
{
|
||||
new int[][] // 1-part (regular)
|
||||
{
|
||||
new int[]{ 150, 150, 300, 300 },
|
||||
new int[]{ 225, 225, 450, 450 },
|
||||
new int[]{ 300, 400, 600, 750 }
|
||||
},
|
||||
new int[][] // 1-part (exceptional)
|
||||
{
|
||||
new int[]{ 300, 300, 600, 600 },
|
||||
new int[]{ 450, 450, 900, 900 },
|
||||
new int[]{ 600, 750, 1200, 1800 }
|
||||
},
|
||||
new int[][] // 4-part (regular)
|
||||
{
|
||||
new int[]{ 4000, 4000, 5000, 5000 },
|
||||
new int[]{ 6000, 6000, 7500, 7500 },
|
||||
new int[]{ 8000, 10000, 10000, 15000 }
|
||||
},
|
||||
new int[][] // 4-part (exceptional)
|
||||
{
|
||||
new int[]{ 5000, 5000, 7500, 7500 },
|
||||
new int[]{ 7500, 7500, 11250, 11250 },
|
||||
new int[]{ 10000, 15000, 15000, 20000 }
|
||||
},
|
||||
new int[][] // 5-part (regular)
|
||||
{
|
||||
new int[]{ 5000, 5000, 7500, 7500 },
|
||||
new int[]{ 7500, 7500, 11250, 11250 },
|
||||
new int[]{ 10000, 15000, 15000, 20000 }
|
||||
},
|
||||
new int[][] // 5-part (exceptional)
|
||||
{
|
||||
new int[]{ 7500, 7500, 10000, 10000 },
|
||||
new int[]{ 11250, 11250, 15000, 15000 },
|
||||
new int[]{ 15000, 20000, 20000, 30000 }
|
||||
},
|
||||
new int[][] // 6-part (regular)
|
||||
{
|
||||
new int[]{ 7500, 7500, 10000, 10000 },
|
||||
new int[]{ 11250, 11250, 15000, 15000 },
|
||||
new int[]{ 15000, 20000, 20000, 30000 }
|
||||
},
|
||||
new int[][] // 6-part (exceptional)
|
||||
{
|
||||
new int[]{ 10000, 10000, 15000, 15000 },
|
||||
new int[]{ 15000, 15000, 22500, 22500 },
|
||||
new int[]{ 20000, 30000, 30000, 50000 }
|
||||
}
|
||||
};
|
||||
|
||||
private static int[][][] m_OldGoldTable = new int[][][]
|
||||
{
|
||||
new int[][] // 1-part (regular)
|
||||
{
|
||||
new int[]{ 150, 150, 300, 300 },
|
||||
new int[]{ 225, 225, 450, 450 },
|
||||
new int[]{ 300, 400, 600, 750 }
|
||||
},
|
||||
new int[][] // 1-part (exceptional)
|
||||
{
|
||||
new int[]{ 300, 300, 600, 600 },
|
||||
new int[]{ 450, 450, 900, 900 },
|
||||
new int[]{ 600, 750, 1200, 1800 }
|
||||
},
|
||||
new int[][] // 4-part (regular)
|
||||
{
|
||||
new int[]{ 3000, 3000, 4000, 4000 },
|
||||
new int[]{ 4500, 4500, 6000, 6000 },
|
||||
new int[]{ 6000, 8000, 8000, 10000 }
|
||||
},
|
||||
new int[][] // 4-part (exceptional)
|
||||
{
|
||||
new int[]{ 4000, 4000, 5000, 5000 },
|
||||
new int[]{ 6000, 6000, 7500, 7500 },
|
||||
new int[]{ 8000, 10000, 10000, 15000 }
|
||||
},
|
||||
new int[][] // 5-part (regular)
|
||||
{
|
||||
new int[]{ 4000, 4000, 5000, 5000 },
|
||||
new int[]{ 6000, 6000, 7500, 7500 },
|
||||
new int[]{ 8000, 10000, 10000, 15000 }
|
||||
},
|
||||
new int[][] // 5-part (exceptional)
|
||||
{
|
||||
new int[]{ 5000, 5000, 7500, 7500 },
|
||||
new int[]{ 7500, 7500, 11250, 11250 },
|
||||
new int[]{ 10000, 15000, 15000, 20000 }
|
||||
},
|
||||
new int[][] // 6-part (regular)
|
||||
{
|
||||
new int[]{ 5000, 5000, 7500, 7500 },
|
||||
new int[]{ 7500, 7500, 11250, 11250 },
|
||||
new int[]{ 10000, 15000, 15000, 20000 }
|
||||
},
|
||||
new int[][] // 6-part (exceptional)
|
||||
{
|
||||
new int[]{ 7500, 7500, 10000, 10000 },
|
||||
new int[]{ 11250, 11250, 15000, 15000 },
|
||||
new int[]{ 15000, 20000, 20000, 30000 }
|
||||
}
|
||||
};
|
||||
|
||||
public override int ComputeGold( int quantity, bool exceptional, BulkMaterialType material, int itemCount, Type type )
|
||||
{
|
||||
int[][][] goldTable = ( Core.AOS ? m_AosGoldTable : m_OldGoldTable );
|
||||
|
||||
int typeIndex = (( itemCount == 6 ? 3 : itemCount == 5 ? 2 : itemCount == 4 ? 1 : 0 ) * 2) + (exceptional ? 1 : 0);
|
||||
int quanIndex = ( quantity == 20 ? 2 : quantity == 15 ? 1 : 0 );
|
||||
int mtrlIndex = ( material == BulkMaterialType.Barbed ? 3 : material == BulkMaterialType.Horned ? 2 : material == BulkMaterialType.Spined ? 1 : 0 );
|
||||
|
||||
int gold = goldTable[typeIndex][quanIndex][mtrlIndex];
|
||||
|
||||
int min = (gold * 9) / 10;
|
||||
int max = (gold * 10) / 9;
|
||||
|
||||
return Utility.RandomMinMax( min, max );
|
||||
}
|
||||
|
||||
public TailorRewardCalculator()
|
||||
{
|
||||
Groups = new RewardGroup[]
|
||||
{
|
||||
new RewardGroup( 0, new RewardItem( 1, Cloth, 0 ) ),
|
||||
new RewardGroup( 50, new RewardItem( 1, Cloth, 1 ) ),
|
||||
new RewardGroup( 100, new RewardItem( 1, Cloth, 2 ) ),
|
||||
new RewardGroup( 150, new RewardItem( 9, Cloth, 3 ), new RewardItem( 1, Sandals ) ),
|
||||
new RewardGroup( 200, new RewardItem( 4, Cloth, 4 ), new RewardItem( 1, Sandals ) ),
|
||||
new RewardGroup( 300, new RewardItem( 1, StretchedHide ) ),
|
||||
new RewardGroup( 350, new RewardItem( 1, RunicKit, 1 ) ),
|
||||
new RewardGroup( 400, new RewardItem( 2, PowerScroll, 5 ), new RewardItem( 3, Tapestry ) ),
|
||||
new RewardGroup( 450, new RewardItem( 1, BearRug ) ),
|
||||
new RewardGroup( 500, new RewardItem( 1, PowerScroll, 10 ) ),
|
||||
new RewardGroup( 550, new RewardItem( 1, ClothingBlessDeed ) ),
|
||||
new RewardGroup( 575, new RewardItem( 1, PowerScroll, 15 ) ),
|
||||
new RewardGroup( 600, new RewardItem( 1, RunicKit, 2 ) ),
|
||||
new RewardGroup( 650, new RewardItem( 1, PowerScroll, 20 ) ),
|
||||
new RewardGroup( 700, new RewardItem( 1, RunicKit, 3 ) )
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
291
Scripts/Engines/BulkOrders/SmallBOD.cs
Normal file
291
Scripts/Engines/BulkOrders/SmallBOD.cs
Normal file
|
|
@ -0,0 +1,291 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
[TypeAlias( "Scripts.Engines.BulkOrders.SmallBOD" )]
|
||||
public abstract class SmallBOD : Item
|
||||
{
|
||||
private int m_AmountCur, m_AmountMax;
|
||||
private Type m_Type;
|
||||
private int m_Number;
|
||||
private int m_Graphic;
|
||||
private bool m_RequireExceptional;
|
||||
private BulkMaterialType m_Material;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int AmountCur{ get{ return m_AmountCur; } set{ m_AmountCur = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int AmountMax{ get{ return m_AmountMax; } set{ m_AmountMax = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Type Type{ get{ return m_Type; } set{ m_Type = value; } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int Number{ get{ return m_Number; } set{ m_Number = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int Graphic{ get{ return m_Graphic; } set{ m_Graphic = value; } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool RequireExceptional{ get{ return m_RequireExceptional; } set{ m_RequireExceptional = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public BulkMaterialType Material{ get{ return m_Material; } set{ m_Material = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool Complete{ get{ return ( m_AmountCur == m_AmountMax ); } }
|
||||
|
||||
public override int LabelNumber{ get{ return 1045151; } } // a bulk order deed
|
||||
|
||||
[Constructable]
|
||||
public SmallBOD( int hue, int amountMax, Type type, int number, int graphic, bool requireExeptional, BulkMaterialType material ) : base( Core.AOS ? 0x2258 : 0x14EF )
|
||||
{
|
||||
Weight = 1.0;
|
||||
Hue = hue; // Blacksmith: 0x44E; Tailoring: 0x483
|
||||
LootType = LootType.Blessed;
|
||||
|
||||
m_AmountMax = amountMax;
|
||||
m_Type = type;
|
||||
m_Number = number;
|
||||
m_Graphic = graphic;
|
||||
m_RequireExceptional = requireExeptional;
|
||||
m_Material = material;
|
||||
}
|
||||
|
||||
public SmallBOD() : base( Core.AOS ? 0x2258 : 0x14EF )
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
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 )
|
||||
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.
|
||||
|
||||
list.Add( 1060656, m_AmountMax.ToString() ); // amount to make: ~1_val~
|
||||
list.Add( 1060658, "#{0}\t{1}", m_Number, m_AmountCur ); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( IsChildOf( from.Backpack ) || InSecureTrade || RootParent is PlayerVendor )
|
||||
from.SendGump( new SmallBODGump( from, this ) );
|
||||
else
|
||||
from.SendLocalizedMessage( 1045156 ); // You must have the deed in your backpack to use it.
|
||||
}
|
||||
|
||||
public override void OnDoubleClickNotAccessible( Mobile from )
|
||||
{
|
||||
OnDoubleClick( from );
|
||||
}
|
||||
|
||||
public override void OnDoubleClickSecureTrade( Mobile from )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
case CraftResource.DullCopper: return BulkMaterialType.DullCopper;
|
||||
case CraftResource.ShadowIron: return BulkMaterialType.ShadowIron;
|
||||
case CraftResource.Copper: return BulkMaterialType.Copper;
|
||||
case CraftResource.Bronze: return BulkMaterialType.Bronze;
|
||||
case CraftResource.Gold: return BulkMaterialType.Gold;
|
||||
case CraftResource.Agapite: return BulkMaterialType.Agapite;
|
||||
case CraftResource.Verite: return BulkMaterialType.Verite;
|
||||
case CraftResource.Valorite: return BulkMaterialType.Valorite;
|
||||
case CraftResource.SpinedLeather: return BulkMaterialType.Spined;
|
||||
case CraftResource.HornedLeather: return BulkMaterialType.Horned;
|
||||
case CraftResource.BarbedLeather: return BulkMaterialType.Barbed;
|
||||
}
|
||||
|
||||
return BulkMaterialType.None;
|
||||
}
|
||||
|
||||
public void EndCombine( Mobile from, object o )
|
||||
{
|
||||
if ( o is Item && ((Item)o).IsChildOf( from.Backpack ) )
|
||||
{
|
||||
Type objectType = o.GetType();
|
||||
|
||||
if ( m_AmountCur >= m_AmountMax )
|
||||
{
|
||||
from.SendLocalizedMessage( 1045166 ); // The maximum amount of requested items have already been combined to this deed.
|
||||
}
|
||||
else if ( m_Type == null || (objectType != m_Type && !objectType.IsSubclassOf( m_Type )) || (!(o is BaseWeapon) && !(o is BaseArmor) && !(o is BaseClothing)) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1045169 ); // The item is not in the request.
|
||||
}
|
||||
else
|
||||
{
|
||||
BulkMaterialType material = BulkMaterialType.None;
|
||||
|
||||
if ( o is BaseArmor )
|
||||
material = GetMaterial( ((BaseArmor)o).Resource );
|
||||
else if ( o is BaseClothing )
|
||||
material = GetMaterial( ((BaseClothing)o).Resource );
|
||||
|
||||
if ( m_Material >= BulkMaterialType.DullCopper && m_Material <= BulkMaterialType.Valorite && material != m_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 )
|
||||
{
|
||||
from.SendLocalizedMessage( 1049352 ); // The item is not made from the requested leather type.
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isExceptional = false;
|
||||
|
||||
if ( o is BaseWeapon )
|
||||
isExceptional = ( ((BaseWeapon)o).Quality == WeaponQuality.Exceptional );
|
||||
else if ( o is BaseArmor )
|
||||
isExceptional = ( ((BaseArmor)o).Quality == ArmorQuality.Exceptional );
|
||||
else if ( o is BaseClothing )
|
||||
isExceptional = ( ((BaseClothing)o).Quality == ClothingQuality.Exceptional );
|
||||
|
||||
if ( m_RequireExceptional && !isExceptional )
|
||||
{
|
||||
from.SendLocalizedMessage( 1045167 ); // The item must be exceptional.
|
||||
}
|
||||
else
|
||||
{
|
||||
((Item)o).Delete();
|
||||
++AmountCur;
|
||||
|
||||
from.SendLocalizedMessage( 1045170 ); // The item has been combined with the deed.
|
||||
|
||||
from.SendGump( new SmallBODGump( from, this ) );
|
||||
|
||||
if ( m_AmountCur < m_AmountMax )
|
||||
BeginCombine( from );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1045158 ); // You must have the item in your backpack to target it.
|
||||
}
|
||||
}
|
||||
|
||||
public SmallBOD( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_AmountCur );
|
||||
writer.Write( m_AmountMax );
|
||||
writer.Write( m_Type == null ? null : m_Type.FullName );
|
||||
writer.Write( m_Number );
|
||||
writer.Write( m_Graphic );
|
||||
writer.Write( m_RequireExceptional );
|
||||
writer.Write( (int) m_Material );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_AmountCur = reader.ReadInt();
|
||||
m_AmountMax = reader.ReadInt();
|
||||
|
||||
string type = reader.ReadString();
|
||||
|
||||
if ( type != null )
|
||||
m_Type = ScriptCompiler.FindTypeByFullName( type );
|
||||
|
||||
m_Number = reader.ReadInt();
|
||||
m_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();
|
||||
}
|
||||
}
|
||||
}
|
||||
93
Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs
Normal file
93
Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class SmallBODAcceptGump : Gump
|
||||
{
|
||||
private SmallBOD m_Deed;
|
||||
private Mobile m_From;
|
||||
|
||||
public SmallBODAcceptGump( Mobile from, SmallBOD deed ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Deed = deed;
|
||||
|
||||
m_From.CloseGump( typeof( LargeBODAcceptGump ) );
|
||||
m_From.CloseGump( typeof( SmallBODAcceptGump ) );
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 25, 10, 430, 264, 5054 );
|
||||
|
||||
AddImageTiled( 33, 20, 413, 245, 2624 );
|
||||
AddAlphaRegion( 33, 20, 413, 245 );
|
||||
|
||||
AddImage( 20, 5, 10460 );
|
||||
AddImage( 430, 5, 10460 );
|
||||
AddImage( 20, 249, 10460 );
|
||||
AddImage( 430, 249, 10460 );
|
||||
|
||||
AddHtmlLocalized( 190, 25, 120, 20, 1045133, 0x7FFF, false, false ); // A bulk order
|
||||
AddHtmlLocalized( 40, 48, 350, 20, 1045135, 0x7FFF, false, false ); // Ah! Thanks for the goods! Would you help me out?
|
||||
|
||||
AddHtmlLocalized( 40, 72, 210, 20, 1045138, 0x7FFF, false, false ); // Amount to make:
|
||||
AddLabel( 250, 72, 1152, deed.AmountMax.ToString() );
|
||||
|
||||
AddHtmlLocalized( 40, 96, 120, 20, 1045136, 0x7FFF, false, false ); // Item requested:
|
||||
AddItem( 385, 96, deed.Graphic );
|
||||
AddHtmlLocalized( 40, 120, 210, 20, deed.Number, 0xFFFFFF, false, false );
|
||||
|
||||
if ( deed.RequireExceptional || deed.Material != BulkMaterialType.None )
|
||||
{
|
||||
AddHtmlLocalized( 40, 144, 210, 20, 1045140, 0x7FFF, false, false ); // Special requirements to meet:
|
||||
|
||||
if ( deed.RequireExceptional )
|
||||
AddHtmlLocalized( 40, 168, 350, 20, 1045141, 0x7FFF, false, false ); // All items must be exceptional.
|
||||
|
||||
if ( deed.Material != BulkMaterialType.None )
|
||||
AddHtmlLocalized( 40, deed.RequireExceptional ? 192 : 168, 350, 20, GetMaterialNumberFor( deed.Material ), 0x7FFF, false, false ); // All items must be made with x material.
|
||||
}
|
||||
|
||||
AddHtmlLocalized( 40, 216, 350, 20, 1045139, 0x7FFF, false, false ); // Do you want to accept this order?
|
||||
|
||||
AddButton( 100, 240, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 135, 240, 120, 20, 1006044, 0x7FFF, false, false ); // Ok
|
||||
|
||||
AddButton( 275, 240, 4005, 4007, 0, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 310, 240, 120, 20, 1011012, 0x7FFF, false, false ); // CANCEL
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID == 1 ) // Ok
|
||||
{
|
||||
if ( m_From.PlaceInBackpack( m_Deed ) )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1045152 ); // The bulk order deed has been placed in your backpack.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1045150 ); // There is not enough room in your backpack for the deed.
|
||||
m_Deed.Delete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Deed.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetMaterialNumberFor( BulkMaterialType material )
|
||||
{
|
||||
if ( material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite )
|
||||
return 1045142 + (int)(material - BulkMaterialType.DullCopper);
|
||||
else if ( material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed )
|
||||
return 1049348 + (int)(material - BulkMaterialType.Spined);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
83
Scripts/Engines/BulkOrders/SmallBODGump.cs
Normal file
83
Scripts/Engines/BulkOrders/SmallBODGump.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class SmallBODGump : Gump
|
||||
{
|
||||
private SmallBOD m_Deed;
|
||||
private Mobile m_From;
|
||||
|
||||
public SmallBODGump( Mobile from, SmallBOD deed ) : base( 25, 25 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Deed = deed;
|
||||
|
||||
m_From.CloseGump( typeof( LargeBODGump ) );
|
||||
m_From.CloseGump( typeof( SmallBODGump ) );
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 50, 10, 455, 260, 5054 );
|
||||
AddImageTiled( 58, 20, 438, 241, 2624 );
|
||||
AddAlphaRegion( 58, 20, 438, 241 );
|
||||
|
||||
AddImage( 45, 5, 10460 );
|
||||
AddImage( 480, 5, 10460 );
|
||||
AddImage( 45, 245, 10460 );
|
||||
AddImage( 480, 245, 10460 );
|
||||
|
||||
AddHtmlLocalized( 225, 25, 120, 20, 1045133, 0x7FFF, false, false ); // A bulk order
|
||||
|
||||
AddHtmlLocalized( 75, 48, 250, 20, 1045138, 0x7FFF, false, false ); // Amount to make:
|
||||
AddLabel( 275, 48, 1152, deed.AmountMax.ToString() );
|
||||
|
||||
AddHtmlLocalized( 275, 76, 200, 20, 1045153, 0x7FFF, false, false ); // Amount finished:
|
||||
AddHtmlLocalized( 75, 72, 120, 20, 1045136, 0x7FFF, false, false ); // Item requested:
|
||||
|
||||
AddItem( 410, 72, deed.Graphic );
|
||||
|
||||
AddHtmlLocalized( 75, 96, 210, 20, deed.Number, 0x7FFF, false, false );
|
||||
AddLabel( 275, 96, 0x480, deed.AmountCur.ToString() );
|
||||
|
||||
if ( deed.RequireExceptional || deed.Material != BulkMaterialType.None )
|
||||
AddHtmlLocalized( 75, 120, 200, 20, 1045140, 0x7FFF, false, false ); // Special requirements to meet:
|
||||
|
||||
if ( deed.RequireExceptional )
|
||||
AddHtmlLocalized( 75, 144, 300, 20, 1045141, 0x7FFF, false, false ); // All items must be exceptional.
|
||||
|
||||
if ( deed.Material != BulkMaterialType.None )
|
||||
AddHtmlLocalized( 75, deed.RequireExceptional ? 168 : 144, 300, 20, GetMaterialNumberFor( deed.Material ), 0x7FFF, false, false ); // All items must be made with x material.
|
||||
|
||||
AddButton( 125, 192, 4005, 4007, 2, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 160, 192, 300, 20, 1045154, 0x7FFF, false, false ); // Combine this deed with the item requested.
|
||||
|
||||
AddButton( 125, 216, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 160, 216, 120, 20, 1011441, 0x7FFF, false, false ); // EXIT
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( m_Deed.Deleted || !m_Deed.IsChildOf( m_From.Backpack ) )
|
||||
return;
|
||||
|
||||
if ( info.ButtonID == 2 ) // Combine
|
||||
{
|
||||
m_From.SendGump( new SmallBODGump( m_From, m_Deed ) );
|
||||
m_Deed.BeginCombine( m_From );
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetMaterialNumberFor( BulkMaterialType material )
|
||||
{
|
||||
if ( material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite )
|
||||
return 1045142 + (int)(material - BulkMaterialType.DullCopper);
|
||||
else if ( material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed )
|
||||
return 1049348 + (int)(material - BulkMaterialType.Spined);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Scripts/Engines/BulkOrders/SmallBODTarget.cs
Normal file
25
Scripts/Engines/BulkOrders/SmallBODTarget.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
110
Scripts/Engines/BulkOrders/SmallBulkEntry.cs
Normal file
110
Scripts/Engines/BulkOrders/SmallBulkEntry.cs
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class SmallBulkEntry
|
||||
{
|
||||
private Type m_Type;
|
||||
private int m_Number;
|
||||
private int m_Graphic;
|
||||
|
||||
public Type Type{ get{ return m_Type; } }
|
||||
public int Number{ get{ return m_Number; } }
|
||||
public int Graphic{ get{ return m_Graphic; } }
|
||||
|
||||
public SmallBulkEntry( Type type, int number, int graphic )
|
||||
{
|
||||
m_Type = type;
|
||||
m_Number = number;
|
||||
m_Graphic = graphic;
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] BlacksmithWeapons
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "weapons" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] BlacksmithArmor
|
||||
{
|
||||
get{ return GetEntries( "Blacksmith", "armor" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] TailorCloth
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "cloth" ); }
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] TailorLeather
|
||||
{
|
||||
get{ return GetEntries( "Tailoring", "leather" ); }
|
||||
}
|
||||
|
||||
private static Dictionary<string, Dictionary<string, SmallBulkEntry[]>> m_Cache;
|
||||
|
||||
public static SmallBulkEntry[] GetEntries( string type, string name )
|
||||
{
|
||||
if ( m_Cache == null )
|
||||
m_Cache = new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>();
|
||||
|
||||
Dictionary<string, SmallBulkEntry[]> table = null;
|
||||
|
||||
if (!m_Cache.TryGetValue(type, out table))
|
||||
m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>();
|
||||
|
||||
SmallBulkEntry[] entries = null;
|
||||
|
||||
if (!table.TryGetValue(name, out entries))
|
||||
table[name] = entries = LoadEntries(type, name);
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] LoadEntries( string type, string name )
|
||||
{
|
||||
return LoadEntries( String.Format( "Data/Bulk Orders/{0}/{1}.cfg", type, name ) );
|
||||
}
|
||||
|
||||
public static SmallBulkEntry[] LoadEntries( string path )
|
||||
{
|
||||
path = Path.Combine( Core.BaseDirectory, path );
|
||||
|
||||
List<SmallBulkEntry> list = new List<SmallBulkEntry>();
|
||||
|
||||
if ( File.Exists( path ) )
|
||||
{
|
||||
using ( StreamReader ip = new StreamReader( path ) )
|
||||
{
|
||||
string line;
|
||||
|
||||
while ( (line = ip.ReadLine()) != null )
|
||||
{
|
||||
if ( line.Length == 0 || line.StartsWith( "#" ) )
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
string[] split = line.Split( '\t' );
|
||||
|
||||
if ( split.Length >= 2 )
|
||||
{
|
||||
Type type = ScriptCompiler.FindTypeByName( split[0] );
|
||||
int graphic = Utility.ToInt32( split[split.Length - 1] );
|
||||
|
||||
if ( type != null && graphic > 0 )
|
||||
list.Add( new SmallBulkEntry( type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic ) );
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
244
Scripts/Engines/BulkOrders/SmallSmithBOD.cs
Normal file
244
Scripts/Engines/BulkOrders/SmallSmithBOD.cs
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Engines.Craft;
|
||||
using Server.Items;
|
||||
using Mat = Server.Engines.BulkOrders.BulkMaterialType;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
[TypeAlias( "Scripts.Engines.BulkOrders.SmallSmithBOD" )]
|
||||
public class SmallSmithBOD : SmallBOD
|
||||
{
|
||||
public static double[] m_BlacksmithMaterialChances = new double[]
|
||||
{
|
||||
0.501953125, // None
|
||||
0.250000000, // Dull Copper
|
||||
0.125000000, // Shadow Iron
|
||||
0.062500000, // Copper
|
||||
0.031250000, // Bronze
|
||||
0.015625000, // Gold
|
||||
0.007812500, // Agapite
|
||||
0.003906250, // Verite
|
||||
0.001953125 // Valorite
|
||||
};
|
||||
|
||||
public override int ComputeFame()
|
||||
{
|
||||
return SmithRewardCalculator.Instance.ComputeFame( this );
|
||||
}
|
||||
|
||||
public override int ComputeGold()
|
||||
{
|
||||
return 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();
|
||||
|
||||
if ( rewardItem != null )
|
||||
{
|
||||
Item item = rewardItem.Construct();
|
||||
|
||||
if ( item != null )
|
||||
list.Add( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static SmallSmithBOD CreateRandomFor( Mobile m )
|
||||
{
|
||||
SmallBulkEntry[] entries;
|
||||
bool useMaterials;
|
||||
|
||||
if ( useMaterials = Utility.RandomBool() )
|
||||
entries = SmallBulkEntry.BlacksmithArmor;
|
||||
else
|
||||
entries = SmallBulkEntry.BlacksmithWeapons;
|
||||
|
||||
if ( entries.Length > 0 )
|
||||
{
|
||||
double theirSkill = m.Skills[SkillName.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
|
||||
amountMax = Utility.RandomList( 10, 10, 15, 20 );
|
||||
|
||||
BulkMaterialType material = BulkMaterialType.None;
|
||||
|
||||
if ( useMaterials && theirSkill >= 70.1 )
|
||||
{
|
||||
for ( int i = 0; i < 20; ++i )
|
||||
{
|
||||
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;
|
||||
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 )
|
||||
{
|
||||
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] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( validEntries.Count > 0 )
|
||||
{
|
||||
SmallBulkEntry entry = validEntries[Utility.Random( validEntries.Count )];
|
||||
return new SmallSmithBOD( entry, material, amountMax, reqExceptional );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private SmallSmithBOD( SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional )
|
||||
{
|
||||
this.Hue = 0x44E;
|
||||
this.AmountMax = amountMax;
|
||||
this.Type = entry.Type;
|
||||
this.Number = entry.Number;
|
||||
this.Graphic = entry.Graphic;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = material;
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
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 )];
|
||||
|
||||
this.Hue = hue;
|
||||
this.AmountMax = amountMax;
|
||||
this.Type = entry.Type;
|
||||
this.Number = entry.Number;
|
||||
this.Graphic = entry.Graphic;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = material;
|
||||
}
|
||||
}
|
||||
|
||||
public SmallSmithBOD( int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional, BulkMaterialType mat )
|
||||
{
|
||||
this.Hue = 0x44E;
|
||||
this.AmountMax = amountMax;
|
||||
this.AmountCur = amountCur;
|
||||
this.Type = type;
|
||||
this.Number = number;
|
||||
this.Graphic = graphic;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = mat;
|
||||
}
|
||||
|
||||
public SmallSmithBOD( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
236
Scripts/Engines/BulkOrders/SmallTailorBOD.cs
Normal file
236
Scripts/Engines/BulkOrders/SmallTailorBOD.cs
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Engines.Craft;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.BulkOrders
|
||||
{
|
||||
public class SmallTailorBOD : SmallBOD
|
||||
{
|
||||
public static double[] m_TailoringMaterialChances = new double[]
|
||||
{
|
||||
0.857421875, // None
|
||||
0.125000000, // Spined
|
||||
0.015625000, // Horned
|
||||
0.001953125 // Barbed
|
||||
};
|
||||
|
||||
public override int ComputeFame()
|
||||
{
|
||||
return TailorRewardCalculator.Instance.ComputeFame( this );
|
||||
}
|
||||
|
||||
public override int ComputeGold()
|
||||
{
|
||||
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();
|
||||
|
||||
if ( rewardItem != null )
|
||||
{
|
||||
Item item = rewardItem.Construct();
|
||||
|
||||
if ( item != null )
|
||||
list.Add( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static SmallTailorBOD CreateRandomFor( Mobile m )
|
||||
{
|
||||
SmallBulkEntry[] entries;
|
||||
bool useMaterials = Utility.RandomBool();
|
||||
|
||||
double theirSkill = m.Skills[SkillName.Tailoring].Base;
|
||||
if ( useMaterials && theirSkill >= 6.2 ) // Ugly, but the easiest leather BOD is Leather Cap which requires at least 6.2 skill.
|
||||
entries = SmallBulkEntry.TailorLeather;
|
||||
else
|
||||
entries = SmallBulkEntry.TailorCloth;
|
||||
|
||||
if ( entries.Length > 0 )
|
||||
{
|
||||
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
|
||||
amountMax = Utility.RandomList( 10, 10, 15, 20 );
|
||||
|
||||
BulkMaterialType material = BulkMaterialType.None;
|
||||
|
||||
if ( useMaterials && theirSkill >= 70.1 )
|
||||
{
|
||||
for ( int i = 0; i < 20; ++i )
|
||||
{
|
||||
BulkMaterialType check = GetRandomMaterial( BulkMaterialType.Spined, m_TailoringMaterialChances );
|
||||
double skillReq = 0.0;
|
||||
|
||||
switch ( check )
|
||||
{
|
||||
case BulkMaterialType.DullCopper: skillReq = 65.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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double excChance = 0.0;
|
||||
|
||||
if ( theirSkill >= 70.1 )
|
||||
excChance = (theirSkill + 80.0) / 200.0;
|
||||
|
||||
bool reqExceptional = ( excChance > Utility.RandomDouble() );
|
||||
|
||||
|
||||
CraftSystem system = DefTailoring.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 )
|
||||
{
|
||||
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] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( validEntries.Count > 0 )
|
||||
{
|
||||
SmallBulkEntry entry = validEntries[Utility.Random( validEntries.Count )];
|
||||
return new SmallTailorBOD( entry, material, amountMax, reqExceptional );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private SmallTailorBOD( SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional )
|
||||
{
|
||||
this.Hue = 0x483;
|
||||
this.AmountMax = amountMax;
|
||||
this.Type = entry.Type;
|
||||
this.Number = entry.Number;
|
||||
this.Graphic = entry.Graphic;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = material;
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
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 )];
|
||||
|
||||
this.Hue = hue;
|
||||
this.AmountMax = amountMax;
|
||||
this.Type = entry.Type;
|
||||
this.Number = entry.Number;
|
||||
this.Graphic = entry.Graphic;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = material;
|
||||
}
|
||||
}
|
||||
|
||||
public SmallTailorBOD( int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional, BulkMaterialType mat )
|
||||
{
|
||||
this.Hue = 0x483;
|
||||
this.AmountMax = amountMax;
|
||||
this.AmountCur = amountCur;
|
||||
this.Type = type;
|
||||
this.Number = number;
|
||||
this.Graphic = graphic;
|
||||
this.RequireExceptional = reqExceptional;
|
||||
this.Material = mat;
|
||||
}
|
||||
|
||||
public SmallTailorBOD( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue