Oblivion Mod:Cobl/Projects/Hunger Effects
< Mod / Oblivion: Oblivion Mod: Cobl: Mods ! Modding ! ProjectsCobl: Old Project Page: This is an old and now inactive discussion article for a Cobl project. If you have questions about this or other Cobl projects, do not edit this page, but instead discuss it at the official forums on Relz topic. |
GoalsEdit
In order for hunger mods to know that the player has consumed food, then they must detect that somehow. There are several ways to do this, but they all seem to have problems. A major problem coming up with some way for hunger mods to detect food that is not available in Oblivion, and which may not be predictably available at all (e.g. because the mod that provides it may or may not be installed). The question is whether Cobl should provide some means to help here, and if so what that means will be. --Wrye 23:38, 24 October 2007 (EDT)
ApproachesEdit
Overview of known approaches to detecting food consumption...
- Add a script to the player and have script individually react to each type of food that the player may eat through onEquip item blocks.
- Pro: Doesn't script the food itself.
- Con: Conflicts with everything else that might want to modify the player.
- Con: Can only handle known foods.
- Add standard script effects
- Con: Requires adding script effects to food. Alchemists may be annoyed at this, since it uses up one effect slot.
Cobl AssistanceEdit
So, what could Cobl do to help?
- Provide Expanded Foods: Simply by including many foods, Cobl makes them available to hunger mod makers who can then handle them.
- Con: How would this handle new meats and misc. foods that are not added by Cobl? One option would be to go ahead and add them to Cobl -- but that implies essentially pushing all foods down into Cobl. Keep in mind that some overhauls add a lot of meat types (essentially a meat type for each type of animal).
- Standardize food effect scripts. Food mod makers would then include the appropriate script in the effects for their food. For vanilla and Cobl foods, the default Cobl install might not actually apply the effects -- that would be left to a glue esp.
- Pro: Very versatile. As long as both the hunger mod and the food mod are based on Cobl, then everything works. Hunger and food mods can be removed and replaced at will.
- Con: Requires adding script effects to food (or at the least non-standard foods).
ProposedEdit
TechnicalitiesEdit
Not sure if you're taking input on this, but one thing that all food ingredients seem to have in common is Restore Fatigue as the first effect. If you could somehow add a script to the Restore Fatigue effect that only triggers when eating ingredients (maybe make a new version of Restore Fatigue without the script, to use on all non-food Restore Fatigue effects), you could then determine when food is being eaten without sacrificing any of the other alchemical properties of food. In order for food added by mods to count as food, it would have to also have Restore Fatigue as its first effect. Just a thought, not sure if this would help or not... --TheRealLurlock Talk 23:47, 24 October 2007 (EDT)
- All of the pages under Cobl/Projects are open discussion (like the Community Portal). So feel free...
- You can't add a script to a regular, you can only add or rather (since almost all foods already have four effects) replace an effect. You wouldn't want to replace one of the basic "restore fatigue" effects because it's usually one of the first effects, and hence is available to low level alchemists. Replacing the top level effect is probably a better choice, but again cuts down on alchemy options (OTOH, if you're adding a bunch of ingredients/foods, then cutting down ingredient options is not that much of a problem, IMO).
- Another consideration is that not all foods provide "restore fatigue". Restore health is another common effect for foods, plus there are some others. (Mods in particular, are much more varied in the positive effects than vanilla oblivion is.)
- There are other complexities too. E.g., some of the food mods work so different races get different benefits from different foods. (E.g. Bosmer because of the Green Pact, only gain nutritional value from meat.) Hence it's not enough to know that something is food -- you have to know what sort of food it is, how big, etc.
- At least that's my understanding -- I'm not an expert at this. (Just moderately knowledgeable.) --Wrye 01:46, 25 October 2007 (EDT)
Haama: Hunger Approach OverviewEdit
Some ideas:
- Scripted Effects - in the script, include a few lines to restore the fatigue of the player, just as if it had been a Restore Fatigue effect. This would require replacing all Restore Fatigue effects with the scripted effect, so they can be mixed together to make a potion. The same can be done for Restore Health, or any other effect.
- Con: Restore Fatigue effect will have to be determined with a formula - pain to write and figure out and will be based on player's current Alchemy level rather than the level they made the potion at.
- Con: Still can't be mixed with Restore Fatigue effects on ingredients from other mods.
- Track when the player eats food - Ravida's Hunger mod seems to do this the best. Looking at an older version, there was a tracking script that would determine the player's total number of food items. To make sure that the food was eaten, a script was placed on every ingredient that would lower the total number on the tracking script when the player dropped a food item. If the player didn't drop any food, and the number of total food items dropped, then it was assumed the player ate the food and their hunger was decreased.
- Pro: No need for scripted effects on ingredients, so their alchemical effects remain intact. No need to "cook" the food.
- Con: Script on every ingredient, so they can't be used for anything else. The scripts are incredibly long as they have to check the item count of every ingredient 2x (when added and when dropped).
- Possible Con: Might be CPU intensive as you would have 100s of GetItemCounts and Sets every time you check (though I have no slow downs doing this with the Inventory Tracker - as long as it's only GetItemCounts and Sets there shouldn't be a problem).
- Con:' There could only be one override script, and it would be difficult as X'fyte found out.
- Track with Inventory Tracker - Use the Inventory Tracker mod instead to keep tabs on when the player eats some food.
- Pro: Specifically scripted to use minimal CPU.
- Pro: No need to add a script to the ingredient or use a scripted effect.
- Con: Requires OBSE and a separate mod (to be clear, I created Inventory Tracker and will keep it separate from COBL).
- Definition Containers (not a complete solution, just a thought) - One of the problems is determining what food is what. For instance, hunger mods will count Vension as 2 units of food and a Watermelon as 3 units of food. To separate the types, and require the player to eat a full selection of food, definition containers could be created (meat container, vegetable container, etc.). Whenever the player eats some food, you can use GetItemCount on the various containers to see what type of food they are. Modders would set up the containers themselves through a quest for compatibility. Also, as shown with the Keychain mod, mods can be created that will use COBL if it's installed without the need for 2 mods.
- OBSE Advantages Using OBSE can offer many solutions to some problems.
- Generalizing Ingredients - Ingredients are all viewed as the same, that is meats are the same as vegetables, etc. Without OSBE the only way to differentiate them would be through script coding. With OBSE, two options are available:
- Definition Containers - Run through the containers with GetInventoryObject, if you don't already have the reference to the food item.
- Model/Icon paths - OBSE can tell where the model file is. If the file path includes a directory called "meat" then assume it's a meat ingredient.
- Generalizing Ingredients - Ingredients are all viewed as the same, that is meats are the same as vegetables, etc. Without OSBE the only way to differentiate them would be through script coding. With OBSE, two options are available:
I'm sure I had more, but I'm hungry and tired right now. Also, a bit confused on what it is people want - there are many possibilites, so...--Haama 18:46, 25 October 2007 (EDT)
Wrye: Dinner Plate (Eating vs. Wortcraft)Edit
Haama's mention of containers got me to thinking... I'm not sure if the following has been done before. (It doesn't seem to be what Haama was talking about.)...
Suppose that we distinguish between wortcraft and eating? E.g., in wortcraft you don't actually eat something, rather you chew it up, extract the alchemical effect and then spit it out. (To make this distinction would require a different sound effect for equipping an ingredient then the current swallowing sound.) So, we would want to be able to both wortcraft a food ingredient and (separately) eat it. Here's how you do that...
- Equipping an ingredient from inventory counts as wortcraft. Chew, then spit. No change.
- To eat, you have a "dinner plate" in inventory. When you equip it, its script finds all (known) food in your inventory and transfers to a special remote container, which is then activated. You're now looking at all possible foods, and you have a count of all foods in the container.
- Now, you can take items out of the container, which will count as eating. The count of items eaten actually takes place when you close the container. At that point, the script again checks your inventory for food items, but this time, these will be removed and counted as eaten. Example:
- Script originally moves three apples to the container,
- player takes one (which moves it to player's inventory)
- player closes container (thus reverting to inventory menu),
- script senses this, checks players inventory again, finds one apple, removes it and counts it as one fruit unit eaten
- script then returns any remaining items back to the player's inventory
- So that works for known ingredients, how about ingredients added by other mods?
- They can get in the game too by having a quest script that watches the state of the main dinner plate object/quest.
- When the dinner plate is initializing (player has equipped dinner plate, but container has not opened yet), they also move their foods to the container.
- When the dinner plate is finalizing (container has closed, but remainders have not been returned yet), it does its count of food items in the players and removes them and counts them as eaten
- Pros and Cons
- Pro: Does not require scripts or script effects on individual ingredients.
- Pro: Distinguishes eating from wortcraft. Wortcraft is still possible and produces usual alchemy effects and skill gain, but eating does neither.
- Pro: Should be relatively easy to automate eating (if player wants). Same script that does the transfer to special container could also have a mode in which eating happens automatically. (I miss NOM style eating, where my pc ate stuff automatically -- not everyone's cup of tea, but many would enjoy it.)
- Pro: If script is automatable, then it could also be applied to companion, to cause the companion to automatically "eat" food.
- Pro: It makes eating more of a distinct action. I.e. it's a bit more "immersive" Rather than just having dinner plates in inventory, they could be lying on a table and work the same way when activated.
- Pro: Opens the option of treating a meal as more than the sum of its parts. E.g., fish plus a particular wine results in special spell effect being cast on player.
- Pro: Opens the option of responses like "You're too full to eat now!" Or "You're too ill to eat." or "You're a vampire. The thought of consuming anything but blood makes you nauseous."
- Pro: Opens the option of selective transfer. E.g., depending on player type, maybe only meat (Bosmer) or only vegetable (vegetarian for some reason) are transferred to the dinner plate container.
- Pro: Player knows exactly what items count as food.
- Con: People who want alchemical effects from eating won't like it.
- Con: A bit more complicated than just eating stuff out of inventory.
Again, I'm not a hunger mod expert, but I don't think I've seen this done before. --Wrye 21:29, 25 October 2007 (EDT)
- I've done a demo of this approach (Wrye Eating Demo.zip). Instead of a plate, I used a .Foods ingredient. (Seemed to work a little better than a plate -- no annoying "You cannot equip... message." -- but perhaps a dinner knife would be better.) Anyway, after you eat it the .Foods and exit the inventory, you'll get the container with your available foods as described above. Since it's just a demo, at the end, you'll get a message with a breakdown of what you "consumed". --Wrye 02:55, 26 October 2007 (EDT)
-
- Note: Dinner plate is implemented in Cobl (as of verison 1.12). --Wrye 00:28, 24 December 2007 (EST)
Scanner : Food -> Alchemical Converter -> Full IngredientEdit
Wrye's Dinner Plate or Wortcraft gave me this idea. Although untested and I don't know if it would work : Food gets scripted but have an unscripted counterpart as ingredient. A converter will change food and turn it into a normal ingredient (normally alchemists would prepare their ingredients anyway). A glue can turn vanilla ingredients seen as food into food and place converters to turn them to ingredients, but this is optional. Each modder of extra food could offer food with ot without converters and counterparts. Food gets identified by scripteffect and ingredient counterparts are thought to be part of Cobl already.
- Pros and Cons
- Pro: Food is easy to identify including how much it counts for hunger and type
- Pro: Once converted (and it could be reconverted) it has 4 effects and Cobl can treat it as normal ingredient
- Pro: Glues give options what food and ingredients to use. Converters allow InGame choices. Converters scripts only handle their own list and are easy.
- Con: Hunger users must at least convert vanilla food or otherwise can't use vanilla food as food (Although a vanilla food converter might turn vanilla ingredients to scripted food)
- Con: Two versions of foods lacking sensibility (see below).
- Con: The built-in alchemy menu throws all SEFF together and uses the first SEFF-script for the potion. And I don't know any way for the script from filtering out running from potions. Although this is a general 'Con' for any hunger mod I've seen using different script effects.
ADDITION: A slightly changed approach could just convert food (1st slot scripted, 2-4 the old 1-3 slots) into refined original 4-effect food. And it's restricted for master alchemists as 4 slots need mastery anyway. For chewing effects the script might give a proper replacement. So both would be consumable, but the refined has lost its food value, because of preparation. Naming would be different too (apple->refined apple). --Scanner 07:01, 27 October 2007 (EDT)
I'm no hunger expert, so if there is something wrong with this scheme, please tell me - or any other cons you can detect. --Scanner 04:27, 26 October 2007 (EDT)
- The main problem is sensibility. E.g., it sounds as if you would have two versions of all foods: one is an ingredient, while the other is a food. E.g., you would have lettuce (food) and lettuce (ingredient) -- and maybe a way of converting between the food. I think that this doesn't make much sense in gameplay -- why are there two versions of lettuce? You might suggest that one is "lettuce", but the other is "prepared lettuce" (the alchemical version). But this isn't consistent with the rest of the game world in which ingredients are specifically alchemical ingredients -- i.e. the only additional preparation that is needed is with normal alchemical apparatus. (By comparison, the logic that I followed for the grinder is: misc. items that are too large and/or too hard to be crushed by a mortar and pestle require the use of a grinder to convert them to ingredients. But that logic doesn't work for foods -- e.g. a head of lettuce is physically similar to a flower, and so should be an ingredient in the same way.)
- There are some other problems too (e.g., doubling the items makes for more than twice as much work, since the two types of each food must be kept paired somehow), but the main problem IMO is that it doesn't seems sensible to have two different types of lettuce ingredients. You need to have a logic behind such distinctions, and I don't see one here. --Wrye 20:19, 26 October 2007 (EDT)
-
- Then how sensible would be the following approach: Food items use the 1st slot and if you are master alchemist and want all 4 effects you "prepare" (convert) the food into an ingredient having 4 effects but named slightly differently to show it has no longer any food value (it looses its food value in favor of all 4 effects). Example : Apple (1st slot uses script for poison/food-value, eat detection and applies additionally original 1st slot effect if chewed) -> Refined Apple (no longer poisoned or usable for hunger). This scheme would even apply to all eating actors including poisoning or other script-effects. Another advantage would be that you could never really be safe from poisened (evil scripted) food without refining it as master alchemist. --Scanner 05:07, 27 October 2007 (EDT)
-
- But now I've got a major SEFF-mixing problem (see above + Cobl release thread). So this whole idea of using food scripts might be doomed anyway. If I don't find any solution I'll give up this suggestion. --Scanner 17:00, 27 October 2007 (EDT)
Tarnsman: Food != AlchemyEdit
Partially in response to Scanner's ideas above, but with additional ideas...
I'll throw my two septims in here, really my personal preference. I would like to see food treated as, well, food. Not as ingredients for potions. This is something that has bugged me since Morrowind. I especially disliked the MW mods in which cooking turns food items into essentially potions with many varied effects, some of them negative. Sort of an immersion breaker, at least for me. Foods should be restricted to one or two effects, (Heal, Cure, Fortify and Restore only) A few food items that require cooking to be edible or made safe to eat would be negative effects until cooked. Eating raw meat for example could have burden or weakness to disease as their first effect (possible scripting to increase duration of these effects?), but they would still satisfy the hunger requirement. Cooking foods would/should increase the 'nutritional' value of food toward the hunger requirements.
Also, I've never liked the attaching scripting to the food items, nor renaming as A Food - Apple, for example. After looking at all the hunger mods I think the best remains Primary Needs. The beauty of Primary Needs is its simple scripting. Granted each and every food item has to be included individually into the PN script, but that to me is the KISS (Keep It Simple, Stupid) solution. This of course assumes that PN will work with the COBL framework. Finally, There is no reason there couldn't be lettuce (food) and lettuce root (ingredient), apple (food) and apple seed (ingredient), strawberry and strawberry flower (ingredient) and so on. Granted this would require additional models/work to implement. Anyway, this is the broad outline of a hunger mod I was considering doing --Tarnsman 23:00, 16 November 2007 (PST)
- One of design principles of Cobl is to "Extend, but don't modify." Of course, that still leaves room for mods loading after Cobl to modify it + vanilla to do as Tarnsman suggests. (Mainly comes down to stripping foods of alchemical effects and/or giving them a single trivial/null alchemical effect.) --Wrye 17:46, 19 November 2007 (EST)
Joben: What about identifying food items by their name?Edit
Sorry I'm not up on wiki etiquete and usage hope I'm entering this right... Would it be practical to identify food items according to their name? For example, all items with the string "meat" or "bread" or "stew" or "berry" in their name are treated as food. If that's a check that only has to be run when you activate a Dinner Plate type item does it even matter if the list is a couple dozen words long, or even a hundred? If this works you won't have to do ANYTHING to the food items themselves and you won't need a list of specific food items.
CompletedEdit
The following changes have been implemented.
Dinner PlateEdit
An alternative approach for accessing food through a "dinner plate". Resolves several of the problems associated with hunger mods w/o require scripting of foods or the player. See Dinner Plate(Eating vs. Wortcraft) below.
- Votes:
- Support (as proposer) --Wrye 17:54, 19 November 2007 (EST)
- Support (misc. Bethsoft forum comments).
This proposal is discussed below and has been discussed on the forums several times with several positive comments and no negative comments. At this time it is tentatively approved (barring potential negative comments) and will be included in an upcoming version of Cobl. There may be some small changes (e.g., may present as dinner knife instead of a dinner plate or loaf of bread). --Wrye 17:54, 19 November 2007 (EST)
Implemented as of verison 1.12. Seems stable and complete as of version 1.15. For usage, see Projects/Hunger Effects. --Wrye 00:28, 24 December 2007 (EST)