#==============================================================================
# ** Hunger_Settings
#------------------------------------------------------------------------------
# This module holds hunger constants that are used over several classes.
#==============================================================================
module Hunger_Settings
#--------------------------------------------------------------------------
# HUNGER_ITEMS : this hash holds the item ids of the items that adjust your
# hunger value for better or for worse.
#--------------------------------------------------------------------------
HUNGER_ITEMS = {
# item_id => hunger_change Ex: 0 => 0.3 *No number larger than 1.0*
33 => 0.3,
}
#--------------------------------------------------------------------------
# HUNGER_FIXED_ITEMS : this hash holds the item ids of items that keep
# your hunger value from lowering for a certain amount of time.
#--------------------------------------------------------------------------
HUNGER_FIXED_ITEMS = {
# item_id => amount_of_time_hunger_isn't_affected
}
#--------------------------------------------------------------------------
# HUNGER_RATE : the rate at which your hunger increases so to speak
#--------------------------------------------------------------------------
HUNGER_RATE = 0.00002
end
#==============================================================================
# ** Thirst_Settings
#------------------------------------------------------------------------------
# This module holds thirst constants that are used over several classes.
#==============================================================================
module Thirst_Settings
#--------------------------------------------------------------------------
# THIRST_ITEMS : this hash holds the item ids of the items that adjust your
# thirst value for better or for worse.
#--------------------------------------------------------------------------
THIRST_ITEMS = {
# item_id => thirst_change Ex: 0 => 0.3 *No number larger than 1.0*
36 => 0.5,
}
#--------------------------------------------------------------------------
# THIRST_FIXED_ITEMS : this hash holds the item ids of items that keep
# your thirst value from lowering for a certain amount of time.
#--------------------------------------------------------------------------
THIRST_FIXED_ITEMS = {
# item_id => amount_of_time_thirst_isn't_affected
}
#--------------------------------------------------------------------------
# THIRST_RATE : the rate at which your thirst increases so to speak
#--------------------------------------------------------------------------
THIRST_RATE = 0.00005
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias_method :them_hunger_game_actor_initialize, :initialize
alias_method :them_hunger_game_actor_item_effect, :item_effect
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :hunger
attr_reader :hunger_fixed_cheat
attr_reader :hunger_fixed_timer
attr_reader :thirst
attr_reader :thirst_fixed_cheat
attr_reader :thirst_fixed_timer
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor_id)
them_hunger_game_actor_initialize(actor_id)
# The current amount of hunger 1.0 means full 0.0 means starving.
@hunger = 1.0
# Is the current hunger amount fixed so it cannot move?
@hunger_fixed_cheat = false
# The amount of time before the hunger value begins to decrease again.
@hunger_fixed_timer = 0
# The current amount of hunger 1.0 means full 0.0 means starving.
@thirst = 1.0
# Is the current hunger amount fixed so it cannot move?
@thirst_fixed_cheat = false
# The amount of time before the hunger value begins to decrease again.
@thirst_fixed_timer = 0
end
#--------------------------------------------------------------------------
# * Application of Item Effects
# item : item
#--------------------------------------------------------------------------
def item_effect(item)
# If the item is listed in the hash as affecting hunger. Change the
# hunger value for better or for worse.
if Hunger_Settings::HUNGER_ITEMS.key?(item.id)
@hunger += Hunger_Settings::HUNGER_ITEMS[item.id]
@hunger = [@hunger, 1.0].min
return true
# If the item is in the item list that fixates hunger for a time.
elsif Hunger_Settings::HUNGER_FIXED_ITEMS.key?(item.id)
@hunger_fixed_timer = Hunger_Settings::HUNGER_FIXED_ITEMS[item.id]
return true
end
# If the item is listed in the hash as affecting thirst. Change the
# thirst value for better or for worse.
if Thirst_Settings::THIRST_ITEMS.key?(item.id)
@thirst += Thirst_Settings::THIRST_ITEMS[item.id]
@thirst = [@thirst, 1.0].min
return true
# If the item is in the item list that fixates thirst for a time.
elsif Thirst_Settings::THIRST_FIXED_ITEMS.key?(item.id)
@thirst_fixed_timer = Thirst_Settings::THIRST_FIXED_ITEMS[item.id]
return true
end
return them_hunger_game_actor_item_effect(item)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# If the cheaty boolean is turned on then ignore hunger for this
# actor.
unless @hunger_fixed_cheat
# If the hunger has been fixated for an amount of time update the timer
# and return.
if @hunger_fixed_timer > 0
@hunger_fixed_timer -= 1
else
# Update the hunger value
@hunger -= Hunger_Settings::HUNGER_RATE if @hunger > 0.0
end
end
# If the cheaty boolean is turned on then ignore thirst for this
# actor.
unless @thirst_fixed_cheat
# If the thirst has been fixated for an amount of time update the timer
# and return.
if @thirst_fixed_timer > 0
@thirst_fixed_timer -= 1
else
# Update the thirst value
@thirst -= Thirst_Settings::THIRST_RATE if @thirst > 0.0
end
end
end
#--------------------------------------------------------------------------
# * &Cheat& Hunger no longer drops
#--------------------------------------------------------------------------
def cheat_hunger_on
@hunger_fixed_cheat = true
end
#--------------------------------------------------------------------------
# * &Cheat& Hunger can drop again
#--------------------------------------------------------------------------
def cheat_hunger_off
@hunger_fixed_cheat = false
end
#--------------------------------------------------------------------------
# * &Cheat& Thirst no longer drops
#--------------------------------------------------------------------------
def cheat_thirst_on
@thirst_fixed_cheat = true
end
#--------------------------------------------------------------------------
# * &Cheat& Thirst can drop again
#--------------------------------------------------------------------------
def cheat_thirst_off
@thirst_fixed_cheat = false
end
end
#==============================================================================
# ** State_HUD
#------------------------------------------------------------------------------
# This hud displays the current state of the party leader.
#==============================================================================
class State_HUD < Sprite
#--------------------------------------------------------------------------
# * Constant Variables
#--------------------------------------------------------------------------
STATE_HUD_DIR = 'Graphics/Pictures/State_HUD/'
STATE_HUD_TEX = 'state_hud.png'
STATE_HUD_HUNGER_TEX = 'hunger.png'
STATE_HUD_FATIGUE_TEX = 'fatigue.png'
STATE_HUD_THIRST_TEX = 'thirst.png'
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super()
# Load the images in the initialize
self.bitmap = Bitmap.new(STATE_HUD_DIR + STATE_HUD_TEX)
@orig = Bitmap.new(STATE_HUD_DIR + STATE_HUD_TEX)
@hunger_bp = Bitmap.new(STATE_HUD_DIR + STATE_HUD_HUNGER_TEX)
@fatigue_bp = Bitmap.new(STATE_HUD_DIR + STATE_HUD_FATIGUE_TEX)
@thirst_bp = Bitmap.new(STATE_HUD_DIR + STATE_HUD_THIRST_TEX)
# Instance variables that will be needed to check if we should refresh.
@actor_hunger = @actor_fatigue = @actor_thirst = @actor = nil
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
x, y = 95, 0
# If there was a change in hunger. Redraw hunger.
if @actor_hunger != @actor.hunger
# Save the instance variable for later checking.
@actor_hunger = @actor.hunger
# Re-adjust y
y = 7
# Clear out this portion so we can redraw to it.
clear_rect = Rect.new(x, y, @hunger_bp.width, @hunger_bp.height)
self.bitmap.blt(x, y, @orig, clear_rect)
# Decide how much of the bitmap we will be using to draw.
draw_rect = Rect.new(0, 0, @hunger_bp.width * (@actor.hunger / 1.0),
@hunger_bp.height)
# Draw the hunger bar
self.bitmap.blt(x, y, @hunger_bp, draw_rect)
end
# If there was a change in hunger. Redraw fatigue.
if @actor_fatigue != @actor.sp
# Save the instance variable for later checking.
@actor_fatigue = @actor.sp
# Re-adjust y
y = 26
# Clear out this portion so we can redraw to it.
clear_rect = Rect.new(x, y, @fatigue_bp.width, @fatigue_bp.height)
self.bitmap.blt(x, y, @orig, clear_rect)
# Decide how much of the bitmap we will be using to draw.
draw_rect = Rect.new(0, 0,
@fatigue_bp.width * (@actor.sp / @actor.maxsp), @fatigue_bp.height)
# Draw the fatigue bar
self.bitmap.blt(x, y, @fatigue_bp, draw_rect)
end
# If there was a change in thirst. Redraw thirst.
if @actor_thirst != @actor.thirst
# Save the instance variable for later checking.
@actor_thirst = @actor.thirst
# Re-adjust y
y = 45
# Clear out this portion so we can redraw to it.
clear_rect = Rect.new(x, y, @thirst_bp.width, @thirst_bp.height)
self.bitmap.blt(x, y, @orig, clear_rect)
# Decide how much of the bitmap we will be using to draw.
draw_rect = Rect.new(0, 0, @thirst_bp.width * (@actor.thirst / 1.0),
@thirst_bp.height)
# Draw the thirst bar.
self.bitmap.blt(x, y, @thirst_bp, draw_rect)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@actor = $game_party.actors.first
refresh
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super()
self.bitmap.dispose unless self.bitmap.disposed?
@orig.dispose unless @orig.disposed?
@hunger_bp.dispose unless @hunger_bp.disposed?
@fatigue_bp.dispose unless @fatigue_bp.disposed?
@thirst_bp.dispose unless @thirst_bp.disposed?
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias_method :them_hunger_scene_map_main, :main
alias_method :them_hunger_scene_map_update, :update
#--------------------------------------------------------------------------
# * Constant Variables
#--------------------------------------------------------------------------
HUD_VISIBLE_ID = 04
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Create our Hunger HUD
@state_hud = State_HUD.new
@state_hud.x = 640 - @state_hud.bitmap.width - 10
@state_hud.y = 480 - @state_hud.bitmap.height - 10
@state_hud.z = 999
@state_hud.opacity = 200
@state_hud.visible = $game_switches[HUD_VISIBLE_ID]
them_hunger_scene_map_main
# Dispose our Hunger HUD
@state_hud.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@state_hud.visible = $game_switches[HUD_VISIBLE_ID]
if @state_hud.visible
# Update the party leader's hunger.
$game_party.actors.first.update
# Call the update for the hunger HUD.
@state_hud.update
if $game_party.actors.first.thirst <= 0.0 ||
$game_party.actors.first.hunger <= 0.0
$scene = Scene_Gameover.new
end
end
# Call the old code.
them_hunger_scene_map_update
end
end