Base State Turns off of Current Turns of 3 Other States

Hello! I have a complex skill I'm trying to work out. I'm using Lunatic States and Yanfly's State Manager, and believe that there should be a way to do this between the two if it's not available otherwise.

I'm trying to create a skill that will consolidate multiple DoT's into one. That alone is simple (basic conditional branches checking for each combination and adding an equivalent state can do this), but the catch is that I'm trying to make the new DoT state have a duration equal to the remaining turns of the other states.

This would need a way to check turns remaining on multiple states, and add those to the total turns of the new state. I can't find a debug script call to check remaining turns on a state, but I think that this is available in Yanfly's State Manager. The new state could be added first as one turn if necessary, then have its duration increased by the remaining turns of the other states as well (subtracting one after).

Any help, or any pointing in the right direction, would be extremely appreciated!

Buff and State Manager:

Spoiler
#==============================================================================# # ▼ Yanfly Engine Ace - Buff & State Manager v1.07# -- Last Updated: 2012.01.26# -- Level: Normal# -- Requires: n/a# #==============================================================================$imported = {} if $imported.nil?$imported["YEA-Buff&StateManager"] = true#==============================================================================# ▼ Updates# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 2012.01.26 - Bug Fixed: Remaining turns aren't drawn in excess.# 2012.01.23 - Compatibility Update: Doppelganger# 2012.01.11 - Compatibility Update: Field State Effects# 2012.01.09 - Bug Fixed: Remaining turns weren't drawn properly again.# 2012.01.07 - Bug Fixed: Remaining turns weren't drawn properly.# 2011.12.30 - Bug Fixed: Decimals are no longer shown on states turns.# 2011.12.28 - Added <state x turn: +y> for actors, classes, weapons, armours,# enemies, and states.# 2011.12.27 - Started Script and Finished.# #==============================================================================# ▼ Introduction# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script alters some of the basic mechanics revolving behind states,# buffs, and debuffs that aren't adjustable within RPG Maker VX Ace by default# such as being able to affect the turns remaining on a state, buff, or debuff# without affecting anything else or even adjusting how many times a buff (or# debuff) can be applied to an actor.# #==============================================================================# ▼ Instructions# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# To install this script, open up your script editor and copy/paste this script# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.# # -----------------------------------------------------------------------------# Actor Notetags - These notetags go in the actors notebox in the database.# -----------------------------------------------------------------------------# <max buff stat: +x># <max buff stat: -x># Increases or decreases the maximum times that particular stat can be buffed# by x. Note that the max increase here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <max debuff stat: +x># <max debuff stat: -x># Increases or decreases the maximum times that particular stat can be debuffed# by x. Note that the max decrease here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <state x turn: +y># <state x turn: -y># When the battler is affected by state x, additional modifiers are made to the# number of turns remaining for state x by y amount. The modifiers cannot# reduce turns to under 0.# # -----------------------------------------------------------------------------# Class Notetags - These notetags go in the class notebox in the database.# -----------------------------------------------------------------------------# <max buff stat: +x># <max buff stat: -x># Increases or decreases the maximum times that particular stat can be buffed# by x. Note that the max increase here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <max debuff stat: +x># <max debuff stat: -x># Increases or decreases the maximum times that particular stat can be debuffed# by x. Note that the max decrease here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <state x turn: +y># <state x turn: -y># When the battler is affected by state x, additional modifiers are made to the# number of turns remaining for state x by y amount. The modifiers cannot# reduce turns to under 0.# # -----------------------------------------------------------------------------# Skill Notetags - These notetags go in the skill notebox in the database.# -----------------------------------------------------------------------------# <state x turn: +y># <state x turn: -y># If the target is affected by state x, this will alter the turns remaining on# that state by y turns if the state can be removed by turns. If the state goes# under 0 turns, the state will be removed.# # <buff stat turn: +x># <buff stat turn: -x># If the target's stat is buffed, this will alter the turns remaining on that# buff by x turns. If the buff's remaining turns go under 0, the buff will be# removed.# # <debuff stat turn: +x># <debuff stat turn: -x># If the target's stat is debuffed, this will alter the turns remaining on that# debuff by x turns. If the debuff's remaining turns go under 0, the debuff# will be removed.# # -----------------------------------------------------------------------------# Item Notetags - These notetags go in the item notebox in the database.# -----------------------------------------------------------------------------# <state x turn: +y># <state x turn: -y># If the target is affected by state x, this will alter the turns remaining on# that state by y turns if the state can be removed by turns. If the state goes# under 0 turns, the state will be removed.# # <buff stat turn: +x># <buff stat turn: -x># If the target's stat is buffed, this will alter the turns remaining on that# buff by x turns. If the buff's remaining turns go under 0, the buff will be# removed.# # <debuff stat turn: +x># <debuff stat turn: -x># If the target's stat is debuffed, this will alter the turns remaining on that# debuff by x turns. If the debuff's remaining turns go under 0, the debuff# will be removed.# # -----------------------------------------------------------------------------# Weapon Notetags - These notetags go in the weapons notebox in the database.# -----------------------------------------------------------------------------# <max buff stat: +x># <max buff stat: -x># Increases or decreases the maximum times that particular stat can be buffed# by x. Note that the max increase here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <max debuff stat: +x># <max debuff stat: -x># Increases or decreases the maximum times that particular stat can be debuffed# by x. Note that the max decrease here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <state x turn: +y># <state x turn: -y># When the battler is affected by state x, additional modifiers are made to the# number of turns remaining for state x by y amount. The modifiers cannot# reduce turns to under 0.# # -----------------------------------------------------------------------------# Armour Notetags - These notetags go in the armour notebox in the database.# -----------------------------------------------------------------------------# <max buff stat: +x># <max buff stat: -x># Increases or decreases the maximum times that particular stat can be buffed# by x. Note that the max increase here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <max debuff stat: +x># <max debuff stat: -x># Increases or decreases the maximum times that particular stat can be debuffed# by x. Note that the max decrease here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <state x turn: +y># <state x turn: -y># When the battler is affected by state x, additional modifiers are made to the# number of turns remaining for state x by y amount. The modifiers cannot# reduce turns to under 0.# # -----------------------------------------------------------------------------# Enemy Notetags - These notetags go in the enemies notebox in the database.# -----------------------------------------------------------------------------# <max buff stat: +x># <max buff stat: -x># Increases or decreases the maximum times that particular stat can be buffed# by x. Note that the max increase here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <max debuff stat: +x># <max debuff stat: -x># Increases or decreases the maximum times that particular stat can be debuffed# by x. Note that the max decrease here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <state x turn: +y># <state x turn: -y># When the battler is affected by state x, additional modifiers are made to the# number of turns remaining for state x by y amount. The modifiers cannot# reduce turns to under 0.# # -----------------------------------------------------------------------------# State Notetags - These notetags go in the states notebox in the database.# -----------------------------------------------------------------------------# <max buff stat: +x># <max buff stat: -x># Increases or decreases the maximum times that particular stat can be buffed# by x. Note that the max increase here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <max debuff stat: +x># <max debuff stat: -x># Increases or decreases the maximum times that particular stat can be debuffed# by x. Note that the max decrease here is still limited by the module constant# MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",# "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.# # <reapply ignore># If this state is cast on a battler with the state already applied, turns# remaining will not be reset nor will turns be added on.# # <reapply reset># If this state is cast on a battler with the state already applied, the turns# will be reset to the default amount of turns the state normally starts with.# # <reapply total># If this state is cast on a battler with the state already applied, the turns# will be added on to the current amount of turns remaining giving the battler# a total of the remaining turns with the default turns for the state.# # <state x turn: +y># <state x turn: -y># When the battler is affected by state x, additional modifiers are made to the# number of turns remaining for state x by y amount. The modifiers cannot# reduce turns to under 0.# #==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.# #==============================================================================module YEA module BUFF_STATE_MANAGER #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Draw Remaining Turns - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # This setting will cause the game to show the number of turns remaining # for a state in battle (if the state will remove itself through turns). # Adjust the settings below to change the font size and the y coordinate # adjustment to where the turns remaining appear if you so desire. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- SHOW_REMAINING_TURNS = true # Show the turns remaining? TURNS_REMAINING_SIZE = 18 # Font size used for turns remaining. TURNS_REMAINING_Y = -4 # Adjusts location of the text. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Buff Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # These settings adjust how buffs play out in your game and the way they # modify a battler's stats such as the maximum times a stat can be buffed # and the buff boost formula. Note that these maximums apply to both buffs # and debuffs. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- DEFAULT_BUFF_LIMIT = 2 # Normal times you can buff a stat. Default: 2 MAXIMUM_BUFF_LIMIT = 2 # Maximum times you can buff a stat. Default: 2 # This is the formula used to apply the rate used for buffs and debuffs. BUFF_BOOST_FORMULA = "buff_level(param_id) * 0.25 + 1.0" #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Reapplying State Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # These settings adjust how the rules apply to states when they are # reapplied onto an actor with the state already intact. If you wish to # have specific states use different rules, use notetags to have them # adjust turns differently. # 0 - Ignored. Default VX setting. # 1 - Turns reset back to existing turns. Default VX Ace Setting. # 2 - Default turns added onto existing turns. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- REAPPLY_STATE_RULES = 1 end # BUFF_STATE_MANAGERend # YEA#==============================================================================# ▼ Editting anything past this point may potentially result in causing# computer damage, incontinence, explosion of user's head, coma, death, and/or# halitosis so edit at your own risk.#==============================================================================module YEA module REGEXP module BASEITEM MAX_BUFF = /<(?:MAX_BUFF|max buff)[ ](.*):[ ]([\+\-]\d+)>/i MAX_DEBUFF = /<(?:MAX_DEBUFF|max debuff)[ ](.*):[ ]([\+\-]\d+)>/i CHANGE_STATE_TURN = /<(?:state)[ ](\d+)[ ](?:TURN|turns):[ ]([\+\-]\d+)>/i STATE_REAPPLY_IGNORE = /<(?:REAPPLY_IGNORE|reapply ignore)>/i STATE_REAPPLY_RESET = /<(?:REAPPLY_RESET|reapply reset)>/i STATE_REAPPLY_TOTAL = /<(?:REAPPLY_TOTAL|reapply total)>/i end # BASEITEM module USABLEITEM CHANGE_STATE_TURN = /<(?:state)[ ](\d+)[ ](?:TURN|turns):[ ]([\+\-]\d+)>/i CHANGE_BUFF_TURN = /<(?:buff)[ ](.*)[ ](?:TURN|turns):[ ]([\+\-]\d+)>/i CHANGE_DEBUFF_TURN = /<(?:debuff)[ ](.*)[ ](?:TURN|turns):[ ]([\+\-]\d+)>/i end # USABLEITEM end # REGEXPend # YEA#==============================================================================# ■ DataManager#==============================================================================module DataManager #-------------------------------------------------------------------------- # alias method: load_database #-------------------------------------------------------------------------- class <<self; alias load_database_bsm load_database; end def self.load_database load_database_bsm load_notetags_bsm end #-------------------------------------------------------------------------- # new method: load_notetags_bsm #-------------------------------------------------------------------------- def self.load_notetags_bsm groups = [$data_actors, $data_classes, $data_weapons, $data_armors, $data_enemies, $data_states, $data_skills, $data_items] for group in groups for obj in group next if obj.nil? obj.load_notetags_bsm end end end end # DataManager#==============================================================================# ■ RPG::BaseItem#==============================================================================class RPG::BaseItem #-------------------------------------------------------------------------- # public instance variables #-------------------------------------------------------------------------- attr_accessor :max_buff attr_accessor :max_debuff attr_accessor :change_state_turns attr_accessor :state_reapply_rules #-------------------------------------------------------------------------- # common cache: load_notetags_bsm #-------------------------------------------------------------------------- def load_notetags_bsm @change_state_turns = {} @max_buff = { 0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0 } @max_debuff = { 0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0 } if self.is_a?(RPG::State) @state_reapply_rules = YEA::BUFF_STATE_MANAGER::REAPPLY_STATE_RULES end #--- self.note.split(/[\r\n]+/).each { |line| case line #--- when YEA::REGEXP::BASEITEM::MAX_BUFF case $1.upcase when "MAXHP", "MHP", "HP" @max_buff[0] = $2.to_i when "MAXMP", "MMP", "MP", "MAXSP", "SP", "MSP" @max_buff[1] = $2.to_i when "ATK" @max_buff[2] = $2.to_i when "DEF" @max_buff[3] = $2.to_i when "MAT", "INT", "SPI" @max_buff[4] = $2.to_i when "MDF", "RES" @max_buff[5] = $2.to_i when "AGI" @max_buff[6] = $2.to_i when "LUK" @max_buff[7] = $2.to_i when "ALL" for i in 0...8; @max_buff = $2.to_i; end end #--- when YEA::REGEXP::BASEITEM::MAX_DEBUFF case $1.upcase when "MAXHP", "MHP", "HP" @max_debuff[0] = $2.to_i when "MAXMP", "MMP", "MP", "MAXSP", "SP", "MSP" @max_debuff[1] = $2.to_i when "ATK" @max_debuff[2] = $2.to_i when "DEF" @max_debuff[3] = $2.to_i when "MAT", "INT", "SPI" @max_debuff[4] = $2.to_i when "MDF", "RES" @max_debuff[5] = $2.to_i when "AGI" @max_debuff[6] = $2.to_i when "LUK" @max_debuff[7] = $2.to_i when "ALL" for i in 0...8; @max_debuff = $2.to_i; end end #--- when YEA::REGEXP::BASEITEM::CHANGE_STATE_TURN @change_state_turns[$1.to_i] = $2.to_i #--- when YEA::REGEXP::BASEITEM::STATE_REAPPLY_IGNORE next unless self.is_a?(RPG::State) @state_reapply_rules = 0 when YEA::REGEXP::BASEITEM::STATE_REAPPLY_RESET next unless self.is_a?(RPG::State) @state_reapply_rules = 1 when YEA::REGEXP::BASEITEM::STATE_REAPPLY_TOTAL next unless self.is_a?(RPG::State) @state_reapply_rules = 2 #--- end } # self.note.split #--- end end # RPG::BaseItem#==============================================================================# ■ RPG::UsableItem#==============================================================================class RPG::UsableItem < RPG::BaseItem #-------------------------------------------------------------------------- # public instance variables #-------------------------------------------------------------------------- attr_accessor :change_state_turns attr_accessor :change_buff_turns attr_accessor :change_debuff_turns #-------------------------------------------------------------------------- # common cache: load_notetags_bsm #-------------------------------------------------------------------------- def load_notetags_bsm @change_state_turns = {} @change_buff_turns = {} @change_debuff_turns = {} #--- self.note.split(/[\r\n]+/).each { |line| case line #--- when YEA::REGEXP::USABLEITEM::CHANGE_STATE_TURN @change_state_turns[$1.to_i] = $2.to_i when YEA::REGEXP::USABLEITEM::CHANGE_BUFF_TURN case $1.upcase when "MAXHP", "MHP", "HP" @change_buff_turns[0] = $2.to_i when "MAXMP", "MMP", "MP", "MAXSP", "SP", "MSP" @change_buff_turns[1] = $2.to_i when "ATK" @change_buff_turns[2] = $2.to_i when "DEF" @change_buff_turns[3] = $2.to_i when "MAT", "INT", "SPI" @change_buff_turns[4] = $2.to_i when "MDF", "RES" @change_buff_turns[5] = $2.to_i when "AGI" @change_buff_turns[6] = $2.to_i when "LUK" @change_buff_turns[7] = $2.to_i when "ALL" for i in 0...8; @change_buff_turns = $2.to_i; end end when YEA::REGEXP::USABLEITEM::CHANGE_DEBUFF_TURN case $1.upcase when "MAXHP", "MHP", "HP" @change_debuff_turns[0] = $2.to_i when "MAXMP", "MMP", "MP", "MAXSP", "SP", "MSP" @change_debuff_turns[1] = $2.to_i when "ATK" @change_debuff_turns[2] = $2.to_i when "DEF" @change_debuff_turns[3] = $2.to_i when "MAT", "INT", "SPI" @change_debuff_turns[4] = $2.to_i when "MDF", "RES" @change_debuff_turns[5] = $2.to_i when "AGI" @change_debuff_turns[6] = $2.to_i when "LUK" @change_debuff_turns[7] = $2.to_i when "ALL" for i in 0...8; @change_debuff_turns = $2.to_i; end end end } # self.note.split #--- end end # class RPG::UsableItem#==============================================================================# ■ Game_BattlerBase#==============================================================================class Game_BattlerBase #-------------------------------------------------------------------------- # overwrite method: param_buff_rate #-------------------------------------------------------------------------- def param_buff_rate(param_id) return eval(YEA::BUFF_STATE_MANAGER::BUFF_BOOST_FORMULA) end #-------------------------------------------------------------------------- # new method: max_buff_limit #-------------------------------------------------------------------------- def max_buff_limit(param_id) n = YEA::BUFF_STATE_MANAGER:😀EFAULT_BUFF_LIMIT if actor? n += self.actor.max_buff[param_id] n += self.class.max_buff[param_id] for equip in equips next if equip.nil? n += equip.max_buff[param_id] end else n += self.enemy.max_buff[param_id] if $imported["YEA-Doppelganger"] && !self.class.nil? n += self.class.max_buff[param_id] end end for state in states next if state.nil? n += state.max_buff[param_id] end return [[n.to_i, 0].max, YEA::BUFF_STATE_MANAGER::MAXIMUM_BUFF_LIMIT].min end #-------------------------------------------------------------------------- # new method: max_debuff_limit #-------------------------------------------------------------------------- def max_debuff_limit(param_id) n = YEA::BUFF_STATE_MANAGER:😀EFAULT_BUFF_LIMIT if actor? n += self.actor.max_debuff[param_id] n += self.class.max_debuff[param_id] for equip in equips next if equip.nil? n += equip.max_debuff[param_id] end else n += self.enemy.max_debuff[param_id] if $imported["YEA-Doppelganger"] && !self.class.nil? n += self.class.max_debuff[param_id] end end for state in states next if state.nil? n += state.max_debuff[param_id] end return [[n.to_i, 0].max, YEA::BUFF_STATE_MANAGER::MAXIMUM_BUFF_LIMIT].min end #-------------------------------------------------------------------------- # overwrite method: buff_icon_index #-------------------------------------------------------------------------- def buff_icon_index(buff_level, param_id) if buff_level > 0 return ICON_BUFF_START + ([buff_level - 1, 1].min) * 8 + param_id elsif buff_level < 0 return ICON_DEBUFF_START + ([-buff_level - 1, -1].max) * 8 + param_id else return 0 end end #-------------------------------------------------------------------------- # new method: buff_turns #-------------------------------------------------------------------------- def buff_turns(param_id) return @buff_turns.include?(param_id) ? @buff_turns[param_id] : 0 end #-------------------------------------------------------------------------- # new method: buff_level #-------------------------------------------------------------------------- def buff_level(param_id) return 0 if @buffs[param_id].nil? buff_maximum = max_buff_limit(param_id) debuff_maximum = max_debuff_limit(param_id) return [[@buffs[param_id], buff_maximum].min, -debuff_maximum].max end #-------------------------------------------------------------------------- # new method: buff_change_turns #-------------------------------------------------------------------------- def buff_change_turns(param_id, value) @buff_turns[param_id] = 0 if @buff_turns[param_id].nil? @buff_turns[param_id] = [value, 0].max end #-------------------------------------------------------------------------- # new method: state_turns #-------------------------------------------------------------------------- def state_turns(state_id) state_id = state_id.id if state_id.is_a?(RPG::State) return @state_turns.include?(state_id) ? @state_turns[state_id] : 0 end #-------------------------------------------------------------------------- # new method: state_steps #-------------------------------------------------------------------------- def state_steps(state_id) state_id = state_id.id if state_id.is_a?(RPG::State) return @state_steps.include?(state_id) ? @state_steps[state_id] : 0 end #-------------------------------------------------------------------------- # new method: state_change_turns #-------------------------------------------------------------------------- def state_change_turns(state_id, value) state_id = state_id.id if state_id.is_a?(RPG::State) @state_turns[state_id] = 0 if @state_turns[state_id].nil? @state_turns[state_id] = [value, 0].max end #-------------------------------------------------------------------------- # new method: state_turn_mod #-------------------------------------------------------------------------- def state_turn_mod(state_id) return 0 if $data_states[state_id].nil? state = $data_states[state_id] n = state.min_turns + rand(1 + [state.max_turns - state.min_turns, 0].max) if actor? if self.actor.change_state_turns.include?(state_id) n += self.actor.change_state_turns[state_id] end if self.class.change_state_turns.include?(state_id) n += self.class.change_state_turns[state_id] end for equip in equips next if equip.nil? next unless equip.change_state_turns.include?(state_id) n += equip.change_state_turns[state_id] end else if self.enemy.change_state_turns.include?(state_id) n += self.enemy.change_state_turns[state_id] end if $imported["YEA-Doppelganger"] && !self.class.nil? if self.class.change_state_turns.include?(state_id) n += self.class.change_state_turns[state_id] end end end for state in states next if state.nil? next unless state.change_state_turns.include?(state_id) n += state.change_state_turns[state_id] end return [n, 0].max end end # Game_BattlerBase#==============================================================================# ■ Game_Battler#==============================================================================class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # overwrite method: buff_max? #-------------------------------------------------------------------------- def buff_max?(param_id) return @buffs[param_id] == max_buff_limit(param_id) end #-------------------------------------------------------------------------- # overwrite method: debuff_max? #-------------------------------------------------------------------------- def debuff_max?(param_id) return @buffs[param_id] == -max_debuff_limit(param_id) end #-------------------------------------------------------------------------- # overwrite method: add_state #-------------------------------------------------------------------------- def add_state(state_id) return if $data_states[state_id].nil? state_rules = $data_states[state_id].state_reapply_rules return if state_rules == 0 && state?(state_id) if state_addable?(state_id) add_new_state(state_id) unless state?(state_id) reset_state_counts(state_id) if state_rules == 0 reset_state_counts(state_id) if state_rules == 1 total_state_counts(state_id) if state_rules == 2 @result.added_states.push(state_id).uniq! end end #-------------------------------------------------------------------------- # overwrite method: state_removed? #-------------------------------------------------------------------------- def state_removed?(state_id) return false end #-------------------------------------------------------------------------- # overwrite method: reset_state_counts #-------------------------------------------------------------------------- def reset_state_counts(state_id) state = $data_states[state_id] @state_turns[state_id] = state_turn_mod(state_id) @state_steps[state_id] = state.steps_to_remove end #-------------------------------------------------------------------------- # new method: total_state_counts #-------------------------------------------------------------------------- def total_state_counts(state_id) state = $data_states[state_id] value = state_turn_mod(state_id) state_change_turns(state_id, value + state_turns(state_id)) end #-------------------------------------------------------------------------- # alias method: item_user_effect #-------------------------------------------------------------------------- alias game_battler_item_user_effect_bsm item_user_effect def item_user_effect(user, item) game_battler_item_user_effect_bsm(user, item) apply_state_turn_changes(user, item) apply_buff_turn_changes(user, item) apply_debuff_turn_changes(user, item) end #-------------------------------------------------------------------------- # new method: apply_state_turn_changes #-------------------------------------------------------------------------- def apply_state_turn_changes(user, item) return if item.nil? return unless $game_party.in_battle for key in item.change_state_turns state_id = key[0] next if field_state?(state_id) next unless state?(state_id) next unless $data_states[state_id].auto_removal_timing > 0 state_change_turns(state_id, key[1] + state_turns(state_id)) remove_state(state_id) if state_turns(state_id) <= 0 @result.success = true end end #-------------------------------------------------------------------------- # new method: field_state? #-------------------------------------------------------------------------- def field_state?(state_id) return false unless $imported["YEA-FieldStateEffects"] return false unless $game_party.in_battle return false unless SceneManager.scene_is?(Scene_Battle) return BattleManager.field_state?(state_id) end #-------------------------------------------------------------------------- # new method: apply_buff_turn_changes #-------------------------------------------------------------------------- def apply_buff_turn_changes(user, item) return if item.nil? return unless $game_party.in_battle for key in item.change_buff_turns param_id = key[0] next unless buff?(param_id) buff_change_turns(param_id, key[1] + buff_turns(param_id)) remove_buff(param_id) if buff_turns(param_id) < 0 @result.success = true end end #-------------------------------------------------------------------------- # new method: apply_debuff_turn_changes #-------------------------------------------------------------------------- def apply_debuff_turn_changes(user, item) return if item.nil? return unless $game_party.in_battle for key in item.change_debuff_turns param_id = key[0] next unless debuff?(param_id) buff_change_turns(param_id, key[1] + buff_turns(param_id)) remove_buff(param_id) if buff_turns(param_id) < 0 @result.success = true end end end # Game_Battler#==============================================================================# ■ Window_Base#==============================================================================class Window_Base < Window #-------------------------------------------------------------------------- # alias method: draw_actor_icons #-------------------------------------------------------------------------- alias window_base_draw_actor_icons_bsm draw_actor_icons def draw_actor_icons(actor, dx, dy, dw = 96) window_base_draw_actor_icons_bsm(actor, dx, dy, dw) draw_actor_icon_turns(actor, dx, dy, dw) end #-------------------------------------------------------------------------- # new method: draw_actor_icon_turns #-------------------------------------------------------------------------- def draw_actor_icon_turns(actor, dx, dy, dw) return unless YEA::BUFF_STATE_MANAGER::SHOW_REMAINING_TURNS return unless SceneManager.scene_is?(Scene_Battle) reset_font_settings contents.font.out_color.alpha = 255 contents.font.bold = true contents.font.size = YEA::BUFF_STATE_MANAGER::TURNS_REMAINING_SIZE bx = dx dy += YEA::BUFF_STATE_MANAGER::TURNS_REMAINING_Y #--- for state in actor.states break if dx + 24 >= dw + bx next if state.icon_index <= 0 turns = actor.state_turns(state.id).to_i if $imported["YEA-FieldStateEffects"] && BattleManager.field_state?(state.id) turns = BattleManager.field_state_turns(state.id) end if state.auto_removal_timing > 0 && turns < 100 draw_text(dx, dy, 24, line_height, turns, 2) end dx += 24 end #--- for i in 0...8 break if dx + 24 >= dw + bx next if actor.buff_icon_index(actor.buff_level(i), i) == 0 turns = actor.buff_turns(i).to_i draw_text(dx, dy, 24, line_height, turns, 2) if turns < 100 dx += 24 end #--- contents.font.out_color = Font.default_out_color reset_font_settings end end # Window_Base#==============================================================================# # ▼ End of File# #==============================================================================

Lunatic States:

Spoiler
Code:
#==================================================================# # ▼ Yanfly Engine Ace - Lunatic States v1.02# -- Last Updated: 2012.01.30# -- Level: Lunatic# -- Requires: n/a# #==============================================================================$imported = {} if $imported.nil?$imported["YEA-LunaticStates"] = true#==============================================================================# ▼ Updates# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 2012.01.30 - Compatibility Update: Ace Battle Engine# 2011.12.19 - Fixed Death State stacking error.# 2011.12.15 - Started Script and Finished.# #==============================================================================# ▼ Introduction# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# Lunatic mode effects have always been a core part of Yanfly Engine scripts.# They exist to provide more effects for those who want more power and control# for their items, skills, status effects, etc., but the users must be able to# add them in themselves.# # This script provides the base setup for state lunatic effects. These effects# will occur under certain conditions, which can include when a state is# applied, erased, leaves naturally, before taking damage, after taking damage,# at the start of a turn, while an action finishes, and at the end of a turn.# #==============================================================================# ▼ Instructions# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# To install this script, open up your script editor and copy/paste this script# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.# #==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.# #==============================================================================class Game_BattlerBase    #--------------------------------------------------------------------------  # ● Welcome to Lunatic Mode  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  # Lunatic States allow allow states to trigger various scripted functions  # throughout certain set periods of times or when certain conditions  # trigger. These effects can occur when a state is applied, when a state is  # erased, when a state leaves naturally, before damage is taken, after  # damage is taken, at the beginning of a turn, while the turn is occuring,  # and at the closing of a turn. These effects are separated by these eight  # different notetags.  #   #     <apply effect: string>     - Occurs when state is applied.  #     <erase effect: string>     - Occurs when state is removed.  #     <leave effect: string>     - Occurs when state timer hits 0.  #     <react effect: string>     - Occurs before taking damage.  #     <shock effect: string>     - Occurs after taking damage.  #     <begin effect: string>     - Occurs at the start of each turn.  #     <while effect: string>     - Occurs after performing an action.  #     <close effect: string>     - Occurs at the end of a turn.  #   # If multiple tags of the same type are used in the same skill/item's  # notebox, then the effects will occur in that order. Replace "string" in  # the tags with the appropriate flag for the method below to search for.  # Note that unlike the previous versions, these are all upcase.  #   # Should you choose to use multiple lunatic effects for a single state, you  # may use these notetags in place of the ones shown above.  #   #     <apply effect>      <erase effect>      <leave effect>  #      string              string              string  #      string              string              string  #     </apply effect>     </erase effect>     </leave effect>  #   #                <react effect>      <shock effect>  #                 string              string  #                 string              string  #                </react effect>     </shock effect>  #   #     <begin effect>      <while effect>      <close effect>  #      string              string              string  #      string              string              string  #     </begin effect>     </while effect>     </close effect>  #   # All of the string information in between those two notetags will be  # stored the same way as the notetags shown before those. There is no  # difference between using either.  #--------------------------------------------------------------------------  def lunatic_state_effect(type, state, user)    return unless SceneManager.scene_is?(Scene_Battle)    return if state.nil?    case type    when :apply; effects = state.apply_effects    when :erase; effects = state.erase_effects    when :leave; effects = state.leave_effects    when :react; effects = state.react_effects    when :shock; effects = state.shock_effects    when :begin; effects = state.begin_effects    when :while; effects = state.while_effects    when :close; effects = state.close_effects    else; return    end    log_window = SceneManager.scene.log_window    state_origin = state_origin?(state.id)    for effect in effects      case effect.upcase      #----------------------------------------------------------------------      # Common Effect: Apply      # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      # This is a common effect that runs whenever a state is refreshly added      # to the battler's state pool. There is no need to modify this unless      # you see fit.      #----------------------------------------------------------------------      when /COMMON APPLY/i        # No common apply effects added.              #----------------------------------------------------------------------      # Common Effect: Erase      # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      # This is a common effect that runs whenever a state is removed from      # the battler's state pool. There is no need to modify this unless you      # see fit.      #----------------------------------------------------------------------      when /COMMON ERASE/i        # No common erase effects added.              #----------------------------------------------------------------------      # Common Effect: Leave      # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      # This is a common effect that runs whenever a state's turns reach 0      # and leaves the battler's state pool. There is no need to modify this      # unless you see fit.      #----------------------------------------------------------------------      when /COMMON LEAVE/i        # No common leave effects added.              #----------------------------------------------------------------------      # Common Effect: React      # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      # This is a common effect that runs right before the battler is about      # to take damage. There is no need to modify this unless you see fit.      #----------------------------------------------------------------------      when /COMMON REACT/i        # No common react effects added.              #----------------------------------------------------------------------      # Common Effect: Shock      # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      # This is a common effect that runs right after the battler has taken      # damage. There is no need to modify this unless you see fit.      #----------------------------------------------------------------------      when /COMMON SHOCK/i        # No common shock effects added.              #----------------------------------------------------------------------      # Common Effect: Begin      # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      # This is a common effect that runs at the start of the party's turn.       # There is no need to modify this unless you see fit.      #----------------------------------------------------------------------      when /COMMON BEGIN/i        # No common begin effects added.              #----------------------------------------------------------------------      # Common Effect: While      # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      # This is a common effect that runs at the end of the battler's turn.       # There is no need to modify this unless you see fit.      #----------------------------------------------------------------------      when /COMMON WHILE/i        # No common while effects added.              #----------------------------------------------------------------------      # Common Effect: Close      # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      # This is a common effect that runs at the end of the party's turn.       # There is no need to modify this unless you see fit.      #----------------------------------------------------------------------      when /COMMON CLOSE/i        # No common close effects added.              #----------------------------------------------------------------------      # Stop editting past this point.      #----------------------------------------------------------------------      else        lunatic_state_extension(effect, state, user, state_origin, log_window)      end    end # for effect in effects  end # lunatic_object_effect  end # Game_BattlerBase#==============================================================================# ▼ Editting anything past this point may potentially result in causing# computer damage, incontinence, explosion of user's head, coma, death, and/or# halitosis so edit at your own risk.#==============================================================================module YEA  module REGEXP  module STATE        APPLY_EFFECT_STR = /<(?:APPLY_EFFECT|apply effect):[ ](.*)>/i    APPLY_EFFECT_ON  = /<(?:APPLY_EFFECT|apply effect)>/i    APPLY_EFFECT_OFF = /<\/(?:APPLY_EFFECT|apply effect)>/i        ERASE_EFFECT_STR = /<(?:ERASE_EFFECT|erase effect):[ ](.*)>/i    ERASE_EFFECT_ON  = /<(?:ERASE_EFFECT|erase effect)>/i    ERASE_EFFECT_OFF = /<\/(?:ERASE_EFFECT|erase effect)>/i        LEAVE_EFFECT_STR = /<(?:LEAVE_EFFECT|leave effect):[ ](.*)>/i    LEAVE_EFFECT_ON  = /<(?:LEAVE_EFFECT|leave effect)>/i    LEAVE_EFFECT_OFF = /<\/(?:LEAVE_EFFECT|leave effect)>/i        REACT_EFFECT_STR = /<(?:REACT_EFFECT|react effect):[ ](.*)>/i    REACT_EFFECT_ON  = /<(?:REACT_EFFECT|react effect)>/i    REACT_EFFECT_OFF = /<\/(?:REACT_EFFECT|react effect)>/i        SHOCK_EFFECT_STR = /<(?:SHOCK_EFFECT|shock effect):[ ](.*)>/i    SHOCK_EFFECT_ON  = /<(?:SHOCK_EFFECT|shock effect)>/i    SHOCK_EFFECT_OFF = /<\/(?:SHOCK_EFFECT|shock effect)>/i        BEGIN_EFFECT_STR = /<(?:BEGIN_EFFECT|begin effect):[ ](.*)>/i    BEGIN_EFFECT_ON  = /<(?:BEGIN_EFFECT|begin effect)>/i    BEGIN_EFFECT_OFF = /<\/(?:BEGIN_EFFECT|begin effect)>/i        WHILE_EFFECT_STR = /<(?:WHILE_EFFECT|while effect):[ ](.*)>/i    WHILE_EFFECT_ON  = /<(?:WHILE_EFFECT|while effect)>/i    WHILE_EFFECT_OFF = /<\/(?:WHILE_EFFECT|while effect)>/i        CLOSE_EFFECT_STR = /<(?:CLOSE_EFFECT|close effect):[ ](.*)>/i    CLOSE_EFFECT_ON  = /<(?:CLOSE_EFFECT|close effect)>/i    CLOSE_EFFECT_OFF = /<\/(?:CLOSE_EFFECT|close effect)>/i      end # STATE  end # REGEXPend # YEA#==============================================================================# ■ DataManager#==============================================================================module DataManager    #--------------------------------------------------------------------------  # alias method: load_database  #--------------------------------------------------------------------------  class <<self; alias load_database_lsta load_database; end  def self.load_database    load_database_lsta    load_notetags_lsta  end    #--------------------------------------------------------------------------  # new method: load_notetags_lsta  #--------------------------------------------------------------------------  def self.load_notetags_lsta    for state in $data_states      next if state.nil?      state.load_notetags_lsta    end  end  end # DataManager#==============================================================================# ■ RPG::State#==============================================================================class RPG::State < RPG::BaseItem    #--------------------------------------------------------------------------  # public instance variables  #--------------------------------------------------------------------------  attr_accessor :apply_effects  attr_accessor :erase_effects  attr_accessor :leave_effects  attr_accessor :react_effects  attr_accessor :shock_effects  attr_accessor :begin_effects  attr_accessor :while_effects  attr_accessor :close_effects    #--------------------------------------------------------------------------  # common cache: load_notetags_lsta  #--------------------------------------------------------------------------  def load_notetags_lsta    @apply_effects = ["COMMON APPLY"]    @erase_effects = ["COMMON ERASE"]    @leave_effects = ["COMMON LEAVE"]    @react_effects = ["COMMON REACT"]    @shock_effects = ["COMMON SHOCK"]    @begin_effects = ["COMMON BEGIN"]    @while_effects = ["COMMON WHILE"]    @close_effects = ["COMMON CLOSE"]    @apply_effects_on = false    @erase_effects_on = false    @leave_effects_on = false    @react_effects_on = false    @shock_effects_on = false    @begin_effects_on = false    @while_effects_on = false    @close_effects_on = false    #---    self.note.split(/[\r\n]+/).each { |line|      case line      #---      when YEA::REGEXP::STATE::APPLY_EFFECT_STR        @apply_effects.push($1.to_s)      when YEA::REGEXP::STATE::ERASE_EFFECT_STR        @erase_effects.push($1.to_s)      when YEA::REGEXP::STATE::LEAVE_EFFECT_STR        @leave_effects.push($1.to_s)      when YEA::REGEXP::STATE::REACT_EFFECT_STR        @react_effects.push($1.to_s)      when YEA::REGEXP::STATE::SHOCK_EFFECT_STR        @shock_effects.push($1.to_s)      when YEA::REGEXP::STATE::BEGIN_EFFECT_STR        @begin_effects.push($1.to_s)      when YEA::REGEXP::STATE::WHILE_EFFECT_STR        @while_effects.push($1.to_s)      when YEA::REGEXP::STATE::CLOSE_EFFECT_STR        @close_effects.push($1.to_s)      #---      when YEA::REGEXP::STATE::APPLY_EFFECT_ON        @apply_effects_on = true      when YEA::REGEXP::STATE::ERASE_EFFECT_ON        @erase_effects_on = true      when YEA::REGEXP::STATE::LEAVE_EFFECT_ON        @leave_effects_on = true      when YEA::REGEXP::STATE::REACT_EFFECT_ON        @react_effects_on = true      when YEA::REGEXP::STATE::SHOCK_EFFECT_ON        @shock_effects_on = true      when YEA::REGEXP::STATE::BEGIN_EFFECT_ON        @begin_effects_on = true      when YEA::REGEXP::STATE::WHILE_EFFECT_ON        @while_effects_on = true      when YEA::REGEXP::STATE::CLOSE_EFFECT_ON        @close_effects_on = true      #---      when YEA::REGEXP::STATE::APPLY_EFFECT_OFF        @apply_effects_on = false      when YEA::REGEXP::STATE::ERASE_EFFECT_OFF        @erase_effects_on = false      when YEA::REGEXP::STATE::LEAVE_EFFECT_OFF        @leave_effects_on = false      when YEA::REGEXP::STATE::REACT_EFFECT_OFF        @react_effects_on = false      when YEA::REGEXP::STATE::SHOCK_EFFECT_OFF        @shock_effects_on = false      when YEA::REGEXP::STATE::BEGIN_EFFECT_OFF        @begin_effects_on = false      when YEA::REGEXP::STATE::WHILE_EFFECT_OFF        @while_effects_on = false      when YEA::REGEXP::STATE::CLOSE_EFFECT_OFF        @close_effects_on = false      #---      else        @apply_effects.push(line.to_s) if @after_effects_on        @erase_effects.push(line.to_s) if @erase_effects_on        @leave_effects.push(line.to_s) if @leave_effects_on        @react_effects.push(line.to_s) if @react_effects_on        @shock_effects.push(line.to_s) if @shock_effects_on        @begin_effects.push(line.to_s) if @begin_effects_on        @while_effects.push(line.to_s) if @while_effects_on        @close_effects.push(line.to_s) if @close_effects_on      end    } # self.note.split    #---  end  end # RPG::State#==============================================================================# ■ Game_BattlerBase#==============================================================================class Game_BattlerBase    #--------------------------------------------------------------------------  # alias method: clear_states  #--------------------------------------------------------------------------  alias game_battlerbase_clear_states_lsta clear_states  def clear_states    game_battlerbase_clear_states_lsta    clear_state_origins  end    #--------------------------------------------------------------------------  # alias method: erase_state  #--------------------------------------------------------------------------  alias game_battlerbase_erase_state_lsta erase_state  def erase_state(state_id)    lunatic_state_effect(:erase, $data_states[state_id], self)    change_state_origin(:erase)    game_battlerbase_erase_state_lsta(state_id)  end    #--------------------------------------------------------------------------  # new method: clear_state_origins  #--------------------------------------------------------------------------  def clear_state_origins    @state_origins = {}  end    #--------------------------------------------------------------------------  # new method: change_state_origin  #--------------------------------------------------------------------------  def change_state_origin(state_id, type = :apply)    return unless $game_party.in_battle    return if state_id == death_state_id    if :apply && SceneManager.scene_is?(Scene_Battle)      subject = SceneManager.scene.subject      clear_state_origins if @state_origins.nil?      if subject.nil?        @state_origins[state_id] = [:actor, self.id] if self.actor?        @state_origins[state_id] = [:enemy, self.index] unless self.actor?      elsif subject.actor?        @state_origins[state_id] = [:actor, subject.id]      else        @state_origins[state_id] = [:enemy, subject.index]      end    else # :erase      @state_origins[state_id] = nil    end  end    #--------------------------------------------------------------------------  # new method: state_origin?  #--------------------------------------------------------------------------  def state_origin?(state_id)    return self unless $game_party.in_battle    return self if @state_origins[state_id].nil?    team = @state_origins[state_id][0]    subject = @state_origins[state_id][1]    if team == :actor      return $game_actors[subject]    else # :enemy      return $game_troop.members[subject]    end  end  end # Game_BattlerBase#==============================================================================# ■ Game_Battler#==============================================================================class Game_Battler < Game_BattlerBase    #--------------------------------------------------------------------------  # alias method: on_battle_start  #--------------------------------------------------------------------------  alias game_battler_on_battle_start_lsta on_battle_start  def on_battle_start    game_battler_on_battle_start_lsta    clear_state_origins  end    #--------------------------------------------------------------------------  # alias method: on_battle_end  #--------------------------------------------------------------------------  alias game_battler_on_battle_end_lsta on_battle_end  def on_battle_end    game_battler_on_battle_end_lsta    clear_state_origins  end    #--------------------------------------------------------------------------  # alias method: add_new_state  #--------------------------------------------------------------------------  alias game_battler_add_new_state_lsta add_new_state  def add_new_state(state_id)    change_state_origin(state_id, :apply)    lunatic_state_effect(:apply, $data_states[state_id], self)    game_battler_add_new_state_lsta(state_id)  end    #--------------------------------------------------------------------------  # alias method: remove_states_auto  #--------------------------------------------------------------------------  alias game_battler_remove_states_auto_lsta remove_states_auto  def remove_states_auto(timing)    states.each do |state|      if @state_turns[state.id] == 0 && state.auto_removal_timing == timing        lunatic_state_effect(:leave, state, self)      end    end    game_battler_remove_states_auto_lsta(timing)  end    #--------------------------------------------------------------------------  # alias method: execute_damage  #--------------------------------------------------------------------------  alias game_battler_execute_damage_lsta execute_damage  def execute_damage(user)    run_lunatic_states(:react);     game_battler_execute_damage_lsta(user)    @result.restore_damage if $imported["YEA-BattleEngine"]    run_lunatic_states(:shock);     return unless $imported["YEA-BattleEngine"]    @result.store_damage    @result.clear_damage_values  end    #--------------------------------------------------------------------------  # new method: run_lunatic_states  #--------------------------------------------------------------------------  def run_lunatic_states(type)    for state in states; lunatic_state_effect(type, state, self); end  end  end # Game_Battler#==============================================================================# ■ Scene_Battle#==============================================================================class Scene_Battle < Scene_Base    #--------------------------------------------------------------------------  # public instance variables  #--------------------------------------------------------------------------  attr_accessor :log_window  attr_accessor :subject    #--------------------------------------------------------------------------  # alias method: turn_start  #--------------------------------------------------------------------------  alias scene_battle_turn_start_lsta turn_start  def turn_start    scene_battle_turn_start_lsta    for member in all_battle_members; member.run_lunatic_states(:begin); end  end    #--------------------------------------------------------------------------  # alias method: turn_end  #--------------------------------------------------------------------------  alias scene_battle_turn_end_lsta turn_end  def turn_end    for member in all_battle_members; member.run_lunatic_states(:close); end    scene_battle_turn_end_lsta  end    #--------------------------------------------------------------------------  # alias method: execute_action  #--------------------------------------------------------------------------  alias scene_battle_execute_action_lsta execute_action  def execute_action    scene_battle_execute_action_lsta    @subject.run_lunatic_states(:while)  end  end # Scene_Battle#==============================================================================# ■ Game_BattlerBase#==============================================================================class Game_BattlerBase    #--------------------------------------------------------------------------  # new method: lunatic_state_extension  #--------------------------------------------------------------------------  def lunatic_state_extension(effect, state, user, state_origin, log_window)    # Reserved for future Add-ons.  end  end # Game_BattlerBase#==============================================================================# # ▼ End of File# #==============================================================================
@state_turns[state.id]Should return the remaining turns of the state in question.

Original thread: https://forums.rpgmakerweb.com/threads/base-state-turns-off-of-current-turns-of-3-other-states.52555/