State Parameters PLUS v 1.4b
(aka States Options part a)
by Mithran
IntroductionWell, I originally split down Advanced State Probability into four scripts to make it more managable. While working on States Options, I decided to split it even further. This is part a, and it deals with modifying nearly every parameter available.
Features- modify nearly every parameter available through states either by a static increase/decrease, a percentage increase or decrease, or setting it to a specific value:
Parameters this script can currently modify:
- elemental rates
- state probability
- atk, def, spi, agi
- any stat added by another script added in the battler class (see: user defined parameters)
- item, skill, attack, and global action speeds
- maxhp and maxmp
- critical, evasion, and hit rates
- critical damage modifier (requires Damage Limit / Critical Damage Selection script)
Also allows you to:
- add or remove elements from the normal attack set with states
- set a states 'priority' value up to 100
- set elements to be absorbed by state
- lock a battlers hp to a specific value (for boss battle type encounters)
- modify attack damage based on the type of attack used (recommend using Physical/Magical Ambiguity Fix)
- using states to modify user defined parameters (eg., custom stats added by other scripts) are now supported as long as they are defined within the battler class
- modify enemy or random targeting odds
- add, subtract, or set actor skills
*new*How to UseFollow the instructions in the script. This script should be installed in the materials section, above main, above Advanced State Probability, and below KGC_LimitBreak, Skill Functions, and any custom stat scripts, where applicable.
Script» Click to show Spoiler - click again to hide... «
CODE
# State Parameters PLUS
# v 1.4b
# By Mithran at RMVX.net
# Last Update February 28, 2009
=begin
CHANGELOG:
v 1.4b
- Bugfix: Fixed a bug with state learned skills not enabling.
v 1.4
- Added Functionality: Actor Skills. Add, subtract, or set the selected
actor's skills for the duration of the state only.
- Added Change Log
- Fixed case sensitivity on some of the note tags. The only case sensitve note
tag is now <STATE PARAMETERS PLUS>.
v 1.3b
- Bugfix: Fixed a crashing error when using F12 to reset during test play /
battle test.
v 1.3
- Bugfix: Fixed a bug with MP limit on "set to value" max MP states
- Added functionality: Odds. Modify random targeting odds (standard plus,
minus, equals, and rate support). See customization section for some
additional options regarding this feature.
v 1.2b
- Bugfix: Fixed a bug with user defined parameters not multiplying correctly
v 1.2
- Added functionality: modify damage recieved by type. For 'barrier',
'shell' and 'safe' type states.
- Added functionality: modify damage dealt by type. For 'magical boost',
'physical atrophy', type states, etc.
- Tested functionality: User Defined Stats. This is now supported.
Please let me know if you have any problems.
- Added some borders in the instructions sections and slightly reformatted
some sections to make it easier to read.
NOTE: This script now needs to be below Skill Functions on the list,
if you use both.
v 1.1
- Fixed a bug in one of the methods.
- Added Functionality: Lock HP. Lock a battlers HP to a certain value or
range of values. Intended for boss battle type encounters.
(eg., his HP cannot go below 90% until a condition is met, then have an event
remove the state). Damage will still display normally, the target just
cannot go below their minimum. Instant death is allowed, however. See script
for usage instructions.
v 1.0
Inital Release. Modify nearly every parameter through states.
This script allows you to modify nearly all the parameters of a actor or enemy
through the use of states.
Usage:
You must have the following in your notes tag of the state to use the extra
parameters:
<STATE PARAMETERS PLUS>
All caps required. Starts looking for matches here. The script will stop
looking for matches if you type it again:
<STATE PARAMETERS PLUS>
Anything between those two tags will be checked for data.
Setting parameters:
use the following -
/(parameter) (operator) (value)(%)
(parameter) is replaced by the paramater you wish to modify (see below)
(operator) is replaced by +, -, or =
(value) is replaced by the value you are modifying it by/setting it to
(%) indicates rate. If is omitted, you are modifying the values by a static
amount
If the '=' operator is used without '%', the value of the parameter for any user
of the state will be set to exactly (value). If multiple are set, only the state
with the highest priority is recognized.
Allowed parameters:
/attack - sets attack
/defense - sets defense
/spirit - sets spirit
/agility - sets agility
/maxhp - sets maxhp
/maxmp - sets maxmp
/hit - sets hit rate
/eva - sets evasion rate
/cri - sets critical rate
/itemspd - sets item speed modifier
/skillspd - sets skill speed modifier
/attackspd - sets attack speed modifier
/allspd - sets all speed modifier
/odds - sets battle targeting odds *
* Odds are very small numbers by default. To make them into bigger values for better
control, see the customization section.
For Elements and States:
/element (n) resist (operator) (value)(%)
/state (n) resist (operator) (value)(%)
(n) is replaced by the element or state id from the database
(operator) is replaced by +, -, or =
(value) is replaced by the value you are modifying it by/setting it to
(%) indicates rate. If is omitted, you are modifying the values by a static
amount
OR
/element (n) resist = (letter_value)
/state (n) resist = (letter_value)
(letter_value) is replaced by A,B,C,D,E,or F
Letter value assignement preceeds all other methods of calculating the state or
element resistance. If multiple states assign a letter value, only the one
with the highest priority will be counted.
Static plus or minus resistance rates are applied second.
Percent rates are applied last.
Special cases:
================================================================================
/priority = (value)
Replace (value) with a number from 0 to 100.
Sets the state's 'priority' rating to the value specificed. It can go as high
as 100, instead of the default of 10
================================================================================
/absorb element (element_ids)
Replace (element_ids) with the id numbers of from the database of
elements you want to be absorbed by the user. Seperate each with a comma.
Sets the element rate for the specified elements to -100.
Elements that are absorbed are not modified by resistances.
================================================================================
/attack elements (operator) (element_ids)
Replace (element_ids) with the id numbers of from the database of
elements you want to be added to the user's normal attack. Seperate
each with a comma. If the operator is =, only the element set specified
will be used (not recommended). Again, only the highest priority state
is used if multiple have an element set.
If the operator is + or -, it will add or subtract the specified elements.
================================================================================
/critical damage mod (operator) (value)
REQUIRES Damage Limit / Attack Critical Damage Selection v 1.0 or higher
found at www.rpgmakervx.net
This will modify all critical damage for the user. The value is expressed
as hundreths. (/critical damage + 100 would increase the critical damage amount
to 1.0 higher than what it was, from 3.0 to 4.0 by default.
/critical damage + 100% would double the critical damage amount, from 3.0 to 6.0
by default.)
Direct sets are applied first, like everything else, only the highest priority
state lend its value here.
================================================================================
/lock hp (min)-(max)(%)
Locks HP to a certain range.
(min) and (max) are replaced by numbers.
(%) is optional. If specificed, the min/max will be percentages of maxhp.
If not, they will be static HP values.
If multiple states are applied that lock HP, only the highest priority state
will be effective.
================================================================================
/type (damage_type) (kind) (operator) (value)(%)
Modifies damage dealt by type. Recommend Physical/Magical Ambiguity fix
Found on the rpgmakervx.net boards.
Does not modify heals, or attacks that are absorbed.
A single state may modify more than one damage type at a time.
Damage rate may not go below 0% (it will not turn attacks into heals, ever)
(damage_type) is replaced by one of the following -
none, physical, or magical, all
none - sets the modifier for attacks which are neither physical nor magical
physical - sets the modifier for physical attacks and skills
magical - sets the modifier for attacks or skills considered magical
all - sets the global damage modifier
(kind) is replaced by either: damage or resistance
damage - modifier is set for outgoing damage
resistance - modifier is set for incoming damage
(operator) is + or -
(value) is the amount you want to modify, a number
(%) is optional. If present, it indicates to apply the number as a rate to the
current damage. If absent, the damage is applied
Examples:
/type physical resist + 25%
- sets phyiscal resistance 25% higher than the baseline
(physical attacks will do 75% of their normal damage)
/type magical resist + 16
- will block 16 points of magical damage from every attack
/type all damage + 50%
- all damage dealt by the user will be increased by 50%
/type none resist + 50%
- attack types that neither physical nor magical nor physical
will do half normal damage on the user.
/type magical resist - 100
- incoming magic attacks that deal 1 or greater damage will be increased by 100
points of damage.
================================================================================
If you want any specific skill or item to ignore these mods, use the
following note tag in the item or skill:
<ignore type damage mod>
This note tag goes in the item or skill note box and does not need
to be placed within the normal <STATE PARAMATERS PLUS> tags.
================================================================================
/actor skills (operator) (skill_ids)
Temporarily adds or subtracts the skills from the target actor for the duration
of the state. Enemys use action lists rather than having skills, so this will
not have any effect on the actions enemies use. Skills subtracted using this
method will NOT be shown during skill selection.
Replace (skill_ids) with the id numbers of from the database of
elements you want to be added to the user's normal attack. Seperate
each with a comma. If the operator is =, only the skills specified can be used
by the afflicted actor. Again, only the highest priority state is used if
multiple have direct skill set assignment. Using /actor skills = 0 will remove
all skills for the duration of the state.
If the operator is + or -, it will add or subtract the specified skills from
the list.
Example:
/actor skills + 2, 3
Adds double attack and triple attack to the actor afflicted with the state.
/actor skills = 82
The actor will only be able to use 'Newclear'. This will be further modified
by other states that add or subtract skills, but only the highest priority
direct assignement will take place.
================================================================================
Examples:
<STATE PARAMETERS PLUS>
/attack + 5
/agility + 5%
/maxhp - 50
/defense = 50
/absorb element 9, 11
<STATE PARAMETERS PLUS>
Adds five to the user's attack parameter. Adds five percent to the user's
agility parameter. Subtracts 50 hp from the user's maximum hitpoints parameter,
and SETS defense to exactly 50, no matter what the value was before.
Absorbs element 9 (fire) and 11 (thunder)
<STATE PARAMETERS PLUS>
/attack = 50%
/defense = 300%
/maxhp - 50%
/priority = 100
/element 10 resist - 50
<STATE PARAMETERS PLUS>
Sets attack to 50% of max (same as attack - 50%)
Sets defense to 300% of max (same as defense + 200%)
Sets maxhp to 50% of max (same as maxhp = 50%)
Sets priority to 100
Subtracts 50 from element 10 (ice) resist. Depending on what it was before, this
can have varying result. Will have no effect if the user can absorb ice, though.
<STATE PARAMETERS PLUS>
/itemspd = 50%
/skillspd = 50%
/element 10 resist = E
<STATE PARAMETERS PLUS>
Action speed for items and skills are halved. Will only take effect if the state
exists right before the combat for the turn starts.
element 10 (ice) resist rate is set to E (0 - immune)
<STATE PARAMETERS PLUS>
/allspd + 100%
/element 9 resist - 50%
/attack elements = 10
/critical damage mod + 5
<STATE PARAMETERS PLUS>
Action speed is doubled for all actions.
Element resist of 9 (fire) will be 50% lower than normal. In other words,
fire element will do 150% as much damage. Note that if fire is already being
absorbed, it will have no effect on the fire element.
Overrides the user's weapon to element 10 (ice)
All critical hits deal 5% more of the base damage. (3.05 by default)
<STATE PARAMETERS PLUS>
/state 1 resist + 100%
/element 9 resist = 0%
/state 2 resist = 50
/attack elements + 11, 12
/attack elements - 10
/critical damage mod + 5%
<STATE PARAMETERS PLUS>
Doubles whatever the user's base resistance against instant death attacks is.
Does absolutely nothing to Element 9 (fire)
Sets the probability state 2 (poison) being applied to 50%
Adds thunder (11) and water (12) to the user's normal attack elements.
Subtracts element 10 (ice) from the normal attack elements, if present.
All critical hits deal 5% more of the TOTAL damage. (3.15 by default)
User defined parameters -
Add in user defined parameters in the module below. This script must be installed
BELOW the script that modifies the parameter. If the parameter is not present,
nothing will happen. If done correctly, you should see a message indicating
that a user defined stat was found during test play. Only affects parameters
defined in the battler class (most stats are). If you are unsure, or can't
get it to work, ask me.
Install: Place in the materials section above main. Should also be placed
above Advanced State Probability, if you use it. It goes below, and is
compatable with, KGC_Limitbreak and Skill Functions.
Made by Mithran at RMVX.net
Feedback, bug reports, and feature requests by
Hesufo at RMVX.net
Mr.Bubble at RMVX.net
LoneVandal at RMVX.net
Please do not redistribute without asking!
=end
$imported = {} if $imported == nil
$imported['StateParametersPlus'] = true
module Mithran
module StateParametersPlus
#================================== CUSTOMOIZATION =============================
USER_DEFINED_PARAMETERS = ["res", "",]
# Allows the script to modify parameters outside the ones that came with RMVX
# The extra parameter script must be placed BEFORE this one in the list
# Usage: Type in the RGSS2 indicator for the stat you want to be able to modify
# (usually just a 3 letter lower-case name) in the quotes in the brackets
# Add commas to seperate multiple entries
USE_BIG_ODDS = true
# If set to true, odds are multiplied for better random target selection
# If set to false, they remain normal.
BIG_ODDS_MULTI = 10
# The number to mutilply odds by before calculation. By default, odds are
# 1 for enemines and 2, 3, or 4 for actors depending on position
MINIMUM_ODDS = 1
# The minimum odds. Use caution when setting to 0. Odds of 0 will make the user
# untargetable by random / enemy target selection, so don't set this to zero unless you are sure.
#================================ END CUSTOMOIZATION ===========================
module Regexps
SPP_SWITCH = /<STATE PARAMETERS PLUS>/
SPP_PARAMS = /\/([^\d\s+=-]+)\s*([-=+])\s*(\d+)(%)?/i
SPP_ATTACK = /(attack|atk)\s*\z/i
SPP_DEFENSE = /(defense|def)\s*\z/i
SPP_SPIRIT = /(spirit|spi)\s*\z/i
SPP_AGILITY = /(agility|agi)\s*\z/i
SPP_MAXHP = /(maximum[_]?hp|maxhp)\s*\z/i
SPP_MAXMP = /(maximum[_]?mp|maxmp)\s*\z/i
SPP_HIT = /(hit|hit[_]rate)\s*\z/i
SPP_EVA = /(evasion|eva)\s*\z/i
SPP_CRITICAL = /(critical|cri)\s*\z/i
SPP_ITEM_SPEED = /(item[_]?speed|itemspd)\s*\z/i
SPP_SKILL_SPEED = /(skill[_]?speed|skillspd)\s*\z/i
SPP_ATTACK_SPEED = /(attack[_]?spd|atk[_]?spd)\s*\z/i
SPP_ALL_SPEED = /(all[_]?speed|all[_]?spd)\s*\z/i
SPP_PRIORITY = /(priority)\s*\z/i
SPP_ODDS = /(odds)\s*\z/i
SPP_ELEMENT_RESIST= /\/element\s*(\d+)\s*resist\s*([-=+])\s*([-]?\d+|[ABCDEF])(%)?/i
SPP_STATE_RESIST = /\/state\s*(\d+)\s*resist\s*([-=+])\s*(\d+|[ABCDEF])(%)?/i
SPP_ABSORB_ELEMENT = /\/absorb\s*element\s*(\d+(?:\s*,\s*\d+)*)/i
SPP_ATTACK_ELEMENT = /\/attack\s*elements\s*([-=+])\s*(\d+(?:\s*,\s*\d+)*)/i
SPP_CRITICAL_MOD = /\/critical\s*damage\s*mod\s*([-=+])\s*(\d+)(%)?/i
SPP_LOCK_HP = /\/lock\s*hp\s*(\d+)\s?-\s?(\d+)(%)?/i
SPP_DAMAGE_TYPES = /\/type\s(physical|magical|all|none)\s*(damage|resistance|resist|dmg)\s*([-=+])\s*(\d+)(%)?/i
SPP_ACTOR_SKILLS = /\/actor\s*skills\s*([-=+])\s*(\d+(?:\s*,\s*\d+)*)/i
CODEBASE = "
if method_defined?(:<<>>)
print 'User Defined Stat found: <<>>' if $TEST
alias <<>>_SPPalias <<>>
def <<>>
n = <<>>_SPPalias
spp_states = spp_states_all
for state in states
value = state.extra_param_exact['<<>>']
return value unless value < 1
end
for state in states
next if state.extra_param_plus['<<>>'] == nil
n += state.extra_param_plus['<<>>']
end
for state in states
next if state.extra_param_rate['<<>>'] == nil
n *= state.extra_param_rate['<<>>'] / 100
end
n = [[n.to_i, 1].max, parameter_limit].min
return n
end
end"
def self.user_defined_parameters
result = []
USER_DEFINED_PARAMETERS.each { |param|
result.push(param) unless param.empty?
}
return result
end
def self.user_defined_regexps
result = {}
for param in Mithran::StateParametersPlus::Regexps.user_defined_parameters
regexp = /#{param}\s*\z/
result[param] = regexp
end
return result
end
def self.make_user_defined_parameter_codes
$code_data_user_defined_params = []
for param in Mithran::StateParametersPlus::Regexps.user_defined_parameters
code = CODEBASE.clone
code.gsub!("<<>>", param)
$code_data_user_defined_params.push(code)
end
end
end
end
end
Mithran::StateParametersPlus::Regexps.make_user_defined_parameter_codes
class RPG::State
include Mithran::StateParametersPlus::Regexps
attr_accessor (:use_extra_parameters, :element_resist_plus, :element_resist_exact, :element_resist_rate,
:state_resist_plus, :state_resist_exact, :state_resist_rate, :extra_param_plus, :extra_param_exact,
:extra_param_rate, :absorb_elements, :attack_element_set_plus, :attack_element_set_minus,
:attack_element_set_overrule, :critical_mod_plus, :critical_mod_rate, :critical_mod_set, :lock_hp_min_rate,
:lock_hp_max_rate, :lock_hp_min, :lock_hp_max, :type_damage_modifier, :type_resist_modifier,
:actor_skills_overrule, :actor_skills_plus, :actor_skills_minus)
def clear_state_parameters_plus_cache
@use_extra_parameters = false
@element_resist_plus = {}
@element_resist_exact = {}
@element_resist_rate = {}
@state_resist_plus = {}
@state_resist_exact = {}
@state_resist_rate = {}
@extra_param_plus = {
"atk" => 0,
"def" => 0,
"spi" => 0,
"agi" => 0,
"maxhp" => 0,
"maxmp" => 0,
"hit" => 0,
"eva" => 0,
"cri" => 0,
"item_spd" => 0,
"skill_spd" => 0,
"attack_spd" => 0,
"all_spd" => 0,
"odds" => 0,
}
@extra_param_plus.default = 0
@extra_param_exact = {
"atk" => -1,
"def" => -1,
"spi" => -1,
"agi" => -1,
"maxhp" => -1,
"maxmp" => -1,
"hit" => -1,
"eva" => -1,
"cri" => -1,
"item_spd" => -1,
"skill_spd" => -1,
"attack_spd" => -1,
"all_spd" => -1,
"odds" => -1,
}
@extra_param_exact.default = -1
@extra_param_rate = {
"atk" => 100,
"def" => 100,
"spi" => 100,
"agi" => 100,
"maxhp" => 100,
"maxmp" => 100,
"hit" => 100,
"eva" => 100,
"cri" => 100,
"item_spd" => 100,
"skill_spd" => 100,
"attack_spd" => 100,
"all_spd" => 100,
"odds" => 100,
}
@extra_param_rate.default = -1
Mithran::StateParametersPlus::Regexps.user_defined_parameters.each { |param|
@extra_param_rate[param] = 100
@extra_param_exact[param] = -1
@extra_param_plus[param] = 0
}
@absorb_elements = []
@attack_element_set_plus = []
@attack_element_set_minus = []
@attack_element_set_overrule = []
@critical_mod_plus = 0
@critical_mod_rate = 100
@critical_mod_set = -1
@type_damage_modifier = {}
@type_resist_modifier = {}
@actor_skills_overrule = []
@actor_skills_plus = []
@actor_skills_minus = []
end
def make_state_parameters_plus_cache
clear_state_parameters_plus_cache
parsing = false
self.note.split(/[\r\n;]/).each { |line|
if line =~ SPP_SWITCH
@use_extra_parameters = true
parsing = !parsing
next
end
next unless parsing
case line
when SPP_ABSORB_ELEMENT
add = $1.scan(/\d+/)
add.each { |i|
@absorb_elements.push(i.to_i) unless @absorb_elements.include?(i.to_i)
}
when SPP_ATTACK_ELEMENT
operator = $1.clone
modify = $2.scan(/\d+/)
modify.each { |i|
case operator
when '+'
@attack_element_set_plus.push(i.to_i) unless @attack_element_set_plus.include?(i.to_i)
when '-'
@attack_element_set_minus.push(i.to_i) unless @attack_element_set_minus.include?(i.to_i)
when '='
@attack_element_set_overrule.push(i.to_i) unless @attack_element_set_overrule.include?(i.to_i)
end
}
when SPP_CRITICAL_MOD
operator = $1.clone
value = $2.to_i
rate = !$3.nil?
if rate
case operator
when '+'
@critical_mod_rate += value
when '-'
@critical_mod_rate -= value
when '='
@critical_mod_set = value
end
else
case operator
when '+'
@critical_mod_plus += value
when '-'
@critical_mod_plus -= value
when '='
@critical_mod_set = value
end
end
when SPP_LOCK_HP
match = $~.clone
if match[3].nil?
@lock_hp_max = match[2].to_i
@lock_hp_min = match[1].to_i
else
@lock_hp_max_rate = match[2].to_i
@lock_hp_min_rate = match[1].to_i
end
when SPP_DAMAGE_TYPES
match = $~.clone
param = match[1].downcase
kind = match[2].downcase
operator = match[3]
value = match[4].to_i
if !match[5].nil?
param += "_rate"
end
if kind == "resistance" or kind == "resist"
case operator
when "+"
@type_resist_modifier[param] ||= 0
@type_resist_modifier[param] += value
when "-"
@type_resist_modifier[param] ||= 0
@type_resist_modifier[param] -= value
when "="
@type_resist_modifier ||= 0
@type_resist_modifier[param] = value
end
elsif kind == "damage" or kind == "dmg"
case operator
when "+"
@type_damage_modifier[param] ||= 0
@type_damage_modifier[param] += value
when "-"
@type_damage_modifier[param] ||= 0
@type_damage_modifier[param] -= value
when "="
@type_damage_modifier ||= 0
@type_damage_modifier[param] = value
end
end
when SPP_ACTOR_SKILLS
set_SPP_actor_skills($~)
when SPP_ELEMENT_RESIST
set_SPP_element_resist($~)
when SPP_STATE_RESIST
set_SPP_state_resist($~)
when SPP_PARAMS
set_SPP_parameters($~)
end
}
end
def set_SPP_actor_skills(match)
operator = match[1].clone
modify = match[2].scan(/\d+/)
modify.each { |i|
skl = $data_skills[i.to_i]
if i.to_i == 0 && operator == "=" then @attack_element_set_overrule = [nil]; return; end
next if skl.nil?
case operator
when '+'
@actor_skills_plus.push(skl) unless @actor_skills_plus.include?(skl)
when '-'
@actor_skills_minus.push(skl) unless @actor_skills_minus.include?(skl)
when '='
@actor_skills_overrule.push(skl) unless @actor_skills_overrule.include?(skl)
end
}
end
def set_SPP_element_resist(match)
element_id = match[1].to_i
operator = match[2]
value = 0
rate = !match[4].nil?
letter_values = [0, 200, 150, 100, 50, 0, -100]
index = 0
if match[3] =~ /([ABCDEF])/i
case $1
when 'A'
index = 1
when 'B'
index = 2
when 'C'
index = 3
when 'D'
index = 4
when 'E'
index = 5
when 'F'
index = 6
end
else
value = match[3].to_i
end
return if value == 0 and index == 0
case operator
when '+'
@element_resist_plus[element_id] ||= 0 unless rate
@element_resist_rate[element_id] ||= 0 if rate
@element_resist_plus[element_id] += value unless rate
@element_resist_rate[element_id] += value if rate
when '-'
@element_resist_plus[element_id] ||= 0 unless rate
@element_resist_rate[element_id] ||= 0 if rate
@element_resist_plus[element_id] -= value unless rate
@element_resist_rate[element_id] -= value if rate
when '='
if index > 0
@element_resist_exact[element_id] = letter_values[index]
else
@element_resist_exact[element_id] = value unless rate
@element_resist_rate[element_id] = value if rate
end
end
end
def set_SPP_state_resist(match)
state_id = match[1].to_i
operator = match[2]
value = 0
rate = !match[4].nil?
letter_values = [0, 100, 80, 60, 40, 20, 0]
index = 0
if match[3] =~ /([ABCDEF])/i
case $1
when 'A'
index = 1
when 'B'
index = 2
when 'C'
index = 3
when 'D'
index = 4
when 'E'
index = 5
when 'F'
index = 6
end
else
value = match[3].to_i
end
return if value == 0 and index == 0
case operator
when '+'
@state_resist_plus[state_id] ||= 0 unless rate
@state_resist_rate[state_id] ||= 0 if rate
@state_resist_plus[state_id] += value unless rate
@state_resist_rate[state_id] += value if rate
when '-'
@state_resist_plus[state_id] ||= 0 unless rate
@state_resist_rate[state_id] ||= 0 if rate
@state_resist_plus[state_id] -= value unless rate
@state_resist_rate[state_id] -= value if rate
when '='
if index > 0
@state_resist_exact[state_id] = letter_values[index]
else
@state_resist_exact[state_id] = value unless rate
@state_resist_rate[state_id] = value if rate
end
end
end
def set_SPP_parameters(match)
hash_key = ""
operator = match[2]
value = match[3].to_i
rate = !match[4].nil?
case match[1]
when SPP_ATTACK
hash_key = "atk"
when SPP_DEFENSE
hash_key = "def"
when SPP_SPIRIT
hash_key = "spi"
when SPP_AGILITY
hash_key = "agi"
when SPP_MAXHP
hash_key = "maxhp"
when SPP_MAXMP
hash_key = "maxmp"
when SPP_HIT
hash_key = "hit"
when SPP_EVA
hash_key = "eva"
when SPP_CRITICAL
hash_key = "cri"
when SPP_ITEM_SPEED
hash_key = "item_spd"
when SPP_SKILL_SPEED
hash_key = "skill_spd"
when SPP_ATTACK_SPEED
hash_key = "attack_spd"
when SPP_ALL_SPEED
hash_key = "all_spd"
when SPP_ODDS
hash_key = "odds"
when SPP_PRIORITY
if operator == "="
value = [[value, 0].max, 100].min
@priority = value
return
end
else
Mithran::StateParametersPlus::Regexps.user_defined_parameters.each { |p|
hash_key = p if match[1] =~ Mithran::StateParametersPlus::Regexps.user_defined_regexps[p]
}
end
return if hash_key.empty?
case operator
when '+'
if rate
@extra_param_rate[hash_key] += value
else
@extra_param_plus[hash_key] += value
end
when '-'
if rate
@extra_param_rate[hash_key] -= value
else
@extra_param_plus[hash_key] -= value
end
when '='
if rate
@extra_param_rate[hash_key] = value
else
@extra_param_exact[hash_key] = value
end
end
end
end
class Scene_Title < Scene_Base
alias load_database_orig_mith_state_parameters_plus load_database
def load_database
load_database_orig_mith_state_parameters_plus
parse_notes_state_parameters_plus
end
def parse_notes_state_parameters_plus
all_objects = $data_states.compact
for this_object in all_objects
this_object.make_state_parameters_plus_cache
end
($data_skills + $data_items).compact.each { |obj|
obj.check_ignore_damage_mod
}
end
alias load_bt_database_orig_mith_state_parameters_plus load_database
def load_bt_database
load_bt_database_orig_mith_state_parameters_plus
parse_notes_state_parameters_plus
end
end
class RPG::BaseItem
unless method_defined?(:magical?)
def magical?
return true if self.spi_f > 0
return false
end
end
def check_ignore_damage_mod
@ignore_damage_mod = (self.note =~ /<ignore type damage mod>/i)
end
def ignore_damage_mod?
return @ignore_damage_mod == nil ? false : true
end
def ambiguous?
return (!magical? && !physical_attack)
end
def phys_and_mag?
return magical? && physical_attack
end
def physical?
return physical_attack
end
end
class Game_Battler
unless method_defined?(:parameter_limit)
def parameter_limit
return 999
end
end
unless method_defined?(:maxmp_limit)
def maxmp_limit
return 9999
end
end
alias element_set_SPPalias element_set
def element_set
unmodset = element_set_SPPalias
modset = unmodset.clone
spp_states = spp_states_all.clone
for state in spp_states.reverse
modset = state.attack_element_set_overrule unless state.attack_element_set_overrule.empty?
end
for state in spp_states
modset |= state.attack_element_set_plus
end
for state in spp_states
modset -= state.attack_element_set_minus
end
return modset
end
alias make_attack_damage_value_SPPalias make_attack_damage_value
def make_attack_damage_value(attacker)
make_attack_damage_value_SPPalias(attacker)
alter_damage_by_type(attacker)
# print @hp_damage
end
alias make_obj_damage_value_SPPalias make_obj_damage_value
def make_obj_damage_value(user, obj)
make_obj_damage_value_SPPalias(user, obj)
alter_damage_by_type(user, obj)
# print @hp_damage
end
def alter_damage_by_type(user, obj = nil)
if obj == nil
alter_damage_type(user, 'physical')
alter_damage_type(user, 'all')
return
end
return if obj.ignore_damage_mod?
if obj.phys_and_mag?
alter_damage_dual(user)
return
end
if obj.physical_attack
alter_damage_type(user, 'physical')
elsif obj.magical?
alter_damage_type(user, 'magical')
elsif obj.ambiguous?
alter_damage_type(user, 'none')
end
alter_damage_type(user, 'all')
end
def type_resist_rate(type)
result = 100
for state in spp_states_all
n = state.type_resist_modifier[type]
next if n == nil
result *= (100 - n) / 100.0
end
return [result, 0].max
end
def type_resist(type)
result = 0
for state in spp_states_all
n = state.type_resist_modifier[type]
next if n == nil
result += n
end
return result
end
def type_damage(type)
result = 0
for state in spp_states_all
n = state.type_damage_modifier[type]
next if n == nil
result += n
end
return result
end
def type_damage_rate(type)
result = 100
for state in spp_states_all
n = state.type_damage_modifier[type]
next if n == nil
result *= (n + 100) / 100.0
end
return [result, 0].max
end
def alter_damage_dual(user)
hp_dmg_buf = @hp_damage
mp_dmg_buf = @mp_damage
@hp_damage = hp_dmg_buf / 2.0
@mp_damage = mp_dmg_buf / 2.0
alter_damage_type(user, 'physical')
nh = @hp_damage
nm = @mp_damage
@hp_damage = hp_dmg_buf / 2.0
@mp_damage = mp_dmg_buf / 2.0
alter_damage_type(user, 'magical')
@hp_damage += nh
@mp_damage += nm
end
def alter_damage_type(user, type)
hp_dmg = @hp_damage
mp_dmg = @mp_damage
if hp_dmg > 0
hp_dmg -= type_resist(type)
hp_dmg += user.type_damage(type)
hp_dmg *= type_resist_rate(type + "_rate") / 100.0
hp_dmg *= user.type_damage_rate(type + "_rate") / 100.0
hp_dmg = [hp_dmg.to_i, 0].max
end
if mp_dmg > 0
mp_dmg -= type_resist(type)
mp_dmg += user.type_damage(type)
mp_dmg *= type_resist_rate(type + "_rate") / 100.0
mp_dmg *= user.type_damage_rate(type + "_rate") / 100.0
mp_dmg = [mp_dmg.to_i, 0].max
end
@hp_damage = hp_dmg
@mp_damage = mp_dmg
end
#~ mp_dmg -= type_resist('physical')
#~ mp_dmg += user.type_damage('physical')
#~ mp_dmg *= (100 - type_resist_rate('physical_rate')) / 100.0
#~ mp_dmg *= (100 - type_damage_rate('physical_rate')) / 100.0
#~ mp_dmg = [hp_dmg.to_i, 0].max
def critical_damage_mod(user, obj = nil)
base_mod = Mithran::CriticalDamage::CRITICAL_DAMAGE_MOD
for state in user.spp_states_all.reverse
next if state.critical_mod_set < 100
base_mod = state.critical_mod_set / 100.0
end
for state in user.spp_states_all
base_mod += state.critical_mod_plus / 100.0
end
for state in user.spp_states_all
base_mod *= state.critical_mod_rate / 100.0
end
return [base_mod, 1.0].max
end
def spp_states_all
result = []
for state in states
result.push(state) if state.use_extra_parameters
end
return result
end
alias :hpSPPalias :hp
def hp
n = hpSPPalias
@hp = [[[@hp, lock_hp_range[1]].min, lock_hp_range[0]].max, maxhp].min
return @hp
end
def lock_hp_range
hp_min = 0
hp_max = maxhp
for state in spp_states_all
if state.lock_hp_max_rate
hp_min = state.lock_hp_min_rate * maxhp / 100
hp_max = state.lock_hp_max_rate * maxhp / 100
break
elsif state.lock_hp_max
hp_min = state.lock_hp_min
hp_max = state.lock_hp_max
break
end
end
return [hp_min, hp_max]
end
alias hpSPPalias= hp=
def hp=(newhp)
ary = lock_hp_range
hp_min = ary[0]
hp_max = ary[1]
newhp = [[newhp, hp_max].min, hp_min].max
self.hpSPPalias = newhp
end
alias mpSPPalias mp
def mp
n = mpSPPalias
if n > maxmp
@mp = maxmp
end
return @mp
end
alias atk_SPPalias atk
def atk
n = atk_SPPalias
spp_states = spp_states_all.clone
for state in spp_states
value = state.extra_param_exact['atk']
return value unless value < 1 or value > parameter_limit
end
for state in spp_states
n += state.extra_param_plus['atk']
end
for state in spp_states
n *= state.extra_param_rate['atk'] / 100.0
end
n = [[n.to_i, 1].max, parameter_limit].min
return n
end
alias :def_SPPalias :def
def def
n = def_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['def']
return value unless value < 1 or value > parameter_limit
end
for state in spp_states
n += state.extra_param_plus['def']
end
for state in spp_states
n *= state.extra_param_rate['def'] / 100.0
end
n = [[n.to_i, 1].max, parameter_limit].min
return n
end
alias spi_SPPalias spi
def spi
n = spi_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['spi']
return value unless value < 1 or value > parameter_limit
end
for state in spp_states
n += state.extra_param_plus['spi']
end
for state in spp_states
n *= state.extra_param_rate['spi'] / 100.0
end
n = [[n.to_i, 1].max, parameter_limit].min
return n
end
alias agi_SPPalias agi
def agi
n = agi_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['agi']
return value unless value < 1 or value > parameter_limit
end
for state in spp_states
n += state.extra_param_plus['agi']
end
for state in spp_states
n *= state.extra_param_rate['agi'] / 100.0
end
n = [[n.to_i, 1].max, parameter_limit].min
return n
end
alias maxhp_SPPalias maxhp
def maxhp
n = maxhp_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['maxhp']
return value unless value < 1 or value > maxhp_limit
end
for state in spp_states
n += state.extra_param_plus['maxhp']
end
for state in spp_states
n *= state.extra_param_rate['maxhp'] / 100.0
end
n = [[n.to_i, 1].max, maxhp_limit].min
return n
end
alias maxmp_SPPalias maxmp
def maxmp
n = maxmp_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['maxmp']
return value unless value < 1 or value > maxmp_limit
end
for state in spp_states
n += state.extra_param_plus['maxmp']
end
for state in spp_states
n *= state.extra_param_rate['maxmp'] / 100.0
end
n = [[n.to_i, 1].max, maxmp_limit].min
return n
end
$code_data_user_defined_params.each { |code|
eval(code)
}
end
class Game_Actor < Game_Battler
alias odds_SPPalias odds
def odds
n = odds_SPPalias
n *= Mithran::StateParametersPlus::BIG_ODDS_MULTI if Mithran::StateParametersPlus::USE_BIG_ODDS
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['odds']
return value unless value < 1 or value > parameter_limit
end
for state in spp_states
n += state.extra_param_plus['odds']
end
for state in spp_states
n *= state.extra_param_rate['odds'] / 100.0
end
n = [[n.to_i, Mithran::StateParametersPlus::MINIMUM_ODDS].max, parameter_limit].min
return n
end
alias hit_SPPalias hit
def hit
n = hit_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['hit']
return value unless value < 0 or value > 200
end
for state in spp_states
n += state.extra_param_plus['hit']
end
for state in spp_states
n *= state.extra_param_rate['hit'] / 100.0
end
n = [[n.to_i, 0].max, 200].min
return n
end
alias eva_SPPalias eva
def eva
n = eva_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['eva']
return value unless value < 0 or value > 200
end
for state in spp_states
n += state.extra_param_plus['eva']
end
for state in spp_states
n *= state.extra_param_rate['eva'] / 100.0
end
n = [[n.to_i, 0].max, 200].min
return n
end
alias cri_SPPalias cri
def cri
n = cri_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['cri']
return value unless value < 0 or value > 200
end
for state in spp_states
n += state.extra_param_plus['cri']
end
for state in spp_states
n *= state.extra_param_rate['cri'] / 100.0
end
n = [[n.to_i, 1].max, 200].min
return n
end
alias element_rate_SPPalias element_rate
def element_rate(element_id)
n = element_rate_SPPalias(element_id)
spp_states = spp_states_all.clone
for state in spp_states
if state.absorb_elements.include?(element_id)
n = -100
end
end
for state in spp_states.reverse
value = state.element_resist_exact[element_id]
n = value unless value == nil
end
return n if n < 0
n -= element_resist_static(element_id)
n *= element_resist_rate(element_id) / 100.0
n = [n, 0].max.to_i
return n
end
def element_resist_static(element_id)
n = 0
for state in spp_states_all
value = state.element_resist_plus[element_id]
n += value unless value.nil?
end
return n
end
def element_resist_rate(element_id)
n = 100
for state in spp_states_all
value = state.element_resist_rate[element_id]
n = n * (100 - value) / 100.0 unless value.nil?
end
return n.to_i
end
alias state_probability_SPPalias state_probability
def state_probability(state_id)
n = state_probability_SPPalias(state_id)
return 100 if $data_states[state_id].nonresistance
spp_states = spp_states_all.clone
for state in spp_states.reverse
value = state.state_resist_exact[state_id]
n = value unless value == nil
end
n -= state_resist_static(state_id)
n *= state_resist_rate(state_id) / 100.0
n = [n, 0].max.to_i
return n
end
def state_resist_static(state_id)
n = 0
for state in spp_states_all
value = state.state_resist_plus[state_id]
n += value unless value.nil?
end
return n
end
def state_resist_rate(state_id)
n = 100
for state in spp_states_all
value = state.state_resist_rate[state_id]
n = n * (100 - value) / 100.0 unless value.nil?
end
return n.to_i
end
alias element_set_SPPalias element_set
def element_set
unmodset = element_set_SPPalias
modset = unmodset.clone
spp_states = spp_states_all.clone
for state in spp_states.reverse
modset = state.attack_element_set_overrule unless state.attack_element_set_overrule.empty?
end
for state in spp_states
modset |= state.attack_element_set_plus
end
for state in spp_states
modset -= state.attack_element_set_minus
end
# modset.each { |i| print i }
return modset
end
alias skills_SPPalias skills
def skills
unmodset = skills_SPPalias
modset = unmodset.clone
spp_states = spp_states_all.clone
for state in spp_states
unless state.actor_skills_overrule.empty?
modset = state.actor_skills_overrule
modset = [] if state.actor_skills_overrule == [nil]
break
end
end
for state in spp_states
modset |= state.actor_skills_plus
end
for state in spp_states
modset -= state.actor_skills_minus
end
modset.sort! { |a, b| a.id <=> b.id }
return modset
end
def has_skill?(skill)
return true if skills.include?(skill)
end
alias skill_can_use_SPPalias skill_can_use?
def skill_can_use?(skill)
return true if (has_skill?(skill) && super)
return skill_can_use_SPPalias(skill)
end
end
class Game_Enemy < Game_Battler
alias odds_SPPalias odds
def odds
n = odds_SPPalias
n *= Mithran::StateParametersPlus::BIG_ODDS_MULTI if Mithran::StateParametersPlus::USE_BIG_ODDS
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['odds']
return value unless value < 1 or value > parameter_limit
end
for state in spp_states
n += state.extra_param_plus['odds']
end
for state in spp_states
n *= state.extra_param_rate['odds'] / 100.0
end
n = [[n.to_i, Mithran::StateParametersPlus::MINIMUM_ODDS].max, parameter_limit].min
return n
end
alias element_rate_SPPalias element_rate
def element_rate(element_id)
n = element_rate_SPPalias(element_id)
spp_states = spp_states_all.clone
for state in spp_states
if state.absorb_elements.include?(element_id)
n = -100
end
end
for state in spp_states.reverse
value = state.element_resist_exact[element_id]
n = value unless value == nil
end
return n if n < 0
n -= element_resist_static(element_id)
n *= element_resist_rate(element_id) / 100.0
n = [n, 0].max.to_i
return n
end
def element_resist_static(element_id)
n = 0
for state in spp_states_all
value = state.element_resist_plus[element_id]
n += value unless value.nil?
end
return n
end
def element_resist_rate(element_id)
n = 100
for state in spp_states_all
value = state.element_resist_rate[element_id]
n = n * (100 - value) / 100.0 unless value.nil?
end
return n.to_i
end
alias state_probability_SPPalias state_probability
def state_probability(state_id)
n = state_probability_SPPalias(state_id)
return 100 if $data_states[state_id].nonresistance
spp_states = spp_states_all.clone
for state in spp_states.reverse
value = state.state_resist_exact[state_id]
n = value unless value == nil
end
n -= state_resist_static(state_id)
n *= state_resist_rate(state_id) / 100.0
n = [n, 0].max.to_i
return n
end
def state_resist_static(state_id)
n = 0
for state in spp_states_all
value = state.state_resist_plus[state_id]
n += value unless value.nil?
end
return n
end
def state_resist_rate(state_id)
n = 100
for state in spp_states_all
value = state.state_resist_rate[state_id]
n = n * (100 - value) / 100.0 unless value.nil?
end
return n.to_i
end
alias hit_SPPalias hit
def hit
n = hit_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['hit']
return value unless value < 0 or value > 200
end
for state in spp_states
n += state.extra_param_plus['hit']
end
for state in spp_states
n *= state.extra_param_rate['hit'] / 100.0
end
n = [[n.to_i, 0].max, 200].min
return n
end
alias cri_SPPalias cri
def cri
n = cri_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['cri']
return value unless value < 0 or value > 200
end
for state in spp_states
n += state.extra_param_plus['cri']
end
for state in spp_states
n *= state.extra_param_rate['cri'] / 100.0
end
n = [[n.to_i, 1].max, 200].min
return n
end
alias eva_SPPalias eva
def eva
n = eva_SPPalias
spp_states = spp_states_all
for state in spp_states
value = state.extra_param_exact['eva']
return value unless value < 0 or value > 200
end
for state in spp_states
n += state.extra_param_plus['eva']
end
for state in spp_states
n *= state.extra_param_rate['eva'] / 100.0
end
n = [[n.to_i, 0].max, 200].min
return n
end
end
class Game_BattleAction
alias make_speed_SPPalias make_speed
def make_speed
make_speed_SPPalias
if item?
modify_speed_item
elsif skill?
modify_speed_skill
elsif attack?
modify_speed_attack
end
modify_speed_all
end
def modify_speed_item
n = @speed
spp_states = battler.spp_states_all.clone
for state in spp_states
value = state.extra_param_exact['item_spd']
return value unless value < 0
end
for state in spp_states
n += state.extra_param_plus['item_spd']
end
for state in spp_states
n *= state.extra_param_rate['item_spd'] / 100.0
end
n = [[n.to_i, 1].max, 10000].min
@speed = n
end
def modify_speed_skill
n = @speed
spp_states = battler.spp_states_all.clone
for state in spp_states.reverse
value = state.extra_param_exact['skill_spd']
n = value unless value < 0
end
for state in spp_states
n += state.extra_param_plus['skill_spd']
end
for state in spp_states
n *= state.extra_param_rate['skill_spd'] / 100.0
end
n = [[n.to_i, 1].max, 10000].min
@speed = n
end
def modify_speed_attack
n = @speed
spp_states = battler.spp_states_all.clone
for state in spp_states.reverse
value = state.extra_param_exact['attack_spd']
n = value unless value < 0
end
for state in spp_states
n += state.extra_param_plus['attack_spd']
end
for state in spp_states
n *= state.extra_param_rate['attack_spd'] / 100.0
end
n = [[n.to_i, 1].max, 10000].min
@speed = n
end
def modify_speed_all
n = @speed
spp_states = battler.spp_states_all.clone
for state in spp_states.reverse
value = state.extra_param_exact['all_spd']
n = value unless value < 0
end
for state in spp_states
n += state.extra_param_plus['all_spd']
end
for state in spp_states
n *= state.extra_param_rate['all_spd'] / 100.0
end
n = [[n.to_i, 1].max, 10000].min
@speed = n
end
end
FAQq. My stats dont seem to be changing at all when I have the state applied.
a. If its not working at all, it could be a problem with the note tag you are using. Double check for typos. Remember, <STATE PARAMETER PLUS> is required to get the script to see your parameter selections.
q. The script still does not work and/or crashes.
a. Please post or PM me with the error you recieved, which line, which scripts you are using, and which parameters you are trying to set.
q. The game says 'User Defined Stat found: res' when I start up.
a. You probably have Enelvon's resist script installed. The message will only show up in playtest, just to let you know that it is working. User defined values are now supported, so if you have any questions regarding this feature, feel free to ask. If you have trouble with it, you can remove the "res", from the brackets (but leave the brackets in place) let me know if you have any problems.
Credit and Thanks- Mithran
- LostEmpires, Mr.Bubble (bug reporting)
- Hesufo (feature requests)
Author's NotesFeedback is welcome. If you run into a bug, please let me know. If you think I ommited a parameter and you would like it added, you can let me know about it in this thread, or back in my
script development thread. Use in projects is fine, but please do not repost/ redistribute this script on other sites.
This post has been edited by Mithran: Mar 1 2009, 04:34 AM