modern_algebra

Visible Injuries 1.0.0

Jul 18th, 2012
171
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #    Visible Injuries
  3. #    Version: 1.0.0
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: July 18, 2012
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #    
  9. #    This script allows you to set it so that an enemy's battler will change
  10. #   when the enemy falls below any percentage of HP you choose. This can be
  11. #   used to make it so that the battler looks like it gets progressively
  12. #   more injured throughout the battle.
  13. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  14. #  Instructions:
  15. #    
  16. #    Paste this script into its own slot in the Script Editor, above Main but
  17. #   below Materials.
  18. #
  19. #    To set which battlers should be used to reflect injury and at what
  20. #   percentage of health, you use the following code in the enemy's note field:
  21. #
  22. #        \injured_battler[p, "b", h]
  23. #
  24. #    where:  p - an integer between 1 and 100; this is the percentage of HP
  25. #           the enemy must fall below before the battler is changed.
  26. #            b - the filename of the battler
  27. #            h - the hue of the battler. If not included, defaults to 0.
  28. #
  29. #  EXAMPLE:
  30. #
  31. #    If the following is in an Slime's note field:
  32. #
  33. #        \injured_battler[50, "Slime", 128]
  34. #
  35. #    Then when the Slime falls below 50% HP, it will change hue to 128.
  36. #
  37. #    If the following is in a Bandit's note field:
  38. #
  39. #        \injured_battler[70, "Injured Bandit"]
  40. #        \injured_battler[25, "Wounded Bandit"]
  41. #
  42. #    Then when the Bandit falls below 70% HP, the battler graphic will change
  43. #   to "Injured Bandit". When the Bandit falls below 25% HP, the battler
  44. #   graphic will change to "Wounded Bandit".
  45. #==============================================================================
  46.  
  47. $imported ||= {}
  48. $imported[:"VisibleInjuries 1.0.0"] = true
  49.  
  50. #==============================================================================
  51. # ** RPG::Enemy
  52. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  53. #  Summary of Changes:
  54. #    new methods - vi_injured_battlers
  55. #==============================================================================
  56.  
  57. class RPG::Enemy
  58.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  59.   # * Injured Battlers
  60.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61.   def vi_injured_battlers
  62.     if !@vi_injured_battlers
  63.       @vi_injured_battlers = []
  64.       self.note.scan(/\\INJURED_BATTLER\[\s*(\d+)[,;:\s]*\"(.+?)\"[,;:\s]*(\d*)\s*\]/i) { |ary|
  65.        @vi_injured_battlers.push([(ary[0].to_f / 100.0), ary[1], ary[2].to_i])
  66.      }
  67.      @vi_injured_battlers.push([100, battler_name, battler_hue])
  68.      @vi_injured_battlers.sort! {|a, b| a[0] <=> b[0] }
  69.    end
  70.    @vi_injured_battlers
  71.  end
  72. end
  73.  
  74. #==============================================================================
  75. # ** Game_Enemy
  76. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  77. #  Summary of Changes:
  78. #    aliased method - hp=; refresh; recover_all
  79. #    new method - vi_update_injuries
  80. #==============================================================================
  81.  
  82. class Game_Enemy
  83.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84.  # * Change HP
  85.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  86.  alias ma_vi_chnghp_2kh5 hp=
  87.  def hp=(*args, &block)
  88.    ma_vi_chnghp_2kh5(*args, &block) # Call Original Method
  89.    vi_update_injuries
  90.  end
  91.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  92.  # * Refresh
  93.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  94.  alias ma_vi_refr_6jz3 refresh
  95.  def refresh(*args, &block)
  96.    ma_vi_refr_6jz3(*args, &block) # Call Original Method
  97.    vi_update_injuries
  98.  end
  99.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100.  # * Recover All
  101.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102.  alias ma_vi_recovall_3hk9 recover_all
  103.  def recover_all(*args, &block)
  104.    ma_vi_recovall_3hk9(*args, &block) # Call Original Method
  105.    vi_update_injuries
  106.  end
  107.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  108.  # * Update Injuries
  109.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  110.  def vi_update_injuries
  111.    enemy.vi_injured_battlers.each { |ary|
  112.      if hp_rate <= ary[0]
  113.        @battler_name = ary[1]
  114.        @battler_hue = ary[2]
  115.        break
  116.      end
  117.    }
  118.  end
  119. end
RAW Paste Data