#=============================================================================== # Hunger/Thirst Factor # By Jet10985 (Jet) #=============================================================================== # This script will add a hunger and/or thirst factor to every actor. These # can effect a lot of things, such as stats in battle, disabling dashing, or # even life or death. # This script has: 32 customization option. #=============================================================================== # Overwritten Methods: # None #------------------------------------------------------------------------------- # Aliased methods: # Game_Actor: initialize # Game_Character: jump, increase_steps # Game_Player: dash? # Scene_Battle: execute_action_attack, execute_action_skill, execute_action_item, # execute_action_guard, execute_action_wait, execute_action_escape # Game_Battler: item_effect, apply_state_changes, atk, def, agi, spi # Window_Status: refresh # Scene_Base: update #=============================================================================== =begin Event commands: change_hunger(actor, amount) change_thirst(actor, amount) actor = the actor you want to change the stat of amount = how much you want to change it by These method SUBTRACT from the score, so if you want to add hunger/thirst, use a negative number like -100. To make an item effect hunger/thirst, put this in the item's notebox: ## = how much it will decrease hunger or thirst by. To check hunger/thirst, you much use slightly more scripting method such as: Equal to: $game_party.members[actor].hunger == amount Greater than or equal to: $game_party.members[actor].hunger >= amount Less than or equal to: $game_party.members[actor].hunger <= amount Greater than: $game_party.members[actor].hunger > amount Less than: $game_party.members[actor].hunger < amount NOTE: Just replace hunger with thirst to check for thirst. actor = actor id you want to check hunger/thirst of. amount = what the amount of hunger/thirst you are checking against =end module HungerThirst # Do you want to use the hunger factor? USE_HUNGER = true # Do you want to use the thirst factor? USE_THIRST = true # What is the maximum hunger? MAX_HUNGER = 2000 # What is the maximum thirst? MAX_THIRST = 1000 # Will the character who has a maxed out hunger/thirst die? DIE_ON_MAX_HUNGER_OR_THIRST = false # If the above is set to true, when the dead character is revived, # how much hunger/thirst will be taken away? REVIVED_HUNGER_LOWER = 500 REVIVED_THIRST_LOWER = 300 # How much hunger will be added for each step? STEP_HUNGER_ADDED = 2 # How much thirst will be added for each step? STEP_THIRST_ADDED = 1 # Do you want the player to add hunger/thirst when jumping? JUMP_SYSTEM_COMPATABILITY = true # How much hunger will be added for each jump? JUMP_HUNGER_ADDED = 2 # How much thirst will be added for each jump? JUMP_THIRST_ADDED = 2 # How much hunger do they need until they can no longer dash? # Note: They will not be able to dash if EITHER this or NO_DASH_THIRST is met. NO_DASH_HUNGER = 1000 # How much thirst do they need until they can no longer dash? # Note: They will not be able to dash if EITHER this or NO_DASH_HUNGER is met. NO_DASH_THIRST = 750 # Do you want hunger to effect player's stats? AFFECT_STATS = true # How much hunger do they need until stats are effected? LOWER_STATS_HUNGER = 500 # How much thirst do they need until stats are effected? LOWER_STATS_THIRST = 400 # This is what stats will be multiplied by if the character is too hungry. # ATK DEF SPI AGI HUNGER_LOWERED_STATS = [0.8, 0.8, 0.8, 0.8] # This is what stats will be multiplied by if the charatcer is too thirsty. # ATK DEF SPI AGI THIRST_LOWERED_STATS = [0.9, 0.9, 0.9, 0.9] # Do you want battle actions to effect hunger/thirst? BATTLE_ACTIONS_AFFECT = true # How much attacking will affect hunger/thirst. ATTACK_HUNGER_RAISE = 10 ATTACK_THIRST_RAISE = 7 # How much using a skill will affect hunger/thirst. SKILL_HUNGER_RAISE = 8 SKILL_THIRST_RAISE = 6 # How much guarding will affect hunger/thirst. GUARD_HUNGER_RAISE = 5 GUARD_THIRST_RAISE = 4 # How much using an item will affect hunger/thirst. ITEM_HUNGER_RAISE = 2 ITEM_THIRST_RAISE = 1 # How much trying to escape will affect hunger/thirst. ESCAPE_HUNGER_RAISE = 5 ESCAPE_THIRST_RAISE = 6 # How much waiting will affect hunger/thirst. WAIT_HUNGER_RAISE = 2 WAIT_THIRST_RAISE = 2 # Do you want each actor's hunger to be output to a variable? HUNGER_TO_VARIABLE = false # If the above is true, configure the hash below following the format listed. ACTOR_HUNGER_VARIABLES = { 1 => 90, # ACTOR_ID => VARIABLE_ID 2 => 91, # ACTOR_ID => VARIABLE_ID 3 => 92, # ACTOR_ID => VARIABLE_ID 4 => 93 # ACTOR_ID => VARIABLE_ID } # Do you want each actor's thirst to be output to a variable? THIRST_TO_VARIABLE = false # If the above is true, configure the hash below following the format listed. ACTOR_THIRST_VARIABLES = { 1 => 94, # ACTOR_ID => VARIABLE_ID 2 => 95, # ACTOR_ID => VARIABLE_ID 3 => 96, # ACTOR_ID => VARIABLE_ID 4 => 97 # ACTOR_ID => VARIABLE_ID } end #=============================================================================== # DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO. #=============================================================================== class Game_Actor attr_accessor :hunger attr_accessor :thirst alias jet5482_initialize initialize unless $@ def initialize(*args) jet5482_initialize(*args) @hunger = 0 @thirst = 0 end end class Game_Interpreter include HungerThirst def change_hunger(actor, amount) $game_party.members[actor].hunger -= amount if $game_party.members[actor].hunger > MAX_HUNGER $game_party.members[actor].hunger = MAX_HUNGER elsif $game_party.members[actor].hunger < 0 $game_party.members[actor].hunger = 0 end end def change_thirst(actor, amount) $game_party.members[actor].thirst -= amount if $game_party.members[actor].thirst > MAX_THIRST $game_party.members[actor].thirst = MAX_THIRST elsif $game_party.members[actor].thirst < 0 $game_party.members[actor].thirst = 0 end end end module Jet def self.check_tag_number(obj, tag) obj.note.split(/[\r\n]+/).each { |notetag| case notetag when tag @result = $1.to_i end } return @result end end module RPG class UsableItem def lower_hunger if @hunger.nil? txt = Jet.check_tag_number(self, /<(?:hunger)[ ]*(\d+)>/i) @hunger = txt.nil? ? :unhunger : txt.to_i end return @hunger end def lower_thirst if @thirst.nil? txt = Jet.check_tag_number(self, /<(?:thirst)[ ]*(\d+)>/i) @thirst = txt.nil? ? :unthirst : txt.to_i end return @thirst end end end class Game_Character include HungerThirst if JUMP_SYSTEM_COMPATABILITY alias jet5903_jump jump unless $@ def jump(*args) for i in 0...$game_party.members.size $game_party.members[i].hunger += JUMP_HUNGER_ADDED if USE_HUNGER $game_party.members[i].thirst += JUMP_THIRST_ADDED if USE_THIRST if $game_party.members[i].hunger > MAX_HUNGER $game_party.members[i].hunger = MAX_HUNGER elsif $game_party.members[i].hunger < 0 $game_party.members[i].hunger = 0 end if $game_party.members[i].thirst > MAX_THIRST $game_party.members[i].thirst = MAX_THIRST elsif $game_party.members[i].thirst < 0 $game_party.members[i].thirst = 0 end end jet5903_jump(*args) end end alias jet2211_increase_steps increase_steps unless $@ def increase_steps(*args) if self.is_a?(Game_Player) for i in 0...$game_party.members.size $game_party.members[i].hunger += STEP_HUNGER_ADDED if USE_HUNGER $game_party.members[i].thirst += STEP_THIRST_ADDED if USE_THIRST if $game_party.members[i].hunger > MAX_HUNGER $game_party.members[i].hunger = MAX_HUNGER elsif $game_party.members[i].hunger < 0 $game_party.members[i].hunger = 0 end if $game_party.members[i].thirst > MAX_THIRST $game_party.members[i].thirst = MAX_THIRST elsif $game_party.members[i].thirst < 0 $game_party.members[i].thirst = 0 end end end jet2211_increase_steps(*args) end end class Game_Player include HungerThirst alias jet6901_dash? dash? unless $@ def dash? for i in 0...$game_party.members.size if USE_HUNGER if $game_party.members[i].hunger >= NO_DASH_HUNGER return false end end if USE_THIRST if $game_party.members[i].thirst >= NO_DASH_THIRST return false end end end jet6901_dash? end end class Scene_Battle include HungerThirst if BATTLE_ACTIONS_AFFECT alias jet0134_execute_action_attack execute_action_attack unless $@ def execute_action_attack if @active_battler.actor? @active_battler.hunger += ATTACK_HUNGER_RAISE if USE_HUNGER @active_battler.thirst += ATTACK_THIRST_RAISE if USE_THIRST if @active_battler.hunger > MAX_HUNGER @active_battler.hunger = MAX_HUNGER elsif @active_battler.hunger < 0 @active_battler.hunger = 0 end if @active_battler.thirst > MAX_THIRST @active_battler.thirst = MAX_THIRST elsif @active_battler.thirst < 0 @active_battler.thirst = 0 end end jet0134_execute_action_attack end alias jet0135_execute_action_guard execute_action_guard unless $@ def execute_action_guard if @active_battler.actor? @active_battler.hunger += GUARD_HUNGER_RAISE if USE_HUNGER @active_battler.thirst += GUARD_THIRST_RAISE if USE_THIRST if @active_battler.hunger > MAX_HUNGER @active_battler.hunger = MAX_HUNGER elsif @active_battler.hunger < 0 @active_battler.hunger = 0 end if @active_battler.thirst > MAX_THIRST @active_battler.thirst = MAX_THIRST elsif @active_battler.thirst < 0 @active_battler.thirst = 0 end end jet0135_execute_action_guard end alias jet0136_execute_action_escape execute_action_escape unless $@ def execute_action_escape if @active_battler.actor? @active_battler.hunger += ESCAPE_HUNGER_RAISE if USE_HUNGER @active_battler.thirst += ESCAPE_THIRST_RAISE if USE_THIRST if @active_battler.hunger > MAX_HUNGER @active_battler.hunger = MAX_HUNGER elsif @active_battler.hunger < 0 @active_battler.hunger = 0 end if @active_battler.thirst > MAX_THIRST @active_battler.thirst = MAX_THIRST elsif @active_battler.thirst < 0 @active_battler.thirst = 0 end end jet0136_execute_action_escape end alias jet0137_execute_action_wait execute_action_wait unless $@ def execute_action_wait if @active_battler.actor? @active_battler.hunger += WAIT_HUNGER_RAISE if USE_HUNGER @active_battler.thirst += WAIT_THIRST_RAISE if USE_THIRST if @active_battler.hunger > MAX_HUNGER @active_battler.hunger = MAX_HUNGER elsif @active_battler.hunger < 0 @active_battler.hunger = 0 end if @active_battler.thirst > MAX_THIRST @active_battler.thirst = MAX_THIRST elsif @active_battler.thirst < 0 @active_battler.thirst = 0 end end jet0137_execute_action_wait end alias jet0138_execute_action_skill execute_action_skill unless $@ def execute_action_skill if @active_battler.actor? @active_battler.hunger += SKILL_HUNGER_RAISE if USE_HUNGER @active_battler.thirst += SKILL_THIRST_RAISE if USE_THIRST if @active_battler.hunger > MAX_HUNGER @active_battler.hunger = MAX_HUNGER elsif @active_battler.hunger < 0 @active_battler.hunger = 0 end if @active_battler.thirst > MAX_THIRST @active_battler.thirst = MAX_THIRST elsif @active_battler.thirst < 0 @active_battler.thirst = 0 end end jet0138_execute_action_skill end alias jet0139_execute_action_item execute_action_item unless $@ def execute_action_item if @active_battler.actor? @active_battler.hunger += ITEM_HUNGER_RAISE if USE_HUNGER @active_battler.thirst += ITEM_THIRST_RAISE if USE_THIRST if @active_battler.hunger > MAX_HUNGER @active_battler.hunger = MAX_HUNGER elsif @active_battler.hunger < 0 @active_battler.hunger = 0 end if @active_battler.thirst > MAX_THIRST @active_battler.thirst = MAX_THIRST elsif @active_battler.thirst < 0 @active_battler.thirst = 0 end end jet0139_execute_action_item end end end class Game_Battler include HungerThirst alias jet5823_item_effect item_effect unless $@ def item_effect(user, item) jet5823_item_effect(user, item) unless @skipped user.hunger -= item.lower_hunger unless item.lower_hunger == :unhunger user.thirst -= item.lower_thirst unless item.lower_thirst == :unthirst if user.hunger > MAX_HUNGER user.hunger = MAX_HUNGER elsif user.hunger < 0 user.hunger = 0 end if user.thirst > MAX_THIRST user.thirst = MAX_THIRST elsif user.thirst < 0 user.thirst = 0 end end end alias jet9243_apply_state_changes apply_state_changes unless $@ def apply_state_changes(obj) if obj.minus_state_set.include?(1) && DIE_ON_MAX_HUNGER_OR_THIRST && self.actor? self.hunger -= REVIVED_HUNGER_LOWER self.thirst -= REVIVED_THIRST_LOWER if self.hunger > MAX_HUNGER self.hunger = MAX_HUNGER elsif self.hunger < 0 self.hunger = 0 end if self.thirst > MAX_THIRST self.thirst = MAX_THIRST elsif self.thirst < 0 self.thirst = 0 end end self.jet9243_apply_state_changes(obj) end if AFFECT_STATS alias jet0132_atk atk unless $@ def atk n = jet0132_atk if self.actor? if self.hunger >= LOWER_STATS_HUNGER n *= HUNGER_LOWERED_STATS[0] end if self.thirst >= LOWER_STATS_THIRST n *= THIRST_LOWERED_STATS[0] end end return n end alias jet8921_def def unless $@ def def n = jet8921_def if self.actor? if self.hunger >= LOWER_STATS_HUNGER n *= HUNGER_LOWERED_STATS[1] end if self.thirst >= LOWER_STATS_THIRST n *= THIRST_LOWERED_STATS[1] end end return n end alias jet9021_spi spi unless $@ def spi n = jet9021_spi if self.actor? if self.hunger >= LOWER_STATS_HUNGER n *= HUNGER_LOWERED_STATS[2] end if self.thirst >= LOWER_STATS_THIRST n *= THIRST_LOWERED_STATS[2] end end return n end alias jet0213_agi agi unless $@ def agi n = jet0213_agi if self.actor? if self.hunger >= LOWER_STATS_HUNGER n *= HUNGER_LOWERED_STATS[3] end if self.thirst >= LOWER_STATS_THIRST n *= THIRST_LOWERED_STATS[3] end end return n end end end class Window_Status alias jet5840_refresh refresh unless $@ def refresh jet5840_refresh self.contents.font.color = system_color self.contents.draw_text(50, 310, 100, 24, "Hunger: ") self.contents.font.color = normal_color self.contents.draw_text(150, 310, 100, 24, @actor.hunger) self.contents.font.color = system_color self.contents.draw_text(50, 334, 100, 24, "Thirst: ") self.contents.font.color = normal_color self.contents.draw_text(150, 334, 100, 24, @actor.thirst) end end class Scene_Base include HungerThirst alias jet2034_update update unless $@ def update jet2034_update unless $scene.is_a?(Scene_Title) for actor in $game_party.members next if actor.nil? $game_variables[ACTOR_HUNGER_VARIABLES[actor.id]] = actor.hunger unless actor.nil? || ACTOR_HUNGER_VARIABLES[actor.id].nil? || !USE_HUNGER $game_variables[ACTOR_THIRST_VARIABLES[actor.id]] = actor.thirst unless actor.nil? || ACTOR_THIRST_VARIABLES[actor.id].nil? || !USE_THIRST if actor.hunger == MAX_HUNGER && DIE_ON_MAX_HUNGER_OR_THIRST && actor.hp != nil actor.hp = 0 if $game_party.all_dead? @window = Window_Help.new @window.y = 152 @window.set_text("Your last party member has died of hunger.", 1) loop do Graphics.update Input.update if Input.trigger?(Input::C) @window.dispose $scene = Scene_Gameover.new break end end end elsif actor.thirst == MAX_THIRST && DIE_ON_MAX_HUNGER_OR_THIRST && actor.hp != nil actor.hp = 0 if $game_party.all_dead? @window = Window_Help.new @window.y = 152 @window.set_text("Your last party member has died of Thirst.", 1) loop do Graphics.update Input.update if Input.trigger?(Input::C) @window.dispose $scene = Scene_Gameover.new break end end end end end end end end