Save-Point
Damage appears behind bars in battle - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Damage appears behind bars in battle (/thread-3629.html)



Damage appears behind bars in battle - prioran - 07-19-2011

Hello all,

I'm back to work on my project and have run into a small problem. Would anyone be willing to share his/her knowledge with me? I'm using the SephirothSpawn bar script on the menu and battle screens, and when damage to the party is displayed during battle, the number appears behind the bars (i.e., is hidden by the bar graphics). Is it possible to display the damage in front of the bars instead?

Thanks in advance for any help you're willing to offer!










RE: Damage appears behind bars in battle - deValdr - 07-19-2011

Could you post the script please? This should be an easy fix.


RE: Damage appears behind bars in battle - prioran - 07-19-2011

Thanks for the quick reply and offer to help!

Here is the script:

Code:
class Window_Base < Window    
  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
  #--------------------------------------------------------------------------
  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 + 18, actor.hp, actor.maxhp, bar_width, 6, Color.new(100, 0, 0, 255), Color.new(255, 0, 0, 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
  end
  #--------------------------------------------------------------------------
  # * Draw SP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  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 + 18, actor.sp, actor.maxsp, bar_width, 6, Color.new(0, 0, 100, 255), Color.new(0, 0, 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

  def draw_actor_exp(actor, x, y)
    if actor.level == 99
    draw_slant_bar(x, y + 18, 1, 1, 190, 6, Color.new(0, 100, 0, 255), Color.new(0, 255, 0, 255))
      else
    draw_slant_bar(x, y + 18, actor.now_exp, actor.next_exp, 190, 6, Color.new(0, 100, 0, 255), Color.new(0, 255, 0, 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,  para_color1, para_color2)
    raz_bars_base_parameter(actor, x, y, type)
  end
end

class Game_Actor
  #--------------------------------------------------------------------------
  # * 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


EDIT: I FIXED THE PROBLEM BY RESTORING WINDOW_BASE TO DEFAULT. SOMETHING THERE WAS PREVENTING THIS CODE FROM WORKING PROPERLY. PLEASE MARK AS SOLVED AND CLOSE.



RE: Damage appears behind bars in battle - prioran - 08-06-2011

My apologies for posting once more here, but it turns out that the problem was not solved as I thought.

The trouble is that battle animations, damage, and "critical" / "miss" text appear behind the bars during battle. I'm still using the script posted above. If I can provide any additional information in order to make troubleshooting easier, please let me know. Thanks to anyone who is willing to help!