Jump to content
Rpg²S Forum
  • 0

Aiuto hud [RISOLTO]


gianlu
 Share

Question

Ciaoooooo! Mi serve un'aiuto con lo script di una Hud che sto cercando di modificare io ci vorrei mettere delle barre ad immagini ma non so come fare, anche perchè uso questo:

#---------------------------------------------------------------------------
# *** HP/MP/ATB/Overdrive bar Slanted Style Compatible with RTAB ***
# *** Version 1
#---------------------------------------------------------------------------
#by Clive based on Cogwheel and Sephirothspawn's bars.
#---------------------------------------------------------------------------
#
#=========================================================================



class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Get the current EXP
#--------------------------------------------------------------------------
 def now_exp
 return @exp - @exp_list[@level]
 end
#--------------------------------------------------------------------------
# * Get the next level's EXP
#--------------------------------------------------------------------------
 def next_exp
 return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
 end
end




class Window_Base < Window  
 
#==========================================================================
# * Customization
#--------------------------------------------------------------------------
# 
@Slant_ATB = false          #  __To enable/disable slanted ATB bars
#
#
#  __If you use the Slanted ATB bar: To change the height of the ATB bar, 
#    change the value of the height at line 297, if you do not use it
#    you can change the height in the RTAB script
#   
#  
#    
#    
#==========================================================================  


 alias raz_bars_base_exp draw_actor_exp
 alias raz_bars_base_parameter draw_actor_parameter
 
#==========================================================================
# * Draw Slant Bar(by SephirothSpawn)
#==========================================================================
 def draw_slant_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 Border
   for i in 0..height
     self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
   end
   # 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 + i, 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 + j, y + height - j, 1, 1, Color.new(r, g, b, a))
     end
   end
 end
 
#==========================================================================
# * Draw HP
#     actor : actor
#     x     : draw spot x-coordinate
#     y     : draw spot y-coordinate
#     width : draw spot width
#==========================================================================
 alias :draw_actor_hp_hpsp :draw_actor_hp
 def draw_actor_hp(actor, x, y, width = 144)
   # Calculate if there is draw space for MaxHP
   if width - 32 >= 108
     hp_x = x + width - 108
     flag = true
   elsif width - 32 >= 48
     hp_x = x + width - 48
     flag = false
   end
   
   if $game_temp.in_battle
     bar_width = hp_x - x + 50
     else
     bar_width = hp_x - x + 100
   end
   # Draw HP
   draw_slant_bar(x, y + 12, actor.hp, actor.maxhp, bar_width, 6, bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
   self.contents.font.color = system_color
   self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
   self.contents.font.color = actor.hp == 0 ? knockout_color :
     actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
   self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
   # Draw MaxHP
   if flag
     self.contents.font.color = normal_color
     self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
     self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
   end
    draw_actor_hp_hpsp(actor, x, y, width)
  end
  
  
#==========================================================================
# * Draw SP
#     actor : actor
#     x     : draw spot x-coordinate
#     y     : draw spot y-coordinate
#     width : draw spot width
#==========================================================================
  alias :draw_actor_sp_hpsp :draw_actor_sp
 def draw_actor_sp(actor, x, y, width = 144)
   # Calculate if there is draw space for MaxHP
   if width - 32 >= 108
     sp_x = x + width - 108
     flag = true
   elsif width - 32 >= 48
     sp_x = x + width - 48
     flag = false
   end
   if $game_temp.in_battle
     bar_width = sp_x - x + 50
     else
     bar_width = sp_x - x + 100
   end
   # Draw SP
   draw_slant_bar(x, y + 12, actor.sp, actor.maxsp, bar_width, 6, bar_color = Color.new(0, 0, 155, 255), end_color = Color.new(255, 255, 255, 255))
   # Draw "SP" text string
   self.contents.font.color = system_color
   self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
   self.contents.font.color = actor.sp == 0 ? knockout_color :
     actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
   self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
   # Draw MaxSP
   if flag
     self.contents.font.color = normal_color
     self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
     self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
   end
 end
 
 
 
#==========================================================================
# * Draw EXP
#     actor : actor
#     x     : draw spot x-coordinate
#     y     : draw spot y-coordinate
#==========================================================================
 def draw_actor_exp(actor, x, y)
   if actor.level == 99
   draw_slant_bar(x, y + 18, 1, 1, 190, 6, bar_color = Color.new(0, 100, 0, 255), end_color = Color.new(0, 255, 0, 255))
     else
   draw_slant_bar(x, y + 18, actor.now_exp, actor.next_exp, 190, 6, bar_color = Color.new(0, 100, 0, 255), end_color = Color.new(255, 255, 255, 255))
   end
   raz_bars_base_exp(actor, x, y)
   end

   def draw_actor_parameter(actor, x, y, type)
   case type
   when 0
     para_color1 = Color.new(100,0,0)
     para_color2 = Color.new(255,0,0)
     para_begin = actor.atk
   when 1
     para_color1 = Color.new(100,100,0)
     para_color2 = Color.new(255,255,0)
     para_begin = actor.pdef
   when 2
     para_color1 = Color.new(100,0,100)
     para_color2 = Color.new(255,0,255)
     para_begin = actor.mdef
   when 3
     para_color1 = Color.new(50,0,100)
     para_color2 = Color.new(50,0,255)
     para_begin = actor.str
   when 4
     para_color1 = Color.new(0,100,0)
     para_color2 = Color.new(0,255,0)
     para_begin = actor.dex
   when 5
     para_color1 = Color.new(50,0,50)
     para_color2 = Color.new(255,0,255)
     para_begin = actor.agi
   when 6
     para_color1 = Color.new(0,100,100)
     para_color2 = Color.new(0,255,255)
     para_begin = actor.int
   end
   draw_slant_bar(x, y + 18, para_begin, 999, 155, 4, bar_color = para_color1, end_color = para_color2)
   raz_bars_base_parameter(actor, x, y, type)
 end

#--------------------------------------------------------------------------
# * Drawing of gauge
#--------------------------------------------------------------------------
 def gauge_rect(x, y, rect_width, width, height, gauge, align1, align2, align3,
               color1, color2, color3, color4, color5, color6, grade1, grade2)
 
 case align1
   when 1
     x += (rect_width - width) / 2
   when 2
     x += rect_width - width
   end
   
case align2
   when 1
     y -= height / 2
   when 2
     y -= height
   end
   
   # Framework Drawing
   #self.contents.fill_rect(x, y, width, height, color1)
   #self.contents.fill_rect(x +1, y+1, width +1, height +1, color2)

   if align3 == 0
     if grade1 == 2
       grade1 = 3
     end
     if grade2 == 2
       grade2 = 3
     end
   end
   
   
   if (align3 == 1 and grade1 == 0) or grade1 > 0
     color = color3
     color3 = color4
     color4 = color
   end
   if (align3 == 1 and grade2 == 0) or grade2 > 0
     color = color5
     color5 = color6
     color6 = color
   end
   
   
# Drawing of empty gauge
# for i in 0..height
#  self.contents.gradation_rect(x + 2, y+ 2, width - 4, height - 4,
#                                  color3, color4, grade1)
#  end

   
   if align3 == 1
     x += width - gauge
   end

   

#Drawing of actual gauge
   for i in 0..height
   self.contents.gradation_rect(x + i, y + height -i, gauge -4, height -4,color5, color6, grade2)
 end


 

 

end  
#end
#end











if @Slant_ATB
#=========================================================================
# * Draw Actor ATG
#     actor : Actor
#     x     : draw spot x-coordinate
#     y     : draw spot y-coordinate
#     width : draw spot width
#=========================================================================

 def draw_actor_atg(actor, x, y, width = 144, height = 5)

   if @at_gauge == nil
     # plus_x:     revised x-coordinate
     # rate_x:     revised X-coordinate as (%)
     # plus_y:     revised y-coordinate
     # plus_width: revised width
     # rate_width: revised width as (%)
     # height:     Vertical width
     # align1: Type 1 ( 0: left justify  1: center justify 2: right justify )
     # align2: Type 2 ( 0: Upper stuffing 1: Central arranging  2:Lower stuffing )
     # align3: Gauge type 0:Left justify 1: Right justify
     @plus_x = 0
     @rate_x = 0
     @plus_y = 16
     @plus_width = 0
     @rate_width = 100
     @width = @plus_width + width * @rate_width / 100
     @height = 5
     @align1 = 0
     @align2 = 1
     @align3 = 0
     # Gradation settings:  grade1: Empty gauge   grade2:Actual gauge
     # (0:On side gradation   1:Vertically gradation    2: Slantedly gradation)
     grade1 = 1
     grade2 = 0
     # Color setting. color1: Outermost framework, color2: Medium framework
     # color3: Empty framework dark color, color4: Empty framework light/write color
     color1 = Color.new(0, 0, 0)
     color2 = Color.new(255, 255, 192)
     color3 = Color.new(0, 0, 0, 192)
     color4 = Color.new(0, 0, 64, 192)
     # Color setting of gauge
     # Usually color setting of the time
     color5 = Color.new(0, 64, 80)
     color6 = Color.new(255, 255, 255)#(0, 128, 160)
     # When gauge is MAX, color setting
     color7 = Color.new(80, 0, 0)
     color8 = Color.new(255, 255,255) #(240,0,0)
     # Color setting at time of cooperation skill use
     color9 = Color.new(80, 64, 32)
     color10 = Color.new(255, 255, 255) #(240, 192, 96)
     # Color setting at time of skill permanent residence
     color11 = Color.new(80, 0, 64)
     color12 = Color.new(255,255, 255) #(240, 0, 192)
     # Drawing of gauge
     gauge_rect_at(@width, @height, @align3, color1, color2,
                 color3, color4, color5, color6, color7, color8,
                 color9, color10, color11, color12, grade1, grade2)
   end
   # Variable at substituting the width of the gauge which is drawn
   if actor.rtp == 0
     at = (width + @plus_width) * actor.atp * @rate_width / 10000
   else
     at = (width + @plus_width) * actor.rt * @rate_width / actor.rtp / 100
   end
   if at > width
     at = width
   end
   # Revision such as the left stuffing central posture of gauge
   case @align1
   when 1
     x += (@rect_width - width) / 2
   when 2
     x += @rect_width - width
   end
   case @align2
   when 1
     y -= @height / 2
   when 2
     y -= @height
   end
   
   #for i in 0..height
   #self.contents.blt(x  - @plus_x + width * @rate_x / 100, y + @plus_y,
   #                  @at_gauge,Rect.new(-10, 0, @width, @height))
   #end
  # Draw Border
   for i in 0..height
     self.contents.fill_rect(x+1.5 + i, y+12 + height - i, width-2 , 3, Color.new(50, 50, 50, 255))
   end
   # 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+1.5 + i, y+12 + height - i, width-3, 3, Color.new(r, b, g, a))
   end
   
   
   
   
   if @align3 == 0
     rect_x = 0
   else
     x += @width - at - 1
     rect_x = @width - at - 1
   end
   
   # Color setting of gauge
   if at == width 
   #Gauge drawing at the time of MAX
     for i in 0..height
     self.contents.blt(x +i + @plus_x + @width * @rate_x / 100, y -i + @plus_y,
     @at_gauge, Rect.new(rect_x, @height * 2, at, @height))
     end
                     
     else
       
   if actor.rtp == 0
     for i in 0..height
   # Usually gauge drawing of the time
     self.contents.blt(x + i + @plus_x + @width * @rate_x / 100, y- i + @plus_y,
     @at_gauge,Rect.new(rect_x, @height, at, @height))
     end
     
     else
       
   if actor.spell == true
     for i in 0..height
   #Gauge drawing at time of cooperation skill use
     self.contents.blt(x +i + @plus_x + @width * @rate_x / 100, y -i + @plus_y,
     @at_gauge, Rect.new(rect_x, @height * 3, at, @height))
     end
   
     else
     
     for i in 0..height              
   # Gauge drawing at time of skill permanent residence
     self.contents.blt(x +i + @plus_x + @width * @rate_x / 100, y -i + @plus_y,
     @at_gauge, Rect.new(rect_x, @height * 4, at, @height))
         end
       end
     end
   end
 end
   
end
end 

 

Questo invece è il mio quello di sopra mi da il problema di riscrivere una parte di window base quindi quando metto draw_actor_hp... me ne mette 2 che sono diverse...

 

class Window_HUD < Window_Base
 def initialize
   super(0, 0, 200, 110)
   self.opacity = 0
   self.contents = Bitmap.new(200 - 32, 110 - 32)
   self.contents.font.size = 10
   self.contents.font.name = "Arial"
   refresh
 end
 def refresh
   self.contents.clear
   reset_variables
   return if !@actor
   draw_actor_hp(@actor, 0, 10)
   draw_actor_name(@actor, -10, 0)
   draw_actor_level(@actor, -30, 20)    
   draw_actor_sp(@actor, 0, 30)
   draw_actor_exp(@actor, 0,50)
 end
 def reset_variables
   @actor = $game_party.actors[0]
   @old_hp = @actor ? @actor.hp : 0
   @old_maxhp = @actor ? @actor.maxhp : 0
   @old_sp = @actor ? @actor.sp : 0
   @old_maxsp = @actor ? @actor.maxsp : 0
 end
 def update
   super
   refresh if (@actor = $game_party.actors[0] or
               @old_hp = @actor ? @actor.hp : 0 or
               @old_maxhp = @actor ? @actor.maxhp : 0 or
               @old_sp = @actor ? @actor.sp : 0 or
               @old_maxsp = @actor ? @actor.maxsp : 0)
 end
end
class Scene_Map
 alias yourhud_main main
 alias yourhud_update update
 def main
   @yourhud = Window_HUD.new
   yourhud_main
   @yourhud.dispose
 end
 def update
   @yourhud.update
   yourhud_update
 end
end

Edited by gianlu

http://mypsn.eu.playstation.com/psn/profile/gianlu9767.png

 

Il mio progetto personale: (Sospeso)

 

http://img833.imageshack.us/img833/3821/progresso.png <-------Clicca sul banner per vedere il mio sito

Cercasi personale (anche alle prime armi) possibilmente grafico e storyboarder

 

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...