Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Resolved]Changing battle damage font

Status
Not open for further replies.
Hey, can someone tell me which default script I need to edit to change the font used for the battle damage amounts? Help would be appreciated please!
 
Place this below that script. Trust me.

Code:
module RPG
  class Sprite < ::Sprite
    @@font = Font.new("Arial Black", 16)
    @@font.bold = true

    def self.font
      @@font
    end

    def self.font=(value)
      @@font = value
    end

    def damage(value, critical, type = 0)
      if value.is_a?(Numeric)
        damage_string = value.abs.to_s
      else
        damage_string = value.to_s
      end
      bitmap = Bitmap.new(160, 48)
      bitmap.font = @@font.clone
      bitmap.font.color.set(0, 0, 0)
      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
      if value.is_a?(Numeric) and value < 0
        if type == 0
          bitmap.font.color.set(176, 255, 144)
        else
          bitmap.font.color.set(176, 144, 255)
        end
      else
        if type == 0
          bitmap.font.color.set(255, 255, 255)
        else
          bitmap.font.color.set(255, 176, 144)
        end
      end
      if type == 2
        bitmap.font.color.set(255, 224, 128)
      end
      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
      if critical
        string = "CRITICAL"
        bitmap.font.size = 20
        bitmap.font.color.set(0, 0, 0)
        bitmap.draw_text(-1, -1, 160, 20, string, 1)
        bitmap.draw_text(+1, -1, 160, 20, string, 1)
        bitmap.draw_text(-1, +1, 160, 20, string, 1)
        bitmap.draw_text(+1, +1, 160, 20, string, 1)
        bitmap.font.color.set(255, 255, 255)
        bitmap.draw_text(0, 0, 160, 20, string, 1)
      end
      num = @_damage.size
      if type != 2
        @_damage.push([::Sprite.new, 40, 0, rand(40) - 20, rand(30) + 50])
      else
        @_damage.push([::Sprite.new, 40, 0, rand(20) - 10, rand(20) + 60])
      end
      @_damage[num][0].bitmap = bitmap
      @_damage[num][0].ox = 80 + self.viewport.ox
      @_damage[num][0].oy = 20 + self.viewport.oy
      if self.battler.is_a?(Game_Actor)
        @_damage[num][0].x = self.x
        @_damage[num][0].y = self.y - self.oy / 2
      else
        @_damage[num][0].x = self.x + self.viewport.rect.x -
                            self.ox + self.src_rect.width / 2
        @_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 +
                            self.viewport.rect.y
        @_damage[num][0].zoom_x = self.zoom_x
        @_damage[num][0].zoom_y = self.zoom_y
        @_damage[num][0].z = 3000
      end
    end
  end
end

Try that.
 
This topic has been resolved. If Dopples or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top