|
||
|
|||||||
| Custom Script Release Archive This is a pre-script database archive of what our users had released. |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Newbie
|
Ok this isnt my first script by far but this is the first one thta I thought was good enough to add here for all to see. This is basically your standard Ore system but with alittle twist. Instead of just adding the typical extra ores to the Osi originals I changed the complete ore system. All the ores are original addition, that means that all the ores from Iron to Val are gone.
This is a very large script that has many, many edited Distro's. If you already have a O/W/L system in place I wouldn't advise trying to add this script to your server. But if you are looking for something new and original to add to your Shard that will suprise many a crafter then this is the system for you. *On a side note This is a sytem that I have wanted to creat for along time and I am suprised that it hasn't been attempted before now. After working on it for a cpl days I seen why. This system was very hard to make and very stressing aswell. But I believe it was worth it and I hope you all enjoy it. ** Also the Woods that are in this system are there thanks to Dew from Dew Drop Inn. INSTRUCTIONS This Ore System is almost completely Edited Distros. So go through and Backup/Replace your original Distros with the Edited Distros. Any non Distro Scripts may be placed in your Custom folder. Please let me know what you think of this System. And I will help the best I can with any bugs or errors you may come across, this System should be error free but as we all know things never work out the way they are supposed to. Thank You UPDATE 1.0 Took out the Custom Woods due to problems in the CraftItem.cs Fixed The Small spelling error that caused errors in the OreInfo.cs |
|
|
|
|
#2 (permalink) | |
|
Forum Expert
Join Date: Feb 2004
Age: 27
Posts: 1,834
|
Quote:
![]() |
|
|
|
|
|
#3 (permalink) |
|
Newbie
|
Well for one as far I know this is the first time this has been attempted. All of the Regular OSI Ores are gone. Every Single ore that you mine and use is custom. As far as it being difficult and stressing, I had to go through alot of scripts and find every mention of the Osi ores and edit them. This took quite along time, I didn't think when I started that I would have to edit as many scripts as I did.
I know that there are alot of differnt Ore systems out there that have alot of extra added Options, special Perks, Uber stats, or what have you. But this is something differnt, a breath of fresh air for the players. When I play on shards I always play a crafter, and I can tell you that the Osi Standard ore have gotten boring. I believe that it will be a great suprise to crafters when they come into a shard and go to Mine or Smith and not see the same old ores. I think it will add that same experience that we all had when we first started playing. They joy of Discovering something new, the feeling of accomplishment when you have figured out what your doing and working with, and the pure joy of working with something new. I may be the only one that sees it this way but that whats I think makes this system what it is. |
|
|
|
|
#4 (permalink) |
|
Forum Novice
|
Run-UO [www.runuo.com] Version 1.0.0, Build 36918
Scripts: Compiling C# scripts...failed <4 errors, 0 warnings> - Error: Scripts\Customs\ForceMine's Ores\Defs\CraftItem.cs: CS1513: <line 1192, column 5> } expected - Error: Scripts\Customs\ForceMine's Ores\Defs\CraftItem.cs: CS1513: <line 1270, column 2> } expected - Error: Scripts\Customs\ForceMine's Ores\Defs\CraftItem.cs: CS1513: <line 1270, column 2> } expected - Error: Scripts\Customs\ForceMine's Ores\Misc\OreInfo.cs: CS:1585: <line 115, column 10> Member modifier 'static' must precede the member type and name Scripts: One or more scripts failed to compile or no script files were foound. - Press return to exit, or R to try again. |
|
|
|
|
#8 (permalink) |
|
Forum Novice
|
Code:
{
Type resourceType = typeRes;
if ( resourceType == null )
resourceType = Ressources.GetAt( 0 ).ItemType;
CraftResource thisResource = CraftResources.GetFromType( resourceType );
if ( thisResource == ((BaseRunicTool)tool).Resource )
{
weapon.Resource = thisResource;
CraftContext context = craftSystem.GetContext( from );
if ( context != null && context.DoNotColor )
weapon.Hue = 0;
switch ( thisResource )
{
endquality = ((ICraftable)item).OnCraft( quality, makersMark, from, craftSystem, typeRes, tool, this, resHue );
if ( item.Hue == 0 )
item.Hue = resHue;
if ( maxAmount > 0 )
item.Amount = maxAmount;
from.AddToBackpack( item );
//from.PlaySound( 0x57 );
}
int num = craftSystem.PlayEndingEffect( from, false, true, toolBroken, endquality, makersMark, this );
bool queryFactionImbue = false;
int availableSilver = 0;
FactionItemDefinition def = null;
Faction faction = null;
if ( item is IFactionItem )
{
def = FactionItemDefinition.Identify( item );
if ( def != null )
{
faction = Faction.Find( from );
if ( faction != null )
{
Town town = Town.FromRegion( from.Region );
if ( town != null && town.Owner == faction )
{
Container pack = from.Backpack;
if ( pack != null )
{
availableSilver = pack.GetAmount( typeof( Silver ) );
if ( availableSilver >= def.SilverCost )
queryFactionImbue = Faction.IsNearType( from, def.VendorType, 12 );
}
}
}
}
}
// TODO: Scroll imbuing
if ( queryFactionImbue )
from.SendGump( new FactionImbueGump( quality, item, from, craftSystem, tool, num, availableSilver, faction, def ) );
else if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
else if ( num > 0 )
from.SendLocalizedMessage( num );
}
else if ( !allRequiredSkills )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, 1044153 ) );
else
from.SendLocalizedMessage( 1044153 ); // You don't have the required skills to attempt this item.
}
else
{
ConsumeType consumeType = ( UseAllRes ? ConsumeType.Half : ConsumeType.All );
int resHue = 0;
int maxAmount = 0;
object message = null;
// Not enough resource to craft it
if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true ) )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
else if ( message is int && (int)message > 0 )
from.SendLocalizedMessage( (int)message );
else if ( message is string )
from.SendMessage( (string)message );
return;
}
tool.UsesRemaining--;
if ( tool.UsesRemaining < 1 )
toolBroken = true;
if ( toolBroken )
tool.Delete();
// SkillCheck failed.
int num = craftSystem.PlayEndingEffect( from, true, true, toolBroken, endquality, false, this );
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
else if ( num > 0 )
from.SendLocalizedMessage( num );
}
} <<<<<<<<<<<<<<<<this is line 1193 column 4 where i get the error of an }expected
|
|
|
|
|
#9 (permalink) |
|
Join Date: Sep 2004
Posts: 255
|
Looks like maybe your brackets lined up at the wrong place..but hard to say without seeing the whole script....so it is just basically a guessing game...most times it is brackets not matching up and without seeing the whole script it is almost impossible to tell from a partial script...please if you want more help ..post the entire script
|
|
|
|
|
#11 (permalink) |
|
Forum Novice
|
Code:
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Factions;
namespace Server.Engines.Craft
{
public enum ConsumeType
{
All, Half, None
}
public interface ICraftable
{
int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue );
}
public class CraftItem
{
private CraftResCol m_arCraftRes;
private CraftSkillCol m_arCraftSkill;
private Type m_Type;
private string m_GroupNameString;
private int m_GroupNameNumber;
private string m_NameString;
private int m_NameNumber;
private int m_Mana;
private int m_Hits;
private int m_Stam;
private bool m_UseAllRes;
private bool m_NeedHeat;
private bool m_NeedOven;
private bool m_UseSubRes2;
private bool m_RequiresSE;
private static Hashtable m_ItemIDs = new Hashtable();
public static int ItemIDOf( Type type )
{
object obj = m_ItemIDs[type];
if ( obj != null )
return (int)obj;
Item item = null;
try{ item = Activator.CreateInstance( type ) as Item; }
catch{}
int itemID = ( item == null ? 0 : item.ItemID );
m_ItemIDs[type] = itemID;
if ( item != null )
item.Delete();
return itemID;
}
public CraftItem( Type type, TextDefinition groupName, TextDefinition name )
{
m_arCraftRes = new CraftResCol();
m_arCraftSkill = new CraftSkillCol();
m_Type = type;
m_GroupNameString = groupName;
m_NameString = name;
m_GroupNameNumber = groupName;
m_NameNumber = name;
}
public void AddRes( Type type, TextDefinition name, int amount )
{
AddRes( type, name, amount, "" );
}
public void AddRes( Type type, TextDefinition name, int amount, TextDefinition message )
{
CraftRes craftRes = new CraftRes( type, name, amount, message );
m_arCraftRes.Add( craftRes );
}
public void AddSkill( SkillName skillToMake, double minSkill, double maxSkill )
{
CraftSkill craftSkill = new CraftSkill( skillToMake, minSkill, maxSkill );
m_arCraftSkill.Add( craftSkill );
}
public int Mana
{
get { return m_Mana; }
set { m_Mana = value; }
}
public int Hits
{
get { return m_Hits; }
set { m_Hits = value; }
}
public int Stam
{
get { return m_Stam; }
set { m_Stam = value; }
}
public bool UseSubRes2
{
get { return m_UseSubRes2; }
set { m_UseSubRes2 = value; }
}
public bool UseAllRes
{
get { return m_UseAllRes; }
set { m_UseAllRes = value; }
}
public bool NeedHeat
{
get { return m_NeedHeat; }
set { m_NeedHeat = value; }
}
public bool NeedOven
{
get { return m_NeedOven; }
set { m_NeedOven = value; }
}
public Type ItemType
{
get { return m_Type; }
}
public string GroupNameString
{
get { return m_GroupNameString; }
}
public int GroupNameNumber
{
get { return m_GroupNameNumber; }
}
public string NameString
{
get { return m_NameString; }
}
public int NameNumber
{
get { return m_NameNumber; }
}
public CraftResCol Ressources
{
get { return m_arCraftRes; }
}
public CraftSkillCol Skills
{
get { return m_arCraftSkill; }
}
public bool RequiresSE
{
get{ return m_RequiresSE; }
set{ m_RequiresSE = value; }
}
public bool ConsumeAttributes( Mobile from, ref object message, bool consume )
{
bool consumMana = false;
bool consumHits = false;
bool consumStam = false;
if ( Hits > 0 && from.Hits < Hits )
{
message = "You lack the required hit points to make that.";
return false;
}
else
{
consumHits = consume;
}
if ( Mana > 0 && from.Mana < Mana )
{
message = "You lack the required mana to make that.";
return false;
}
else
{
consumMana = consume;
}
if ( Stam > 0 && from.Stam < Stam )
{
message = "You lack the required stamina to make that.";
return false;
}
else
{
consumStam = consume;
}
if ( consumMana )
from.Mana -= Mana;
if ( consumHits )
from.Hits -= Hits;
if ( consumStam )
from.Stam -= Stam;
return true;
}
private static Type[][] m_TypesTable = new Type[][]
{
new Type[]{ typeof( Log ), typeof( Board ) },
new Type[]{ typeof( BirchLog ), typeof( BirchBoard ) },
new Type[]{ typeof( AshLog ), typeof( AshBoard ) },
new Type[]{ typeof( WengeLog ), typeof( WengeBoard ) },
new Type[]{ typeof( YewLog ), typeof( YewBoard ) },
new Type[]{ typeof( OakLog ), typeof( OakBoard ) },
new Type[]{ typeof( SwampLog ), typeof( SwampBoard ) },
new Type[]{ typeof( EbonyLog ), typeof( EbonyBoard ) },
new Type[]{ typeof( PinkIvoryLog ), typeof( PinkIvoryBoard ) },
new Type[]{ typeof( TulipwoodLog ), typeof( TulipwoodBoard ) },
new Type[]{ typeof( CherrywoodLog ), typeof( CherrywoodBoard ) },
new Type[]{ typeof( DewwoodLog ), typeof( DewwoodBoard ) },
new Type[]{ typeof( Leather ), typeof( Hides ) },
new Type[]{ typeof( SpinedLeather ), typeof( SpinedHides ) },
new Type[]{ typeof( HornedLeather ), typeof( HornedHides ) },
new Type[]{ typeof( BarbedLeather ), typeof( BarbedHides ) },
new Type[]{ typeof( BlankMap ), typeof( BlankScroll ) },
new Type[]{ typeof( Cloth ), typeof( UncutCloth ) },
new Type[]{ typeof( CheeseWheel ), typeof( CheeseWedge ) }
};
private static Type[] m_ColoredItemTable = new Type[]
{
typeof( BaseWeapon ), typeof( BaseArmor ), typeof( BaseClothing ),
typeof( BaseJewel ), typeof( DragonBardingDeed )
};
private static Type[] m_ColoredResourceTable = new Type[]
{
typeof( Log ), typeof( BirchLog ), typeof( AshLog ), typeof( WengeLog ), typeof( YewLog ), typeof( OakLog ), typeof( SwampLog ), typeof( EbonyLog ), typeof( PinkIvoryLog ), typeof( TulipwoodLog ), typeof( CherrywoodLog ), typeof( DewwoodLog ),
typeof( Board ), typeof( BirchBoard ), typeof( AshBoard ), typeof( WengeBoard ), typeof( YewBoard ), typeof( OakBoard ), typeof( SwampBoard ), typeof( EbonyBoard ), typeof( PinkIvoryBoard ), typeof( TulipwoodBoard ), typeof( CherrywoodBoard ), typeof( DewwoodBoard ),
typeof( BaseIngot ), typeof( BaseOre ),
typeof( BaseLeather ), typeof( BaseHides ),
typeof( UncutCloth ), typeof( Cloth ),
typeof( BaseGranite ), typeof( BaseScales )
};
private static Type[] m_MarkableTable = new Type[]
{
typeof( BaseArmor ),
typeof( BaseWeapon ),
typeof( BaseClothing ),
typeof( BaseInstrument ),
typeof( DragonBardingDeed )
};
public bool IsMarkable( Type type )
{
for ( int i = 0; i < m_MarkableTable.Length; ++i )
{
if ( type == m_MarkableTable[i] || type.IsSubclassOf( m_MarkableTable[i] ) )
return true;
}
return false;
}
public bool RetainsColorFrom( CraftSystem system, Type type )
{
if ( system.RetainsColorFrom( this, type ) )
return true;
bool inItemTable = false, inResourceTable = false;
for ( int i = 0; !inItemTable && i < m_ColoredItemTable.Length; ++i )
inItemTable = ( m_Type == m_ColoredItemTable[i] || m_Type.IsSubclassOf( m_ColoredItemTable[i] ) );
for ( int i = 0; inItemTable && !inResourceTable && i < m_ColoredResourceTable.Length; ++i )
inResourceTable = ( type == m_ColoredResourceTable[i] || type.IsSubclassOf( m_ColoredResourceTable[i] ) );
return ( inItemTable && inResourceTable );
}
private static int[] m_HeatSources = new int[]
{
0x461, 0x48E, // Sandstone oven/fireplace
0x92B, 0x96C, // Stone oven/fireplace
0xDE3, 0xDE9, // Campfire
0xFAC, 0xFAC, // Firepit
0x184A, 0x184C, // Heating stand (left)
0x184E, 0x1850, // Heating stand (right)
0x398C, 0x399F // Fire field
};
private static int[] m_Ovens = new int[]
{
0x461, 0x46F, // Sandstone oven
0x92B, 0x93F // Stone oven
};
public bool Find( Mobile from, int[] itemIDs )
{
Map map = from.Map;
if ( map == null )
return false;
IPooledEnumerable eable = map.GetItemsInRange( from.Location, 2 );
foreach ( Item item in eable )
{
if ( (item.Z + 16) > from.Z && (from.Z + 16) > item.Z && Find( item.ItemID, itemIDs ) )
{
eable.Free();
return true;
}
}
eable.Free();
for ( int x = -2; x <= 2; ++x )
{
for ( int y = -2; y <= 2; ++y )
{
int vx = from.X + x;
int vy = from.Y + y;
Tile[] tiles = map.Tiles.GetStaticTiles( vx, vy, true );
for ( int i = 0; i < tiles.Length; ++i )
{
int z = tiles[i].Z;
int id = tiles[i].ID & 0x3FFF;
if ( (z + 16) > from.Z && (from.Z + 16) > z && Find( id, itemIDs ) )
return true;
}
}
}
return false;
}
public bool Find( int itemID, int[] itemIDs )
{
bool contains = false;
for ( int i = 0; !contains && i < itemIDs.Length; i += 2 )
contains = ( itemID >= itemIDs[i] && itemID <= itemIDs[i + 1] );
return contains;
}
public bool IsQuantityType( Type[][] types )
{
for ( int i = 0; i < types.Length; ++i )
{
Type[] check = types[i];
for ( int j = 0; j < check.Length; ++j )
{
if ( typeof( IHasQuantity ).IsAssignableFrom( check[j] ) )
return true;
}
}
return false;
}
public int ConsumeQuantity( Container cont, Type[][] types, int[] amounts )
{
if ( types.Length != amounts.Length )
throw new ArgumentException();
Item[][] items = new Item[types.Length][];
int[] totals = new int[types.Length];
for ( int i = 0; i < types.Length; ++i )
{
items[i] = cont.FindItemsByType( types[i], true );
for ( int j = 0; j < items[i].Length; ++j )
{
IHasQuantity hq = items[i][j] as IHasQuantity;
if ( hq == null )
{
totals[i] += items[i][j].Amount;
}
else
{
if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != BeverageType.Water )
continue;
totals[i] += hq.Quantity;
}
}
if ( totals[i] < amounts[i] )
return i;
}
for ( int i = 0; i < types.Length; ++i )
{
int need = amounts[i];
for ( int j = 0; j < items[i].Length; ++j )
{
Item item = items[i][j];
IHasQuantity hq = item as IHasQuantity;
if ( hq == null )
{
int theirAmount = item.Amount;
if ( theirAmount < need )
{
item.Delete();
need -= theirAmount;
}
else
{
item.Consume( need );
break;
}
}
else
{
if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != BeverageType.Water )
continue;
int theirAmount = hq.Quantity;
if ( theirAmount < need )
{
hq.Quantity -= theirAmount;
need -= theirAmount;
}
else
{
hq.Quantity -= need;
break;
}
}
}
}
return -1;
}
public int GetQuantity( Container cont, Type[] types )
{
Item[] items = cont.FindItemsByType( types, true );
int amount = 0;
for ( int i = 0; i < items.Length; ++i )
{
IHasQuantity hq = items[i] as IHasQuantity;
if ( hq == null )
{
amount += items[i].Amount;
}
else
{
if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != BeverageType.Water )
continue;
amount += hq.Quantity;
}
}
return amount;
}
public bool ConsumeRes( Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message )
{
return ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, false );
}
public bool ConsumeRes( Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message, bool isFailure )
{
Container ourPack = from.Backpack;
if ( ourPack == null )
return false;
if ( m_NeedHeat && !Find( from, m_HeatSources ) )
{
message = 1044487; // You must be near a fire source to cook.
return false;
}
if ( m_NeedOven && !Find( from, m_Ovens ) )
{
message = 1044493; // You must be near an oven to bake that.
return false;
}
Type[][] types = new Type[m_arCraftRes.Count][];
int[] amounts = new int[m_arCraftRes.Count];
maxAmount = int.MaxValue;
CraftSubResCol resCol = ( m_UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes );
for ( int i = 0; i < types.Length; ++i )
{
CraftRes craftRes = m_arCraftRes.GetAt( i );
Type baseType = craftRes.ItemType;
// Resource Mutation
if ( (baseType == resCol.ResType) && ( typeRes != null ) )
{
baseType = typeRes;
CraftSubRes subResource = resCol.SearchFor( baseType );
if ( subResource != null && from.Skills[craftSystem.MainSkill].Base < subResource.RequiredSkill )
{
message = subResource.Message;
return false;
}
}
// ******************
for ( int j = 0; types[i] == null && j < m_TypesTable.Length; ++j )
{
if ( m_TypesTable[j][0] == baseType )
types[i] = m_TypesTable[j];
}
if ( types[i] == null )
types[i] = new Type[]{ baseType };
/*if ( !retainedColor && RetainsColorFrom( craftSystem, baseType ) )
{
retainedColor = true;
Item resItem = ourPack.FindItemByType( types[i] );
if ( resItem != null )
resHue = resItem.Hue;
}*/
amounts[i] = craftRes.Amount;
// For stackable items that can ben crafted more than one at a time
if ( UseAllRes )
{
int tempAmount = ourPack.GetAmount( types[i] );
tempAmount /= amounts[i];
if ( tempAmount < maxAmount )
{
maxAmount = tempAmount;
if ( maxAmount == 0 )
{
CraftRes res = m_arCraftRes.GetAt( i );
if ( res.MessageNumber > 0 )
message = res.MessageNumber;
else if ( res.MessageString != null && res.MessageString != String.Empty )
message = res.MessageString;
else
message = 502925; // You don't have the resources required to make that item.
return false;
}
}
}
// ****************************
if ( isFailure && !craftSystem.ConsumeOnFailure( from, types[i][0], this ) )
amounts[i] = 0;
}
// We adjust the amount of each resource to consume the max posible
if ( UseAllRes )
{
for ( int i = 0; i < amounts.Length; ++i )
amounts[i] *= maxAmount;
}
else
maxAmount = -1;
Item consumeExtra = null;
if ( m_NameNumber == 1041267 )
{
// Runebooks are a special case, they need a blank recall rune
Item[] runes = ourPack.FindItemsByType( typeof( RecallRune ) );
for ( int i = 0; i < runes.Length; ++i )
{
RecallRune rune = runes[i] as RecallRune;
if ( rune != null && !rune.Marked )
{
consumeExtra = rune;
break;
}
}
if ( consumeExtra == null )
{
message = 1044253; // You don't have the components needed to make that.
return false;
}
}
int index = 0;
// Consume ALL
if ( consumeType == ConsumeType.All )
{
m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem;
if ( IsQuantityType( types ) )
index = ConsumeQuantity( ourPack, types, amounts );
else
index = ourPack.ConsumeTotalGrouped( types, amounts, true, new OnItemConsumed( OnResourceConsumed ), new CheckItemGroup( CheckHueGrouping ) );
resHue = m_ResHue;
}
// Consume Half ( for use all resource craft type )
else if ( consumeType == ConsumeType.Half )
{
for ( int i = 0; i < amounts.Length; i++ )
{
amounts[i] /= 2;
if ( amounts[i] < 1 )
amounts[i] = 1;
}
m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem;
if ( IsQuantityType( types ) )
index = ConsumeQuantity( ourPack, types, amounts );
else
index = ourPack.ConsumeTotalGrouped( types, amounts, true, new OnItemConsumed( OnResourceConsumed ), new CheckItemGroup( CheckHueGrouping ) );
resHue = m_ResHue;
}
else // ConstumeType.None ( it's basicaly used to know if the crafter has enough resource before starting the process )
{
index = -1;
if ( IsQuantityType( types ) )
{
for ( int i = 0; i < types.Length; i++ )
{
if ( GetQuantity( ourPack, types[i] ) < amounts[i] )
{
index = i;
break;
}
}
}
else
{
for ( int i = 0; i < types.Length; i++ )
{
if ( ourPack.GetBestGroupAmount( types[i], true, new CheckItemGroup( CheckHueGrouping ) ) < amounts[i] )
{
index = i;
break;
}
}
}
}
if ( index == -1 )
{
if ( consumeType != ConsumeType.None )
if ( consumeExtra != null )
consumeExtra.Delete();
return true;
}
else
{
CraftRes res = m_arCraftRes.GetAt( index );
if ( res.MessageNumber > 0 )
message = res.MessageNumber;
else if ( res.MessageString != null && res.MessageString != String.Empty )
message = res.MessageString;
else
message = 502925; // You don't have the resources required to make that item.
return false;
}
}
private int m_ResHue;
private int m_ResAmount;
private CraftSystem m_System;
private void OnResourceConsumed( Item item, int amount )
{
if ( !RetainsColorFrom( m_System, item.GetType() ) )
return;
if ( amount >= m_ResAmount )
{
m_ResHue = item.Hue;
m_ResAmount = amount;
}
}
private int CheckHueGrouping( Item a, Item b )
{
return b.Hue.CompareTo( a.Hue );
}
public double GetExceptionalChance( CraftSystem system, double chance, Mobile from )
{
switch ( system.ECA )
{
default:
case CraftECA.ChanceMinusSixty: return chance - 0.6;
case CraftECA.FiftyPercentChanceMinusTenPercent: return (chance * 0.5) - 0.1;
case CraftECA.ChanceMinusSixtyToFourtyFive:
{
double offset = 0.60 - ((from.Skills[system.MainSkill].Value - 95.0) * 0.03);
if ( offset < 0.45 )
offset = 0.45;
else if ( offset > 0.60 )
offset = 0.60;
return chance - offset;
}
}
}
public bool CheckSkills( Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, ref bool allRequiredSkills )
{
return CheckSkills( from, typeRes, craftSystem, ref quality, ref allRequiredSkills, true );
}
public bool CheckSkills( Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, ref bool allRequiredSkills, bool gainSkills )
{
double chance = GetSuccessChance( from, typeRes, craftSystem, gainSkills, ref allRequiredSkills );
if ( GetExceptionalChance( craftSystem, chance, from ) >= Utility.RandomDouble() )
quality = 2;
return ( chance >= Utility.RandomDouble() );
}
public double GetSuccessChance( Mobile from, Type typeRes, CraftSystem craftSystem, bool gainSkills, ref bool allRequiredSkills )
{
double minMainSkill = 0.0;
double maxMainSkill = 0.0;
double valMainSkill = 0.0;
allRequiredSkills = true;
for ( int i = 0; i < m_arCraftSkill.Count; i++)
{
CraftSkill craftSkill = m_arCraftSkill.GetAt(i);
double minSkill = craftSkill.MinSkill;
double maxSkill = craftSkill.MaxSkill;
double valSkill = from.Skills[craftSkill.SkillToMake].Value;
if ( valSkill < minSkill )
allRequiredSkills = false;
if ( craftSkill.SkillToMake == craftSystem.MainSkill )
{
minMainSkill = minSkill;
maxMainSkill = maxSkill;
valMainSkill = valSkill;
}
if ( gainSkills ) // This is a passive check. Success chance is entirely dependant on the main skill
from.CheckSkill( craftSkill.SkillToMake, minSkill, maxSkill );
}
double chance;
if ( allRequiredSkills )
chance = craftSystem.GetChanceAtMin( this ) + ((valMainSkill - minMainSkill) / (maxMainSkill - minMainSkill) * (1.0 - craftSystem.GetChanceAtMin( this )));
else
chance = 0.0;
if ( allRequiredSkills && valMainSkill == maxMainSkill )
chance = 1.0;
return chance;
}
public void Craft( Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool )
{
if ( from.BeginAction( typeof( CraftSystem ) ) )
{
int flags = from.NetState == null ? 0 : from.NetState.Flags;
if( !RequiresSE || (flags & 0x10) != 0 )// SE 2D = 0x1F SE 3D = 0x11F
{
bool allRequiredSkills = true;
double chance = GetSuccessChance( from, typeRes, craftSystem, false, ref allRequiredSkills );
if ( allRequiredSkills && chance >= 0.0 )
{
int badCraft = craftSystem.CanCraft( from, tool, m_Type );
if ( badCraft <= 0 )
{
int resHue = 0;
int maxAmount = 0;
object message = null;
if ( ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message ) )
{
message = null;
if ( ConsumeAttributes( from, ref message, false ) )
{
CraftContext context = craftSystem.GetContext( from );
if ( context != null )
context.OnMade( this );
int iMin = craftSystem.MinCraftEffect;
int iMax = ( craftSystem.MaxCraftEffect - iMin ) + 1;
int iRandom = Utility.Random( iMax );
iRandom += iMin + 1;
new InternalTimer( from, craftSystem, this, typeRes, tool, iRandom ).Start();
}
else
{
from.EndAction( typeof( CraftSystem ) );
from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
}
}
else
{
from.EndAction( typeof( CraftSystem ) );
from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
}
}
else
{
from.EndAction( typeof( CraftSystem ) );
from.SendGump( new CraftGump( from, craftSystem, tool, badCraft ) );
}
}
else
{
from.EndAction( typeof( CraftSystem ) );
from.SendGump( new CraftGump( from, craftSystem, tool, 1044153 ) ); // You don't have the required skills to attempt this item.
}
}
else
{
from.EndAction( typeof( CraftSystem ) );
from.SendGump( new CraftGump( from, craftSystem, tool, 1063307 ) ); //The "Samurai Empire" expansion is required to attempt this item.
}
}
else
{
from.SendLocalizedMessage( 500119 ); // You must wait to perform another action
}
}
public void CompleteCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool )
{
int badCraft = craftSystem.CanCraft( from, tool, m_Type );
if ( badCraft > 0 )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, badCraft ) );
else
from.SendLocalizedMessage( badCraft );
return;
}
int checkResHue = 0, checkMaxAmount = 0;
object checkMessage = null;
// Not enough resource to craft it
if ( !ConsumeRes( from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage ) )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
else if ( checkMessage is int && (int)checkMessage > 0 )
from.SendLocalizedMessage( (int)checkMessage );
else if ( checkMessage is string )
from.SendMessage( (string)checkMessage );
return;
}
else if ( !ConsumeAttributes( from, ref checkMessage, false ) )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
else if ( checkMessage is int && (int)checkMessage > 0 )
from.SendLocalizedMessage( (int)checkMessage );
else if ( checkMessage is string )
from.SendMessage( (string)checkMessage );
return;
}
bool toolBroken = false;
int ignored = 1;
int endquality = 1;
bool allRequiredSkills = true;
if ( CheckSkills( from, typeRes, craftSystem, ref ignored, ref allRequiredSkills ) )
{
// Resource
int resHue = 0;
int maxAmount = 0;
object message = null;
// Not enough resource to craft it
if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message ) )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
else if ( message is int && (int)message > 0 )
from.SendLocalizedMessage( (int)message );
else if ( message is string )
from.SendMessage( (string)message );
return;
}
else if ( !ConsumeAttributes( from, ref message, true ) )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
else if ( message is int && (int)message > 0 )
from.SendLocalizedMessage( (int)message );
else if ( message is string )
from.SendMessage( (string)message );
return;
}
tool.UsesRemaining--;
if ( craftSystem is DefBlacksmithy )
{
AncientSmithyHammer hammer = from.FindItemOnLayer( Layer.OneHanded ) as AncientSmithyHammer;
if ( hammer != null && hammer != tool )
{
hammer.UsesRemaining--;
if ( hammer.UsesRemaining < 1 )
hammer.Delete();
}
}
if ( tool.UsesRemaining < 1 )
toolBroken = true;
if ( toolBroken )
tool.Delete();
Item item;
if ( typeof( MapItem ).IsAssignableFrom( ItemType ) && from.Map != Map.Trammel && from.Map != Map.Felucca )
{
item = new IndecipherableMap();
from.SendLocalizedMessage( 1070800 ); // The map you create becomes mysteriously indecipherable.
}
else
{
item = Activator.CreateInstance( ItemType ) as Item;
}
if ( item != null )
{
if ( item is Board )
{
Type resourceType = typeRes;
if ( resourceType == null )
resourceType = Ressources.GetAt( 0 ).ItemType;
CraftResource thisResource = CraftResources.GetFromType( resourceType );
switch ( thisResource )
{
case CraftResource.Log: item = new Board(); break;
case CraftResource.Birch: item = new BirchBoard(); break;
case CraftResource.Ash: item = new AshBoard(); break;
case CraftResource.Wenge: item = new WengeBoard(); break;
case CraftResource.Yew: item = new YewBoard(); break;
case CraftResource.Oak: item = new OakBoard(); break;
case CraftResource.Swamp: item = new SwampBoard(); break;
case CraftResource.Ebony: item = new EbonyBoard(); break;
case CraftResource.PinkIvory: item = new PinkIvoryBoard(); break;
case CraftResource.Tulipwood: item = new TulipwoodBoard(); break;
case CraftResource.Cherrywood: item = new CherrywoodBoard(); break;
case CraftResource.Dewwood: item = new DewwoodBoard(); break;
default: item = new Board(); break;
}
}
if ( item is BaseWeapon )
{
BaseWeapon weapon = ( BaseWeapon )item;
weapon.Quality = (WeaponQuality)quality;
endquality = quality;
if ( makersMark )
weapon.Crafter = from;
weapon.PlayerConstructed = true;
if ( Core.AOS )
{
Type resourceType = typeRes;
if ( resourceType == null )
resourceType = Ressources.GetAt( 0 ).ItemType;
weapon.Resource = CraftResources.GetFromType( resourceType );
CraftContext context = craftSystem.GetContext( from );
if ( context != null && context.DoNotColor )
weapon.Hue = 0;
if ( tool is BaseRunicTool )
((BaseRunicTool)tool).ApplyAttributesTo( weapon );
if ( quality == 2 )
{
if ( weapon.Attributes.WeaponDamage > 35 )
weapon.Attributes.WeaponDamage -= 20;
else
weapon.Attributes.WeaponDamage = 15;
}
}
else if ( tool is BaseRunicTool )
{
Type resourceType = typeRes;
if ( resourceType == null )
resourceType = Ressources.GetAt( 0 ).ItemType;
CraftResource thisResource = CraftResources.GetFromType( resourceType );
if ( thisResource == ((BaseRunicTool)tool).Resource )
{
weapon.Resource = thisResource;
CraftContext context = craftSystem.GetContext( from );
if ( context != null && context.DoNotColor )
weapon.Hue = 0;
switch ( thisResource )
{
endquality = ((ICraftable)item).OnCraft( quality, makersMark, from, craftSystem, typeRes, tool, this, resHue );
if ( item.Hue == 0 )
item.Hue = resHue;
if ( maxAmount > 0 )
item.Amount = maxAmount;
from.AddToBackpack( item );
//from.PlaySound( 0x57 );
}
int num = craftSystem.PlayEndingEffect( from, false, true, toolBroken, endquality, makersMark, this );
bool queryFactionImbue = false;
int availableSilver = 0;
FactionItemDefinition def = null;
Faction faction = null;
if ( item is IFactionItem )
{
def = FactionItemDefinition.Identify( item );
if ( def != null )
{
faction = Faction.Find( from );
if ( faction != null )
{
Town town = Town.FromRegion( from.Region );
if ( town != null && town.Owner == faction )
{
Container pack = from.Backpack;
if ( pack != null )
{
availableSilver = pack.GetAmount( typeof( Silver ) );
if ( availableSilver >= def.SilverCost )
queryFactionImbue = Faction.IsNearType( from, def.VendorType, 12 );
}
}
}
}
}
// TODO: Scroll imbuing
if ( queryFactionImbue )
from.SendGump( new FactionImbueGump( quality, item, from, craftSystem, tool, num, availableSilver, faction, def ) );
else if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
else if ( num > 0 )
from.SendLocalizedMessage( num );
}
else if ( !allRequiredSkills )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, 1044153 ) );
else
from.SendLocalizedMessage( 1044153 ); // You don't have the required skills to attempt this item.
}
else
{
ConsumeType consumeType = ( UseAllRes ? ConsumeType.Half : ConsumeType.All );
int resHue = 0;
int maxAmount = 0;
object message = null;
// Not enough resource to craft it
if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true ) )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
else if ( message is int && (int)message > 0 )
from.SendLocalizedMessage( (int)message );
else if ( message is string )
from.SendMessage( (string)message );
return;
}
tool.UsesRemaining--;
if ( tool.UsesRemaining < 1 )
toolBroken = true;
if ( toolBroken )
tool.Delete();
// SkillCheck failed.
int num = craftSystem.PlayEndingEffect( from, true, true, toolBroken, endquality, false, this );
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
else if ( num > 0 )
from.SendLocalizedMessage( num );
}
}
private class InternalTimer : Timer
{
private Mobile m_From;
private int m_iCount;
private int m_iCountMax;
private CraftItem m_CraftItem;
private CraftSystem m_CraftSystem;
private Type m_TypeRes;
private BaseTool m_Tool;
public InternalTimer( Mobile from, CraftSystem craftSystem, CraftItem craftItem, Type typeRes, BaseTool tool, int iCountMax ) : base( TimeSpan.Zero, TimeSpan.FromSeconds( craftSystem.Delay ), iCountMax )
{
m_From = from;
m_CraftItem = craftItem;
m_iCount = 0;
m_iCountMax = iCountMax;
m_CraftSystem = craftSystem;
m_TypeRes = typeRes;
m_Tool = tool;
}
protected override void OnTick()
{
m_iCount++;
m_From.DisruptiveAction();
if ( m_iCount < m_iCountMax )
{
m_CraftSystem.PlayCraftEffect( m_From );
}
else
{
m_From.EndAction( typeof( CraftSystem ) );
int badCraft = m_CraftSystem.CanCraft( m_From, m_Tool, m_CraftItem.m_Type );
if ( badCraft > 0 )
{
if ( m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0 )
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, badCraft ) );
else
m_From.SendLocalizedMessage( badCraft );
return;
}
int quality = 1;
bool allRequiredSkills = true;
m_CraftItem.CheckSkills( m_From, m_TypeRes, m_CraftSystem, ref quality, ref allRequiredSkills, false );
CraftContext context = m_CraftSystem.GetContext( m_From );
if ( context == null )
return;
bool makersMark = false;
if ( quality == 2 && m_From.Skills[m_CraftSystem.MainSkill].Base >= 100.0 )
makersMark = m_CraftItem.IsMarkable( m_CraftItem.ItemType );
if ( makersMark && context.MarkOption == CraftMarkOption.PromptForMark )
{
m_From.SendGump( new QueryMakersMarkGump( quality, m_From, m_CraftItem, m_CraftSystem, m_TypeRes, m_Tool ) );
}
else
{
if ( context.MarkOption == CraftMarkOption.DoNotMark )
makersMark = false;
m_CraftItem.CompleteCraft( quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool );
}
}
}
}
}
}
|
|
|
|
|
#13 (permalink) |
|
Newbie
|
What makes this one special in my opion is easy. With the other Ore system all they have done is add more ores to the existing OSI standard ores. So you still had to wade through all the old boring ores to get to the new ones. My system bypasses all of that. Right when you start out you are using new and differnt ores.
I think this will add to the enjoyment of the players. As something new and unseen usually does. Others may not see this sytem as anything major but to me it is. |
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|