03-07-2008, 04:38 AM
Recover HP/SP on the Map
Version: 1.1
Version: 1.1
Introduction
A script to recover the HP/SP of the party on the screen every few seconds.
Screenshots
Script
Content Hidden
Code:
#==============================================================================
# ** Recover HP/SP on Map
#==============================================================================
# Raziel
# Version 1.1
# 2006-11-18
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Recover HP/SP on Map', 'Raziel', 1.0, '2006-11-18')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Recover HP/SP on Map')
#===============================================================================
# * Module HPSP
#===============================================================================
module HPSP
# if Percent is true the player receives a percentual ammount of his HP back.
Percent = true
# SE that plays whenever the hp or sp will be added on the map
SE = "105-Heal01"
# How many Seconds will pass untill the hp/sp will be added to the actors hp/sp
Seconds = 3
# How many HP will be added
HP = 1
# How many SP will be added
SP = 1
# awitch id to turn script on/off
Switch_ID = 1
end
#===============================================================================
# * Window_HPSP
#===============================================================================
class Window_HPSP < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.visible = false
refresh
end
#---------------------------------------------------------------------------
# * Refresh
#---------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 16
self.contents.font.bold = true
if $game_switches[HPSP::Switch_ID]
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
hp = actor.hp >= actor.maxhp ? "" : $data_system.words.hp
sp = actor.sp >= actor.maxsp ? "" : $data_system.words.sp
php = HPSP::Percent == true ? $game_party.actors[0].maxhp / 100.0 * HPSP::HP.to_f : HPSP::HP
psp = HPSP::Percent == true ? $game_party.actors[0].maxsp / 100.0 * HPSP::SP.to_f : HPSP::SP
addhp = actor.hp >= actor.maxhp ? "" : "+#{php.to_i}"
addsp = actor.sp >= actor.maxsp ? "" : "+#{psp.to_i}"
self.contents.font.color = Color.new(0, 0, 0)
for i in 1..4
x = i == 1 ? 49 : i == 2 ? 51 : i == 3 ? 49 : i == 4 ? 51 : 0
y = i == 1 ? 49 : i == 2 ? 49 : i == 3 ? 51 : i == 4 ? 51 : 0
unless HPSP::HP == 0
self.contents.draw_text(($game_player.screen_x - x) + 10, $game_player.screen_y - y, 150, 32, "#{addhp} #{hp}")
end
unless HPSP::SP == 0
self.contents.draw_text(($game_player.screen_x - x) + 10, ($game_player.screen_y - y) + 16, 150, 32, "#{addsp} #{sp}")
end
end
self.contents.font.color = Color.new(100, 255, 100)
unless HPSP::HP == 0
self.contents.draw_text($game_player.screen_x - 40, $game_player.screen_y - 50, 150, 32, "#{addhp} #{hp}")
end
unless HPSP::SP == 0
self.contents.draw_text($game_player.screen_x - 40, $game_player.screen_y - 34, 150, 32, "#{addsp} #{sp}")
end
end
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#----------------------------------------------------------------------------
# * Alias Listings
#----------------------------------------------------------------------------
alias raz_map_hpsp_main_draw main_draw
alias raz_map_hpsp_update update
#--------------------------------------------------------------------------
# * Main Draw
#--------------------------------------------------------------------------
def main_draw
@count = 0
@move_count = 0
@window_move = false
@hpsp_window = Window_HPSP.new
raz_map_hpsp_main_draw
end
#----------------------------------------------------------------------------
# * Frame Update
#----------------------------------------------------------------------------
def update
if $game_switches[HPSP::Switch_ID]
unless $game_player.moving?
if Graphics.frame_count / Graphics.frame_rate != @total_sec
@count += 1
end
end
if @count >= HPSP::Seconds * 40
@hpsp_window.refresh
@count = 0
@move_count = 0
@window_move = true
@hpsp_window.visible = true
for i in 0...$game_party.actors.size
actors = $game_party.actors[i]
hp = HPSP::Percent == true ? actors.maxhp.to_f / 100 * HPSP::HP.to_f : HPSP::HP
sp = HPSP::Percent == true ? actors.maxsp.to_f / 100 * HPSP::SP.to_f : HPSP::SP
actors.hp += hp.to_i
actors.sp += sp.to_i
if (HPSP::HP != 0 and actors.hp < actors.maxhp) or (HPSP::SP != 0 and actors.sp < actors.maxsp)
Audio.se_play("Audio/SE/" + HPSP::SE)
end
end
end
if @window_move
@hpsp_window.y -= 1
if @hpsp_window.y <= -30
@window_move = false
@hpsp_window.visible = false
@hpsp_window.y = 0
end
end
end
raz_map_hpsp_update
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
Instructions
Instructions are within the script
You can almost customiza anything. If there's something you wish me to change, just post it.
The HP/SP will only recover if the character is not moving.
FAQ
Non SDK version
Content Hidden
Code:
#==============================================================================
# ** Recover HP/SP on Map
#==============================================================================
# Raziel
# Version 1.1
# 2006-11-18
#------------------------------------------------------------------------------
#===============================================================================
# * Module HPSP
#===============================================================================
module HPSP
# if Percent is true the player receives a percentual ammount of his HP back.
Percent = true
# SE that plays whenever the hp or sp will be added on the map
SE = "105-Heal01"
# How many Seconds will pass untill the hp/sp will be added to the actors hp/sp
Seconds = 3
# How many HP will be added
HP = 1
# How many SP will be added
SP = 1
# awitch id to turn script on/off
Switch_ID = 1
end
#===============================================================================
# * Window_HPSP
#===============================================================================
class Window_HPSP < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.visible = false
refresh
end
#---------------------------------------------------------------------------
# * Refresh
#---------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 16
self.contents.font.bold = true
if $game_switches[HPSP::Switch_ID]
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
hp = actor.hp >= actor.maxhp ? "" : $data_system.words.hp
sp = actor.sp >= actor.maxsp ? "" : $data_system.words.sp
php = HPSP::Percent == true ? $game_party.actors[0].maxhp / 100.0 * HPSP::HP.to_f : HPSP::HP
psp = HPSP::Percent == true ? $game_party.actors[0].maxsp / 100.0 * HPSP::SP.to_f : HPSP::SP
addhp = actor.hp >= actor.maxhp ? "" : "+#{php.to_i}"
addsp = actor.sp >= actor.maxsp ? "" : "+#{psp.to_i}"
self.contents.font.color = Color.new(0, 0, 0)
for i in 1..4
x = i == 1 ? 49 : i == 2 ? 51 : i == 3 ? 49 : i == 4 ? 51 : 0
y = i == 1 ? 49 : i == 2 ? 49 : i == 3 ? 51 : i == 4 ? 51 : 0
unless HPSP::HP == 0
self.contents.draw_text(($game_player.screen_x - x) + 10, $game_player.screen_y - y, 150, 32, "#{addhp} #{hp}")
end
unless HPSP::SP == 0
self.contents.draw_text(($game_player.screen_x - x) + 10, ($game_player.screen_y - y) + 16, 150, 32, "#{addsp} #{sp}")
end
end
self.contents.font.color = Color.new(100, 255, 100)
unless HPSP::HP == 0
self.contents.draw_text($game_player.screen_x - 40, $game_player.screen_y - 50, 150, 32, "#{addhp} #{hp}")
end
unless HPSP::SP == 0
self.contents.draw_text($game_player.screen_x - 40, $game_player.screen_y - 34, 150, 32, "#{addsp} #{sp}")
end
end
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#----------------------------------------------------------------------------
# * Alias Listings
#----------------------------------------------------------------------------
alias raz_map_hpsp_main main
alias raz_map_hpsp_update update
#--------------------------------------------------------------------------
# * Main Draw
#--------------------------------------------------------------------------
def main
@count = 0
@move_count = 0
@window_move = false
@hpsp_window = Window_HPSP.new
raz_map_hpsp_main
@hpsp_window.dispose
end
#----------------------------------------------------------------------------
# * Frame Update
#----------------------------------------------------------------------------
def update
if $game_switches[HPSP::Switch_ID]
unless $game_player.moving?
if Graphics.frame_count / Graphics.frame_rate != @total_sec
@count += 1
end
end
if @count >= HPSP::Seconds * 40
@hpsp_window.refresh
@count = 0
@move_count = 0
@window_move = true
@hpsp_window.visible = true
for i in 0...$game_party.actors.size
actors = $game_party.actors[i]
hp = HPSP::Percent == true ? actors.maxhp.to_f / 100 * HPSP::HP.to_f : HPSP::HP
sp = HPSP::Percent == true ? actors.maxsp.to_f / 100 * HPSP::SP.to_f : HPSP::SP
actors.hp += hp.to_i
actors.sp += sp.to_i
if (HPSP::HP != 0 and actors.hp < actors.maxhp) or (HPSP::SP != 0 and actors.sp < actors.maxsp)
Audio.se_play("Audio/SE/" + HPSP::SE)
end
end
end
if @window_move
@hpsp_window.y -= 1
if @hpsp_window.y <= -30
@window_move = false
@hpsp_window.visible = false
@hpsp_window.y = 0
end
end
end
raz_map_hpsp_update
end
end