01-20-2008, 01:00 PM
Break HP & SP Limits 3.0
by El Conductor
Jan 20, 2008
Alright I got several requests for such a thing so I whipped
a Break Limit script. It allows HP and SP to go above 9999
while wearing specified armor. This is like FFX. Also, there
wasn't a default Damage Limit. I've done over million HP in
damage in perfect test conditions. So I made a Damage Limit
that can also be broken by equipping certain weapons.
The actual limits, weapons, and armors can easily be defined
by the user. See script for more details.
New to version 3.0, Actor HP Limits and non-Actor HP limits are separate.
I also redid some of the code that made the script size a few 100 lines
smaller, haha.
by El Conductor
Jan 20, 2008
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Alright I got several requests for such a thing so I whipped
a Break Limit script. It allows HP and SP to go above 9999
while wearing specified armor. This is like FFX. Also, there
wasn't a default Damage Limit. I've done over million HP in
damage in perfect test conditions. So I made a Damage Limit
that can also be broken by equipping certain weapons.
The actual limits, weapons, and armors can easily be defined
by the user. See script for more details.
New to version 3.0, Actor HP Limits and non-Actor HP limits are separate.
I also redid some of the code that made the script size a few 100 lines
smaller, haha.
Code:
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Break HP/SP Limits 3.0 +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# By: R. Johnson aka.(El Conductor) +
# Updated: July/22/08 +
# Version: 3.0 +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#----------------------------------------------------------------------------
# What it Does:
# Actors HP and SP can now go above 9999 when certian armor that breaks
# the limit are equipped. By default damage wasn't limited like HP & SP.
# So I made a Limit that can be broken with certian weapons. I made the
# limits values and which weapons and armors break those limits easy to
# customize in the Module Break_Limits.
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How it Works:
#
# This script defines Default and Broken limit values in Module
# Break_Limits. These values are used in the Game_Battler class's maxhp
# & maxsp methods. Hidden classes RPG::Weapon and RPG::Armor were given
# new boolean attributes as to whether they broke the limit 'true' or
# not 'false'. Various methods in other classes have been altered or
# created to deal with the above and make this script work. I could get
# real in depth about it, but it is not necessary to use this script.
#
# Lengths and settings for limits are stored in Module Break_Limits.
#
# New and altered scripts are:
#
# - Module Break_Limits
# - RPG::Weapon
# - RPG::Armor
# - Scene_Title
# - Game_Actor
# - Game_Battler 1 & 3
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How to Use This Script:
# Just copy it and paste it above Main.
#
# To change the limits and other settings go to Module Break_Limits
# and change the values there.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Comments:
# I hope my script is easy for you to use and modify. Study this script
# to learn the ways of RGSS and join the ranks of those known as 'Scripters'.
#----------------------------------------------------------------------------
#==============================================================================
# Module Break_Limits
#------------------------------------------------------------------------------
# Houses limit values and the arrays of equipment that break the limits.
#==============================================================================
module Break_Limits
# Set values to Constants
# Set HP and SP Limits
DEFAULT_HP_LIMIT = 9999
BROKEN_HP_LIMIT = 999999
BROKEN_ACTOR_HP_LIMIT = 99999
DEFAULT_SP_LIMIT = 9999
BROKEN_SP_LIMIT = 999999
BROKEN_ACTOR_SP_LIMIT = 99999
# Set a limit for damage
DAMAGE_LIMIT = 9999
# Set an array of ID's of weapons you want to break the damage limit
# Example Mithril Sword ID is 4. So we have 4 in the array
BROKEN_WEAPONS = [1, 4, 8, 12, 16, 20, 24, 28, 32]
# Set an array of ID's of armors you want to break the hp limit
BROKEN_ARMORS_HP = [4, 8, 12, 16, 20, 24, 25]
# Set an array of ID's of armors you want to break the sp limit
BROKEN_ARMORS_SP = [11, 12, 23, 24, 28]
end
#==============================================================================
# ** Game_Battler (part 1 and 3)
#------------------------------------------------------------------------------
# Methods that deal with max HP & SP have been adjusted to work with new
# system. Methods attack_effect & skill_effect have been modified to handle
# weapons the don't break the limit.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Get Maximum HP
#--------------------------------------------------------------------------
def maxhp
n = [[base_maxhp + @maxhp_plus, 1].max, Break_Limits::BROKEN_HP_LIMIT].min
for i in @states
n *= $data_states[i].maxhp_rate / 100.0
end
n = [[Integer(n), 1].max, Break_Limits::BROKEN_HP_LIMIT].min
return n
end
#--------------------------------------------------------------------------
# * Get Maximum SP
#--------------------------------------------------------------------------
def maxsp
n = [[base_maxsp + @maxsp_plus, 0].max, Break_Limits::BROKEN_SP_LIMIT].min
for i in @states
n *= $data_states[i].maxsp_rate / 100.0
end
n = [[Integer(n), 0].max, Break_Limits::BROKEN_SP_LIMIT].min
return n
end
#--------------------------------------------------------------------------
# * Set Maximum HP
# maxhp : new maximum HP
#--------------------------------------------------------------------------
def maxhp=(maxhp)
limit = Break_Limits::BROKEN_HP_LIMIT
@maxhp_plus += maxhp - self.maxhp
@maxhp_plus = [[@maxhp_plus, -limit].max, limit].min
@hp = [@hp, self.maxhp].min
end
#--------------------------------------------------------------------------
# * Set Maximum SP
# maxsp : new maximum SP
#--------------------------------------------------------------------------
def maxsp=(maxsp)
limit = Break_Limits::BROKEN_SP_LIMIT
@maxsp_plus += maxsp - self.maxsp
@maxsp_plus = [[@maxsp_plus, -limit].max, limit].min
@sp = [@sp, self.maxsp].min
end
#--------------------------------------------------------------------------
# * Applying Normal Attack Effects
# attacker : battler
#--------------------------------------------------------------------------
def attack_effect(attacker)
# Clear critical flag
self.critical = false
# First hit detection
hit_result = (rand(100) < attacker.hit)
# If hit occurs
if hit_result == true
# Calculate basic damage
atk = [attacker.atk - self.pdef / 2, 0].max
self.damage = atk * (20 + attacker.str) / 20
# Element correction
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Critical correction
if rand(100) < 4 * attacker.dex / self.agi
self.damage *= 2
self.critical = true
end
# Guard correction
if self.guarding?
self.damage /= 2
end
end
# Dispersion
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# Second hit detection
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
# If hit occurs
if hit_result == true
# State Removed by Shock
remove_states_shock
# Only check if attacke is an actor
unless attacker.is_a?(Game_Enemy)
# Perform check if damage is limited only if actors weapon
# doesn't break the limit.
unless attacker.breaks_limit?
# If damage is higher than limit
if self.damage > Break_Limits::DAMAGE_LIMIT
# Set damage equal to limit
self.damage = Break_Limits::DAMAGE_LIMIT
end
end
end
# Substract damage from HP
self.hp -= self.damage
# State change
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
# When missing
else
# Set damage to "Miss"
self.damage = "Miss"
# Clear critical flag
self.critical = false
end
# End Method
return true
end
#--------------------------------------------------------------------------
# * Apply Skill Effects
# user : the one using skills (battler)
# skill : skill
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# Clear critical flag
self.critical = false
# If skill scope is for ally with 1 or more HP, and your own HP = 0,
# or skill scope is for ally with 0, and your own HP = 1 or more
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
# End Method
return false
end
# Clear effective flag
effective = false
# Set effective flag if common ID is effective
effective |= skill.common_event_id > 0
# First hit detection
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
# If hit occurs
if hit_result == true
# Calculate power
power = skill.power + user.atk * skill.atk_f / 100
if power > 0
power -= self.pdef * skill.pdef_f / 200
power -= self.mdef * skill.mdef_f / 200
power = [power, 0].max
end
# Calculate rate
rate = 20
rate += (user.str * skill.str_f / 100)
rate += (user.dex * skill.dex_f / 100)
rate += (user.agi * skill.agi_f / 100)
rate += (user.int * skill.int_f / 100)
# Calculate basic damage
self.damage = power * rate / 20
# Element correction
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Guard correction
if self.guarding?
self.damage /= 2
end
end
# Dispersion
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# Second hit detection
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
end
# If hit occurs
if hit_result == true
# If physical attack has power other than 0
if skill.power != 0 and skill.atk_f > 0
# State Removed by Shock
remove_states_shock
# Set to effective flag
effective = true
end
# Only check if user is an actor
unless user.is_a?(Game_Enemy)
# Perform check if damage is limited only if actors weapon
# doesn't break the limit.
unless user.breaks_limit?
# If damage is higher than limit
if self.damage > Break_Limits::DAMAGE_LIMIT
# Set damage equal to limit
self.damage = Break_Limits::DAMAGE_LIMIT
end
end
end
# Substract damage from HP
last_hp = self.hp
self.hp -= self.damage
effective |= self.hp != last_hp
# State change
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# If power is 0
if skill.power == 0
# Set damage to an empty string
self.damage = ""
# If state is unchanged
unless @state_changed
# Set damage to "Miss"
self.damage = "Miss"
end
end
# If miss occurs
else
# Set damage to "Miss"
self.damage = "Miss"
end
# If not in battle
unless $game_temp.in_battle
# Set damage to nil
self.damage = nil
end
# End Method
return effective
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# New limit attributes have been added that the modified maxhp & maxsp
# methods will use. Other new methods check if any armor equiped breaks any
# limits, and whether the actors weapon breaks the limit.
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :hp_limit # Current HP limit
attr_accessor :sp_limit # Current SP limit
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias limit_game_actor_setup setup
alias limit_game_actor_equip equip
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor_id)
super()
# Set limits to default values stored in Module Break_Limits
@hp_limit = Break_Limits::DEFAULT_HP_LIMIT
@sp_limit = Break_Limits::DEFAULT_SP_LIMIT
setup(actor_id)
end
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def setup(actor_id)
# Original method
limit_game_actor_setup(actor_id)
# New method calls
# Check if initial equipment breaks the limit
check_armor_hp_limit
check_armor_sp_limit
end
#--------------------------------------------------------------------------
# * Get Maximum HP
#--------------------------------------------------------------------------
def maxhp
n = [[base_maxhp + @maxhp_plus, 1].max, @hp_limit].min
for i in @states
n *= $data_states[i].maxhp_rate / 100.0
end
n = [[Integer(n), 1].max, @hp_limit].min
return n
end
#--------------------------------------------------------------------------
# * Get Maximum SP
#--------------------------------------------------------------------------
def maxsp
n = [[base_maxsp + @maxsp_plus, 1].max, @sp_limit].min
for i in @states
n *= $data_states[i].maxsp_rate / 100.0
end
n = [[Integer(n), 1].max, @sp_limit].min
return n
end
#--------------------------------------------------------------------------
# * Change Equipment
#--------------------------------------------------------------------------
def equip(equip_type, id)
# Original method actions
limit_game_actor_equip(equip_type, id)
# New method calls
check_armor_hp_limit
check_armor_sp_limit
end
#--------------------------------------------------------------------------
# * Checks every armor equiped for break HP limit
#--------------------------------------------------------------------------
def check_armor_hp_limit
# Check if any currently equiped armor breaks the limit
# If so, then set limit to the broken value
if @armor1_id != 0 and Break_Limits::BROKEN_ARMORS_HP.include?(@armor1_id)
@hp_limit = Break_Limits::BROKEN_ACTOR_HP_LIMIT
elsif @armor2_id != 0 and Break_Limits::BROKEN_ARMORS_HP.include?(@armor2_id)
@hp_limit = Break_Limits::BROKEN_ACTOR_HP_LIMIT
elsif @armor3_id != 0 and Break_Limits::BROKEN_ARMORS_HP.include?(@armor3_id)
@hp_limit = Break_Limits::BROKEN_ACTOR_HP_LIMIT
elsif @armor4_id != 0 and Break_Limits::BROKEN_ARMORS_HP.include?(@armor4_id)
@hp_limit = Break_Limits::BROKEN_ACTOR_HP_LIMIT
# Otherwise set the actors limit to the default
else
@hp_limit = Break_Limits::DEFAULT_HP_LIMIT
# If current HP is higher than limit, correct it
if @hp > maxhp
@hp = maxhp
end
end
end
#--------------------------------------------------------------------------
# * Checks every armor equiped for break SP limit
#--------------------------------------------------------------------------
def check_armor_sp_limit
# Check if any currently equiped armor breaks the limit
# If so, then set limit to the broken value
if @armor1_id != 0 and Break_Limits::BROKEN_ARMORS_SP.include?(@armor1_id)
@sp_limit = Break_Limits::BROKEN_ACTOR_SP_LIMIT
elsif @armor2_id != 0 and Break_Limits::BROKEN_ARMORS_SP.include?(@armor2_id)
@sp_limit = Break_Limits::BROKEN_ACTOR_SP_LIMIT
elsif @armor3_id != 0 and Break_Limits::BROKEN_ARMORS_SP.include?(@armor3_id)
@sp_limit = Break_Limits::BROKEN_ACTOR_SP_LIMIT
elsif @armor4_id != 0 and Break_Limits::BROKEN_ARMORS_SP.include?(@armor4_id)
@sp_limit = Break_Limits::BROKEN_ACTOR_SP_LIMIT
# Otherwise set the actors limit to the default
else
@sp_limit = Break_Limits::DEFAULT_SP_LIMIT
# If current HP is higher than limit, correct it
if @sp > maxsp
@sp = maxsp
end
end
end
#--------------------------------------------------------------------------
# * Checks if actors current weapon breaks the damage limit and return
# true or false to its caller. Is called from Game_Battler attack_effect.
#--------------------------------------------------------------------------
def breaks_limit?
# Check if actor has a weapon at all
if @weapon_id != 0
return Break_Limits::BROKEN_WEAPONS.include?(@weapon_id) # Return limit_broken
else # If not then,
return false # Return false
end
end
end