Tes4Mod:Cobl/Projects/Wrye Crafting

Because this is a fairly specific and complicated proposal and may be countered with other proposals, I'm tagging it with my name. If it's accepted it will become "Cobl Crafting". The first two sections are all written by me (please do respond in them). To respond or discuss, please use Discussion section and sign comments as usual.

Wrye: Intial Thoughts
I'm not really into crafting mods, so handling crafting in Cobl has not been at the top of my to do list. (Besides, having not played with such mods, I'm not familiar with the popular variations.) However, it's looming up on the do list for a couple of reasons (upcoming MMM work, integrating Coleen's Oblivion Farmers Market, etc.). So, here goes...

Prefer Neutrality
Cobl has a policy of preferring to remain neutral when there are competing implementations of popular features. E.g. Cobl water sources should work fine with any Cobl-aware thirst mod. However, in defining commonality, sometimes some implementation decisions need to be standardized. E.g. the Dinner Plate for cooking provides a consistent, single way of consuming foods, which while being optional is strongly preferred to be used by eating mods. 

For crafting mods, the need for a common interface will necessarily draw more interface choices into Cobl. 

Cobl Commonality
Keeping in mind that Cobl's goal is establishing commonality, I see two main commonality considerations here:
Ability To Extend: It's important for various mods to be able to extend what can be crafted. E.g. one mod might allow crafting of Amber armor, while another might allow crafting of Obsidian armor. It should be easy for Cobl aware mods to add additional crafting "recipes".
Common Interface: The various crafting extensions provided by different mods should behave in a consistent way. E.g. if one cooking mod requires that a saucepan must be equipped in order to fry grits, then another mod that's going to fry rice should behave in the same way.

Triggers
A fundamental question is how do you trigger a crafting action? I.e. if you want to fletch an arrow, then how do you start doing it? The main approaches are:
Activate something in the outside world. I.e. to begin cooking the player activates an oven, which provides a menu. Or maybe you activate the oven while holding (somehow?) an item that needs to be cooked. 
Equip some item in inventory. E.g. equip a pen to write a scroll. Equip a saucepan to fry some food. (Of course, it's possible to allow both activating in the exterior world and equipping from inventory.)
Knowledge based approach. Equip a recipe, and if your conditions are correct (i.e. if you have the correct equipment, and/or have the right condition, e.g. are near an oven), then you'll carry out the action.

A consideration here is how much immersion is desirable. Extreme immersionists want the solution to be as close to real life as possible. (Get butter in hand. Put butter in saucepan. Equip potato. Use potato on shredder to get shredded potatoes. Get that and put it in saucepan. Etc.) The problems with this are: 
It's quite difficult to do given the limitations of the game engine; 
It's object expensive -- you need a lot of objects with a lot of scriped behaviors;
It's (IMO) ridiculously tedious; 
It's inconsistent with level of mechanics provided in default Oblivion (where e.g. to repair armor, you just equip a hammer and click through a menu several times; similarly for alchemy). 

(Insert several hours of pacing around and thinking here.) Okay, I've got a plan (next section). I had originally been thinking of a pure knowledge approach, but I'm going to go with mixed activators/equippers instead. However, I'm (generally) not going to go with extreme immsersion.

Specific Design
Okay, here's my plan of how to do things. Keep in mind that I really haven't played with crafting mods at all (other than a looking at MMM crafting briefly and skimming over some crafting topics), so I don't know how much of this is done and not done.

Overview
Essentially you will make items either through recipes or through converters. 

For converters, there's a container where that you place items in and later get different items out.
Immediate converters convert materials immediately. Put items in, and then immediately (or almost immediately) get different items out. Current grinder works like this. 
Continuous processing converters (this is the way the grinder should work) will process items one at a time, taking x number of seconds per item. You can interrupt the process at any time and remove both the converted and non-converted items.
Batch processing converters will take take an amount of time to process material. E.g. a tanning barrel. Put 10 hides in, come back in an hour and get ten tanned hides out. While hides are tanning, you won't be able to open the container.

For recipes, you activate or equip an item. This brings up a recipes menu which you then use to create stuff. 
The created items may go directly into player's inventory (if you made it continuously by hand), or may go into a container to be recovered later after enough time has passed (e.g an oven or cooking pot).
Recipes are divided into separate menus: BakingMenu, GrillingMenu, FryingMenu, HotForgeMenu, FletchingMenu, LeatherWorkingMenu, WritingMenu, etc. Each of these is triggered by activating/equipping specific items.
Recipe menus will work just like Cobl's Options menu. Mods can add new recipes into the recipe menu/container (most likely this would happen in the course of gameplay: reading a recipes book, being taught by someone, etc.) 

Time Consumption: When making items directly by hand, each item made will use up a specific amount of time. E.g. 10 minutes for 10 arrows, or four hours for a complex piece of armor. 
When you exit the crafting menus, the consumed time will kick in in the form of the clock jumping ahead. E.g. spend 6 hours crafting and the gametime clock will jump ahead six hours.
Player will have limited amount of time available to craft. Something like six to eight hours. After that time is used up, you won't be able to craft more. Or rather more accurately, the time left will be checked before you make the item. If the item takes two hours and you've only got one work hour left, then you won't be able to make the item.
As you spend time away from crafting your "craft available time" will recover steadily up to the max (6 or 8 hours). 

Skills: Crafting skills level can be maintained for each type of crafting (cooking, fletching, etc.) Crafting skill might be used to:
Determine if you can make an item at all. And/or what your chance of success at making it is. Or determine how high quality it is.
Determine how long it takes you to make the item. Higher skill level will allow you to create more items in a given amount of time.

Hopper Converters
One by one converter: Suppose something like the grinder, but have it take a given amount of time per conversion. E.g., like so... 
  on activate
  set timer to 0
  if timer > 0
    set timer to timer - getSecondsPassed
    return
   endif
   if self.getitemCount Bone
    self.removeItem bone 1
    set timer to timer + 1
   elseif self.getItemCount BigBone
    self.removeItem bigBone 1
    set timer to timer + 2
   endif
Now suppose that the player leaves the cell (thus suspending the script). No problem. In this case, when the player re-enters the cell, check time-date and compare to previous time-date, then remove that amount of time from the timer. (set timer to timer - timeAway). The script will then run every frame until the extra time is used up.

Suppose that an external script wants to extend this, then the script needs to be on an unplayable token in the container. It does the same trick of waiting until timer   glutty bread -> bread -> burn bread -> baking ash (the breads are retextured bread)
interaction needed with time consuming eg. changing ore to armour - it generally need an activator when activated then 1)really few times repeated then 2)the menu then looping animation until activate button is pressed then 3)flow gametime make exchange the item then 4) repeats step 2-3 until work done then 5) play animation that work was exhausting
instant merging ie. water+flour -> dough - this should be done like in crafty bits - by grabbing one near one (sometimes place with activator needed, it may be prooved with special item eg. mixing plate (I'll like steel one), sometimes not needed anything)
in-hand done actions - only simple menu and changes
:::::: (last two is similair and can be exchanged)
Majaczek 12:51, 8 May 2008 (EDT)


I asked autor of CLS version of crafty bits (continuating of original abandoned) for help/permission of including his work on his project page Majaczek 14:32, 8 May 2008 (EDT)