Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Hunger Script

Hey, I just wanted to ask if there was a script for a hunger system out there. (The character's hunger stat slowly drops as the game goes on, and using food items restores it.) I'll gladly give credit for the script. Thanks in advance!
 
Why a script? This can be done pretty easily with common events.

Make one called "Hunger", trigger parallel process, condition switch "Game Start" (which you'll turn on after your beginning cutscreen)
- Wait 100 frames
- Control Variables: Hunger - 1
- Conditional Branch: If Hunger < 0...
    - Text: Ugh, I'm starving...
    - Game Over

Make one called "Eating", trigger none
- Text: Mmm, delicious!
- Control Variables: Hunger = 100

Make an item called "Food".
- Have it call common event "Eat".
- Make it usable through the menu only
- Consumable: Yes

You'll probably want to replace most of my numbers, starvation effects, etc., but that's the basic idea of it anyway.
 
Interesting, the negative connotation of the word 'hunger' would seem to indicate that when hunger == 0, I am NOT hungry. (thinking like a programmer).  Which leads us to think, "What would be 0, if hunger is 100?"
Energy, Stamina?  (Try those in your search, along with 'food') Also, try some of the other rmxp support sites.
Although RMXP.org is the "BEST" site (shameless plug! :) ), it's not the only site.

Arbiter, the problem is, there is no "Event Systems" forum, and even if there was people tend to focus on one specific solution rather than the problem. The requester may have just assumed that the only solution was a script. I don't see a problem with suggesting an event based solution if it solves the problem. The requester can always say, "Thank you for the suggestion, but I would like to do this with a script."
Of course, you are always equally welcome to suggest "it would be better to script...", but you should offer an explanation as to why it would be 'better', or more efficient.

Admittedly, Blakadder should have posted his question, as written, in the "Script Requests" forum. Or, written it as, "Could someone suggest ideas or example as to how I would create a 'hunger' system?"
Most likely the latter, since he didn't provide specific requirements it appears that he is looking for general guidance.

In this case, I think it's arbitrary & should be left up to the requester. Although he will still need to modify / alias the menu script (Window_Status) to show the 'hunger' or 'energy' status.
He'll also need to decide if he wants to have different 'nutrition' values for different foods (perhaps linked to the 'price' or 'recover HP' value of the item?), and if food also recovers HP at all.

I know I've run across systems that are similar to the request, I will have another look & see what I can find.

Be Well
 
The common event idea works well, except is there a way to make it work every certain number of steps?
And, again, sorry about posting this in the wrong section. I'm new to this site! :-[
 
No worries!  If a MOD wants it moved, they'll move it.

I took a quick look, and didn't find a script for hunger, energy or food. (I could have sworn I saw one somewhere...)

Anyways, to use events by steps...
This is the common event (parallel process)

Code:
Control Variables: [0001: hunger steps] = Steps          #set to current total steps taken
Control Variables: [0001: hunger steps] %= 10            #%= is the MOD function (divide by & give the remainder)
Conditional Branch: Variable [0001: hunger steps] == 0   
   Control Variables: [0002: hunger] -= 1                    #reduce the current hunger by one
   Conditional Branch: Variable [0002: hunger] == 0
      [i]do your starving commands here[/i]
   Branch End
Branch End

In the 2nd line, change '10' to the number of steps you want to use.

Be Well
 
Arbiter":967vpn4r said:
Why do people post events in the rgss support forum?, it would be better to script rather than use events, plus he asked for a script not an EVENT.

A script may very well be better, but nobody has offered one yet. I assumed that an imperfect solution was better than none at all. I didn't realize that was so offensive.  ???

@Brew, you're right, it doesn't make much sense. I wrote that event thinking of the OP's description rather than the players' experience... I've played games where having a high "bad" stat is actually a good thing, and it can be pretty confusing.  The first time I made a hunger system, I had it in reverse (+1 hunger, with starvation if it rose over 100). "Fullness" and "satiety" are other opposites of hunger, but I wouldn't use "satiety" because it's pretty uncommon.

Welcome to the site, BlakAdder. :D
 
Snuggles, I too was addressing BlakAdder's post, rather than yours. "The character's hunger stat slowly drops..." just seemed backward to my Left Brain! :)  and it also illustrated 'thinking outside the box' or 'looking from a different perspective' to help come up with a more robust Search.

I was disappointed my search came up dry. I know I've seen 'hunger' systems somewhere...???

Your solution was just fine, and illustrated the general logic needed.

There still needs to be some sort of feedback to the player that they are getting hungry.
This could be an "Energy" stat on the main menu, Status menu, or a HUD
Or something as simple as...

Code:
Control Variables: [0001: hunger steps] = Steps          #set to current total steps taken
Control Variables: [0001: hunger steps] %= 10            #%= is the MOD function (divide by & give the remainder)
Conditional Branch: Variable [0001: hunger steps] == 0   
   Control Variables: [0002: hunger] -= 1                    #reduce the current hunger by one
   Conditional Branch: Variable [0002: hunger] == 20
      Text: You're getting hungry
   Branch End
   Conditional Branch: Variable [0002: hunger] == 10
      Text: You are starting to feel faint. You'd better eat something now!
   Branch End
   Conditional Branch: Variable [0002: hunger] == 0
      Text: You collapse from malnutrition. TTFN!
      Game Over
   Branch End
Branch End

And yes, Blakadder, welcome.  Happy Gamemaking.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top