[XP] Hunger/Thirst

Started by ForeverZer0, May 14, 2010, 05:54:10 pm

Previous topic - Next topic

ForeverZer0

May 14, 2010, 05:54:10 pm Last Edit: May 30, 2011, 09:34:19 pm by ForeverZer0
Hunger & Thirst
Authors: ForeverZer0
Version: 1.1
Type: Party/Actor Add-On
Key Term: Actor Add-on



Introduction

Basically the title says it all. This script will add a Hunger/Thirst dynamic to your game. Actor's hunger/thirst will decrease over time or by stepcount. Has configuration for food/drink items and for states that will be added to actors whose hunger/thirst falls within specified ranges.


Features


  • Easy to use
  • Hunger/Thirst can decrease by time, stepcount, or both.
  • Can have the player's max hunger/thirst capacity increase with levels
  • Easy script offer complet manipulation of system and actors' hunger/thirst
  • Automatically applies states (configurable)
  • Hunger/Thirst recovery can be by either percent or by absolute value



Screenshots

None.


Demo

None.


Script

Click here for the script.
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Hunger/Thirst
# Author: ForeverZer0
# Date: 5.14.2010
# Version: 1.0
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Features:
#   - Easy to use
#   - MUCH less complicated than many other similar scripts, yet it has more
#     features and less code
#   - Can have hunger and thirst decrease by time intervals or by steps walked
#     by the player
#   - Ability to have each character's 'Max Hunger' increase so that they can go
#     longer in between food and drinks as they gain in power
#   - Can use script calls to easily change hunger/thirst values, and to disable
#     the system for long cutscenes, etc. so that nothing decreases while the
#     player does not have control
#   - Automatically added states if hunger/thirst is at specific rates.
#
# Compatibility:
#   - If using Zero Add-On Collection, place this script below it. There is a
#     minor issue with the Chemist Class script, but placing this script below
#     it will solve the problem.
#
# Instructions:
#   - Place script below debug, and above main (below Zer0 Add-Ons, if present)
#   - All configuration is below and described fully in its respective section
#   - The following script calls can be used in game:
#
#    ►  Zer0.hunger_system(true/false)  
#       - If false, hunger/thirst rates will not decrease. Good for long scenes
#         where the player is not in control, etc. The system will remain ON/OFF
#         until it is changed.
#
#    ►  Zer0.set_hunger(ACTOR_ID, AMOUNT)
#    ►  Zer0.set_thirst(ACTOR_ID, AMOUNT)
#       - Sets the hunger/thirst of actor in your database with ACTOR_ID to the
#         number specified by AMOUNT
#
#    ►  Zer0.set_max_hunger(ACTOR_ID, AMOUNT)
#    ►  Zer0.set_max_thirst(ACTOR_ID, AMOUNT)
#       - Sets the MAX hunger/thirst of actor in your database with ACTOR_ID to
#         the number specified by AMOUNT
#
#    ►  Zer0.recover_hunger(ACTOR_ID)
#       - Will recover all hunger/thirst to actor with ACTOR_ID. If you omit the
#         ( ) at the end of the script call, it will recover the entire party.
#
#    ►  Zer0.actor_hunger_id(ACTOR_ID)
#       - Returns the current hunger of actor with ACTOR_ID
#
#    ►  Zer0.actor_thirst_id(ACTOR_ID)
#       - Returns the current thirst of actor with ACTOR_ID
#
#    ►  Zer0.actor_hunger_pos(POSITION)
#       - Return the current hunger of actor at party POSITION
#         (0 is the leader, 1 is actor 2, etc)
#
#    ►  Zer0.actor_thirst_pos(POSITION)
#       - Return the current thist of actor at party POSITION
#         (0 is the leader, 1 is actor 2, etc)
#
#    ►  Zer0.hunger_debugger
#       - Displays info on-screen of each characters hunger/thirst, current
#         count for steps and time, and shows which features are currently ON.
#
# Special Thanks:
#   - kukusu, whose request gave me the inspiration for the script
#   - SBR*, for pointing out a stupid error I made with the stepcount
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:


#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#                          BEGIN CONFIGURATION
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

module Zer0
 
 DEFAULT_HUNGER = 100          
 DEFAULT_THIRST = 100          
 # Default max hunger/thirst players will begin with. This can be increased as
 # the player becomes more powerful, through items, etc. if desired.
 
 BY_TIME   = true
 BY_STEPS  = true
 # There are two ways hunger and thirst can be calculated; one by just how many
 # seconds pass, and the other by how many steps have been taken. You can use
 # both if you like, but I would suggest that if you do to try to keep it more
 # skewed to one or the other as the main method of decreasing, and use the
 # other as a minor added dynamic.
 
 STEPS_HUNGER_DOWN = 100  
 STEPS_THIRST_DOWN = 80
 # Only if using 'BY_STEPS', otherwise ignore these. These are the amount
 # of steps before hunger/thirst decrease.
 
 SECS_HUNGER_DOWN = 120
 SECS_THIRST_DOWN = 120
 # Only if using 'BY_TIME', otherwise ignore these. These are the amount
 # of seconds before hunger/thirst decrease.
 
 LVL_UP_INCREASE = true
 # If true, will increase max hunger/thirst at each level up, the amount of
 # increase is defined just below.
 LVL_UP_AMOUNT = 5
 # This will be added to the actor's max hunger/thirst at each level up, only
 # if LVL_UP_INCREASE is true.

#-------------------------------------------------------------------------------
# Food/Drink Items:
#
#   Set up your food/drink items recovery rates here. Food and drink are each in
#   their own section. Use this syntax to set them up:
#
#     when ITEM_ID the return RECOVERY_AMOUNT
#
#   For example, in the first example below, it means that the item in your
#   database with ID(1) will cure hunger by 15. If RECOVER_BY_PERCENT (below) is
#   set to true, it will recover 15% of that actors MAX hunger/thirst.
#
#   You can also create items that have negative effects by making the
#   RECOVERY_AMOUNT a negative number. DO NOT have food/drink items do anything
#   other than recover hunger/thirst and/or add/remove states. Anything else,
#   such has HP/MP recovery, will have no effect.
#
#-------------------------------------------------------------------------------

 RECOVER_BY_PERCENT = true
 # Recovery can be by either absolute value, or by percent. Setting this to
 # true will make it by percent.

 def self.food(item_id)
   case item_id
   when 1 then return 15
   when 2 then return 25
   when 3 then return 35
   when 4 then return 50
   when 5 then return 75
   when 6 then return 100
   end
 end
 
 def self.drink(item_id)
   case item_id
   when 1 then return 15
   when 2 then return 25
   when 3 then return 35
   when 4 then return 50
   when 5 then return 75
   when 6 then return 100
   end
 end
 
#-------------------------------------------------------------------------------
# Hunger/Thirst States
#
#   Set up states that will be applied when an actors hunger/thirst fall within
#   a defined range, such as 'Starvation', 'Dehydration', etc.
#   Configure like this:
#
#   when MIN..MAX then return STATE_ID
#
#   If actor's hunger/thirst is equal to or between MIN and MAX, the state with
#   STATE_ID will be applied. This method is refreshed everytime the system
#   decreases hunger/thirst.
#
#   Keep in mind that these states will NOT be automatically cured if the actor's
#   hunger/thirst rise above. Create your food/drink items to cure these states.
#
#-------------------------------------------------------------------------------

 def self.hunger_states(current_hunger)
   case current_hunger
   when 0 then return 1
   when 1..9 then return 2
   when 10..15 then return 3
   end
 end
 
 def self.thirst_states(current_thirst)
   case current_thirst
   when 0 then return 1
   when 1..9 then return 2
   when 10..15 then return 3
   end
 end
     
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#                             END CONFIGURATION
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

 def self.hunger_system(value)
   $game_party.hunger = value
   return true
 end

 def self.set_hunger(actor_id, amount)
   $game_party.actors.each {|a| a.hunger = amount if a.id == actor_id}
 end
   
 def self.set_thirst(actor_id, amount)
   $game_party.actors.each {|a| a.thirst = amount if a.id == actor_id}
 end  
 
 def self.set_max_hunger(actor_id, amount)
   $game_party.actors.each {|a| a.max_hunger = amount if a.id == actor_id}
 end
   
 def self.set_max_thirst(actor_id, amount)
   $game_party.actors.each {|a| a.max_thirst = amount if a.id == actor_id}
 end  
 
 def self.actor_hunger_id(actor_id)
   $game_party.actors.each {|a| return a.hunger if a.id == actor_id}
 end
 
 def self.actor_thirst_id(actor_id)
   $game_party.actors.each {|a| return a.thirst if a.id == actor_id}
 end
 
 def self.actor_hunger_pos(pos = 0)
   return $game_party.actors[pos].hunger if $game_party.actors[pos] != nil
 end
 
 def self.actor_thist_pos(position = 0)
   return $game_party.actors[pos].thirst if $game_party.actors[pos] != nil
 end
 
 def self.recover_hunger(actor_id = nil)
   $game_party.actors.each {|actor|
     if actor_id == nil
       actor.hunger = actor.max_hunger
       actor.thirst = actor.max_thirst
     elsif actor.id == actor_id
       actor.hunger = actor.max_hunger
       actor.thirst = actor.max_thirst
     end
   }
 end
 
 def self.hunger_debugger
   sys = "System ON: #{$game_party.hunger}\n\n" +
         "By Time: #{BY_TIME}\n" +
         "By Steps: #{BY_STEPS}\n\n"
   actors = ''
   $game_party.actors.each {|actor| actors +=
     "#{actor.name}\nHunger: #{actor.hunger}\\#{actor.max_hunger}\n" +
     "Thirst: #{actor.thirst}\\#{actor.max_thirst}\n\n"}
   ht = "HungerTime: #{$game_party.time_hunger/40}\\#{SECS_HUNGER_DOWN}\n"
   tt = "ThirstTime: #{$game_party.time_thirst/40}\\#{SECS_THIRST_DOWN}\n"
   hs = "HungerStep: #{$game_party.steps}\\#{$game_party.step_hunger}\n"
   ts = "ThirstStep: #{$game_party.steps}\\#{$game_party.step_thirst}\n"
   print(sys + actors + ht + tt + hs + ts)
 end
 
end

#-------------------------------------------------------------------------------
# ** Game_Actor
#-------------------------------------------------------------------------------

class Game_Actor < Game_Battler
 
 attr_accessor :hunger
 attr_accessor :max_hunger
 attr_accessor :thirst
 attr_accessor :max_thirst
 
 alias zer0_hunger_setup setup
 def setup(actor_id)
   zer0_hunger_setup(actor_id)
   @hunger = @max_hunger = Zer0::DEFAULT_HUNGER
   @thirst = @max_thirst = Zer0::DEFAULT_THIRST
   if Zer0::LVL_UP_INCREASE && @level > 1
     increase = Zer0::LVL_UP_AMOUNT
     @hunger = @max_hunger = (@level - 1) * increase + Zer0::DEFAULT_HUNGER
     @thirst = @max_thirst = (@level - 1) * increase + Zer0::DEFAULT_THIRST
   end
 end
 
 alias zer0_hunger_level_up exp=
 def exp=(exp)
   level = @level
   zer0_hunger_level_up(exp)
   if Zer0::LVL_UP_INCREASE && level != @level
     lvls = @level - level
     @max_hunger += (Zer0::LVL_UP_AMOUNT * lvls)
     @max_thirst += (Zer0::LVL_UP_AMOUNT * lvls)
   end
 end  
end

#-------------------------------------------------------------------------------
# ** Game_Battler
#-------------------------------------------------------------------------------

class Game_Battler
 
 alias test item_effect
 def item_effect(item)
   food_item = false
   hunger_plus = Zer0.food(item.id)
   thirst_plus = Zer0.drink(item.id)
   if hunger_plus != nil
     if Zer0::RECOVER_BY_PERCENT
       hunger_plus = (self.max_hunger * (hunger_plus * 0.01)).ceil
     end
     self.hunger += hunger_plus
     self.hunger = [[self.hunger, self.max_hunger].min, 0].max      
     food_item = true
   end
   if thirst_plus != nil
     if Zer0::RECOVER_BY_PERCENT
       thirst_plus = (self.max_thirst * (thirst_plus * 0.01)).ceil
     end
     self.thirst += thirst_plus
     self.thirst = [[self.thirst, self.max_thirst].min, 0].max
     food_item = true
   end
   if food_item
     states_plus(item.plus_state_set)
     states_minus(item.minus_state_set)
     return true
   end
   test(item)
 end
end

#-------------------------------------------------------------------------------
# ** Game_Party
#-------------------------------------------------------------------------------

class Game_Party
 
 attr_accessor :hunger
 attr_accessor :time_hunger
 attr_accessor :time_thirst
 attr_accessor :step_hunger
 attr_accessor :step_thirst
 
 alias zer0_hunger_system_init initialize
 def initialize
   zer0_hunger_system_init
   @hunger = true
   @time_hunger = @time_thirst = 0
   @step_hunger = Zer0::STEPS_HUNGER_DOWN
   @step_thirst = Zer0::STEPS_THIRST_DOWN
 end
 
 def check_hunger_states
   @actors.each {|actor|
   state_id = Zer0.hunger_states(actor.hunger)
   actor.add_state(state_id) if state_id != nil}
 end
 
 def check_thirst_states
   @actors.each {|actor|
   state_id = Zer0.thirst_states(actor.thirst)
   actor.add_state(state_id) if state_id != nil}
 end
 
end

#-------------------------------------------------------------------------------
# ** Scene_Map
#-------------------------------------------------------------------------------

class Scene_Map
 
 alias zer0_hunger_map_upd update
 def update
   zer0_hunger_map_upd
   if $game_party.hunger
     update_hunger
   end
 end
 
 def update_hunger
   if Zer0::BY_TIME
     $game_party.time_hunger += 1
     $game_party.time_thirst += 1
     if $game_party.time_hunger == (Zer0::SECS_HUNGER_DOWN * 40)
       $game_party.actors.each {|actor|
         actor.hunger -= 1 unless actor.dead? || actor.hunger == 0}
       $game_party.check_hunger_states
       $game_party.time_hunger = 0
     end
     if $game_party.time_thirst == (Zer0::SECS_THIRST_DOWN * 40)
       $game_party.actors.each {|actor|
         actor.thirst -= 1 unless actor.dead? || actor.thirst == 0}
       $game_party.check_thirst_states
       $game_party.time_thirst = 0
     end
   end
   if Zer0::BY_STEPS
     if $game_party.steps == $game_party.step_hunger
       $game_party.actors.each {|actor|
         actor.hunger -= 1 unless actor.dead? || actor.hunger == 0}
       $game_party.check_hunger_states
       $game_party.step_hunger = $game_party.steps + Zer0::STEPS_HUNGER_DOWN
     end
     if $game_party.steps == $game_party.step_thirst
       $game_party.actors.each {|actor|
         actor.thirst -= 1 unless actor.dead? || actor.thirst == 0}
       $game_party.check_thirst_states
       $game_party.step_thirst = $game_party.steps + Zer0::STEPS_THIRST_DOWN
     end
   end
 end
end


Here is also an Add-On I made for the system. It is a HUD that displays hunger/thirst rates using gradient bars for the party. There are a few instructions in the script, but most are self-explanatory. As of the moment, there are only two styles of bars, but both have fully configurable width, height, gradient colors, etc. I may end up doing more with the Gradient Bars script in the future, but for the moment, it is what it is.

Spoiler: ShowHide

#===============================================================================
# ** Hunger_HUD
#===============================================================================

class Hunger_HUD < Window_Base

  #====================================================================#
  #                    BEGIN CONFIGURATION                             #
  #====================================================================#
 
  # Define the colors used for each of the bars.
  HUNGER_EMPTY = Color.new(255, 0, 0)
  HUNGER_FULL = Color.new(0, 255, 0)
 
  THIRST_EMPTY = Color.new(96, 96, 96)
  THIRST_FULL = Color.new(128, 128, 255)
 
  BACKGROUND_COLOR = Color.new(0, 0, 0)
 
  # Define the type of bar used. (0 = Gradient, 1 = Transitional)
  # It would take longer to explain the differences than to just try each out.
  # There's only two as of the moment.
  BAR_STYLE = 1
 
  # Define the width and height, in pixels, of the bars.
  BAR_WIDTH = 128
  BAR_HEIGHT = 8
 
  # Define switch for active/visibility control within game.
  ONOFF_SWITCH = 10
 
  #====================================================================#
  #                     END CONFIGURATION                              #
  #====================================================================#
 
  def initialize(y = -12)
    super(0, y, 640, 96)
    # Set the windowskin's opacity to 0.
    self.windowskin = nil
    @colors1 = [HUNGER_EMPTY, HUNGER_FULL, BACKGROUND_COLOR]
    @colors2 = [THIRST_EMPTY, THIRST_FULL, BACKGROUND_COLOR]
    @actors = $game_party.actors
    @stats = stats
    refresh
  end
 
  def refresh
    # Dispose the contents of the HUD.
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    # Adjust width and location of window.
    self.width = @actors.size * (BAR_WIDTH + 48)
    self.x = (640 - self.width) / 2
    self.contents = Bitmap.new(self.width, self.height)
    # Iterate actors.
    @actors.each_index {|i|
      actor = @actors[i]
      # Calculate locations for each actor's bars.
      x = i * (BAR_WIDTH + 48)
      # Draw actor's name.
      self.contents.font.size = 16
      self.contents.draw_text(x, 0, BAR_WIDTH, 16, actor.name)
      # Draw hunger bars.
      w, h, rate, max = BAR_WIDTH, BAR_HEIGHT, @stats[i][0], @stats[i][1]
      self.contents.draw_bar(x, 16, w, h, rate, max, BAR_STYLE, @colors1)
      # Draw thirst bars.
      rate, max, height = @stats[i][2], @stats[i][3], 16+BAR_HEIGHT+4
      self.contents.draw_bar(x, height, w, h, rate, max, BAR_STYLE, @colors2)
    }
  end
 
  def stats
    return @actors.collect {|a| [a.hunger, a.max_hunger, a.thirst, a.max_thirst]}
  end
 
  def update
    self.visible = $game_switches[ONOFF_SWITCH]
    if self.visible
      if (@stats != stats) || (@actors != $game_party.actors)
        @stats, @actors = stats, $game_party.actors
        refresh
      end
    end
  end
end

#===============================================================================
# ** Gradient_Bar
#===============================================================================

class Bitmap
 
  def draw_bar(x, y, w, h, rate, max, style, colors = nil)
    # Set required instance variables.
    @bar_rect = Rect.new(x, y, w, h)
    @rate, @max, @style, @colors = rate, max, style, colors
    # Define default colors if not defined. (RED <--> GREEN)
    if @colors == nil
      @colors = [Color.new(255, 0, 0), Color.new(0, 255, 0), Color.new(0, 0, 0)]
    end
    # Draw the background color.
    self.fill_rect(@bar_rect, @colors[2])
    # Branch by what style is being used.
    case @style
    when 0 then gradient
    when 1 then transition
    end
  end
#-------------------------------------------------------------------------------
  def gradient
    # Get the bar from the cache.
    key = [@style, @bar_rect.width-2, @bar_rect.height-2, @colors[0], @colors[1]]
    bar = RPG::Cache.gradient_bar(*key)
    # Draw the gradient bar using rectangular transfer.
    rect = Rect.new(0, 0, fill_width, @bar_rect.height)
    self.blt(@bar_rect.x+1, @bar_rect.y+1, bar, rect)
  end
#-------------------------------------------------------------------------------
  def transition
    # Returns the color for current rate.
    c1 = [@colors[0].red, @colors[0].green, @colors[0].blue, @colors[0].alpha]
    c2 = [@colors[1].red, @colors[1].green, @colors[1].blue, @colors[1].alpha]
    rgba, rate = [],  1 - (@rate.to_f / @max)
    c1.each_index {|i| rgba[i] = c2[i] - ((c2[i] - c1[i]) * rate) }
    # Set the bars fill rate and color depending on value.
    rect = Rect.new(@bar_rect.x+1, @bar_rect.y+1, fill_width, @bar_rect.height-2)
    self.fill_rect(rect, Color.new(*rgba))
  end
#-------------------------------------------------------------------------------
  def fill_width
    # Calculate the difference, in percentage, of the min and max rates.
    return ((@rate / @max.to_f) * (@bar_rect.width - 2)).round
  end
#-------------------------------------------------------------------------------
end

#===============================================================================
# ** Scene_Map
#===============================================================================

class Scene_Map
 
  alias zer0_hunger_hud_main main
  def main
    # Add the bars to Scene_Map.
    @hunger_hud = Hunger_HUD.new
    zer0_hunger_hud_main
    @hunger_hud.dispose unless @hunger_hud.disposed? || @hunger_hud == nil
  end
 
  alias zer0_hunger_hud_upd update
  def update
    # Update the bars as needed.
    @hunger_hud.update
    zer0_hunger_hud_upd
  end
end

#===============================================================================
# ** RPG::Cache
#===============================================================================

module RPG::Cache
 
  def self.gradient_bar(style, width, height, color1, color2)
    # Create a unique key to call the bar back with.
    path = [style, width, height, color1, color2]
    # Check if cache already has bitmap defined, if not create it now.
    if !@cache.include?(path) || @cache[path].disposed?
      bitmap, rates = Bitmap.new(width, height), []
      # Iterate through each pixel horizontally, setting a gradient color.
      c1 = [color1.red, color1.green, color1.blue, color1.alpha]
      c2 = [color2.red, color2.green, color2.blue, color2.alpha]
      # Draw the bar, having in transition from the first color to the second.
      c1.each_index {|i| rates[i] = (c1[i] - c2[i]).to_f / width }
      (0...width).each {|i|
        values = [0, 1, 2, 3].collect {|j| c1[j] - (i * rates[j]) }
        # Set the color incrementally. This will be used later.
        bitmap.fill_rect(i, 0, 1, height, Color.new(*values))
      }
      @cache[path] = bitmap
    end
    # Return the created bitmap.
    return @cache[path]
  end
end




Instructions

Place below default scripts, and above Main.
If Zer0 Add-On Collection is present, place below it.


Compatibility

There is an issue with the Chemist Class Script within Zer0 Add-Ons, but placing this script below it will solve the problem.


Credits and Thanks


  • ForeverZer0, for writing the script.
  • Jragyn, for fixing some issues with the HUD
  • kukusu, for requesting the script.
  • SBR*, for pointing out an error I made.
  • swick, for requesting the HUD.



Author's Notes

Please report any bug/issues you may find, and I'll be happy to fix them.
Enjoy!
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Jragyn

I feel like I've seen a lot of requests for a script of this nature, so I'm glad to be able to point people in this direction.

Good job, yo.
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

kukusu

Thank you again for making it. It turned out much better than I expected. It's perfect!

And, You put me in the credits!! Thank you!  :D

Magus

Hmm... want to try this out so bad :D
Will this thing show like a visual way (for example a bar) that will show us his hunger level eventually.
I'm about to try this thing out.
LEVEL ME DOWN. THE ANTI-BLIZZ GROUP IS AMONG YOU... Do it for the chick below...She watches..<br />

ForeverZer0

Quote from: Nawm on May 19, 2010, 10:09:56 pm
Hmm... want to try this out so bad :D
Will this thing show like a visual way (for example a bar) that will show us his hunger level eventually.
I'm about to try this thing out.


Go here: http://forum.chaos-project.com/index.php/topic,6047.0.html

This was the original post that made me write the script. There is a spoiler in there that uses the bars from Tons to display the hunger/thirst on the menu. You may have to change the x and y of where it displays on the screen.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Holyrapid

Sorry for necroing, but i just want to say, that i've been looking for something like this.
Would it be possible to add hunger and thirst indicators to BABS hud? That would be very useful.

ForeverZer0

I added a custom HUD to display the hunger/thirst for party on the map, as per request.

And yes I necro-posted in my own thread. I will do it again, too. I'm just that much of a bad-ass.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

acknowledge101

hi, total noob here to rgss scripting, been working with rm2k3 for years however.  i'm a noob to this board too obviously.

i'm using this hunger/thirst script for my new rmxp project and am very happy with it.  don't worry, giving credit where credit is due of course.

anyway, i'm wondering what the script call would be to disable the hud for cutscenes/etc purely for aesthetic reasons.  i'm thinking it's some kind of true/false call much like toggling the actual system itself, but since i'm a noob and all i don't even know where to begin.

thanks for any and all answers, and thanks for making the script, foreverzero.

ForeverZer0

Actually, you made me realize that not being able to disable the HUD is an oversight of mine.
Here is a fix for it, just place this code below the script anywhere:


class Scene_Map
  attr_accessor :hunger_hud
end


You can now change the opacity of the HUD (Scene_Map only) with this script call:
$scene.hunger_hud.opacity = 0

To turn it back on:
$scene.hunger_hud.opacity = 255

This is a cheap temporary fix. I will update it sometime here with a built in edit. Thanks for pointing that out, though. I'm glad you like it!  ;)
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

acknowledge101

thanks, but it's not working.  i tried several different methods but i still can't get it to disappear.  even went and tried to learn the basics of ruby to maybe figure out how to do it myself, but nope.  i did figure out how to do a few other things in the process however.  at least the code's not looking like a foreign language like it was before.

anyway, don't worry about it for now though, i'll just wait till you update the script with the permanent fix.

megaman30796

do the hunger/thirst hud work with custom huds?
"You know the world is going crazy," Chris Rock declared in 2003, "when the best rapper [Eminem] is a white guy, the best golfer [Tiger Woods] is a black guy, the tallest guy in the NBA [Yao Ming] is Chinese, the Swiss hold the America's Cup, France is accusing the U.S. of arrogance, Germany doesn't want to go to war, and the three most powerful men in America are named 'Bush,' 'Dick,' and 'Colon.' Need I say more?"

wethefallen

Im having a glitch when using atoas acbs (with atb) with the hunger thirst plugin, ( http://www.hbgames.org/forums/viewtopic.php?f=11&t=62914 ), It seems to fight it out with the Atoa Game_Battler class, If the hunger script is above it, I can remove the states normally, but not add to regen the hunger counter, if below, i can add hunger but not remove states via items. Used Items not called out via that script work fine. Since ive already put a lot of work into using the battle system it is much higher priority, i was trying to figure out how to make the hunger script compliant with set_item_state_change in atoa, but im having trouble figuring it out on my own. Any suggestions?

ForeverZer0

Sounds like you have IDs for states conflicting with one another.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

kmart002

Hey I love your script, but I don't know where to put the HUD cause I already have a different HUD. Could it maybe be a stat instead of a bar? I have this script that allows switching on the party leader, could you make the hunger/thirst bar for only the party leader instead of the whole party? Either way works.