The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX Ace => VXA Scripts Database => Topic started by: modern algebra on July 18, 2012, 07:09:03 PM

Title: [VXA] Visible Injuries 1.0.0
Post by: modern algebra on July 18, 2012, 07:09:03 PM
Visible Injuries
Version: 1.0.0
Author: modern algebra
Date: July 18, 2012

Version History



Description


This script allows you to set it so that an enemy's battler will change when the enemy falls below any percentage of HP you choose. This can be used to give the player visual feedback as to the HP status of each enemy.

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fs8.postimage.org%2F6uu07qoph%2Fvisinjuries.png&hash=f10a85f86825a302cdcbde206e3d5c5552cd0b99)

Instructions

Paste the script into its own slot in the Script Editor, above Main but below Materials.

See the header for additional instructions regarding setting up the script.

Script


Code: [Select]
#==============================================================================
#    Visible Injuries
#    Version: 1.0.0
#    Author: modern algebra (rmrk.net)
#    Date: July 18, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#   
#    This script allows you to set it so that an enemy's battler will change
#   when the enemy falls below any percentage of HP you choose. This can be
#   used to make it so that the battler looks like it gets progressively
#   more injured throughout the battle.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#   
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials.
#
#    To set which battlers should be used to reflect injury and at what
#   percentage of health, you use the following code in the enemy's note field:
#
#        \injured_battler[p, "b", h]
#
#    where:  p - an integer between 1 and 100; this is the percentage of HP
#           the enemy must fall below before the battler is changed.
#            b - the filename of the battler
#            h - the hue of the battler. If not included, defaults to 0.
#
#  EXAMPLE:
#
#    If the following is in an Slime's note field:
#
#        \injured_battler[50, "Slime", 128]
#
#    Then when the Slime falls below 50% HP, it will change hue to 128.
#
#    If the following is in a Bandit's note field:
#
#        \injured_battler[70, "Injured Bandit"]
#        \injured_battler[25, "Wounded Bandit"]
#
#    Then when the Bandit falls below 70% HP, the battler graphic will change
#   to "Injured Bandit". When the Bandit falls below 25% HP, the battler
#   graphic will change to "Wounded Bandit".
#==============================================================================

$imported ||= {}
$imported[:"VisibleInjuries 1.0.0"] = true

#==============================================================================
# ** RPG::Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new methods - vi_injured_battlers
#==============================================================================

class RPG::Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Injured Battlers
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def vi_injured_battlers
    if !@vi_injured_battlers
      @vi_injured_battlers = []
      self.note.scan(/\\INJURED_BATTLER\[\s*(\d+)[,;:\s]*\"(.+?)\"[,;:\s]*(\d*)\s*\]/i) { |ary|
        @vi_injured_battlers.push([(ary[0].to_f / 100.0), ary[1], ary[2].to_i])
      }
      @vi_injured_battlers.push([100, battler_name, battler_hue])
      @vi_injured_battlers.sort! {|a, b| a[0] <=> b[0] }
    end
    @vi_injured_battlers
  end
end

#==============================================================================
# ** Game_Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - hp=; refresh; recover_all
#    new method - vi_update_injuries
#==============================================================================

class Game_Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Change HP
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_vi_chnghp_2kh5 hp=
  def hp=(*args, &block)
    ma_vi_chnghp_2kh5(*args, &block) # Call Original Method
    vi_update_injuries
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_vi_refr_6jz3 refresh
  def refresh(*args, &block)
    ma_vi_refr_6jz3(*args, &block) # Call Original Method
    vi_update_injuries
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Recover All
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_vi_recovall_3hk9 recover_all
  def recover_all(*args, &block)
    ma_vi_recovall_3hk9(*args, &block) # Call Original Method
    vi_update_injuries
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Injuries
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def vi_update_injuries
    enemy.vi_injured_battlers.each { |ary|
      if hp_rate <= ary[0]
        @battler_name = ary[1]
        @battler_hue = ary[2]
        break
      end
    }
  end
end

You can also find the script at Pastebin (http://pastebin.com/BpBWv2kV)

Credit



Support


Please post in this topic at RMRK if you have any questions, suggestions, or other feedback.

Known Compatibility Issues

No currently known compatibility issues. If you find one, please let me know and provide a link to the incompatible script.

Terms of Use


I adopt RMRK's default Terms of Use (http://rmrk.net/index.php/topic,45481.0.html).
Title: Re: Visible Injuries 1.0.0
Post by: D&P3 on July 18, 2012, 07:27:38 PM
Good script as always, Modern :)


Where do you come up with these ideas for scripts?
Title: Re: Visible Injuries 1.0.0
Post by: Wiimeiser on July 19, 2012, 02:28:32 AM
This was in Final Fantasy: Mystic Quest (known in PAL regions as Mystic Quest: Legend and the first turn-based RPG released in a PAL country)
Title: Re: Visible Injuries 1.0.0
Post by: modern algebra on July 19, 2012, 02:19:04 PM
Well, I've never played that game, but I am sure I probably saw it in some other game somewhere. I sort of recall writing something like it for VX too, but I couldn't find it when I looked.