Wounded Enemy Graphics
Version: 1.0a
Author: modern algebra
Date: July 29, 2011
Version History
- <Version 1.0a> 2011.08.29 - Changed the REGEXP to allow for the use of quotation marks to resolve ambiguities
- <Version 1.0> 2011.07.08 - Original Release
Description
This script allows you to change the graphics used for enemy battlers and depending on the amount of HP they have left. This allows you to make them look wounded when they get below a certain percentage of health
Features
- Allows you to replace the graphic of an enemy when they fall below a specified percentage of HP
- Can set individual and multiple thresholds for each enemy, allowing them to look progressively weaker
- Can also set the hue
Screenshots Instructions
Paste this script into its own slot above Main but below Materials in the Script Editor. If you are using the Note Editor and General Patch, then this script should go below it.
See the header of the script for instructions on use.
Script
#==============================================================================
# Wounded Enemy Graphics
# Version: 1.0a
# Author: modern algebra (rmrk.net)
# Date: July 29, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to change the graphics used for enemy battlers and
# depending on the amount of HP they have left. This allows you to make them
# look wounded when they get below a certain percentage of health
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into its own slot above Main but below Materials in the
# Script Editor. If you are using the Note Editor and General Patch, then
# this script should go below it.
#
# This script is easy to use. To setup a wounded graphic, all you need to do
# is put the following code in the notebox of an enemy:
#
# \WG[threshold, "filename", hue]
# threshold : this is an integer and it is the percentage of HP below
# which this graphic will be shown. If excluded, it defaults to the
# value you set at line 50.
# filename : the name of the battler graphic it changes to. You
# should use quotation marks to avoid ambiguity (especially with
# filenames that are numbers) but you can also omit them.
# hue : the hue the graphic is when it changes. Defaults to 0
# if excluded.
#
# EXAMPLES:
#
# \wg[20, "Slime"]
# The graphic would change to slime with hue 0 when the enemy goes below 20%
# health
#
# \Wg["54", 70]
# The graphic would change to that of 54 with hue 70 when the enemy's HP
# falls below whatever percentage you set at line 50 (by default, 15)
#
# \WG[40, Slime, 75]
# The graphic would change to Slime with hue 75 when the enemy goes below
# 40% health.
#==============================================================================
$imported = {} unless $imported
$imported["MAWoundedEnemyGraphics"] = true
# The below value is the default HP threshold to show a new graphic.
MAWEG_DEFAULT_THRESHOLD = 15
#==============================================================================
# ** RPG::Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - wounded_graphics
# aliased method (if using Note Editor & Patch) - ma_reset_note_values
#==============================================================================
class RPG::Enemy
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Wounded Graphics
#``````````````````````````````````````````````````````````````````````````
# This method interprets the notes and returns an array with each battler
# in the form [threshold, battler_graphic, hue]
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def wounded_graphics
if !@wounded_graphics
@wounded_graphics = { 100 => [self.battler_name, self.battler_hue] }
self.note.gsub (/\\WG\[\s*(\d*?)\s*[,;]?\s*\"?([^,;\]\"]+)\"?[,;]?\s*(\d*?)\s*\]/i) {
threshold = $1.empty? ? MAWEG_DEFAULT_THRESHOLD : $1.to_i
@wounded_graphics[threshold] = [$2, $3.to_i]; ""
}
end
return @wounded_graphics
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Reset Note Values
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if self.method_defined? (:ma_reset_note_values)
alias mlg_woundgrp_resetnote_6th2 ma_reset_note_values
def ma_reset_note_values (*args)
mlg_woundgrp_resetnote_6th2 (*args) # Run Original Method
@wounded_graphics = nil
end
end
end
#==============================================================================
# ** Game_Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - hp=
#==============================================================================
class Game_Enemy
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set HP
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mag_wound_sethp_6gz9 hp= unless self.method_defined? (:mag_wound_sethp_6gz9)
def hp= (*args, &block)
mag_wound_sethp_6gz9 (*args, &block) # Run Original Method
wg = enemy.wounded_graphics
return if wg.empty? || self.dead? # Ignore if no wounded set or dead
# Set battle graphics depending on whether the threshold has been reached
health_percent = (self.hp * 100) / self.maxhp
wg.keys.sort.each { |threshold|
if health_percent <= threshold
@battler_name, @battler_hue = *wg[threshold]
break
end
}
end
end
Credit
Support
Please post in this topic at RMRK for support, no matter how old the topic is. Do not PM me.
Known Compatibility Issues
Except for scripts that dramatically change battler graphics, this should be compatible with most other scripts. If using the Note Editor, then the General Compatibility Patch is required and both should be above this script in the Editor.