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.

Help with Damage Display (Outside Battle)

I've been trying to use scripts that display a number over a character when he takes damage or gains health outside of battle.

In Trickster's Damage Display, everything works in the demo except that one feature, and this problem occurs in a few other ones I've tried before, too.

For some reason, the numbers just won't show up at all.

Thank you for your time.
 
If you have the MACL 2.1+, you can use this:
Code:
$game_map.events[event_id].damage = n
$game_map.events[event_id].damage_pop = true

If not, just insert this in your game:
Code:
#============================================================================== 
# ** RGSS.Characters
#------------------------------------------------------------------------------
# Description:
# ------------
# Methods for the Game_Character classes and sub-classes
#  
# Method List:
# ------------
#
#   Game_Character
#   --------------
#   opacity=
#   battler=
#   battler
#   damage=
#   damage
#   critical=
#   critical
#   damage_pop=
#   damage_pop
#   can_move_toward_target?
#   move_toward_target
#    
#   Game_Event
#   ----------
#   erased
#   event_comment_list
#
# Modified Methods:
# -----------------
#
#   Game_Player:
#   ------------
#   initialize
#   refresh
#==============================================================================

#==============================================================================
# ** Game_Character
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_writer :opacity
  attr_accessor :damage, :critical, :damage_pop, :battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_maclchrdp_gchr_init, :initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @damage, @critical, @damage_pop, @battler = nil, false, false, nil
    seph_maclchrdp_gchr_init
  end
  #-------------------------------------------------------------------------
  # * Name      : Can Move Towards Target?
  #   Info      : Checks if character can move towards target
  #   Author    : SephirothSpawn
  #   Call Info : Integer Amounts, Destination X & Y
  #-------------------------------------------------------------------------
  def can_move_toward_target?(x, y)
    # Get difference in player coordinates
    sx = @x - x
    sy = @y - y
    # If coordinates are equal, return false
    return false if sx == 0 and sy == 0
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    # Passable Testings
    pass = {2 => passable?(@x, @y, 2), 4 => passable?(@x, @y, 4), 
            6 => passable?(@x, @y, 6), 8 => passable?(@x, @y, 8),
            24 => passable?(@x, @y, 2) && passable?(@x, @y + 1, 4),
            26 => passable?(@x, @y, 2) && passable?(@x, @y + 1, 6),
            42 => passable?(@x, @y, 4) && passable?(@x - 1, @y, 2),
            48 => passable?(@x, @y, 4) && passable?(@x - 1, @y, 8),
            62 => passable?(@x, @y, 6) && passable?(@x + 1, @y, 2),
            68 => passable?(@x, @y, 6) && passable?(@x + 1, @y, 8),
            84 => passable?(@x, @y, 8) && passable?(@x, @y - 1, 4),
            86 => passable?(@x, @y, 8) && passable?(@x, @y - 1, 6)}
    # Movement Testings
    if abs_sx > abs_sy
      if sx != 0
        if sx > 0
          return true, 4 if pass[4]
          sy > 0 ? (return true, 8 if pass[84]) : (return true, 2 if pass[24])
        else
          return true, 6 if pass[6]
          sy > 0 ? (return true, 8 if pass[86]) : (return true, 2 if pass[26])
        end
      end
      if sy != 0
        if sy > 0
          return true, 8 if pass[8]
          sx > 0 ? (return true, 4 if pass[48]) : (return true, 6 if pass[68])
        else
          return true, 2 if pass[2]
          sx > 0 ? (return true, 4 if pass[42]) : (return true, 6 if pass[62])
        end
      end
    else
      if sy != 0
        if sy > 0
          return true, 8 if pass[8]
          sx > 0 ? (return true, 4 if pass[48]) : (return true, 6 if pass[68])
        else
          return true, 2 if pass[2]
          sx > 0 ? (return true, 4 if pass[42]) : (return true, 6 if pass[62])
        end
      end
      if sx != 0
        if sx > 0
          return true, 4 if pass[4]
          sy > 0 ? (return true, 8 if pass[84]) : (return true, 2 if pass[24])
        else
          return true, 6 if pass[6]
          sy > 0 ? (return true, 8 if pass[86]) : (return true, 2 if pass[26])
        end
      end
    end
    # Return False if No Possible Moves
    return false
  end
  #-------------------------------------------------------------------------
  # * Name      : Move Towards Target
  #   Info      : Moves character towards target position
  #   Author    : SephirothSpawn
  #   Call Info : Integer Amounts, Destination X & Y
  #-------------------------------------------------------------------------
  def move_toward_target(x, y)
    # Gets Test Status
    can, dir = can_move_toward_target?(x, y)
    # Returns If Can't Move
    return unless can
    # Moves By Direction
    move_down  if dir == 2
    move_left  if dir == 4
    move_right if dir == 6
    move_up    if dir == 8
  end
end

#==============================================================================
# ** Game_Player
#==============================================================================

class Game_Player
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  alias_method :macl_gmplyr_init, :initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super
    @battler = $game_party.actors[0]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # If party members = 0
    if $game_party.actors.size == 0
      # Clear character file name and hue
      @character_name = ""
      @character_hue = 0
      # End method
      return
    end
    # Set lead actor
    @battler = $game_party.actors[0]
    # Set character file name and hue
    @character_name = @battler.character_name
    @character_hue = @battler.character_hue
    # Initialize opacity level and blending method
    @opacity = 255
    @blend_type = 0
  end
end

#==============================================================================
# ** Game_Event
#==============================================================================

class Game_Event
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :erased                  # trigger
  #-------------------------------------------------------------------------
  # * Name      : Event Comment List
  #   Info      : Gets the Info from the comments in events
  #               returns A Hash setup like so {'trigger' => info}
  #   Author    : Trickster
  #   Call Info : Variable Amount, String used for triggers
  #   Comments  : Detects Integers, Floats, Arrays and Hashes, else its a string
  #-------------------------------------------------------------------------
  def event_comment_list(*triggers)
    # Setup Parameters
    parameters = {}
    # Run Through Each Page With Index
    @event.pages.each_with_index do |page, index|
      parameters[index] = {}
      list = page.list
      return if list == nil or not list.is_a?(Array)
      list.each do |command|
        next if command.code != 108
        comment = command.parameters[0]
        array = comment.split
        trigger = array[0]
        value = array[1...array.size].join
        value = value.to_i if value =~ /\d+/
        value = value.to_f if value =~ /\d+\.\d+/
        value = eval(value) if value =~ /\[\.+\]/ or value =~ /\{\.+\}/
        parameters[index][trigger] = value if triggers.include?(trigger)
      end
    end
    return parameters
  end
end
#==============================================================================
# ** Sprite_Character
#==============================================================================

class Sprite_Character
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :sephmaclchdp_schr_update, :update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    sephmaclchdp_schr_update
    return if @character.nil? || self.visible == false || self.bitmap.nil?
    # Damage
    if @character.damage_pop
      damage(@character.damage, @character.critical)
      @character.damage = nil
      @character.critical = false
      @character.damage_pop = false
    end
  end
end

Mind you, all I did was take out the elements I added into the MACL. Granted, there are more than what you need there, but I am lazy. Just use the MACL 2.1. XD
 

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