I just stumbled across a script a friend of mines did for me and I noticed it needed tweaking. I'm not sure how to do it myself but what this script does is inflicts a sleep status when a character has walked to much or if customized can take away HP. Sleep status can be affected in battle as well. The problem I have with this script is it counts from 100 down to 0. What I want it to do is after x steps 1 percent is added to fatigue. When the person reaches 100 percent they will have the sleep status.
Hope you can help!
Code:
#===================================
# Leon's Fatigue Script
# Fatigue has different effects on each actor.
#----------------------------------------------------------------------
# v1.0
# 12/16/2006
#----------------------------------------------------------------------
# Instructions:
# 1. Put above main, but below the rest of your scripts.
# 2. Set the stuff in the module as it is needed.
# 3. To restore fatigue via event, use call script, then type:
# for i in 0...$game_party.actors.size
# $game_party.actors[i].fatigue = 100
# end
#===================================
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# Module Fatigue
#//////////////////////////////////////////////////////////////////////
module Fatigue
#----------------------------------------------------------------------
# SLEEP_ID = I.D number of sleep status.
#----------------------------------------------------------------------
SLEEP_ID = 7
#----------------------------------------------------------------------
# FATIGUE_SLEEP
# when true, 0 fatigue puts actor to sleep. when false, it takes away HP.
#----------------------------------------------------------------------
FATIGUE_SLEEP = true
#----------------------------------------------------------------------
# ADD_IN_BATTLE = How much fatigue is restored per turn of sleep in battle.
#----------------------------------------------------------------------
ADD_IN_BATTLE = 4
#----------------------------------------------------------------------
# ADD_PER_ITEM = How much fatigue is restored when an item in Items_Food is used.
#----------------------------------------------------------------------
ADD_PER_ITEM = 25
#----------------------------------------------------------------------
# Items_Food = [item_id that restores fatigue,...]
#----------------------------------------------------------------------
Items_Food = [34]
#----------------------------------------------------------------------
# STEPS = Number of steps before 1 is taken from fatigue.
#----------------------------------------------------------------------
STEPS = 5
#----------------------------------------------------------------------
# STATUS_WINDOW = shows health if using default status window.
#----------------------------------------------------------------------
STATUS_WINDOW = true
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Game_Actor < Game_Battler
attr_accessor :fatigue
alias leon_fatigue_ga_setup setup
def setup(actor_id)
@fatigue = 100
leon_fatigue_ga_setup(actor_id)
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Game_Party
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Game_Party
alias leon_fatigue_ga_increase_steps increase_steps
def increase_steps
leon_fatigue_ga_increase_steps
if @steps % Fatigue::STEPS == 0
#print "True"
for i in 0...@actors.size
if @actors[i].fatigue > 0
@actors[i].fatigue -= 1
else
if Fatigue::FATIGUE_SLEEP == true
unless @actors[i].states.include?(Fatigue::SLEEP_ID)
@actors[i].states.push(Fatigue::SLEEP_ID)
end
else
@actors[i].hp -= 1
end
end
end
end
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Window_Status
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Window_Status < Window_Base
alias leon_fatigue_windowstatus_refresh refresh
def refresh
leon_fatigue_windowstatus_refresh
if Fatigue::STATUS_WINDOW == true
self.contents.font.color = system_color
self.contents.draw_text(320, 112, 80, 32, "Health")
self.contents.font.color = normal_color
self.contents.draw_text(400, 112, 84, 32, @actor.fatigue.to_s + "/100", 2)
end
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Scene_Item
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Scene_Item
def update_target
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
unless $game_party.item_can_use?(@item.id)
@item_window.refresh
end
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
if Input.trigger?(Input::C)
if $game_party.item_number(@item.id) == 0
$game_system.se_play($data_system.buzzer_se)
return
end
if @target_window.index == -1
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
if @target_window.index >= 0
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
if used
$game_system.se_play(@item.menu_se)
#########################################################
if Fatigue::Items_Food.include?(@item.id)
$game_party.actors[@target_window.index].fatigue += Fatigue::ADD_PER_ITEM
if $game_party.actors[@target_window.index].fatigue >= 100
$game_party.actors[@target_window.index].fatigue = 100
end
end
#########################################################
if @item.consumable
$game_party.lose_item(@item.id, 1)
@item_window.draw_item(@item_window.index)
end
@target_window.refresh
if $game_party.all_dead?
$scene = Scene_Gameover.new
return
end
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$scene = Scene_Map.new
return
end
end
unless used
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Scene_Battle
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Scene_Battle
alias leon_fatigue_sb_ups2 update_phase4_step2
def update_phase4_step2
unless @active_battler.current_action.forcing
if @active_battler.restriction == 2 or @active_battler.restriction == 3
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
end
if @active_battler.restriction == 4
if @active_battler.is_a?(Game_Actor)
if @active_battler.states.include?(Fatigue::SLEEP_ID)
@active_battler.fatigue += Fatigue::ADD_IN_BATTLE
if @active_battler.fatigue >= 100
@active_battler.fatigue = 100
end
end
end
$game_temp.forcing_battler = nil
@phase4_step = 1
return
end
end
@target_battlers = []
case @active_battler.current_action.kind
when 0
make_basic_action_result
when 1
make_skill_action_result
when 2
make_item_action_result
end
if @phase4_step == 2
@phase4_step = 3
end
end
end
Hope you can help!