Jump to content

Multiple result recipes


ghastley

Recommended Posts

Before I leap in and potentially re-invent a wheel, is there an existing implementation of constructible items with multiple results?

That is, more than one type of item is made, as multiples of a single item already exists, e.g. leather strips. It would have at least two uses: bonus items and deconstruction. My initial implementation wants to allow grain milling to result in both flour and straw, but I want to create a generic method. The idea is to borrow from hearthfire’s token system to run a script on the combo result that splits out the components when it enters the player’s inventory. It’s obvious enough that I expect it already exists, but can’t find it.

Link to comment
Share on other sites

The way it is set up, you can only create one specific item, though you can create more than one of that item.  So, for instant, in your example of grain milling, you could create either flour or straw, in whatever amount you choose, but not both.  To get two specific items, you would need to set a two-step process, first create one specific item of any number, and then, using some of the resulting items, make the second item from the crafting options.  So there would be two separate records listed under the Constructible Object category.  One would be the initial item created, and the second would be for the item which is created by using those initial items.

 

As for creating two separate specific items from one, if there is a way to possibly do it, I certainly have never seen it in any mod.

Link to comment
Share on other sites

I should add, that it is possible to get multiple items from one item, but not via the crafting stations - rather through something like what is used by Aviform in the mod Better and Breakable Eggs , where when an egg is destroyed, you get both the yolk and the eggshell.  

Link to comment
Share on other sites

The method I intend using is similar to the way Hearthfire does it as described at http://ghastley.org/Skyrim/ModNotes/HearthfiresMods.html using a Misc Item token with an attached script. It's the two-step process rolled into one as far as the player sees. Make one item and the conversion to multiple is behind the scenes.

Instead of calling the BuildingItem script, the inventory token will simply AddItem the results, and then RemoveItem itself. No enabling of world items needed in this case, because it's all in the container, conveniently the same one that triggers the OnContainerChanged(). Heartfire DLC had to track what you'd made to avoid duplicates etc, but this is much simpler.

Current plan is two options - second item is added randomly, or always. Either item can be an item list, as AddItem takes single or list. Lots of properties, so the script can be applied to any result token, which can be the result of a regular recipe.

 

Edit: I'm starting to think this may not be needed. The current recipe for Flour produces a leveled list result. with the possibility of 1-4 sacks. A different LeveledItem could mix them without added scripts, or intermediates. LeveledItem already has the "chance of none" and the multiple returns. More experimentation is required 

Mis-read that. LeveledList is not valid for result.

Link to comment
Share on other sites

Spoiler
Scriptname BYOHMaterialScript extends Form  
{script for fake inventory objects used for crafting multiple items
}

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	debug.trace(self+" akNewContainer = "+akNewContainer+",  akOldContainer = "+akOldContainer)
	If akNewContainer == Game.GetPlayer() && akOldContainer == None
		; Add the always item
		if AddItem
			Game.GetPlayer().AddItem(AddItem, CountItem, true) ; add item silently
		endif
		if AddItem2 
			If Random == 100
				Game.GetPlayer().AddItem(AddItem2, CountItem2, true) ; add item silently
			elseif Random > 0
 				If Utility.RandomInt() <= Random
					Game.GetPlayer().AddItem(AddItem2, CountItem2, true) ; add item silently
				endif
			endif
		endif
	EndIf
	Game.GetPlayer().RemoveItem(MySelf, 1, true) ; And remove token item
EndEvent


MiscObject Property mySelf Auto
{ So it can be removed after the rest are added }

FormList Property AddItem Auto
{ the item. or list of items,  that is ALWAUS created }

FormList Property AddItem2 Auto
{ The item or list that may be added as bonus }

int Property Random Auto
{ percentage chance of adding AddItem2. 100 = always, 0 = never }

Int Property CountItem  Auto  

Int Property CountItem2  Auto  

 

It seems to work. The items have to be put in lists, and the count applies to each item in that list, but there's enough flexibility for what I need right now.I'm making 5 Sacks of flour and one Straw from 15 Wheat. The little .esl mod that uses it will be available soon, once I sort out packaging.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...