#W# Initial Commit: Avatars Conquest
This commit is contained in:
commit
8eae46895e
7512 changed files with 416187 additions and 0 deletions
56
Scripts/Engines/Craft/Core/CraftContext.cs
Normal file
56
Scripts/Engines/Craft/Core/CraftContext.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public enum CraftMarkOption
|
||||
{
|
||||
MarkItem,
|
||||
DoNotMark,
|
||||
PromptForMark
|
||||
}
|
||||
|
||||
public class CraftContext
|
||||
{
|
||||
private List<CraftItem> m_Items;
|
||||
private int m_LastResourceIndex;
|
||||
private int m_LastGroupIndex;
|
||||
private bool m_DoNotColor;
|
||||
private CraftMarkOption m_MarkOption;
|
||||
|
||||
public List<CraftItem> Items { get { return m_Items; } }
|
||||
public int LastResourceIndex{ get{ return m_LastResourceIndex; } set{ m_LastResourceIndex = value; } }
|
||||
public int LastGroupIndex{ get{ return m_LastGroupIndex; } set{ m_LastGroupIndex = value; } }
|
||||
public bool DoNotColor{ get{ return m_DoNotColor; } set{ m_DoNotColor = value; } }
|
||||
public CraftMarkOption MarkOption{ get{ return m_MarkOption; } set{ m_MarkOption = value; } }
|
||||
|
||||
public CraftContext()
|
||||
{
|
||||
m_Items = new List<CraftItem>();
|
||||
m_LastResourceIndex = -1;
|
||||
m_LastGroupIndex = -1;
|
||||
}
|
||||
|
||||
public CraftItem LastMade
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_Items.Count > 0 )
|
||||
return m_Items[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMade( CraftItem item )
|
||||
{
|
||||
m_Items.Remove( item );
|
||||
|
||||
if ( m_Items.Count == 10 )
|
||||
m_Items.RemoveAt( 9 );
|
||||
|
||||
m_Items.Insert( 0, item );
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Scripts/Engines/Craft/Core/CraftGroup.cs
Normal file
39
Scripts/Engines/Craft/Core/CraftGroup.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftGroup
|
||||
{
|
||||
private CraftItemCol m_arCraftItem;
|
||||
|
||||
private string m_NameString;
|
||||
private int m_NameNumber;
|
||||
|
||||
public CraftGroup( TextDefinition groupName )
|
||||
{
|
||||
m_NameNumber = groupName;
|
||||
m_NameString = groupName;
|
||||
m_arCraftItem = new CraftItemCol();
|
||||
}
|
||||
|
||||
public void AddCraftItem( CraftItem craftItem )
|
||||
{
|
||||
m_arCraftItem.Add( craftItem );
|
||||
}
|
||||
|
||||
public CraftItemCol CraftItems
|
||||
{
|
||||
get { return m_arCraftItem; }
|
||||
}
|
||||
|
||||
public string NameString
|
||||
{
|
||||
get { return m_NameString; }
|
||||
}
|
||||
|
||||
public int NameNumber
|
||||
{
|
||||
get { return m_NameNumber; }
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Scripts/Engines/Craft/Core/CraftGroupCol.cs
Normal file
48
Scripts/Engines/Craft/Core/CraftGroupCol.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftGroupCol : System.Collections.CollectionBase
|
||||
{
|
||||
public CraftGroupCol()
|
||||
{
|
||||
}
|
||||
|
||||
public int Add( CraftGroup craftGroup )
|
||||
{
|
||||
return List.Add( craftGroup );
|
||||
}
|
||||
|
||||
public void Remove( int index )
|
||||
{
|
||||
if ( index > Count - 1 || index < 0 )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
List.RemoveAt( index );
|
||||
}
|
||||
}
|
||||
|
||||
public CraftGroup GetAt( int index )
|
||||
{
|
||||
return ( CraftGroup ) List[index];
|
||||
}
|
||||
|
||||
public int SearchFor( TextDefinition groupName )
|
||||
{
|
||||
for ( int i = 0; i < List.Count; i++ )
|
||||
{
|
||||
CraftGroup craftGroup = (CraftGroup)List[i];
|
||||
|
||||
int nameNumber = craftGroup.NameNumber;
|
||||
string nameString = craftGroup.NameString;
|
||||
|
||||
if ( ( nameNumber != 0 && nameNumber == groupName.Number ) || ( nameString != null && nameString == groupName.String ) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
539
Scripts/Engines/Craft/Core/CraftGump.cs
Normal file
539
Scripts/Engines/Craft/Core/CraftGump.cs
Normal file
|
|
@ -0,0 +1,539 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Items;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private CraftSystem m_CraftSystem;
|
||||
private BaseTool m_Tool;
|
||||
|
||||
private CraftPage m_Page;
|
||||
|
||||
private const int LabelHue = 0x480;
|
||||
private const int LabelColor = 0x7FFF;
|
||||
private const int FontColor = 0xFFFFFF;
|
||||
|
||||
private enum CraftPage
|
||||
{
|
||||
None,
|
||||
PickResource
|
||||
}
|
||||
|
||||
/*public CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool ): this( from, craftSystem, -1, -1, tool, null )
|
||||
{
|
||||
}*/
|
||||
|
||||
public CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool, object notice ) : this( from, craftSystem, tool, notice, CraftPage.None )
|
||||
{
|
||||
}
|
||||
|
||||
private CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page ) : base( 40, 40 )
|
||||
{
|
||||
m_From = from;
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Tool = tool;
|
||||
m_Page = page;
|
||||
|
||||
CraftContext context = craftSystem.GetContext( from );
|
||||
|
||||
from.CloseGump( typeof( CraftGump ) );
|
||||
from.CloseGump( typeof( CraftGumpItem ) );
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 530, 437, 5054 );
|
||||
AddImageTiled( 10, 10, 510, 22, 2624 );
|
||||
AddImageTiled( 10, 292, 150, 45, 2624 );
|
||||
AddImageTiled( 165, 292, 355, 45, 2624 );
|
||||
AddImageTiled( 10, 342, 510, 85, 2624 );
|
||||
AddImageTiled( 10, 37, 200, 250, 2624 );
|
||||
AddImageTiled( 215, 37, 305, 250, 2624 );
|
||||
AddAlphaRegion( 10, 10, 510, 417 );
|
||||
|
||||
if ( craftSystem.GumpTitleNumber > 0 )
|
||||
AddHtmlLocalized( 10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false );
|
||||
else
|
||||
AddHtml( 10, 12, 510, 20, craftSystem.GumpTitleString, false, false );
|
||||
|
||||
AddHtmlLocalized( 10, 37, 200, 22, 1044010, LabelColor, false, false ); // <CENTER>CATEGORIES</CENTER>
|
||||
AddHtmlLocalized( 215, 37, 305, 22, 1044011, LabelColor, false, false ); // <CENTER>SELECTIONS</CENTER>
|
||||
AddHtmlLocalized( 10, 302, 150, 25, 1044012, LabelColor, false, false ); // <CENTER>NOTICES</CENTER>
|
||||
|
||||
AddButton( 15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 50, 405, 150, 18, 1011441, LabelColor, false, false ); // EXIT
|
||||
|
||||
AddButton( 270, 402, 4005, 4007, GetButtonID( 6, 2 ), GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 305, 405, 150, 18, 1044013, LabelColor, false, false ); // MAKE LAST
|
||||
|
||||
// Mark option
|
||||
if ( craftSystem.MarkOption )
|
||||
{
|
||||
AddButton( 270, 362, 4005, 4007, GetButtonID( 6, 6 ), GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false ); // MARK ITEM
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
// Resmelt option
|
||||
if ( craftSystem.Resmelt )
|
||||
{
|
||||
AddButton( 15, 342, 4005, 4007, GetButtonID( 6, 1 ), GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 50, 345, 150, 18, 1044259, LabelColor, false, false ); // SMELT ITEM
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
// Repair option
|
||||
if ( craftSystem.Repair )
|
||||
{
|
||||
AddButton( 270, 342, 4005, 4007, GetButtonID( 6, 5 ), GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 305, 345, 150, 18, 1044260, LabelColor, false, false ); // REPAIR ITEM
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
if ( notice is int && (int)notice > 0 )
|
||||
AddHtmlLocalized( 170, 295, 350, 40, (int)notice, LabelColor, false, false );
|
||||
else if ( notice is string )
|
||||
AddHtml( 170, 295, 350, 40, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice ), false, false );
|
||||
|
||||
// If the system has more than one resource
|
||||
if ( craftSystem.CraftSubRes.Init )
|
||||
{
|
||||
string nameString = craftSystem.CraftSubRes.NameString;
|
||||
int nameNumber = craftSystem.CraftSubRes.NameNumber;
|
||||
|
||||
int resIndex = ( context == null ? -1 : context.LastResourceIndex );
|
||||
|
||||
Type resourceType = craftSystem.CraftSubRes.ResType;
|
||||
|
||||
if ( resIndex > -1 )
|
||||
{
|
||||
CraftSubRes subResource = craftSystem.CraftSubRes.GetAt( resIndex );
|
||||
|
||||
nameString = subResource.NameString;
|
||||
nameNumber = subResource.NameNumber;
|
||||
resourceType = subResource.ItemType;
|
||||
}
|
||||
|
||||
int resourceCount = 0;
|
||||
|
||||
if ( from.Backpack != null )
|
||||
{
|
||||
Item[] items = from.Backpack.FindItemsByType( resourceType, true );
|
||||
|
||||
for ( int i = 0; i < items.Length; ++i )
|
||||
resourceCount += items[i].Amount;
|
||||
}
|
||||
|
||||
AddButton( 15, 362, 4005, 4007, GetButtonID( 6, 0 ), GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( nameNumber > 0 )
|
||||
AddHtmlLocalized( 50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false );
|
||||
else
|
||||
AddLabel( 50, 362, LabelHue, String.Format( "{0} ({1} Available)", nameString, resourceCount ) );
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
CreateGroupList();
|
||||
|
||||
if ( page == CraftPage.PickResource )
|
||||
CreateResList( false, from );
|
||||
else if ( context != null && context.LastGroupIndex > -1 )
|
||||
CreateItemList( context.LastGroupIndex );
|
||||
}
|
||||
|
||||
public void CreateResList( bool opt, Mobile from )
|
||||
{
|
||||
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
|
||||
|
||||
for ( int i = 0; i < res.Count; ++i )
|
||||
{
|
||||
int index = i % 10;
|
||||
|
||||
CraftSubRes subResource = res.GetAt( i );
|
||||
|
||||
if ( index == 0 )
|
||||
{
|
||||
if ( i > 0 )
|
||||
AddButton( 485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1 );
|
||||
|
||||
AddPage( (i / 10) + 1 );
|
||||
|
||||
if ( i > 0 )
|
||||
AddButton( 455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10 );
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext( m_From );
|
||||
|
||||
AddButton( 220, 260, 4005, 4007, GetButtonID( 6, 4 ), GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false );
|
||||
}
|
||||
|
||||
int resourceCount = 0;
|
||||
|
||||
if ( from.Backpack != null )
|
||||
{
|
||||
Item[] items = from.Backpack.FindItemsByType( subResource.ItemType, true );
|
||||
|
||||
for ( int j = 0; j < items.Length; ++j )
|
||||
resourceCount += items[j].Amount;
|
||||
}
|
||||
|
||||
AddButton( 220, 60 + (index * 20), 4005, 4007, GetButtonID( 5, i ), GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( subResource.NameNumber > 0 )
|
||||
AddHtmlLocalized( 255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false );
|
||||
else
|
||||
AddLabel( 255, 60 + ( index * 20 ), LabelHue, String.Format( "{0} ({1})", subResource.NameString, resourceCount ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateMakeLastList()
|
||||
{
|
||||
CraftContext context = m_CraftSystem.GetContext( m_From );
|
||||
|
||||
if ( context == null )
|
||||
return;
|
||||
|
||||
List<CraftItem> items = context.Items;
|
||||
|
||||
if ( items.Count > 0 )
|
||||
{
|
||||
for ( int i = 0; i < items.Count; ++i )
|
||||
{
|
||||
int index = i % 10;
|
||||
|
||||
CraftItem craftItem = items[i];
|
||||
|
||||
if ( index == 0 )
|
||||
{
|
||||
if ( i > 0 )
|
||||
{
|
||||
AddButton( 370, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1 );
|
||||
AddHtmlLocalized( 405, 263, 100, 18, 1044045, LabelColor, false, false ); // NEXT PAGE
|
||||
}
|
||||
|
||||
AddPage( (i / 10) + 1 );
|
||||
|
||||
if ( i > 0 )
|
||||
{
|
||||
AddButton( 220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10 );
|
||||
AddHtmlLocalized( 255, 263, 100, 18, 1044044, LabelColor, false, false ); // PREV PAGE
|
||||
}
|
||||
}
|
||||
|
||||
AddButton( 220, 60 + (index * 20), 4005, 4007, GetButtonID( 3, i ), GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( craftItem.NameNumber > 0 )
|
||||
AddHtmlLocalized( 255, 63 + (index * 20), 220, 18, craftItem.NameNumber, LabelColor, false, false );
|
||||
else
|
||||
AddLabel( 255, 60 + (index * 20), LabelHue, craftItem.NameString );
|
||||
|
||||
AddButton( 480, 60 + (index * 20), 4011, 4012, GetButtonID( 4, i ), GumpButtonType.Reply, 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: This is not as OSI; it is an intentional difference
|
||||
|
||||
AddHtmlLocalized( 230, 62, 200, 22, 1044165, LabelColor, false, false ); // You haven't made anything yet.
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateItemList( int selectedGroup )
|
||||
{
|
||||
if ( selectedGroup == 501 ) // 501 : Last 10
|
||||
{
|
||||
CreateMakeLastList();
|
||||
return;
|
||||
}
|
||||
|
||||
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
|
||||
CraftGroup craftGroup = craftGroupCol.GetAt( selectedGroup );
|
||||
CraftItemCol craftItemCol = craftGroup.CraftItems;
|
||||
|
||||
for ( int i = 0; i < craftItemCol.Count; ++i )
|
||||
{
|
||||
int index = i % 10;
|
||||
|
||||
CraftItem craftItem = craftItemCol.GetAt( i );
|
||||
|
||||
if ( index == 0 )
|
||||
{
|
||||
if ( i > 0 )
|
||||
{
|
||||
AddButton( 370, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1 );
|
||||
AddHtmlLocalized( 405, 263, 100, 18, 1044045, LabelColor, false, false ); // NEXT PAGE
|
||||
}
|
||||
|
||||
AddPage( (i / 10) + 1 );
|
||||
|
||||
if ( i > 0 )
|
||||
{
|
||||
AddButton( 220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10 );
|
||||
AddHtmlLocalized( 255, 263, 100, 18, 1044044, LabelColor, false, false ); // PREV PAGE
|
||||
}
|
||||
}
|
||||
|
||||
AddButton( 220, 60 + (index * 20), 4005, 4007, GetButtonID( 1, i ), GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( craftItem.NameNumber > 0 )
|
||||
AddHtmlLocalized( 255, 63 + (index * 20), 220, 18, craftItem.NameNumber, LabelColor, false, false );
|
||||
else
|
||||
AddLabel( 255, 60 + (index * 20), LabelHue, craftItem.NameString );
|
||||
|
||||
AddButton( 480, 60 + (index * 20), 4011, 4012, GetButtonID( 2, i ), GumpButtonType.Reply, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
public int CreateGroupList()
|
||||
{
|
||||
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
|
||||
|
||||
AddButton( 15, 60, 4005, 4007, GetButtonID( 6, 3 ), GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 50, 63, 150, 18, 1044014, LabelColor, false, false ); // LAST TEN
|
||||
|
||||
for ( int i = 0; i < craftGroupCol.Count; i++ )
|
||||
{
|
||||
CraftGroup craftGroup = craftGroupCol.GetAt( i );
|
||||
|
||||
AddButton( 15, 80 + (i * 20), 4005, 4007, GetButtonID( 0, i ), GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( craftGroup.NameNumber > 0 )
|
||||
AddHtmlLocalized( 50, 83 + (i * 20), 150, 18, craftGroup.NameNumber, LabelColor, false, false );
|
||||
else
|
||||
AddLabel( 50, 80 + (i * 20), LabelHue, craftGroup.NameString );
|
||||
}
|
||||
|
||||
return craftGroupCol.Count;
|
||||
}
|
||||
|
||||
public static int GetButtonID( int type, int index )
|
||||
{
|
||||
return 1 + type + (index * 7);
|
||||
}
|
||||
|
||||
public void CraftItem( CraftItem item )
|
||||
{
|
||||
int num = m_CraftSystem.CanCraft( m_From, m_Tool, item.ItemType );
|
||||
|
||||
if ( num > 0 )
|
||||
{
|
||||
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, num ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Type type = null;
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext( m_From );
|
||||
|
||||
if ( context != null )
|
||||
{
|
||||
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
|
||||
int resIndex = ( context.LastResourceIndex );
|
||||
|
||||
if ( resIndex >= 0 && resIndex < res.Count )
|
||||
type = res.GetAt( resIndex ).ItemType;
|
||||
}
|
||||
|
||||
m_CraftSystem.CreateItem( m_From, item.ItemType, type, m_Tool, item );
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID <= 0 )
|
||||
return; // Canceled
|
||||
|
||||
int buttonID = info.ButtonID - 1;
|
||||
int type = buttonID % 7;
|
||||
int index = buttonID / 7;
|
||||
|
||||
CraftSystem system = m_CraftSystem;
|
||||
CraftGroupCol groups = system.CraftGroups;
|
||||
CraftContext context = system.GetContext( m_From );
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case 0: // Show group
|
||||
{
|
||||
if ( context == null )
|
||||
break;
|
||||
|
||||
if ( index >= 0 && index < groups.Count )
|
||||
{
|
||||
context.LastGroupIndex = index;
|
||||
m_From.SendGump( new CraftGump( m_From, system, m_Tool, null ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // Create item
|
||||
{
|
||||
if ( context == null )
|
||||
break;
|
||||
|
||||
int groupIndex = context.LastGroupIndex;
|
||||
|
||||
if ( groupIndex >= 0 && groupIndex < groups.Count )
|
||||
{
|
||||
CraftGroup group = groups.GetAt( groupIndex );
|
||||
|
||||
if ( index >= 0 && index < group.CraftItems.Count )
|
||||
CraftItem( group.CraftItems.GetAt( index ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Item details
|
||||
{
|
||||
if ( context == null )
|
||||
break;
|
||||
|
||||
int groupIndex = context.LastGroupIndex;
|
||||
|
||||
if ( groupIndex >= 0 && groupIndex < groups.Count )
|
||||
{
|
||||
CraftGroup group = groups.GetAt( groupIndex );
|
||||
|
||||
if ( index >= 0 && index < group.CraftItems.Count )
|
||||
m_From.SendGump( new CraftGumpItem( m_From, system, group.CraftItems.GetAt( index ), m_Tool ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Create item (last 10)
|
||||
{
|
||||
if ( context == null )
|
||||
break;
|
||||
|
||||
List<CraftItem> lastTen = context.Items;
|
||||
|
||||
if ( index >= 0 && index < lastTen.Count )
|
||||
CraftItem( lastTen[index] );
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Item details (last 10)
|
||||
{
|
||||
if ( context == null )
|
||||
break;
|
||||
|
||||
List<CraftItem> lastTen = context.Items;
|
||||
|
||||
if ( index >= 0 && index < lastTen.Count )
|
||||
m_From.SendGump( new CraftGumpItem( m_From, system, lastTen[index], m_Tool ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // Resource selected
|
||||
{
|
||||
if ( m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count )
|
||||
{
|
||||
int groupIndex = ( context == null ? -1 : context.LastGroupIndex );
|
||||
|
||||
CraftSubRes res = system.CraftSubRes.GetAt( index );
|
||||
|
||||
if ( SkillCheck.TradeSkill( m_From, system.MainSkill, false ) < res.RequiredSkill )
|
||||
{
|
||||
m_From.SendGump( new CraftGump( m_From, system, m_Tool, res.Message ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( context != null )
|
||||
context.LastResourceIndex = index;
|
||||
|
||||
m_From.SendGump( new CraftGump( m_From, system, m_Tool, null ) );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 6: // Misc. buttons
|
||||
{
|
||||
switch ( index )
|
||||
{
|
||||
case 0: // Resource selection
|
||||
{
|
||||
if ( system.CraftSubRes.Init )
|
||||
m_From.SendGump( new CraftGump( m_From, system, m_Tool, null, CraftPage.PickResource ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // Smelt item
|
||||
{
|
||||
if ( system.Resmelt )
|
||||
Resmelt.Do( m_From, system, m_Tool );
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Make last
|
||||
{
|
||||
if ( context == null )
|
||||
break;
|
||||
|
||||
CraftItem item = context.LastMade;
|
||||
|
||||
if ( item != null )
|
||||
CraftItem( item );
|
||||
else
|
||||
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, 1044165, m_Page ) ); // You haven't made anything yet.
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Last 10
|
||||
{
|
||||
if ( context == null )
|
||||
break;
|
||||
|
||||
context.LastGroupIndex = 501;
|
||||
m_From.SendGump( new CraftGump( m_From, system, m_Tool, null ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Toggle use resource hue
|
||||
{
|
||||
if ( context == null )
|
||||
break;
|
||||
|
||||
context.DoNotColor = !context.DoNotColor;
|
||||
|
||||
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, null, m_Page ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // Repair item
|
||||
{
|
||||
if ( system.Repair )
|
||||
Repair.Do( m_From, system, m_Tool );
|
||||
|
||||
break;
|
||||
}
|
||||
case 6: // Toggle mark option
|
||||
{
|
||||
if ( context == null || !system.MarkOption )
|
||||
break;
|
||||
|
||||
switch ( context.MarkOption )
|
||||
{
|
||||
case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break;
|
||||
case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break;
|
||||
case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break;
|
||||
}
|
||||
|
||||
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, null, m_Page ) );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
244
Scripts/Engines/Craft/Core/CraftGumpItem.cs
Normal file
244
Scripts/Engines/Craft/Core/CraftGumpItem.cs
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Items;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftGumpItem : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private CraftSystem m_CraftSystem;
|
||||
private CraftItem m_CraftItem;
|
||||
private BaseTool m_Tool;
|
||||
|
||||
private const int LabelHue = 0x480; // 0x384
|
||||
private const int RedLabelHue = 0x20;
|
||||
|
||||
private const int LabelColor = 0x7FFF;
|
||||
private const int RedLabelColor = 0x6400;
|
||||
|
||||
private const int GreyLabelColor = 0x3DEF;
|
||||
|
||||
private int m_OtherCount;
|
||||
|
||||
public CraftGumpItem( Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool ) : base( 40, 40 )
|
||||
{
|
||||
m_From = from;
|
||||
m_CraftSystem = craftSystem;
|
||||
m_CraftItem = craftItem;
|
||||
m_Tool = tool;
|
||||
|
||||
from.CloseGump( typeof( CraftGump ) );
|
||||
from.CloseGump( typeof( CraftGumpItem ) );
|
||||
|
||||
AddPage( 0 );
|
||||
AddBackground( 0, 0, 530, 417, 5054 );
|
||||
AddImageTiled( 10, 10, 510, 22, 2624 );
|
||||
AddImageTiled( 10, 37, 150, 148, 2624 );
|
||||
AddImageTiled( 165, 37, 355, 90, 2624 );
|
||||
AddImageTiled( 10, 190, 155, 22, 2624 );
|
||||
AddImageTiled( 10, 217, 150, 53, 2624 );
|
||||
AddImageTiled( 165, 132, 355, 80, 2624 );
|
||||
AddImageTiled( 10, 275, 155, 22, 2624 );
|
||||
AddImageTiled( 10, 302, 150, 53, 2624 );
|
||||
AddImageTiled( 165, 217, 355, 80, 2624 );
|
||||
AddImageTiled( 10, 360, 155, 22, 2624 );
|
||||
AddImageTiled( 165, 302, 355, 80, 2624 );
|
||||
AddImageTiled( 10, 387, 510, 22, 2624 );
|
||||
AddAlphaRegion( 10, 10, 510, 399 );
|
||||
|
||||
AddHtmlLocalized( 170, 40, 150, 20, 1044053, LabelColor, false, false ); // ITEM
|
||||
AddHtmlLocalized( 10, 192, 150, 22, 1044054, LabelColor, false, false ); // <CENTER>SKILLS</CENTER>
|
||||
AddHtmlLocalized( 10, 277, 150, 22, 1044055, LabelColor, false, false ); // <CENTER>MATERIALS</CENTER>
|
||||
AddHtmlLocalized( 10, 362, 150, 22, 1044056, LabelColor, false, false ); // <CENTER>OTHER</CENTER>
|
||||
|
||||
if ( craftSystem.GumpTitleNumber > 0 )
|
||||
AddHtmlLocalized( 10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false );
|
||||
else
|
||||
AddHtml( 10, 12, 510, 20, craftSystem.GumpTitleString, false, false );
|
||||
|
||||
AddButton( 15, 387, 4014, 4016, 0, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 50, 390, 150, 18, 1044150, LabelColor, false, false ); // BACK
|
||||
|
||||
AddButton( 270, 387, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 305, 390, 150, 18, 1044151, LabelColor, false, false ); // MAKE NOW
|
||||
|
||||
if ( craftItem.NameNumber > 0 )
|
||||
AddHtmlLocalized( 330, 40, 180, 18, craftItem.NameNumber, LabelColor, false, false );
|
||||
else
|
||||
AddLabel( 330, 40, LabelHue, craftItem.NameString );
|
||||
|
||||
if ( craftItem.UseAllRes )
|
||||
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1048176, LabelColor, false, false ); // Makes as many as possible at once
|
||||
|
||||
DrawItem();
|
||||
DrawSkill();
|
||||
DrawResource();
|
||||
}
|
||||
|
||||
private bool m_ShowExceptionalChance;
|
||||
|
||||
public void DrawItem()
|
||||
{
|
||||
Type type = m_CraftItem.ItemType;
|
||||
|
||||
AddItem( 20, 50, CraftItem.ItemIDOf( type ) );
|
||||
|
||||
if ( m_CraftItem.IsMarkable( type ) )
|
||||
{
|
||||
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1044059, LabelColor, false, false ); // This item may hold its maker's mark
|
||||
m_ShowExceptionalChance = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawSkill()
|
||||
{
|
||||
for ( int i = 0; i < m_CraftItem.Skills.Count; i++ )
|
||||
{
|
||||
CraftSkill skill = m_CraftItem.Skills.GetAt( i );
|
||||
double minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;
|
||||
|
||||
if ( minSkill < 0 )
|
||||
minSkill = 0;
|
||||
|
||||
AddLabel( 170, 132 + (i * 20), LabelHue, SkillCheck.TradeName( skill.SkillToMake ) );
|
||||
AddLabel( 430, 132 + (i * 20), LabelHue, String.Format( "{0:F1}", minSkill ) );
|
||||
}
|
||||
|
||||
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
|
||||
int resIndex = -1;
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext( m_From );
|
||||
|
||||
if ( context != null )
|
||||
resIndex = ( context.LastResourceIndex );
|
||||
|
||||
bool allRequiredSkills = true;
|
||||
double chance = m_CraftItem.GetSuccessChance( m_From, resIndex > -1 ? res.GetAt( resIndex ).ItemType : null, m_CraftSystem, ref allRequiredSkills );
|
||||
double excepChance = m_CraftItem.GetExceptionalChance( m_CraftSystem, chance, m_From );
|
||||
|
||||
if ( chance < 0.0 )
|
||||
chance = 0.0;
|
||||
else if ( chance > 1.0 )
|
||||
chance = 1.0;
|
||||
|
||||
AddHtmlLocalized( 170, 80, 250, 18, 1044057, LabelColor, false, false ); // Success Chance:
|
||||
AddLabel( 430, 80, LabelHue, String.Format( "{0:F1}%", chance * 100 ) );
|
||||
|
||||
if ( m_ShowExceptionalChance )
|
||||
{
|
||||
if( excepChance < 0.0 )
|
||||
excepChance = 0.0;
|
||||
else if( excepChance > 1.0 )
|
||||
excepChance = 1.0;
|
||||
|
||||
AddHtmlLocalized( 170, 100, 250, 18, 1044058, 32767, false, false ); // Exceptional Chance:
|
||||
AddLabel( 430, 100, LabelHue, String.Format( "{0:F1}%", excepChance * 100 ) );
|
||||
}
|
||||
}
|
||||
|
||||
private static Type typeofBlankScroll = typeof( BlankScroll );
|
||||
private static Type typeofSpellScroll = typeof( SpellScroll );
|
||||
|
||||
public void DrawResource()
|
||||
{
|
||||
bool retainedColor = false;
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext( m_From );
|
||||
|
||||
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
|
||||
int resIndex = -1;
|
||||
|
||||
if ( context != null )
|
||||
resIndex = ( context.LastResourceIndex );
|
||||
|
||||
bool cropScroll = ( m_CraftItem.Resources.Count > 1 )
|
||||
&& m_CraftItem.Resources.GetAt( m_CraftItem.Resources.Count - 1 ).ItemType == typeofBlankScroll
|
||||
&& typeofSpellScroll.IsAssignableFrom( m_CraftItem.ItemType );
|
||||
|
||||
for ( int i = 0; i < m_CraftItem.Resources.Count - (cropScroll ? 1 : 0) && i < 4; i++ )
|
||||
{
|
||||
Type type;
|
||||
string nameString;
|
||||
int nameNumber;
|
||||
|
||||
CraftRes craftResource = m_CraftItem.Resources.GetAt( i );
|
||||
|
||||
type = craftResource.ItemType;
|
||||
nameString = craftResource.NameString;
|
||||
nameNumber = craftResource.NameNumber;
|
||||
|
||||
// Resource Mutation
|
||||
if ( type == res.ResType && resIndex > -1 )
|
||||
{
|
||||
CraftSubRes subResource = res.GetAt( resIndex );
|
||||
|
||||
type = subResource.ItemType;
|
||||
|
||||
nameString = subResource.NameString;
|
||||
nameNumber = subResource.GenericNameNumber;
|
||||
|
||||
if ( nameNumber <= 0 )
|
||||
nameNumber = subResource.NameNumber;
|
||||
}
|
||||
// ******************
|
||||
|
||||
if ( !retainedColor && m_CraftItem.RetainsColorFrom( m_CraftSystem, type ) )
|
||||
{
|
||||
retainedColor = true;
|
||||
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1044152, LabelColor, false, false ); // * The item retains the color of this material
|
||||
AddLabel( 500, 219 + (i * 20), LabelHue, "*" );
|
||||
}
|
||||
|
||||
if ( nameNumber > 0 )
|
||||
AddHtmlLocalized( 170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false );
|
||||
else
|
||||
AddLabel( 170, 219 + (i * 20), LabelHue, nameString );
|
||||
|
||||
AddLabel( 430, 219 + (i * 20), LabelHue, craftResource.Amount.ToString() );
|
||||
}
|
||||
|
||||
if ( cropScroll )
|
||||
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 360, 18, 1044379, LabelColor, false, false ); // Inscribing scrolls also requires a blank scroll and mana.
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
// Back Button
|
||||
if ( info.ButtonID == 0 )
|
||||
{
|
||||
CraftGump craftGump = new CraftGump( m_From, m_CraftSystem, m_Tool, null );
|
||||
m_From.SendGump( craftGump );
|
||||
}
|
||||
else // Make Button
|
||||
{
|
||||
int num = m_CraftSystem.CanCraft( m_From, m_Tool, m_CraftItem.ItemType );
|
||||
|
||||
if ( num > 0 )
|
||||
{
|
||||
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, num ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Type type = null;
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext( m_From );
|
||||
|
||||
if ( context != null )
|
||||
{
|
||||
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
|
||||
int resIndex = ( context.LastResourceIndex );
|
||||
|
||||
if ( resIndex > -1 )
|
||||
type = res.GetAt( resIndex ).ItemType;
|
||||
}
|
||||
|
||||
m_CraftSystem.CreateItem( m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1161
Scripts/Engines/Craft/Core/CraftItem.cs
Normal file
1161
Scripts/Engines/Craft/Core/CraftItem.cs
Normal file
File diff suppressed because it is too large
Load diff
58
Scripts/Engines/Craft/Core/CraftItemCol.cs
Normal file
58
Scripts/Engines/Craft/Core/CraftItemCol.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftItemCol : System.Collections.CollectionBase
|
||||
{
|
||||
public CraftItemCol()
|
||||
{
|
||||
}
|
||||
|
||||
public int Add( CraftItem craftItem )
|
||||
{
|
||||
return List.Add( craftItem );
|
||||
}
|
||||
|
||||
public void Remove( int index )
|
||||
{
|
||||
if ( index > Count - 1 || index < 0 )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
List.RemoveAt( index );
|
||||
}
|
||||
}
|
||||
|
||||
public CraftItem GetAt( int index )
|
||||
{
|
||||
return ( CraftItem ) List[index];
|
||||
}
|
||||
|
||||
public CraftItem SearchForSubclass( Type type )
|
||||
{
|
||||
for ( int i = 0; i < List.Count; i++ )
|
||||
{
|
||||
CraftItem craftItem = ( CraftItem )List[i];
|
||||
|
||||
if ( craftItem.ItemType == type || type.IsSubclassOf( craftItem.ItemType ) )
|
||||
return craftItem;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CraftItem SearchFor( Type type )
|
||||
{
|
||||
for ( int i = 0; i < List.Count; i++ )
|
||||
{
|
||||
CraftItem craftItem = ( CraftItem )List[i];
|
||||
if ( craftItem.ItemType == type )
|
||||
{
|
||||
return craftItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Scripts/Engines/Craft/Core/CraftItemIDAttribute.cs
Normal file
18
Scripts/Engines/Craft/Core/CraftItemIDAttribute.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
[AttributeUsage( AttributeTargets.Class )]
|
||||
public class CraftItemIDAttribute : Attribute
|
||||
{
|
||||
private int m_ItemID;
|
||||
|
||||
public int ItemID{ get{ return m_ItemID; } }
|
||||
|
||||
public CraftItemIDAttribute( int itemID )
|
||||
{
|
||||
m_ItemID = itemID;
|
||||
}
|
||||
}
|
||||
}
|
||||
71
Scripts/Engines/Craft/Core/CraftRes.cs
Normal file
71
Scripts/Engines/Craft/Core/CraftRes.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftRes
|
||||
{
|
||||
private Type m_Type;
|
||||
private int m_Amount;
|
||||
|
||||
private string m_MessageString;
|
||||
private int m_MessageNumber;
|
||||
|
||||
private string m_NameString;
|
||||
private int m_NameNumber;
|
||||
|
||||
public CraftRes( Type type, int amount )
|
||||
{
|
||||
m_Type = type;
|
||||
m_Amount = amount;
|
||||
}
|
||||
|
||||
public CraftRes( Type type, TextDefinition name, int amount, TextDefinition message ): this ( type, amount )
|
||||
{
|
||||
m_NameNumber = name;
|
||||
m_MessageNumber = message;
|
||||
|
||||
m_NameString = name;
|
||||
m_MessageString = message;
|
||||
}
|
||||
|
||||
public void SendMessage( Mobile from )
|
||||
{
|
||||
if ( m_MessageNumber > 0 )
|
||||
from.SendLocalizedMessage( m_MessageNumber );
|
||||
else if ( !String.IsNullOrEmpty( m_MessageString ) )
|
||||
from.SendMessage( m_MessageString );
|
||||
else
|
||||
from.SendLocalizedMessage( 502925 ); // You don't have the resources required to make that item.
|
||||
}
|
||||
|
||||
public Type ItemType
|
||||
{
|
||||
get { return m_Type; }
|
||||
}
|
||||
|
||||
public string MessageString
|
||||
{
|
||||
get { return m_MessageString; }
|
||||
}
|
||||
|
||||
public int MessageNumber
|
||||
{
|
||||
get { return m_MessageNumber; }
|
||||
}
|
||||
|
||||
public string NameString
|
||||
{
|
||||
get { return m_NameString; }
|
||||
}
|
||||
|
||||
public int NameNumber
|
||||
{
|
||||
get { return m_NameNumber; }
|
||||
}
|
||||
|
||||
public int Amount
|
||||
{
|
||||
get { return m_Amount; }
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Scripts/Engines/Craft/Core/CraftResCol.cs
Normal file
32
Scripts/Engines/Craft/Core/CraftResCol.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftResCol : System.Collections.CollectionBase
|
||||
{
|
||||
public CraftResCol()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add( CraftRes craftRes )
|
||||
{
|
||||
List.Add( craftRes );
|
||||
}
|
||||
|
||||
public void Remove( int index )
|
||||
{
|
||||
if ( index > Count - 1 || index < 0 )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
List.RemoveAt( index );
|
||||
}
|
||||
}
|
||||
|
||||
public CraftRes GetAt( int index )
|
||||
{
|
||||
return ( CraftRes ) List[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Scripts/Engines/Craft/Core/CraftSkill.cs
Normal file
34
Scripts/Engines/Craft/Core/CraftSkill.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftSkill
|
||||
{
|
||||
private Trades m_SkillToMake;
|
||||
private double m_MinSkill;
|
||||
private double m_MaxSkill;
|
||||
|
||||
public CraftSkill( Trades skillToMake, double minSkill, double maxSkill )
|
||||
{
|
||||
m_SkillToMake = skillToMake;
|
||||
m_MinSkill = minSkill;
|
||||
m_MaxSkill = maxSkill;
|
||||
}
|
||||
|
||||
public Trades SkillToMake
|
||||
{
|
||||
get { return m_SkillToMake; }
|
||||
}
|
||||
|
||||
public double MinSkill
|
||||
{
|
||||
get { return m_MinSkill; }
|
||||
}
|
||||
|
||||
public double MaxSkill
|
||||
{
|
||||
get { return m_MaxSkill; }
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Scripts/Engines/Craft/Core/CraftSkillCol.cs
Normal file
32
Scripts/Engines/Craft/Core/CraftSkillCol.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftSkillCol : System.Collections.CollectionBase
|
||||
{
|
||||
public CraftSkillCol()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add( CraftSkill craftSkill )
|
||||
{
|
||||
List.Add( craftSkill );
|
||||
}
|
||||
|
||||
public void Remove( int index )
|
||||
{
|
||||
if ( index > Count - 1 || index < 0 )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
List.RemoveAt( index );
|
||||
}
|
||||
}
|
||||
|
||||
public CraftSkill GetAt( int index )
|
||||
{
|
||||
return ( CraftSkill ) List[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Scripts/Engines/Craft/Core/CraftSubRes.cs
Normal file
58
Scripts/Engines/Craft/Core/CraftSubRes.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftSubRes
|
||||
{
|
||||
private Type m_Type;
|
||||
private double m_ReqSkill;
|
||||
private string m_NameString;
|
||||
private int m_NameNumber;
|
||||
private int m_GenericNameNumber;
|
||||
private object m_Message;
|
||||
|
||||
public CraftSubRes( Type type, TextDefinition name, double reqSkill, object message ) : this( type, name, reqSkill, 0, message )
|
||||
{
|
||||
}
|
||||
|
||||
public CraftSubRes( Type type, TextDefinition name, double reqSkill, int genericNameNumber, object message )
|
||||
{
|
||||
m_Type = type;
|
||||
m_NameNumber = name;
|
||||
m_NameString = name;
|
||||
m_ReqSkill = reqSkill;
|
||||
m_GenericNameNumber = genericNameNumber;
|
||||
m_Message = message;
|
||||
}
|
||||
|
||||
public Type ItemType
|
||||
{
|
||||
get { return m_Type; }
|
||||
}
|
||||
|
||||
public string NameString
|
||||
{
|
||||
get { return m_NameString; }
|
||||
}
|
||||
|
||||
public int NameNumber
|
||||
{
|
||||
get { return m_NameNumber; }
|
||||
}
|
||||
|
||||
public int GenericNameNumber
|
||||
{
|
||||
get { return m_GenericNameNumber; }
|
||||
}
|
||||
|
||||
public object Message
|
||||
{
|
||||
get { return m_Message; }
|
||||
}
|
||||
|
||||
public double RequiredSkill
|
||||
{
|
||||
get { return m_ReqSkill; }
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Scripts/Engines/Craft/Core/CraftSubResCol.cs
Normal file
75
Scripts/Engines/Craft/Core/CraftSubResCol.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftSubResCol : System.Collections.CollectionBase
|
||||
{
|
||||
private Type m_Type;
|
||||
private string m_NameString;
|
||||
private int m_NameNumber;
|
||||
private bool m_Init;
|
||||
|
||||
public bool Init
|
||||
{
|
||||
get { return m_Init; }
|
||||
set { m_Init = value; }
|
||||
}
|
||||
|
||||
public Type ResType
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { m_Type = value; }
|
||||
}
|
||||
|
||||
public string NameString
|
||||
{
|
||||
get { return m_NameString; }
|
||||
set { m_NameString = value; }
|
||||
}
|
||||
|
||||
public int NameNumber
|
||||
{
|
||||
get { return m_NameNumber; }
|
||||
set { m_NameNumber = value; }
|
||||
}
|
||||
|
||||
public CraftSubResCol()
|
||||
{
|
||||
m_Init = false;
|
||||
}
|
||||
|
||||
public void Add( CraftSubRes craftSubRes )
|
||||
{
|
||||
List.Add( craftSubRes );
|
||||
}
|
||||
|
||||
public void Remove( int index )
|
||||
{
|
||||
if ( index > Count - 1 || index < 0 )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
List.RemoveAt( index );
|
||||
}
|
||||
}
|
||||
|
||||
public CraftSubRes GetAt( int index )
|
||||
{
|
||||
return ( CraftSubRes ) List[index];
|
||||
}
|
||||
|
||||
public CraftSubRes SearchFor( Type type )
|
||||
{
|
||||
for ( int i = 0; i < List.Count; i++ )
|
||||
{
|
||||
CraftSubRes craftSubRes = ( CraftSubRes )List[i];
|
||||
if ( craftSubRes.ItemType == type )
|
||||
{
|
||||
return craftSubRes;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
283
Scripts/Engines/Craft/Core/CraftSystem.cs
Normal file
283
Scripts/Engines/Craft/Core/CraftSystem.cs
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public enum CraftECA
|
||||
{
|
||||
ChanceMinusSixty,
|
||||
FiftyPercentChanceMinusTenPercent,
|
||||
ChanceMinusSixtyToFourtyFive
|
||||
}
|
||||
|
||||
public abstract class CraftSystem
|
||||
{
|
||||
private int m_MinCraftEffect;
|
||||
private int m_MaxCraftEffect;
|
||||
private double m_Delay;
|
||||
private bool m_Resmelt;
|
||||
private bool m_Repair;
|
||||
private bool m_MarkOption;
|
||||
|
||||
private CraftItemCol m_CraftItems;
|
||||
private CraftGroupCol m_CraftGroups;
|
||||
private CraftSubResCol m_CraftSubRes;
|
||||
|
||||
public int MinCraftEffect { get { return m_MinCraftEffect; } }
|
||||
public int MaxCraftEffect { get { return m_MaxCraftEffect; } }
|
||||
public double Delay { get { return m_Delay; } }
|
||||
|
||||
public CraftItemCol CraftItems{ get { return m_CraftItems; } }
|
||||
public CraftGroupCol CraftGroups{ get { return m_CraftGroups; } }
|
||||
public CraftSubResCol CraftSubRes{ get { return m_CraftSubRes; } }
|
||||
|
||||
public abstract Trades MainSkill{ get; }
|
||||
|
||||
public virtual int GumpTitleNumber{ get{ return 0; } }
|
||||
public virtual string GumpTitleString{ get{ return ""; } }
|
||||
|
||||
public virtual CraftECA ECA{ get{ return CraftECA.ChanceMinusSixty; } }
|
||||
|
||||
private Dictionary<Mobile, CraftContext> m_ContextTable = new Dictionary<Mobile, CraftContext>();
|
||||
|
||||
public abstract double GetChanceAtMin( CraftItem item );
|
||||
|
||||
public virtual bool RetainsColorFrom( CraftItem item, Type type )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public CraftContext GetContext( Mobile m )
|
||||
{
|
||||
if ( m == null )
|
||||
return null;
|
||||
|
||||
if ( m.Deleted )
|
||||
{
|
||||
m_ContextTable.Remove( m );
|
||||
return null;
|
||||
}
|
||||
|
||||
CraftContext c = null;
|
||||
m_ContextTable.TryGetValue( m, out c );
|
||||
|
||||
if ( c == null )
|
||||
m_ContextTable[m] = c = new CraftContext();
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public void OnMade( Mobile m, CraftItem item )
|
||||
{
|
||||
CraftContext c = GetContext( m );
|
||||
|
||||
if ( c != null )
|
||||
c.OnMade( item );
|
||||
}
|
||||
|
||||
public bool Resmelt
|
||||
{
|
||||
get { return m_Resmelt; }
|
||||
set { m_Resmelt = value; }
|
||||
}
|
||||
|
||||
public bool Repair
|
||||
{
|
||||
get{ return m_Repair; }
|
||||
set{ m_Repair = value; }
|
||||
}
|
||||
|
||||
public bool MarkOption
|
||||
{
|
||||
get{ return m_MarkOption; }
|
||||
set{ m_MarkOption = value; }
|
||||
}
|
||||
|
||||
public CraftSystem( int minCraftEffect, int maxCraftEffect, double delay )
|
||||
{
|
||||
m_MinCraftEffect = minCraftEffect;
|
||||
m_MaxCraftEffect = maxCraftEffect;
|
||||
m_Delay = delay;
|
||||
|
||||
m_CraftItems = new CraftItemCol();
|
||||
m_CraftGroups = new CraftGroupCol();
|
||||
m_CraftSubRes = new CraftSubResCol();
|
||||
|
||||
InitCraftList();
|
||||
}
|
||||
|
||||
public virtual bool ConsumeOnFailure( Mobile from, Type resourceType, CraftItem craftItem )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void CreateItem( Mobile from, Type type, Type typeRes, BaseTool tool, CraftItem realCraftItem )
|
||||
{
|
||||
// Verify if the type is in the list of the craftable item
|
||||
CraftItem craftItem = m_CraftItems.SearchFor( type );
|
||||
if ( craftItem != null )
|
||||
{
|
||||
// The item is in the list, try to create it
|
||||
// Test code: items like sextant parts can be crafted either directly from ingots, or from different parts
|
||||
realCraftItem.Craft( from, this, typeRes, tool );
|
||||
//craftItem.Craft( from, this, typeRes, tool );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int AddCraft( Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount )
|
||||
{
|
||||
return AddCraft( typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, "" );
|
||||
}
|
||||
|
||||
public int AddCraft( Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount, TextDefinition message )
|
||||
{
|
||||
return AddCraft( typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, message );
|
||||
}
|
||||
|
||||
public int AddCraft( Type typeItem, TextDefinition group, TextDefinition name, Trades skillToMake, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount )
|
||||
{
|
||||
return AddCraft( typeItem, group, name, skillToMake, minSkill, maxSkill, typeRes, nameRes, amount, "" );
|
||||
}
|
||||
|
||||
public int AddCraft( Type typeItem, TextDefinition group, TextDefinition name, Trades skillToMake, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount, TextDefinition message )
|
||||
{
|
||||
CraftItem craftItem = new CraftItem( typeItem, group, name );
|
||||
craftItem.AddRes( typeRes, nameRes, amount, message );
|
||||
craftItem.AddSkill( skillToMake, minSkill, maxSkill );
|
||||
|
||||
DoGroup( group, craftItem );
|
||||
return m_CraftItems.Add( craftItem );
|
||||
}
|
||||
|
||||
|
||||
private void DoGroup( TextDefinition groupName, CraftItem craftItem )
|
||||
{
|
||||
int index = m_CraftGroups.SearchFor( groupName );
|
||||
|
||||
if ( index == -1)
|
||||
{
|
||||
CraftGroup craftGroup = new CraftGroup( groupName );
|
||||
craftGroup.AddCraftItem( craftItem );
|
||||
m_CraftGroups.Add( craftGroup );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CraftGroups.GetAt( index ).AddCraftItem( craftItem );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetManaReq( int index, int mana )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.Mana = mana;
|
||||
}
|
||||
|
||||
public void SetStamReq( int index, int stam )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.Stam = stam;
|
||||
}
|
||||
|
||||
public void SetHitsReq( int index, int hits )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.Hits = hits;
|
||||
}
|
||||
|
||||
public void SetUseAllRes( int index, bool useAll )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.UseAllRes = useAll;
|
||||
}
|
||||
|
||||
public void SetNeedHeat( int index, bool needHeat )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.NeedHeat = needHeat;
|
||||
}
|
||||
|
||||
public void SetNeedOven( int index, bool needOven )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.NeedOven = needOven;
|
||||
}
|
||||
|
||||
public void SetNeedMill( int index, bool needMill )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.NeedMill = needMill;
|
||||
}
|
||||
|
||||
public void SetNeededExpansion( int index, Expansion expansion )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.RequiredExpansion = expansion;
|
||||
}
|
||||
|
||||
public void AddRes( int index, Type type, TextDefinition name, int amount )
|
||||
{
|
||||
AddRes( index, type, name, amount, "" );
|
||||
}
|
||||
|
||||
public void AddRes( int index, Type type, TextDefinition name, int amount, TextDefinition message )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.AddRes( type, name, amount, message );
|
||||
}
|
||||
|
||||
public void AddSkill( int index, Trades skillToMake, double minSkill, double maxSkill )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.AddSkill(skillToMake, minSkill, maxSkill);
|
||||
}
|
||||
|
||||
public void ForceNonExceptional( int index )
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt( index );
|
||||
craftItem.ForceNonExceptional = true;
|
||||
}
|
||||
|
||||
public void SetSubRes( Type type, string name )
|
||||
{
|
||||
m_CraftSubRes.ResType = type;
|
||||
m_CraftSubRes.NameString = name;
|
||||
m_CraftSubRes.Init = true;
|
||||
}
|
||||
|
||||
public void SetSubRes( Type type, int name )
|
||||
{
|
||||
m_CraftSubRes.ResType = type;
|
||||
m_CraftSubRes.NameNumber = name;
|
||||
m_CraftSubRes.Init = true;
|
||||
}
|
||||
|
||||
public void AddSubRes( Type type, int name, double reqSkill, object message )
|
||||
{
|
||||
CraftSubRes craftSubRes = new CraftSubRes( type, name, reqSkill, message );
|
||||
m_CraftSubRes.Add( craftSubRes );
|
||||
}
|
||||
|
||||
public void AddSubRes( Type type, int name, double reqSkill, int genericName, object message )
|
||||
{
|
||||
CraftSubRes craftSubRes = new CraftSubRes( type, name, reqSkill, genericName, message );
|
||||
m_CraftSubRes.Add( craftSubRes );
|
||||
}
|
||||
|
||||
public void AddSubRes( Type type, string name, double reqSkill, object message )
|
||||
{
|
||||
CraftSubRes craftSubRes = new CraftSubRes( type, name, reqSkill, message );
|
||||
m_CraftSubRes.Add( craftSubRes );
|
||||
}
|
||||
|
||||
public abstract void InitCraftList();
|
||||
|
||||
public abstract void PlayCraftEffect( Mobile from );
|
||||
public abstract int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item );
|
||||
|
||||
public abstract int CanCraft( Mobile from, BaseTool tool, Type itemType );
|
||||
}
|
||||
}
|
||||
36
Scripts/Engines/Craft/Core/CustomCraft.cs
Normal file
36
Scripts/Engines/Craft/Core/CustomCraft.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public abstract class CustomCraft
|
||||
{
|
||||
private Mobile m_From;
|
||||
private CraftItem m_CraftItem;
|
||||
private CraftSystem m_CraftSystem;
|
||||
private Type m_TypeRes;
|
||||
private BaseTool m_Tool;
|
||||
private int m_Quality;
|
||||
|
||||
public Mobile From{ get{ return m_From; } }
|
||||
public CraftItem CraftItem{ get{ return m_CraftItem; } }
|
||||
public CraftSystem CraftSystem{ get{ return m_CraftSystem; } }
|
||||
public Type TypeRes{ get{ return m_TypeRes; } }
|
||||
public BaseTool Tool{ get{ return m_Tool; } }
|
||||
public int Quality{ get{ return m_Quality; } }
|
||||
|
||||
public CustomCraft( Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, BaseTool tool, int quality )
|
||||
{
|
||||
m_From = from;
|
||||
m_CraftItem = craftItem;
|
||||
m_CraftSystem = craftSystem;
|
||||
m_TypeRes = typeRes;
|
||||
m_Tool = tool;
|
||||
m_Quality = quality;
|
||||
}
|
||||
|
||||
public abstract void EndCraftAction();
|
||||
public abstract Item CompleteCraft( out int message );
|
||||
}
|
||||
}
|
||||
54
Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs
Normal file
54
Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class QueryMakersMarkGump : Gump
|
||||
{
|
||||
private int m_Quality;
|
||||
private Mobile m_From;
|
||||
private CraftItem m_CraftItem;
|
||||
private CraftSystem m_CraftSystem;
|
||||
private Type m_TypeRes;
|
||||
private BaseTool m_Tool;
|
||||
|
||||
public QueryMakersMarkGump( int quality, Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, BaseTool tool ) : base( 100, 200 )
|
||||
{
|
||||
from.CloseGump( typeof( QueryMakersMarkGump ) );
|
||||
|
||||
m_Quality = quality;
|
||||
m_From = from;
|
||||
m_CraftItem = craftItem;
|
||||
m_CraftSystem = craftSystem;
|
||||
m_TypeRes = typeRes;
|
||||
m_Tool = tool;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 220, 170, 5054 );
|
||||
AddBackground( 10, 10, 200, 150, 3000 );
|
||||
|
||||
AddHtmlLocalized( 20, 20, 180, 80, 1018317, false, false ); // Do you wish to place your maker's mark on this item?
|
||||
|
||||
AddHtmlLocalized( 55, 100, 140, 25, 1011011, false, false ); // CONTINUE
|
||||
AddButton( 20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 55, 125, 140, 25, 1011012, false, false ); // CANCEL
|
||||
AddButton( 20, 125, 4005, 4007, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
|
||||
{
|
||||
bool makersMark = ( info.ButtonID == 1 );
|
||||
|
||||
if ( makersMark )
|
||||
m_From.SendLocalizedMessage( 501808 ); // You mark the item.
|
||||
else
|
||||
m_From.SendLocalizedMessage( 501809 ); // Cancelled mark.
|
||||
|
||||
m_CraftItem.CompleteCraft( m_Quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
230
Scripts/Engines/Craft/Core/Repair.cs
Normal file
230
Scripts/Engines/Craft/Core/Repair.cs
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
using Server.Items;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class Repair
|
||||
{
|
||||
public Repair()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Do( Mobile from, CraftSystem craftSystem, BaseTool tool )
|
||||
{
|
||||
from.Target = new InternalTarget( craftSystem, tool );
|
||||
from.SendLocalizedMessage( 1044276 ); // Target an item to repair.
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private CraftSystem m_CraftSystem;
|
||||
private BaseTool m_Tool;
|
||||
|
||||
public InternalTarget( CraftSystem craftSystem, BaseTool tool ) : base ( 2, false, TargetFlags.None )
|
||||
{
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Tool = tool;
|
||||
}
|
||||
|
||||
private static void EndGolemRepair( object state )
|
||||
{
|
||||
((Mobile)state).EndAction( typeof( Golem ) );
|
||||
}
|
||||
|
||||
private int GetWeakenChance( Mobile mob, Trades trade, int curHits, int maxHits )
|
||||
{
|
||||
// 40% - (1% per hp lost) - (1% per 10 craft skill)
|
||||
return (40 + (maxHits - curHits)) - (int)((SkillCheck.TradeSkill( mob, trade, false ) ) / 10);
|
||||
}
|
||||
|
||||
private bool CheckWeaken( Mobile mob, Trades trade, int curHits, int maxHits )
|
||||
{
|
||||
return ( GetWeakenChance( mob, trade, curHits, maxHits ) > Utility.Random( 100 ) );
|
||||
}
|
||||
|
||||
private int GetRepairDifficulty( int curHits, int maxHits )
|
||||
{
|
||||
return (((maxHits - curHits) * 1250) / Math.Max( maxHits, 1 )) - 250;
|
||||
}
|
||||
|
||||
private bool CheckRepairDifficulty( Mobile mob, Trades trade, int curHits, int maxHits )
|
||||
{
|
||||
double difficulty = GetRepairDifficulty( curHits, maxHits ) * 0.1;
|
||||
|
||||
return SkillCheck.TestTrade( mob, trade, difficulty - 25.0, difficulty + 25.0 );
|
||||
}
|
||||
|
||||
private bool IsSpecialClothing( BaseClothing clothing )
|
||||
{
|
||||
// Armor repairable but not craftable
|
||||
|
||||
if( m_CraftSystem is DefTailoring )
|
||||
{
|
||||
return (clothing is BearMask)
|
||||
|| (clothing is DeerMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsSpecialWeapon( BaseWeapon weapon )
|
||||
{
|
||||
// Weapons repairable but not craftable
|
||||
|
||||
if ( m_CraftSystem is DefTinkering )
|
||||
{
|
||||
return ( weapon is Cleaver )
|
||||
|| ( weapon is Hatchet )
|
||||
|| ( weapon is Pickaxe )
|
||||
|| ( weapon is ButcherKnife )
|
||||
|| ( weapon is SkinningKnife );
|
||||
}
|
||||
else if ( m_CraftSystem is DefCarpentry )
|
||||
{
|
||||
return ( weapon is Club )
|
||||
|| ( weapon is BlackStaff );
|
||||
}
|
||||
else if ( m_CraftSystem is DefTailoring )
|
||||
{
|
||||
return ( weapon is Whip );
|
||||
}
|
||||
else if ( m_CraftSystem is DefBlacksmithy )
|
||||
{
|
||||
return ( weapon is Pitchfork );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
int number;
|
||||
|
||||
if ( m_CraftSystem.CanCraft( from, m_Tool, targeted.GetType() ) == 1044267 )
|
||||
{
|
||||
number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
|
||||
}
|
||||
else if ( targeted is BaseWeapon )
|
||||
{
|
||||
BaseWeapon weapon = (BaseWeapon)targeted;
|
||||
Trades trade = m_CraftSystem.MainSkill;
|
||||
int toWeaken = 0;
|
||||
|
||||
double skillLevel = SkillCheck.TradeSkill( from, trade, false );
|
||||
|
||||
if ( skillLevel >= 90.0 )
|
||||
toWeaken = 1;
|
||||
else if ( skillLevel >= 70.0 )
|
||||
toWeaken = 2;
|
||||
else
|
||||
toWeaken = 3;
|
||||
|
||||
if ( m_CraftSystem.CraftItems.SearchForSubclass( weapon.GetType() ) == null && !IsSpecialWeapon( weapon ) )
|
||||
{
|
||||
number = 1044277; // That item cannot be repaired.
|
||||
}
|
||||
else if ( !weapon.IsChildOf( from.Backpack ) )
|
||||
{
|
||||
number = 1044275; // The item must be in your backpack to repair it.
|
||||
}
|
||||
else if ( weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints )
|
||||
{
|
||||
number = 1044281; // That item is in full repair
|
||||
}
|
||||
else if ( weapon.MaxHitPoints <= toWeaken )
|
||||
{
|
||||
number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( CheckWeaken( from, trade, weapon.HitPoints, weapon.MaxHitPoints ) )
|
||||
{
|
||||
weapon.MaxHitPoints -= toWeaken;
|
||||
weapon.HitPoints = Math.Max( 0, weapon.HitPoints - toWeaken );
|
||||
}
|
||||
|
||||
if ( CheckRepairDifficulty( from, trade, weapon.HitPoints, weapon.MaxHitPoints ) )
|
||||
{
|
||||
number = 1044279; // You repair the item.
|
||||
m_CraftSystem.PlayCraftEffect( from );
|
||||
weapon.HitPoints = weapon.MaxHitPoints;
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 1044280; // You fail to repair the item.
|
||||
m_CraftSystem.PlayCraftEffect( from );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if ( targeted is BaseArmor )
|
||||
{
|
||||
BaseArmor armor = (BaseArmor)targeted;
|
||||
Trades trade = m_CraftSystem.MainSkill;
|
||||
int toWeaken = 0;
|
||||
|
||||
double skillLevel = SkillCheck.TradeSkill( from, trade, false );
|
||||
|
||||
if ( skillLevel >= 90.0 )
|
||||
toWeaken = 1;
|
||||
else if ( skillLevel >= 70.0 )
|
||||
toWeaken = 2;
|
||||
else
|
||||
toWeaken = 3;
|
||||
|
||||
if ( m_CraftSystem.CraftItems.SearchForSubclass( armor.GetType() ) == null )
|
||||
{
|
||||
number = 1044277; // That item cannot be repaired.
|
||||
}
|
||||
else if ( !armor.IsChildOf( from.Backpack ) )
|
||||
{
|
||||
number = 1044275; // The item must be in your backpack to repair it.
|
||||
}
|
||||
else if ( armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints )
|
||||
{
|
||||
number = 1044281; // That item is in full repair
|
||||
}
|
||||
else if ( armor.MaxHitPoints <= toWeaken )
|
||||
{
|
||||
number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( CheckWeaken( from, trade, armor.HitPoints, armor.MaxHitPoints ) )
|
||||
{
|
||||
armor.MaxHitPoints -= toWeaken;
|
||||
armor.HitPoints = Math.Max( 0, armor.HitPoints - toWeaken );
|
||||
}
|
||||
|
||||
if ( CheckRepairDifficulty( from, trade, armor.HitPoints, armor.MaxHitPoints ) )
|
||||
{
|
||||
number = 1044279; // You repair the item.
|
||||
m_CraftSystem.PlayCraftEffect( from );
|
||||
armor.HitPoints = armor.MaxHitPoints;
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 1044280; // You fail to repair the item.
|
||||
m_CraftSystem.PlayCraftEffect( from );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( targeted is Item )
|
||||
{
|
||||
number = 1044277;
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 500426; // You can't repair that.
|
||||
}
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext( from );
|
||||
from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, number ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
147
Scripts/Engines/Craft/Core/Resmelt.cs
Normal file
147
Scripts/Engines/Craft/Core/Resmelt.cs
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Targeting;
|
||||
using Server.Items;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public enum SmeltResult
|
||||
{
|
||||
Success,
|
||||
Invalid,
|
||||
NoSkill
|
||||
}
|
||||
|
||||
public class Resmelt
|
||||
{
|
||||
public Resmelt()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Do( Mobile from, CraftSystem craftSystem, BaseTool tool )
|
||||
{
|
||||
int num = craftSystem.CanCraft( from, tool, null );
|
||||
|
||||
if ( num > 0 && num != 1044267 )
|
||||
{
|
||||
from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.Target = new InternalTarget( craftSystem, tool );
|
||||
from.SendLocalizedMessage( 1044273 ); // Target an item to recycle.
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private CraftSystem m_CraftSystem;
|
||||
private BaseTool m_Tool;
|
||||
|
||||
public InternalTarget( CraftSystem craftSystem, BaseTool tool ) : base ( 2, false, TargetFlags.None )
|
||||
{
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Tool = tool;
|
||||
}
|
||||
|
||||
private SmeltResult Resmelt( Mobile from, Item item, CraftResource resource )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( CraftResources.GetType( resource ) != CraftResourceType.Metal )
|
||||
return SmeltResult.Invalid;
|
||||
|
||||
CraftResourceInfo info = CraftResources.GetInfo( resource );
|
||||
|
||||
if ( info == null || info.ResourceTypes.Length == 0 )
|
||||
return SmeltResult.Invalid;
|
||||
|
||||
CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor( item.GetType() );
|
||||
|
||||
if ( craftItem == null || craftItem.Resources.Count == 0 )
|
||||
return SmeltResult.Invalid;
|
||||
|
||||
CraftRes craftResource = craftItem.Resources.GetAt( 0 );
|
||||
|
||||
if ( craftResource.Amount < 2 )
|
||||
return SmeltResult.Invalid; // Not enough metal to resmelt
|
||||
|
||||
double difficulty = 0.0;
|
||||
|
||||
if ( difficulty > SkillCheck.TradeSkill( from, Trades.Mining, false ) )
|
||||
return SmeltResult.NoSkill;
|
||||
|
||||
Type resourceType = info.ResourceTypes[0];
|
||||
Item ingot = (Item)Activator.CreateInstance( resourceType );
|
||||
|
||||
if ( (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed) )
|
||||
ingot.Amount = craftResource.Amount / 2;
|
||||
else
|
||||
ingot.Amount = 1;
|
||||
|
||||
item.Delete();
|
||||
from.AddToBackpack( ingot );
|
||||
|
||||
from.PlaySound( 0x2A );
|
||||
from.PlaySound( 0x240 );
|
||||
return SmeltResult.Success;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return SmeltResult.Invalid;
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
int num = m_CraftSystem.CanCraft( from, m_Tool, null );
|
||||
|
||||
if ( num > 0 )
|
||||
{
|
||||
if ( num == 1044267 )
|
||||
{
|
||||
bool anvil, forge;
|
||||
|
||||
DefBlacksmithy.CheckAnvilAndForge( from, 2, out anvil, out forge );
|
||||
|
||||
if ( !anvil )
|
||||
num = 1044266; // You must be near an anvil
|
||||
else if ( !forge )
|
||||
num = 1044265; // You must be near a forge.
|
||||
}
|
||||
|
||||
from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, num ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
SmeltResult result = SmeltResult.Invalid;
|
||||
bool isStoreBought = false;
|
||||
int message;
|
||||
|
||||
if ( targeted is BaseArmor )
|
||||
{
|
||||
result = Resmelt( from, (BaseArmor)targeted, ((BaseArmor)targeted).Resource );
|
||||
isStoreBought = !((BaseArmor)targeted).PlayerConstructed;
|
||||
}
|
||||
else if ( targeted is BaseWeapon )
|
||||
{
|
||||
result = Resmelt( from, (BaseWeapon)targeted, ((BaseWeapon)targeted).Resource );
|
||||
isStoreBought = !((BaseWeapon)targeted).PlayerConstructed;
|
||||
}
|
||||
|
||||
switch ( result )
|
||||
{
|
||||
default:
|
||||
case SmeltResult.Invalid: message = 1044272; break; // You can't melt that down into ingots.
|
||||
case SmeltResult.NoSkill: message = 1044269; break; // You have no idea how to work this metal.
|
||||
case SmeltResult.Success: message = isStoreBought ? 500418 : 1044270; break; // You melt the item down into ingots.
|
||||
}
|
||||
|
||||
from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, message ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue