RadethDart
Sponsor
Could someone tell me how to make my HUD update as soon as something is changed? It only changes when the time is updated, how can I do this?
EDIT: I FIXED THAT, now my character takes a few steps, then stops for like half a sec, then keeps going, is there a way to make it so that she walks normally?
Here is the script, and please, no one try to steal it :dead:.
EDIT: I FIXED THAT, now my character takes a few steps, then stops for like half a sec, then keeps going, is there a way to make it so that she walks normally?
Here is the script, and please, no one try to steal it :dead:.
Code:
#-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:
# Shifter HUD
# v 1.0
# Author - Joshua Long
# This HUD is made for Shifter.
#-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:
class Scene_Map
alias hud_main main
alias hud_update update
def main
@hud = Window_hud.new
hud_main
@hud.dispose
end
def update
hud_update
@hud.update
end
end
class Window_hud < Window_Base
def initialize
super(-10, -10, 700, 700)
self.contents = Bitmap.new(750 - 32, 750 - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 16
self.back_opacity = 0
self.opacity = 0
refresh
end
#--------------------------------------------------------------------------
# * Game Time
#--------------------------------------------------------------------------
def game_time
total_sec = Graphics.frame_count / Graphics.frame_rate
hour = total_sec / 60 / 60
min = total_sec / 60 % 60
sec = total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
return text
end
#-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:
# Defines what goes into the hud
#-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:
def refresh
self.contents.clear
@actor = $game_party.actors[0]
@oldsp = @actor ? @actor.sp : 0
@oldmaxsp = @actor ? @actor.maxsp : 0
@oldhp = @actor ? @actor.hp : 0
@oldmaxhp = @actor ? @actor.maxhp : 0
@str = @actor ? @actor.str : 0
@agi = @actor ? @actor.agi : 0
@int = @actor ? @actor.int : 0
@dex = @actor ? @actor.dex : 0
@time = game_time
@time = $kts.time.to_s if $kts != nil
return if !@actor
bitmap = RPG::Cache.picture("hud")
self.contents.blt(-5, -5, bitmap, Rect.new(0, 0, 640, 480))
draw_bar(10, 460, @actor.sp, @actor.maxsp, 125, 10, Color.new(170, 170, 0, 255), Color.new(235, 230, 0, 255))
draw_bar(10, 440, @actor.hp, @actor.maxhp, 125, 10, Color.new(0, 175, 0, 255), Color.new(0, 73, 0, 255))
self.contents.draw_text(15, 445, 120, 32, "Stamina: " +$game_party.actors[0].sp.to_s + "/" +$game_party.actors[0].maxsp.to_s)
self.contents.draw_text(15, 425, 120, 32, "Health: " +$game_party.actors[0].hp.to_s + "/" +$game_party.actors[0].maxhp.to_s)
draw_actor_name(@actor, 585, 0)
self.contents.draw_text(5, 20, 100, 32, "Strength: " +$game_party.actors[0].str.to_s)
self.contents.draw_text(5, 34, 100, 32, "Agility: " +$game_party.actors[0].agi.to_s)
self.contents.draw_text(5, 48, 100, 32, "Intelligence: " +$game_party.actors[0].int.to_s)
self.contents.draw_text(5, 62, 100, 32, "Dexterity: " +$game_party.actors[0].dex.to_s)
self.contents.draw_text(395, 13, 640, 32, $game_party.gold.to_s)
self.contents.font.color = system_color
self.contents.font.color = normal_color
self.contents.font.size = 16
self.contents.draw_text(100, 20, 640, 32, "Level:")
self.contents.draw_text(150, 20, 640, 32, @actor.level.to_s)
draw_actor_graphic(@actor, 600, 75)
self.contents.draw_text(485, 13, 120, 32, @time.to_s)
weapon = $data_weapons[$game_party.actors[0].weapon_id]
unless weapon.nil?
weapon_name = weapon.name
weapon_icon = RPG::Cache.icon(weapon.icon_name)
self.contents.blt(579, 430, weapon_icon, weapon_icon.rect)
self.contents.draw_text(579, 405, 120, 32, weapon_name)
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
super
refresh if something_changed?
end
def something_changed?
actor = $game_party.actors[0]
@actor = $game_party.actors[0]
return false if Graphics.frame_count % 30 != 0
return true if Graphics.frame_count / Graphics.frame_rate != @total_sec
return true if actor != @actor
return true if @oldsp != @actor.sp or @oldmaxsp != @actor.maxsp
return true if @str != @actor.str
return true if @agi != @actor.agi
return true if @int != @actor.int
return true if @eva != @actor.dex
return true if @gold_n != $game_party.gold
return true if @level != @actor.level
return true if $kts != nil and @time != $kts.time.to_s
return true if $kts == nil and @time != game_time
end
end
end
#================================================= =============================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#================================================= =============================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw Slant Bar
#--------------------------------------------------------------------------
def draw_bar(x, y, min, max, width = 152, height = 6,
bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
# Draw Background
for i in 1..(height - 1)
r = 100 * (height - i) / height + 0 * i / height
g = 100 * (height - i) / height + 0 * i / height
b = 100 * (height - i) / height + 0 * i / height
a = 255 * (height - i) / height + 255 * i / height
self.contents.fill_rect(x, y + height - i, width, 1, Color.new(r, b, g, a))
end
# Draws Bar
for i in 1..( (min / max.to_f) * width - 1)
for j in 1..(height - 1)
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
self.contents.fill_rect(x + i - 1, y + height - j, 1, 1, Color.new(r, g, b, a))
end
end
end
end