#==================================================
# ** Stamina
# By onidsouza
# Version 1.2
# 02/26/09
#-------------------------------------------------
module OniStamina
Initial = 100 # Initial stamina value
EvolutionRate = 1.3 #Float value representing the level up evolution rate.
# Leave 1.0 for none
InitialRecoverFrames = 15 # Recover Frames Rate
RecoverEvolutionRate = 3 #Float value representing the level up recover time
# evolution rate. Leave 1.0 for none.
ActorMember = 0# Number from 0 to 3, representing the actor in the party.
end
class Game_Actor
alias onistamina_init initialize
alias onistamina_lvlup level_up
attr_reader :stamina
attr_accessor :maxsta
attr_reader :recover
def initialize(actor_id)
onistamina_init(actor_id)
@stamina = OniStamina::Initial
@maxsta = @stamina
@recover = OniStamina::InitialRecoverFrames
end
def level_up
@maxsta = @maxsta * OniStamina::EvolutionRate
@recover = @recover / OniStamina::RecoverEvolutionRate
@maxsta = @maxsta.to_i
@recover = @recover.to_i
onistamina_lvlup
end
def stamina_text
(@stamina).to_s + '/' + (@maxsta).to_s
end
def lose_sta(x)
if ((@stamina - x) >= 0)
@stamina = @stamina - x
else
@stamina = 0
end
end
def gain_sta(x)
if ((@stamina + x) <= @maxsta)
@stamina = @stamina + x
end
end
end
class Window_Stamina < Window_Base
def initialize(x, y, wid, hei)
super(x, y, wid, hei)
@stamina = $game_party.members[OniStamina::ActorMember].stamina
@maxsta = $game_party.members[OniStamina::ActorMember].stamina
self.opacity = 0
end
def refresh
self.contents.clear
draw_stamina(0, 0)
end
def draw_stamina(x, y, width = 100)
wd = width * $game_party.members[OniStamina::ActorMember].stamina / $game_party.members[OniStamina::ActorMember].maxsta
self.contents.fill_rect(x, y, width, 10, Color.new(0, 0, 0))
self.contents.fill_rect(x, y, wd, 10, Color.new(255, 255, 119))
text_wid = contents.text_size($game_party.members[OniStamina::ActorMember].stamina_text).width
self.contents.draw_text(x + 0, y + 15, text_wid, 20, $game_party.members[OniStamina::ActorMember].stamina_text)
end
end
class Scene_Map
alias onista_start start
alias onista_terminate terminate
alias onista_update update
attr_reader :winsta
def start
onista_start
@waiting_sta = 0
@winsta = Window_Stamina.new(-10, 1, 150, 80)
end
def terminate
onista_terminate
@winsta.dispose
end
def update
onista_update
if $game_player.moving? and $game_player.dash?
$game_party.members[OniStamina::ActorMember].lose_sta(1)
end
if $game_system.waiting_sta == $game_party.members[OniStamina::ActorMember].recover
$game_party.members[OniStamina::ActorMember].gain_sta(1)
end
@winsta.refresh
end
end
class Game_Player < Game_Character
alias sta_dash? dash?
def dash?
return false if $game_party.members[OniStamina::ActorMember].stamina == 0
sta_dash?
end
end
class Game_System
attr_reader :waiting_sta
alias onista_update update
alias onista_initialize initialize
def initialize
@waiting_sta = 0
onista_initialize
end
def update
@waiting_sta = @waiting_sta + 1
@waiting_sta = 0 if @waiting_sta > $game_party.members[OniStamina::ActorMember].recover
onista_update
end
end