Go Back   RunUO - Ultima Online Emulation > RunUO > RunUO Post Archive

RunUO Post Archive The Archvie

Reply
 
Thread Tools Display Modes
Old 04-12-2004, 04:53 PM   #1 (permalink)
 
Join Date: Feb 2004
Location: Canada eh
Posts: 413
Default Tweaked Crafting subsystem for V1 RC0

Summary:
This file set implements three things:

1) Fixes a small bug I reported in Beta36 that missed the cut for v1 RC0
2) Adds new flexibility in using either string or cliloc entries when calling AddCraft and Subsquent methods.
3) Extends the Crafting subsystem to be able to handle crafting objects that require parameters on their constructor.


Description:
This fixes this bug:
Stat Gain

Extends the AddCraft method by replacing all of 24 permutations of overloaded signatures with 4 main signatures that use objects as the passed parameter type instead of the permutations of string and int.
This would fix MANY peoples problems with finding the correct signature to use and also adds a few permutations that were not allowed in the original. See the following for discussions that could have been not rquired or greatly simplified:
light shedding property for items
http://www.runuo.com/forum/showthread.php?t=33856
Faster Gain
[SetMy

Further extends the AddCraft method by adding 4 more prototypes that accept an array of type object to be used as constructor parameters on the subsequent item creation. See:
Ever been accused of ......
http://www.runuo.com/forum/showthread.php?t=31788

Some examples of usages possible in this new variant:
Code:
	// Components
	AddCraft( typeof( Rope ), "Components", 1020934, SkillName.Tailoring, 20.0, 45.0, typeof( SpoolOfThread ), 1024000, 5, "You do not have sufficient thread to make that." );
	AddCraft( typeof( Rope ), 1011155, "Rope", SkillName.Tailoring, 20.0, 45.0, typeof( SpoolOfThread ), 1024000, 5, "You do not have sufficient thread to make that." );
	AddCraft( typeof( Rope ), 1011155, 1020934, SkillName.Tailoring, 20.0, 45.0, typeof( SpoolOfThread ), "Thread", 5, "You do not have sufficient thread to make that." );
	AddCraft( typeof( Rope ), 1011155, 1020934, SkillName.Tailoring, 20.0, 45.0, typeof( SpoolOfThread ), 1024000, 5, 1042081 );
	AddCraft( typeof( Rope ), 1011155, 1020934, SkillName.Tailoring, 20.0, 45.0, typeof( SpoolOfThread ), 1024000, 5, "You do not have sufficient thread to make that.", new object[] {10} );// MAKES 10 piles of rope by virtue of the parameter 10!
	AddCraft( typeof( RunicHammer ), "WOW", "Valorite Runic Hammer", SkillName.Blacksmith, 100.0, 120.0, typeof( Gold ), 1023822, 5000, 1019022, new object[] {CraftResource.Valorite, 10} );
	// and if you have the fireable cannon script from script submissions that's been tweaked to compile in V1 RC0 you could even try this
	AddCraft( typeof( fcannonDeed ), "WOW", "Fireable Cannon (North) Deed", SkillName.Blacksmith, 100.0, 120.0, typeof( IronIngot ), 1044036, 500, 1044037, new object[] {1} );

Installation:
Replace same named files in the directory Scripts\Engines\Craft\Core\

Use at your leisure in any Def<craft> source files.

NOTE: the newscript.php submission form was still not working at the time I originally posted this. I just sort of hacked my way arround the manage attachments (newattachment.php) section to get this to work.

--editted May 14 2004---
I updated CraftItem.cs to allow crafting items of with a quantity in the constructor to use the SetUseAllRes. (there was one change on line 1241 to read "item.Amount = item.Amount * maxAmount;") For example, changing the crafting of shafts to make 12 shafts from each log/board, and still use all logs/boards in your inventory:
Code:
	index =   AddCraft( typeof( Shaft ), 1044457, "Shafts (Logs x 12)", 0.0, 40.0, typeof( Log ), 1044041, 1, 1044351,  new object[] {12} ); 
	SetUseAllRes( index, true );
Thx flowerbudd! for using it getting me to think of this!
(old version had 343 dnloads)
-----------------------------------------------------------------------------------------------------------------------------------
awdball · NON-beligerent Forum Member · · · · ;^) · · · · RUNUO-FAQ · · [CODE] Post CODE inside tags [/CODE]
The team for moderation on RUNUO Forums · · · · HelpSomeone · · CAPitalizaTION Counts m_BeCareful!
(old school c coder learning and luvin c#) · · · · · · · Great C# Tutorial · · Good forum searching tips
Attached Files
File Type: zip v1rc0CraftRewrite.zip (12.8 KB, 248 views)
__________________
awdball
awdball is offline   Reply With Quote
Old 04-12-2004, 06:47 PM   #2 (permalink)
 
Join Date: Feb 2004
Posts: 7
Default

Quote:
Originally Posted by awdball
Summary:
This file set implements three things:

1) Fixes a small bug I reported in Beta36 that missed the cut for v1 RC0
2) Adds new flexibility in using either string or cliloc entries when calling AddCraft and Subsquent methods.
3) Extends the Crafting subsystem to be able to handle crafting objects that require parameters on their constructor.
etc... etc...


You are the grandmaster of C# dude! Are you on the development team? How do you find the time to do this stuff?!

Thanks again! This will help me with a couple of modules I've been playing with at home. I'd give ya more good Karma if I could, but I've given you some already and haven't given out enough to others yet... oh well... Cheers dude!
Vector1 is offline   Reply With Quote
Old 04-13-2004, 12:11 PM   #3 (permalink)
 
Join Date: Feb 2004
Location: Canada eh
Posts: 413
Default

Quote:
Originally Posted by Vector1
You are....Cheers dude!
um.... thx.

But any comments from you script developers out there on what you were able to do with this? Did I miss any cases, I know I found a bug late in the process, just before publishing this, where the crafting gump was trying to display the image of the item and failed horribly, did anyone see any other problems like that?

Part of my intent with adding the ability to use parameters was to make it so we don't need to create shell objects for things like cannon which take a parameter on the constructor. Today we have MediumStoneTableEastDeed and MediumStoneTableSouthDeed. With this we could have just one MediumStoneTableDeed that took a direction as a parameter, and still have both craftable.

Also to facilitate things like making 12 shafts from one log using something like
Code:
AddCraft( typeof( Shaft ), 1044457, 1027124, 0.0, 40.0, typeof( Log ), 1044041, 1, 1044351,  new object[] {12} );
Anyway, looking forward to any comments or questions.
--------------------------------------------------------------------------------
awdball · NON-beligerent Forum Member · · · · ;^) · · · · RUNUO-FAQ
The team for moderation on RUNUO Forums · · · · HelpSomeone
(old school c coder learning and luvin c#) · · · · · · · Great C# Tutorial
__________________
awdball
awdball is offline   Reply With Quote
Old 05-09-2004, 07:18 PM   #4 (permalink)
Newbie
 
Join Date: Apr 2004
Location: Alabama
Age: 19
Posts: 91
Send a message via ICQ to weaselboy246 Send a message via AIM to weaselboy246
Exclamation

Quote:
Originally Posted by awdball
um.... thx.

But any comments from you script developers out there on what you were able to do with this? Did I miss any cases, I know I found a bug late in the process, just before publishing this, where the crafting gump was trying to display the image of the item and failed horribly, did anyone see any other problems like that?

Part of my intent with adding the ability to use parameters was to make it so we don't need to create shell objects for things like cannon which take a parameter on the constructor. Today we have MediumStoneTableEastDeed and MediumStoneTableSouthDeed. With this we could have just one MediumStoneTableDeed that took a direction as a parameter, and still have both craftable.

Also to facilitate things like making 12 shafts from one log using something like
Code:
AddCraft( typeof( Shaft ), 1044457, 1027124, 0.0, 40.0, typeof( Log ), 1044041, 1, 1044351,  new object[] {12} );
Anyway, looking forward to any comments or questions.
--------------------------------------------------------------------------------
awdball · NON-beligerent Forum Member · · · · ;^) · · · · RUNUO-FAQ
The team for moderation on RUNUO Forums · · · · HelpSomeone
(old school c coder learning and luvin c#) · · · · · · · Great C# Tutorial
what about Beverages? i used your script and it made the server crash
Code:
			index = AddCraft( typeof( BeverageBottle ), "Drinks", "Bottle of Ale", 

SkillName.Cooking, 0.0, 100.0, typeof( SackFlour ), 1044468, 1, 1044253, new object[] 

{BeverageType.Ale, 1} );
			AddRes( index, typeof( BaseBeverage ), 1046458, 1, 1044253 );
			AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
weaselboy246 is offline   Reply With Quote
Old 05-09-2004, 07:57 PM   #5 (permalink)
Newbie
 
Join Date: Apr 2004
Location: Alabama
Age: 19
Posts: 91
Send a message via ICQ to weaselboy246 Send a message via AIM to weaselboy246
Default

Quote:
Originally Posted by weaselboy246
what about Beverages? i used your script and it made the server crash
Code:
			index = AddCraft( typeof( BeverageBottle ), "Drinks", "Bottle of Ale", 

SkillName.Cooking, 0.0, 100.0, typeof( SackFlour ), 1044468, 1, 1044253, new object[] 

{BeverageType.Ale, 1} );
			AddRes( index, typeof( BaseBeverage ), 1046458, 1, 1044253 );
			AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
nevermind... figured it out, you confused me with {BeverageType.Ale, 1} take off the 1
weaselboy246 is offline   Reply With Quote
Old 05-10-2004, 02:24 AM   #6 (permalink)
 
Join Date: Feb 2004
Location: Canada eh
Posts: 413
Default

Quote:
Originally Posted by weaselboy246
nevermind... figured it out, you confused me with {BeverageType.Ale, 1} take off the 1
Glad you got it to work. I know I showed someone how to do this just the other day, funny though I can't find my post. I never suggested {BeverageType.Ale, 1} to anyone though. pretty sure I said new object[] { BeverageType.Ale }... it was somehting about HopsCones or some such as the base material.... oh well, just glad you got it to work.
-----------------------------------------------------------------------------------------------------------------------------------
awdball · NON-beligerent Forum Member · · · · ;^) · · · · RUNUO-FAQ · · [CODE] Post CODE inside tags [/CODE]
The team for moderation on RUNUO Forums · · · · HelpSomeone · · CAPitalizaTION Counts m_BeCareful!
(old school c coder learning and luvin c#) · · · · · · · Great C# Tutorial
__________________
awdball
awdball is offline   Reply With Quote
Old 05-13-2004, 01:15 AM   #7 (permalink)
Forum Expert
 
flowerbudd's Avatar
 
Join Date: Jul 2003
Location: Missouri
Age: 31
Posts: 701
Send a message via ICQ to flowerbudd Send a message via AIM to flowerbudd Send a message via MSN to flowerbudd Send a message via Yahoo to flowerbudd
Default

I have installed this, not all sure what it is, but i went ahead and added it in, and replaced, and it all compiles and all that, but when i went to make shafts the server crashed

Code:
using System;
using Server.Items;

namespace Server.Engines.Craft
{
	public class DefBowFletching : CraftSystem
	{
		public override SkillName MainSkill
		{
			get	{ return SkillName.Fletching; }
		}

		public override int GumpTitleNumber
		{
			get { return 1044006; } // <CENTER>BOWCRAFT AND FLETCHING MENU</CENTER>
		}

		private static CraftSystem m_CraftSystem;

		public static CraftSystem CraftSystem
		{
			get
			{
				if ( m_CraftSystem == null )
					m_CraftSystem = new DefBowFletching();

				return m_CraftSystem;
			}
		}

		public override double GetChanceAtMin( CraftItem item )
		{
			return 0.5; // 50%
		}

		private DefBowFletching() : base( 1, 1, 1.25 )// base( 1, 2, 1.7 )
		{
		}

		public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
		{
			if ( tool.Deleted || tool.UsesRemaining < 0 )
				return 1044038; // You have worn out your tool!
			else if ( !BaseTool.CheckAccessible( tool, from ) )
				return 1044263; // The tool must be on your person to use.

			return 0;
		}

		public override void PlayCraftEffect( Mobile from )
		{
			// no animation
			//if ( from.Body.Type == BodyType.Human && !from.Mounted )
			//	from.Animate( 33, 5, 1, true, false, 0 );

			from.PlaySound( 0x55 );
		}

		public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool 

toolBroken, int quality, bool makersMark, CraftItem item )
		{
			if ( toolBroken )
				from.SendLocalizedMessage( 1044038 ); // You have worn out your tool

			if ( failed )
			{
				if ( lostMaterial )
					return 1044043; // You failed to create the item, and some of your 

materials are lost.
				else
					return 1044157; // You failed to create the item, but no materials were 

lost.
			}
			else
			{
				if ( quality == 0 )
					return 502785; // You were barely able to make this item.  It's quality 

is below average.
				else if ( makersMark && quality == 2 )
					return 1044156; // You create an exceptional quality item and affix 

your maker's mark.
				else if ( quality == 2 )
					return 1044155; // You create an exceptional quality item.
				else				
					return 1044154; // You create the item.
			}
		}

		public override CraftECA ECA{ get{ return CraftECA.FiftyPercentChanceMinusTenPercent; } }

		public override void InitCraftList()
		{
			int index = -1;

			// Materials
			AddCraft( typeof( Kindling ), 1044457, 1023553, 0.0, 00.0, typeof( Log ), 1044041, 1, 

1044351 );

			AddCraft( typeof( Shaft ), 1044457, 1027124, 0.0, 40.0, typeof( Log ), 1044041, 1, 

1044351,  new object[] {12} );

			SetUseAllRes( index, true );

			// Ammunition
			index = AddCraft( typeof( Arrow ), 1044565, 1023903, 0.0, 40.0, typeof( Shaft ), 

1044560, 1, 1044561 );
			AddRes( index, typeof( Feather ), 1044562, 1, 1044563 );
			SetUseAllRes( index, true );

			index = AddCraft( typeof( Bolt ), 1044565, 1027163, 0.0, 40.0, typeof( Shaft ), 

1044560, 1, 1044561 );
			AddRes( index, typeof( Feather ), 1044562, 1, 1044563 );
			SetUseAllRes( index, true );

			// Weapons
			AddCraft( typeof( Bow ), 1044566, 1025042, 30.0, 70.0, typeof( Log ), 1044041, 7, 

1044351 );
			AddCraft( typeof( Crossbow ), 1044566, 1023919, 60.0, 100.0, typeof( Log ), 1044041, 7, 

1044351 );
			AddCraft( typeof( HeavyCrossbow ), 1044566, 1025117, 80.0, 120.0, typeof( Log ), 

1044041, 10, 1044351 );

			if ( Core.AOS )
			{
				AddCraft( typeof( CompositeBow ), 1044566, 1029922, 70.0, 110.0, typeof( Log ), 

1044041, 10, 1044351 );
				AddCraft( typeof( RepeatingCrossbow ), 1044566, 1029923, 90.0, 130.0, typeof( 

Log ), 1044041, 10, 1044351 );
//				AddCraft( typeof( OakBow ), 1044566, "Oak Bow", 35.0, 75.0, typeof( OakLog ), 

"OakLog", 7, 1044351 );
//				AddCraft( typeof( RedTreeBow ), 1044566, "RedTree Bow", 45.0, 80.0, typeof( 

RedTreeLog ), "RedTreeLog", 7, 1044351 );
//				AddCraft( typeof( DarkTreeBow ), 1044566, "DarkTree Bow", 50.0, 85.0, typeof( 

DarkTreeLog ), "DarkTreeLog", 7, 1044351 );
//				AddCraft( typeof( SwampBow ), 1044566, "Swamp Bow", 55.0, 90.0, typeof( 

SwampLog ), "SwampLog", 7, 1044351 );
//				AddCraft( typeof( KeranitBow ), 1044566, "Keranit Bow", 60.0, 95.0, typeof( 

KeranitLog ), "KeranitLog", 7, 1044351 );
//				AddCraft( typeof( AvalonBow ), 1044566, "Avalon Bow", 70.0, 100.0, typeof( 

AvalonLog ), "AvalonLog", 7, 1044351 );
//				AddCraft( typeof( ElvenBow ), 1044566, "Elven Bow", 80.0, 105.0, typeof( 

ElvenLog ), "ElvenLog", 7, 1044351 );
//				AddCraft( typeof( AsterxylonBow ), 1044566, "Asterxylon Bow", 90.0, 110.0, 

typeof( AsterxylonLog ), "AsterxylonLog", 7, 1044351 );
			}
//	Begining of modification by FNP to add Triel_Toria's lumber to the bowcrafting menu.

			// Set the overidable material
			SetSubRes( typeof( Log ), "LOGS" );

			// Add every material you want the player to be able to chose from
			// This will overide the overidable material
			AddSubRes( typeof( Log ),		"LOGS", 00.0, 0 );
			AddSubRes( typeof( OakLog ),		"OAK LOGS", 55.0, "You have no idea how to work 

this type of lumber." );
			AddSubRes( typeof( RedTreeLog ),	"REDTREE LOGS", 60.0, "You have no idea how to 

work this type of lumber." );
			AddSubRes( typeof( DarkTreeLog ),	"DARKTREE LOGS", 65.0, "You have no idea how to 

work this type of lumber." );
			AddSubRes( typeof( SwampLog ),		"SWAMP LOGS", 70.0, "You have no idea how to 

work this type of lumber." );			
			AddSubRes( typeof( KeranitLog ),	"KERANIT LOGS", 75.0, "You have no idea how to 

work this type of lumber." );
			AddSubRes( typeof( AvalonLog ),		"AVALON LOGS", 80.0, "You have no idea how to 

work this type of lumber." );
			AddSubRes( typeof( ElvenLog ),		"ELVEN LOGS", 85.0, "You have no idea how to 

work this type of lumber." );
			AddSubRes( typeof( AsterxylonLog ),	"ASTERXYLON LOGS", 90.0, "You have no idea how 

to work this type of lumber." );				

//	End of modification by FNP to add Triel_Toria's lumber to the bowcrafting menu.

			MarkOption = true;
			Repair = true;
		}
	}
}
__________________
Med-Surg Nurse, Full time Pittsburg State Univ Sophmore, and FT Mother to 5 kids
flowerbudd is offline   Reply With Quote
Old 05-13-2004, 11:08 AM   #8 (permalink)
 
Join Date: Feb 2004
Location: Canada eh
Posts: 413
Default

Quote:
Originally Posted by flowerbudd
...
Code:
	AddCraft( typeof( Shaft ), 1044457, 1027124, 0.0, 40.0, typeof( Log ), 1044041, 1, 1044351,  new object[] {12} );
	SetUseAllRes( index, true );
...
All of the modifiers to AddCraft use index to reference the craftable item in a list, therefore index must be set to the craftables list position. So what you have to do is change those two lines to capture the list position:
Code:
	index =   AddCraft( typeof( Shaft ), 1044457, 1027124, 0.0, 40.0, typeof( Log ), 1044041, 1, 1044351,  new object[] {12} );
	SetUseAllRes( index, true );
--editted in after--
By the way I hadn't tested the make 12 shafts from one log with the useall resources option yet. That's not working correctly so I don't suggest you use it I'll post a fix shortly. You can use just the addcraft line by itself, no SetUseAllRes for now.
-----------------------------------------------------------------------------------------------------------------------------------
awdball · NON-beligerent Forum Member · · · · ;^) · · · · RUNUO-FAQ · · [CODE] Post CODE inside tags [/CODE]
The team for moderation on RUNUO Forums · · · · HelpSomeone · · CAPitalizaTION Counts m_BeCareful!
(old school c coder learning and luvin c#) · · · · · · · Great C# Tutorial
__________________
awdball
awdball is offline   Reply With Quote
Old 05-13-2004, 11:46 AM   #9 (permalink)
 
Join Date: Feb 2004
Location: Canada eh
Posts: 413
Default

I believe the fix to get SetUseAllRes to work when the craftable has a quantity is to change in CraftItem.cs (line 1241) the CompleteCraft method this
Code:
	if ( maxAmount > 0 )
		item.Amount = maxAmount;
to this
Code:
	if ( maxAmount > 0 )
		item.Amount = item.Amount * maxAmount;
Again I haven't finished testing this I'm just reading the code while I'm at work. I'll test later tonight and post the results. Thanks Flowerbudd for getting me thinking about this!
--editted--
Finished testing, worked like a charm, updated the download. May I suggest flowerbudd that you use this:
Code:
	index = AddCraft( typeof( Shaft ), 1044457, "Shafts (Logs x 12)", 0.0, 40.0, 
		typeof( Log ), 1044041, 1, 1044351,  new object[] {12} ); 
	SetUseAllRes( index, true );
I modified the label to highlight that the Shafts will be made 12 per log/board, because otherwise that's not shown on the crafter's gump anywhere.
-----------------------------------------------------------------------------------------------------------------------------------
awdball · NON-beligerent Forum Member · · · · ;^) · · · · RUNUO-FAQ · · [CODE] Post CODE inside tags [/CODE]
The team for moderation on RUNUO Forums · · · · HelpSomeone · · CAPitalizaTION Counts m_BeCareful!
(old school c coder learning and luvin c#) · · · · · · · Great C# Tutorial · · Good forum searching tips
__________________
awdball
awdball is offline   Reply With Quote
Old 05-18-2004, 01:46 PM   #10 (permalink)
Forum Expert
 
flowerbudd's Avatar
 
Join Date: Jul 2003
Location: Missouri
Age: 31
Posts: 701
Send a message via ICQ to flowerbudd Send a message via AIM to flowerbudd Send a message via MSN to flowerbudd Send a message via Yahoo to flowerbudd
Default

Ohh i never saw the updated thread with your fix, the first post you had about it was the last i had seen and that one wasnt working for me, i will try this one
__________________
Med-Surg Nurse, Full time Pittsburg State Univ Sophmore, and FT Mother to 5 kids
flowerbudd is offline   Reply With Quote
Old 05-18-2004, 02:03 PM   #11 (permalink)
Forum Expert
 
flowerbudd's Avatar
 
Join Date: Jul 2003
Location: Missouri
Age: 31
Posts: 701
Send a message via ICQ to flowerbudd Send a message via AIM to flowerbudd Send a message via MSN to flowerbudd Send a message via Yahoo to flowerbudd
Default

No, it shows in the menu it should make x 12 but it only creates 1
__________________
Med-Surg Nurse, Full time Pittsburg State Univ Sophmore, and FT Mother to 5 kids
flowerbudd is offline   Reply With Quote
Old 05-18-2004, 03:46 PM   #12 (permalink)
 
Join Date: Feb 2004
Location: Canada eh
Posts: 413
Default

Quote:
Originally Posted by flowerbudd
No, it shows in the menu it should make x 12 but it only creates 1
Have you dnloaded all of the crafting system and replaced the original scripts with my mods (over and above that last little fix)?
--edditted--
got your PM flowerbudd, I sent you a merged version of my changes to CraftItem with your changes. Were the other script files unchanged? Did you use all of my other modded scripts in addition to CraftItem? (CraftGroup.cs, CraftGumpItem.cs, CraftRes.cs, CraftSystem.cs)
-----------------------------------------------------------------------------------------------------------------------------------
awdball · NON-beligerent Forum Member · · · · ;^) · · · · RUNUO-FAQ · · [CODE] Post CODE inside tags [/CODE]
The team for moderation on RUNUO Forums · · · · HelpSomeone · · CAPitalizaTION Counts m_BeCareful!
(old school c coder learning and luvin c#) · · · · · · · Great C# Tutorial · · Good forum searching tips
__________________
awdball
awdball is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5