Glitchfinder
Staff
By: Glitchfinder
Introduction
This script is one that I thought of doing when I was thinking about the classic advice to avoid injured animals, because they are much more dangerous, as well as thinking of the phrase "...like there is no tomorrow". What this script does is modify the default battle system so that when an actor or enemy has HP below a certain percentage defined by you, then their stats will change. (Which ones change and how much are also defined by you) For example, you could make an enemy that is below 25% HP have it's attack power go up, and have a drop in defense. This script will allow you to define which enemies or actors can experience this change, as well as how much the change will be, and in what stats.
Features
- Adds depth to any battle!
- Can be used to make battles easier, or more difficult!
- Changes occur dynamically based on the remaining HP of the character or monster!
- The less HP is left, the more pronounced the change becomes!
- Make monsters dangerous when injured!
- Weaken players as they get hurt!
Screenshots
This script would be difficult to take screenshots of, so I have decided to omit them.
Script
RMXP Version
Code:
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# ** Glitchfinder's Cornered Battle Statistics [RPG Maker XP]
# Version 1.10
#------------------------------------------------------------------------------
# This script helps game designers to manipulate the statistics of an enemy or
# character based on their remaining HP.
#==============================================================================
# * Version History
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Version 1 ---------------------------------------------------- (2008-08-10)
# - Initial version
# - Author: Glitchfinder
# Version 1.10 ----=------------------------------------------- (2011-03-16)
# - Added better documentation
# - Fixed crash on F12
# - Author: Glitchfinder
#==============================================================================
# * Instructions
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Place this script above Main, and below the default scripts. (I realize this
# is obvious to most, but some people don't get it.)
#
# To change the default percentage of HP at which an enemy will start
# experiencing stat changes, edit the values in the Enemy_Percent array within
# the Conrnered_Stats module. Each value corresponds to a specific enemy, with
# the first being enemy 001 (The default is Ghost), the second being enemy 002
# (Basilisk), and so on.
#
# To change the default percentage of HP at which an actor will start
# experiencing stat changes, edit the values in the Actor_Percent array within
# the Cornered_Stats module. This array follows the same rule as the
# Enemy_Percent array mentioned above.
#
# To modify the maximum percentage that an enemy's stats can change, edit the
# values in the Enemy_Percent_Change array in the Cornered_Stats module. The
# order of the values is Strength, Dexterity, Agility, Intelligence, Attack
# Power, Physical Defense Power, Magic Defense Power, and Evasion Correction.
# The first row is the first enemy in the database, (Ghost), the second row is
# the second enemy in the database (Basilisk), and so on.
#
# To modify the maximum percentage that an actor's stats can change, edit the
# values in the Actor_Percent_Change array in the Cornered_Stats module. The
# rules are the same as within the Enemy_Percent_Change array mentioned above.
#
# The percentages placed within the Enemy_Percent and Actor_Percent arrays must
# be in the decimal forma, while those placed within the Enemy_Percent_Change
# and Actor_Percent_Change arrays must be placed as a percentage, minus the %
# symbol.
#
# The percentages in the Enemy_Percent_Change and the Actor_Percent_Change
# arrays may be either negative or positive, while those placed in the
# Enemy_Percent and Actor_Percent arrays must be positive.
#
# If you do not want an enemy or actor to recive stat changes, then put nil in
# the proper location in the Enemy_Percent or Actor_Percent arrays.
#
# If you have designated an enemy or actor as unable to recieve stat changes,
# you must still define their row in their place in the Enemy_Percent_Change or
# Actor_Percent_Change arrays by placing a 0 in each stat.
#
# The amount that an enemy's or an actor's stats will change when this script
# comes into effect depends upon their remaining HP. The remaining HP is
# divided by the threshhold, and then is multiplied by the percent that the
# stat can change.(The threshhold is the amount of HP that corresponds to the
# percent defined in the Enemy_Percent or Actor_Percent arrays of the
# Cornered_Stats module.)
#==============================================================================
# * Glitchfinder's Advice
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# This script is meant for people with at least basic scripting knowledge. It
# may be difficult to use, and thus, if you are unsure of your abilities, it
# may be simpler to avoid using this script.
#
# I would recommend leaving the percentages within the Enemy_Percent_Change and
# Actor_Percent_Change arrays low, due to large stat distortions that may
# occur. (For example, even minor changes in one or two stats will render an
# enemy either unable to hit an actor or able to hit an actor every time)
#==============================================================================
# * Contact
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Glitchfinder, the author of this script, may be contacted through his
# website, found at [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]
#
# You may also find Glitchfinder at [url=http://www.hbgames.org]http://www.hbgames.org[/url]
#==============================================================================
# * Usage
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# This script may be used with the following terms and conditions:
#
# 1. This script is free to use in any noncommercial project. If you wish to
# use this script in a commercial (paid) project, please contact
# Glitchfinder at his website.
# 2. This script may only be hosted at the following domains:
# [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]
# [url=http://www.hbgames.org]http://www.hbgames.org[/url]
# 3. If you wish to host this script elsewhere, please contact Glitchfinder.
# 4. If you wish to translate this script, please contact Glitchfinder. He
# will need the web address that you plan to host the script at, as well
# as the language this script is being translated to.
# 5. This header must remain intact at all times.
# 6. Glitchfinder remains the sole owner of this code. He may modify or
# revoke this license at any time, for any reason.
# 7. Any code derived from code within this script is owned by Glitchfinder,
# and you must have his permission to publish, host, or distribute his
# code.
# 8. This license applies to all code derived from the code within this
# script.
# 9. If you use this script within your project, you must include visible
# credit to Glitchfinder, within reason.
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
#==============================================================================
# ** Cornered_Stats
#------------------------------------------------------------------------------
# This module deals with values used in an addition to the battle system. Its
# used within the Game_Battler and Scene_Battle classes.
#==============================================================================
module Cornered_Stats
#--------------------------------------------------------------------------
# * Set Enemy Stat Change Starting Point (Percentage, divided by 100)
#--------------------------------------------------------------------------
Enemy_Percent = [0.50, 0.25, 0.30, 0.40, 0.35, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil]
#--------------------------------------------------------------------------
# * Set Actor Stat Change Starting Point (Percentage, divided by 100)
#--------------------------------------------------------------------------
Actor_Percent = [0.15, nil, nil, nil, nil, nil, nil, nil]
#--------------------------------------------------------------------------
# * Set Maximum Enemy Stat Change (Percentage)
#--------------------------------------------------------------------------
Enemy_Percent_Change = [
# STR, DEX, AGI, INT, ATK, PDEF, MDEF, EVA
0, 0, 0, 0, 11, -5, -9, -3,
0, 0, 0, 0, 16, -2, -5, 0,
0, 0, 0, 0, 4, -7, -6, 0,
0, 0, 0, 0, 7, -4, -3, 0,
0, 0, 0, 0, 13, -2, -5, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
]
#--------------------------------------------------------------------------
# * Set Maximum Actor Stat Change (Percentage)
#--------------------------------------------------------------------------
Actor_Percent_Change = [
# STR, DEX, AGI, INT, ATK, PDEF, MDEF, EVA
0, 0, 0, 0, 16, -7, -9, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
]
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# This class deals with battlers. Its used as a superclass for the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
# If the initialize method has not been aliased
unless method_defined?(:cornered_battlers_initialize)
# Alias the enemy selection method
alias cornered_battlers_initialize initialize
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Set base stat modifiers
@str_change = 0
@dex_change = 0
@agi_change = 0
@int_change = 0
@atk_change = 0
@pdef_change = 0
@mdef_change = 0
@eva_change = 0
# Call the original method
cornered_battlers_initialize
end
#--------------------------------------------------------------------------
# * Get Strength (STR)
#--------------------------------------------------------------------------
def str
# Calculate the base stat
n = [[base_str + @str_plus + @str_change, 1].max, 999].min
# Iterate through the battler's current states
for i in @states
# Apply state-based modifiers to the stat
n *= $data_states[i].str_rate / 100.0
end
# Force the stat to a value between 1 and 999
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Get Dexterity (DEX)
#--------------------------------------------------------------------------
def dex
# Calculate the base stat
n = [[base_dex + @dex_plus + @dex_change, 1].max, 999].min
# Iterate through the battler's current states
for i in @states
# Apply state-based modifiers to the stat
n *= $data_states[i].dex_rate / 100.0
end
# Force the stat to a value between 1 and 999
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Get Agility (AGI)
#--------------------------------------------------------------------------
def agi
# Calculate the base stat
n = [[base_agi + @agi_plus + @agi_change, 1].max, 999].min
# Iterate through the battler's current states
for i in @states
# Apply state-based modifiers to the stat
n *= $data_states[i].agi_rate / 100.0
end
# Force the stat to a value between 1 and 999
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Get Intelligence (INT)
#--------------------------------------------------------------------------
def int
# Calculate the base stat
n = [[base_int + @int_plus + @int_change, 1].max, 999].min
# Iterate through the battler's current states
for i in @states
# Apply state-based modifiers to the stat
n *= $data_states[i].int_rate / 100.0
end
# Force the stat to a value between 1 and 999
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Get Attack Power
#--------------------------------------------------------------------------
def atk
# Calculate the base stat
n = base_atk + @atk_change
# Iterate through the battler's current states
for i in @states
# Apply state-based modifiers to the stat
n *= $data_states[i].atk_rate / 100.0
end
# Convert the stat into an integer and return it
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Physical Defense Power
#--------------------------------------------------------------------------
def pdef
# Calculate the base stat
n = base_pdef + @pdef_change
# Iterate through the battler's current states
for i in @states
# Apply state-based modifiers to the stat
n *= $data_states[i].pdef_rate / 100.0
end
# Convert the stat into an integer and return it
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Magic Defense Power
#--------------------------------------------------------------------------
def mdef
# Calculate the base stat
n = base_mdef + @mdef_change
# Iterate through the battler's current states
for i in @states
# Apply state-based modifiers to the stat
n *= $data_states[i].mdef_rate / 100.0
end
# Convert the stat into an integer and return it
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Evasion Correction
#--------------------------------------------------------------------------
def eva
# Calculate the base stat
n = base_eva + @eva_change
# Iterate through the battler's current states
for i in @states
# Apply state-based modifiers to the stat
n += $data_states[i].eva
end
return n
end
#--------------------------------------------------------------------------
# * Set Attack Power Modifier
# atk : new Attack Power
#--------------------------------------------------------------------------
def str_modifier=(str)
# Set the stat modifier
@str_change = str
end
#--------------------------------------------------------------------------
# * Set Attack Power Modifier
# atk : new Attack Power
#--------------------------------------------------------------------------
def dex_modifier=(dex)
# Set the stat modifier
@dex_change = dex
end
#--------------------------------------------------------------------------
# * Set Attack Power Modifier
# atk : new Attack Power
#--------------------------------------------------------------------------
def agi_modifier=(agi)
# Set the stat modifier
@agi_change = agi
end
#--------------------------------------------------------------------------
# * Set Attack Power Modifier
# atk : new Attack Power
#--------------------------------------------------------------------------
def int_modifier=(int)
# Set the stat modifier
@int_change = int
end
#--------------------------------------------------------------------------
# * Set Attack Power Modifier
# atk : new Attack Power
#--------------------------------------------------------------------------
def atk_modifier=(atk)
# Set the stat modifier
@atk_change = atk
end
#--------------------------------------------------------------------------
# * Set Physical Defense Power Modifier
# pdef : new Physical Defense Power
#--------------------------------------------------------------------------
def pdef_modifier=(pdef)
# Set the stat modifier
@pdef_change = pdef
end
#--------------------------------------------------------------------------
# * Set Magic Defense Power Modifier
# mdef : new Magic Defense Power
#--------------------------------------------------------------------------
def mdef_modifier=(mdef)
# Set the stat modifier
@mdef_change = mdef
end
#--------------------------------------------------------------------------
# * Set Evasion Correction Modifier
# eva : new Evasion Correction
#--------------------------------------------------------------------------
def eva_modifier=(eva)
# Set the stat modifier
@eva_change = eva
end
#--------------------------------------------------------------------------
# * Set Cornered Stats
#--------------------------------------------------------------------------
def cornered_stats(percent_change)
# Set the stat modifiers
cornered_str(percent_change)
cornered_dex(percent_change)
cornered_agi(percent_change)
cornered_int(percent_change)
cornered_atk(percent_change)
cornered_pdef(percent_change)
cornered_mdef(percent_change)
cornered_eva(percent_change)
end
#--------------------------------------------------------------------------
# * Get Cornered Strength
#--------------------------------------------------------------------------
def cornered_str(percent_change)
# Calculate index in stat array
str_formula = (8 * (self.id)) - 8
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
str_change_default = Cornered_Stats::Enemy_Percent_Change[str_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
str_change_default = Cornered_Stats::Actor_Percent_Change[str_formula]
end
# Calculate the stat change percentage
str_change_percent = str_change_default * (percent_change * 100)
# Calculate the stat change
str_change = (base_str * str_change_percent)
# Set the stat change
self.str_modifier = str_change
end
#--------------------------------------------------------------------------
# * Get Cornered Dexterity
#--------------------------------------------------------------------------
def cornered_dex(percent_change)
# Calculate index in stat array
dex_formula = (8 * (self.id)) - 7
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
dex_change_default = Cornered_Stats::Enemy_Percent_Change[dex_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
dex_change_default = Cornered_Stats::Actor_Percent_Change[dex_formula]
end
# Calculate the stat change percentage
dex_change_percent = dex_change_default * (percent_change * 100)
# Calculate the stat change
dex_change = (base_dex * dex_change_percent)
# Set the stat change
self.dex_modifier = dex_change
end
#--------------------------------------------------------------------------
# * Get Cornered Agility
#--------------------------------------------------------------------------
def cornered_agi(percent_change)
# Calculate index in stat array
agi_formula = (8 * (self.id)) - 6
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
agi_change_default = Cornered_Stats::Enemy_Percent_Change[agi_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
agi_change_default = Cornered_Stats::Actor_Percent_Change[agi_formula]
end
# Calculate the stat change percentage
agi_change_percent = agi_change_default * (percent_change * 100)
# Calculate the stat change
agi_change = (base_agi * agi_change_percent)
# Set the stat change
self.agi_modifier = agi_change
end
#--------------------------------------------------------------------------
# * Get Cornered Intelligence
#--------------------------------------------------------------------------
def cornered_int(percent_change)
# Calculate index in stat array
int_formula = (8 * (self.id)) - 5
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
int_change_default = Cornered_Stats::Enemy_Percent_Change[int_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
int_change_default = Cornered_Stats::Actor_Percent_Change[int_formula]
end
# Calculate the stat change percentage
int_change_percent = int_change_default * (percent_change * 100)
# Calculate the stat change
int_change = (base_int * int_change_percent)
# Set the stat change
self.int_modifier = int_change
end
#--------------------------------------------------------------------------
# * Get Cornered Attack Power
#--------------------------------------------------------------------------
def cornered_atk(percent_change)
# Calculate index in stat array
atk_formula = (8 * (self.id)) - 4
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
atk_change_default = Cornered_Stats::Enemy_Percent_Change[atk_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
atk_change_default = Cornered_Stats::Actor_Percent_Change[atk_formula]
end
# Calculate the stat change percentage
atk_change_percent = atk_change_default * (percent_change * 100)
# Calculate the stat change
atk_change = (base_atk * atk_change_percent)
# Set the stat change
self.atk_modifier = atk_change
end
#--------------------------------------------------------------------------
# * Get Cornered Physical Defense Power
#--------------------------------------------------------------------------
def cornered_pdef(percent_change)
# Calculate index in stat array
pdef_formula = (8 * (self.id)) - 3
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
pdef_change_default = Cornered_Stats::Enemy_Percent_Change[pdef_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
pdef_change_default = Cornered_Stats::Actor_Percent_Change[pdef_formula]
end
# Calculate the stat change percentage
pdef_change_percent = pdef_change_default * (percent_change * 100)
# Calculate the stat change
pdef_change = (base_pdef * pdef_change_percent)
# Set the stat change
self.pdef_modifier = pdef_change
end
#--------------------------------------------------------------------------
# * Get Cornered Magic Defense Power
#--------------------------------------------------------------------------
def cornered_mdef(percent_change)
# Calculate index in stat array
mdef_formula = (8 * (self.id)) - 2
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
mdef_change_default = Cornered_Stats::Enemy_Percent_Change[mdef_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
mdef_change_default = Cornered_Stats::Actor_Percent_Change[mdef_formula]
end
# Calculate the stat change percentage
mdef_change_percent = mdef_change_default * (percent_change * 100)
# Calculate the stat change
mdef_change = (base_mdef * mdef_change_percent)
# Set the stat change
self.mdef_modifier = mdef_change
end
#--------------------------------------------------------------------------
# * Get Cornered Evasion Correction
#--------------------------------------------------------------------------
def cornered_eva(percent_change)
# Calculate index in stat array
eva_formula = (8 * (self.id)) - 1
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
eva_change_default = Cornered_Stats::Enemy_Percent_Change[eva_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
eva_change_default = Cornered_Stats::Actor_Percent_Change[eva_formula]
end
# Calculate the stat change percentage
eva_change_percent = eva_change_default * (percent_change * 100)
# Calculate the stat change
eva_change = (base_eva * eva_change_percent)
# Set the stat change
self.eva_modifier = eva_change
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
# If the method has not been aliased
unless method_defined?(:cornered_battlers_update_phase4_step2)
# Alias the method
alias cornered_battlers_update_phase4_step2 update_phase4_step2
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 2 : start action)
#--------------------------------------------------------------------------
def update_phase4_step2
# Determine the active battler's current HP percentage
hp_percent = @active_battler.hp.to_f / @active_battler.base_maxhp.to_f
# Get the active battler's ID
battler_id = @active_battler.id - 1
# If the active battler is an enemy
if @active_battler.is_a?(Game_Enemy)
# Find the battler's stat change activation percentage
enemy_cornered_percent = Cornered_Stats::Enemy_Percent[battler_id]
# If the percentage is not nil and is greater than 0
if nil != enemy_cornered_percent && enemy_cornered_percent.to_s.to_f > 0
# If the battler is currently at or below the activation percentage
if enemy_cornered_percent.to_s.to_f >= hp_percent
# Determine the battler's stat changes
percent_change = (((enemy_cornered_percent.to_s.to_f *
@active_battler.base_maxhp) - @active_battler.hp) /
(enemy_cornered_percent.to_s.to_f * @active_battler.base_maxhp))
# Set the battler's stat changes
@active_battler.cornered_stats(percent_change.to_f)
end
end
# If the battler is an actor
elsif @active_battler.is_a?(Game_Actor)
# Find the battler's stat change activation percentage
actor_cornered_percent = Cornered_Stats::Actor_Percent[battler_id]
# If the percentage is not nil and is greater than 0
if nil != actor_cornered_percent && actor_cornered_percent.to_s.to_f > 0
# If the battler is currently at or below the activation percentage
if actor_cornered_percent.to_s.to_i >= hp_percent
# Determine the battler's stat changes
percent_change = (((actor_cornered_percent.to_s.to_f *
@active_battler.base_maxhp) - @active_battler.hp) /
(actor_cornered_percent.to_s.to_f * @active_battler.base_maxhp))
# Set the battler's stat changes
@active_battler::cornered_stats(percent_change)
end
end
end
# Call the original method
cornered_battlers_update_phase4_step2
end
end
RMVX Version
Code:
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# ** Glitchfinder's Cornered Battle Statistics [RPG Maker VX]
# Version 1.10
#------------------------------------------------------------------------------
# This script helps game designers to manipulate the statistics of an enemy or
# character based on their remaining HP.
#==============================================================================
# * Version History
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Version 1.00 ------------------------------------------------- (2008-08-10)
# - Initial version
# - Author: Glitchfinder
# Version 1.10 ----=------------------------------------------- (2011-03-16)
# - Added better documentation
# - Fixed crash on F12
# - Corrected stat lookup formulas
# - Author: Glitchfinder
#==============================================================================
# * Instructions
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Place this script above Main, and below the default scripts. (I realize this
# is obvious to most, but some people don't get it.)
#
# To change the default percentage of HP at which an enemy will start
# experiencing stat changes, edit the values in the Enemy_Percent array within
# the Conrnered_Stats module. Each value corresponds to a specific enemy, with
# the first being enemy 001 (The default is Slime), the second being enemy 002
# (Bat), and so on.
#
# To change the default percentage of HP at which an actor will start
# experiencing stat changes, edit the values in the Actor_Percent array within
# the Cornered_Stats module. This array follows the same rule as the
# Enemy_Percent array mentioned above.
#
# To modify the maximum percentage that an enemy's stats can change, edit the
# values in the Enemy_Percent_Change array in the Cornered_Stats module. The
# order of the values is Attack, Defense, Spirit, and Agility. The first row
# is the first enemy in the database, (Ghost), the second row is the second
# enemy in the database (Basilisk), and so on.
#
# To modify the maximum percentage that an actor's stats can change, edit the
# values in the Actor_Percent_Change array in the Cornered_Stats module. The
# rules are the same as within the Enemy_Percent_Change array mentioned above.
#
# The percentages placed within the Enemy_Percent and Actor_Percent arrays must
# be in the decimal forma, while those placed within the Enemy_Percent_Change
# and Actor_Percent_Change arrays must be placed as a percentage, minus the %
# symbol.
#
# The percentages in the Enemy_Percent_Change and the Actor_Percent_Change
# arrays may be either negative or positive, while those placed in the
# Enemy_Percent and Actor_Percent arrays must be positive.
#
# If you do not want an enemy or actor to recive stat changes, then put nil in
# the proper location in the Enemy_Percent or Actor_Percent arrays.
#
# If you have designated an enemy or actor as unable to recieve stat changes,
# you must still define their row in their place in the Enemy_Percent_Change or
# Actor_Percent_Change arrays by placing a 0 in each stat.
#
# The amount that an enemy's or an actor's stats will change when this script
# comes into effect depends upon their remaining HP. The remaining HP is
# divided by the threshhold, and then is multiplied by the percent that the
# stat can change.(The threshhold is the amount of HP that corresponds to the
# percent defined in the Enemy_Percent or Actor_Percent arrays of the
# Cornered_Stats module.)
#==============================================================================
# * Advice
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# This script is meant for people with at least basic scripting knowledge. It
# may be difficult to use, and thus, if you are unsure of your abilities, it
# may be simpler to avoid using this script.
#
# I would recommend leaving the percentages within the Enemy_Percent_Change and
# Actor_Percent_Change arrays low, due to large stat distortions that may
# occur. (For example, even minor changes in one or two stats will render an
# enemy either unable to hit an actor or able to hit an actor every time)
#==============================================================================
# * Contact
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Glitchfinder, the author of this script, may be contacted through his
# website, found at [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]
#
# You may also find Glitchfinder at [url=http://www.hbgames.org]http://www.hbgames.org[/url]
#==============================================================================
# * Usage
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# This script may be used with the following terms and conditions:
#
# 1. This script is free to use in any noncommercial project. If you wish to
# use this script in a commercial (paid) project, please contact
# Glitchfinder at his website.
# 2. This script may only be hosted at the following domains:
# [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]
# [url=http://www.hbgames.org]http://www.hbgames.org[/url]
# 3. If you wish to host this script elsewhere, please contact Glitchfinder.
# 4. If you wish to translate this script, please contact Glitchfinder. He
# will need the web address that you plan to host the script at, as well
# as the language this script is being translated to.
# 5. This header must remain intact at all times.
# 6. Glitchfinder remains the sole owner of this code. He may modify or
# revoke this license at any time, for any reason.
# 7. Any code derived from code within this script is owned by Glitchfinder,
# and you must have his permission to publish, host, or distribute his
# code.
# 8. This license applies to all code derived from the code within this
# script.
# 9. If you use this script within your project, you must include visible
# credit to Glitchfinder, within reason.
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
#==============================================================================
# ** Cornered_Stats
#------------------------------------------------------------------------------
# This module deals with values used in an addition to the battle system. Its
# used within the Game_Battler and Scene_Battle classes.
#==============================================================================
module Cornered_Stats
#--------------------------------------------------------------------------
# * Set Enemy Stat Change Starting Point (Percentage, divided by 100)
#--------------------------------------------------------------------------
Enemy_Percent = [0.75, 0.25, 0.30, 0.40, 0.35, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil]
#--------------------------------------------------------------------------
# * Set Actor Stat Change Starting Point (Percentage, divided by 100)
#--------------------------------------------------------------------------
Actor_Percent = [0.15, nil, nil, nil, nil, nil, nil, nil]
#--------------------------------------------------------------------------
# * Set Maximum Enemy Stat Change (Percentage)
#--------------------------------------------------------------------------
Enemy_Percent_Change = [
# ATK, DEF, SPI, AGI
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
]
#--------------------------------------------------------------------------
# * Set Maximum Actor Stat Change (Percentage)
#--------------------------------------------------------------------------
Actor_Percent_Change = [
# ATK, DEF, SPI, AGI
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
]
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# This class deals with battlers. Its used as a superclass for the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
# If the initialize method has not been aliased
unless method_defined?(:cornered_battlers_initialize)
# Alias the enemy selection method
alias cornered_battlers_initialize initialize
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Set base stat modifiers
@atk_change = 0
@def_change = 0
@spi_change = 0
@agi_change = 0
# Call the original method
cornered_battlers_initialize
end
#--------------------------------------------------------------------------
# * Get Attack
#--------------------------------------------------------------------------
def atk
# Calculate the base stat
n = [[base_atk + @atk_plus + @atk_change, 1].max, 999].min
# Apply state-based modifiers to the stat
for state in states do n *= state.atk_rate / 100.0 end
# Force the stat to a value between 1 and 999
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Get Defense
#--------------------------------------------------------------------------
def def
# Calculate the base stat
n = [[base_def + @def_plus + @def_change, 1].max, 999].min
# Apply state-based modifiers to the stat
for state in states do n *= state.def_rate / 100.0 end
# Force the stat to a value between 1 and 999
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Get Spirit
#--------------------------------------------------------------------------
def spi
# Calculate the base stat
n = [[base_spi + @spi_plus + @spi_change, 1].max, 999].min
# Apply state-based modifiers to the stat
for state in states do n *= state.spi_rate / 100.0 end
# Force the stat to a value between 1 and 999
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Get Agility
#--------------------------------------------------------------------------
def agi
# Calculate the base stat
n = [[base_agi + @agi_plus + @agi_change, 1].max, 999].min
# Apply state-based modifiers to the stat
for state in states do n *= state.agi_rate / 100.0 end
# Force the stat to a value between 1 and 999
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Set Attack Power Modifier
# atk : new Attack Power
#--------------------------------------------------------------------------
def atk_modifier=(atk)
# Set the stat modifier
@atk_change = atk
end
#--------------------------------------------------------------------------
# * Set Attack Power Modifier
# atk : new Attack Power
#--------------------------------------------------------------------------
def def_modifier=(defense)
# Set the stat modifier
@def_change = defense
end
#--------------------------------------------------------------------------
# * Set Spirit Modifier
# atk : new Attack Power
#--------------------------------------------------------------------------
def spi_modifier=(spi)
# Set the stat modifier
@spi_change = spi
end
#--------------------------------------------------------------------------
# * Set Agility Modifier
# atk : new Attack Power
#--------------------------------------------------------------------------
def agi_modifier=(agi)
# Set the stat modifier
@agi_change = agi
end
#--------------------------------------------------------------------------
# * Set Cornered Stats
#--------------------------------------------------------------------------
def cornered_stats(percent_change)
# Set the stat modifiers
cornered_atk(percent_change)
cornered_def(percent_change)
cornered_spi(percent_change)
cornered_agi(percent_change)
end
#--------------------------------------------------------------------------
# * Get Cornered Attack
#--------------------------------------------------------------------------
def cornered_atk(percent_change)
# Calculate index in stat array
atk_formula = (4 * (self.id)) - 4
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
atk_change_default = Cornered_Stats::Enemy_Percent_Change[atk_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
atk_change_default = Cornered_Stats::Actor_Percent_Change[atk_formula]
end
# Calculate the stat change percentage
atk_change_percent = atk_change_default * (percent_change * 100)
# Calculate the stat change
atk_change = (base_atk * atk_change_percent)
# Set the stat change
self.atk_modifier = atk_change
end
#--------------------------------------------------------------------------
# * Get Cornered Defense
#--------------------------------------------------------------------------
def cornered_def(percent_change)
# Calculate index in stat array
def_formula = (4 * (self.id)) - 3
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
def_change_default = Cornered_Stats::Enemy_Percent_Change[def_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
def_change_default = Cornered_Stats::Actor_Percent_Change[def_formula]
end
# Calculate the stat change percentage
def_change_percent = def_change_default * (percent_change * 100)
# Calculate the stat change
def_change = (base_def * def_change_percent)
# Set the stat change
self.def_modifier = def_change
end
#--------------------------------------------------------------------------
# * Get Cornered Spirit
#--------------------------------------------------------------------------
def cornered_spi(percent_change)
# Calculate index in stat array
spi_formula = (4 * (self.id)) - 2
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
spi_change_default = Cornered_Stats::Enemy_Percent_Change[spi_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
spi_change_default = Cornered_Stats::Actor_Percent_Change[spi_formula]
end
# Calculate the stat change percentage
spi_change_percent = spi_change_default * (percent_change * 100)
# Calculate the stat change
spi_change = (base_spi * spi_change_percent)
# Set the stat change
self.spi_modifier = spi_change
end
#--------------------------------------------------------------------------
# * Get Cornered Agility
#--------------------------------------------------------------------------
def cornered_agi(percent_change)
# Calculate index in stat array
agi_formula = (4 * (self.id)) - 1
# If the battler is an enemy
if self.is_a?(Game_Enemy)
# Get the HP percentage at which the change begins
agi_change_default = Cornered_Stats::Enemy_Percent_Change[agi_formula]
# If the battler is an actor
else
# Get the HP percentage at which the change begins
agi_change_default = Cornered_Stats::Actor_Percent_Change[agi_formula]
end
# Calculate the stat change percentage
agi_change_percent = agi_change_default * (percent_change * 100)
# Calculate the stat change
agi_change = (base_agi * agi_change_percent)
# Set the stat change
self.agi_modifier = agi_change
end
end
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
# This class handles enemy characters. It's used within the Game_Troop class
# ($game_troop).
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Get Enemy ID
#--------------------------------------------------------------------------
def id
return @enemy_id
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Battle Action Processing
#--------------------------------------------------------------------------
def process_action
# Return if the battle has been decided
return if judge_win_loss
# Return if a scene change is scheduled
return if $game_temp.next_scene != nil
# Set the next battler to use
set_next_active_battler
# If there is no active battler
if @active_battler == nil
# End the turn
turn_end
return
end
# Determine the active battler's current HP percentage
hp_percent = @active_battler.hp.to_f / @active_battler.base_maxhp.to_f
# Get the active battler's ID
battler_id = @active_battler.id - 1
# If the active battler is an enemy
if @active_battler.is_a?(Game_Enemy)
# Find the battler's stat change activation percentage
enemy_cornered_percent = Cornered_Stats::Enemy_Percent[battler_id]
# If the percentage is not nil and is greater than 0
if enemy_cornered_percent != nil && enemy_cornered_percent.to_s.to_f > 0
# If the battler is currently at or below the activation percentage
if enemy_cornered_percent.to_s.to_f >= hp_percent
# Determine the battler's stat changes
percent_change = (((enemy_cornered_percent.to_s.to_f *
@active_battler.base_maxhp) - @active_battler.hp) /
(enemy_cornered_percent.to_s.to_f * @active_battler.base_maxhp))
# Set the battler's stat changes
@active_battler.cornered_stats(percent_change.to_f)
end
end
# If the battler is an actor
elsif @active_battler.is_a?(Game_Actor)
# Find the battler's stat change activation percentage
actor_cornered_percent = Cornered_Stats::Actor_Percent[battler_id]
# If the percentage is not nil and is greater than 0
if actor_cornered_percent != nil && actor_cornered_percent.to_s.to_f > 0
# If the battler is currently at or below the activation percentage
if actor_cornered_percent.to_s.to_f >= hp_percent
# Determine the battler's stat changes
percent_change = (((actor_cornered_percent.to_s.to_f *
@active_battler.base_maxhp) - @active_battler.hp) /
(actor_cornered_percent.to_s.to_f * @active_battler.base_maxhp))
# Set the battler's stat changes
@active_battler::cornered_stats(percent_change)
end
end
end
# Clear all text from the message window
@message_window.clear
# Wait for five frames
wait(5)
# Force the active battler to flash white
@active_battler.white_flash = true
# If the active battler's action is not being forced
unless @active_battler.action.forcing
# Prepare the active battler's action
@active_battler.action.prepare
end
# If the active battler's action is valid
if @active_battler.action.valid?
# Execute the active battler's action
execute_action
end
# If the active battler's action is not being forced
unless @active_battler.action.forcing
# Clear all text from the message window
@message_window.clear
# Automatically remove states from the active battler
remove_states_auto
# Display the active battler's current states
display_current_state
end
# Force the active battler to stop flashing white
@active_battler.white_flash = false
# Clear all text from the message window
@message_window.clear
end
end
Instructions
(These instructions are taken from the RMXP version. Names in the RMVX version will vary)
Place this script above Main, and below the default scripts. (I realize this is obvious to most, but some people don't get it.)
To change the default percentage of HP at which an enemy will start experiencing stat changes, edit the values in the Enemy_Percent array within the Conrnered_Stats module. Each value corresponds to a specific enemy, with the first being enemy 001 (The default is Ghost), the second being enemy 002 (Basilisk), and so on.
To change the default percentage of HP at which an actor will start experiencing stat changes, edit the values in the Actor_Percent array within
the Cornered_Stats module. This array follows the same rule as the Enemy_Percent array mentioned above.
To modify the maximum percentage that an enemy's stats can change, edit the values in the Enemy_Percent_Change array in the Cornered_Stats module. The order of the values is Strength, Dexterity, Agility, Intelligence, Attack Power, Physical Defense Power, Magic Defense Power, and Evasion Correction. The first row is the first enemy in the database, (Ghost), the second row is the second enemy in the database (Basilisk), and so on.
To modify the maximum percentage that an actor's stats can change, edit the values in the Actor_Percent_Change array in the Cornered_Stats module. The rules are the same as within the Enemy_Percent_Change array mentioned above.
The percentages placed within the Enemy_Percent and Actor_Percent arrays must be in the decimal forma, while those placed within the Enemy_Percent_Change and Actor_Percent_Change arrays must be placed as a percentage, minus the % symbol.
The percentages in the Enemy_Percent_Change and the Actor_Percent_Change arrays may be either negative or positive, while those placed in the Enemy_Percent and Actor_Percent arrays must be positive.
If you do not want an enemy or actor to recive stat changes, then put nil in the proper location in the Enemy_Percent or Actor_Percent arrays.
If you have designated an enemy or actor as unable to recieve stat changes, you must still define their row in their place in the Enemy_Percent_Change or Actor_Percent_Change arrays by placing a 0 in each stat.
The amount that an eney's or an actor's stats will change when this script comes into effect depends upon their remaining HP. The remaining HP is divided by the threshhold, and then is multiplied by the percent that the stat can change.(The threshhold is the amount of HP that corresponds to the percent defined in the Enemy_Percent or Actor_Percent arrays of the Cornered_Stats module.)
Compatibility
This script is incompatible with non-default battle systems, and will need to be completely rewritten for most.
Terms and Conditions
- This script is free to use in any noncommercial project. If you wish to use this script in a commercial (paid) project, please contact Glitchfinder at his website.
- This script may only be hosted at the following domains:
http://www.glitchkey.com
http://www.hbgames.org - If you wish to host this script elsewhere, please contact Glitchfinder.
- If you wish to translate this script, please contact Glitchfinder. He will need the web address that you plan to host the script at, as well as the language this script is being translated to.
- The script header must remain intact at all times.
- Glitchfinder remains the sole owner of this code. He may modify or revoke this license at any time, for any reason.
- Any code derived from code within this script is owned by Glitchfinder, and you must have his permission to publish, host, or distribute his code.
- This license applies to all code derived from the code within this script.
- If you use this script within your project, you must include visible credit to Glitchfinder, within reason.