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/Hud

Ok this one was made in a joint effort by Myself, KHMP and Gando. This is a combination system.

DEMO

ScreenShot
http://i27.tinypic.com/ih8hs6.png[/img]

Things you will need:
1 empty common event
1 empty variable
1 switch
2 png's
1 empty script


Step 1:
  Take your empty common event and your empty variable and mix them together with 2 conditional branch and 1 wait.
      Once you've mixed them together it should look like this.
          ====================================================
          ||  {Hunger System Core}        {Paralleled}        {Hunger Switch}  ||
          ||=================================================||
          ||    Control Variables:[01] -= 2                                      ||
          ||      Conditional Branch: Variable [01] >= 101                  ||
          ||        Control Variable:[01] = 100                                ||
          ||                                                                                        ||
          ||      Branch End                                                                  ||
          ||      Conditional Branch:[01] <= 0                                ||
          ||        Change HP: Entire Party, -5                                          ||
          ||      Branch End                                                                  ||
          ||    Wait:60 frame(s)                                                            ||
          ====================================================
What we've done here is made the Hunger System Core run Parallel to a switch we've called Hunger. What we've also did was name a Variable Hunger. Every 60 frames 2 points will be subtracted from the Variable Hunger. If the Variable Hunger is equal to or greater then 101 then we set it back to 100. Sorry but you can't give your 110% in eating. We've also told it that if Variable Hunger is less then or equal to 0 to subtract 5 health points from the Entire Party. That pretty much means you're starving to death. Since this common event is paralleled it'll always run so long as it's switch is on. Now I bet you're wondering how we're going to show the player how hunger they are without showing a text box every 60 frames. Well that's where STEP 2 comes in.

Step 2:

You need this script
Code:
#==============================================================================
# Hunger_Hud
#------------------------------------------------------------------------------
# By: L0rdPh0enix
# Helped by: Khmp, Gando  
# 5/4/2008
#------------------------------------------------------------------------------
#==============================================================================
  HUD_SWITCH = 1
  Variablehunger = 1
  
class Hunger_Hud < Window_Base
  Max_Hunger = 100
  Hunger_Bar = 'Hunger_100'
  Hunger_Empty = 'Hunger_0'
  #--------------------------------------------------------------------------
  # * Initialize             
  #--------------------------------------------------------------------------
  def initialize
    super(151, 0, 96, 61)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 200
    self.visible = false
    @hunger_bar = Bitmap.new('Graphics/Pictures/' + Hunger_Bar)
    @empty_bar = Bitmap.new('Graphics/Pictures/' + Hunger_Empty)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    reset_variables
        # How full are we?
    percent = [@variablehunger / Max_Hunger.to_f, 1.0].min

    bar_width = (@hunger_bar.width * percent).to_i

    # First clear the bar's position. Draw the old bar first
    self.contents.blt(0, 3, @empty_bar, 
      Rect.new(0, 0, @empty_bar.width, @empty_bar.height))
    # Now draw the bar.
    self.contents.blt(0, 3, @hunger_bar, 
      Rect.new(0, 0, bar_width, @hunger_bar.height))
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    super()
    @hunger_bar.dispose unless @hunger_bar.disposed?
    @empty_bar.dispose unless @empty_bar.disposed?
  end

  def reset_variables
    @variablehunger = $game_variables[Variablehunger]
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    super
    refresh if @variablehunger != $game_variables[Variablehunger]
  end 
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map

  alias hungerhud_main main
  alias hungerhud_update update
  def main
    @hungerhud = Hunger_Hud.new
    hungerhud_main
    @hungerhud.dispose
  end
  def update
    if $game_switches[HUD_SWITCH]
      @hungerhud.visible = true
    else
      @hungerhud.visible = false
    end
    @hungerhud.update
    hungerhud_update
  end
end

This script is compatible with everything I think. Least it should be. You will however need those 2 png's I mentioned earlier for this. Since instead of this hud writing the text of how hunger you are, it shows it in a picture and how full the picture is.

These are the two pictures I use. Just put them in your Graphics/Pictures folder and the script does the rest.
http://i30.tinypic.com/2gwi0du.png[/img] << starving
http://i30.tinypic.com/24vsjl5.png[/img]<< full

Ok now you're asking yourself "Ok I'm starving, where am I gonna get something to eat?" Don't get your undies in a bunch. Just make the different foods you want in the database in Items and link em to their own common event that adds so much to the Hunger variable. Since I have a cooking skill in my game the player can cook and eat his or her own food  :thumb:. You don't have to make any food or common events to do this, just treat it like any other variable in the game.

Credits would be nice to all three of us if you use this thanks and Good Luck.

Oh and if you need any help with it just post it in this topic.
 
GENIUS! Im going to defiantly use this in my game. Do you take requests? this was such a cool idea i wonder what your capable of.  +1
 
No I don't have the scripting skills for request but If you put for a few of your ideas or needs I may be able to figure something out for you as far as eventing with a mix of some script.
 
Great!, this is perfect for a Survival Mini-Game. My game has a few missions
that do with the Desert. What I had was:
{ Event System: Parallel ------->  -1 Energy, Wait 180 Frames                                                    }
{ Event System 2: Parallel ----->  Wait 1600 Frames, +[Parched] State                                          }
{ Event System 3: Parallel ----->  Conditional Branch: Does P1 have [Parched]? => Change Speed 2    }
But yours is much better
 
This looks incredible, but I can't access the demo because the link is all weird. But chances are, I'll use this in one of my games. :3
 

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