- #===============================================================================
- #
- # Yanfly Engine Melody - Battle Engine Melody - Part V - Base Code
- # Last Date Updated: 2010.05.01
- # Level: Phantasm
- #
- # Over here is the base code used for Battle Engine Melody. The module will
- # contain in Melody script the base actions for each of the major and minor
- # actions found commonly within the battle scene. It's highly recommended that
- # you don't modify these unless you absolutely know what you're doing as these
- # values are considered the default Melody scripts for each of the major
- # actions used within the battle scene.
- #
- #===============================================================================
- # Updates
- # -----------------------------------------------------------------------------
- # o 2010.02.12 to 2010.05.01 - Started and Finished Script.
- #===============================================================================
- # Debug Shortcuts
- #===============================================================================
- # These shortcuts will only occur during $TEST and $BTEST. Otherwise, they will
- # not occur at all. These are only used for the sake of testing.
- #
- # F5 Button
- # - Fully heals the currently highlighted actor during turn selection.
- # - Fully heals the party during party command selection.
- # - Instantly kills the enemy when attacking.
- #
- # F6 Button
- # - Heals the highlighted actor's HP during turn selection.
- # - Heals the party's HP during party command selection.
- # - Prevents missing and evasion during calculations for actors.
- #
- # F7 Button
- # - Heals the highlighted actor's MP during turn selection.
- # - Heals the party's SP during command selection.
- #
- # F8 Button
- # - Damages the highlighted actor by various degrees when holding SHIFT or CTRL.
- # - Damages the whole party during command selection.
- #
- # F9 Button
- # - Enter the debug menu.
- #
- # CTRL Button
- # - If pressed with SHIFT held down during party selection, collapse enemies.
- # - If pressed with ALT held down, turn debug window appears.
- #===============================================================================
- # Editting anything past this point may potentially result in causing computer
- # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
- # Therefore, edit at your own risk.
- #===============================================================================
- #===============================================================================
- # Yanfly Engine Melody
- #===============================================================================
- module YEM
- module REGEXP
- module ANI
- ACTION_COPY = /<(?:ACTION_COPY|action copy):[ ](.*):[ ]*(\d+)>/i
- SETUP_ANI_ON = /<(?:SETUP_ACTION|setup action|setup)>/i
- SETUP_ANI_OFF = /<\/(?:SETUP_ACTION|setup action|setup)>/i
- WHOLE_ANI_ON = /<(?:WHOLE_ACTION|whole action|whole)>/i
- WHOLE_ANI_OFF = /<\/(?:WHOLE_ACTION|whole action|whole)>/i
- TARGET_ANI_ON = /<(?:TARGET_ACTION|target action|target)>/i
- TARGET_ANI_OFF = /<\/(?:TARGET_ACTION|target action|target)>/i
- FOLLOW_ANI_ON = /<(?:FOLLOW_ACTION|follow action|follow)>/i
- FOLLOW_ANI_OFF = /<\/(?:FOLLOW_ACTION|follow action|follow)>/i
- FINISH_ANI_ON = /<(?:FINISH_ACTION|finish action|finish)>/i
- FINISH_ANI_OFF = /<\/(?:FINISH_ACTION|finish action|finish)>/i
- GUARD_ANI_ON = /<(?:GUARD_ACTION|guard action|guard)>/i
- GUARD_ANI_OFF = /<\/(?:GUARD_ACTION|guard action|guard)>/i
- ANI_TYPE_S6 = /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
- ANI_TYPE_S5 = /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
- ANI_TYPE_S4 = /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
- ANI_TYPE_S3 = /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*)/i
- ANI_TYPE_S2 = /[ ]*(.*):[ ](.*),[ ](.*)/i
- ANI_TYPE_S1 = /[ ]*(.*):[ ](.*)/i
- ANI_TYPE_S0 = /[ ]*(.*)/i
- end # ANI
- module BASEITEM
- HIT_RATE = /<(?:HIT_RATE|hit rate|hit):[ ]*(\d+)([%%])>/i
- PTB_BONUS = /<(?:PTB_BONUS|ptb bonus):[ ]*([\+\-]\d+)>/i
- PTB_MAX_CANCEL = /<(?:PTB_MAX_CANCEL|ptb max cancel):[ ]*([\+\-]\d+)>/i
- PTB_MAX_REGAIN = /<(?:PTB_MAX_REGAIN|ptb max regain):[ ]*([\+\-]\d+)>/i
- ATB_CHANGE_SET = /<(?:ATB_CHANGE|atb change):[ ]*([\+\-]\d+)>/i
- ATB_CHANGE_PER = /<(?:ATB_CHANGE|atb change):[ ]*([\+\-]\d+)([%%])>/i
- ATB_RESET = /<(?:ATB_RESET|atb reset):[ ]*(\d+)([%%])>/i
- ATB_RESET_PLUS = /<(?:ATB_RESET|atb reset):[ ]*([\+\-]\d+)([%%])>/i
- CTB_CHANGE_SET = /<(?:CTB_CHANGE|ctb change):[ ]*([\+\-]\d+)>/i
- CTB_CHANGE_PER = /<(?:CTB_CHANGE|ctb change):[ ]*([\+\-]\d+)([%%])>/i
- CTB_RESET = /<(?:CTB_RESET|ctb reset):[ ]*(\d+)([%%])>/i
- CTB_RESET_PLUS = /<(?:CTB_RESET|ctb reset):[ ]*([\+\-]\d+)([%%])>/i
- DAMAGE_FORMULA = /<(?:DAMAGE|dmg):[ ](.*)>/i
- TRAITS = /<(?:TRAIT|traits):[ ](.*)>/i
- SET_ELE_RK = /<(?:ELEMENT_RANK|element rank)[ ](.*):(.*)>/i
- SET_STA_RK = /<(?:STATE_RANK|state rank)[ ](.*):(.*)>/i
- ADD_ELE_RK = /<(?:ELEMENT_RANK|element rank)[ ](.*):[ ]([\+\-]\d+)>/i
- ADD_STA_RK = /<(?:STATE_RANK|state rank)[ ](.*):[ ]([\+\-]\d+)>/i
- REV_ELE_RK = /<(?:ELEMENT_MIRROR|element mirror):[ ](\d+(?:\s*,\s*\d+)*)>/i
- REV_STA_RK = /<(?:STATE_MIRROR|state mirror):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- SET_ELE_RT = /<(?:ELEMENT_RATE|element rate)[ ](.*):[ ]([\+\-]\d+)([%%])>/i
- SET_STA_RT = /<(?:STATE_RATE|state rate)[ ](.*):[ ]([\+\-]\d+)([%%])>/i
- PER_ELE_RT = /<(?:ELEMENT_RATE|element rate)[ ](.*):[ ](\d+)([%%])>/i
- PER_STA_RT = /<(?:STATE_RATE|state rate)[ ](.*):[ ](\d+)([%%])>/i
- ATK_ELE = /<(?:ATTACK_ELEMENT|attack element):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- ATK_STA = /<(?:ATTACK_STATE|attack state):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- end # BASEITEM
- module USABLEITEM
- SKILL_TYPE = /<(?:SKILL_TYPE|skill type):[ ](.*)>/i
- ITEM_TYPE = /<(?:ITEM_TYPE|item type):[ ](.*)>/i
- HIDE_IN_BATTLE = /<(?:HIDE_IN_BATTLE|hide in battle)>/i
- PTB_TURN_COST = /<(?:PTB_TURN_COST|ptb turn cost):[ ]*(\d+)>/i
- PTB_TURN_GAIN = /<(?:PTB_TURN_GAIN|ptb turn gain):[ ]*(\d+)>/i
- PTB_TURN_LOSS = /<(?:PTB_TURN_LOSS|ptb turn loss):[ ]*(\d+)>/i
- HIT_RATE = /<(?:HIT_RATE|hit rate|hit):[ ]*(\d+)([%%])>/i
- SPEED_RATE = /<(?:SPEED|initiative):[ ]([\+\-]\d+)>/i
- STAT_F = /<(.*)(?:_F| f):[ ]*(\d+)([%%])>/i
- CRIT_RATE = /<(?:CRITICAL|critical rate|crit rate):[ ]*(\d+)([%%])>/i
- CAST_ANI = /<(?:CAST_ANIMATION|cast animation|cast ani):[ ]*(\d+)>/i
- SKILL_COST = /<(?:COST|skill cost):[ ](.*)>/i
- COST_ICON = /<(?:COST_ICON|cost icon):[ ](.*)>/i
- RAGE_BOOST = /<(?:RAGE_BOOST|rage boost):[ ]([\+\-]\d+)>/i
- TARG_RAGE = /<(?:TARGET_RAGE|target rage):[ ]([\+\-]\d+)>/i
- COOLDOWN = /<(?:COOLDOWN|recharge):[ ](\d+)>/i
- LIMITEDUSE = /<(?:LIMITED_USE|limited use|limit use):[ ](\d+)>/i
- INSTANT = /<(?:INSTANT|instant use|instant cast)>/i
- ELE_GROW = /<(?:ELEMENT_RATE|element rate)[ ](\d+):[ ]([\+\-]\d+)([%%])>/i
- STA_GROW = /<(?:STATE_RATE|state rate)[ ](\d+):[ ]([\+\-]\d+)([%%])>/i
- REQUIREMENTS = /<(?:REQ|REQUIRE)[ ](.*)[ ](.*):[ ](\d+(?:\s*,\s*\d+)*)>/i
- CHARGES = /<(?:CHARGES|charge|item charges):[ ]*(\d+)>/i
- CHANGE_VAR = /<(?:VARIABLE|var)[ ](\d+):[ ]*([\+\-]\d+)>/i
- CHANGE_SWI = /<(?:SWITCH|sw)[ ](\d+):[ ]*(.*)>/i
- PHARMA_ONLY = /<(?:PHARMACOLOGY_ONLY|pharmacology only)>/i
- RESTRICT = /<(?:RESTRICT|forbid)[ ](.*):[ ](\d+(?:\s*,\s*\d+)*)>/i
- NULLIFY = /<(?:nullify|no effect)[ ](.*):[ ](\d+(?:\s*,\s*\d+)*)>/i
- UNIQUE_EFFECT = /<(.*)[ ]*(\d+)[ ]*(?:EFFECT|ability):[ ]*(\d+)>/i
- PHARMA_EFFECT = /<(?:PHARMACOLOGY_EFFECT|pharmacology effect):[ ]*(\d+)>/i
- CUSTOM_BEFORE = /<(?:BSE|before effect):[ ](.*)>/i
- CUSTOM_DURING = /<(?:DSE|during effect):[ ](.*)>/i
- CUSTOM_AFTER = /<(?:ASE|after effect):[ ](.*)>/i
- TARGETS = /<(?:TARGET|targets):[ ](.*)>/i
- AOE_IMAGE = /<(?:AREA_IMAGE|area image|aoe image):[ ](.*)>/i
- AOE_BLEND = /<(?:AREA_BLEND|area blend|aoe blend):[ ](\d+)>/i
- AOE_HEIGHT = /<(?:AREA_HEIGHT|area height|aoe height):[ ](\d+)([%%])>/i
- AOE_RADIUS = /<(?:AREA_RADIUS|area radius|aoe radius):[ ](\d+)>/i
- RECT_IMAGE = /<(?:RECT_IMAGE|rect image):[ ](.*)>/i
- RECT_BLEND = /<(?:RECT_BLEND|rect blend):[ ](\d+)>/i
- RECT_COL = /<(?:AREA_COLUMN|area column|aoe column):[ ](\d+)>/i
- RECT_ROW = /<(?:AREA_ROW|area row|aoe row):[ ](\d+)>/i
- RECT_MAP = /<(?:AREA_MAP|area map|aoe map)>/i
- TARGET_TEXT_ON = /<(?:TARGET_TEXT|target text|target name)>/i
- TARGET_TEXT_OFF = /<\/(?:TARGET_TEXT|target text|target name)>/i
- end # USABLEITEM
- module ENEMY
- ATTACK_ANIMATION = /<(?:ATTACK_ANIMATION|attack animation):[ ]*(\d+)>/i
- ENEMY_ICON = /<(?:ENEMY_ICON|enemy icon):[ ]*(\d+)>/i
- ENEMY_ICON_HUE = /<(?:ENEMY_ICON_HUE|enemy icon hue):[ ]*([\+\-]\d+)>/i
- EMPTYVIEW_MIRROR = /<(?:EMPTYVIEW_MIRROR|emptyview mirror)>/i
- FRONTVIEW_MIRROR = /<(?:FRONTVIEW_MIRROR|frontview mirror)>/i
- SIDEVIEW_MIRROR = /<(?:SIDEVIEW_MIRROR|sideview mirror)>/i
- ANGLEVIEW_MIRROR = /<(?:ANGLEVIEW_MIRROR|angleview mirror)>/i
- EMPTYVIEW_ZOOM = /<(?:EMPTYVIEW_ZOOM|emptyview zoom):[ ]*(\d+)([%%])>/i
- FRONTVIEW_ZOOM = /<(?:FRONTVIEW_ZOOM|frontview zoom):[ ]*(\d+)([%%])>/i
- SIDEVIEW_ZOOM = /<(?:SIDEVIEW_ZOOM|sideview zoom):[ ]*(\d+)([%%])>/i
- ANGLEVIEW_ZOOM = /<(?:ANGLEVIEW_ZOOM|angleview zoom):[ ]*(\d+)([%%])>/i
- PTB_TURNS = /<(?:PTB_TURNS|ptb turns):[ ]*(\d+)>/i
- PTB_MAX_CANCEL = /<(?:PTB_MAX_CANCEL|ptb max cancel):[ ]*(\d+)>/i
- PTB_MAX_REGAIN = /<(?:PTB_MAX_REGAIN|ptb max regain):[ ]*(\d+)>/i
- ATB_CHANGE_SET = /<(?:ATB_CHANGE|atb change):[ ]*([\+\-]\d+)>/i
- ATB_CHANGE_PER = /<(?:ATB_CHANGE|atb change):[ ]*([\+\-]\d+)([%%])>/i
- ATB_RESET = /<(?:ATB_RESET|atb reset):[ ]*(\d+)([%%])>/i
- CTB_CHANGE_SET = /<(?:CTB_CHANGE|ctb change):[ ]*([\+\-]\d+)>/i
- CTB_CHANGE_PER = /<(?:CTB_CHANGE|ctb change):[ ]*([\+\-]\d+)([%%])>/i
- CTB_RESET = /<(?:CTB_RESET|ctb reset):[ ]*(\d+)([%%])>/i
- DAMAGE_FORMULA = /<(?:DAMAGE|dmg):[ ](.*)>/i
- STATE_ANI_ZOOM = /<(?:STATE_ZOOM|state zoom):[ ]*(\d+)([%%])>/i
- TRAITS = /<(?:TRAIT|traits):[ ](.*)>/i
- GAUGE_WIDTH = /<(?:GAUGE_WIDTH|gauge width):[ ]*(\d+)>/i
- HIDE_GAUGE = /<(.*)[ ](.*)[ ](?:GAUGE|gauge)>/i
- HP_GAUGE = /<(?:HP_GAUGE|hp gauge):[ ]*(\d+),[ ]*(\d+)>/i
- MP_GAUGE = /<(?:MP_GAUGE|mp gauge):[ ]*(\d+),[ ]*(\d+)>/i
- ATK_ELE = /<(?:ATTACK_ELEMENT|attack element):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- ATK_STA = /<(?:ATTACK_STATE|attack state):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- ANIMATION_STANCE = /<(.*)[ ](?:STANCE|stand):[ ]*(\d+)>/i
- STANCE_HUE = /<(?:STANCE_HUE|stance hue|animation hue):[ ]*([\+\-]\d+)>/i
- UNMOVING = /<(?:UNMOVING|unmovable|cannot move|do not move)>/i
- CHARSET0 = /<(?:CS|charset):[ ](.*)>/i
- CHARSET1 = /<(?:CS|charset):[ ](.*),[ ]*(\d+)>/i
- WEAPON = /<(?:WEAPONS|weapon):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- SHIELD = /<(?:SHIELD|shield):[ ]*(\d+)>/i
- end # ENEMY
- module STATE
- POPUP_ADD = /<(?:POPUP_ADD_RULE|popup add rule|popup add):[ ](.*)>/i
- POPUP_REM = /<(?:POPUP_REM_RULE|popup rem rule|popup rem):[ ](.*)>/i
- POPUP_DUR = /<(?:POPUP_DUR_RULE|popup dur rule|popup dur):[ ](.*)>/i
- HIDE_ADD = /<(?:POPUP_HIDE_ADD|popup hide add|hide add)>/i
- HIDE_REM = /<(?:POPUP_HIDE_REM|popup hide rem|hide rem)>/i
- HIDE_DUR = /<(?:POPUP_HIDE_DUR|popup hide dur|hide dur)>/i
- STATE_TYPE = /<(?:STATE_TYPE|state type):[ ](.*)>/i
- STATE_ANI = /<(?:STATE_ANIMATION|state animation|state ani):[ ]*(\d+)>/i
- DMG_TAKEN = /<(.*)[ ](?:extra|taken):[ ]*(\d+)([%%])>/i
- DMG_BONUS = /<(.*)[ ](?:given|bonus):[ ]*(\d+)([%%])>/i
- DMG_WALL = /<(.*)[ ](?:WALL|guard|boost|raise):[ ]*([\+\-]\d+)>/i
- SLIP_SET = /<\s*(HP|MP)?\s*[ ]\s*(DEGEN|REGEN)?\s*:[ ]*(\d+)>/i
- SLIP_PER = /<\s*(HP|MP)?\s*[ ]\s*(DEGEN|REGEN)?\s*:[ ]*(\d+)([%%])>/i
- PTB_BONUS = /<(?:PTB_BONUS|ptb bonus):[ ]*([\+\-]\d+)>/i
- PTB_MAX_CANCEL = /<(?:PTB_MAX_CANCEL|ptb max cancel):[ ]*([\+\-]\d+)>/i
- PTB_MAX_REGAIN = /<(?:PTB_MAX_REGAIN|ptb max regain):[ ]*([\+\-]\d+)>/i
- ATB_RESET_PLUS = /<(?:ATB_RESET|atb reset):[ ]*([\+\-]\d+)([%%])>/i
- CTB_RESET_PLUS = /<(?:CTB_RESET|ctb reset):[ ]*([\+\-]\d+)([%%])>/i
- RAGE_BOOST_PER = /<(?:RAGE_BOOST|rage boost):[ ]*(\d+)([%%])>/i
- RAGE_BOOST_SET = /<(?:RAGE_BOOST|rage boost):[ ]*([\+\-]\d+)>/i
- RESTRICT_SKILL = /<(?:RESTRICT_SKILLS|restrict skills):[ ](.*)>/i
- RESTRICT_ITEM = /<(?:RESTRICT_ITEMS|restrict items):[ ](.*)>/i
- MAX_STACK = /<(?:MAX_STACK|max stack|stack):[ ]*(\d+)>/i
- TRAITS = /<(?:TRAIT|traits):[ ](.*)>/i
- COST_PER = /<(.*)[ ](?:COST|costs):[ ]*(\d+)([%%])>/i
- COST_SET = /<(.*)[ ](?:COST|costs):[ ]*([\+\-]\d+)>/i
- STAT_PER = /<(.*):[ ]*(\d+)([%%])>/i
- STAT_SET = /<(.*):[ ]*([\+\-]\d+)>/i
- CUSTOM_APPLY = /<(?:APPLY_EFFECT|apply effect):[ ](.*)>/i
- CUSTOM_ERASE = /<(?:ERASE_EFFECT|erase effect):[ ](.*)>/i
- CUSTOM_LEAVE = /<(?:LEAVE_EFFECT|leave effect):[ ](.*)>/i
- CUSTOM_REACT = /<(?:REACT_EFFECT|react effect):[ ](.*)>/i
- CUSTOM_SHOCK = /<(?:SHOCK_EFFECT|shock effect):[ ](.*)>/i
- CUSTOM_BEGIN = /<(?:BEGIN_EFFECT|begin effect):[ ](.*)>/i
- CUSTOM_WHILE = /<(?:WHILE_EFFECT|while effect):[ ](.*)>/i
- CUSTOM_CLOSE = /<(?:CLOSE_EFFECT|close effect):[ ](.*)>/i
- SET_ELE_RK = /<(?:ELEMENT_RANK|element rank)[ ](.*):(.*)>/i
- SET_STA_RK = /<(?:STATE_RANK|state rank)[ ](.*):(.*)>/i
- ADD_ELE_RK = /<(?:ELEMENT_RANK|element rank)[ ](.*):[ ]([\+\-]\d+)>/i
- ADD_STA_RK = /<(?:STATE_RANK|state rank)[ ](.*):[ ]([\+\-]\d+)>/i
- REV_ELE_RK = /<(?:ELEMENT_MIRROR|element mirror):[ ](\d+(?:\s*,\s*\d+)*)>/i
- REV_STA_RK = /<(?:STATE_MIRROR|state mirror):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- SET_ELE_RT = /<(?:ELEMENT_RATE|element rate)[ ](.*):[ ]([\+\-]\d+)([%%])>/i
- SET_STA_RT = /<(?:STATE_RATE|state rate)[ ](.*):[ ]([\+\-]\d+)([%%])>/i
- PER_ELE_RT = /<(?:ELEMENT_RATE|element rate)[ ](.*):[ ](\d+)([%%])>/i
- PER_STA_RT = /<(?:STATE_RATE|state rate)[ ](.*):[ ](\d+)([%%])>/i
- ATK_ELE = /<(?:ATTACK_ELEMENT|attack element):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- ATK_STA = /<(?:ATTACK_STATE|attack state):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- WEAPON_ICON = /<(?:WEAPON_ICON|weapon icon):[ ]*(\d+)>/i
- ATTACK_ANI = /<(?:ATTACK_ANIMATION|attack animation|attack ani):[ ]*(\d+)>/i
- end # STATE
- end # REGEXP
- module BATTLE_ENGINE
- module_function
- #--------------------------------------------------------------------------
- # convert_integer_array
- #--------------------------------------------------------------------------
- def convert_integer_array(array)
- result = []
- array.each { |i|
- case i
- when Range; result |= i.to_a
- when Integer; result |= [i]
- end }
- return result
- end
- #--------------------------------------------------------------------------
- # converted_contants
- #--------------------------------------------------------------------------
- ALLY_ELEMENTS = convert_integer_array(ALLY_ELEMENTS)
- ALLY_STATES = convert_integer_array(ALLY_STATES)
- end # BATTLE_ENGINE
- end # YEM
- #===============================================================================
- # module Vocab
- #===============================================================================
- module Vocab
- #--------------------------------------------------------------------------
- # self.hit
- #--------------------------------------------------------------------------
- def self.hit; return YEM::BATTLE_ENGINE::STAT_VOCAB[:hit]; end
- #--------------------------------------------------------------------------
- # self.eva
- #--------------------------------------------------------------------------
- def self.eva; return YEM::BATTLE_ENGINE::STAT_VOCAB[:eva]; end
- #--------------------------------------------------------------------------
- # self.cri
- #--------------------------------------------------------------------------
- def self.cri; return YEM::BATTLE_ENGINE::STAT_VOCAB[:cri]; end
- #--------------------------------------------------------------------------
- # self.odds
- #--------------------------------------------------------------------------
- def self.odds; return YEM::BATTLE_ENGINE::STAT_VOCAB[:odds]; end
- #--------------------------------------------------------------------------
- # self.rage
- #--------------------------------------------------------------------------
- def self.rage; return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_vocab]; end
- #--------------------------------------------------------------------------
- # self.rage_a
- #--------------------------------------------------------------------------
- def self.rage_a; return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_abbrev]; end
- end # Vocab
- #===============================================================================
- # RPG::BGM
- #===============================================================================
- module RPG
- class BGM < AudioFile
- #--------------------------------------------------------------------------
- # overwrite method: play
- #--------------------------------------------------------------------------
- def play
- if @name.empty?
- Audio.bgm_stop
- @@last = BGM.new
- else
- vol = @volume
- if $game_variables != nil
- options = YEM::BATTLE_ENGINE::OPTIONS
- vol = vol * $game_variables[options[:bgm_variable]] / 100
- vol = [[vol, 0].max, 100].min
- vol = 0 if $game_switches[options[:bgm_mute_sw]]
- end
- Audio.bgm_play("Audio/BGM/" + @name, vol, @pitch)
- @@last = self
- end
- end
- end # BGM
- class ME < AudioFile
- #--------------------------------------------------------------------------
- # overwrite method: play
- #--------------------------------------------------------------------------
- def play
- if @name.empty?
- Audio.me_stop
- else
- vol = @volume
- if $game_variables != nil
- options = YEM::BATTLE_ENGINE::OPTIONS
- vol = vol * $game_variables[options[:bgm_variable]] / 100
- vol = [[vol, 0].max, 100].min
- vol = 0 if $game_switches[options[:bgm_mute_sw]]
- end
- Audio.me_play("Audio/ME/" + @name, vol, @pitch)
- end
- end
- end # ME
- class BGS < AudioFile
- #--------------------------------------------------------------------------
- # overwrite method: play
- #--------------------------------------------------------------------------
- def play
- if @name.empty?
- Audio.bgs_stop
- @@last = BGS.new
- else
- vol = @volume
- if $game_variables != nil
- options = YEM::BATTLE_ENGINE::OPTIONS
- vol = vol * $game_variables[options[:bgs_variable]] / 100
- vol = [[vol, 0].max, 100].min
- vol = 0 if $game_switches[options[:bgs_mute_sw]]
- end
- Audio.bgs_play("Audio/BGS/" + @name, vol, @pitch)
- @@last = self
- end
- end
- end # BGS
- class SE < AudioFile
- #--------------------------------------------------------------------------
- # overwrite method: play
- #--------------------------------------------------------------------------
- def play
- unless @name.empty?
- vol = @volume
- if $game_variables != nil
- options = YEM::BATTLE_ENGINE::OPTIONS
- vol = vol * $game_variables[options[:sfx_variable]] / 100
- vol = [[vol, 0].max, 100].min
- vol = 0 if $game_switches[options[:sfx_mute_sw]]
- end
- Audio.se_play("Audio/SE/" + @name, vol, @pitch)
- end
- end
- end # SE
- end # RPG
- #===============================================================================
- # RPG::BaseItem
- #===============================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :attack_vocab
- attr_accessor :guard_vocab
- attr_accessor :setup_action_list
- attr_accessor :whole_action_list
- attr_accessor :target_action_list
- attr_accessor :follow_action_list
- attr_accessor :finish_action_list
- attr_accessor :guard_action_list
- attr_accessor :ptb_bonus
- attr_accessor :ptb_max_cancel
- attr_accessor :ptb_max_regain
- attr_accessor :atb_change_set
- attr_accessor :atb_change_per
- attr_accessor :atb_reset
- attr_accessor :atb_reset_plus
- attr_accessor :ctb_change_set
- attr_accessor :ctb_change_per
- attr_accessor :ctb_reset
- attr_accessor :ctb_reset_plus
- attr_accessor :damage_formula
- attr_accessor :traits
- attr_accessor :element_rank
- attr_accessor :state_rank
- attr_accessor :attack_element
- attr_accessor :attack_state
- attr_accessor :element_rank_add
- attr_accessor :state_rank_add
- attr_accessor :element_rank_rev
- attr_accessor :state_rank_rev
- attr_accessor :element_rate_set
- attr_accessor :state_rate_set
- attr_accessor :element_rate_per
- attr_accessor :state_rate_per
- #--------------------------------------------------------------------------
- # new method: create_default_baseitem_values
- #--------------------------------------------------------------------------
- def create_default_baseitem_values
- @attack_vocab = Vocab.attack
- @guard_vocab = Vocab.guard
- @ptb_bonus = 0
- @ptb_max_cancel = 0
- @ptb_max_regain = 0
- @atb_change_set = 0
- @atb_change_per = 0
- @atb_reset = 0
- @atb_reset_plus = 0
- @ctb_change_set = 0
- @ctb_change_per = 0
- @ctb_reset = 0
- @ctb_reset_plus = 0
- @damage_formula = []
- #---
- @traits = []
- if self.is_a?(RPG::Weapon)
- @traits.push(:fast_attack) if self.fast_attack
- @traits.push(:dual_attack) if self.dual_attack
- end
- if self.is_a?(RPG::Armor)
- @traits.push(:prevent_critical) if self.prevent_critical
- @traits.push(:half_mp_cost) if self.half_mp_cost
- @traits.push(:double_exp_gain) if self.double_exp_gain
- @traits.push(:auto_hp_recover) if self.auto_hp_recover
- end
- #---
- @element_rank = {}
- @state_rank = {}
- @attack_element = []
- @attack_state = []
- @element_rank_add = {}
- @state_rank_add = {}
- @element_rank_rev = []
- @state_rank_rev = []
- @element_rate_set = {}
- @state_rate_set = {}
- @element_rate_per = {}
- @state_rate_per = {}
- end
- #--------------------------------------------------------------------------
- # new method: finish_default_baseitem_values
- #--------------------------------------------------------------------------
- def finish_default_baseitem_values
- #---
- if @damage_formula == []
- if self.is_a?(RPG::Weapon)
- @damage_formula = ["ATK WEAPON"]
- elsif self.is_a?(RPG::UsableItem)
- @damage_formula = ["NORMAL"]
- end
- end
- #---
- end
- #--------------------------------------------------------------------------
- # common cache: yem_cache_baseitem_bem
- #--------------------------------------------------------------------------
- def yem_cache_baseitem_bem
- return if @cached_baseitem_bem; @cached_baseitem_bem = true
- create_default_baseitem_values
- self.note.split(/[\r\n]+/).each { |line|
- case line
- #---
- when YEM::REGEXP::BASEITEM::HIT_RATE
- @hit = $1.to_i
- #---
- when YEM::REGEXP::BASEITEM::PTB_BONUS
- @ptb_bonus = $1.to_i
- when YEM::REGEXP::BASEITEM::PTB_MAX_CANCEL
- @ptb_max_cancel = $1.to_i
- when YEM::REGEXP::BASEITEM::PTB_MAX_REGAIN
- @ptb_max_regain = $1.to_i
- #---
- when YEM::REGEXP::BASEITEM::ATB_CHANGE_SET
- @atb_change_set = $1.to_i
- when YEM::REGEXP::BASEITEM::ATB_CHANGE_PER
- @atb_change_per = $1.to_i
- when YEM::REGEXP::BASEITEM::ATB_RESET
- @atb_reset = $1.to_i
- when YEM::REGEXP::BASEITEM::ATB_RESET_PLUS
- @atb_reset_plus = $1.to_i
- #---
- when YEM::REGEXP::BASEITEM::CTB_CHANGE_SET
- @ctb_change_set = $1.to_i
- when YEM::REGEXP::BASEITEM::CTB_CHANGE_PER
- @ctb_change_per = $1.to_i
- when YEM::REGEXP::BASEITEM::CTB_RESET
- @ctb_reset = $1.to_i
- when YEM::REGEXP::BASEITEM::CTB_RESET_PLUS
- @ctb_reset_plus = $1.to_i
- #---
- when YEM::REGEXP::BASEITEM::DAMAGE_FORMULA
- @damage_formula.push($1.to_s.upcase)
- #---
- when YEM::REGEXP::BASEITEM::TRAITS
- case $1.upcase
- when "SUPER GUARD", "SUPER_GUARD", "SUPERGUARD"
- @traits.push(:super_guard)
- when "PHARMACOLOGY", "PHARMA", "ITEM BOOST", "ITEM_BOOST"
- @traits.push(:pharmacology)
- when "FAST ATTACK", "FAST_ATTACK", "FASTATTACK"
- @traits.push(:fast_attack)
- when "DUAL ATTACK", "DUALATTACK", "DUAL_ATTACK"
- @traits.push(:dual_attack)
- when "PREVENT_CRITICAL", "PREVENT CRITICAL", "PREVENT CRI"
- @traits.push(:prevent_critical)
- when "HALF MP COST", "HALF_MP_COST", "HALF MP", "HALF_MP", "HALFMP"
- @traits.push(:half_mp_cost)
- when "DOUBLE EXP GAIN", "DOUBLE_EXP_GAIN", "DOUBLE EXP", "DOUBLE_EXP"
- @traits.push(:double_exp_gain)
- when "AUTO_HP_RECOVER", "AUTO HP RECOVER", "AUTO HP", "AUTO_HP"
- @traits.push(:auto_hp_recover)
- when "ANTI HP REGEN", "ANTI_HP_REGEN"
- @traits.push(:anti_hp_regen)
- when "ANTI HP DEGEN", "ANTI_HP_DEGEN"
- @traits.push(:anti_hp_degen)
- when "ANTI MP REGEN", "ANTI_MP_REGEN"
- @traits.push(:anti_mp_regen)
- when "ANTI MP DEGEN", "ANTI_MP_DEGEN"
- @traits.push(:anti_mp_degen)
- else; next
- end
- #---
- when YEM::REGEXP::BASEITEM::SET_ELE_RT
- next if self.is_a?(RPG::Item)
- if $1.to_i != 0
- @element_rate_set[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_system.elements.size - 1)
- @element_rate_set[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::BASEITEM::PER_ELE_RT
- next if self.is_a?(RPG::Item)
- if $1.to_i != 0
- @element_rate_per[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_system.elements.size - 1)
- @element_rate_per[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::BASEITEM::ADD_ELE_RK
- if $1.to_i != 0
- @element_rank_add[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_system.elements.size - 1)
- @element_rank_add[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::BASEITEM::SET_ELE_RK
- case $2.upcase
- when "S", "Z"; value = 0
- when "A"; value = 1
- when "B"; value = 2
- when "C"; value = 3
- when "D"; value = 4
- when "E"; value = 5
- when "F"; value = 6
- else; next
- end
- if $1.to_i != 0
- @element_rank[$1.to_i] = value
- elsif $1.upcase == "ALL"
- for i in 1..($data_system.elements.size - 1)
- @element_rank[i] = value
- end
- end
- #---
- when YEM::REGEXP::BASEITEM::SET_STA_RT
- if $1.to_i != 0
- @state_rate_set[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_states.size - 1)
- @state_rate_set[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::BASEITEM::PER_STA_RT
- if $1.to_i != 0
- @state_rate_per[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_states.size - 1)
- @state_rate_per[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::BASEITEM::ADD_STA_RK
- if $1.to_i != 0
- @state_rank_add[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_states.size - 1)
- @state_rank_add[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::BASEITEM::SET_STA_RK
- case $2.upcase
- when "S", "Z"; value = 0
- when "A"; value = 1
- when "B"; value = 2
- when "C"; value = 3
- when "D"; value = 4
- when "E"; value = 5
- when "F"; value = 6
- else; next
- end
- if $1.to_i != 0
- @state_rank[$1.to_i] = value
- elsif $1.upcase == "ALL"
- for i in 1..($data_states.size - 1)
- @state_rank[i] = value
- end
- end
- #---
- when YEM::REGEXP::BASEITEM::ATK_ELE
- $1.scan(/\d+/).each { |num|
- @attack_element.push(num.to_i) if num.to_i > 0 }
- #---
- when YEM::REGEXP::BASEITEM::ATK_STA
- $1.scan(/\d+/).each { |num|
- @attack_state.push(num.to_i) if num.to_i > 0 }
- #---
- end
- } # self.note.split
- finish_default_baseitem_values
- #--- Melody REGEXP ---
- create_default_action_codes
- self.note.split(/[\r\n]+/).each { |line|
- case line
- #---
- when YEM::REGEXP::ANI::ACTION_COPY
- case $1.upcase
- when "I", "ITEM"
- obj = $data_items[$2.to_i]
- next if obj == nil
- obj.yem_cache_baseitem_bem
- when "S", "SKILL"
- obj = $data_skills[$2.to_i]
- next if obj == nil
- obj.yem_cache_baseitem_bem
- when "W", "WEAPON"
- obj = $data_weapons[$2.to_i]
- next if obj == nil
- obj.yem_cache_baseitem_bem
- when "A", "ARMOR", "ARMOUR"
- obj = $data_armors[$2.to_i]
- next if obj == nil
- obj.yem_cache_baseitem_bem
- when "E", "ENEMY"
- obj = $data_enemies[$2.to_i]
- next if obj == nil
- obj.yem_cache_enemy_bem
- else; next
- end
- @setup_action_list = obj.setup_action_list.clone
- @whole_action_list = obj.whole_action_list.clone
- @target_action_list = obj.target_action_list.clone
- @follow_action_list = obj.follow_action_list.clone
- @finish_action_list = obj.finish_action_list.clone
- @guard_action_list = obj.guard_action_list.clone
- #---
- when YEM::REGEXP::ANI::SETUP_ANI_ON
- @melody_line = true
- @setup_action_list = []
- @setup_action_flag = true
- when YEM::REGEXP::ANI::SETUP_ANI_OFF
- @melody_line = false
- @setup_action_flag = false
- when YEM::REGEXP::ANI::WHOLE_ANI_ON
- @melody_line = true
- @whole_action_list = []
- @whole_action_flag = true
- when YEM::REGEXP::ANI::WHOLE_ANI_OFF
- @melody_line = false
- @whole_action_flag = false
- when YEM::REGEXP::ANI::TARGET_ANI_ON
- @melody_line = true
- @target_action_list = []
- @target_action_flag = true
- when YEM::REGEXP::ANI::TARGET_ANI_OFF
- @melody_line = false
- @target_action_flag = false
- when YEM::REGEXP::ANI::FOLLOW_ANI_ON
- @melody_line = true
- @follow_action_list = []
- @follow_action_flag = true
- when YEM::REGEXP::ANI::FOLLOW_ANI_OFF
- @melody_line = false
- @follow_action_flag = false
- when YEM::REGEXP::ANI::FINISH_ANI_ON
- @melody_line = true
- @finish_action_list = []
- @finish_action_flag = true
- when YEM::REGEXP::ANI::FINISH_ANI_OFF
- @melody_line = false
- @finish_action_flag = false
- #---
- when YEM::REGEXP::ANI::GUARD_ANI_ON
- @melody_line = true
- @guard_action_list = []
- @guard_action_flag = true
- when YEM::REGEXP::ANI::GUARD_ANI_OFF
- @melody_line = false
- @guard_action_flag = false
- #---
- else
- next unless @melody_line
- case line
- when YEM::REGEXP::ANI::ANI_TYPE_S6
- type = $1
- value = [$2, $3, $4, $5, $6, $7]
- when YEM::REGEXP::ANI::ANI_TYPE_S5
- type = $1
- value = [$2, $3, $4, $5, $6]
- when YEM::REGEXP::ANI::ANI_TYPE_S4
- type = $1
- value = [$2, $3, $4, $5]
- when YEM::REGEXP::ANI::ANI_TYPE_S3
- type = $1
- value = [$2, $3, $4]
- when YEM::REGEXP::ANI::ANI_TYPE_S2
- type = $1
- value = [$2, $3]
- when YEM::REGEXP::ANI::ANI_TYPE_S1
- type = $1
- value = [$2]
- when YEM::REGEXP::ANI::ANI_TYPE_S0
- type = $1
- value = [nil]
- else; next
- end
- case type.upcase
- when /IF[ ](.*)/i, /UNLESS[ ](.*)/i, /ELSIF[ ](.*)/i
- ignore_upcase = true
- when "MESSAGE", "SCRIPT", "SCRIPT CALL", "POPUP"
- type = type.upcase
- ignore_upcase = true
- when /CHANGE[ ](?:VARIABLE|VAR)[ ](.*)/i
- else
- type = type.upcase
- ignore_upcase = false
- end
- for i in 0..(value.size-1)
- next if value[i] == nil
- next if ignore_upcase
- next if value[i] == /IF[ ](.*)/i
- next if value[i] == /UNLESS[ ](.*)/i
- value[i] = value[i].to_s.upcase
- end
- array = [type, value]
- if @setup_action_flag
- @setup_action_list[@setup_action_list.size] = array
- elsif @whole_action_flag
- @whole_action_list[@whole_action_list.size] = array
- elsif @target_action_flag
- @target_action_list[@target_action_list.size] = array
- elsif @follow_action_flag
- @follow_action_list[@follow_action_list.size] = array
- elsif @finish_action_flag
- @finish_action_list[@finish_action_list.size] = array
- elsif @guard_action_flag
- @guard_action_list[@guard_action_list.size] = array
- end
- end
- } # self.note.split
- #--- Melody REGEXP ---
- end # yem_cache_baseitem_bem
- #--------------------------------------------------------------------------
- # new method: create_default_action_codes
- #--------------------------------------------------------------------------
- def create_default_action_codes
- @setup_action_list = []; @finish_action_list = []
- @whole_action_list = []; @target_action_list = []
- @guard_action_list = []; @follow_action_list = []
- if self.is_a?(RPG::Weapon)
- @setup_action_list = YEM::DEFAULT_ACTIONS::ATTACK_SETUP
- @whole_action_list = YEM::DEFAULT_ACTIONS::ATTACK_WHOLE
- @target_action_list = YEM::DEFAULT_ACTIONS::ATTACK_TARGET
- @follow_action_list = YEM::DEFAULT_ACTIONS::ATTACK_FOLLOW
- @finish_action_list = YEM::DEFAULT_ACTIONS::ATTACK_FINISH
- return
- end
- if self.is_a?(RPG::Skill) and !self.physical_attack
- @setup_action_list = YEM::DEFAULT_ACTIONS::MAGIC_SETUP
- @whole_action_list = YEM::DEFAULT_ACTIONS::MAGIC_WHOLE
- @target_action_list = YEM::DEFAULT_ACTIONS::MAGIC_TARGET
- @follow_action_list = YEM::DEFAULT_ACTIONS::MAGIC_FOLLOW
- @finish_action_list = YEM::DEFAULT_ACTIONS::MAGIC_FINISH
- return
- elsif self.is_a?(RPG::Skill) and self.physical_attack
- @setup_action_list = YEM::DEFAULT_ACTIONS::PHYSICAL_SETUP
- @whole_action_list = YEM::DEFAULT_ACTIONS::PHYSICAL_WHOLE
- @target_action_list = YEM::DEFAULT_ACTIONS::PHYSICAL_TARGET
- @follow_action_list = YEM::DEFAULT_ACTIONS::PHYSICAL_FOLLOW
- @finish_action_list = YEM::DEFAULT_ACTIONS::PHYSICAL_FINISH
- return
- end
- if self.is_a?(RPG::Item)
- @setup_action_list = YEM::DEFAULT_ACTIONS::ITEM_SETUP
- @whole_action_list = YEM::DEFAULT_ACTIONS::ITEM_WHOLE
- @target_action_list = YEM::DEFAULT_ACTIONS::ITEM_TARGET
- @follow_action_list = YEM::DEFAULT_ACTIONS::ITEM_FOLLOW
- @finish_action_list = YEM::DEFAULT_ACTIONS::ITEM_FINISH
- return
- end
- if self.is_a?(RPG::Armor) and self.kind == 0
- @guard_action_list = YEM::DEFAULT_ACTIONS::GUARD_ACTIONS
- end
- end
- end # RPG::BaseItem
- #===============================================================================
- # RPG::UsableItem
- #===============================================================================
- class RPG::UsableItem < RPG::BaseItem
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :skill_type
- attr_accessor :item_type
- attr_accessor :hide_in_battle
- attr_accessor :ptb_turn_cost
- attr_accessor :ptb_turn_gain
- attr_accessor :ptb_turn_loss
- attr_accessor :random_targets
- attr_accessor :def_f
- attr_accessor :res_f
- attr_accessor :dex_f
- attr_accessor :agi_f
- attr_accessor :cri_rate
- attr_accessor :cast_ani
- attr_accessor :skill_cost
- attr_accessor :cost_icon
- attr_accessor :rage_skill
- attr_accessor :rage_boost
- attr_accessor :rage_target
- attr_accessor :cooldown
- attr_accessor :limited_use
- attr_accessor :instant
- attr_accessor :requirements
- attr_accessor :element_growth
- attr_accessor :state_growth
- attr_accessor :lunatic_effects
- attr_accessor :charges
- attr_accessor :change_variable
- attr_accessor :change_switch
- attr_accessor :pharmacology_only
- attr_accessor :restrict
- attr_accessor :targets
- attr_accessor :target_text
- attr_accessor :aoe_animation
- attr_accessor :aoe_image
- attr_accessor :aoe_blend
- attr_accessor :aoe_height
- attr_accessor :aoe_radius
- attr_accessor :rect_image
- attr_accessor :rect_blend
- attr_accessor :rect_type
- attr_accessor :rect_value
- attr_accessor :for_opponent
- attr_accessor :for_friend
- attr_accessor :nullify
- attr_accessor :unique_effect
- #--------------------------------------------------------------------------
- # new method: create_default_usableitem_values
- #--------------------------------------------------------------------------
- def create_default_usableitem_values
- @name.gsub!(/\[.*\]/) { "" }
- #---
- @skill_type = ["ALL"] if self.is_a?(RPG::Skill)
- @item_type = ["ALL"] if self.is_a?(RPG::Item)
- @hide_in_battle = false
- #---
- @ptb_turn_cost = 1
- @ptb_turn_gain = 0
- @ptb_turn_loss = 0
- #---
- @def_f = 0
- @res_f = 0
- @dex_f = 0
- @agi_f = 0
- #--
- @cast_ani = 0
- if self.is_a?(RPG::Skill) and !self.physical_attack
- @cast_ani = YEM::BATTLE_ENGINE::DEFAULT_CAST_ANIMATION
- end
- @skill_cost = ""
- @skill_cost = self.mp_cost.to_s + " MP" if self.is_a?(RPG::Skill)
- @rage_skill = false
- @rage_boost = 0
- if self.is_a?(RPG::Skill) and self.physical_attack
- @rage_boost = YEM::BATTLE_ENGINE::SKILL_SETTINGS[:physical_rage_gain]
- elsif self.is_a?(RPG::Skill)
- @rage_boost = YEM::BATTLE_ENGINE::SKILL_SETTINGS[:magical_rage_gain]
- end
- @rage_target = 0
- @cooldown = 0
- @limited_use = 0
- @instant = false
- @requirements = {}
- @lunatic_effects = {}
- @element_growth = {}
- @state_growth = {}
- #---
- @charges = 1
- @change_variable = {}
- @change_switch = {}
- @pharmacology_only = false
- @restrict = {:actors => [], :classes => []}
- @nullify = {:actors => [], :classes => [], :enemies => []}
- @unique_effect = {:pharm => nil, :actor => {}, :class => {}}
- #---
- @targets = []
- @aoe_animation = false
- @aoe_image = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:circ_name]
- @aoe_blend = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:circ_blend]
- @aoe_height = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:circ_height]
- @aoe_radius = 0
- @rect_image = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:rect_name]
- @rect_blend = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:rect_blend]
- @rect_type = 0
- @rect_value = 0
- end
- #--------------------------------------------------------------------------
- # common cache: finish_default_usableitem_values
- #--------------------------------------------------------------------------
- def finish_default_usableitem_values
- @lunatic_effects[:before] = [] if @lunatic_effects[:before] == nil
- @lunatic_effects[:before].push("COMMON BEFORE")
- @lunatic_effects[:during] = [] if @lunatic_effects[:during] == nil
- @lunatic_effects[:before].push("COMMON DURING")
- @lunatic_effects[:after] = [] if @lunatic_effects[:after] == nil
- @lunatic_effects[:before].push("COMMON AFTER")
- #---
- if @aoe_animation and $data_animations[self.animation_id] != nil
- animation = $data_animations[self.animation_id]
- @aoe_animation = false if animation.position == 3
- end
- #---
- if @targets == []
- string = "NONE"
- if self.for_opponent?
- @for_opponent = true
- @for_friend = false
- if self.for_random?
- if self.for_one?
- string = "1 RANDOM FOE"
- @random_targets = 1
- elsif self.for_two?
- string = "2 RANDOM FOES"
- @random_targets = 2
- else
- string = "3 RANDOM FOES"
- @random_targets = 3
- end
- elsif self.dual?
- string = "2 HITS FOE"
- elsif self.for_one?
- string = "1 HIT FOE"
- else
- string = "ALL FOES X1"
- end
- elsif self.for_user?
- @for_friend = true
- @for_opponent = false
- string = "USER ONLY"
- elsif self.for_dead_friend?
- @for_friend = true
- @for_opponent = false
- if self.for_one?
- string = "1 HIT DEAD ALLY"
- else
- string = "ALL DEAD ALLIES X1"
- end
- elsif self.for_friend?
- @for_friend = true
- @for_opponent = false
- if self.for_one?
- string = "1 HIT ALLY"
- else
- string = "ALL ALLIES X1"
- end
- elsif self.for_none?
- @for_friend = false
- @for_opponent = false
- end
- @targets.push(string)
- end # @targets == []
- @random_targets = 0 if @random_targets == nil
- @targets.push("COMMON TARGET")
- remodify_scope
- end
- #--------------------------------------------------------------------------
- # common cache: yem_cache_usableitem_bem
- #--------------------------------------------------------------------------
- def yem_cache_usableitem_bem
- return if @cached_usableitem_bem; @cached_usableitem_bem = true
- create_default_usableitem_values
- self.note.split(/[\r\n]+/).each { |line|
- case line
- #---
- when YEM::REGEXP::USABLEITEM::SKILL_TYPE
- next unless self.is_a?(RPG::Skill)
- @skill_type.push($1.upcase)
- when YEM::REGEXP::USABLEITEM::ITEM_TYPE
- next unless self.is_a?(RPG::Item)
- @item_type.push($1.upcase)
- when YEM::REGEXP::USABLEITEM::HIDE_IN_BATTLE
- @hide_in_battle = true
- #---
- when YEM::REGEXP::USABLEITEM::PTB_TURN_COST
- next if @instant
- @ptb_turn_cost = $1.to_i
- when YEM::REGEXP::USABLEITEM::PTB_TURN_GAIN
- @ptb_turn_gain = $1.to_i
- when YEM::REGEXP::USABLEITEM::PTB_TURN_LOSS
- @ptb_turn_loss = $1.to_i
- #---
- when YEM::REGEXP::USABLEITEM::ELE_GROW
- @element_growth[$1.to_i] = $2.to_i
- when YEM::REGEXP::USABLEITEM::STA_GROW
- @state_growth[$1.to_i] = $2.to_i
- #---
- when YEM::REGEXP::USABLEITEM::HIT_RATE
- next unless self.is_a?(RPG::Skill)
- @hit = $1.to_i
- when YEM::REGEXP::USABLEITEM::SPEED_RATE
- @speed = $1.to_i
- when YEM::REGEXP::USABLEITEM::STAT_F
- value = $2.to_i
- case $1.upcase
- when "ATK"; @atk_f = value
- when "DEF"; @def_f = value
- when "SPI"; @spi_f = value
- when "RES"; @res_f = value
- when "DEX"; @dex_f = value
- when "AGI"; @agi_f = value
- end
- #---
- when YEM::REGEXP::USABLEITEM::CRIT_RATE
- @cri_rate = $1.to_i
- #---
- when YEM::REGEXP::USABLEITEM::CAST_ANI
- @cast_ani = $1.to_i
- #---
- when YEM::REGEXP::USABLEITEM::SKILL_COST
- @skill_cost = $1.to_s.upcase
- case $1.upcase
- when /(\d+)[ ]RAGE/i
- @rage_skill = true
- end
- #---
- when YEM::REGEXP::USABLEITEM::COST_ICON
- @cost_icon = $1.to_i
- #---
- when YEM::REGEXP::USABLEITEM::RAGE_BOOST
- @rage_boost = $1.to_i
- when YEM::REGEXP::USABLEITEM::TARG_RAGE
- @target_rage = $1.to_i
- #---
- when YEM::REGEXP::USABLEITEM::COOLDOWN
- @cooldown = $1.to_i
- when YEM::REGEXP::USABLEITEM::LIMITEDUSE
- @limited_use = $1.to_i
- #---
- when YEM::REGEXP::USABLEITEM::INSTANT
- @instant = true
- @speed = 10 ** 10
- @ptb_turn_cost = 0
- @atb_reset = 100
- @ctb_reset = 100
- #---
- when YEM::REGEXP::USABLEITEM::REQUIREMENTS
- case $2.upcase
- when "STATE", "STATES"
- case $1.upcase
- when "ANY"; type = :any_state
- when "ALL"; type = :all_state
- end
- when "ELEMENT", "ELEMENTS", "ELE"
- case $1.upcase
- when "ANY"; type = :any_ele
- when "ALL"; type = :all_ele
- end
- when "SWITCH", "SWITCHES"
- case $1.upcase
- when "ANY"; type = :any_switch
- when "ALL"; type = :all_switch
- end
- else; next
- end
- @requirements[type] = [] if @requirements[type] == nil
- $3.scan(/\d+/).each { |num|
- @requirements[type].push(num.to_i) if num.to_i > 0 }
- #---
- when YEM::REGEXP::USABLEITEM::CUSTOM_BEFORE
- string = $1.upcase; type = :before
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- when YEM::REGEXP::USABLEITEM::CUSTOM_DURING
- string = $1.upcase; type = :during
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- when YEM::REGEXP::USABLEITEM::CUSTOM_AFTER
- string = $1.upcase; type = :after
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- #---
- when YEM::REGEXP::USABLEITEM::CHARGES
- next unless self.is_a?(RPG::Item)
- @charges = $1.to_i
- when YEM::REGEXP::USABLEITEM::CHANGE_VAR
- next unless self.is_a?(RPG::Item)
- @change_variable[$1.to_i] = $2.to_i
- when YEM::REGEXP::USABLEITEM::CHANGE_SWI
- next unless self.is_a?(RPG::Item)
- case $2.upcase
- when "TRUE", "ON"; value = :true
- when "FALSE", "OFF"; value = :false
- when "TOGGLE"; value = :toggle
- else; next
- end
- @change_switch[$1.to_i] = value
- #---
- when YEM::REGEXP::USABLEITEM::PHARMA_ONLY
- @pharmacology_only = true
- when YEM::REGEXP::USABLEITEM::RESTRICT
- case $1.upcase
- when "ACTOR", "ACTORS"; type = :actors
- when "CLASS", "CLASSES"; type = :classes
- else; next
- end
- $2.scan(/\d+/).each { |num|
- @restrict[type].push(num.to_i) if num.to_i > 0 }
- when YEM::REGEXP::USABLEITEM::NULLIFY
- case $1.upcase
- when "ACTOR", "ACTORS"; type = :actors
- when "CLASS", "CLASSES"; type = :classes
- when "ENEMY", "ENEMIES"; type = :enemies
- else; next
- end
- $2.scan(/\d+/).each { |num|
- @nullify[type].push(num.to_i) if num.to_i > 0 }
- #---
- when YEM::REGEXP::USABLEITEM::PHARMA_EFFECT
- @unique_effect[:pharm] = $1.to_i
- when YEM::REGEXP::USABLEITEM::UNIQUE_EFFECT
- next unless self.is_a?(RPG::Item)
- case $1.upcase
- when "ACTOR"; type = :actor
- when "CLASS"; type = :class
- else; next
- end
- @unique_effect[type][$2.to_i] = $3.to_i
- #---
- when YEM::REGEXP::USABLEITEM::TARGETS
- string = $1.to_s.upcase
- @targets.push(string)
- case string
- when /DEAD/i
- @for_dead = true
- end
- #---
- case string
- when "EVERYBODY"
- @for_opponent = true
- @for_friend = true
- when "ALL BUT USER"
- @for_friend = true
- @for_opponent = false
- when /(\d+)[ ](?:RANDOM|RAND)[ ](.*)/i
- @random_targets = $1.to_i
- case $2.upcase
- when /(?:FOE|FOES)/i
- @for_opponent = true
- @for_friend = false
- when /(?:ALLY|ALLIES)/i
- @for_friend = true
- @for_opponent = false
- end
- when /(?:FOE|FOES)/i
- @for_opponent = true
- @for_friend = false
- when /(?:ALLY|ALLIES|USER|USERS)/i
- @for_friend = true
- @for_opponent = false
- end
- #---
- when YEM::REGEXP::USABLEITEM::AOE_IMAGE
- @aoe_image = $1.to_s
- when YEM::REGEXP::USABLEITEM::AOE_BLEND
- @aoe_blend = $1.to_i
- when YEM::REGEXP::USABLEITEM::AOE_HEIGHT
- @aoe_height = $1.to_i / 100.0
- when YEM::REGEXP::USABLEITEM::AOE_RADIUS
- @aoe_radius = [$1.to_i, 3].max
- @aoe_animation = true
- when YEM::REGEXP::USABLEITEM::RECT_IMAGE
- @rect_image = $1.to_s
- when YEM::REGEXP::USABLEITEM::RECT_BLEND
- @rect_blend = $1.to_i
- when YEM::REGEXP::USABLEITEM::RECT_COL
- @rect_type = 1
- @rect_value = [$1.to_i, 3].max
- @aoe_animation = true
- when YEM::REGEXP::USABLEITEM::RECT_ROW
- @rect_type = 2
- @rect_value = [$1.to_i, 3].max
- @aoe_animation = true
- when YEM::REGEXP::USABLEITEM::RECT_MAP
- @rect_type = 3
- #---
- when YEM::REGEXP::USABLEITEM::TARGET_TEXT_ON
- @target_text_enabled = true
- @target_text = ""
- when YEM::REGEXP::USABLEITEM::TARGET_TEXT_OFF
- @target_text_enabled = false
- #---
- else
- if @target_text_enabled
- @target_text += line
- end
- end
- } # self.note.split
- finish_default_usableitem_values
- end # yem_cache_usableitem_bem
- #--------------------------------------------------------------------------
- # overwrite method: for_opponent?
- #--------------------------------------------------------------------------
- def for_opponent?
- return @for_opponent if @for_opponent != nil
- return [1, 2, 3, 4, 5, 6].include?(@scope)
- end
- #--------------------------------------------------------------------------
- # overwrite method: for_friend?
- #--------------------------------------------------------------------------
- def for_friend?
- return @for_friend if @for_friend != nil
- return [7, 8, 9, 10, 11].include?(@scope)
- end
- #--------------------------------------------------------------------------
- # overwrite method: for_random?
- #--------------------------------------------------------------------------
- def for_random?
- return @random_targets > 0 if @random_targets != nil
- return [4, 5, 6].include?(@scope)
- end
- #--------------------------------------------------------------------------
- # new method: for_none?
- #--------------------------------------------------------------------------
- def for_none?; return [0].include?(@scope); end
- #--------------------------------------------------------------------------
- # overwrite method: for_dead_friend?
- #--------------------------------------------------------------------------
- def for_dead_friend?
- return true if @for_dead
- return [9, 10].include?(@scope)
- end
- #--------------------------------------------------------------------------
- # new method: can_critical?
- #--------------------------------------------------------------------------
- def can_critical?
- return true if @cri_rate != nil and @cri_rate > 0
- return YEM::BATTLE_ENGINE::CRITICAL_SKILLS[:healing] if @base_damage < 0
- return YEM::BATTLE_ENGINE::CRITICAL_SKILLS[:physical] if @physical_attack
- return YEM::BATTLE_ENGINE::CRITICAL_SKILLS[:magical]
- end
- #--------------------------------------------------------------------------
- # new method: remodify_scope
- #--------------------------------------------------------------------------
- def remodify_scope
- for target in targets
- #---
- case target.upcase
- when "USER ONLY"
- @scope = 11 # User Only
- when "ALL BUT USER", "EVERYBODY"
- @scope = 2 # All Enemies
- #---
- when /(?:PICK|TARGET)[ ](\d+)[ ](?:RANDOM|RAND)[ ](.*)/i,
- /(\d+)[ ](?:HIT|HITS)[ ](.*)/i
- case $2.upcase
- when "DEAD FOE", "DEAD FOES", "FOE", "FOES"
- @scope = 1 # One Enemy
- when "DEAD ALLIES", "DEAD ALLIES", "ALLY", "ALLIES"
- @scope = 7 # One Ally
- else; next
- end
- #---
- when /(?:ALL|EVERY)[ ](.*)[ ]X(\d+)/i
- case $1.upcase
- when "DEAD FOE", "DEAD FOES", "FOE", "FOES"
- @scope = 2 # All Enemies
- when "DEAD ALLIES", "DEAD ALLIES", "ALLY", "ALLIES"
- @scope = 8 # All Allies
- else; next
- end
- #---
- when /(?:RANDOM|RAND)/i
- @scope = 4
- #---
- else; next
- end
- break
- end
- end
- end # RPG::UsableItem
- #===============================================================================
- # RPG::Enemy
- #===============================================================================
- class RPG::Enemy
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :attack_animation
- attr_accessor :enemy_icon
- attr_accessor :enemy_icon_hue
- attr_accessor :view_mirror
- attr_accessor :view_zoom
- attr_accessor :setup_action_list
- attr_accessor :whole_action_list
- attr_accessor :target_action_list
- attr_accessor :follow_action_list
- attr_accessor :finish_action_list
- attr_accessor :guard_action_list
- attr_accessor :ptb_turns
- attr_accessor :ptb_max_cancel
- attr_accessor :ptb_max_regain
- attr_accessor :atb_change_set
- attr_accessor :atb_change_per
- attr_accessor :atb_reset
- attr_accessor :ctb_change_set
- attr_accessor :ctb_change_per
- attr_accessor :ctb_reset
- attr_accessor :damage_formula
- attr_accessor :state_zoom
- attr_accessor :traits
- attr_accessor :target_offset_x
- attr_accessor :target_offset_y
- attr_accessor :quick_gauge
- attr_accessor :attack_element
- attr_accessor :attack_state
- attr_accessor :animation_stance
- attr_accessor :animation_hue
- attr_accessor :unmoving
- attr_accessor :character_name
- attr_accessor :character_index
- attr_accessor :weapons
- attr_accessor :shield
- #--------------------------------------------------------------------------
- # new method: create_default_enemy_values
- #--------------------------------------------------------------------------
- def create_default_enemy_values
- @attack_animation = YEM::BATTLE_ENGINE::DEFAULT_ENEMY_ATTACK
- @enemy_icon = YEM::BATTLE_ENGINE::DEFAULT_ENEMY_ICON
- @enemy_icon_hue = 0
- @view_mirror ={
- :empty => false,
- :front => false,
- :side => false,
- :angle => false, }
- @view_zoom ={
- :empty => 1.0,
- :front => 1.0,
- :side => 1.0,
- :angle => 1.0 }
- @state_zoom = 100
- @ptb_turns = YEM::BATTLE_ENGINE::PTB_RULES[:provided_turns]
- @ptb_max_cancel = YEM::BATTLE_ENGINE::PTB_RULES[:max_actor_cancel]
- @ptb_max_regain = YEM::BATTLE_ENGINE::PTB_RULES[:max_actor_regain]
- @atb_change_set = 0
- @atb_change_per = 0
- @atb_reset = 0
- @ctb_change_set = 0
- @ctb_change_per = 0
- @ctb_reset = 0
- @damage_formula = []
- @target_offset_x = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:target_off_x]
- @target_offset_y = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:target_off_y]
- #---
- @quick_gauge ={
- :width => YEM::BATTLE_ENGINE::QUICK_QUERY_SETTINGS[:width] + 32,
- :states => YEM::BATTLE_ENGINE::QUICK_QUERY_SETTINGS[:states],
- :show_hp => YEM::BATTLE_ENGINE::QUICK_QUERY_SETTINGS[:show_hp],
- :hp_gauge1 => YEM::BATTLE_ENGINE::QUICK_QUERY_SETTINGS[:hp_gauge1],
- :hp_gauge2 => YEM::BATTLE_ENGINE::QUICK_QUERY_SETTINGS[:hp_gauge2],
- :show_mp => YEM::BATTLE_ENGINE::QUICK_QUERY_SETTINGS[:show_mp],
- :mp_gauge1 => YEM::BATTLE_ENGINE::QUICK_QUERY_SETTINGS[:mp_gauge1],
- :mp_gauge2 => YEM::BATTLE_ENGINE::QUICK_QUERY_SETTINGS[:mp_gauge2],
- } # End Quick Gauge
- #---
- @attack_element = []
- @attack_state = []
- #---
- @animation_stance = {}
- @animation_hue = 0
- @unmoving = false
- #---
- @character_name = ""
- @character_index = 0
- @weapons = []
- @shield = nil
- end
- #--------------------------------------------------------------------------
- # new method: finish_default_enemy_values
- #--------------------------------------------------------------------------
- def finish_default_enemy_values
- @damage_formula = ["ATK WEAPON"] if @damage_formula == []
- if @animation_stance.include?("IDLE")
- @animation_stance["PIYORI"] = @animation_stance["CRITICAL"] if
- @animation_stance.include?("CRITICAL")
- @animation_stance["PIYORI"] = @animation_stance["IDLE"] unless
- @animation_stance.include?("PIYORI")
- @animation_stance["STASIS"] = @animation_stance["IDLE"] unless
- @animation_stance.include?("STASIS")
- end
- end
- #--------------------------------------------------------------------------
- # common cache: yem_cache_enemy_bem
- #--------------------------------------------------------------------------
- def yem_cache_enemy_bem
- return if @cached_enemy_bem; @cached_enemy_bem = true
- create_default_enemy_values
- self.note.split(/[\r\n]+/).each { |line|
- case line
- #---
- when YEM::REGEXP::ENEMY::CHARSET1
- @character_name = $1.to_s
- @character_index = [$2.to_i, 7].min
- @battler_name = ""
- when YEM::REGEXP::ENEMY::CHARSET0
- @character_name = $1.to_s
- @character_name
- @battler_name = ""
- when YEM::REGEXP::ENEMY::WEAPON
- $1.scan(/\d+/).each { |num|
- @weapons.push($data_weapons[num.to_i]) if num.to_i > 0 }
- when YEM::REGEXP::ENEMY::SHIELD
- @shield = $data_armors[$1.to_i]
- #---
- when YEM::REGEXP::ENEMY::ATTACK_ANIMATION
- @attack_animation = $1.to_i
- #---
- when YEM::REGEXP::ENEMY::ANIMATION_STANCE
- @animation_stance[$1.upcase] = $2.to_i
- when YEM::REGEXP::ENEMY::STANCE_HUE
- @animation_hue = $1.to_i
- #---
- when YEM::REGEXP::ENEMY::ENEMY_ICON
- @enemy_icon = $1.to_i
- when YEM::REGEXP::ENEMY::ENEMY_ICON_HUE
- @enemy_icon_hue = $1.to_i
- when YEM::REGEXP::ENEMY::STATE_ANI_ZOOM
- @state_zoom = $1.to_i
- #---
- when YEM::REGEXP::ENEMY::EMPTYVIEW_MIRROR
- @view_mirror[:empty] = true
- when YEM::REGEXP::ENEMY::FRONTVIEW_MIRROR
- @view_mirror[:front] = true
- when YEM::REGEXP::ENEMY::SIDEVIEW_MIRROR
- @view_mirror[:side] = true
- when YEM::REGEXP::ENEMY::ANGLEVIEW_MIRROR
- @view_mirror[:angle] = true
- #---
- when YEM::REGEXP::ENEMY::EMPTYVIEW_ZOOM
- @view_zoom[:empty] = $1.to_i * 0.01
- when YEM::REGEXP::ENEMY::FRONTVIEW_ZOOM
- @view_zoom[:front] = $1.to_i * 0.01
- when YEM::REGEXP::ENEMY::SIDEVIEW_ZOOM
- @view_zoom[:side] = $1.to_i * 0.01
- when YEM::REGEXP::ENEMY::ANGLEVIEW_ZOOM
- @view_zoom[:angle] = $1.to_i * 0.01
- #---
- when YEM::REGEXP::ENEMY::PTB_TURNS
- @ptb_turns = $1.to_i
- when YEM::REGEXP::ENEMY::PTB_MAX_CANCEL
- @ptb_max_cancel = $1.to_i
- when YEM::REGEXP::ENEMY::PTB_MAX_REGAIN
- @ptb_max_regain = $1.to_i
- #---
- when YEM::REGEXP::ENEMY::ATB_CHANGE_SET
- @atb_change_set = $1.to_i
- when YEM::REGEXP::ENEMY::ATB_CHANGE_PER
- @atb_change_per = $1.to_i
- when YEM::REGEXP::ENEMY::ATB_RESET
- @atb_reset = $1.to_i
- #---
- when YEM::REGEXP::ENEMY::CTB_CHANGE_SET
- @ctb_change_set = $1.to_i
- when YEM::REGEXP::ENEMY::CTB_CHANGE_PER
- @ctb_change_per = $1.to_i
- when YEM::REGEXP::ENEMY::CTB_RESET
- @ctb_reset = $1.to_i
- #---
- when YEM::REGEXP::ENEMY::DAMAGE_FORMULA
- @damage_formula.push($1.to_s.upcase)
- #---
- when YEM::REGEXP::BASEITEM::TRAITS
- case $1.upcase
- when "SUPER GUARD", "SUPER_GUARD", "SUPERGUARD"
- @traits.push(:super_guard)
- when "FAST ATTACK", "FAST_ATTACK", "FASTATTACK"
- @traits.push(:fast_attack)
- when "DUAL ATTACK", "DUALATTACK", "DUAL_ATTACK"
- @traits.push(:dual_attack)
- when "PREVENT_CRITICAL", "PREVENT CRITICAL", "PREVENT CRI"
- @traits.push(:prevent_critical)
- when "HALF MP COST", "HALF_MP_COST", "HALF MP", "HALF_MP", "HALFMP"
- @traits.push(:half_mp_cost)
- when "ANTI HP REGEN", "ANTI_HP_REGEN"
- @traits.push(:anti_hp_regen)
- when "ANTI HP DEGEN", "ANTI_HP_DEGEN"
- @traits.push(:anti_hp_degen)
- when "ANTI MP REGEN", "ANTI_MP_REGEN"
- @traits.push(:anti_mp_regen)
- when "ANTI MP DEGEN", "ANTI_MP_DEGEN"
- @traits.push(:anti_mp_degen)
- else; next
- end
- #---
- when YEM::REGEXP::ENEMY::GAUGE_WIDTH
- @quick_gauge[:width] = $1.to_i + 32
- when YEM::REGEXP::ENEMY::HIDE_GAUGE
- case $1.upcase
- when "HIDE"
- setting = false
- when "SHOW"
- setting = true
- else; next
- end
- case $2.upcase
- when "STATE", "STATES"
- @quick_gauge[:states] = setting
- when "HP"
- @quick_gauge[:show_hp] = setting
- when "MP", "SP"
- @quick_gauge[:show_mp] = setting
- else; next
- end
- when YEM::REGEXP::ENEMY::HP_GAUGE
- @quick_gauge[:hp_gauge1] = $1.to_i
- @quick_gauge[:hp_gauge2] = $2.to_i
- when YEM::REGEXP::ENEMY::MP_GAUGE
- @quick_gauge[:mp_gauge1] = $1.to_i
- @quick_gauge[:mp_gauge2] = $2.to_i
- #---
- when YEM::REGEXP::ENEMY::ATK_ELE
- $1.scan(/\d+/).each { |num|
- @attack_element.push(num.to_i) if num.to_i > 0 }
- #---
- when YEM::REGEXP::ENEMY::ATK_STA
- $1.scan(/\d+/).each { |num|
- @attack_state.push(num.to_i) if num.to_i > 0 }
- when YEM::REGEXP::ENEMY::UNMOVING
- @unmoving = true
- #---
- end
- } # self.note.split
- finish_default_enemy_values
- #--- Melody REGEXP ---
- create_default_action_codes
- self.note.split(/[\r\n]+/).each { |line|
- case line
- #---
- when YEM::REGEXP::ANI::ACTION_COPY
- case $1.upcase
- when "I", "ITEM"
- obj = $data_items[$2.to_i]
- next if obj == nil
- obj.yem_cache_baseitem_bem
- when "S", "SKILL"
- obj = $data_skills[$2.to_i]
- next if obj == nil
- obj.yem_cache_baseitem_bem
- when "W", "WEAPON"
- obj = $data_weapons[$2.to_i]
- next if obj == nil
- obj.yem_cache_baseitem_bem
- when "A", "ARMOR", "ARMOUR"
- obj = $data_armors[$2.to_i]
- next if obj == nil
- obj.yem_cache_baseitem_bem
- when "E", "ENEMY"
- obj = $data_enemies[$2.to_i]
- next if obj == nil
- obj.yem_cache_enemy_bem
- else; next
- end
- @setup_action_list = obj.setup_action_list.clone
- @whole_action_list = obj.whole_action_list.clone
- @target_action_list = obj.target_action_list.clone
- @follow_action_list = obj.follow_action_list.clone
- @finish_action_list = obj.finish_action_list.clone
- @guard_action_list = obj.guard_action_list.clone
- #---
- when YEM::REGEXP::ANI::SETUP_ANI_ON
- @melody_line = true
- @setup_action_list = []
- @setup_action_flag = true
- when YEM::REGEXP::ANI::SETUP_ANI_OFF
- @melody_line = false
- @setup_action_flag = false
- when YEM::REGEXP::ANI::WHOLE_ANI_ON
- @melody_line = true
- @whole_action_list = []
- @whole_action_flag = true
- when YEM::REGEXP::ANI::WHOLE_ANI_OFF
- @melody_line = false
- @whole_action_flag = false
- when YEM::REGEXP::ANI::TARGET_ANI_ON
- @melody_line = true
- @target_action_list = []
- @target_action_flag = true
- when YEM::REGEXP::ANI::TARGET_ANI_OFF
- @melody_line = false
- @target_action_flag = false
- when YEM::REGEXP::ANI::FOLLOW_ANI_ON
- @melody_line = true
- @follow_action_list = []
- @follow_action_flag = true
- when YEM::REGEXP::ANI::FOLLOW_ANI_OFF
- @melody_line = false
- @follow_action_flag = false
- when YEM::REGEXP::ANI::FINISH_ANI_ON
- @melody_line = true
- @finish_action_list = []
- @finish_action_flag = true
- when YEM::REGEXP::ANI::FINISH_ANI_OFF
- @melody_line = false
- @finish_action_flag = false
- #---
- when YEM::REGEXP::ANI::GUARD_ANI_ON
- @melody_line = true
- @guard_action_list = []
- @guard_action_flag = true
- when YEM::REGEXP::ANI::GUARD_ANI_OFF
- @melody_line = false
- @guard_action_flag = false
- #---
- else
- next unless @melody_line
- case line
- when YEM::REGEXP::ANI::ANI_TYPE_S6
- type = $1
- value = [$2, $3, $4, $5, $6, $7]
- when YEM::REGEXP::ANI::ANI_TYPE_S5
- type = $1
- value = [$2, $3, $4, $5, $6]
- when YEM::REGEXP::ANI::ANI_TYPE_S4
- type = $1
- value = [$2, $3, $4, $5]
- when YEM::REGEXP::ANI::ANI_TYPE_S3
- type = $1
- value = [$2, $3, $4]
- when YEM::REGEXP::ANI::ANI_TYPE_S2
- type = $1
- value = [$2, $3]
- when YEM::REGEXP::ANI::ANI_TYPE_S1
- type = $1
- value = [$2]
- when YEM::REGEXP::ANI::ANI_TYPE_S0
- type = $1
- value = [nil]
- else; next
- end
- case type.upcase
- when /IF[ ](.*)/i, /UNLESS[ ](.*)/i, /ELSIF[ ](.*)/i
- ignore_upcase = true
- when "MESSAGE", "SCRIPT", "SCRIPT CALL", "POPUP"
- type = type.upcase
- ignore_upcase = true
- when /CHANGE[ ](?:VARIABLE|VAR)[ ](.*)/i
- else
- type = type.upcase
- ignore_upcase = false
- end
- for i in 0..(value.size-1)
- next if value[i] == nil
- next if ignore_upcase
- next if value[i] == /IF[ ](.*)/i
- next if value[i] == /UNLESS[ ](.*)/i
- value[i] = value[i].to_s.upcase
- end
- array = [type, value]
- if @setup_action_flag
- @setup_action_list[@setup_action_list.size] = array
- elsif @whole_action_flag
- @whole_action_list[@whole_action_list.size] = array
- elsif @target_action_flag
- @target_action_list[@target_action_list.size] = array
- elsif @follow_action_flag
- @follow_action_list[@follow_action_list.size] = array
- elsif @finish_action_flag
- @finish_action_list[@finish_action_list.size] = array
- elsif @guard_action_flag
- @guard_action_list[@guard_action_list.size] = array
- end
- end
- } # self.note.split
- #--- Melody REGEXP ---
- end # yem_cache_enemy_bem
- #--------------------------------------------------------------------------
- # new method: create_default_action_codes
- #--------------------------------------------------------------------------
- def create_default_action_codes
- @setup_action_list = YEM::DEFAULT_ACTIONS::ATTACK_SETUP
- @whole_action_list = YEM::DEFAULT_ACTIONS::ATTACK_WHOLE
- @target_action_list = YEM::DEFAULT_ACTIONS::ATTACK_TARGET
- @follow_action_list = YEM::DEFAULT_ACTIONS::ATTACK_FOLLOW
- @finish_action_list = YEM::DEFAULT_ACTIONS::ATTACK_FINISH
- @guard_action_list = YEM::DEFAULT_ACTIONS::GUARD_ACTIONS
- end
- end # RPG::Enemy
- #===============================================================================
- # RPG::State
- #===============================================================================
- class RPG::State
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :popup_rules
- attr_accessor :state_type
- attr_accessor :state_ani
- attr_accessor :restrict_skill
- attr_accessor :restrict_item
- attr_accessor :ptb_bonus
- attr_accessor :ptb_max_cancel
- attr_accessor :ptb_max_regain
- attr_accessor :atb_reset_plus
- attr_accessor :ctb_reset_plus
- attr_accessor :dmg_taken_rate
- attr_accessor :dmg_bonus_rate
- attr_accessor :dmg_wall
- attr_accessor :slip_effect
- attr_accessor :rage_boost
- attr_accessor :stack
- attr_accessor :lunatic_effects
- attr_accessor :cost_per
- attr_accessor :cost_set
- attr_accessor :maxhp_rate
- attr_accessor :maxmp_rate
- attr_accessor :hit_rate
- attr_accessor :eva_rate
- attr_accessor :cri_rate
- attr_accessor :odds_rate
- attr_accessor :maxhp_set
- attr_accessor :maxmp_set
- attr_accessor :atk_set
- attr_accessor :def_set
- attr_accessor :spi_set
- attr_accessor :agi_set
- attr_accessor :hit_set
- attr_accessor :eva_set
- attr_accessor :cri_set
- attr_accessor :odds_set
- attr_accessor :traits
- attr_accessor :element_rank
- attr_accessor :state_rank
- attr_accessor :attack_element
- attr_accessor :attack_state
- attr_accessor :element_rank_add
- attr_accessor :state_rank_add
- attr_accessor :element_rank_rev
- attr_accessor :state_rank_rev
- attr_accessor :element_rate_set
- attr_accessor :state_rate_set
- attr_accessor :element_rate_per
- attr_accessor :state_rate_per
- attr_accessor :weapon_icon
- attr_accessor :attack_animation
- #--------------------------------------------------------------------------
- # new method: create_default_state_values
- #--------------------------------------------------------------------------
- def create_default_state_values
- @popup_rules = {
- :add => "ADDSTATE",
- :rem => "REMSTATE",
- :dur => nil }
- #---
- @state_ani = 0
- @state_type = ["ALL"]
- @restrict_skill = []
- @restrict_item = []
- #---
- @ptb_bonus = 0
- @ptb_max_cancel = 0
- @ptb_max_regain = 0
- @atb_reset_plus = 0
- @ctb_reset_plus = 0
- #---
- @dmg_taken_rate = {}
- @dmg_bonus_rate = {}
- @dmg_wall = {}
- @rage_boost = {}
- #---
- @lunatic_effects = {}
- @slip_effect = {}
- @slip_effect[:hp_degen_per] = 10 if @slip_damage
- @stack = 1
- @maxhp_rate = 100
- @maxmp_rate = 100
- @hit_rate = 100
- @eva_rate = 100
- @cri_rate = 100
- @odds_rate = 100
- @maxhp_set = 0
- @maxmp_set = 0
- @atk_set = 0
- @def_set = 0
- @spi_set = 0
- @agi_set = 0
- @hit_set = 0
- @eva_set = 0
- @cri_set = 0
- @odds_set = 0
- @traits = []
- @cost_per = {}
- @cost_set = {}
- #---
- @element_rank = {}
- @state_rank = {}
- @attack_element = []
- @attack_state = []
- @element_rank_add = {}
- @state_rank_add = {}
- @element_rank_rev = []
- @state_rank_rev = []
- @element_rate_set = {}
- @state_rate_set = {}
- @element_rate_per = {}
- @state_rate_per = {}
- @weapon_icon = 0
- @attack_animation = 0
- end
- #--------------------------------------------------------------------------
- # new method: finish_default_state_values
- #--------------------------------------------------------------------------
- def finish_default_state_values
- @lunatic_effects[:apply] = [] if @lunatic_effects[:apply] == nil
- @lunatic_effects[:apply].push("COMMON APPLY")
- @lunatic_effects[:erase] = [] if @lunatic_effects[:erase] == nil
- @lunatic_effects[:erase].push("COMMON ERASE")
- @lunatic_effects[:leave] = [] if @lunatic_effects[:leave] == nil
- @lunatic_effects[:leave].push("COMMON LEAVE")
- @lunatic_effects[:react] = [] if @lunatic_effects[:react] == nil
- @lunatic_effects[:react].push("COMMON REACT")
- @lunatic_effects[:shock] = [] if @lunatic_effects[:shock] == nil
- @lunatic_effects[:shock].push("COMMON APPLY")
- @lunatic_effects[:begin] = [] if @lunatic_effects[:begin] == nil
- @lunatic_effects[:begin].push("COMMON BEGIN")
- @lunatic_effects[:while] = [] if @lunatic_effects[:while] == nil
- @lunatic_effects[:while].push("COMMON WHILE")
- @lunatic_effects[:close] = [] if @lunatic_effects[:close] == nil
- @lunatic_effects[:close].push("COMMON CLOSE")
- end
- #--------------------------------------------------------------------------
- # common cache: yem_cache_state_bem
- #--------------------------------------------------------------------------
- def yem_cache_state_bem
- return if @cached_state_bem; @cached_state_bem = true
- create_default_state_values
- self.note.split(/[\r\n]+/).each { |line|
- case line
- #---
- when YEM::REGEXP::STATE::POPUP_ADD
- @popup_rules[:add] = $1.to_s
- when YEM::REGEXP::STATE::POPUP_REM
- @popup_rules[:rem] = $1.to_s
- when YEM::REGEXP::STATE::POPUP_DUR
- @popup_rules[:dur] = $1.to_s
- when YEM::REGEXP::STATE::HIDE_ADD
- @popup_rules[:add] = nil
- when YEM::REGEXP::STATE::HIDE_REM
- @popup_rules[:rem] = nil
- when YEM::REGEXP::STATE::HIDE_DUR
- @popup_rules[:dur] = nil
- #---
- when YEM::REGEXP::STATE::STATE_TYPE
- @state_type.push($1.upcase) unless type?($1.upcase)
- when YEM::REGEXP::STATE::STATE_ANI
- @state_ani = $1.to_i
- when YEM::REGEXP::STATE::RESTRICT_SKILL
- type = $1.upcase
- @restrict_skill.push(type) unless @restrict_skill.include?(type)
- when YEM::REGEXP::STATE::RESTRICT_ITEM
- type = $1.upcase
- @restrict_item.push(type) unless @restrict_item.include?(type)
- #---
- when YEM::REGEXP::STATE::PTB_BONUS
- @ptb_bonus = $1.to_i
- when YEM::REGEXP::STATE::PTB_MAX_CANCEL
- @ptb_max_cancel = $1.to_i
- when YEM::REGEXP::STATE::PTB_MAX_REGAIN
- @ptb_max_regain = $1.to_i
- #---
- when YEM::REGEXP::STATE::ATB_RESET_PLUS
- @atb_reset_plus = $1.to_i
- #---
- when YEM::REGEXP::STATE::DMG_TAKEN
- case $1.upcase
- when "HP DMG", "HP DAMAGE"
- temp = :hp_dmg
- when "MP DMG", "MP DAMAGE", "SP DMG", "SP DAMAGE"
- temp = :mp_dmg
- when "HP HEAL", "HP HEALING"
- temp = :hp_heal
- when "MP HEAL", "MP HEALING", "SP HEAL", "SP HEALING"
- temp = :mp_heal
- else; next
- end
- @dmg_taken_rate[temp] = $2.to_i
- when YEM::REGEXP::STATE::DMG_BONUS
- case $1.upcase
- when "HP DMG", "HP DAMAGE"
- temp = :hp_dmg
- when "MP DMG", "MP DAMAGE", "SP DMG", "SP DAMAGE"
- temp = :mp_dmg
- when "HP HEAL", "HP HEALING"
- temp = :hp_heal
- when "MP HEAL", "MP HEALING", "SP HEAL", "SP HEALING"
- temp = :mp_heal
- else; next
- end
- @dmg_bonus_rate[temp] = $2.to_i
- when YEM::REGEXP::STATE::DMG_WALL
- case $1.upcase
- when "HP DMG", "HP DAMAGE"
- temp = :hp_dmg
- when "MP DMG", "MP DAMAGE", "SP DMG", "SP DAMAGE"
- temp = :mp_dmg
- when "HP HEAL", "HP HEALING"
- temp = :hp_heal
- when "MP HEAL", "MP HEALING", "SP HEAL", "SP HEALING"
- temp = :mp_heal
- else; next
- end
- @dmg_wall[temp] = $2.to_i
- #---
- when YEM::REGEXP::STATE::RAGE_BOOST_PER
- @rage_boost[:per] = $1.to_i
- when YEM::REGEXP::STATE::RAGE_BOOST_SET
- @rage_boost[:set] = $1.to_i
- #---
- when YEM::REGEXP::STATE::SLIP_SET
- case $1.upcase
- when "HP"
- case $2.upcase
- when "DEGEN"
- @slip_effect[:hp_degen_set] = $3.to_i
- when "REGEN"
- @slip_effect[:hp_degen_set] = -$3.to_i
- end
- when "MP"
- case $2.upcase
- when "DEGEN"
- @slip_effect[:mp_degen_set] = $3.to_i
- when "REGEN"
- @slip_effect[:mp_degen_set] = -$3.to_i
- end
- else; return
- end
- @slip_damage = true
- when YEM::REGEXP::STATE::SLIP_PER
- case $1.upcase
- when "HP"
- case $2.upcase
- when "DEGEN"
- @slip_effect[:hp_degen_per] = $3.to_i
- when "REGEN"
- @slip_effect[:hp_degen_per] = -$3.to_i
- end
- when "MP"
- case $2.upcase
- when "DEGEN"
- @slip_effect[:mp_degen_per] = $3.to_i
- when "REGEN"
- @slip_effect[:mp_degen_per] = -$3.to_i
- end
- else; return
- end
- @slip_damage = true
- #---
- when YEM::REGEXP::STATE::MAX_STACK
- @stack = [$1.to_i, 1].max
- #---
- when YEM::REGEXP::STATE::TRAITS
- case $1.upcase
- when "SUPER GUARD", "SUPER_GUARD", "SUPERGUARD"
- @traits.push(:super_guard)
- when "PHARMACOLOGY", "PHARMA", "ITEM BOOST", "ITEM_BOOST"
- @traits.push(:pharmacology)
- when "FAST ATTACK", "FAST_ATTACK", "FASTATTACK"
- @traits.push(:fast_attack)
- when "DUAL ATTACK", "DUALATTACK", "DUAL_ATTACK"
- @traits.push(:dual_attack)
- when "PREVENT_CRITICAL", "PREVENT CRITICAL", "PREVENT CRI"
- @traits.push(:prevent_critical)
- when "HALF MP COST", "HALF_MP_COST", "HALF MP", "HALF_MP", "HALFMP"
- @traits.push(:half_mp_cost)
- when "DOUBLE EXP GAIN", "DOUBLE_EXP_GAIN", "DOUBLE EXP", "DOUBLE_EXP"
- @traits.push(:double_exp_gain)
- when "AUTO_HP_RECOVER", "AUTO HP RECOVER", "AUTO HP", "AUTO_HP"
- @traits.push(:auto_hp_recover)
- when "ANTI HP REGEN", "ANTI_HP_REGEN"
- @traits.push(:anti_hp_regen)
- when "ANTI HP DEGEN", "ANTI_HP_DEGEN"
- @traits.push(:anti_hp_degen)
- when "ANTI MP REGEN", "ANTI_MP_REGEN"
- @traits.push(:anti_mp_regen)
- when "ANTI MP DEGEN", "ANTI_MP_DEGEN"
- @traits.push(:anti_mp_degen)
- else; next
- end
- #---
- when YEM::REGEXP::STATE::COST_PER
- name = $1.upcase
- case name
- when "SP"; name = "MP"
- when "LP"; name = "HP"
- end
- @cost_per[name] = $2.to_i
- when YEM::REGEXP::STATE::COST_SET
- name = $1.upcase
- case name
- when "SP"; name = "MP"
- when "LP"; name = "HP"
- end
- @cost_set[name] = $2.to_i
- #---
- when YEM::REGEXP::STATE::CUSTOM_APPLY
- string = $1.upcase; type = :apply
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- when YEM::REGEXP::STATE::CUSTOM_ERASE
- string = $1.upcase; type = :erase
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- when YEM::REGEXP::STATE::CUSTOM_LEAVE
- string = $1.upcase; type = :leave
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- when YEM::REGEXP::STATE::CUSTOM_REACT
- string = $1.upcase; type = :react
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- when YEM::REGEXP::STATE::CUSTOM_SHOCK
- string = $1.upcase; type = :shock
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- when YEM::REGEXP::STATE::CUSTOM_BEGIN
- string = $1.upcase; type = :begin
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- when YEM::REGEXP::STATE::CUSTOM_WHILE
- string = $1.upcase; type = :while
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- when YEM::REGEXP::STATE::CUSTOM_CLOSE
- string = $1.upcase; type = :close
- @lunatic_effects[type] = [] if @lunatic_effects[type] == nil
- @lunatic_effects[type].push(string)
- #---
- when YEM::REGEXP::STATE::SET_ELE_RT
- if $1.to_i != 0
- @element_rate_set[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_system.elements.size - 1)
- @element_rate_set[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::STATE::PER_ELE_RT
- if $1.to_i != 0
- @element_rate_per[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_system.elements.size - 1)
- @element_rate_per[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::STATE::ADD_ELE_RK
- if $1.to_i != 0
- @element_rank_add[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_system.elements.size - 1)
- @element_rank_add[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::STATE::SET_ELE_RK
- case $2.upcase
- when "S", "Z"; value = 0
- when "A"; value = 1
- when "B"; value = 2
- when "C"; value = 3
- when "D"; value = 4
- when "E"; value = 5
- when "F"; value = 6
- else; next
- end
- if $1.to_i != 0
- @element_rank[$1.to_i] = value
- elsif $1.upcase == "ALL"
- for i in 1..($data_system.elements.size - 1)
- @element_rank[i] = value
- end
- end
- #---
- when YEM::REGEXP::STATE::SET_STA_RT
- if $1.to_i != 0
- @state_rate_set[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_states.size - 1)
- @state_rate_set[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::STATE::PER_STA_RT
- if $1.to_i != 0
- @state_rate_per[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_states.size - 1)
- @state_rate_per[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::STATE::ADD_STA_RK
- if $1.to_i != 0
- @state_rank_add[$1.to_i] = $2.to_i
- elsif $1.upcase == "ALL"
- for i in 1..($data_states.size - 1)
- @state_rank_add[i] = $2.to_i
- end
- end
- #---
- when YEM::REGEXP::STATE::SET_STA_RK
- case $2.upcase
- when "S", "Z"; value = 0
- when "A"; value = 1
- when "B"; value = 2
- when "C"; value = 3
- when "D"; value = 4
- when "E"; value = 5
- when "F"; value = 6
- else; next
- end
- if $1.to_i != 0
- @state_rank[$1.to_i] = value
- elsif $1.upcase == "ALL"
- for i in 1..($data_states.size - 1)
- @state_rank[i] = value
- end
- end
- #---
- when YEM::REGEXP::STATE::ATK_ELE
- $1.scan(/\d+/).each { |num|
- @attack_element.push(num.to_i) if num.to_i > 0 }
- when YEM::REGEXP::STATE::ATK_STA
- $1.scan(/\d+/).each { |num|
- @attack_state.push(num.to_i) if num.to_i > 0 }
- #---
- when YEM::REGEXP::STATE::WEAPON_ICON
- @weapon_icon = $1.to_i
- when YEM::REGEXP::STATE::ATTACK_ANI
- @attack_animation = $1.to_i
- #--- Make sure this remains at the bottom of the list.
- when YEM::REGEXP::STATE::STAT_PER
- case $1.upcase
- when "MAXHP"
- @maxhp_rate = $2.to_i
- when "MAXMP", "MAXSP"
- @maxmp_rate = $2.to_i
- when "ATK"
- @atk_rate = $2.to_i
- when "DEF"
- @def_rate = $2.to_i
- when "SPI", "INT"
- @spi_rate = $2.to_i
- when "AGI"
- @agi_rate = $2.to_i
- when "HIT"
- @hit_rate = $2.to_i
- when "EVA"
- @eva_rate = $2.to_i
- when "CRI"
- @cri_rate = $2.to_i
- when "ODDS", "AGR", "AGGRO"
- @odds_rate = $2.to_i
- else; next
- end
- when YEM::REGEXP::STATE::STAT_SET
- case $1.upcase
- when "MAXHP"
- @maxhp_set = $2.to_i
- when "MAXMP", "MAXSP"
- @maxmp_set = $2.to_i
- when "ATK"
- @atk_set = $2.to_i
- when "DEF"
- @def_set = $2.to_i
- when "SPI", "INT"
- @spi_set = $2.to_i
- when "AGI"
- @agi_set = $2.to_i
- when "HIT"
- @hit_set = $2.to_i
- when "EVA"
- @eva_set = $2.to_i
- when "CRI"
- @cri_set = $2.to_i
- when "ODDS", "AGR", "AGGRO"
- @odds_set = $2.to_i
- else; next
- end
- #---
- end
- } # end self.note.split
- finish_default_state_values
- end # end yem_cache_state_bem
- #--------------------------------------------------------------------------
- # new method: type?
- #--------------------------------------------------------------------------
- def type?(name); return @state_type.include?(name.upcase); end
- end # RPG::State
- #===============================================================================
- # RPG::Animation
- #===============================================================================
- class RPG::Animation
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :anti_mirror
- attr_accessor :battler_looping
- #--------------------------------------------------------------------------
- # common cache: yem_cache_animation_bem
- #--------------------------------------------------------------------------
- def yem_cache_animation_bem
- @battler_looping = true
- @anti_mirror = false
- #---
- case name
- when /\[(?:NO_LOOP|NOLOOP|NO LOOP)\]/i
- @battler_looping = false
- when /\[(?:NO_MIRROR|NOMIRROR|NO MIRROR)\]/i
- @anti_mirror = true
- end
- end
- end # RPG::Animation
- #===============================================================================
- # RPG::Troop
- #===============================================================================
- class RPG::Troop
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :strike_case
- #--------------------------------------------------------------------------
- # common cache: yem_cache_troop_bem
- #--------------------------------------------------------------------------
- def yem_cache_troop_bem
- @strike_case = 0
- #---
- case @name
- when /\[(?:NORMAL|NO SURPRISE|NO PREEMPTIVE)\]/i
- @strike_case = 1
- when /\[(?:PREEMPTIVE|PRE EMPTIVE|FIRST STRIKE)\]/i
- @strike_case = 2
- when /\[(?:SURPRISE|SURPRISED|BACK ATTACK)\]/i
- @strike_case = 3
- end
- end
- end # RPG::Troop
- #===============================================================================
- # Scene_Title
- #===============================================================================
- class Scene_Title < Scene_Base
- #--------------------------------------------------------------------------
- # alias method: load_bt_database
- #--------------------------------------------------------------------------
- alias load_bt_database_bem load_bt_database unless $@
- def load_bt_database
- load_bt_database_bem
- load_bem_cache
- end
- #--------------------------------------------------------------------------
- # alias method: load_database
- #--------------------------------------------------------------------------
- alias load_database_bem load_database unless $@
- def load_database
- load_database_bem
- load_bem_cache
- end
- #--------------------------------------------------------------------------
- # new method: load_bem_cache
- #--------------------------------------------------------------------------
- def load_bem_cache
- groups = [$data_skills, $data_items, $data_weapons, $data_armors,
- $data_enemies, $data_states, $data_animations, $data_troops]
- for group in groups
- for obj in group
- next if obj == nil
- obj.yem_cache_enemy_bem if obj.is_a?(RPG::Enemy)
- obj.yem_cache_state_bem if obj.is_a?(RPG::State)
- obj.yem_cache_baseitem_bem if obj.is_a?(RPG::BaseItem)
- obj.yem_cache_usableitem_bem if obj.is_a?(RPG::UsableItem)
- obj.yem_cache_animation_bem if obj.is_a?(RPG::Animation)
- obj.yem_cache_troop_bem if obj.is_a?(RPG::Troop)
- end
- end
- end
- #--------------------------------------------------------------------------
- # alias method: create_game_objects
- #--------------------------------------------------------------------------
- alias create_game_objects_bem create_game_objects unless $@
- def create_game_objects
- create_game_objects_bem
- $game_system.create_battle_options
- $game_temp.atk_effects = ["calc", "dmg", "state", "effect", "collapse"]
- $game_temp.skill_effects = ["calc", "dmg", "state", "effect", "collapse"]
- $game_temp.item_effects = ["calc", "growth", "dmg", "state", "effect",
- "collapse"]
- end
- #--------------------------------------------------------------------------
- # alias method: command_new_game
- #--------------------------------------------------------------------------
- alias command_new_game_bem command_new_game unless $@
- def command_new_game
- command_new_game_bem
- $game_system.create_battle_options
- end
- end # Scene_Title
- #===============================================================================
- # Scene_File
- #===============================================================================
- class Scene_File < Scene_Base
- #--------------------------------------------------------------------------
- # alias method: do_load
- #--------------------------------------------------------------------------
- alias do_load_bem do_load unless $@
- def do_load
- do_load_bem
- $game_party.battle_items_cache = nil
- $game_party.clear_caches
- end
- end # Scene_File
- #===============================================================================
- # Game_Temp
- #===============================================================================
- class Game_Temp
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :action_elements
- attr_accessor :atk_effects
- attr_accessor :force_critical
- attr_accessor :hp_damage_inflate
- attr_accessor :iconset
- attr_accessor :item_effects
- attr_accessor :less_spacing
- attr_accessor :mp_damage_inflate
- attr_accessor :perfect_hit
- attr_accessor :skill_effects
- #--------------------------------------------------------------------------
- # alias method: initialize
- #--------------------------------------------------------------------------
- alias initialize_game_temp_bem initialize unless $@
- def initialize
- initialize_game_temp_bem
- @iconset = Cache.system("Iconset")
- end
- end # Game_Temp
- #===============================================================================
- # Game_System
- #===============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- # new method: create_battle_options
- #--------------------------------------------------------------------------
- def create_battle_options
- return if @created_battle_options
- @created_battle_options = true
- #--- View and Battle Types ---
- $game_variables[YEM::BATTLE_ENGINE::VIEW_TYPE_VARIABLE] =
- YEM::BATTLE_ENGINE::DEFAULT_VIEW
- $game_variables[YEM::BATTLE_ENGINE::BATTLE_TYPE_VARIABLE] =
- YEM::BATTLE_ENGINE::DEFAULT_TYPE
- #--- Option Commands ---
- options = YEM::BATTLE_ENGINE::OPTIONS
- atb = YEM::BATTLE_ENGINE::ATB_RULES
- $game_variables[options[:bgm_variable]] = 100
- $game_variables[options[:bgs_variable]] = 100
- $game_variables[options[:sfx_variable]] = 100
- $game_variables[options[:atb_avariable]] = atb[:default_type]
- $game_variables[options[:atb_svariable]] = atb[:default_speed]
- $game_switches[options[:bgm_mute_sw]] = false
- $game_switches[options[:bgs_mute_sw]] = false
- $game_switches[options[:sfx_mute_sw]] = false
- $game_switches[options[:animation_sw]] = true
- $game_switches[options[:autocursor_sw]] = true
- $game_switches[options[:next_actor_sw]] = true
- $game_switches[options[:skill_help_sw]] = false
- end
- end # Game_System
- #===============================================================================
- # Game_Battler
- #===============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # public instance variable
- #--------------------------------------------------------------------------
- attr_accessor :absorbed
- attr_accessor :action
- attr_accessor :atb_speed
- attr_accessor :atb_speed_bonus
- attr_accessor :bonus_element_affinity
- attr_accessor :bonus_state_affinity
- attr_accessor :critical
- attr_accessor :ctb_cache
- attr_accessor :ctb_speed
- attr_accessor :ctb_prediction
- attr_accessor :element_max
- attr_accessor :equip_clocktick
- attr_accessor :hp_damage
- attr_accessor :make_auto_skill
- attr_accessor :mp_damage
- attr_accessor :stored_action
- attr_accessor :ptb_actions
- attr_accessor :ptb_cancel
- attr_accessor :ptb_performed
- attr_accessor :ptb_regain
- attr_accessor :rage
- attr_accessor :state_animation_id
- attr_accessor :temp_immortal
- attr_accessor :turn_count
- attr_accessor :update_maxhp
- attr_accessor :update_maxmp
- attr_accessor :update_states
- attr_accessor :update_commands
- #--------------------------------------------------------------------------
- # alias method: initialize
- #--------------------------------------------------------------------------
- alias initialize_game_battler_bem initialize unless $@
- def initialize
- initialize_game_battler_bem
- @rage = 0
- @state_animation_id = 0
- end
- #--------------------------------------------------------------------------
- # new method: enemy?
- #--------------------------------------------------------------------------
- def enemy?; return false; end
- #--------------------------------------------------------------------------
- # overwrite method: state?
- #--------------------------------------------------------------------------
- def state?(state_id)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- return states.include?($data_states[state_id])
- end
- #--------------------------------------------------------------------------
- # new method: clear_battle_cache
- #--------------------------------------------------------------------------
- def clear_battle_cache
- @cache_ptb = {}
- @cache_rage = {}
- @cache_states = {}
- @cache_params = {}
- @cache_traits = nil
- @cache_skill_costs = {}
- @cache_restrict_skill = nil
- @cache_restrict_item = nil
- @cache_element_rate = {}
- @cache_state_rate = {}
- @cache_element_set = nil
- @cache_state_set = nil
- @cache_weapon_icon = {}
- @cache_atk_animation = {}
- end
- #--------------------------------------------------------------------------
- # alias method: clear_action_results
- #--------------------------------------------------------------------------
- alias clear_action_results_bem clear_action_results unless $@
- def clear_action_results
- clear_action_results_bem
- @element_max = 100
- end
- #--------------------------------------------------------------------------
- # alias method: hp=
- #--------------------------------------------------------------------------
- alias hp_equals_bem hp= unless $@
- def hp=(hp)
- hp_equals_bem(hp)
- @update_commands = true
- $scene.refresh_battle_windows if $scene.is_a?(Scene_Battle)
- end
- #--------------------------------------------------------------------------
- # alias method: mp=
- #--------------------------------------------------------------------------
- alias mp_equals_bem mp= unless $@
- def mp=(mp)
- mp_equals_bem(mp)
- @update_commands = true
- $scene.refresh_battle_windows if $scene.is_a?(Scene_Battle)
- end
- #--------------------------------------------------------------------------
- # overwrite method: make_attack_damage_value
- #--------------------------------------------------------------------------
- def make_attack_damage_value(attacker); make_damage_values(attacker); end
- #--------------------------------------------------------------------------
- # overwrite method: make_obj_damage_value
- #--------------------------------------------------------------------------
- def make_obj_damage_value(user, obj); make_damage_values(user, obj); end
- #--------------------------------------------------------------------------
- # new method: apply_max_min
- #--------------------------------------------------------------------------
- def apply_max_min(damage, type, obj = nil)
- maximum = YEM::BATTLE_ENGINE::MAXIMUM_DMG == nil ? damage :
- YEM::BATTLE_ENGINE::MAXIMUM_DMG
- minimum = YEM::BATTLE_ENGINE::MINIMUM_DMG == nil ? 0 :
- YEM::BATTLE_ENGINE::MINIMUM_DMG
- type = 0 if obj == nil
- #---
- case type
- when 0 # Normal Attack
- damage = [[damage, maximum].min, minimum].max
- when 1 # Damage Skill
- damage = [[damage, maximum].min, minimum].max
- when 2 # Heal Skill
- maximum = YEM::BATTLE_ENGINE::MAXIMUM_DMG == nil ? damage :
- -YEM::BATTLE_ENGINE::MAXIMUM_DMG
- damage = [[damage, maximum].max, minimum].min
- end
- #---
- return damage
- end
- #--------------------------------------------------------------------------
- # new method: apply_element_rate
- #--------------------------------------------------------------------------
- def apply_element_rate(user, damage, obj = nil)
- return damage if damage == 0
- if obj != nil
- set = obj.element_set
- if obj.physical_attack and YEM::BATTLE_ENGINE::APPLY_PHYSICAL_ELE
- set += user.element_set
- elsif YEM::BATTLE_ENGINE::APPLY_MAGICAL_ELE
- set += user.element_set
- end
- else
- set = user.element_set
- end
- set = $game_temp.action_elements if $game_temp.action_elements != nil
- damage *= elements_max_rate(set)
- damage /= 100
- return damage
- end
- #--------------------------------------------------------------------------
- # new method: apply_state_rates
- #--------------------------------------------------------------------------
- def apply_state_rates(value, user, stat)
- case stat
- when :hp
- temp = value > 0 ? :hp_dmg : :hp_heal
- when :mp
- temp = value > 0 ? :mp_dmg : :mp_heal
- else; return value
- end
- for state in user.states
- next unless state.dmg_bonus_rate.include?(temp)
- stack(state).times do
- value = value * state.dmg_bonus_rate[temp] / 100
- end
- end
- for state in self.states
- next unless state.dmg_taken_rate.include?(temp)
- stack(state).times do
- value = value * state.dmg_taken_rate[temp] / 100
- end
- end
- return value
- end
- #--------------------------------------------------------------------------
- # new method: apply_damage_wall
- #--------------------------------------------------------------------------
- def apply_damage_wall(value, stat)
- case stat
- when :hp
- temp = value > 0 ? :hp_dmg : :hp_heal
- when :mp
- temp = value > 0 ? :mp_dmg : :mp_heal
- else; return value
- end
- heal = value > 0 ? false : true
- for state in self.states
- next unless state.dmg_wall.include?(temp)
- bonus = state.dmg_wall[temp] * stack(state)
- value = [(value + bonus), 0].max if !heal
- value = [(value + bonus), 0].min if heal
- end
- return value
- end
- #--------------------------------------------------------------------------
- # new method: apply_state_rank
- #--------------------------------------------------------------------------
- def apply_state_rank(state_id)
- if actor?
- rank = self.class.state_ranks[state_id]
- else
- rank = enemy.state_ranks[state_id]
- end
- result = []
- #---
- if actor?
- for equip in equips.compact
- next unless equip.state_rank.include?(state_id)
- result.push(equip.state_rank[state_id])
- end
- end
- #---
- for state in states
- next unless state.state_rank.include?(state_id)
- result.push(state.state_rank[state_id])
- end
- #---
- rank = result.min if result != []
- #---
- if actor?
- for equip in equips.compact
- next unless equip.state_rank_add.include?(state_id)
- rank += equip.state_rank_add[state_id]
- end
- end
- #---
- for state in states
- next unless state.state_rank_add.include?(state_id)
- rank += state.state_rank_add[state_id] * stack(state)
- end
- #---
- rank = [[rank, 0].max, 6].min
- for state in states
- next unless state.state_rank_rev.include?(state_id)
- case rank
- when 0; rank = 6
- when 1; rank = 5
- when 2; rank = 4
- when 4; rank = 2
- when 5; rank = 1
- when 6; rank = 0
- end
- break
- end
- return rank
- end
- #--------------------------------------------------------------------------
- # new method: state_probability_table
- #--------------------------------------------------------------------------
- def state_probability_table(state_id, rank)
- if YEM::BATTLE_ENGINE::STATE_RATE.include?(state_id)
- result = YEM::BATTLE_ENGINE::STATE_RATE[state_id]
- else
- result = YEM::BATTLE_ENGINE::STATE_RATE[0]
- end
- rate = result[rank]
- #---
- create_affinity_bonus
- @bonus_state_affinity[state_id] = 0 if
- @bonus_state_affinity[state_id] == nil
- rate += @bonus_state_affinity[state_id]
- #---
- if actor?
- for equip in equips.compact
- next unless equip.state_rate_per.include?(state_id)
- percent = equip.state_rate_per[state_id]
- rate = rate * percent / 100
- end
- end
- #---
- for state in states
- next unless state.state_rate_per.include?(state_id)
- stack(state).times do
- rate = rate * state.state_rate_per[state_id] / 100
- end
- end
- #---
- if actor?
- for equip in equips.compact
- next unless equip.state_rate_set.include?(state_id)
- rate += equip.state_rate_set[state_id]
- end
- end
- #---
- for state in states
- next unless state.state_rate_set.include?(state_id)
- rate += state.state_rate_set[state_id] * stack(state)
- end
- #---
- return [rate, 0].max
- end
- #--------------------------------------------------------------------------
- # new method: element_apply_state_rate
- #--------------------------------------------------------------------------
- def element_apply_state_rate(rate)
- return rate unless $scene.is_a?(Scene_Battle)
- return rate unless YEM::BATTLE_ENGINE::STATE_ELEMENT_APPLY
- return rate if $scene.active_battler == nil
- battler = $scene.active_battler
- if battler.action.item? or battler.action.skill?
- obj = battler.action.item if $scene.active_battler.action.item?
- obj = battler.action.skill if $scene.active_battler.action.skill?
- else
- obj = nil
- end
- rate = apply_element_rate(battler, rate, obj)
- return rate
- end
- #--------------------------------------------------------------------------
- # new method: attack_formulas
- #--------------------------------------------------------------------------
- def attack_formulas; return ["ATK WEAPON"]; end
- #--------------------------------------------------------------------------
- # new method: added_states_plus
- #--------------------------------------------------------------------------
- def added_states_plus(state_id)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- if state?(state_id)
- remained_states_plus(state_id)
- return
- end
- add_state(state_id)
- return if @added_states.include?(state_id)
- @added_states.push(state_id)
- @added_states.uniq!
- @added_states.sort!
- end
- #--------------------------------------------------------------------------
- # new method: removed_states_plus
- #--------------------------------------------------------------------------
- def removed_states_plus(state_id)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- return unless state?(state_id)
- return if @removed_states.include?(state_id)
- remove_state(state_id)
- @removed_states.push(state_id)
- @removed_states.uniq!
- @removed_states.sort!
- end
- #--------------------------------------------------------------------------
- # new method: remained_states_plus
- #--------------------------------------------------------------------------
- def remained_states_plus(state_id)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- return unless state?(state_id)
- return if @remained_states.include?(state_id)
- @remained_states.push(state_id)
- @remained_states.uniq!
- @remained_states.sort!
- end
- #--------------------------------------------------------------------------
- # new method: clear_state_tags
- #--------------------------------------------------------------------------
- def clear_state_tags
- @added_states = []
- @removed_states = []
- @remained_states = []
- end
- #--------------------------------------------------------------------------
- # alias method: add_state
- #--------------------------------------------------------------------------
- alias add_state_bem add_state unless $@
- def add_state(state_id)
- hpdif = maxhp; mpdif = maxmp
- #---
- add_state_bem(state_id)
- increase_stack(state_id)
- #---
- @state_clockticks = {} if @state_clockticks == nil
- ctr = 32
- if $scene.is_a?(Scene_Battle)
- ctr = YEM::BATTLE_ENGINE::ATB_RULES[:turns_ctr] if $scene.atb?
- ctr = YEM::BATTLE_ENGINE::CTB_RULES[:turns_ctr] if $scene.ctb?
- end
- @state_clockticks[state_id] = ctr
- #---
- apply_state_differences(hpdif, mpdif, true)
- create_state_origin(state_id)
- reload_state_animation
- lunatic_status_effects(state_id, :apply)
- #---
- clear_battle_cache
- if $scene.is_a?(Scene_Battle)
- @update_states = true
- @update_maxhp = true
- @update_maxmp = true
- @update_commands = true
- $scene.refresh_battle_windows
- end
- end
- #--------------------------------------------------------------------------
- # alias method: remove_state
- #--------------------------------------------------------------------------
- alias remove_state_bem remove_state unless $@
- def remove_state(state_id)
- hpdif = maxhp; mpdif = maxmp
- #---
- remove_state_bem(state_id)
- clear_stack(state_id)
- #---
- @state_clockticks = {} if @state_clockticks == nil
- @state_clockticks.delete(state_id)
- #---
- apply_state_differences(hpdif, mpdif, false)
- clear_state_origin(state_id)
- reload_state_animation
- lunatic_status_effects(state_id, :remove)
- #---
- clear_battle_cache
- if $scene.is_a?(Scene_Battle)
- @update_states = true
- @update_maxhp = true
- @update_maxmp = true
- @update_commands = true
- spriteset.revive_character_death if state_id == 1
- $scene.refresh_battle_windows
- end
- end
- #--------------------------------------------------------------------------
- # alias method: remove_states_auto
- # Game Battler version
- #--------------------------------------------------------------------------
- alias remove_states_auto_bem remove_states_auto unless $@
- def remove_states_auto
- return unless exist?
- for state in states; lunatic_status_effects(state, :while); end
- for i in @state_turns.keys.clone
- next unless @state_turns[i] <= 0
- lunatic_status_effects(i, :leave)
- end
- remove_states_auto_bem
- @update_states = true
- end
- #--------------------------------------------------------------------------
- # new method: stack
- #--------------------------------------------------------------------------
- def stack(state_id)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- state = $data_states[state_id]
- return 0 unless state?(state)
- @state_stack = {} if @state_stack == nil
- max_stack = state.stack
- return [[@state_stack[state_id].to_i, 1].max, max_stack].min
- end
- #--------------------------------------------------------------------------
- # new method: create_state_origin
- #--------------------------------------------------------------------------
- def create_state_origin(state_id)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- @state_origin = {} if @state_origin == nil
- return unless $scene.is_a?(Scene_Battle)
- @state_origin[state_id] = $scene.active_battler
- end
- #--------------------------------------------------------------------------
- # new method: clear_state_origin
- #--------------------------------------------------------------------------
- def clear_state_origin(state_id)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- @state_origin = {} if @state_origin == nil
- @state_origin.delete(state_id)
- end
- #--------------------------------------------------------------------------
- # new method: reset_state_origins
- #--------------------------------------------------------------------------
- def reset_state_origins; @state_origin = {}; end
- #--------------------------------------------------------------------------
- # new method: state_origin
- #--------------------------------------------------------------------------
- def state_origin(state_id)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- @state_origin = {} if @state_origin == nil
- origin = @state_origin[state_id]
- origin = self if origin == nil
- return origin
- end
- #--------------------------------------------------------------------------
- # new method: increase_stack
- #--------------------------------------------------------------------------
- def increase_stack(state_id, value = 1)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- state = $data_states[state_id]
- return unless state?(state_id)
- return if state_id == 1
- @state_stack = {} if @state_stack == nil
- @state_stack[state_id] = 0 if @state_stack[state_id] == nil
- original_stack = @state_stack[state_id]
- @state_stack[state_id] += value
- @state_stack[state_id] = [@state_stack[state_id], state.stack].min
- #---
- clear_battle_cache
- #---
- return if @state_stack[state_id] == original_stack
- @added_states.push(state_id) if !@added_states.include?(state_id)
- end
- #--------------------------------------------------------------------------
- # new method: decrease_stack
- #--------------------------------------------------------------------------
- def decrease_stack(state_id, value = 1)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- increase_stack(state_id, -value)
- @state_stack = {} if @state_stack == nil
- @state_stack.delete(state_id) if @state_stack[state_id].to_i <= 0
- end
- #--------------------------------------------------------------------------
- # new method: clear_stack
- #--------------------------------------------------------------------------
- def clear_stack(state_id)
- state_id = state_id.id if state_id.is_a?(RPG::State)
- @state_stack = {} if @state_stack == nil
- @state_stack.delete(state_id)
- end
- #--------------------------------------------------------------------------
- # overwrite method: maxhp
- #--------------------------------------------------------------------------
- def maxhp
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:maxhp] if @cache_params[:maxhp] != nil
- end
- #---
- n = [base_maxhp + @maxhp_plus, 1].max
- for state in states
- stack(state).times do
- n = n * state.maxhp_rate / 100.0
- end
- end
- for state in states
- next if state.maxhp_set == 0
- n += state.maxhp_set * stack(state)
- end
- #---
- @cache_params[:maxhp] = [[Integer(n), maxhp_limit].min, 1].max
- @hp = [@cache_params[:maxhp], @hp].min
- return @cache_params[:maxhp]
- end
- #--------------------------------------------------------------------------
- # alias methods: maxhp=
- #--------------------------------------------------------------------------
- alias maxhp_equals_bem maxhp= unless $@
- def maxhp=(value)
- maxhp_equals_bem(value)
- clear_battle_cache
- @update_maxhp = true
- @hp = [@hp, self.maxhp].min
- end
- #--------------------------------------------------------------------------
- # overwrite method: maxmp
- #--------------------------------------------------------------------------
- def maxmp
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:maxmp] if @cache_params[:maxmp] != nil
- end
- #---
- n = [base_maxmp + @maxmp_plus, 0].max
- for state in states
- stack(state).times do
- n = n * state.maxmp_rate / 100.0
- end
- end
- for state in states
- next if state.maxmp_set == 0
- n += state.maxmp_set * stack(state)
- end
- #---
- @cache_params[:maxmp] = [[Integer(n), maxmp_limit].min, 0].max
- @mp = [@cache_params[:maxmp], @mp].min
- return @cache_params[:maxmp]
- end
- #--------------------------------------------------------------------------
- # alias methods: maxmp=
- #--------------------------------------------------------------------------
- alias maxmp_equals_bem maxmp= unless $@
- def maxmp=(value)
- maxmp_equals_bem(value)
- clear_battle_cache
- @update_maxmp = true
- @mp = [@mp, self.maxmp].min
- end
- #--------------------------------------------------------------------------
- # overwrite method: atk
- #--------------------------------------------------------------------------
- def atk
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:atk] if @cache_params[:atk] != nil
- end
- #---
- n = [base_atk + @atk_plus, 1].max
- for state in states
- stack(state).times do
- n = n * state.atk_rate / 100.0
- end
- end
- for state in states
- next if state.atk_set == 0
- n += state.atk_set * stack(state)
- end
- #---
- @cache_params[:atk] = [[Integer(n), parameter_limit].min, 1].max
- return @cache_params[:atk]
- end
- #--------------------------------------------------------------------------
- # alias methods: atk=
- #--------------------------------------------------------------------------
- alias atk_equals_bem atk= unless $@
- def atk=(value)
- atk_equals_bem(value)
- clear_battle_cache
- end
- #--------------------------------------------------------------------------
- # overwrite method: def
- #--------------------------------------------------------------------------
- def def
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:def] if @cache_params[:def] != nil
- end
- #---
- n = [base_def + @def_plus, 1].max
- for state in states
- stack(state).times do
- n = n * state.def_rate / 100.0
- end
- end
- for state in states
- next if state.def_set == 0
- n += state.def_set * stack(state)
- end
- #---
- @cache_params[:def] = [[Integer(n), parameter_limit].min, 1].max
- return @cache_params[:def]
- end
- #--------------------------------------------------------------------------
- # alias methods: def=
- #--------------------------------------------------------------------------
- alias def_equals_bem def= unless $@
- def def=(value)
- def_equals_bem(value)
- clear_battle_cache
- end
- #--------------------------------------------------------------------------
- # overwrite method: spi
- #--------------------------------------------------------------------------
- def spi
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:spi] if @cache_params[:spi] != nil
- end
- #---
- n = [base_spi + @spi_plus, 1].max
- for state in states
- stack(state).times do
- n = n * state.spi_rate / 100.0
- end
- end
- for state in states
- next if state.spi_set == 0
- n += state.spi_set * stack(state)
- end
- #---
- @cache_params[:spi] = [[Integer(n), parameter_limit].min, 1].max
- return @cache_params[:spi]
- end
- #--------------------------------------------------------------------------
- # alias methods: spi=
- #--------------------------------------------------------------------------
- alias spi_equals_bem spi= unless $@
- def spi=(value)
- spi_equals_bem(value)
- clear_battle_cache
- end
- #--------------------------------------------------------------------------
- # overwrite method: agi
- #--------------------------------------------------------------------------
- def agi
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:agi] if @cache_params[:agi] != nil
- end
- #---
- n = [base_agi + @agi_plus, 1].max
- for state in states
- stack(state).times do
- n = n * state.agi_rate / 100.0
- end
- end
- for state in states
- next if state.agi_set == 0
- n += state.agi_set * stack(state)
- end
- #---
- @cache_params[:agi] = [[Integer(n), parameter_limit].min, 1].max
- return @cache_params[:agi]
- end
- #--------------------------------------------------------------------------
- # alias methods: agi=
- #--------------------------------------------------------------------------
- alias agi_equals_bem agi= unless $@
- def agi=(value)
- agi_equals_bem(value)
- clear_battle_cache
- end
- #--------------------------------------------------------------------------
- # new method: traits
- #--------------------------------------------------------------------------
- def traits
- return @cache_traits if @cache_traits != nil
- @cache_traits = []
- for state in states; @cache_traits |= state.traits; end
- if actor?
- for equip in equips.compact; @cache_traits |= equip.traits; end
- end
- return @cache_traits
- end
- #--------------------------------------------------------------------------
- # new method: auto_battle
- #--------------------------------------------------------------------------
- def auto_battle; return false; end
- #--------------------------------------------------------------------------
- # overwrite method: super_guard
- #--------------------------------------------------------------------------
- def super_guard; return traits.include?(:super_guard); end
- #--------------------------------------------------------------------------
- # overwrite method: fast_attack
- #--------------------------------------------------------------------------
- def fast_attack; return traits.include?(:fast_attack); end
- #--------------------------------------------------------------------------
- # overwrite method: dual_attack
- #--------------------------------------------------------------------------
- def dual_attack; return traits.include?(:dual_attack); end
- #--------------------------------------------------------------------------
- # overwrite method: prevent_critical
- #--------------------------------------------------------------------------
- def prevent_critical; return traits.include?(:dual_attack); end
- #--------------------------------------------------------------------------
- # overwrite method: half_mp_cost
- #--------------------------------------------------------------------------
- def half_mp_cost; return traits.include?(:half_mp_cost); end
- #--------------------------------------------------------------------------
- # new method: anti_hp_regen
- #--------------------------------------------------------------------------
- def anti_hp_regen; return traits.include?(:anti_hp_regen); end
- #--------------------------------------------------------------------------
- # new method: anti_hp_degen
- #--------------------------------------------------------------------------
- def anti_hp_degen; return traits.include?(:anti_hp_degen); end
- #--------------------------------------------------------------------------
- # new method: anti_mp_regen
- #--------------------------------------------------------------------------
- def anti_mp_regen; return traits.include?(:anti_mp_regen); end
- #--------------------------------------------------------------------------
- # new method: anti_mp_degen
- #--------------------------------------------------------------------------
- def anti_mp_degen; return traits.include?(:anti_mp_degen); end
- #--------------------------------------------------------------------------
- # overwrite method: skill_can_use?
- #--------------------------------------------------------------------------
- def skill_can_use?(skill)
- return false unless skill.is_a?(RPG::Skill)
- return false unless movable?
- return false if silent? and skill.spi_f > 0
- #---
- return false if skill_restriction?(skill)
- return false if skill_limited?(skill)
- return false if cooldown(skill) > 0
- return false unless meet_obj_requirements(skill)
- #---
- return false unless custom_skill_costs(skill, :can_use)
- #---
- return ($game_temp.in_battle) ? skill.battle_ok? : skill.menu_ok?
- end
- #--------------------------------------------------------------------------
- # new method: meet_obj_requirements
- #--------------------------------------------------------------------------
- def meet_obj_requirements(obj)
- return false unless met_obj_state_requirements(obj)
- return false unless met_obj_element_requirements(obj)
- return false unless met_obj_switch_requirements(obj)
- return true
- end
- #--------------------------------------------------------------------------
- # new method: met_obj_state_requirements
- #--------------------------------------------------------------------------
- def met_obj_state_requirements(obj)
- if obj.requirements[:all_state] != nil
- for id in obj.requirements[:all_state]
- return false unless state?(id)
- end
- end
- #---
- if obj.requirements[:any_state] != nil
- for id in obj.requirements[:any_state]
- return true if state?(id)
- end
- end
- #---
- return true
- end
- #--------------------------------------------------------------------------
- # new method: met_obj_element_requirements
- #--------------------------------------------------------------------------
- def met_obj_element_requirements(obj)
- return true if self.enemy?
- if obj.requirements[:all_ele] != nil
- for id in obj.requirements[:all_ele]
- return false unless element_set.include?(id)
- end
- end
- #---
- if obj.requirements[:any_ele] != nil
- for id in obj.requirements[:any_ele]
- return true if element_set.include?(id)
- end
- end
- #---
- return true
- end
- #--------------------------------------------------------------------------
- # new method: met_obj_switch_requirements
- #--------------------------------------------------------------------------
- def met_obj_switch_requirements(obj)
- if obj.requirements[:all_switch] != nil
- for id in obj.requirements[:all_switch]
- return false unless $game_switches[id]
- end
- end
- #---
- if obj.requirements[:any_switch] != nil
- for id in obj.requirements[:any_switch]
- return true if $game_switches[id]
- end
- end
- #---
- return true
- end
- #--------------------------------------------------------------------------
- # new method: skill_restriction?
- #--------------------------------------------------------------------------
- def skill_restriction?(skill)
- if @cache_restrict_skill == nil
- @cache_restrict_skill = []
- for state in states
- @cache_restrict_skill += state.restrict_skill
- end
- end
- return true if (@cache_restrict_skill & skill.skill_type != [])
- return false
- end
- #--------------------------------------------------------------------------
- # alias method: calc_hit
- #--------------------------------------------------------------------------
- alias calc_hit_bem calc_hit unless $@
- def calc_hit(user, obj = nil)
- return 100 if $game_temp.perfect_hit
- if ($TEST or $BTEST) and Input.press?(Input::F6)
- return 100 if user.actor?
- return 0 if user.enemy?
- end
- return calc_hit_bem(user, obj)
- end
- #--------------------------------------------------------------------------
- # alias method: calc_eva
- #--------------------------------------------------------------------------
- alias calc_eva_bem calc_eva unless $@
- def calc_eva(user, obj = nil)
- return -1 if $game_temp.perfect_hit
- if ($TEST or $BTEST) and Input.press?(Input::F6)
- return 0 if user.actor?
- return 100 if user.enemy?
- end
- return calc_eva_bem(user, obj)
- end
- #--------------------------------------------------------------------------
- # overwrite method: elements_max_rate
- #--------------------------------------------------------------------------
- def elements_max_rate(element_set)
- if element_set.empty?
- @element_max = 100
- return 100
- end
- rate_list = []
- for i in element_set
- rate_list.push(element_rate(i))
- end
- #---
- case YEM::BATTLE_ENGINE::ELEMENT_RATE_CALCULATION
- when 1 # Lowest of the rates
- n = rate_list.min
- when 2 # Average of the rates without absorb, then apply absorb
- n = 0; absorb = false
- for rate in rate_list
- absorb = true if rate < 0
- n += rate.abs
- end
- n *= -1 if absorb
- n /= rate_list.size
- when 3 # Average of the rates with absorb
- n = 0
- for rate in rate_list;
- n += rate
- end
- n /= rate_list.size
- when 4 # Priority to absorb, resist, find maximum for the rest.
- result = []
- for rate in rate_list
- next if rate >= 100
- result.push(rate)
- end
- n = (result != []) ? result.min : rate_list.max
- when 5 # Priority to absorb, resist, find average for the rest.
- result = []
- n = 0
- for rate in rate_list
- result.push(rate) if rate <= 99
- n += rate
- end
- n = (result != []) ? result.min : n / rate_list.size
- when 6 # Priority to absorb, immune, find maximum for the rest.
- result = []
- for rate in rate_list
- next if rate > 0
- result.push(rate)
- end
- n = (result != []) ? result.min : rate_list.max
- when 7 # Priority to absorb, immune, find average for the rest.
- result = []
- n = 0
- for rate in rate_list
- result.push(rate) if rate <= 0
- n += rate
- end
- n = (result != []) ? result.min : n / rate_list.size
- when 8 # Multiply all of the rates together to yield a STAB multiplier.
- n = 100
- for rate in rate_list; n = n * rate / 100; end
- when 9 # Absorb and resist priority, apply multiplication for rest.
- result = []
- n = 100
- for rate in rate_list
- result.push(rate) if rate <= 99
- n = n * rate / 100
- end
- n = result.min if result != []
- when 10 # Absorb and immune priority, apply multiplication for rest.
- result = []
- n = 100
- for rate in rate_list
- result.push(rate) if rate <= 0
- n = n * rate / 100
- end
- n = result.min if result != []
- else # Default: Highest of the rates
- n = rate_list.max
- end
- #---
- @element_max = n
- return n
- end
- #--------------------------------------------------------------------------
- # new method: apply_element_rank
- #--------------------------------------------------------------------------
- def apply_element_rank(element_id)
- if actor?
- rank = self.class.element_ranks[element_id]
- else
- rank = enemy.element_ranks[element_id]
- end
- result = []
- #---
- if actor?
- for equip in equips.compact
- next unless equip.element_rank.include?(element_id)
- result.push(equip.element_rank[element_id])
- end
- end
- #---
- for state in states
- next unless state.element_rank.include?(element_id)
- result.push(state.element_rank[element_id])
- end
- rank = result.min if result != []
- #---
- if actor?
- for equip in equips.compact
- next unless equip.element_rank_add.include?(element_id)
- rank += equip.element_rank_add[element_id]
- end
- end
- #---
- for state in states
- next unless state.element_rank_add.include?(element_id)
- multiplier = stack(state)
- rank += state.element_rank_add[element_id] * multiplier
- end
- #---
- rank = [[rank, 0].max, 6].min
- for state in states
- next unless state.element_rank_rev.include?(element_id)
- case rank
- when 0; rank = 6
- when 1; rank = 5
- when 2; rank = 4
- when 4; rank = 2
- when 5; rank = 1
- when 6; rank = 0
- end
- break
- end
- #---
- return rank
- end
- #--------------------------------------------------------------------------
- # new method: element_rate_table
- #--------------------------------------------------------------------------
- def element_rate_table(element_id, rank)
- if YEM::BATTLE_ENGINE::ELEMENT_RATE.include?(element_id)
- result = YEM::BATTLE_ENGINE::ELEMENT_RATE[element_id]
- else
- result = YEM::BATTLE_ENGINE::ELEMENT_RATE[0]
- end
- rate = result[rank]
- absorb = (rate < 0)
- #---
- create_affinity_bonus
- @bonus_element_affinity[element_id] = 0 if
- @bonus_element_affinity[element_id] == nil
- rate += @bonus_element_affinity[element_id]
- #---
- if actor?
- for equip in equips.compact
- next unless equip.element_rate_per.include?(element_id)
- percent = equip.element_rate_per[element_id]
- rate = rate * percent / 100
- end
- end
- #---
- for state in states
- next unless state.element_rate_per.include?(element_id)
- stack(state).times do
- rate = rate * state.element_rate_per[element_id] - 100 / 100
- end
- end
- #---
- if actor?
- for equip in equips.compact
- next unless equip.element_rate_set.include?(element_id)
- rate += equip.element_rate_set[element_id]
- end
- end
- #---
- for state in states
- next unless state.element_rate_set.include?(element_id)
- rate += state.element_rate_set[element_id] * stack(state)
- end
- #---
- rate = absorb ? [rate, 0].min : [rate, 0].max
- rate = [rate, YEM::BATTLE_ENGINE::MAX_ELEMENT_RATE].min
- rate = [rate, YEM::BATTLE_ENGINE::MIN_ELEMENT_RATE].max
- return rate
- end
- #--------------------------------------------------------------------------
- # alias method: execute_damage
- #--------------------------------------------------------------------------
- alias execute_damage_bem execute_damage unless $@
- def execute_damage(user)
- for state in states; lunatic_status_effects(state, :react); end
- #--- Damage Inflate ---
- $game_temp.hp_damage_inflate = 100 if $game_temp.hp_damage_inflate == nil
- $game_temp.mp_damage_inflate = 100 if $game_temp.mp_damage_inflate == nil
- @hp_damage = @hp_damage * $game_temp.hp_damage_inflate / 100
- @mp_damage = @mp_damage * $game_temp.mp_damage_inflate / 100
- @hp_damage = apply_damage_wall(@hp_damage, :hp)
- @mp_damage = apply_damage_wall(@mp_damage, :hp)
- #--- Damage Inflate ---
- execute_damage_bem(user)
- #--- Debug Options ---
- self.hp = 0 if ($TEST or $BTEST) and Input.press?(Input::F5) and enemy?
- for state in states; lunatic_status_effects(state, :shock); end
- end
- #--------------------------------------------------------------------------
- # new method: maxmp_limit
- #--------------------------------------------------------------------------
- unless method_defined?(:maxmp_limit)
- def maxmp_limit; return 9999; end
- end # method_defined?(:maxmp_limit)
- #--------------------------------------------------------------------------
- # new method: parameter_limit
- #--------------------------------------------------------------------------
- unless method_defined?(:parameter_limit)
- def parameter_limit; return 999; end
- end # method_defined?(:parameter_limit)
- #--------------------------------------------------------------------------
- # new method: attack_setup_actions
- #--------------------------------------------------------------------------
- def attack_setup_actions
- return YEM::DEFAULT_ACTIONS::ATTACK_SETUP
- end
- #--------------------------------------------------------------------------
- # new method: attack_whole_actions
- #--------------------------------------------------------------------------
- def attack_whole_actions
- return YEM::DEFAULT_ACTIONS::ATTACK_WHOLE
- end
- #--------------------------------------------------------------------------
- # new method: attack_follow_actions
- #--------------------------------------------------------------------------
- def attack_follow_actions
- return YEM::DEFAULT_ACTIONS::ATTACK_FOLLOW
- end
- #--------------------------------------------------------------------------
- # new method: attack_target_actions
- #--------------------------------------------------------------------------
- def attack_target_actions
- return YEM::DEFAULT_ACTIONS::ATTACK_TARGET
- end
- #--------------------------------------------------------------------------
- # new method: attack_finish_actions
- #--------------------------------------------------------------------------
- def attack_finish_actions
- return YEM::DEFAULT_ACTIONS::ATTACK_FINISH
- end
- #--------------------------------------------------------------------------
- # new method: guard_actions
- #--------------------------------------------------------------------------
- def guard_actions
- return YEM::DEFAULT_ACTIONS::GUARD_ACTIONS
- end
- #--------------------------------------------------------------------------
- # overwrite method: apply_state_changes
- #--------------------------------------------------------------------------
- def apply_state_changes(obj)
- plus = obj.plus_state_set
- minus = obj.minus_state_set
- #---
- if obj.is_a?(RPG::UsableItem) and $scene.is_a?(Scene_Battle)
- if YEM::BATTLE_ENGINE::APPLY_PHYSICAL_STATE and obj.physical_attack
- plus += $scene.active_battler.plus_state_set
- minus += $scene.active_battler.minus_state_set
- elsif YEM::BATTLE_ENGINE::APPLY_MAGICAL_STATE
- plus += $scene.active_battler.plus_state_set
- minus += $scene.active_battler.minus_state_set
- end
- end
- #---
- for i in plus
- next if state_resist?(i)
- next if dead?
- next if i == 1 and @immortal
- if state?(i)
- remained_rules(i)
- @remained_states.push(i) unless @remained_states.include?(i)
- next
- end
- if rand(100) < state_probability(i)
- @added_states.push(i) unless @added_states.include?(i)
- add_state(i)
- end
- end
- for i in minus
- next unless state?(i)
- remove_state(i)
- @removed_states.push(i) unless @removed_states.include?(i)
- end
- for i in @added_states & @removed_states
- @added_states.delete(i)
- @removed_states.delete(i)
- end
- end
- #--------------------------------------------------------------------------
- # new method: remained_rules
- #--------------------------------------------------------------------------
- def remained_rules(state_id)
- state = $data_states[state_id]
- return if state == nil
- #---
- hpdif = maxhp; mpdif = maxmp
- increase_stack(state)
- #---
- case YEM::BATTLE_ENGINE::REMAINED_RULES
- when 0 # No changes
- return
- when 1 # Reset Turns
- @state_turns[state_id] = state.hold_turn
- when 2 # Add Turns
- @state_turns[state_id] = 0 if !@state_turns.include?(state_id)
- @state_turns[state_id] += state.hold_turn
- end
- #---
- apply_state_differences(hpdif, mpdif)
- end
- #--------------------------------------------------------------------------
- # new method: apply_state_differences
- #--------------------------------------------------------------------------
- def apply_state_differences(hpdif, mpdif, apply = true)
- return if dead?
- state_settings = YEM::BATTLE_ENGINE::STATE_SETTINGS
- hpdif = maxhp - hpdif; mpdif = maxmp - mpdif
- return if hpdif == 0 and mpdif == 0
- if apply
- self.hp += hpdif if hpdif > 0 and state_settings[:apply_heal_hp]
- self.hp += hpdif if hpdif < 0 and state_settings[:apply_dmg_hp]
- self.mp += mpdif if mpdif > 0 and state_settings[:apply_heal_mp]
- self.mp += mpdif if mpdif < 0 and state_settings[:apply_dmg_mp]
- else
- self.hp += hpdif if hpdif > 0 and state_settings[:erase_heal_hp]
- self.hp += hpdif if hpdif < 0 and state_settings[:erase_dmg_hp]
- self.mp += mpdif if mpdif > 0 and state_settings[:erase_heal_mp]
- self.mp += mpdif if mpdif < 0 and state_settings[:erase_dmg_mp]
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: attack_effect
- #--------------------------------------------------------------------------
- def attack_effect(attacker)
- clear_action_results if $game_temp.atk_effects.include?("calc")
- unless attack_effective?(attacker)
- @skipped = true
- return
- end
- #---
- if $game_temp.atk_effects.include?("calc")
- if rand(100) >= calc_hit(attacker)
- @missed = true
- return
- end
- if rand(100) < calc_eva(attacker)
- @evaded = true
- return
- end
- end
- #---
- if $game_temp.atk_effects.include?("effect")
- atb_change_effect(attacker, nil)
- attacker.create_atb_reset(nil)
- ctb_change_effect(attacker, nil)
- attacker.create_ctb_reset(nil)
- earn_rage(attacker, nil)
- end
- #---
- if $game_temp.atk_effects.include?("dmg")
- make_attack_damage_value(attacker)
- execute_damage(attacker)
- return if @hp_damage == 0
- end
- #---
- apply_state_changes(attacker) if $game_temp.atk_effects.include?("state")
- ##---
- end
- #--------------------------------------------------------------------------
- # alias method: skill_test
- #--------------------------------------------------------------------------
- alias skill_test_bem skill_test unless $@
- def skill_test(user, skill)
- for state_id in skill.plus_state_set
- state = $data_states[state_id]
- next if state == nil
- return true if state.stack > self.stack(state)
- end
- return skill_test_bem(user, skill)
- end
- #--------------------------------------------------------------------------
- # overwrite method: skill_effect
- #--------------------------------------------------------------------------
- def skill_effect(user, skill)
- clear_action_results if $game_temp.skill_effects.include?("calc")
- unless skill_effective?(user, skill)
- @skipped = true
- return
- end
- #---
- if $game_temp.skill_effects.include?("calc")
- if rand(100) >= calc_hit(user, skill)
- @missed = true
- return
- end
- if rand(100) < calc_eva(user, skill)
- @evaded = true
- return
- end
- end
- #---
- if $game_temp.skill_effects.include?("effect")
- ptb_obj_effect(user, skill)
- atb_change_effect(user, skill)
- user.create_atb_reset(skill)
- ctb_change_effect(user, skill)
- user.create_ctb_reset(skill)
- earn_rage(user, skill)
- end
- #---
- if $game_temp.skill_effects.include?("dmg")
- make_obj_damage_value(user, skill)
- make_obj_absorb_effect(user, skill)
- execute_damage(user)
- return if skill.physical_attack and @hp_damage == 0
- end
- #---
- apply_state_changes(skill) if $game_temp.skill_effects.include?("state")
- end
- #--------------------------------------------------------------------------
- # new method: perform_skill_cost
- #--------------------------------------------------------------------------
- def perform_skill_cost(skill)
- return if skill == nil or !skill.is_a?(RPG::Skill)
- custom_skill_costs(skill, :perform)
- make_cooldown(skill)
- make_limited(skill)
- end
- #--------------------------------------------------------------------------
- # new method: apply_skill_cost_changes
- #--------------------------------------------------------------------------
- def apply_skill_cost_changes(skill, cost, type = "MP")
- clear_battle_cache if @cache_skill_costs == nil
- return @cache_skill_costs[skill.id] if @cache_skill_costs[skill.id] != nil
- cost = apply_skill_cost_state_per(skill, cost, type)
- cost = apply_skill_cost_state_set(skill, cost, type)
- @cache_skill_costs[skill.id] = [Integer(cost), 0].max
- return @cache_skill_costs[skill.id]
- end
- #--------------------------------------------------------------------------
- # new method: apply_skill_cost_state_per
- #--------------------------------------------------------------------------
- def apply_skill_cost_state_per(skill, cost, type = "MP")
- for state in states
- next unless state.cost_per[type.upcase] != nil
- stack(state).times do
- cost = cost * state.cost_per[type.upcase] / 100.0
- end
- end
- return cost
- end
- #--------------------------------------------------------------------------
- # new method: apply_skill_cost_state_set
- #--------------------------------------------------------------------------
- def apply_skill_cost_state_set(skill, cost, type = "MP")
- for state in states
- next unless state.cost_set[type.upcase] != nil
- cost += state.cost_set[type.upcase] * stack(state)
- end
- return cost
- end
- #--------------------------------------------------------------------------
- # overwrite method: item_effect
- #--------------------------------------------------------------------------
- def item_effect(user, item)
- clear_action_results if $game_temp.item_effects.include?("calc")
- unless item_effective?(user, item)
- @skipped = true
- return
- end
- #---
- if $game_temp.item_effects.include?("calc")
- if rand(100) >= calc_hit(user, item)
- @missed = true
- return
- end
- if rand(100) < calc_eva(user, item)
- @evaded = true
- return
- end
- end
- #---
- item_growth_effect(user, item) if $game_temp.item_effects.include?("growth")
- #---
- if $game_temp.item_effects.include?("effect")
- ptb_obj_effect(user, item)
- atb_change_effect(user, item)
- user.create_atb_reset(item)
- ctb_change_effect(user, item)
- user.create_ctb_reset(item)
- earn_rage(user, item)
- end
- #---
- if $game_temp.item_effects.include?("dmg")
- hp_recovery = calc_hp_recovery(user, item)
- mp_recovery = calc_mp_recovery(user, item)
- make_obj_damage_value(user, item)
- @hp_damage -= hp_recovery
- @mp_damage -= mp_recovery
- make_obj_absorb_effect(user, item)
- execute_damage(user)
- return if item.physical_attack and @hp_damage == 0
- end
- #---
- apply_state_changes(item) if $game_temp.item_effects.include?("state")
- end
- #--------------------------------------------------------------------------
- # alias method: item_effective?
- #--------------------------------------------------------------------------
- alias item_effective_bem item_effective?
- def item_effective?(user, item)
- return false if nullify_effect?(item)
- return item_effective_bem(user, item)
- end
- #--------------------------------------------------------------------------
- # new method: create_affinity_bonus
- #--------------------------------------------------------------------------
- def create_affinity_bonus
- @bonus_element_affinity = {} if @bonus_element_affinity == nil
- @bonus_state_affinity = {} if @bonus_state_affinity == nil
- end
- #--------------------------------------------------------------------------
- # alias method: item_test
- #--------------------------------------------------------------------------
- alias item_test_bem item_test unless $@
- def item_test(user, item)
- return true if item.element_growth != {}
- return true if item.state_growth != {}
- return item_test_bem(user, item)
- end
- #--------------------------------------------------------------------------
- # alias method: item_growth_effect
- #--------------------------------------------------------------------------
- alias item_growth_effect_bem item_growth_effect unless $@
- def item_growth_effect(user, item)
- create_affinity_bonus
- if item.element_growth != {}
- for key in item.element_growth
- ele_id = key[0]; value = key[1]
- @bonus_element_affinity[ele_id] = 0 if
- @bonus_element_affinity[ele_id] == nil
- @bonus_element_affinity[ele_id] += value
- end
- end
- if item.state_growth != {}
- for key in item.state_growth
- state_id = key[0]; value = key[1]
- @bonus_state_affinity[state_id] = 0 if
- @bonus_state_affinity[state_id] == nil
- @bonus_state_affinity[state_id] += value
- end
- end
- item_growth_effect_bem(user, item)
- end
- #--------------------------------------------------------------------------
- # new method: nullify_effect?
- #--------------------------------------------------------------------------
- def nullify_effect?(item)
- return false unless item.is_a?(RPG::Item)
- if actor?
- return true if item.nullify[:actors].include?(@actor_id)
- return true if item.nullify[:classes].include?(@class_id)
- elsif enemy?
- return true if item.nullify[:enemies].include?(@enemy_id)
- end
- return false
- end
- #--------------------------------------------------------------------------
- # new method: consume_item
- #--------------------------------------------------------------------------
- def consume_item(item)
- return unless self.actor?
- perform_consume_item(item)
- end
- #--------------------------------------------------------------------------
- # new method: perform_consume_item
- #--------------------------------------------------------------------------
- def perform_consume_item(item)
- return if item == nil or !item.is_a?(RPG::Item)
- $game_party.consume_item(item)
- end
- #--------------------------------------------------------------------------
- # overwrite method: calc_hp_recovery
- #--------------------------------------------------------------------------
- def calc_hp_recovery(user, item)
- result = maxhp * item.hp_recovery_rate / 100 + item.hp_recovery
- rate = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:hp_pharma_rate]
- result = Integer(result * rate) if user.pharmacology
- return result
- end
- #--------------------------------------------------------------------------
- # overwrite method: calc_mp_recovery
- #--------------------------------------------------------------------------
- def calc_mp_recovery(user, item)
- result = maxmp * item.mp_recovery_rate / 100 + item.mp_recovery
- rate = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:hp_pharma_rate]
- result = Integer(result * rate) if user.pharmacology
- return result
- end
- #--------------------------------------------------------------------------
- # new method: item_can_use?
- #--------------------------------------------------------------------------
- def item_can_use?(item); return false; end
- #--------------------------------------------------------------------------
- # new method: item_restriction?
- #--------------------------------------------------------------------------
- def item_restriction?(item)
- if @cache_restrict_item == nil
- @cache_restrict_item = []
- for state in states
- @cache_restrict_item |= state.restrict_item
- end
- end
- return true if (@cache_restrict_item & item.item_type != [])
- return false
- end
- #--------------------------------------------------------------------------
- # new method: active_battler?
- #--------------------------------------------------------------------------
- def active_battler?
- return false unless $scene.is_a?(Scene_Battle)
- return self == $scene.active_battler
- end
- #--------------------------------------------------------------------------
- # overwrite method: slip_damage_effect
- #--------------------------------------------------------------------------
- def slip_damage_effect
- return unless slip_damage?
- for state in states; perform_slip_effect(state); end
- end
- #--------------------------------------------------------------------------
- # new method: perform_slip_effect
- #--------------------------------------------------------------------------
- def perform_slip_effect(state)
- return if state == nil
- return unless exist?
- return unless state.slip_damage
- hp_dmg = 0; mp_dmg = 0
- hash = state.slip_effect
- #---
- hp_dmg += maxhp * hash[:hp_degen_per] / 100 if hash [:hp_degen_per] != nil
- hp_dmg += hash[:hp_degen_set] if hash[:hp_degen_set] != nil
- hp_dmg *= stack(state) if hp_dmg != 0
- mp_dmg += maxmp * hash[:mp_degen_per] / 100 if hash [:mp_degen_per] != nil
- mp_dmg += hash[:mp_degen_set] if hash[:mp_degen_set] != nil
- mp_dmg *= stack(state) if mp_dmg != 0
- #---
- hp_dmg = [hp_dmg, @hp - 1].min
- hp_dmg = 0 if anti_hp_regen if hp_dmg < 0
- hp_dmg = 0 if anti_hp_degen if hp_dmg > 0
- mp_dmg = 0 if anti_mp_regen if mp_dmg < 0
- mp_dmg = 0 if anti_mp_degen if mp_dmg > 0
- #---
- if hp_dmg != 0
- @hp = [[@hp - hp_dmg, maxhp].min, 0].max
- if hp_dmg > 0
- rules = "HP_DMG"
- value = hp_dmg
- sprint = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:hp_dmg]
- else
- rules = "HP_HEAL"
- value = -hp_dmg
- sprint = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:hp_heal]
- end
- create_popup(value, rules) if $scene.is_a?(Scene_Battle)
- end
- if mp_dmg != 0
- @mp = [[@mp - mp_dmg, maxmp].min, 0].max
- if mp_dmg > 0
- rules = "MP_DMG"
- value = mp_dmg
- sprint = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:mp_dmg]
- else
- rules = "MP_HEAL"
- value = -mp_dmg
- sprint = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:mp_heal]
- end
- value = sprintf(sprint, value)
- create_popup(value, rules) if $scene.is_a?(Scene_Battle)
- end
- end
- #--------------------------------------------------------------------------
- # new method: use_rage?
- #--------------------------------------------------------------------------
- def use_rage?
- for skill in total_skills
- next if skill == nil
- return true if skill.rage_skill
- end
- return false
- end
- #--------------------------------------------------------------------------
- # new method: max_rage
- #--------------------------------------------------------------------------
- def max_rage; return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:max_rage]; end
- #--------------------------------------------------------------------------
- # new method: earn_rage
- #--------------------------------------------------------------------------
- def earn_rage(user, obj = nil)
- if user.actor? != actor?
- value = YEM::BATTLE_ENGINE::SKILL_SETTINGS[:hit_rage_gain]
- value = rage_modifiers(value)
- gain_rage(value)
- end
- if obj != nil
- value = obj.rage_target
- gain_rage(value)
- end
- #---
- if obj == nil
- value = YEM::BATTLE_ENGINE::SKILL_SETTINGS[:attack_rage_gain]
- else
- value = obj.rage_boost
- end
- value = user.rage_modifiers(value)
- user.gain_rage(value)
- end
- #--------------------------------------------------------------------------
- # new method: rage_modifiers
- #--------------------------------------------------------------------------
- def rage_modifiers(value)
- #---
- if @cache_rage[:per] == nil
- percent = 100
- for state in states
- next if state == nil
- next if state.rage_boost[:per] == nil
- percent += state.rage_boost[:per] - 100
- end
- @cache_rage[:per] = percent
- end
- #---
- if @cache_rage[:set] == nil
- modifier = 0
- for state in states
- next if state == nil
- next if state.rage_boost[:set] == nil
- modifier += state.rage_boost[:set]
- end
- @cache_rage[:set] = modifier
- end
- #---
- value = value * @cache_rage[:per] / 100
- value += @cache_rage[:set]
- #---
- return value
- end
- #--------------------------------------------------------------------------
- # new method: gain_rage
- #--------------------------------------------------------------------------
- def gain_rage(value = 1)
- @rage = 0 if @rage == nil
- @rage = [@rage + value, max_rage].min
- end
- #--------------------------------------------------------------------------
- # new method: lose_rage
- #--------------------------------------------------------------------------
- def lose_rage(value = 1)
- @rage = 0 if @rage == nil
- @rage = [@rage - value, 0].max
- end
- #--------------------------------------------------------------------------
- # new method: cooldown
- #--------------------------------------------------------------------------
- def cooldown(skill_id)
- skill_id = skill_id.id if skill_id.is_a?(RPG::Skill)
- @cooldown = {} if @cooldown == nil
- return @cooldown[skill_id].to_i
- end
- #--------------------------------------------------------------------------
- # new method: make_cooldown
- #--------------------------------------------------------------------------
- def make_cooldown(skill_id, value = nil)
- skill_id = skill_id.id if skill_id.is_a?(RPG::Skill)
- @cooldown = {} if @cooldown == nil
- value = $data_skills[skill_id].cooldown if value == nil
- @cooldown[skill_id] = value
- #---
- @cooldown_clockticks = {} if @cooldown_clockticks == nil
- ctr = 32
- if $scene.is_a?(Scene_Battle)
- ctr = YEM::BATTLE_ENGINE::ATB_RULES[:turns_ctr] if $scene.atb?
- ctr = YEM::BATTLE_ENGINE::CTB_RULES[:turns_ctr] if $scene.ctb?
- end
- @cooldown_clockticks[skill_id] = ctr
- end
- #--------------------------------------------------------------------------
- # new method: clear_cooldowns
- #--------------------------------------------------------------------------
- def clear_cooldowns; @cooldown = {}; end
- #--------------------------------------------------------------------------
- # new method: update_all_cooldown
- #--------------------------------------------------------------------------
- def update_all_cooldown
- @cooldown = {} if @cooldown == nil
- return if @cooldown == {}
- for key in @cooldown
- skill_id = key[0]
- update_cooldown(skill_id)
- end
- end
- #--------------------------------------------------------------------------
- # new method: update_cooldown
- #--------------------------------------------------------------------------
- def update_cooldown(skill_id)
- @cooldown = {} if @cooldown == nil
- return if @cooldown[skill_id] == nil
- value = 1
- @cooldown[skill_id] -= value
- return unless @cooldown[skill_id] <= 0
- @cooldown.delete(skill_id)
- @cooldown_clockticks.delete(skill_id)
- end
- #--------------------------------------------------------------------------
- # new method: update_clocktick_cooldown
- #--------------------------------------------------------------------------
- def update_clocktick_cooldown
- return unless $scene.is_a?(Scene_Battle)
- @cooldown_clockticks = {} if @cooldown_clockticks == nil
- remove_skills = []
- ctr = YEM::BATTLE_ENGINE::ATB_RULES[:turns_ctr] if $scene.atb?
- ctr = YEM::BATTLE_ENGINE::CTB_RULES[:turns_ctr] if $scene.ctb?
- for key in @cooldown_clockticks
- skill_id = key[0]; ticks = key[1]
- if @cooldown_clockticks[skill_id] == nil
- remove_skills.push(skill_id)
- next
- end
- @cooldown_clockticks[skill_id] = ctr if
- @cooldown_clockticks[skill_id] == nil
- @cooldown_clockticks[skill_id] -= 1
- next unless @cooldown_clockticks[skill_id] <= 0
- @cooldown_clockticks[skill_id] = ctr
- update_cooldown(skill_id)
- $scene.refresh_battle_windows
- remove_skills.push(skill_id) if cooldown(skill_id) <= 0
- end
- #---
- for skill_id in remove_skills
- @cooldown_clockticks.delete(skill_id)
- end
- end
- #--------------------------------------------------------------------------
- # new method: skill_limited?
- #--------------------------------------------------------------------------
- def skill_limited?(skill_id)
- skill_id = skill_id.id if skill_id.is_a?(RPG::Skill)
- skill = $data_skills[skill_id]
- return false if skill.limited_use <= 0
- @limited_use = {} if @limited_use == nil
- return (@limited_use[skill_id].to_i >= skill.limited_use)
- end
- #--------------------------------------------------------------------------
- # new method: clear_limited_use
- #--------------------------------------------------------------------------
- def clear_limited_use; @limited_use = {}; end
- #--------------------------------------------------------------------------
- # new method: make_limited
- #--------------------------------------------------------------------------
- def make_limited(skill_id, value = 1)
- skill_id = skill_id.id if skill_id.is_a?(RPG::Skill)
- return if $data_skills[skill_id].limited_use <= 0
- @limited_use = {} if @limited_use == nil
- @limited_use[skill_id] = 0 if @limited_use[skill_id] == nil
- @limited_use[skill_id] += value
- end
- #--------------------------------------------------------------------------
- # new method: ptb_provided_turns
- #--------------------------------------------------------------------------
- def ptb_provided_turns
- return 0 unless movable?
- return @cache_ptb[:provided_turns] if @cache_ptb[:provided_turns] != nil
- result = YEM::BATTLE_ENGINE::PTB_RULES[:provided_turns]
- #---
- if self.actor?
- for equip in equips.compact; result += equip.ptb_bonus; end
- elsif self.enemy?
- result = enemy.ptb_turns
- end
- if @cache_states[:ptb_bonus] == nil
- @cache_states[:ptb_bonus] = 0
- for state in states
- @cache_states[:ptb_bonus] += state.ptb_bonus
- end
- end
- result += @cache_states[:ptb_bonus]
- #---
- @cache_ptb[:provided_turns] = result
- return @cache_ptb[:provided_turns]
- end
- #--------------------------------------------------------------------------
- # new method: ptb_max_cancel
- #--------------------------------------------------------------------------
- def ptb_max_cancel
- return @cache_ptb[:max_cancel] if @cache_ptb[:max_cancel] != nil
- result = YEM::BATTLE_ENGINE::PTB_RULES[:max_actor_cancel]
- #---
- if self.actor?
- for equip in equips.compact; result += equip.ptb_max_cancel; end
- elsif self.enemy?
- result = enemy.ptb_max_cancel
- end
- if @cache_states[:ptb_max_cancel] == nil
- @cache_states[:ptb_max_cancel] = 0
- for state in states
- @cache_states[:ptb_max_cancel] += state.ptb_max_cancel
- end
- end
- result += @cache_states[:ptb_max_cancel]
- #---
- @cache_ptb[:max_cancel] = result
- return @cache_ptb[:max_cancel]
- end
- #--------------------------------------------------------------------------
- # new method: ptb_max_regain
- #--------------------------------------------------------------------------
- def ptb_max_regain
- return @cache_ptb[:max_regain] if @cache_ptb[:max_regain] != nil
- result = YEM::BATTLE_ENGINE::PTB_RULES[:max_actor_regain]
- #---
- if self.actor?
- for equip in equips.compact; result += equip.ptb_max_regain; end
- elsif self.enemy?
- result = enemy.ptb_max_regain
- end
- if @cache_states[:ptb_max_regain] == nil
- @cache_states[:ptb_max_regain] = 0
- for state in states
- @cache_states[:ptb_max_regain] += state.ptb_max_regain
- end
- end
- result += @cache_states[:ptb_max_regain]
- #---
- @cache_ptb[:max_regain] = result
- return @cache_ptb[:max_regain]
- end
- #--------------------------------------------------------------------------
- # new method: ptb_obj_effect
- #--------------------------------------------------------------------------
- def ptb_obj_effect(battler, obj)
- return unless $scene.is_a?(Scene_Battle)
- return unless $scene.ptb?
- return if obj == nil
- if obj.ptb_turn_gain > 0
- battler.action.friends_unit.gain_bonus(nil, obj.ptb_turn_gain, false)
- end
- if obj.ptb_turn_loss > 0
- battler.action.friends_unit.cancel_turn(nil, obj.ptb_turn_loss, false)
- end
- end
- #--------------------------------------------------------------------------
- # new method: atb_position
- #--------------------------------------------------------------------------
- def atb_position
- @atb_speed = 0 if @atb_speed == nil
- value = @atb_speed * 300 / $game_troop.atb_max
- value = [[value, 0].max, 300].min
- return value
- end
- #--------------------------------------------------------------------------
- # new method: reset_atb_speed
- #--------------------------------------------------------------------------
- def reset_atb_speed
- @atb_speed = 0
- @atb_speed_bonus = 0
- action.clear
- action.atb_queue_down
- make_action if self.actor? and self.auto_battle
- return unless self.enemy?
- make_action
- action_bonus_speed
- @turn_count += 1
- end
- #--------------------------------------------------------------------------
- # new method: update_atb_speed
- #--------------------------------------------------------------------------
- def update_atb_speed
- update_clocktick_states
- update_clocktick_equip
- update_clocktick_cooldown
- return if active_battler?
- return unless movable?
- return if $game_troop.atb_ready.include?(self)
- value = self.agi
- value += @atb_speed_bonus if @atb_speed >= $game_troop.atb_threshold
- value = [value, Integer(base_agi*$game_troop.atb_min_speed)].max
- @atb_speed += value
- confirm_atb_speed
- end
- #--------------------------------------------------------------------------
- # new method: confirm_atb_speed
- #--------------------------------------------------------------------------
- def confirm_atb_speed
- if @atb_speed >= $game_troop.atb_threshold
- action.atb_guarding = false
- end
- return unless @atb_speed >= $game_troop.atb_max
- $game_troop.atb_ready.push(self)
- end
- #--------------------------------------------------------------------------
- # new method: action_bonus_speed
- #--------------------------------------------------------------------------
- def action_bonus_speed
- action.make_speed
- value = action.speed
- value -= self.agi
- @atb_speed_bonus = value
- end
- #--------------------------------------------------------------------------
- # new method: atb_reached_treshold?
- #--------------------------------------------------------------------------
- def atb_reached_treshold?
- return false unless @atb_speed >= $game_troop.atb_threshold
- if berserker? or confusion?
- if !action.attack?
- action.set_attack
- group = (actor? and berserker?) ? $game_troop : $game_party
- size = group.existing_members.size
- action.target_index = group.existing_members[rand(size)]
- action.atb_queue_down
- end
- return false
- end
- return true if action.wait?
- return true if action.nothing?
- return false
- end
- #--------------------------------------------------------------------------
- # new method: atb_change_effect
- #--------------------------------------------------------------------------
- def atb_change_effect(user, obj = nil)
- return unless $scene.is_a?(Scene_Battle)
- return unless $scene.atb?
- @atb_speed = 0 if @atb_speed == nil
- if obj == nil
- @atb_speed += user.atb_change_value
- else
- change = $game_troop.atb_max * obj.atb_change_per / 100
- change += obj.atb_change_set
- @atb_speed += change
- end
- @atb_speed = [[@atb_speed, 0].max, $game_troop.atb_max].min
- confirm_atb_speed
- end
- #--------------------------------------------------------------------------
- # new method: atb_change_value
- #--------------------------------------------------------------------------
- def atb_change_value; return 0; end
- #--------------------------------------------------------------------------
- # new method: create_atb_reset
- #--------------------------------------------------------------------------
- def create_atb_reset(obj = nil)
- return unless $scene.is_a?(Scene_Battle)
- return unless $scene.atb?
- if obj == nil
- @atb_reset_speed = 0
- return
- end
- @atb_reset_speed = $game_troop.atb_max * obj.atb_reset / 100
- end
- #--------------------------------------------------------------------------
- # new method: process_atb_reset
- #--------------------------------------------------------------------------
- def process_atb_reset
- @atb_reset_speed = 0 if @atb_reset_speed == nil
- if @cache_states[:atb_reset_plus] == nil
- @cache_states[:atb_reset_plus] = 0
- for state in states
- next if state == nil
- @cache_states[:atb_reset_plus] += state.atb_reset_plus
- end
- end
- @atb_reset_speed += @cache_states[:atb_reset_plus]
- return if @atb_reset_speed == 0
- speed = $game_troop.atb_max * @atb_reset_speed / 100
- @atb_speed = [[speed, $game_troop.atb_max].min, 0].max
- end
- #--------------------------------------------------------------------------
- # new method: ctb_active?
- #--------------------------------------------------------------------------
- def ctb_active?
- return false unless $scene.is_a?(Scene_Battle)
- return ($game_troop.ctb_ready[0] == self)
- end
- #--------------------------------------------------------------------------
- # new method: ctb_ctr
- #--------------------------------------------------------------------------
- def ctb_ctr
- return @ctb_cache if @ctb_cache != nil
- value = 0
- @ctb_speed = 0 if @ctb_speed == nil
- @ctb_prediction = @ctb_speed + ctb_speed_bonus
- loop do
- break if @ctb_prediction >= $game_troop.ctb_max
- value += 1
- @ctb_prediction += self.agi
- end
- @ctb_cache = value
- return @ctb_cache
- end
- #--------------------------------------------------------------------------
- # new method: ctb_total_speed
- #--------------------------------------------------------------------------
- def ctb_total_speed; return @ctb_speed + ctb_speed_bonus; end
- #--------------------------------------------------------------------------
- # new method: ctb_speed_bonus
- #--------------------------------------------------------------------------
- def ctb_speed_bonus
- case self.action.kind
- when 0 # Basic
- return 0
- when 1, 2 # Skill
- obj = self.action.skill if self.action.skill?
- obj = self.action.item if self.action.item?
- value = [obj.speed, 0].min
- value = YEM::BATTLE_ENGINE::CTB_RULES[:speed_rate] * value
- return Integer(value)
- end
- return 0
- end
- #--------------------------------------------------------------------------
- # new method: reset_ctb_speed
- #--------------------------------------------------------------------------
- def reset_ctb_speed
- @ctb_reset_speed = 0 if @ctb_reset_speed == nil
- @ctb_speed = 0
- if action.skill? or action.item?
- obj = action.skill if action.skill?
- obj = action.item if action.item?
- if obj.speed > 0
- multiplier = YEM::BATTLE_ENGINE::CTB_RULES[:speed_rate]
- @ctb_speed += Integer(obj.speed * multiplier)
- end
- end
- action.clear
- if @ctb_reset_speed != 0
- @ctb_speed += $game_troop.ctb_max * @ctb_reset_speed / 100
- end
- @ctb_reset_speed = nil
- return unless self.enemy?
- make_action
- @turn_count += 1
- end
- #--------------------------------------------------------------------------
- # new method: update_ctb_speed
- #--------------------------------------------------------------------------
- def update_ctb_speed
- return unless $scene.is_a?(Scene_Battle)
- update_clocktick_states
- update_clocktick_equip
- update_clocktick_cooldown
- return unless movable?
- @ctb_speed += self.agi
- confirm_ctb_speed
- end
- #--------------------------------------------------------------------------
- # new method: confirm_ctb_speed
- #--------------------------------------------------------------------------
- def confirm_ctb_speed
- return unless ctb_total_speed >= $game_troop.ctb_max
- $game_troop.ctb_ready.push(self)
- $game_troop.ctb_ready.sort! { |a,b|
- if a.ctb_ctr != b.ctb_ctr
- a.ctb_ctr <=> b.ctb_ctr
- elsif a.ctb_prediction != b.ctb_prediction
- b.ctb_prediction <=> a.ctb_prediction
- elsif a.agi != b.agi
- b.agi <=> a.agi
- else
- b.screen_x <=> a.screen_x
- end }
- end
- #--------------------------------------------------------------------------
- # new method: update_clocktick_states
- #--------------------------------------------------------------------------
- def update_clocktick_states
- return unless $scene.is_a?(Scene_Battle)
- @state_clockticks = {} if @state_clockticks == nil
- remove_states = []
- ctr = YEM::BATTLE_ENGINE::ATB_RULES[:turns_ctr] if $scene.atb?
- ctr = YEM::BATTLE_ENGINE::CTB_RULES[:turns_ctr] if $scene.ctb?
- for key in @state_clockticks
- state_id = key[0]; ticks = key[1]
- next if state_id == 1
- next if rand(100) >= $data_states[state_id].auto_release_prob
- if @state_clockticks[state_id] == nil
- remove_states.push(state_id)
- next
- end
- @state_clockticks[state_id] -= 1
- next unless @state_clockticks[state_id] <= 0
- perform_slip_effect($data_states[state_id])
- next if @state_turns[state_id] == nil
- @state_turns[state_id] -= 1
- @state_clockticks[state_id] = ctr
- lunatic_status_effects($data_states[state_id], :while)
- if @state_turns[state_id] < 0
- remove_state(state_id)
- @removed_states.push(state_id)
- remove_states.push(state_id)
- lunatic_status_effects(state_id, :leave)
- $scene.pause_atb(true)
- $scene.display_state_changes(self) if exist?
- clear_state_tags
- $scene.pause_atb(false)
- $scene.refresh_battle_windows
- end
- @update_states = true
- end
- #---
- for state_id in remove_states
- next if state?(state_id)
- @state_clockticks.delete(state_id)
- @update_states = true
- end
- end
- #--------------------------------------------------------------------------
- # new method: update_clocktick_equip
- #--------------------------------------------------------------------------
- def update_clocktick_equip
- return unless $scene.is_a?(Scene_Battle)
- return unless self.actor?
- return if @equip_clocktick == nil
- @equip_clocktick -= 1
- return unless @equip_clocktick <= 0
- @equip_cooldown -= 1
- if @equip_cooldown > 0
- @equip_clocktick = YEM::BATTLE_ENGINE::ATB_RULES[:turns_ctr]
- else
- @equip_clocktick = nil
- @update_commands = true
- end
- end
- #--------------------------------------------------------------------------
- # new method: ctb_change_effect
- #--------------------------------------------------------------------------
- def ctb_change_effect(user, obj = nil)
- return unless $scene.is_a?(Scene_Battle)
- return unless $scene.ctb?
- @ctb_speed = 0 if @ctb_speed == nil
- if obj == nil
- @ctb_speed += user.ctb_change_value
- else
- change = $game_troop.ctb_max * obj.ctb_change_per / 100
- change += obj.ctb_change_set
- @ctb_speed += change
- end
- @ctb_speed = [@ctb_speed, 0].max
- confirm_ctb_speed
- end
- #--------------------------------------------------------------------------
- # new method: ctb_change_value
- #--------------------------------------------------------------------------
- def ctb_change_value; return 0; end
- #--------------------------------------------------------------------------
- # new method: create_ctb_reset
- #--------------------------------------------------------------------------
- def create_ctb_reset(obj = nil)
- return unless $scene.is_a?(Scene_Battle)
- return unless $scene.ctb?
- if obj == nil
- @ctb_reset_speed = 0
- return
- end
- @ctb_reset_speed = obj.ctb_reset
- end
- #--------------------------------------------------------------------------
- # new method: process_ctb_reset
- #--------------------------------------------------------------------------
- def process_ctb_reset
- @ctb_reset_speed = 0 if @ctb_reset_speed == nil
- if @cache_states[:ctb_reset_plus] == nil
- @cache_states[:ctb_reset_plus] = 0
- for state in states
- next if state == nil
- @cache_states[:ctb_reset_plus] += state.ctb_reset_plus
- end
- end
- @ctb_reset_speed += @cache_states[:ctb_reset_plus]
- return if @ctb_reset_speed == 0
- speed = $game_troop.ctb_max * @ctb_reset_speed / 100
- @ctb_speed = [[speed, $game_troop.ctb_max].min, 0].max
- end
- #--------------------------------------------------------------------------
- # anti-crash method: dex, dex=, res, res=
- #--------------------------------------------------------------------------
- unless $imported["DEX Stat"]
- def dex; return agi; end
- def dex=(value); agi=(value); end
- end
- unless $imported["RES Stat"]
- def res; return spi; end
- def res=(value); spi=(value); end
- end
- end # Game_Battler
- #===============================================================================
- # Game_BattleAction
- #===============================================================================
- class Game_BattleAction
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :atb_guarding
- attr_accessor :atb_queue_kind
- attr_accessor :atb_queue_basic
- attr_accessor :atb_queue_target
- attr_accessor :ctb_guarding
- attr_accessor :ctb_guarding_queue
- attr_accessor :ptb_guarding
- #--------------------------------------------------------------------------
- # alias method: clear
- #--------------------------------------------------------------------------
- alias clear_battleaction_bem clear unless $@
- def clear
- clear_battleaction_bem if allow_clear?
- @basic = 3
- end
- #--------------------------------------------------------------------------
- # new method: allow_clear?
- #--------------------------------------------------------------------------
- def allow_clear?
- if $scene.is_a?(Scene_Battle) and $scene.atb?
- battler.atb_speed = 0 if battler.atb_speed == nil
- return false if battler.atb_speed >= $game_troop.atb_threshold
- return true
- end
- return true
- end
- #--------------------------------------------------------------------------
- # alias method: set_attack
- #--------------------------------------------------------------------------
- alias set_attack_bem set_attack unless $@
- def set_attack
- if $scene.is_a?(Scene_Battle) and $scene.atb? and !@battler.make_auto_skill
- @atb_queue_kind = 0
- @atb_queue_basic = 0
- return
- end
- set_attack_bem
- end
- #--------------------------------------------------------------------------
- # alias method: set_guard
- #--------------------------------------------------------------------------
- alias set_guard_bem set_guard unless $@
- def set_guard
- if $scene.is_a?(Scene_Battle) and $scene.ptb?
- @ptb_guarding = true
- return
- elsif $scene.is_a?(Scene_Battle) and $scene.atb?
- @atb_queue_kind = 0
- @atb_queue_basic = 1
- return
- elsif $scene.is_a?(Scene_Battle) and $scene.ctb?
- @ctb_guarding_queue = true
- return
- end
- set_guard_bem
- end
- #--------------------------------------------------------------------------
- # alias method: guard?
- #--------------------------------------------------------------------------
- alias guard_questionmark_bem guard? unless $@
- def guard?
- return true if @ptb_guarding
- return @atb_guarding if $scene.is_a?(Scene_Battle) and $scene.atb?
- return @ctb_guarding if $scene.is_a?(Scene_Battle) and $scene.ctb?
- return guard_questionmark_bem
- end
- #--------------------------------------------------------------------------
- # new method: set_escape
- #--------------------------------------------------------------------------
- def set_escape
- if $scene.is_a?(Scene_Battle) and $scene.atb?
- @atb_queue_kind = 0
- @atb_queue_basic = 2
- return
- end
- @kind = 0
- @basic = 2
- end
- #--------------------------------------------------------------------------
- # new method: escape?
- #--------------------------------------------------------------------------
- def escape?; return (@kind == 0 and @basic == 2); end
- #--------------------------------------------------------------------------
- # alias method: set_skill
- #--------------------------------------------------------------------------
- alias set_skill_bem set_skill unless $@
- def set_skill(skill_id)
- if $scene.is_a?(Scene_Battle) and $scene.atb? and !@battler.make_auto_skill
- @atb_queue_kind = 1
- @atb_queue_basic = skill_id
- return
- end
- set_skill_bem(skill_id)
- end
- #--------------------------------------------------------------------------
- # alias method: set_item
- #--------------------------------------------------------------------------
- alias set_item_bem set_item unless $@
- def set_item(item_id)
- if $scene.is_a?(Scene_Battle) and $scene.atb?
- @atb_queue_kind = 2
- @atb_queue_basic = item_id
- return
- end
- set_item_bem(item_id)
- end
- #--------------------------------------------------------------------------
- # new method: wait?
- #--------------------------------------------------------------------------
- def wait?
- return true if nothing?
- return (@kind == 0 and @basic == 3)
- end
- #--------------------------------------------------------------------------
- # new method: atb_queue_down
- #--------------------------------------------------------------------------
- def atb_queue_down
- return unless $scene.is_a?(Scene_Battle)
- return unless $scene.atb?
- return unless wait? or battler.atb_speed <= $game_troop.atb_threshold
- @kind = @atb_queue_kind
- case @kind
- when 0
- @basic = @atb_queue_basic
- when 1
- @skill_id = @atb_queue_basic
- when 2
- @item_id = @atb_queue_basic
- end
- @target_index = @atb_queue_target
- battler.action_bonus_speed
- @atb_queue_kind = 0
- @atb_queue_basic = 3
- @atb_queue_target = 0
- if $scene.is_a?(Scene_Battle)
- return if $scene.status_window == nil
- $scene.status_window.battle_refresh_call = true
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: valid?
- #--------------------------------------------------------------------------
- def valid?
- return false if nothing?
- return true if @forcing
- return false unless battler.movable?
- if skill?
- return false unless battler.skill_can_use?(skill)
- elsif item?
- return false unless battler.item_can_use?(item)
- end
- return true
- end
- #--------------------------------------------------------------------------
- # overwrite method: make_speed
- #--------------------------------------------------------------------------
- def make_speed
- @speed = battler.agi
- @speed += skill.speed if skill?
- @speed += item.speed if item?
- @speed += guard_speed if guard?
- @speed += fast_attack_speed if battler.fast_attack
- @speed = -4444 if battler.dead?
- end
- #--------------------------------------------------------------------------
- # new method: guard_speed
- #--------------------------------------------------------------------------
- def guard_speed; return 2000; end
- #--------------------------------------------------------------------------
- # new method: fast_attack_speed
- #--------------------------------------------------------------------------
- def fast_attack_speed; return 1000; end
- #--------------------------------------------------------------------------
- # new method: target_index=
- #--------------------------------------------------------------------------
- def target_index=(value)
- if $scene.atb?
- @atb_queue_target = value
- return
- end
- @target_index = value
- end
- #--------------------------------------------------------------------------
- # overwrite method: make_obj_targets
- #--------------------------------------------------------------------------
- def make_obj_targets(obj)
- targets = custom_battle_targets(obj)
- for target in targets
- next if target == nil
- group = target.actor? ? $game_party : $game_troop
- targets += group.area_targets(target, obj)
- end
- return targets
- end
- end # Game_BattleAction
- #===============================================================================
- # Game_Actor
- #===============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :actor_id
- attr_accessor :battle_command_index
- attr_accessor :equip_cooldown
- #--------------------------------------------------------------------------
- # alias method: setup
- #--------------------------------------------------------------------------
- alias setup_game_actor_bem setup unless $@
- def setup(actor_id)
- setup_game_actor_bem(actor_id)
- @cooldown = {}
- @limited_use = {}
- @state_origin = {}
- @battle_command_index = 0
- @equip_cooldown = 0
- @bonus_element_affinity = nil
- @bonus_state_affinity = nil
- create_affinity_bonus
- end
- #--------------------------------------------------------------------------
- # alias method: change_equip
- #--------------------------------------------------------------------------
- alias change_equip_bem change_equip unless $@
- def change_equip(equip_type, item, test = false)
- change_equip_bem(equip_type, item, test)
- clear_battle_cache
- if $game_temp.in_battle
- @update_states = true
- @update_maxhp = true
- @update_maxmp = true
- @update_commands = true
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: element_rate
- #--------------------------------------------------------------------------
- def element_rate(element_id)
- if @cache_element_rate[element_id] != nil and $scene.is_a?(Scene_Battle)
- return @cache_element_rate[element_id]
- end
- rank = apply_element_rank(element_id)
- result = element_rate_table(element_id, rank)
- for armor in armors.compact
- result /= 2 if armor.element_set.include?(element_id)
- end
- for state in states
- result /= 2 if state.element_set.include?(element_id)
- end
- result
- @cache_element_rate[element_id] = result
- return @cache_element_rate[element_id]
- end
- #--------------------------------------------------------------------------
- # overwrite method: state_probability
- #--------------------------------------------------------------------------
- def state_probability(state_id)
- if @cache_state_rate[state_id] != nil and $scene.is_a?(Scene_Battle)
- rate = element_apply_state_rate(@cache_state_rate[state_id])
- return rate
- end
- if $data_states[state_id].nonresistance
- result = 100
- else
- rank = apply_state_rank(state_id)
- result = state_probability_table(state_id, rank)
- end
- @cache_state_rate[state_id] = result
- rate = element_apply_state_rate(@cache_state_rate[state_id])
- return rate
- end
- #--------------------------------------------------------------------------
- # alias method: element_set
- #--------------------------------------------------------------------------
- alias element_set_actor_esa element_set unless $@
- def element_set
- return @cache_element_set if @cache_element_set != nil
- result = element_set_actor_esa
- #---
- for equip in equips.compact
- result += equip.attack_element
- end
- #---
- for state in states
- result += state.attack_element
- end
- #---
- @cache_element_set = result.uniq
- return @cache_element_set
- end
- #--------------------------------------------------------------------------
- # alias method: plus_state_set
- #--------------------------------------------------------------------------
- alias plus_state_set_actor_esa plus_state_set unless $@
- def plus_state_set
- return @cache_state_set if @cache_state_set != nil
- result = plus_state_set_actor_esa
- #---
- for equip in equips.compact
- result += equip.attack_state
- end
- #---
- for state in states
- result += state.attack_state
- end
- #---
- @cache_state_set = result.uniq
- return @cache_state_set
- end
- #--------------------------------------------------------------------------
- # alias method: hit
- #--------------------------------------------------------------------------
- alias game_actor_hit_bem hit unless $@
- def hit
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:hit] if @cache_params[:hit] != nil
- end
- #---
- n = game_actor_hit_bem
- for state in states
- stack(state).times do
- n = n * state.hit_rate / 100.0
- end
- end
- for state in states
- next if state.hit_set == 0
- n += state.hit_set * stack(state)
- end
- #---
- @cache_params[:hit] = [Integer(n), 0].max
- return @cache_params[:hit]
- end
- #--------------------------------------------------------------------------
- # alias method: eva
- #--------------------------------------------------------------------------
- alias game_actor_eva_bem eva unless $@
- def eva
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:eva] if @cache_params[:eva] != nil
- end
- #---
- n = game_actor_eva_bem
- for state in states
- stack(state).times do
- n = n * state.eva_rate / 100.0
- end
- end
- for state in states
- next if state.eva_set == 0
- n += state.eva_set * stack(state)
- end
- #---
- @cache_params[:eva] = [Integer(n), 0].max
- return @cache_params[:eva]
- end
- #--------------------------------------------------------------------------
- # alias method: cri
- #--------------------------------------------------------------------------
- alias game_actor_cri_bem cri unless $@
- def cri
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:cri] if @cache_params[:cri] != nil
- end
- #---
- n = game_actor_cri_bem
- for state in states
- stack(state).times do
- n = n * state.cri_rate / 100.0
- end
- end
- for state in states
- next if state.cri_set == 0
- n += state.cri_set * stack(state)
- end
- #---
- @cache_params[:cri] = [Integer(n), 0].max
- return @cache_params[:cri]
- end
- #--------------------------------------------------------------------------
- # alias method: odds
- #--------------------------------------------------------------------------
- alias game_actor_odds_bem odds unless $@
- def odds
- clear_battle_cache if @cache_params == nil
- if $scene.is_a?(Scene_Battle)
- return @cache_params[:odds] if @cache_params[:odds] != nil
- end
- #---
- n = game_actor_odds_bem
- for state in states
- stack(state).times do
- n = n * state.odds_rate / 100.0
- end
- end
- for state in states
- next if state.odds_set == 0
- n += state.odds_set * stack(state)
- end
- #---
- @cache_params[:odds] = [Integer(n), 1].max
- return @cache_params[:odds]
- end
- #--------------------------------------------------------------------------
- # alias method: super_guard
- #--------------------------------------------------------------------------
- alias super_guard_bem super_guard unless $@
- def super_guard
- return true if traits.include?(:super_guard)
- return super_guard_bem
- end
- #--------------------------------------------------------------------------
- # overwrite method: pharmacology
- #--------------------------------------------------------------------------
- alias pharmacology_bem pharmacology unless $@
- def pharmacology
- return true if traits.include?(:pharmacology)
- return pharmacology_bem
- end
- #--------------------------------------------------------------------------
- # alias method: fast_attack
- #--------------------------------------------------------------------------
- alias fast_attack_bem fast_attack unless $@
- def fast_attack
- return true if traits.include?(:fast_attack)
- return fast_attack_bem
- end
- #--------------------------------------------------------------------------
- # alias method: dual_attack
- #--------------------------------------------------------------------------
- alias dual_attack_bem dual_attack unless $@
- def dual_attack
- return true if traits.include?(:dual_attack)
- return dual_attack_bem
- end
- #--------------------------------------------------------------------------
- # alias method: prevent_critical
- #--------------------------------------------------------------------------
- alias prevent_critical_bem prevent_critical unless $@
- def prevent_critical
- return true if traits.include?(:prevent_critical)
- return prevent_critical_bem
- end
- #--------------------------------------------------------------------------
- # alias method: half_mp_cost
- #--------------------------------------------------------------------------
- alias half_mp_cost_bem half_mp_cost unless $@
- def half_mp_cost
- return true if traits.include?(:half_mp_cost)
- return half_mp_cost_bem
- end
- #--------------------------------------------------------------------------
- # alias method: double_exp_gain
- #--------------------------------------------------------------------------
- alias double_exp_gain_bem double_exp_gain unless $@
- def double_exp_gain
- return true if traits.include?(:double_exp_gain)
- return double_exp_gain_bem
- end
- #--------------------------------------------------------------------------
- # alias method: auto_hp_recover
- #--------------------------------------------------------------------------
- alias auto_hp_recover_bem auto_hp_recover unless $@
- def auto_hp_recover
- return true if traits.include?(:auto_hp_recover)
- return auto_hp_recover_bem
- end
- #--------------------------------------------------------------------------
- # overwrite method: skill_can_use?
- #--------------------------------------------------------------------------
- def skill_can_use?(skill); return super(skill); end
- #--------------------------------------------------------------------------
- # new method: item_can_use?
- #--------------------------------------------------------------------------
- def item_can_use?(item)
- return false if item == nil
- return false if item.pharmacology_only and !pharmacology
- return false if item.restrict[:actors].include?(@actor_id)
- return false if item.restrict[:classes].include?(@class_id)
- return false if item_restriction?(item)
- return action.friends_unit.item_can_use?(item)
- end
- #--------------------------------------------------------------------------
- # alias method: make_action
- #--------------------------------------------------------------------------
- alias make_action_bem make_action unless $@
- def make_action
- @make_auto_skill = true
- make_action_bem
- @make_auto_skill = nil
- action_bonus_speed if $scene.is_a?(Scene_Battle) and $scene.atb?
- end
- #--------------------------------------------------------------------------
- # new method: attack_formulas
- #--------------------------------------------------------------------------
- def attack_formulas
- result = []
- for weapon in weapons.compact
- result = weapon.damage_formula
- break
- end
- result = ["ATK WEAPON"] if result == []
- return result
- end
- #--------------------------------------------------------------------------
- # new method: attack_vocab
- #--------------------------------------------------------------------------
- def attack_vocab
- return weapons.compact[0].attack_vocab if weapons.compact != []
- return Vocab.attack
- end
- #--------------------------------------------------------------------------
- # new method: attack_setup_actions
- #--------------------------------------------------------------------------
- def attack_setup_actions
- return weapons.compact[0].setup_action_list if weapons.compact != []
- return super
- end
- #--------------------------------------------------------------------------
- # new method: attack_whole_actions
- #--------------------------------------------------------------------------
- def attack_whole_actions
- return weapons.compact[0].whole_action_list if weapons.compact != []
- return super
- end
- #--------------------------------------------------------------------------
- # new method: attack_target_actions
- #--------------------------------------------------------------------------
- def attack_target_actions
- return weapons.compact[0].target_action_list if weapons.compact != []
- return super
- end
- #--------------------------------------------------------------------------
- # new method: attack_follow_actions
- #--------------------------------------------------------------------------
- def attack_follow_actions
- return weapons.compact[0].follow_action_list if weapons.compact != []
- return super
- end
- #--------------------------------------------------------------------------
- # new method: attack_finish_actions
- #--------------------------------------------------------------------------
- def attack_finish_actions
- return weapons.compact[0].finish_action_list if weapons.compact != []
- return super
- end
- #--------------------------------------------------------------------------
- # new method: guard_vocab
- #--------------------------------------------------------------------------
- def guard_vocab
- for armor in armors.compact
- next unless armor.kind == 0
- return armor.guard_vocab
- end
- return Vocab.guard
- end
- #--------------------------------------------------------------------------
- # new method: guard_actions
- #--------------------------------------------------------------------------
- def guard_actions
- for armor in armors.compact
- next unless armor.kind == 0
- return armor.guard_action_list
- end
- return super
- end
- #--------------------------------------------------------------------------
- # new method: skill_vocab
- #--------------------------------------------------------------------------
- def skill_vocab
- return self.class.skill_name if self.class.skill_name_valid
- return Vocab.skill
- end
- #--------------------------------------------------------------------------
- # new method: total_skills
- #--------------------------------------------------------------------------
- def total_skills
- result = skills
- return result
- end
- #--------------------------------------------------------------------------
- # new method: confirm_atb_speed
- #--------------------------------------------------------------------------
- def confirm_atb_speed
- if atb_reached_treshold?
- if auto_battle
- make_action
- action_bonus_speed
- else
- @atb_speed = $game_troop.atb_threshold
- return
- end
- end
- super
- end
- #--------------------------------------------------------------------------
- # new method: atb_change_value
- #--------------------------------------------------------------------------
- def atb_change_value
- result = 0
- percent = 0
- for weapon in weapons.compact
- percent += weapon.atb_change_per
- result += weapon.atb_change_set
- end
- result += $game_troop.atb_max * percent / 100
- return result
- end
- #--------------------------------------------------------------------------
- # new method: create_atb_reset
- #--------------------------------------------------------------------------
- def create_atb_reset(obj = nil)
- if obj == nil
- @atb_reset_speed = 0
- for weapon in weapons.compact
- @atb_reset_speed += weapon.atb_reset
- end
- return
- end
- super(obj)
- end
- #--------------------------------------------------------------------------
- # new method: process_atb_reset
- #--------------------------------------------------------------------------
- def process_atb_reset
- @atb_reset_speed = 0 if @atb_reset_speed == nil
- for equip in equips.compact
- @atb_reset_speed += equip.atb_reset_plus
- end
- super
- end
- #--------------------------------------------------------------------------
- # new method: ctb_change_value
- #--------------------------------------------------------------------------
- def ctb_change_value
- result = 0
- percent = 0
- for weapon in weapons.compact
- percent += weapon.ctb_change_per
- result += weapon.ctb_change_set
- end
- result += $game_troop.ctb_max * percent / 100
- return result
- end
- #--------------------------------------------------------------------------
- # new method: create_ctb_reset
- #--------------------------------------------------------------------------
- def create_ctb_reset(obj = nil)
- if obj == nil
- @ctb_reset_speed = 0
- for weapon in weapons.compact
- @ctb_reset_speed += weapon.ctb_reset
- end
- return
- end
- super(obj)
- end
- #--------------------------------------------------------------------------
- # new method: process_ctb_reset
- #--------------------------------------------------------------------------
- def process_ctb_reset
- @ctb_reset_speed = 0 if @ctb_reset_speed == nil
- for equip in equips.compact
- @ctb_reset_speed += equip.ctb_reset_plus
- end
- super
- end
- end # Game_Actor
- #===============================================================================
- # Game_Enemy
- #===============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # new method: enemy?
- #--------------------------------------------------------------------------
- def enemy?; return true; end
- #--------------------------------------------------------------------------
- # alias method: hit
- #--------------------------------------------------------------------------
- alias game_enemy_hit_bem hit unless $@
- def hit
- clear_battle_cache if @cache_params == nil
- return @cache_params[:hit] if @cache_params[:hit] != nil
- #---
- n = game_enemy_hit_bem
- for state in states
- stack(state).times do
- n = n * state.hit_rate / 100.0
- end
- end
- for state in states
- next if state.hit_set == 0
- n += state.hit_set * stack(state)
- end
- #---
- @cache_params[:hit] = [Integer(n), 0].max
- return @cache_params[:hit]
- end
- #--------------------------------------------------------------------------
- # alias method: eva
- #--------------------------------------------------------------------------
- alias game_enemy_eva_bem eva unless $@
- def eva
- clear_battle_cache if @cache_params == nil
- return @cache_params[:eva] if @cache_params[:eva] != nil
- #---
- n = game_enemy_eva_bem
- for state in states
- stack(state).times do
- n = n * state.eva_rate / 100.0
- end
- end
- for state in states
- next if state.eva_set == 0
- n += state.eva_set * stack(state)
- end
- #---
- @cache_params[:eva] = [Integer(n), 0].max
- return @cache_params[:eva]
- end
- #--------------------------------------------------------------------------
- # alias method: cri
- #--------------------------------------------------------------------------
- alias game_enemy_cri_bem cri unless $@
- def cri
- clear_battle_cache if @cache_params == nil
- return @cache_params[:cri] if @cache_params[:cri] != nil
- #---
- n = game_enemy_cri_bem
- for state in states
- stack(state).times do
- n = n * state.cri_rate / 100.0
- end
- end
- for state in states
- next if state.cri_set == 0
- n += state.cri_set * stack(state)
- end
- #---
- @cache_params[:cri] = [Integer(n), 0].max
- return @cache_params[:cri]
- end
- #--------------------------------------------------------------------------
- # alias method: odds
- #--------------------------------------------------------------------------
- alias game_enemy_odds_bem odds unless $@
- def odds
- clear_battle_cache if @cache_params == nil
- return @cache_params[:odds] if @cache_params[:odds] != nil
- #---
- n = game_enemy_odds_bem
- for state in states
- stack(state).times do
- n = n * state.odds_rate / 100.0
- end
- end
- for state in states
- next if state.odds_set == 0
- n += state.odds_set * stack(state)
- end
- #---
- @cache_params[:odds] = [Integer(n), 1].max
- return @cache_params[:odds]
- end
- #--------------------------------------------------------------------------
- # overwrite method: element_rate
- #--------------------------------------------------------------------------
- def element_rate(element_id)
- if @cache_element_rate[element_id] != nil
- return @cache_element_rate[element_id]
- end
- rank = apply_element_rank(element_id)
- result = element_rate_table(element_id, rank)
- for state in states
- result /= 2 if state.element_set.include?(element_id)
- end
- @cache_element_rate[element_id] = result
- return @cache_element_rate[element_id]
- end
- #--------------------------------------------------------------------------
- # overwrite method: state_probability
- #--------------------------------------------------------------------------
- def state_probability(state_id)
- if @cache_state_rate[state_id] != nil
- rate = element_apply_state_rate(@cache_state_rate[state_id])
- return rate
- end
- if $data_states[state_id].nonresistance
- result = 100
- else
- rank = apply_state_rank(state_id)
- result = state_probability_table(state_id, rank)
- end
- @cache_state_rate[state_id] = result
- rate = element_apply_state_rate(@cache_state_rate[state_id])
- return rate
- end
- #--------------------------------------------------------------------------
- # new method: element_set
- #--------------------------------------------------------------------------
- def element_set
- return @cache_element_set if @cache_element_set != nil
- result = super
- result += enemy.attack_element
- for state in states
- result += state.attack_element
- end
- @cache_element_set = result.uniq
- return @cache_element_set
- end
- #--------------------------------------------------------------------------
- # new method: plus_state_set
- #--------------------------------------------------------------------------
- def plus_state_set
- return @cache_state_set if @cache_state_set != nil
- result = super
- result += enemy.attack_state
- for state in states
- result += state.attack_state
- end
- @cache_state_set = result.uniq
- return @cache_state_set
- end
- #--------------------------------------------------------------------------
- # new method: attack_formulas
- #--------------------------------------------------------------------------
- def attack_formulas; return enemy.damage_formula; end
- #--------------------------------------------------------------------------
- # new method: attack_setup_actions
- #--------------------------------------------------------------------------
- def attack_setup_actions; return enemy.setup_action_list; end
- #--------------------------------------------------------------------------
- # new method: attack_whole_actions
- #--------------------------------------------------------------------------
- def attack_whole_actions; return enemy.whole_action_list; end
- #--------------------------------------------------------------------------
- # new method: attack_target_actions
- #--------------------------------------------------------------------------
- def attack_target_actions; return enemy.target_action_list; end
- #--------------------------------------------------------------------------
- # new method: attack_follow_actions
- #--------------------------------------------------------------------------
- def attack_follow_actions; return enemy.follow_action_list; end
- #--------------------------------------------------------------------------
- # new method: attack_finish_actions
- #--------------------------------------------------------------------------
- def attack_finish_actions; return enemy.finish_action_list; end
- #--------------------------------------------------------------------------
- # new method: guard_actions
- #--------------------------------------------------------------------------
- def guard_actions; return enemy.guard_action_list; end
- #--------------------------------------------------------------------------
- # new method: total_skills
- #--------------------------------------------------------------------------
- def total_skills
- result = []
- for action in enemy.actions
- next unless action.kind == 1
- skill = $data_skills[action.skill_id]
- result.push(skill) unless result.include?(skill)
- end
- result.sort! { |a,b| a.id <=> b.id }
- return result.uniq
- end
- #--------------------------------------------------------------------------
- # overwrite method: perform_collapse
- #--------------------------------------------------------------------------
- def perform_collapse
- return unless $game_temp.in_battle
- return unless dead?
- @collapse = true
- Sound.play_enemy_collapse
- battler_animation_stance("DEAD") if use_battler_animations?
- return if $scene.target_enemy_window == nil
- $scene.target_enemy_window.refresh
- end
- #--------------------------------------------------------------------------
- # alias method: conditions_met?
- #--------------------------------------------------------------------------
- alias conditions_met_bem conditions_met? unless $@
- def conditions_met?(action)
- if action.condition_type == 1
- n = @turn_count
- a = action.condition_param1
- b = action.condition_param2
- return false if (b == 0 and n != a)
- return false if (b > 0 and (n < 1 or n < a or n % b != a % b))
- return true
- end
- return conditions_met_bem(action)
- end
- #--------------------------------------------------------------------------
- # new method: atb_change_value
- #--------------------------------------------------------------------------
- def atb_change_value
- result = 0
- result += enemy.atb_change_set
- result += $game_troop.atb_max * enemy.atb_change_per / 100
- return result
- end
- #--------------------------------------------------------------------------
- # new method: create_atb_reset
- #--------------------------------------------------------------------------
- def create_atb_reset(obj = nil)
- if obj == nil
- @atb_reset_speed = enemy.atb_reset
- return
- end
- super(obj)
- end
- #--------------------------------------------------------------------------
- # new method: ctb_change_value
- #--------------------------------------------------------------------------
- def ctb_change_value
- result = 0
- result += enemy.ctb_change_set
- result += $game_troop.ctb_max * enemy.ctb_change_per / 100
- return result
- end
- #--------------------------------------------------------------------------
- # new method: create_ctb_reset
- #--------------------------------------------------------------------------
- def create_ctb_reset(obj = nil)
- if obj == nil
- @ctb_reset_speed = enemy.ctb_reset
- return
- end
- super(obj)
- end
- end # Game_Enemy
- #===============================================================================
- # Game_Unit
- #===============================================================================
- class Game_Unit
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :ptb_bonus_turns
- attr_accessor :ptb_cancel_turns
- attr_accessor :ptb_spent_turns
- #--------------------------------------------------------------------------
- # new method: total_agi
- #--------------------------------------------------------------------------
- def total_agi
- result = 0
- for member in members; result += member.agi; end
- return result
- end
- #--------------------------------------------------------------------------
- # new method: update_battle_start
- #--------------------------------------------------------------------------
- def update_battle_start
- reset_ptb_turns
- for member in members
- member.action.clear if $scene.is_a?(Scene_Battle) and !$scene.dtb?
- member.clear_battle_cache
- member.turn_count = 0
- end
- end
- #--------------------------------------------------------------------------
- # new method: update_turn_start
- #--------------------------------------------------------------------------
- def update_turn_start
- for member in members
- member.ptb_actions = 0
- #---
- for state in member.states
- member.lunatic_status_effects(state, :begin)
- end
- end
- end
- #--------------------------------------------------------------------------
- # new method: update_turn_end
- #--------------------------------------------------------------------------
- def update_turn_end
- slip_damage_effect
- for member in members
- for state in member.states
- member.lunatic_status_effects(state, :close)
- end
- end
- end
- #--------------------------------------------------------------------------
- # new method: update_battle_over
- #--------------------------------------------------------------------------
- def update_battle_over
- reset_ptb_turns
- skill_settings = YEM::BATTLE_ENGINE::SKILL_SETTINGS
- for member in members
- member.clear_battle_cache
- member.reset_state_origins
- member.clear_cooldowns if skill_settings[:cooldown_reset]
- member.clear_limited_use if skill_settings[:limited_reset]
- member.lose_rage(member.max_rage) if skill_settings[:rage_reset]
- end
- end
- #--------------------------------------------------------------------------
- # new method: ptb_total_turns
- #--------------------------------------------------------------------------
- def ptb_total_turns
- result = ptb_member_turns + @ptb_bonus_turns
- result -= @ptb_cancel_turns + @ptb_spent_turns
- return [result, 0].max
- end
- #--------------------------------------------------------------------------
- # new method: ptb_member_turns
- #--------------------------------------------------------------------------
- def ptb_member_turns
- result = 0
- for member in existing_members; result += member.ptb_provided_turns; end
- return result
- end
- #--------------------------------------------------------------------------
- # new method: reset_ptb_turns
- #--------------------------------------------------------------------------
- def reset_ptb_turns
- for member in members;
- member.action.ptb_guarding = nil
- member.ptb_performed = false
- member.ptb_actions = 0
- member.ptb_cancel = 0
- member.ptb_regain = 0
- end
- @ptb_bonus_turns = 0
- @ptb_cancel_turns = 0
- @ptb_spent_turns = 0
- end
- #--------------------------------------------------------------------------
- # new method: update_ptb
- #--------------------------------------------------------------------------
- def update_ptb(value = 1, ignore = false)
- return unless $scene.is_a?(Scene_Battle)
- return unless $scene.ptb?
- return if $scene.active_battler.action.forcing
- #---
- unless ignore
- if $scene.active_battler.action.skill?
- obj = $scene.active_battler.action.skill
- value = obj.ptb_turn_cost
- elsif $scene.active_battler.action.item?
- obj = $scene.active_battler.action.item
- value = obj.ptb_turn_cost
- end
- end
- #---
- value.times do
- if @ptb_bonus_turns > 0
- @ptb_bonus_turns -= 1
- else
- @ptb_spent_turns += 1
- end
- end
- #---
- $scene.active_battler.ptb_actions += 1 if $scene.active_battler != nil
- end
- #--------------------------------------------------------------------------
- # new method: gain_bonus
- #--------------------------------------------------------------------------
- def gain_bonus(battler = nil, value = 1, follow_rule = true)
- return unless $scene.is_a?(Scene_Battle)
- return unless $scene.ptb?
- if battler != nil and follow_rule
- battler.ptb_regain += 1
- if battler.ptb_regain <= battler.ptb_max_regain
- @ptb_bonus_turns += value
- sfx = YEM::BATTLE_ENGINE::PTB_RULES[:one_more_sfx]
- sfx.play if sfx != nil
- end
- else
- @ptb_bonus_turns += value
- sfx = YEM::BATTLE_ENGINE::PTB_RULES[:one_more_sfx]
- sfx.play if sfx != nil
- end
- $scene.ptb_updated = true
- $scene.refresh_ptb_windows
- end
- #--------------------------------------------------------------------------
- # new method: cancel_turn
- #--------------------------------------------------------------------------
- def cancel_turn(battler = nil, value = 1, follow_rule = true)
- return unless $scene.is_a?(Scene_Battle)
- return unless $scene.ptb?
- if battler != nil and follow_rule
- battler.ptb_cancel += 1
- if battler.ptb_cancel <= battler.ptb_max_cancel
- @ptb_cancel_turns += value
- sfx = YEM::BATTLE_ENGINE::PTB_RULES[:one_less_sfx]
- sfx.play if sfx != nil
- end
- else
- @ptb_cancel_turns += value
- sfx = YEM::BATTLE_ENGINE::PTB_RULES[:one_less_sfx]
- sfx.play if sfx != nil
- end
- $scene.ptb_updated = true
- $scene.refresh_ptb_windows
- end
- #--------------------------------------------------------------------------
- # new method: create_initial_atb_speeds
- #--------------------------------------------------------------------------
- def create_initial_atb_speeds
- percent1 = YEM::BATTLE_ENGINE::ATB_RULES[:initial]
- percent2 = YEM::BATTLE_ENGINE::ATB_RULES[:surprise]
- random = YEM::BATTLE_ENGINE::ATB_RULES[:random]
- value = Integer($game_troop.atb_max * percent1)
- bonus = Integer($game_troop.atb_max * percent2)
- $scene.force_preemptive_or_surprise
- for member in members
- member.turn_count = 0
- member.reset_atb_speed
- member.atb_speed = value
- member.action.atb_queue_kind = 0
- member.action.atb_queue_basic = 3
- member.action.atb_guarding = false
- random.times do; member.atb_speed += rand(member.base_agi); end
- member.atb_speed += bonus if member.actor? and $game_troop.preemptive
- member.atb_speed += bonus if member.enemy? and $game_troop.surprise
- member.atb_speed = [member.atb_speed, 0].max
- member.atb_speed = [member.atb_speed, $game_troop.atb_threshold].min
- end
- end
- #--------------------------------------------------------------------------
- # new method: create_initial_ctb_speeds
- #--------------------------------------------------------------------------
- def create_initial_ctb_speeds
- percent1 = YEM::BATTLE_ENGINE::CTB_RULES[:initial]
- percent2 = YEM::BATTLE_ENGINE::CTB_RULES[:surprise]
- random = YEM::BATTLE_ENGINE::CTB_RULES[:random]
- value = Integer($game_troop.ctb_max * percent1)
- bonus = Integer($game_troop.ctb_max * percent2)
- $scene.force_preemptive_or_surprise
- for member in members
- member.turn_count = 0
- member.reset_ctb_speed
- member.ctb_speed = value
- member.action.ctb_guarding = false
- member.action.ctb_guarding_queue = false
- random.times do; member.ctb_speed += rand(member.base_agi); end
- member.ctb_speed += bonus if member.actor? and $game_troop.preemptive
- member.ctb_speed += bonus if member.enemy? and $game_troop.surprise
- member.ctb_speed = [member.ctb_speed, 0].max
- end
- end
- #--------------------------------------------------------------------------
- # new method: update_group_cooldowns
- #--------------------------------------------------------------------------
- def update_group_cooldowns
- for member in existing_members; member.update_all_cooldown; end
- end
- #--------------------------------------------------------------------------
- # new method: area_targets
- #--------------------------------------------------------------------------
- def area_targets(main_target, obj = nil)
- return [] unless $scene.is_a?(Scene_Battle)
- return [] if obj == nil
- result = []
- for member in members
- next if member.dead? != obj.for_dead_friend?
- next if member.hidden
- result.push(member) if within_radius?(main_target, member, obj)
- result.push(member) if within_area?(main_target, member, obj)
- end
- return result.uniq
- end
- #--------------------------------------------------------------------------
- # new method: within_radius?
- #--------------------------------------------------------------------------
- def within_radius?(main_target, target, obj)
- return false if target == main_target
- return false if obj == nil
- return false if obj.aoe_radius <= 0
- radius = obj.aoe_radius + 1
- height = obj.aoe_height
- #--- Target Point Creation ---
- main_x = main_target.screen_x
- main_y = main_target.screen_y
- target_x = target.screen_x
- target_y = target.screen_y
- #--- Target Offset Buffering ---
- main_x += main_target.enemy.target_offset_x unless main_target.actor?
- main_y += main_target.enemy.target_offset_y unless main_target.actor?
- target_x += target.enemy.target_offset_x unless target.actor?
- target_y += target.enemy.target_offset_y unless target.actor?
- #--- Target Point Buffering ---
- if main_x >= target_x
- target_x += target.bitmap_width/2
- elsif main_x <= target_x
- target_x -= target.bitmap_width/2
- end
- #--- Calculations ---
- x = (target_x - main_x) * Math.cos(0) + (target_y - main_y) * Math.sin(0)
- y = -(target_x - main_x) * Math.sin(0) + (target_y - main_y) * Math.cos(0)
- a = radius; b = radius * height
- return (x**2 / a**2) + (y**2 / b**2) <= 1
- end
- #--------------------------------------------------------------------------
- # new method: within_area?
- #--------------------------------------------------------------------------
- def within_area?(main_target, target, obj)
- return false if target == main_target
- return false if obj == nil
- return false if obj.rect_type <= 0
- #--- Target Point Creation ---
- main_x = main_target.origin_x
- main_y = main_target.origin_y
- target_x = target.screen_x
- target_y = target.screen_y
- #--- Target Offset Buffering ---
- main_x += main_target.enemy.target_offset_x unless main_target.actor?
- main_y += main_target.enemy.target_offset_y unless main_target.actor?
- target_x += target.enemy.target_offset_x unless target.actor?
- target_y += target.enemy.target_offset_y unless target.actor?
- #--- Target Point Buffering ---
- if main_x >= target_x
- target_x += target.bitmap_width/2
- elsif main_x <= target_x
- target_x -= target.bitmap_width/2
- end
- #--- Area Creation ---
- case obj.rect_type
- when 1 # Column
- y1 = 0; y2 = Graphics.height
- x1 = main_x - obj.rect_value
- x2 = main_x + obj.rect_value
- when 2 # Row
- x1 = 0; x2 = Graphics.width
- y1 = main_y - obj.rect_value
- y2 = main_y + obj.rect_value
- when 3 # Map
- x1 = 0; x2 = Graphics.width
- y1 = 0; y2 = Graphics.height
- else; return false
- end
- #--- Calculations ---
- in_x = ((x1..x2) === target_x)
- in_y = ((y1..y2) === target_y)
- return (in_x and in_y)
- end
- end # Game_Unit
- #===============================================================================
- # Game_Party
- #===============================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :battle_items_cache
- attr_accessor :item_charges
- #--------------------------------------------------------------------------
- # alias method: setup_starting_members
- #--------------------------------------------------------------------------
- alias setup_starting_members_bem setup_starting_members unless $@
- def setup_starting_members
- setup_starting_members_bem
- for i in 0..$data_actors.size
- actor = $game_actors[i]
- next if actor == nil
- actor.clear_battle_cache
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: on_player_walk
- #--------------------------------------------------------------------------
- def on_player_walk
- for actor in members
- if actor.slip_damage?
- for state in actor.states; actor.perform_slip_effect(state); end
- end
- if actor.auto_hp_recover and actor.hp > 0
- actor.hp += 1
- end
- end
- #---
- if YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_decay] > 0
- if @steps % YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_decay] == 0
- for member in members; member.lose_rage; end
- end
- end
- if YEM::BATTLE_ENGINE::SKILL_SETTINGS[:cooldown_decay] > 0
- if @steps % YEM::BATTLE_ENGINE::SKILL_SETTINGS[:cooldown_decay] == 0
- for member in members; member.update_all_cooldown; end
- end
- end
- #---
- end
- #--------------------------------------------------------------------------
- # alias method: gain_item
- # Quick Cache Data
- #--------------------------------------------------------------------------
- alias gain_item_bem gain_item unless $@
- def gain_item(item, n, include_equip = false)
- gain_item_bem(item, n, include_equip)
- @battle_items_cache = nil
- end
- #--------------------------------------------------------------------------
- # alias method: consume_item
- #--------------------------------------------------------------------------
- alias consume_item_bem consume_item unless $@
- def consume_item(item)
- item_variable_switch_change(item)
- if item.is_a?(RPG::Item) and item.consumable
- @item_charges = {} if @item_charges == nil
- @item_charges[item.id] = item.charges if @item_charges[item.id] == nil
- @item_charges[item.id] -= 1
- if @item_charges[item.id] <= 0
- @item_charges[item.id] = item.charges
- consume_item_bem(item)
- end
- else
- consume_item_bem(item)
- end
- end
- #--------------------------------------------------------------------------
- # new method: item_variable_switch_change
- #--------------------------------------------------------------------------
- def item_variable_switch_change(item)
- return unless item.is_a?(RPG::Item)
- for key in item.change_variable
- variable_id = key[0]; value = key[1]
- $game_variables[variable_id] += value
- end
- for key in item.change_switch
- switch_id = key[0]; value = key[1]
- case value
- when :true; $game_switches[switch_id] = true
- when :false; $game_switches[switch_id] = false
- when :toggle; $game_switches[switch_id] = !$game_switches[switch_id]
- end
- end
- end
- #--------------------------------------------------------------------------
- # new method: battle_item_size
- # Quick Cache Data
- #--------------------------------------------------------------------------
- def battle_item_size
- return @battle_items_cache if @battle_items_cache != nil
- @battle_items_cache = 0
- for item in items
- next unless item_can_use?(item)
- @battle_items_cache += 1
- end
- return @battle_items_cache
- end
- #--------------------------------------------------------------------------
- # new method: update_battle_start
- #--------------------------------------------------------------------------
- def update_battle_start
- super
- clear_caches
- for member in members
- member.turn_count = 0
- end
- end
- #--------------------------------------------------------------------------
- # new method: update_turn_start
- #--------------------------------------------------------------------------
- def update_turn_start
- super
- for member in members
- member.equip_cooldown = 0 if member.equip_cooldown == nil
- member.equip_cooldown = [member.equip_cooldown - 1, 0].max
- end
- end
- #--------------------------------------------------------------------------
- # new method: update_turn_end
- #--------------------------------------------------------------------------
- def update_turn_end
- super
- do_auto_recovery
- end
- #--------------------------------------------------------------------------
- # new method: update_battle_over
- #--------------------------------------------------------------------------
- def update_battle_over
- super
- remove_states_battle
- clear_caches
- for member in members
- member.equip_cooldown = 0
- member.equip_clocktick = nil
- next if $scene.is_a?(Scene_Battle) and $scene.dtb?
- member.action.clear
- end
- end
- #--------------------------------------------------------------------------
- # new method: clear_caches
- #--------------------------------------------------------------------------
- def clear_caches
- @battle_items_cache = nil
- for i in 0..$data_actors.size
- actor = $game_actors[i]
- next if actor == nil
- actor.clear_battle_cache
- end
- end
- end # Game_Party
- #===============================================================================
- # Game_Troop
- #===============================================================================
- class Game_Troop < Game_Unit
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :atb_max
- attr_accessor :atb_min_speed
- attr_accessor :atb_threshold
- attr_accessor :atb_ready
- attr_accessor :ctb_max
- attr_accessor :ctb_min_speed
- attr_accessor :ctb_ready
- attr_accessor :turn_count
- #--------------------------------------------------------------------------
- # overwrite method: make_actions
- #--------------------------------------------------------------------------
- def make_actions
- if @preemptive and ($scene.is_a?(Scene_Battle) and !$scene.atb?)
- clear_actions
- else
- for enemy in members; enemy.make_action; end
- end
- end
- #--------------------------------------------------------------------------
- # new method: update_battle_start
- #--------------------------------------------------------------------------
- def update_battle_start
- super
- end
- #--------------------------------------------------------------------------
- # new method: update_turn_start
- #--------------------------------------------------------------------------
- def update_turn_start
- super
- end
- #--------------------------------------------------------------------------
- # new method: update_turn_end
- #--------------------------------------------------------------------------
- def update_turn_end
- super
- end
- #--------------------------------------------------------------------------
- # new method: update_battle_over
- #--------------------------------------------------------------------------
- def update_battle_over
- super
- end
- #--------------------------------------------------------------------------
- # overwrite method: increase_turn
- #--------------------------------------------------------------------------
- def increase_turn
- for page in troop.pages
- if page.span == 1
- @event_flags[page] = false
- end
- end
- @turn_count += 1
- return unless $scene.is_a?(Scene_Battle)
- return if $scene.atb? or $scene.ctb?
- for member in ($game_party.members + $game_troop.members)
- member.turn_count = 0 if member.turn_count == nil
- member.turn_count += 1
- end
- end
- #--------------------------------------------------------------------------
- # new method: create_atb_max_speed
- #--------------------------------------------------------------------------
- def create_atb_max_speed
- array = $game_troop.members + $game_party.members
- @atb_max = 0
- @atb_min_speed = YEM::BATTLE_ENGINE::ATB_RULES[:min_speed]
- for member in array; @atb_max += member.base_agi; end
- @atb_max = Integer(@atb_max * YEM::BATTLE_ENGINE::ATB_RULES[:max_rate])
- @atb_max += YEM::BATTLE_ENGINE::ATB_RULES[:max_offset]
- @atb_max = [@atb_max, YEM::BATTLE_ENGINE::ATB_RULES[:max_low]].max
- threshold = YEM::BATTLE_ENGINE::ATB_RULES[:threshold]
- @atb_threshold = Integer(threshold * @atb_max)
- @atb_ready = []
- end
- #--------------------------------------------------------------------------
- # new method: create_ctb_max_speed
- #--------------------------------------------------------------------------
- def create_ctb_max_speed
- array = $game_troop.members + $game_party.members
- @ctb_max = 0
- @ctb_min_speed = YEM::BATTLE_ENGINE::CTB_RULES[:min_speed]
- for member in array; @ctb_max += member.base_agi; end
- @ctb_max = Integer(@ctb_max * YEM::BATTLE_ENGINE::CTB_RULES[:max_rate])
- @ctb_max += YEM::BATTLE_ENGINE::CTB_RULES[:max_offset]
- @ctb_max = [@ctb_max, YEM::BATTLE_ENGINE::CTB_RULES[:max_low]].max
- @ctb_ready = []
- clear_ctb_cache
- end
- #--------------------------------------------------------------------------
- # new method: clear_ctb_cache
- #--------------------------------------------------------------------------
- def clear_ctb_cache
- for battler in ($game_party.members + $game_troop.members)
- battler.ctb_cache = nil
- end
- end
- end # Game_Troop
- #===============================================================================
- # Game_Interpreter
- #===============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # alias method: Change Parameters
- #--------------------------------------------------------------------------
- alias command_317_bem command_317 unless $@
- def command_317
- n = command_317_bem
- actor = $game_actors[@params[0]]
- actor.clear_battle_cache
- actor.update_maxhp = true
- actor.update_maxmp = true
- return n
- end
- #--------------------------------------------------------------------------
- # alias method: Change Skills
- #--------------------------------------------------------------------------
- alias command_318_bem command_318 unless $@
- def command_318
- n = command_318_bem
- actor = $game_actors[@params[0]]
- if actor != nil and $scene.is_a?(Scene_Battle)
- if @params[1] != 0
- skill = $data_skills[@params[2]]
- if actor.action.skill? and actor.action.skill == skill
- actor.action.clear
- end
- end
- end
- return true
- end
- #--------------------------------------------------------------------------
- # overwrite method: Enemy Appear
- #--------------------------------------------------------------------------
- def command_335
- enemy = $game_troop.members[@params[0]]
- if enemy != nil and enemy.hidden
- enemy.hidden = false
- enemy.battler_animation_stance("IDLE")
- $game_troop.make_unique_names
- end
- return true
- end
- #--------------------------------------------------------------------------
- # alias method: Force Action
- #--------------------------------------------------------------------------
- alias command_339_bem command_339 unless $@
- def command_339
- iterate_battler(@params[0], @params[1]) do |battler|
- next unless battler.exist?
- next if battler.stored_action != nil
- battler.stored_action = battler.action.clone if battler.action != nil
- end
- n = command_339_bem
- #---
- if $scene.is_a?(Scene_Battle) and ($scene.ctb? or $scene.atb?)
- iterate_battler(@params[0], @params[1]) do |battler|
- next unless battler.exist?
- current_active_battler = $scene.active_battler
- $scene.active_battler = battler
- $scene.process_action
- $scene.active_battler = current_active_battler
- end
- $game_troop.forcing_battler = nil
- end
- return n
- end
- #--------------------------------------------------------------------------
- # new method: clear_limited_use
- #--------------------------------------------------------------------------
- def clear_limited_use
- for member in $game_party.members; member.clear_limited_use; end
- end
- end # Game_Interpreter
- #===============================================================================
- # Scene_Skill
- #===============================================================================
- class Scene_Skill < Scene_Base
- #--------------------------------------------------------------------------
- # overwrite method: use_skill_nontarget
- #--------------------------------------------------------------------------
- def use_skill_nontarget
- Sound.play_use_skill
- @actor.perform_skill_cost(@skill)
- @status_window.refresh
- @skill_window.refresh
- @target_window.refresh
- if $game_party.all_dead?
- $scene = Scene_Gameover.new
- elsif @skill.common_event_id > 0
- $game_temp.common_event_id = @skill.common_event_id
- $scene = Scene_Map.new
- end
- end
- end # Scene_Skill
- #===============================================================================
- # Scene_Equip
- #===============================================================================
- class Scene_Equip < Scene_Base
- #--------------------------------------------------------------------------
- # alias method: next_actor
- #--------------------------------------------------------------------------
- alias next_actor_scene_equip next_actor unless $@
- def next_actor
- if $game_temp.in_battle
- Sound.play_buzzer
- return
- end
- next_actor_scene_equip
- end
- #--------------------------------------------------------------------------
- # alias method: prev_actor
- #--------------------------------------------------------------------------
- alias prev_actor_scene_equip prev_actor unless $@
- def prev_actor
- if $game_temp.in_battle
- Sound.play_buzzer
- return
- end
- prev_actor_scene_equip
- end
- end # Scene_Equip
- #===============================================================================
- # Scene_Battle
- #===============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :action_battlers
- attr_accessor :active_battler
- attr_accessor :actor_command_window
- attr_accessor :battle_type
- attr_accessor :camera_speed
- attr_accessor :camera_x
- attr_accessor :camera_y
- attr_accessor :characters
- attr_accessor :combo_hits
- attr_accessor :combo_damage
- attr_accessor :combo_update
- attr_accessor :confirm_command_window
- attr_accessor :enemychars
- attr_accessor :help_viewport
- attr_accessor :hide_battlecursor
- attr_accessor :highlighted_targets
- attr_accessor :info_viewport
- attr_accessor :message_window
- attr_accessor :mirror_ani
- attr_accessor :party_command_window
- attr_accessor :party_input_flag
- attr_accessor :performed_actors
- attr_accessor :ptb_party_window
- attr_accessor :ptb_troop_window
- attr_accessor :ptb_updated
- attr_accessor :selected_battler
- attr_accessor :spriteset
- attr_accessor :status_window
- attr_accessor :target_actor_window
- attr_accessor :target_enemy_window
- attr_accessor :target_help_window
- attr_accessor :view_type
- #--------------------------------------------------------------------------
- # overwrite method: start
- #--------------------------------------------------------------------------
- def start
- super
- $game_system.create_battle_options
- $game_temp.in_battle = true
- set_battle_types
- @performed_actors = []
- @action_battlers = []
- @action_values = []
- @spriteset = Spriteset_Battle.new
- @message_window = Window_BattleMessageMelody.new
- @hide_battlecursor = false
- reset_extra_calculation_modifiers
- create_info_viewport
- create_bem_windows
- update_battler_poses
- @spriteset.update
- end
- #--------------------------------------------------------------------------
- # new method: set_battle_types
- #--------------------------------------------------------------------------
- def set_battle_types
- @current_party = $game_party.members.clone
- @all_members = ($game_party.members + $game_troop.members).clone
- @battle_type = $game_variables[YEM::BATTLE_ENGINE::BATTLE_TYPE_VARIABLE]
- @view_type = $game_variables[YEM::BATTLE_ENGINE::VIEW_TYPE_VARIABLE]
- setup_atb if atb?
- setup_ctb if ctb?
- force_create_empty_actions
- end
- #--------------------------------------------------------------------------
- # new method: force_create_empty_actions
- #--------------------------------------------------------------------------
- def force_create_empty_actions
- for member in ($game_troop.members + $game_party.members)
- member.rage = 0 if member.rage == nil
- member.action = Game_BattleAction.new(member) if member.action == nil
- member.action.kind = 0 if member.action.kind == nil
- member.action.basic = 3 if member.action.basic == nil
- member.reload_state_animation
- end
- end
- #--------------------------------------------------------------------------
- # new method: dtb? (Default Turn Battle)
- #--------------------------------------------------------------------------
- def dtb?; return @battle_type == 0; end
- #--------------------------------------------------------------------------
- # new method: ptb? (Press Turn Battle)
- #--------------------------------------------------------------------------
- def ptb?; return @battle_type == 1; end
- #--------------------------------------------------------------------------
- # new method: atb? (Active Turn Battle)
- #--------------------------------------------------------------------------
- def atb?; return @battle_type == 2; end
- #--------------------------------------------------------------------------
- # new method: ctb? (Charge Turn Battle)
- #--------------------------------------------------------------------------
- def ctb?; return @battle_type == 3; end
- #--------------------------------------------------------------------------
- # new method: active_atb?
- #--------------------------------------------------------------------------
- def active_atb?
- return $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]] >= 0
- end
- #--------------------------------------------------------------------------
- # new method: semi_active_atb?
- #--------------------------------------------------------------------------
- def semi_active_atb?
- return $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]] >= 1
- end
- #--------------------------------------------------------------------------
- # new method: semi_wait_atb?
- #--------------------------------------------------------------------------
- def semi_wait_atb?
- return $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]] >= 2
- end
- #--------------------------------------------------------------------------
- # new method: wait_atb?
- #--------------------------------------------------------------------------
- def wait_atb?
- return $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]] >= 3
- end
- #--------------------------------------------------------------------------
- # new method: cinematic?
- #--------------------------------------------------------------------------
- def cinematic?; return false; end
- #--------------------------------------------------------------------------
- # new method: emptyview?
- #--------------------------------------------------------------------------
- def emptyview?; return @view_type == 0; end
- #--------------------------------------------------------------------------
- # new method: frontview?
- #--------------------------------------------------------------------------
- def frontview?; return @view_type == 1; end
- #--------------------------------------------------------------------------
- # new method: sideview?
- #--------------------------------------------------------------------------
- def sideview?; return @view_type == 2; end
- #--------------------------------------------------------------------------
- # new method: angleview?
- #--------------------------------------------------------------------------
- def angleview?; return @view_type == 3; end
- #--------------------------------------------------------------------------
- # alias method: terminate
- #--------------------------------------------------------------------------
- alias terminate_scene_battle_bem terminate unless $@
- def terminate
- terminate_scene_battle_bem
- if $disposable_melody_windows != nil
- for window in $disposable_melody_windows
- window.dispose unless window.disposed?
- end
- $disposable_melody_windows = []
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: create_info_viewport
- #--------------------------------------------------------------------------
- def create_info_viewport
- force_preemptive_or_surprise
- #---
- @info_viewport = Viewport.new(0, Graphics.height-128, Graphics.width, 128)
- @info_viewport.z = 100
- #---
- @status_window = Window_BattleStatus.new(true)
- @status_window.viewport = @info_viewport
- @status_window.x = 128
- @status_hp_window = Window_BattleStatusHP.new
- @status_hp_window.viewport = @info_viewport
- @status_hp_window.x = 128
- @status_mp_window = Window_BattleStatusMP.new
- @status_mp_window.viewport = @info_viewport
- @status_mp_window.x = 128
- @status_rage_window = Window_BattleStatusRage.new
- @status_rage_window.viewport = @info_viewport
- @status_rage_window.x = 128
- @status_rage_window.z = @status_mp_window.z + 1
- @status_states_window = Window_BattleStatusStates.new
- @status_states_window.viewport = @info_viewport
- @status_states_window.x = 128 # MK original value: 128
- #---
- @party_command_window = Window_PartyCommand.new
- @actor_command_window = Window_ActorCommand.new
- @party_command_window.viewport = @info_viewport
- @actor_command_window.viewport = @info_viewport
- @actor_command_window.x = Graphics.width
- @confirm_command_window = Window_ConfirmCommand.new
- @confirm_command_window.viewport = @info_viewport
- @confirm_command_window.x = Graphics.width
- #---
- @info_viewport.ox = 128
- @actor_index = 0
- @status_shortcut_index = 0
- @status_window.index = 0
- @status_window.refresh
- actor = @status_window.actor
- @actor_command_window.setup(actor)
- if $game_switches[YEM::BATTLE_ENGINE::OPTIONS[:autocursor_sw]]
- @actor_command_window.index = actor.battle_command_index.to_i
- end
- #--- Calculate PTB Initiative
- if ptb? and (rand($game_party.total_agi) < rand($game_troop.total_agi) or
- $game_troop.surprise and !$scene.atb?)
- if !(($TEST or $BTEST) and Input.press?(Input::CTRL)) and
- !$game_troop.preemptive
- @ptb_initiative = true
- @info_viewport.ox = 64
- @actor_index = -1
- @status_window.index = -1
- @status_window.refresh
- @actor_command_window.openness = 0
- @party_command_window.openness = 0
- end
- end
- if ctb?
- make_action_orders_ctb
- if @action_battlers[0].actor?
- @actor_index = @action_battlers[0].index
- @status_window.index = @action_battlers[0].index
- actor = @status_window.actor
- @actor_command_window.setup(actor)
- if $game_switches[YEM::BATTLE_ENGINE::OPTIONS[:autocursor_sw]]
- index = actor.battle_command_index.to_i
- maximum = @actor_command_window.item_max - 1
- @actor_command_window.index = [index, maximum].min
- end
- else
- @ctb_initiative = true
- @info_viewport.ox = 64
- @actor_index = -1
- @status_window.index = -1
- @actor_command_window.openness = 0
- @party_command_window.openness = 0
- end
- @status_window.refresh
- end
- #---
- @info_viewport.visible = true
- end
- #--------------------------------------------------------------------------
- # dispose_info_viewport
- #--------------------------------------------------------------------------
- def dispose_info_viewport
- #---
- @status_window.dispose
- @status_hp_window.dispose
- @status_mp_window.dispose
- @status_rage_window.dispose
- @status_states_window.dispose
- #---
- @party_command_window.dispose
- @actor_command_window.dispose
- @confirm_command_window.dispose
- @info_viewport.dispose
- #---
- dispose_bem_windows
- end
- #--------------------------------------------------------------------------
- # overwrite method: update_info_viewport
- #--------------------------------------------------------------------------
- def update_info_viewport
- return if atb?
- @party_command_window.update
- @actor_command_window.update
- @confirm_command_window.update
- update_info_viewport_windows
- end
- #--------------------------------------------------------------------------
- # new method: update_info_viewport_windows
- #--------------------------------------------------------------------------
- def update_info_viewport_windows
- if @party_command_window.active and @info_viewport.ox > 0
- @info_viewport.ox = [@info_viewport.ox - 16, 0].max
- elsif @actor_command_window.active and @info_viewport.ox < 128
- @info_viewport.ox = [@info_viewport.ox + 16, 128].min
- elsif @confirm_command_window.active and @info_viewport.ox < 128
- @info_viewport.ox = [@info_viewport.ox + 16, 128].min
- end
- end
- #--------------------------------------------------------------------------
- # new method: force_preemptive_or_surprise
- #--------------------------------------------------------------------------
- def force_preemptive_or_surprise
- case $game_troop.troop.strike_case
- when 1
- $game_troop.preemptive = false
- $game_troop.surprise = false
- when 2
- $game_troop.preemptive = true
- $game_troop.surprise = false
- when 3
- $game_troop.preemptive = false
- $game_troop.surprise = true
- else
- return
- end
- end
- #--------------------------------------------------------------------------
- # new method: create_bem_windows
- #--------------------------------------------------------------------------
- def create_bem_windows
- @combo_window = Window_ComboCounter.new
- @combo_window.viewport = @spriteset.viewportA
- #---
- @view_help_window = Window_Help.new
- dh = @view_help_window.height
- @help_viewport = Viewport.new(0, Graphics.height-128-dh, Graphics.width, dh)
- @help_viewport.z = 100
- @view_help_window.viewport = @help_viewport
- @view_help_window.y = dh
- #---
- @target_help_window = Window_TargetHelp.new
- dh = @target_help_window.height
- @target_viewport = Viewport.new(0, 0, Graphics.width, dh)
- @target_viewport.z = 100
- @target_help_window.viewport = @target_viewport
- @target_help_window.y = -dh
- @target_help_window.active = false
- #--- Debug Window ---
- if $TEST or $BTEST
- @debug_window = Window_BattleDebug.new
- @debug_window.viewport = @help_viewport
- end
- #--- PTB Windows ---
- if ptb?
- @ptb_party_window = Window_PressTurns.new($game_party)
- @ptb_party_window.viewport = @spriteset.viewportA
- @ptb_troop_window = Window_PressTurns.new($game_troop)
- @ptb_troop_window.viewport = @spriteset.viewportA
- end
- end
- #--------------------------------------------------------------------------
- # new method: dispose_bem_windows
- #--------------------------------------------------------------------------
- def dispose_bem_windows
- @combo_window.dispose if @combo_window != nil
- @debug_window.dispose if @debug_window != nil
- #---
- @ptb_party_window.dispose if @ptb_party_window != nil
- @ptb_troop_window.dispose if @ptb_troop_window != nil
- #---
- @view_help_window.dispose if @view_help_window != nil
- @help_viewport.dispose if @help_viewport != nil
- #---
- @target_help_window.dispose if @target_help_window != nil
- @target_viewport.dispose
- end
- #--------------------------------------------------------------------------
- # overwrite method: update
- #--------------------------------------------------------------------------
- def update # Scene_Battle
- super
- return unless $scene.is_a?(Scene_Battle)
- update_basic(true)
- update_info_viewport
- @message_window.visible = true if $game_message.visible
- update_input_windows unless atb?
- update_scene_change
- end
- #--------------------------------------------------------------------------
- # new method: update_input_windows
- #--------------------------------------------------------------------------
- def update_input_windows
- return if $game_message.visible
- return if judge_win_loss
- if @target_enemy_window != nil
- update_target_enemy_selection
- elsif @target_actor_window != nil
- update_target_actor_selection
- elsif @skill_window != nil
- update_skill_selection
- elsif @item_window != nil
- update_item_selection
- elsif @actor_status_window != nil
- update_actor_status
- elsif @options_window != nil
- update_options
- elsif @party_command_window.active
- update_party_command_selection
- elsif @actor_command_window.active
- update_actor_command_selection
- elsif @confirm_command_window.active
- update_confirm_command_selection
- elsif !atb?
- process_battle_event
- process_action
- process_battle_event
- end
- end
- #--------------------------------------------------------------------------
- # alias method: update_basic
- #--------------------------------------------------------------------------
- alias update_basic_bem update_basic unless $@
- def update_basic(main = false)
- update_party
- #---
- update_basic_bem(main)
- #---
- update_bem_windows
- update_atb
- call_debug_menu if ($TEST or $BTEST) and Input.trigger?(Input::F9)
- end
- #--------------------------------------------------------------------------
- # new method: update_party
- #--------------------------------------------------------------------------
- def update_party
- return if @current_party == $game_party.members
- @current_party = $game_party.members.clone
- @all_members = ($game_party.members + $game_troop.members).clone
- @spriteset.create_actors
- @spriteset.create_order_sprites
- make_action_orders
- wait(20, true)
- end
- #--------------------------------------------------------------------------
- # new method: update_bem_windows
- #--------------------------------------------------------------------------
- def update_bem_windows
- @status_window.update if @status_window != nil
- @status_hp_window.update if @status_hp_window != nil
- @status_mp_window.update if @status_mp_window != nil
- @status_rage_window.update if @status_rage_window != nil
- @status_states_window.update if @status_states_window != nil
- #---
- @combo_window.update if @combo_window != nil
- @debug_window.update if @debug_window != nil
- #---
- if scroll_help_viewport? and !@judge_win_loss
- height = @view_help_window.height
- @help_viewport.oy = [@help_viewport.oy + 4, height].min
- else
- @help_viewport.oy = [@help_viewport.oy - 4, 0].max
- end
- if @target_help_window.active and !@judge_win_loss
- height = @target_help_window.height
- @target_viewport.oy = [@target_viewport.oy - 4, -height].max
- else
- @target_viewport.oy = [@target_viewport.oy + 4, 0].min
- end
- #---
- if ptb?
- @ptb_party_window.update
- @ptb_troop_window.update
- end
- end
- #--------------------------------------------------------------------------
- # new method: setup_atb
- #--------------------------------------------------------------------------
- def setup_atb
- $game_troop.create_atb_max_speed
- $game_troop.create_initial_atb_speeds
- $game_party.create_initial_atb_speeds
- @ctr_per_turn = YEM::BATTLE_ENGINE::ATB_RULES[:turns_ctr]
- @pause_atb = false
- @atb_counter = 0
- @clockticks = 0
- end
- #--------------------------------------------------------------------------
- # new method: setup_ctb
- #--------------------------------------------------------------------------
- def setup_ctb
- $game_troop.create_ctb_max_speed
- $game_troop.create_initial_ctb_speeds
- $game_party.create_initial_ctb_speeds
- @ctr_per_turn = YEM::BATTLE_ENGINE::CTB_RULES[:turns_ctr]
- @clockticks = 0
- end
- #--------------------------------------------------------------------------
- # new method: update_atb
- #--------------------------------------------------------------------------
- def update_atb
- return unless atb?
- update_info_viewport_windows
- return if @judge_win_loss
- @party_command_window.update
- @actor_command_window.update
- @confirm_command_window.update
- update_input_windows
- return if @pause_atb
- return if $game_troop.interpreter.running?
- if atb_action_ready?
- process_action
- return
- end
- @atb_counter += 1
- return unless @atb_counter % atb_speed == 0
- @clockticks += 1
- if @clockticks % @ctr_per_turn == 0
- $game_troop.turn_ending = true
- process_battle_event
- $game_troop.turn_ending = false
- $game_troop.increase_turn
- if YEM::BATTLE_ENGINE::ATB_COMMON_EVENTS[:turn_update] != nil
- event_id = YEM::BATTLE_ENGINE::ATB_COMMON_EVENTS[:turn_update]
- $game_temp.common_event_id = event_id
- process_battle_event
- end
- process_battle_event
- end
- for member in @all_members; member.update_atb_speed; end
- pause_atb(true) if input_atb_actor?
- end
- #--------------------------------------------------------------------------
- # new method: input_atb_actor?
- #--------------------------------------------------------------------------
- def input_atb_actor?
- return false unless wait_atb?
- for member in $game_party.existing_members
- next if member.atb_speed < $game_troop.atb_threshold
- if member.action.wait?
- @actor_index = member.index
- @status_window.index = @actor_index
- @selected_battler = $game_party.members[@actor_index]
- start_actor_command_selection
- YEM::BATTLE_ENGINE::ATB_WAIT_SOUND.play
- return true
- end
- end
- return false
- end
- #--------------------------------------------------------------------------
- # new method: atb_speed
- #--------------------------------------------------------------------------
- def atb_speed
- value = $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_svariable]]
- value = 20 - value * 2
- return [[value, 20].min, 1].max
- end
- #--------------------------------------------------------------------------
- # new method: atb_action_ready?
- #--------------------------------------------------------------------------
- def atb_action_ready?
- return false if @active_battler != nil
- return true if $game_troop.forcing_battler != nil
- return $game_troop.atb_ready != []
- end
- #--------------------------------------------------------------------------
- # new method: update_ctb_clockticks
- #--------------------------------------------------------------------------
- def update_ctb_clockticks
- return unless ctb?
- for member in ($game_troop.members + $game_party.members)
- $game_troop.ctb_ready.delete(member) if !member.movable?
- next if member.ctb_speed >= $game_troop.ctb_max
- $game_troop.ctb_ready.delete(member)
- end
- #---
- loop do
- break if $game_troop.ctb_ready.size > 0
- return if judge_win_loss
- @clockticks += 1
- if @clockticks % @ctr_per_turn == 0
- $game_troop.turn_ending = true
- process_battle_event
- $game_troop.turn_ending = false
- $game_troop.increase_turn
- if YEM::BATTLE_ENGINE::CTB_COMMON_EVENTS[:turn_update] != nil
- event_id = YEM::BATTLE_ENGINE::CTB_COMMON_EVENTS[:turn_update]
- $game_temp.common_event_id = event_id
- process_battle_event
- end
- process_battle_event
- end
- for member in @all_members
- if member.actor? and member.auto_battle and member.action.wait?
- member.make_action
- end
- member.update_ctb_speed
- end
- end
- #---
- @first_ctb_update = true
- @active_battler = $game_troop.ctb_ready[0]
- @active_battler.action.prepare unless @active_battler.action.forcing
- if !@active_battler.movable? and @active_battler.action.valid?
- process_action
- return
- end
- if @active_battler.actor? and (@active_battler.action.wait? or
- !@active_battler.action.valid?) and !@active_battler.auto_battle
- @selected_battler = @active_battler
- @actor_index = @selected_battler.index
- @status_window.index = @selected_battler.index
- @selected_battler.action.ctb_guarding_queue = false
- @selected_battler.action.ctb_guarding = false
- start_actor_command_selection
- elsif @active_battler.actor?
- @actor_command_window.active = false
- close_input_windows
- process_action
- return if @active_battler == nil
- @active_battler.make_action if @active_battler.auto_battle
- elsif @active_battler.enemy?
- @actor_command_window.active = false
- close_input_windows
- create_enemy_ctb_action
- end
- end
- #--------------------------------------------------------------------------
- # new method: create_enemy_ctb_action
- #--------------------------------------------------------------------------
- def create_enemy_ctb_action
- if @active_battler.action.wait? or @active_battler.action.nothing?
- @active_battler.make_action
- if @active_battler.action.skill? and
- @active_battler.action.skill.speed < 0
- $game_troop.ctb_ready.shift
- $game_troop.clear_ctb_cache
- make_action_orders
- return
- end
- end
- process_action
- end
- #--------------------------------------------------------------------------
- # new method: scroll_help_viewport?
- #--------------------------------------------------------------------------
- def scroll_help_viewport?
- if YEM::BATTLE_ENGINE::TARGET_WINDOW[:hidehelp]
- return false if @target_actor_window != nil
- return false if @target_enemy_window != nil
- end
- if @skill_window != nil
- return false if @skill_window.skill == nil
- return true
- end
- if @item_window != nil
- return false if @item_window.item == nil
- return true
- end
- return false
- end
- #--------------------------------------------------------------------------
- # new method: win_loss_flag
- #--------------------------------------------------------------------------
- def win_loss_flag; return @judge_win_loss; end
- #--------------------------------------------------------------------------
- # alias method: judge_win_loss
- #--------------------------------------------------------------------------
- alias judge_win_loss_bem judge_win_loss unless $@
- def judge_win_loss
- return false if @action_occuring
- return judge_win_loss_bem
- end
- #--------------------------------------------------------------------------
- # overwrite method: process_battle_start
- #--------------------------------------------------------------------------
- def process_battle_start
- @message_window.clear
- #---
- if YEM::BATTLE_ENGINE::DISPLAY_MESSAGE[:enemy_appear]
- for name in $game_troop.enemy_names
- text = sprintf(Vocab::Emerge, name)
- $game_message.texts.push(text)
- end
- end
- #---
- if YEM::BATTLE_ENGINE::DISPLAY_MESSAGE[:advantage] and !ptb?
- if $game_troop.preemptive
- text = sprintf(Vocab::Preemptive, $game_party.name)
- $game_message.texts.push(text)
- @pause_atb = true
- elsif $game_troop.surprise
- text = sprintf(Vocab::Surprise, $game_party.name)
- $game_message.texts.push(text)
- @pause_atb = true
- end
- end
- #---
- wait_for_message
- pause_atb(false)
- @message_window.clear
- @message_window.visible = false
- $game_party.update_battle_start
- $game_troop.update_battle_start
- make_escape_ratio
- $game_troop.make_actions
- make_action_orders
- if YEM::BATTLE_ENGINE::ALL_COMMON_EVENTS[:battle_start] != nil
- event_id = YEM::BATTLE_ENGINE::ALL_COMMON_EVENTS[:battle_start]
- $game_temp.common_event_id = event_id
- process_battle_event
- end
- process_battle_event
- if ctb?
- update_ctb_clockticks
- return
- end
- if enemy_initiative?
- enemy_turn_start
- else
- party_turn_start
- end
- end
- #--------------------------------------------------------------------------
- # new method: enemy_initiative?
- #--------------------------------------------------------------------------
- def enemy_initiative?
- return false if atb?
- return false if $game_troop.preemptive
- return true if ptb? and @ptb_initiative
- return true if ctb? and @ctb_initiative
- return $game_troop.surprise
- end
- #--------------------------------------------------------------------------
- # new method: party_turn_start
- #--------------------------------------------------------------------------
- def party_turn_start
- if ptb?
- ptb_remove_states_auto($game_party)
- ptb_turn_end($game_troop)
- @active_battler = nil
- $game_party.reset_ptb_turns
- $game_party.update_group_cooldowns
- @ptb_party_window.appear
- @ptb_troop_window.disappear
- ptb_party_berserk
- end
- @message_window.clear
- @message_window.visible = false
- if ptb? and YEM::BATTLE_ENGINE::PTB_COMMON_EVENTS[:party_turn] != nil
- event_id = YEM::BATTLE_ENGINE::PTB_COMMON_EVENTS[:party_turn]
- $game_temp.common_event_id = event_id
- process_battle_event
- end
- #---
- berserk_members = 0
- create_autobattler_actions unless ptb?
- for member in $game_party.existing_members
- next unless member.berserker? or member.confusion? or member.auto_battle
- berserk_members += 1
- end
- if berserk_members >= $game_party.existing_members.size
- enemy_turn_start
- return
- end
- #---
- @party_input_flag = true
- @actor_index = -1
- next_actor
- end
- #--------------------------------------------------------------------------
- # new method: enemy_turn_start
- #--------------------------------------------------------------------------
- def enemy_turn_start
- ptb_remove_states_auto($game_troop)
- ptb_turn_end($game_party)
- $game_troop.make_actions
- make_action_orders
- @party_input_flag = false
- $game_party.clear_actions if ptb?
- if ptb? and YEM::BATTLE_ENGINE::PTB_COMMON_EVENTS[:troop_turn] != nil
- event_id = YEM::BATTLE_ENGINE::PTB_COMMON_EVENTS[:troop_turn]
- $game_temp.common_event_id = event_id
- process_battle_event
- end
- start_main
- end
- #--------------------------------------------------------------------------
- # new method: create_autobattler_actions
- #--------------------------------------------------------------------------
- def create_autobattler_actions
- for member in $game_party.members
- next if member == nil
- next unless member.auto_battle
- unless member.exist?
- member.action.clear
- @status_window.draw_item(member.index)
- next
- end
- member.make_action
- @status_window.draw_item(member.index)
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: make_escape_ratio
- #--------------------------------------------------------------------------
- def make_escape_ratio
- actors_agi = $game_party.average_agi
- enemies_agi = $game_troop.average_agi
- @escape_ratio = 150 - 100 * enemies_agi / actors_agi
- if @action_escape and (dtb? or ptb?)
- @escape_ratio /= $game_party.members.size
- end
- @escape_ratio = 100 if ($TEST or $BTEST) and Input.press?(Input::CTRL)
- end
- #--------------------------------------------------------------------------
- # overwrite method: process_escape
- #--------------------------------------------------------------------------
- def process_escape
- @hide_battlecursor = true
- make_escape_ratio
- @message_window.visible = true
- text = sprintf(Vocab::EscapeStart, $game_party.name)
- $game_message.texts.push(text) unless @action_escape
- if $game_troop.preemptive
- success = true
- else
- success = (rand(100) < @escape_ratio)
- end
- Sound.play_escape unless @action_escape
- if success
- @enemy_gauge_window.visible = false if @enemy_gauge_window != nil
- $game_message.texts[0] += "\\.\\." unless @action_escape
- action_list = YEM::DEFAULT_ACTIONS::ACTOR_ESCAPE_ACTIONS
- perform_action_list(action_list, $game_party.existing_members)
- wait_for_message unless @action_escape
- battle_end(1)
- else
- if @action_escape
- @message_window.add_instant_text(Vocab::EscapeFailure)
- action_list = [["AUTOMELODY", ["RETURN ORIGIN"]]]
- battler = @selected_battler if @selected_battler != nil
- battler = @active_battler if @active_battler != nil
- perform_action_list(action_list, [battler])
- else
- $game_message.texts.push('\.' + Vocab::EscapeFailure)
- wait_for_message
- $game_party.clear_actions
- @status_window.refresh
- start_main
- @hide_battlecursor = false
- end
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: process_victory
- #--------------------------------------------------------------------------
- def process_victory
- @judge_win_loss = true
- pause_atb(true, true)
- @enemy_gauge_window.dispose if @enemy_gauge_window != nil
- @hide_battlecursor = true
- @party_input_flag = true
- @message_window.visible = true
- RPG::BGM.stop
- $game_system.battle_end_me.play
- unless $BTEST
- $game_temp.map_bgm.play
- $game_temp.map_bgs.play
- end
- start_victory_poses
- @spriteset.update_dtb_order
- @spriteset.update_ctb_order
- wait(45,true)
- if YEM::BATTLE_ENGINE::DEFAULT_VICTORY_MESSAGE
- @message_window.dispose
- @message_window = Window_BattleMessage.new
- @info_viewport.oy = Graphics.height * 8
- else
- close_input_windows
- wait(10)
- end
- display_exp_and_gold
- display_drop_items
- display_level_up
- battle_end(0)
- end
- #--------------------------------------------------------------------------
- # overwrite method: process_defeat
- #--------------------------------------------------------------------------
- def process_defeat
- @hide_battlecursor = true
- @judge_win_loss = true
- pause_atb(true, true)
- @message_window.visible = true
- text = sprintf(Vocab::Defeat, $game_party.name)
- $game_message.texts.push(text)
- wait_for_message
- battle_end(2)
- end
- #--------------------------------------------------------------------------
- # overwrite method: battle_end
- #--------------------------------------------------------------------------
- def battle_end(result)
- reset_extra_calculation_modifiers
- if result == 2 and not $game_troop.can_lose
- call_gameover
- else
- $game_troop.distribute_jp if result == 0 and $imported["SkillOverhaul"]
- $game_party.update_battle_over
- $game_troop.clear
- if $game_temp.battle_proc != nil
- $game_temp.battle_proc.call(result)
- $game_temp.battle_proc = nil
- end
- unless $BTEST
- $game_temp.map_bgm.play
- $game_temp.map_bgs.play
- end
- @message_window.clear
- $game_message.clear
- $scene = Scene_Map.new
- Graphics.fadeout(30)
- if YEM::BATTLE_ENGINE::ALL_COMMON_EVENTS[:battle_finish] != nil
- event_id = YEM::BATTLE_ENGINE::ALL_COMMON_EVENTS[:battle_finish]
- $game_temp.common_event_id = event_id
- end
- end
- $game_temp.in_battle = false
- end
- #--------------------------------------------------------------------------
- # new method: call_debug_menu
- #--------------------------------------------------------------------------
- def call_debug_menu
- return if @debug_entry_window != nil
- Sound.play_decision
- Graphics.freeze
- hide_screen_items
- snapshot_for_background
- $scene = Scene_Debug.new
- $scene.main
- $scene = self
- show_screen_items
- @actor_command_window.refresh
- @status_window.refresh
- perform_transition
- end
- #--------------------------------------------------------------------------
- # new method: call_equip_menu
- #--------------------------------------------------------------------------
- def call_equip_menu
- Graphics.freeze
- hide_screen_items
- snapshot_for_background
- previous_equips = @selected_battler.equips.clone
- $scene = Scene_Equip.new(@selected_battler.index)
- $scene.main
- $scene = self
- #---
- if @selected_battler.equips != previous_equips
- @selected_battler.equip_cooldown = YEM::BATTLE_ENGINE::EQUIP_COOLDOWN
- if atb?
- ctr = YEM::BATTLE_ENGINE::ATB_RULES[:turns_ctr]
- @selected_battler.equip_clocktick = ctr
- elsif ctb?
- ctr = YEM::BATTLE_ENGINE::CTB_RULES[:turns_ctr]
- @selected_battler.equip_clocktick = ctr
- end
- end
- #---
- show_screen_items
- @actor_command_window.refresh
- @status_window.refresh
- perform_transition
- end
- #--------------------------------------------------------------------------
- # new method: hide_screen_items
- #--------------------------------------------------------------------------
- def hide_screen_items
- @info_viewport.visible = false
- @spriteset.viewportA.visible = false
- @spriteset.viewportB.visible = false
- @spriteset.viewportC.visible = false
- end
- #--------------------------------------------------------------------------
- # new method: show_screen_items
- #--------------------------------------------------------------------------
- def show_screen_items
- @info_viewport.visible = true
- @spriteset.viewportA.visible = true
- @spriteset.viewportB.visible = true
- @spriteset.viewportC.visible = true
- end
- #--------------------------------------------------------------------------
- # overwrite method: next_actor
- #--------------------------------------------------------------------------
- def next_actor
- if @actor_index == $game_party.members.size-1
- @status_shortcut_index = $game_party.members.size-1
- start_confirm_command_selection
- return
- end
- @status_window.index = @actor_index += 1
- @selected_battler = $game_party.members[@actor_index]
- start_actor_command_selection
- end
- #--------------------------------------------------------------------------
- # overwrite method: prior_actor
- #--------------------------------------------------------------------------
- def prior_actor
- if @actor_index == 0
- @status_shortcut_index = 0
- start_party_command_selection
- return
- end
- @status_window.index = @actor_index -= 1
- @selected_battler = $game_party.members[@actor_index]
- start_actor_command_selection
- end
- #--------------------------------------------------------------------------
- # overwrite method: start_party_command_selection
- #--------------------------------------------------------------------------
- def start_party_command_selection
- return unless $game_temp.in_battle
- pause_atb(true)
- @status_window.refresh
- @status_window.index = @actor_index = -1
- @party_command_window.openness = 255
- @actor_command_window.openness = 255
- @confirm_command_window.active = false
- @selected_battler = nil
- @info_viewport.visible = true
- @message_window.visible = false unless atb?
- if !$game_switches[YEM::BATTLE_ENGINE::OPTIONS[:autocursor_sw]]
- @party_command_window.index = 0
- end
- @party_command_window.active = true
- @actor_command_window.active = false
- return if atb?
- loop do
- update_basic
- break if @info_viewport.ox == 0
- if @info_viewport.ox >= 0
- @info_viewport.ox -= [16, (0 - @info_viewport.ox).abs].min
- else
- @info_viewport.ox += [16, (0 - @info_viewport.ox).abs].min
- end
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: update_party_command_selection
- #--------------------------------------------------------------------------
- def update_party_command_selection
- if Input.trigger?(Input::C)
- party_command_case
- elsif Input.repeat?(Input::RIGHT)
- Sound.play_cursor
- @actor_index = -1
- next_actor
- elsif Input.trigger?(Input::L)
- Sound.play_cursor
- @actor_index = @status_shortcut_index - 1
- next_actor
- elsif Input.trigger?(Input::R)
- Sound.play_cursor
- start_confirm_command_selection
- #--- Debug Shortcuts ---
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F5)
- Sound.play_recovery
- for member in $game_party.members
- member.recover_all
- member.gain_rage(member.max_rage)
- end
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F6)
- Sound.play_use_item
- for member in $game_party.members
- member.hp += member.maxhp
- end
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F7)
- Sound.play_use_skill
- for member in $game_party.members
- member.mp += member.maxmp
- member.gain_rage(member.max_rage)
- end
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F8)
- Sound.play_actor_damage
- if Input.press?(Input::SHIFT)
- for member in $game_party.members
- member.hp -= member.maxhp/4 + 4
- member.mp -= member.maxmp/4 + 4
- member.lose_rage(member.max_rage/4)
- member.perform_collapse
- end
- else
- for member in $game_party.members
- member.hp = 1
- member.mp = 0
- member.lose_rage(member.max_rage)
- end
- end
- elsif ($TEST or $BTEST) and Input.press?(Input::CTRL) and
- Input.press?(Input::SHIFT)
- for enemy in $game_troop.existing_members
- enemy.hp = 0
- enemy.perform_collapse
- end
- end
- end
- #--------------------------------------------------------------------------
- # new method: party_command_case
- #--------------------------------------------------------------------------
- def party_command_case
- case @party_command_window.item
- when :fight
- Sound.play_decision
- @status_window.index = @actor_index = -1
- next_actor
- when :execute
- Sound.play_decision
- start_confirm_command_selection
- when :option
- Sound.play_decision
- start_options(@party_command_window)
- when :escape
- if $game_troop.can_escape == false
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- process_escape
- #---
- when :turnskip
- Sound.play_decision
- enemy_turn_start
- #---
- when :atb_type
- Sound.play_decision
- variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]
- $game_variables[variable] += 1
- $game_variables[variable] = 0 if $game_variables[variable] > 3
- @party_command_window.refresh
- @confirm_command_window.refresh
- when :atb_speed
- Sound.play_decision
- variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_svariable]
- $game_variables[variable] += 1
- $game_variables[variable] = 1 if $game_variables[variable] > 10
- @party_command_window.refresh
- @confirm_command_window.refresh
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: start_actor_command_selection
- #--------------------------------------------------------------------------
- def start_actor_command_selection
- update_battler_poses
- @party_command_window.active = false
- @confirm_command_window.active = false
- pause_atb(false)
- @confirm_command_window.openness = 0
- @actor_command_window.openness = 255 if @actor_command_window.openness == 0
- @actor_command_window.setup(@selected_battler)
- @actor_command_window.active = true
- if $game_switches[YEM::BATTLE_ENGINE::OPTIONS[:autocursor_sw]]
- index = @selected_battler.battle_command_index.to_i
- maximum = @actor_command_window.item_max - 1
- @actor_command_window.index = [index, maximum].min
- end
- @selected_battler.battle_command_index = nil
- update_battle_cursor
- end
- #--------------------------------------------------------------------------
- # overwrite method: update_actor_command_selection
- #--------------------------------------------------------------------------
- def update_actor_command_selection
- if @selected_battler.battle_command_index != @actor_command_window.index
- @selected_battler.battle_command_index = @actor_command_window.index
- if (dtb? or ctb?) and !@selected_battler.auto_battle
- $game_troop.clear_ctb_cache
- last_action = @selected_battler.action.clone
- case @actor_command_window.item
- when :attack; @selected_battler.action.set_attack
- when :guard; @selected_battler.action.set_guard
- else
- item = @actor_command_window.item
- array = YEM::BATTLE_ENGINE::SKILL_COMMANDS[item]
- if array != nil
- skill = $data_skills[array[0]]
- @selected_battler.action.set_skill(skill.id) if skill != nil
- end
- end
- make_action_orders
- @selected_battler.action = last_action
- end
- make_action_orders if @selected_battler.auto_battle and (dtb? or ctb?)
- end
- #---
- if Input.trigger?(Input::B)
- Sound.play_cancel
- cancel_action
- elsif Input.trigger?(Input::C)
- actor_command_case
- #~ elsif Input.repeat?(Input::LEFT) # Disable selecting actors when it's not
- #~ Sound.play_cursor # their turn; comment out all this above
- #~ prior_actor # the phrase "Debug Shortcuts"
- #~ elsif Input.repeat?(Input::RIGHT)
- #~ Sound.play_cursor
- #~ next_actor
- #~ elsif Input.trigger?(Input::L)
- #~ Sound.play_cursor
- #~ @status_shortcut_index = @status_window.index
- #~ start_party_command_selection
- #~ elsif Input.trigger?(Input::R)
- #~ Sound.play_cursor
- #~ @status_shortcut_index = @status_window.index
- #~ start_confirm_command_selection
- #--- Debug Shortcuts ---
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F5)
- Sound.play_recovery
- @selected_battler.recover_all
- @selected_battler.gain_rage(@selected_battler.max_rage)
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F6)
- Sound.play_use_item
- if Input.press?(Input::SHIFT)
- @selected_battler.hp += @selected_battler.maxhp/5
- else
- @selected_battler.hp = @selected_battler.maxhp
- end
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F7)
- Sound.play_use_skill
- if Input.press?(Input::SHIFT)
- @selected_battler.mp += @selected_battler.maxmp/5
- @selected_battler.gain_rage(@selected_battler.max_rage/5)
- else
- @selected_battler.mp = @selected_battler.maxmp
- @selected_battler.gain_rage(@selected_battler.max_rage)
- end
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F8)
- Sound.play_actor_damage
- if Input.press?(Input::SHIFT)
- @selected_battler.hp -= @selected_battler.maxhp/4 + 4
- @selected_battler.perform_collapse
- elsif Input.press?(Input::CTRL)
- @selected_battler.mp -= @selected_battler.maxmp/4 + 4
- @selected_battler.lose_rage(@selected_battler.max_rage/4)
- else
- @selected_battler.hp = 1
- @selected_battler.mp = 0
- @selected_battler.lose_rage(@selected_battler.max_rage)
- end
- elsif ($TEST or $BTEST) and Input.press?(Input::CTRL) and
- Input.press?(Input::SHIFT)
- for enemy in $game_troop.existing_members
- enemy.hp = 0
- enemy.perform_collapse
- end
- end
- end
- #--------------------------------------------------------------------------
- # new method: actor_command_case
- #--------------------------------------------------------------------------
- def actor_command_case
- if !@actor_command_window.enabled?(@actor_command_window.item)
- if @selected_battler.inputable? and !@selected_battler.auto_battle
- Sound.play_buzzer
- else
- Sound.play_cursor
- if !dtb? and (@actor_index == $game_party.members.size - 1)
- @actor_index = -1
- end
- next_actor
- end
- return
- end
- #---
- case @actor_command_window.item
- when :attack
- Sound.play_decision
- @selected_battler.action.set_attack
- start_target_enemy_selection
- when :skill
- Sound.play_decision
- start_skill_selection
- when :guard
- Sound.play_decision
- @selected_battler.action.set_guard
- confirm_action
- when :item
- Sound.play_decision
- start_item_selection
- when :equip
- Sound.play_decision
- call_equip_menu
- when :escape
- Sound.play_decision
- @selected_battler.action.set_escape
- confirm_action
- else
- Sound.play_decision
- @command_action = true
- @skill = @actor_command_window.skill
- determine_skill
- end
- end
- #--------------------------------------------------------------------------
- # new method: cancel_action
- #--------------------------------------------------------------------------
- def cancel_action
- return if @selected_battler == @active_battler
- @selected_battler.action.clear if allow_cancel_action?
- @status_window.draw_item(@selected_battler.index)
- $game_troop.clear_ctb_cache if ctb?
- make_action_orders unless @actor_command_window.active
- if $game_switches[YEM::BATTLE_ENGINE::OPTIONS[:next_actor_sw]] and !ctb?
- prior_actor unless @actor_index == 0
- end
- end
- #--------------------------------------------------------------------------
- # new method: allow_cancel_action?
- #--------------------------------------------------------------------------
- def allow_cancel_action?
- return false if @selected_battler.auto_battle
- return true unless atb?
- return false if @selected_battler == @active_battler
- return false if @selected_battler.atb_speed > $game_troop.atb_threshold
- return true
- end
- #--------------------------------------------------------------------------
- # new method: confirm_action
- #--------------------------------------------------------------------------
- def confirm_action
- @status_window.draw_item(@selected_battler.index)
- @selected_battler.action.atb_queue_down
- make_action_orders unless ctb?
- if instant_action?
- if ctb?
- wait(20, true) if @help_viewport.oy != 0
- close_input_windows
- end
- perform_instant_action
- else
- if atb? and @actor_index == $game_party.members.size - 1 and
- $game_switches[YEM::BATTLE_ENGINE::OPTIONS[:next_actor_sw]]
- @actor_index = -1
- end
- if ctb?
- if @selected_battler.ctb_active?
- $game_troop.ctb_ready.shift
- $game_troop.clear_ctb_cache
- make_action_orders
- update_ctb_clockticks
- return
- end
- make_action_orders
- if $game_switches[YEM::BATTLE_ENGINE::OPTIONS[:next_actor_sw]]
- @actor_index = -1 if @actor_index == $game_party.members.size - 1
- end
- end
- next_actor if $game_switches[YEM::BATTLE_ENGINE::OPTIONS[:next_actor_sw]]
- end
- end
- #--------------------------------------------------------------------------
- # new method: instant_action?
- #--------------------------------------------------------------------------
- def instant_action?
- return true if dtb_instant?
- return true if ptb?
- return true if ctb_instant?
- return false
- end
- #--------------------------------------------------------------------------
- # new method: dtb_instant?
- #--------------------------------------------------------------------------
- def dtb_instant?
- return false unless dtb?
- case @selected_battler.action.kind
- when 0; return false
- when 1; return @selected_battler.action.skill.instant
- when 2; return @selected_battler.action.item.instant
- end
- return false
- end
- #--------------------------------------------------------------------------
- # new method: ctb_instant?
- #--------------------------------------------------------------------------
- def ctb_instant?
- return false unless ctb?
- $game_troop.clear_ctb_cache
- return false unless @selected_battler.ctb_active?
- return true if @selected_battler.action.kind == 0
- return false if @selected_battler.ctb_total_speed < $game_troop.ctb_max
- return true
- end
- #--------------------------------------------------------------------------
- # new method: perform_instant_action
- #--------------------------------------------------------------------------
- def perform_instant_action
- @message_window.clear
- @message_window.visible = true
- @actor_command_window.active = false
- @active_battler = @selected_battler if @selected_battler != nil
- @instant_cast = true
- #---
- case @selected_battler.action.kind
- when 1; instant_property = @selected_battler.action.skill.instant
- when 2; instant_property = @selected_battler.action.item.instant
- else; instant_property = false
- end
- #---
- process_action
- @instant_cast = false
- @active_battler = nil
- if @selected_battler != nil
- @selected_battler.action.clear
- @status_window.draw_item(@selected_battler.index)
- end
- @message_window.clear
- @message_window.visible = false
- if ptb? and @selected_battler != nil
- ptb_party_berserk(true)
- #---
- berserk_members = 0
- for member in $game_party.existing_members
- next unless member.berserker? or member.confusion?
- berserk_members += 1
- end
- if $game_party.existing_members.size <= berserk_members
- enemy_turn_start
- return
- end
- #---
- if @selected_battler.action.friends_unit.ptb_total_turns <= 0
- enemy_turn_start
- return
- end
- @actor_index = -1 if @actor_index == $game_party.members.size-1
- if !$game_switches[YEM::BATTLE_ENGINE::OPTIONS[:next_actor_sw]] or
- instant_property
- @actor_index = @selected_battler.index - 1
- next_actor
- return
- end
- end
- @actor_index = @selected_battler.index - 1 if dtb?
- return if ctb?
- next_actor if $game_switches[YEM::BATTLE_ENGINE::OPTIONS[:next_actor_sw]]
- end
- #--------------------------------------------------------------------------
- # new method: start_confirm_command_selection
- #--------------------------------------------------------------------------
- def start_confirm_command_selection
- @selected_battler = nil
- @status_window.index = @actor_index = -1
- @actor_command_window.openness = 0
- @actor_command_window.active = false
- @party_command_window.active = false
- if !$game_switches[YEM::BATTLE_ENGINE::OPTIONS[:autocursor_sw]]
- @confirm_command_window.index = 0
- end
- @confirm_command_window.openness = 255
- @confirm_command_window.active = true
- pause_atb(true)
- make_action_orders
- end
- #--------------------------------------------------------------------------
- # new method: start_confirm_command_selection
- #--------------------------------------------------------------------------
- def update_confirm_command_selection
- if Input.trigger?(Input::B) or Input.repeat?(Input::LEFT)
- Sound.play_cancel if Input.trigger?(Input::B)
- Sound.play_cursor if Input.repeat?(Input::LEFT)
- @actor_index = $game_party.members.size
- @actor_command_window.openness = 255
- @actor_command_window.active = true
- @confirm_command_window.openness = 0
- @confirm_command_window.active = false
- prior_actor
- elsif Input.trigger?(Input::C)
- confirm_command_case
- elsif Input.trigger?(Input::L)
- Sound.play_cursor
- start_party_command_selection
- elsif Input.trigger?(Input::R)
- Sound.play_cursor
- @actor_index = @status_shortcut_index + 1
- prior_actor
- #--- Debug Shortcuts ---
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F5)
- Sound.play_recovery
- for member in $game_party.members
- member.recover_all
- member.gain_rage(member.max_rage)
- end
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F6)
- Sound.play_use_item
- for member in $game_party.members
- member.hp += member.maxhp
- end
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F7)
- Sound.play_use_skill
- for member in $game_party.members
- member.mp += member.maxmp
- member.gain_rage(member.max_rage)
- end
- elsif ($TEST or $BTEST) and Input.trigger?(Input::F8)
- Sound.play_actor_damage
- if Input.press?(Input::SHIFT)
- for member in $game_party.members
- member.hp -= member.maxhp/4 + 4
- member.mp -= member.maxmp/4 + 4
- member.perform_collapse
- end
- else
- for member in $game_party.members
- member.hp = 1
- member.mp = 0
- end
- end
- elsif ($TEST or $BTEST) and Input.press?(Input::CTRL) and
- Input.press?(Input::SHIFT)
- for enemy in $game_troop.existing_members
- enemy.hp = 0
- enemy.perform_collapse
- end
- end
- end
- #--------------------------------------------------------------------------
- # new method: confirm_command_case
- #--------------------------------------------------------------------------
- def confirm_command_case
- case @confirm_command_window.item
- when :confirm
- Sound.play_decision
- start_main
- when :status
- Sound.play_decision
- start_actor_status
- when :option
- Sound.play_decision
- start_options(@confirm_command_window)
- when :escape
- if !$game_troop.can_escape
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- process_escape
- #---
- when :turnskip
- Sound.play_decision
- enemy_turn_start
- #---
- when :atb_type
- Sound.play_decision
- variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]
- $game_variables[variable] += 1
- $game_variables[variable] = 0 if $game_variables[variable] > 3
- @party_command_window.refresh
- @confirm_command_window.refresh
- when :atb_speed
- Sound.play_decision
- variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_svariable]
- $game_variables[variable] += 1
- $game_variables[variable] = 1 if $game_variables[variable] > 10
- @party_command_window.refresh
- @confirm_command_window.refresh
- end
- end
- #--------------------------------------------------------------------------
- # new method: start_actor_status
- #--------------------------------------------------------------------------
- def start_actor_status
- @actor_status_window = Window_BattleActor.new
- @actor_states_window = Window_BattleActorStates.new
- @actor_status_window.viewport = @spriteset.viewportC
- @actor_states_window.viewport = @spriteset.viewportC
- @confirm_command_window.active = false
- @status_window.active = true
- @status_window.index = 0
- end
- #--------------------------------------------------------------------------
- # new method: update_actor_status
- #--------------------------------------------------------------------------
- def update_actor_status
- @actor_states_window.update
- if @last_query_index != @status_window.index
- @last_query_index = @status_window.index
- @actor_status_window.refresh(@last_query_index)
- @actor_states_window.refresh(@status_window.actor)
- end
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @status_window.active = false
- @last_query_index = nil
- @actor_status_window.dispose
- @actor_status_window = nil
- @actor_states_window.dispose
- @actor_states_window = nil
- start_confirm_command_selection
- end
- end
- #--------------------------------------------------------------------------
- # new method: start_options
- #--------------------------------------------------------------------------
- def start_options(host_window)
- host_window.active = false
- @options_host_window = host_window
- @help_window = Window_Help.new
- @options_window = Window_BattleOptions.new(0, @help_window.height)
- @options_window.help_window = @help_window
- @options_window.viewport = @spriteset.viewportC
- @help_window.viewport = @spriteset.viewportC
- end
- #--------------------------------------------------------------------------
- # new method: end_options
- #--------------------------------------------------------------------------
- def end_options
- @options_window.dispose
- @options_window = nil
- @help_window.dispose
- @help_window = nil
- @options_host_window.active = true
- end
- #--------------------------------------------------------------------------
- # new method: update_options
- #--------------------------------------------------------------------------
- def update_options
- @options_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- end_options
- end
- end
- #--------------------------------------------------------------------------
- # new method: create_highlighted_targets
- #--------------------------------------------------------------------------
- def create_highlighted_targets(group = nil)
- return if group == nil
- @highlighted_targets = []
- return if @selected_battler.action.attack? and !atb?
- obj = @selected_battler.action.skill if @selected_battler.action.skill?
- obj = @selected_battler.action.item if @selected_battler.action.item?
- if atb?
- case @selected_battler.action.atb_queue_kind
- when 0; return
- when 1; obj = $data_skills[@selected_battler.action.atb_queue_basic]
- when 2; obj = $data_items[@selected_battler.action.atb_queue_basic]
- else; return
- end
- end
- if obj.for_user?
- @highlighted_targets |= [@selected_battler]
- elsif obj.for_random? or obj.for_all?
- @highlighted_targets |= group.existing_members
- end
- #---
- main_target = @target_enemy_window.enemy if @target_enemy_window != nil
- main_target = @target_actor_window.actor if @target_actor_window != nil
- return if main_target == nil
- @highlighted_targets |= group.area_targets(main_target, obj)
- end
- #--------------------------------------------------------------------------
- # overwrite method: start_target_enemy_selection
- #--------------------------------------------------------------------------
- def start_target_enemy_selection
- pause_atb(true) if semi_active_atb? or wait_atb?
- create_highlighted_targets($game_troop)
- @target_help_window.active = true
- @status_window.draw_item(@selected_battler.index)
- @target_enemy_window = Window_TargetEnemy.new
- @target_enemy_window.y = Graphics.height * 8
- if !left_to_right
- @target_enemy_window.index = @target_enemy_window.item_max-1
- end
- @actor_command_window.active = false
- create_aoe_indicator(@target_enemy_window)
- @enemy_gauge_window = Window_EnemyGauge.new
- @enemy_gauge_window.viewport = @spriteset.viewportB
- end
- #--------------------------------------------------------------------------
- # overwrite method: end_target_enemy_selection
- #--------------------------------------------------------------------------
- def end_target_enemy_selection
- @target_help_window.active = false
- @last_target_enemy = nil
- @status_window.draw_item(@selected_battler.index)
- @target_enemy_window.dispose
- @target_enemy_window = nil
- if @actor_command_window.item == :attack or @command_action
- @actor_command_window.active = true
- @command_action = false
- end
- pause_atb(false) if semi_active_atb?
- dispose_aoe_indicator
- @enemy_gauge_window.dispose if @enemy_gauge_window != nil
- @enemy_gauge_window = nil
- end
- #--------------------------------------------------------------------------
- # overwrite method: update_target_enemy_selection
- #--------------------------------------------------------------------------
- def update_target_enemy_selection
- @target_enemy_window.update
- if @target_enemy_window.enemy != nil
- @target_enemy_window.enemy.white_flash = true
- end
- for target in @highlighted_targets; target.white_flash = true; end
- if @last_target_enemy != @target_enemy_window.index
- @last_target_enemy = @target_enemy_window.index
- @target_help_window.refresh(@target_enemy_window.enemy, @selected_battler)
- update_battle_cursor
- @enemy_gauge_window.battler = @target_enemy_window.enemy
- end
- @enemy_gauge_window.update
- if Input.trigger?(Input::B)
- @selected_battler.action.clear
- @mini_window.refresh if @mini_window != nil
- Sound.play_cancel
- end_target_enemy_selection
- update_battle_cursor
- elsif Input.trigger?(Input::C)
- return if @target_enemy_window.enemy == nil
- Sound.play_decision
- @selected_battler.action.target_index = @target_enemy_window.enemy.index
- end_target_enemy_selection
- end_skill_selection
- end_item_selection
- confirm_action
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: start_target_actor_selection
- #--------------------------------------------------------------------------
- def start_target_actor_selection
- pause_atb(true) if semi_active_atb? or wait_atb?
- if @command_action
- @info_viewport.ox += @status_window.width
- @info_viewport.rect.x += @status_window.width
- end
- create_highlighted_targets($game_party)
- @target_help_window.active = true
- @target_actor_window = Window_BattleStatus.new(true)
- @target_actor_window.index = 0
- @target_actor_window.active = true
- @target_actor_window.y = @info_viewport.rect.y
- @actor_command_window.active = false
- #---
- @target_actor_hp = Window_BattleStatusHP.new
- @target_actor_mp = Window_BattleStatusMP.new
- @target_actor_states = Window_BattleStatusStates.new
- @target_actor_rage = Window_BattleStatusRage.new
- @target_actor_hp.y = @target_actor_window.y
- @target_actor_mp.y = @target_actor_window.y
- @target_actor_states.y = @target_actor_window.y
- @target_actor_rage.y = @target_actor_window.y
- #---
- if atb_target_actor_case
- obj = @selected_battler.action.skill if @selected_battler.action.skill?
- obj = @selected_battler.action.item if @selected_battler.action.item?
- if atb?
- case @selected_battler.action.atb_queue_kind
- when 1
- obj = $data_skills[@selected_battler.action.atb_queue_basic]
- when 2
- obj = $data_items[@selected_battler.action.atb_queue_basic]
- end
- end
- @target_actor_window.target_highlight = true
- @target_actor_window.highlight_all = true if obj.for_all?
- @target_actor_window.highlight_all = true if obj.for_random?
- @target_actor_window.highlight_user = true if obj.for_user?
- @target_actor_window.frozen_cursor = true if obj.for_user?
- @target_actor_window.index = @selected_battler.index if obj.for_user?
- @target_actor_window.highlight_none = true if obj.for_none?
- @target_actor_window.highlight_dead = true if obj.for_dead_friend?
- @target_actor_window.refresh
- end
- #---
- @target_help_window.refresh(@target_actor_window.actor, @selected_battler)
- hide_object_windows
- update_battle_cursor
- create_aoe_indicator(@target_actor_window)
- end
- #--------------------------------------------------------------------------
- # new method: atb_target_actor_case
- #--------------------------------------------------------------------------
- def atb_target_actor_case
- if atb?
- return true if [1, 2].include?(@selected_battler.action.atb_queue_kind)
- return false
- end
- return true if @selected_battler.action.skill?
- return true if @selected_battler.action.item?
- return false
- end
- #--------------------------------------------------------------------------
- # overwrite method: end_target_actor_selection
- #--------------------------------------------------------------------------
- def end_target_actor_selection
- @target_help_window.active = false
- @last_target_enemy = nil
- @status_window.draw_item(@selected_battler.index)
- @target_actor_window.dispose
- @target_actor_window = nil
- #---
- @target_actor_hp.dispose
- @target_actor_mp.dispose
- @target_actor_states.dispose
- @target_actor_rage.dispose
- @target_actor_hp = nil
- @target_actor_mp = nil
- @target_actor_states = nil
- @target_actor_rage = nil
- #---
- show_object_windows
- if @actor_command_window.item == :attack or @command_action
- @info_viewport.ox -= @status_window.width
- @info_viewport.rect.x -= @status_window.width
- @actor_command_window.active = true
- @command_action = false
- end
- pause_atb(false) if semi_active_atb?
- dispose_aoe_indicator
- end
- #--------------------------------------------------------------------------
- # overwrite method: update_target_actor_selection
- #--------------------------------------------------------------------------
- def update_target_actor_selection
- @target_actor_window.update
- if @target_actor_window.actor != nil
- @target_actor_window.actor.white_flash = true
- end
- for target in @highlighted_targets; target.white_flash = true; end
- if @last_target_actor != @target_actor_window.index
- @last_target_actor = @target_actor_window.index
- @target_help_window.refresh(@target_actor_window.actor, @selected_battler)
- update_battle_cursor
- end
- if Input.trigger?(Input::B)
- @selected_battler.action.clear
- @mini_window.refresh if @mini_window != nil
- Sound.play_cancel
- end_target_actor_selection
- update_battle_cursor
- elsif Input.trigger?(Input::C)
- if !@target_actor_window.opacity?(@target_actor_window.actor)
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- @selected_battler.action.target_index = @target_actor_window.index
- end_target_actor_selection
- end_skill_selection
- end_item_selection
- confirm_action
- end
- end
- #--------------------------------------------------------------------------
- # new method: create_mini_window
- #--------------------------------------------------------------------------
- def create_mini_window
- $game_temp.less_spacing = nil
- @info_viewport.oy = Graphics.height * 8
- @mini_window = Window_BattleStatus_Mini.new if @mini_window == nil
- end
- #--------------------------------------------------------------------------
- # new method: dispose_mini_window
- #--------------------------------------------------------------------------
- def dispose_mini_window
- @info_viewport.oy = 0
- return if @mini_window == nil
- @mini_window.dispose
- @mini_window = nil
- end
- #--------------------------------------------------------------------------
- # new method: hide_object_windows
- #--------------------------------------------------------------------------
- def hide_object_windows
- @skill_window.y = Graphics.height * 8 if @skill_window != nil
- @item_window.y = Graphics.height * 8 if @item_window != nil
- end
- #--------------------------------------------------------------------------
- # new method: show_object_windows
- #--------------------------------------------------------------------------
- def show_object_windows
- @skill_window.y = @info_viewport.rect.y if @skill_window != nil
- @item_window.y = @info_viewport.rect.y if @item_window != nil
- end
- #--------------------------------------------------------------------------
- # overwrite method: start_skill_selection
- #--------------------------------------------------------------------------
- def start_skill_selection
- dx = 0; dy = Graphics.height-128; dw = Graphics.width - 128; dh = 128
- $game_temp.less_spacing = true
- @skill_window = Window_Skill.new(dx, dy, dw, dh, @selected_battler)
- @skill_window.help_window = @view_help_window
- @actor_command_window.active = false
- create_mini_window
- pause_atb(true) if semi_wait_atb? or wait_atb?
- end
- #--------------------------------------------------------------------------
- # overwrite method: end_skill_selection
- #--------------------------------------------------------------------------
- def end_skill_selection
- dispose_mini_window
- if @skill_window != nil
- @skill_window.dispose
- @skill_window = nil
- end
- @last_skill_index = nil
- $game_troop.clear_ctb_cache if ctb?
- make_action_orders
- @actor_command_window.active = true
- pause_atb(false)
- end
- #--------------------------------------------------------------------------
- # overwrite method: update_skill_selection
- #--------------------------------------------------------------------------
- def update_skill_selection
- @skill_window.active = true
- @skill_window.update
- #---
- if @last_skill_index != @skill_window.index
- @last_skill_index = @skill_window.index
- if dtb? or ctb?
- $game_troop.clear_ctb_cache
- skill = @skill_window.skill
- if skill != nil and @selected_battler.skill_can_use?(skill)
- last_action = @selected_battler.action.clone
- @selected_battler.action.set_skill(skill.id)
- make_action_orders
- @selected_battler.action = last_action
- end
- end
- end
- #---
- if Input.trigger?(Input::B)
- @selected_battler.action.clear
- @status_window.draw_item(@selected_battler.index)
- Sound.play_cancel
- end_skill_selection
- update_battle_cursor
- elsif Input.trigger?(Input::C)
- @skill = @skill_window.skill
- if @skill != nil
- @selected_battler.last_skill_id = @skill.id
- end
- if @selected_battler.skill_can_use?(@skill)
- Sound.play_decision
- determine_skill
- else
- Sound.play_buzzer
- end
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: determine_skill
- #--------------------------------------------------------------------------
- def determine_skill
- @selected_battler.action.set_skill(@skill.id)
- @mini_window.refresh if @mini_window != nil
- @skill_window.active = false if @skill_window != nil
- if @skill.for_opponent?
- start_target_enemy_selection
- else
- start_target_actor_selection
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: start_item_selection
- #--------------------------------------------------------------------------
- def start_item_selection
- dx = 0; dy = Graphics.height-128; dw = Graphics.width - 128; dh = 128
- $game_temp.less_spacing = true
- @item_window = Window_Item.new(dx, dy, dw, dh)
- @item_window.help_window = @view_help_window
- @actor_command_window.active = false
- create_mini_window
- pause_atb(true) if semi_wait_atb? or wait_atb?
- end
- #--------------------------------------------------------------------------
- # overwrite method: end_item_selection
- #--------------------------------------------------------------------------
- def end_item_selection
- dispose_mini_window
- if @item_window != nil
- @item_window.dispose
- @item_window = nil
- end
- @last_item_index = nil
- $game_troop.clear_ctb_cache if ctb?
- make_action_orders
- @actor_command_window.active = true
- end
- #--------------------------------------------------------------------------
- # overwrite method: update_item_selection
- #--------------------------------------------------------------------------
- def update_item_selection
- @item_window.active = true
- @item_window.update
- #---
- if @last_item_index != @item_window.index
- @last_item_index = @item_window.index
- if dtb? or ctb?
- $game_troop.clear_ctb_cache
- item = @item_window.item
- if item != nil and @selected_battler.item_can_use?(item)
- last_action = @selected_battler.action.clone
- @selected_battler.action.set_item(item.id)
- make_action_orders
- @selected_battler.action = last_action
- end
- end
- end
- #---
- if Input.trigger?(Input::B)
- @selected_battler.action.clear
- @status_window.draw_item(@selected_battler.index)
- Sound.play_cancel
- end_item_selection
- update_battle_cursor
- elsif Input.trigger?(Input::C)
- @item = @item_window.item
- if @item != nil
- $game_party.last_item_id = @item.id
- end
- if @selected_battler.item_can_use?(@item)
- Sound.play_decision
- determine_item
- else
- Sound.play_buzzer
- end
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: determine_item
- #--------------------------------------------------------------------------
- def determine_item
- @selected_battler.action.set_item(@item.id)
- @mini_window.refresh if @mini_window != nil
- @item_window.active = false
- if @item.for_opponent?
- start_target_enemy_selection
- else
- start_target_actor_selection
- end
- end
- #--------------------------------------------------------------------------
- # new method: pause_atb
- #--------------------------------------------------------------------------
- def pause_atb(value, locked = false)
- return unless atb?
- return if @locked
- @locked = locked
- if value == true
- @pause_atb = true
- return
- end
- return if @confirm_command_window.active
- return if @party_command_window.active
- return if @options_window != nil
- return if @actor_status_window != nil
- return if @active_battler != nil
- if semi_active_atb? or semi_wait_atb? or wait_atb?
- return if @target_enemy_window != nil
- return if @target_actor_window != nil
- end
- if semi_wait_atb? or wait_atb?
- return if @skill_window != nil
- return if @item_window != nil
- end
- if wait_atb?
- for member in $game_party.existing_members
- next if member.atb_speed < $game_troop.atb_threshold
- return if member.action.wait?
- end
- end
- @pause_atb = false
- end
- #--------------------------------------------------------------------------
- # overwrite method: start_main
- # Used as starting turns or processing actions.
- #--------------------------------------------------------------------------
- def start_main
- $game_troop.increase_turn
- #---
- start_main_dtb
- start_main_ptb
- #---
- @message_window.visible = true
- @message_window.clear
- close_input_windows unless atb?
- @selected_battler = nil
- @active_battler = nil
- @message_window.clear
- @performed_actors = []
- @party_input_flag = nil
- make_action_orders
- end
- #--------------------------------------------------------------------------
- # new method: close_input_windows
- #--------------------------------------------------------------------------
- def close_input_windows
- @party_command_window.active = false
- @actor_command_window.active = false
- @confirm_command_window.active = false
- @party_command_window.openness = 0
- @actor_command_window.openness = 0
- @confirm_command_window.openness = 0
- loop do
- update_basic
- break if @info_viewport.ox == 64
- if @info_viewport.ox >= 64
- @info_viewport.ox -= [16, (64 - @info_viewport.ox).abs].min
- else
- @info_viewport.ox += [16, (64 - @info_viewport.ox).abs].min
- end
- end
- @status_window.index = @actor_index = -1
- end
- #--------------------------------------------------------------------------
- # new method: start_main_dtb
- #--------------------------------------------------------------------------
- def start_main_dtb
- $game_party.update_turn_start
- $game_party.update_group_cooldowns
- $game_troop.update_turn_start
- $game_troop.update_group_cooldowns
- @spriteset.mark_first_time_order
- close_input_windows
- if YEM::BATTLE_ENGINE::DTB_COMMON_EVENTS[:turn_start] != nil
- event_id = YEM::BATTLE_ENGINE::DTB_COMMON_EVENTS[:turn_start]
- $game_temp.common_event_id = event_id
- process_battle_event
- end
- end
- #--------------------------------------------------------------------------
- # new method: start_main_ptb
- #--------------------------------------------------------------------------
- def start_main_ptb
- return unless ptb?
- $game_troop.reset_ptb_turns
- $game_troop.update_group_cooldowns
- @ptb_troop_window.appear
- @ptb_party_window.disappear
- $game_troop.update_turn_start
- end
- #--------------------------------------------------------------------------
- # overwrite method: make_action_orders
- #--------------------------------------------------------------------------
- def make_action_orders
- make_action_orders_dtb
- make_action_orders_ptb
- make_action_orders_ctb
- end
- #--------------------------------------------------------------------------
- # new method: make_action_orders_ctb
- #--------------------------------------------------------------------------
- def make_action_orders_ctb
- return unless ctb?
- @action_battlers = @all_members.clone
- @action_battlers.sort! { |a,b|
- if a.ctb_ctr != b.ctb_ctr
- a.ctb_ctr <=> b.ctb_ctr
- elsif a.ctb_prediction != b.ctb_prediction
- b.ctb_prediction <=> a.ctb_prediction
- elsif a.agi != b.agi
- b.agi <=> a.agi
- else
- b.screen_x <=> a.screen_x
- end
- }
- @spriteset.update_ctb_order if @first_ctb_update
- end
- #--------------------------------------------------------------------------
- # overwrite method: turn_end
- #--------------------------------------------------------------------------
- def turn_end
- remove_states_auto
- $game_troop.turn_ending = true
- $game_troop.update_turn_end
- $game_party.update_turn_end
- $game_troop.preemptive = false
- $game_troop.surprise = false
- @message_window.visible = false
- if dtb? and YEM::BATTLE_ENGINE::DTB_COMMON_EVENTS[:turn_finish] != nil
- event_id = YEM::BATTLE_ENGINE::DTB_COMMON_EVENTS[:turn_finish]
- $game_temp.common_event_id = event_id
- process_battle_event
- end
- process_battle_event
- $game_troop.turn_ending = false
- $game_troop.make_actions
- @performed_actors = []
- party_turn_start
- end
- #--------------------------------------------------------------------------
- # overwrite method: ptb_turn_end
- #--------------------------------------------------------------------------
- def ptb_turn_end(group)
- return unless ptb?
- $game_troop.turn_ending = true
- group.update_turn_end
- $game_troop.preemptive = false
- $game_troop.surprise = false
- process_battle_event
- $game_troop.turn_ending = false
- end
- #--------------------------------------------------------------------------
- # overwrite method: set_next_active_battler
- #--------------------------------------------------------------------------
- def set_next_active_battler
- @performed_actors = [] if @performed_actors == nil
- loop do
- if $game_troop.forcing_battler != nil
- @active_battler = $game_troop.forcing_battler
- @action_battlers.delete(@active_battler)
- $game_troop.forcing_battler = nil
- else
- make_action_orders
- @action_battlers -= @performed_actors
- @active_battler = @action_battlers.shift
- end
- @performed_actors.push(@active_battler) unless @active_battler == nil
- return if @active_battler == nil
- return if @active_battler.index != nil
- end
- end
- #--------------------------------------------------------------------------
- # new method: sort_targets
- #--------------------------------------------------------------------------
- def sort_targets(targets, obj = nil)
- if obj != nil
- return targets.compact if obj.for_random?
- end
- if left_to_right
- targets.sort! { |a,b| a.screen_x <=> b.screen_x }
- else
- targets.sort! { |a,b| b.screen_x <=> a.screen_x }
- end
- return targets.compact
- end
- #--------------------------------------------------------------------------
- # new method: left_to_right
- #--------------------------------------------------------------------------
- def left_to_right
- case @view_type
- when 0; type = :empty
- when 1; type = :front
- when 2; type = :side
- when 3; type = :angle
- else; return true
- end
- return YEM::BATTLE_ENGINE::MISC_VIEW_ADJUSTMENTS[type][2]
- end
- #--------------------------------------------------------------------------
- # new method: status_window_refresh
- #--------------------------------------------------------------------------
- def status_window_refresh
- return unless @active_battler.actor?
- @status_window.draw_item(@active_battler.index)
- end
- #--------------------------------------------------------------------------
- # overwrite method: process_action
- #--------------------------------------------------------------------------
- def process_action
- return if judge_win_loss
- return if $game_temp.next_scene != nil
- @combo_damage = 0; @combo_heal = 0
- @action_occuring = true
- process_dtb_action if dtb?
- process_ptb_action if ptb?
- process_atb_action if atb?
- process_ctb_action if ctb?
- @message_window.clear
- @action_occuring = false
- update_battler_poses
- update_ctb_clockticks
- end
- #--------------------------------------------------------------------------
- # new method: process_dtb_action
- #--------------------------------------------------------------------------
- def process_dtb_action
- loop do
- set_next_active_battler unless @instant_cast
- if @active_battler == nil
- turn_end unless @instant_cast
- return
- end
- @status_window.refresh
- @message_window.clear
- @active_battler.action.prepare unless @active_battler.action.forcing
- if @active_battler.action.valid?
- break
- else
- @message_window.clear
- display_current_state
- end
- end
- execute_action
- update_battler_poses
- unless @active_battler.action.forcing
- @message_window.clear
- display_current_state
- end
- @active_battler = nil
- end
- #--------------------------------------------------------------------------
- # new method: process_ptb_action
- #--------------------------------------------------------------------------
- def process_ptb_action
- if $game_troop.forcing_battler != nil
- @active_battler = $game_troop.forcing_battler
- $game_troop.forcing_battler = nil
- process_ptb_action
- return
- elsif @active_battler == nil
- make_action_orders
- @active_battler = @action_battlers[0]
- if @active_battler != nil and @active_battler.enemy?
- @active_battler.make_action
- end
- party_turn_start if $game_troop.ptb_total_turns <= 0
- return
- end
- @status_window.refresh
- @message_window.clear
- @active_battler.action.prepare unless @active_battler.action.forcing
- return if !@active_battler.action.valid?
- execute_action
- return if @active_battler == nil
- if @active_battler.action == nil
- @active_battler = nil
- return
- end
- unless @active_battler.action.forcing
- @message_window.clear
- display_current_state
- end
- @active_battler.action.forcing = false
- @active_battler = nil
- end
- #--------------------------------------------------------------------------
- # new method: ptb_party_berserk
- #--------------------------------------------------------------------------
- def ptb_party_berserk(set_return = false)
- return unless ptb?
- previous_selected_battler = @selected_battler
- berserk_members = 0
- performed_action = false
- for member in $game_party.existing_members
- next unless member.berserker? or member.confusion? or member.auto_battle
- berserk_members += 1
- next if $game_party.ptb_total_turns <= 0
- next if member.ptb_performed
- member.ptb_performed = true
- member.action.set_attack
- if member.auto_battle and !member.berserker? and !member.confusion?
- member.make_action
- end
- @selected_battler = member
- @actor_command_window.setup(@selected_battler)
- @status_window.index = @selected_battler.index
- perform_instant_action
- performed_action = true
- end
- @selected_battler = previous_selected_battler
- if performed_action and !set_return and @selected_battler != nil
- @actor_command_window.setup(@selected_battler)
- @status_window.index = @selected_battler.index
- end
- return if set_return
- return if $game_party.existing_members.size > berserk_members
- enemy_turn_start
- end
- #--------------------------------------------------------------------------
- # new method: ptb_remove_states_auto
- #--------------------------------------------------------------------------
- def ptb_remove_states_auto(group)
- return unless ptb?
- return if $game_troop.surprise
- for member in group.members
- last_st = member.states
- member.remove_states_auto
- if member.states != last_st
- display_state_changes(member)
- @message_window.clear
- end
- end
- end
- #--------------------------------------------------------------------------
- # new method: process_atb_action
- #--------------------------------------------------------------------------
- def process_atb_action
- if $game_troop.forcing_battler != nil
- @active_battler = $game_troop.forcing_battler
- else
- @active_battler = $game_troop.atb_ready[0]
- $game_troop.atb_ready.delete(@active_battler)
- end
- return if @active_battler == nil
- return if !@active_battler.action.valid?
- pause_atb(true)
- @message_window.visible = true
- execute_action unless @active_battler.action.wait?
- @message_window.clear
- @message_window.visible = false
- unless $game_troop.forcing_battler
- $game_troop.atb_ready.delete(@active_battler)
- @active_battler.reset_atb_speed
- @active_battler.process_atb_reset
- end
- $game_troop.forcing_battler = nil
- @active_battler = nil
- if YEM::BATTLE_ENGINE::ATB_COMMON_EVENTS[:end_action] != nil
- event_id = YEM::BATTLE_ENGINE::ATB_COMMON_EVENTS[:end_action]
- $game_temp.common_event_id = event_id
- process_battle_event
- end
- pause_atb(false)
- end
- #--------------------------------------------------------------------------
- # new method: process_ctb_action
- #--------------------------------------------------------------------------
- def process_ctb_action
- return if @active_battler == nil
- @spriteset.mark_first_time_order
- $game_troop.clear_ctb_cache
- make_action_orders
- @message_window.visible = true
- @instant_action = true
- unless $game_troop.forcing_battler
- @active_battler.action.ctb_guarding = false
- end
- execute_action
- @message_window.clear
- @message_window.visible = false
- unless $game_troop.forcing_battler
- @active_battler.reset_ctb_speed
- @active_battler.process_ctb_reset
- end
- $game_troop.forcing_battler = nil
- @active_battler.action.forcing = false
- @active_battler = nil
- if YEM::BATTLE_ENGINE::CTB_COMMON_EVENTS[:end_action] != nil
- event_id = YEM::BATTLE_ENGINE::CTB_COMMON_EVENTS[:end_action]
- $game_temp.common_event_id = event_id
- process_battle_event
- end
- $game_troop.ctb_ready.shift unless @instant_ctb_action
- $game_troop.clear_ctb_cache
- make_action_orders
- end
- #--------------------------------------------------------------------------
- # alias method: execute_action
- #--------------------------------------------------------------------------
- alias execute_action_bem execute_action unless $@
- def execute_action
- reset_extra_calculation_modifiers
- if @active_battler != nil
- if @active_battler.action.valid? or @active_battler.action.forcing
- execute_action_bem if @active_battler.action != nil
- end
- #---
- if @active_battler.action.forcing and
- @active_battler.stored_action != nil
- @active_battler.action = @active_battler.stored_action
- @active_battler.stored_action = nil
- elsif @active_battler.action.forcing
- @active_battler.action.clear
- end
- end
- reset_extra_calculation_modifiers
- end
- #--------------------------------------------------------------------------
- # new method: reset_extra_calculation_modifiers
- #--------------------------------------------------------------------------
- def reset_extra_calculation_modifiers
- $game_temp.action_elements = nil
- $game_temp.force_critical = nil
- $game_temp.perfect_hit = false
- $game_temp.hp_damage_inflate = 100
- $game_temp.mp_damage_inflate = 100
- @ignore_cost = false
- @ptb_updated = false
- @combo_hits = 0
- $game_temp.atk_effects = ["calc", "dmg", "state", "effect", "collapse"]
- $game_temp.item_effects = ["calc", "growth", "dmg", "state", "effect",
- "collapse"]
- $game_temp.skill_effects = ["calc", "dmg", "state", "effect", "collapse"]
- for member in ($game_party.members + $game_troop.members)
- member.clear_action_results
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: execute_action_attack
- #--------------------------------------------------------------------------
- def execute_action_attack
- targets = @active_battler.action.make_targets
- targets = sort_targets(targets)
- #--- Setup ---
- action_list = @active_battler.attack_setup_actions
- perform_action_list(action_list, targets) unless @chain_action
- @active_battler.action.friends_unit.update_ptb
- lunatic_obj_effects(:before)
- #--- Whole ---
- action_list = @active_battler.attack_whole_actions
- perform_action_list(action_list, targets)
- #--- Target ---
- action_list = @active_battler.attack_target_actions
- for target in targets
- next if target.dead?
- perform_action_list(action_list, [target])
- end
- #--- Follow ---
- action_list = @active_battler.attack_follow_actions
- perform_action_list(action_list, targets)
- lunatic_obj_effects(:after)
- #--- Finish ---
- refresh_ptb_windows unless @ptb_updated
- action_list = @active_battler.attack_finish_actions
- perform_action_list(action_list, targets) unless @chain_action
- perform_earn_jp(:attack) if $imported["SkillOverhaul"]
- end
- #--------------------------------------------------------------------------
- # overwrite method: execute_action_guard
- #--------------------------------------------------------------------------
- def execute_action_guard
- @active_battler.action.friends_unit.update_ptb
- if atb?
- @active_battler.action.atb_guarding = true
- elsif ctb?
- @active_battler.action.ctb_guarding = true
- @active_battler.action.ctb_guarding_queue = false
- end
- refresh_ptb_windows
- action_list = @active_battler.guard_actions
- perform_action_list(action_list, [@active_battler])
- perform_earn_jp(:guard) if $imported["SkillOverhaul"]
- end
- #--------------------------------------------------------------------------
- # overwrite method: execute_action_escape
- #--------------------------------------------------------------------------
- def execute_action_escape
- @active_battler.action.friends_unit.update_ptb
- refresh_ptb_windows
- action_list = YEM::DEFAULT_ACTIONS::ENEMY_ESCAPE_ACTIONS
- perform_action_list(action_list, [@active_battler])
- end
- #--------------------------------------------------------------------------
- # overwrite method: execute_action_wait
- #--------------------------------------------------------------------------
- def execute_action_wait
- if (ptb? and @active_battler.action.guard?) or (ctb?)
- execute_action_guard
- return
- end
- @active_battler.action.friends_unit.update_ptb
- refresh_ptb_windows
- action_list = YEM::DEFAULT_ACTIONS::WAIT_ACTIONS
- perform_action_list(action_list, [@active_battler])
- end
- #--------------------------------------------------------------------------
- # overwrite method: execute_action_skill
- #--------------------------------------------------------------------------
- def execute_action_skill
- @copy_targets = [] if $imported["SkillEquipSystem"]
- skill = @active_battler.action.skill
- @scene_skill = skill
- perform_skill(skill)
- perform_earn_jp(:skill) if $imported["SkillOverhaul"]
- readjust_instant_properties if skill.instant
- end
- #--------------------------------------------------------------------------
- # overwrite method: perform_skill
- #--------------------------------------------------------------------------
- def perform_skill(skill)
- targets = @active_battler.action.make_targets
- targets = sort_targets(targets, skill)
- #--- Setup ---
- action_list = skill.setup_action_list
- perform_action_list(action_list, targets) unless @chain_action
- lunatic_obj_effects(:before, skill)
- @active_battler.perform_skill_cost(skill) unless @ignore_cost
- @active_battler.action.friends_unit.update_ptb
- status_window_refresh
- #--- Whole ---
- action_list = skill.whole_action_list
- perform_action_list(action_list, targets)
- #--- Target ---
- action_list = skill.target_action_list
- for target in targets
- next if target.dead? and !skill.for_dead_friend?
- perform_action_list(action_list, [target])
- end
- #--- Follow ---
- action_list = skill.follow_action_list
- perform_action_list(action_list, targets)
- lunatic_obj_effects(:after, skill)
- #--- Finish ---
- perform_copy_skill(skill) if $imported["SkillEquipSystem"]
- refresh_ptb_windows unless @ptb_updated
- action_list = skill.finish_action_list
- perform_action_list(action_list, targets) unless @chain_action
- end
- #--------------------------------------------------------------------------
- # overwrite method: execute_action_item
- #--------------------------------------------------------------------------
- def execute_action_item
- item = @active_battler.action.item
- if unique_item_effect?(item)
- perform_unique_item(item)
- else
- @scene_item = item
- perform_item(item)
- end
- perform_earn_jp(:item) if $imported["SkillOverhaul"]
- readjust_instant_properties if item.instant
- end
- #--------------------------------------------------------------------------
- # new method: unique_item_effect?
- #--------------------------------------------------------------------------
- def unique_item_effect?(item)
- return false unless @active_battler.actor?
- if @active_battler.pharmacology and item.unique_effect[:pharm] != nil
- return true
- elsif item.unique_effect[:actor].include?(@active_battler.actor_id)
- return true
- elsif item.unique_effect[:class].include?(@active_battler.class_id)
- return true
- end
- return false
- end
- #--------------------------------------------------------------------------
- # new method: perform_unique_item
- #--------------------------------------------------------------------------
- def perform_unique_item(item)
- if @active_battler.pharmacology and item.unique_effect[:pharm] != nil
- item_id = item.unique_effect[:pharm]
- elsif item.unique_effect[:actor].include?(@active_battler.actor_id)
- item_id = item.unique_effect[:actor][@active_battler.actor_id]
- elsif item.unique_effect[:class].include?(@active_battler.class_id)
- item_id = item.unique_effect[:class][@active_battler.class_id]
- end
- unique_item = $data_items[item_id]
- @active_battler.perform_consume_item(item)
- @ignore_cost = true
- perform_item(unique_item)
- end
- #--------------------------------------------------------------------------
- # new method: perform_item
- #--------------------------------------------------------------------------
- def perform_item(item)
- targets = @active_battler.action.make_targets
- targets = sort_targets(targets, item)
- #--- Setup ---
- action_list = item.setup_action_list
- perform_action_list(action_list, targets) unless @chain_action
- lunatic_obj_effects(:before, item)
- @active_battler.perform_consume_item(item) unless @ignore_cost
- @active_battler.action.friends_unit.update_ptb
- status_window_refresh
- #--- Whole ---
- action_list = item.whole_action_list
- perform_action_list(action_list, targets)
- #--- Target ---
- action_list = item.target_action_list
- for target in targets
- next if target.dead? and !item.for_dead_friend?
- perform_action_list(action_list, [target])
- end
- #--- Follow ---
- action_list = item.follow_action_list
- perform_action_list(action_list, targets)
- lunatic_obj_effects(:after, item)
- #--- Finish ---
- refresh_ptb_windows unless @ptb_updated
- action_list = item.finish_action_list
- perform_action_list(action_list, targets) unless @chain_action
- end
- #--------------------------------------------------------------------------
- # overwrite method: process_battle_event
- #--------------------------------------------------------------------------
- def process_battle_event
- @message_window.clear
- @message_window.visible = true
- loop do
- return if judge_win_loss
- return if $game_temp.next_scene != nil
- $game_troop.interpreter.update
- $game_troop.setup_battle_event
- wait_for_message
- process_action if $game_troop.forcing_battler != nil
- return unless $game_troop.interpreter.running?
- update_basic
- end
- @message_window.clear
- $game_message.clear
- end
- #--------------------------------------------------------------------------
- # new method: process_complete_battle_event
- #--------------------------------------------------------------------------
- def process_complete_battle_event
- @message_window.clear
- @message_window.visible = true
- loop do
- $game_troop.interpreter.update
- $game_troop.setup_battle_event
- wait_for_message
- process_action if $game_troop.forcing_battler != nil
- return unless $game_troop.interpreter.running?
- update_basic
- end
- @message_window.clear
- $game_message.clear
- end
- #--------------------------------------------------------------------------
- # new method: readjust_instant_properties
- #--------------------------------------------------------------------------
- def readjust_instant_properties
- @performed_actors.delete(@active_battler)
- if @active_battler.enemy?
- @active_battler.make_action
- @instant_ctb_action = true if ctb?
- elsif @active_battler.actor? and @active_battler.auto_battle
- @active_battler.make_action
- end
- end
- #--------------------------------------------------------------------------
- # new method: target_mirror?
- #--------------------------------------------------------------------------
- def target_mirror?(mirror, target)
- case @view_type
- when 0; view = :empty
- when 1; view = :front
- when 2; view = :side
- when 3; view = :angle
- else; return mirror
- end
- index = target.actor? ? 0 : 1
- mirror = !mirror if YEM::BATTLE_ENGINE::MISC_VIEW_ADJUSTMENTS[view][index]
- return mirror
- end
- #--------------------------------------------------------------------------
- # new method: show_animation?
- #--------------------------------------------------------------------------
- def show_animation?
- return true if cinematic?
- return $game_switches[YEM::BATTLE_ENGINE::OPTIONS[:animation_sw]]
- end
- #--------------------------------------------------------------------------
- # overwrite method: remove_states_auto
- # Scene Battle Version
- #--------------------------------------------------------------------------
- def remove_states_auto
- for member in $game_troop.members + $game_party.members
- next if member == nil
- @message_window.clear
- member.remove_states_auto
- display_state_changes(member)
- end
- @message_window.clear
- end
- #--------------------------------------------------------------------------
- # alias method: display_current_state
- #--------------------------------------------------------------------------
- alias display_current_state_bem display_current_state unless $@
- def display_current_state
- return unless YEM::BATTLE_ENGINE::DISPLAY_MESSAGE[:currentstate]
- display_current_state_bem
- end
- #--------------------------------------------------------------------------
- # display_action_effects
- #--------------------------------------------------------------------------
- def display_action_effects(target, obj = nil)
- return if target.skipped
- line_number = @message_window.line_number
- display_critical(target, obj)
- display_damage(target, obj)
- display_state_changes(target, obj)
- lunatic_obj_effects(:during, obj, target)
- @message_window.back_to(line_number)
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_critical
- #--------------------------------------------------------------------------
- def display_critical(target, obj = nil)
- return unless target.critical
- action_list = YEM::DEFAULT_ACTIONS::CRITICAL_ACTIONS
- perform_action_list(action_list, [target])
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_miss
- #--------------------------------------------------------------------------
- def display_miss(target, obj = nil)
- if obj == nil or obj.physical_attack
- action_list = YEM::DEFAULT_ACTIONS::MISS_ACTIONS
- perform_action_list(action_list, [target])
- else
- display_failure(target, obj)
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_evasion
- #--------------------------------------------------------------------------
- def display_evasion(target, obj = nil)
- action_list = YEM::DEFAULT_ACTIONS::EVADE_ACTIONS
- perform_action_list(action_list, [target])
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_failure
- #--------------------------------------------------------------------------
- def display_failure(target, obj = nil)
- action_list = YEM::DEFAULT_ACTIONS::FAIL_ACTIONS
- perform_action_list(action_list, [target])
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_hp_damage
- #--------------------------------------------------------------------------
- def display_hp_damage(target, obj = nil)
- if target.hp_damage == 0
- return if obj != nil and obj.damage_to_mp
- return if obj != nil and obj.base_damage == 0
- @combo_hits += 1
- action_list = YEM::DEFAULT_ACTIONS::HP_DAMAGE_NONE
- perform_action_list(action_list, [target])
- elsif target.hp_damage > 0
- @combo_hits += 1
- @combo_damage += target.hp_damage
- @combo_update = true
- action_list = YEM::DEFAULT_ACTIONS::HP_DAMAGE_DMG
- perform_action_list(action_list, [target])
- else
- @combo_hits += 1
- @combo_damage += target.hp_damage
- @combo_update = true
- action_list = YEM::DEFAULT_ACTIONS::HP_DAMAGE_HEAL
- perform_action_list(action_list, [target])
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_mp_damage
- #--------------------------------------------------------------------------
- def display_mp_damage(target, obj = nil)
- return if target.dead?
- return if target.mp_damage == 0
- if target.mp_damage > 0
- action_list = YEM::DEFAULT_ACTIONS::MP_DAMAGE_DMG
- perform_action_list(action_list, [target])
- else
- action_list = YEM::DEFAULT_ACTIONS::MP_DAMAGE_HEAL
- perform_action_list(action_list, [target])
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_state_changes
- #--------------------------------------------------------------------------
- def display_state_changes(target, obj = nil)
- return if target.missed or target.evaded
- return unless target.states_active?
- if @message_window.line_number < 4 and
- YEM::BATTLE_ENGINE::DISPLAY_MESSAGE[:state_change]
- @message_window.add_instant_text("")
- end
- display_added_states(target, obj)
- display_removed_states(target, obj)
- display_remained_states(target, obj)
- if YEM::BATTLE_ENGINE::DISPLAY_MESSAGE[:state_change] and
- @message_window.last_instant_text.empty?
- @message_window.back_one
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_added_states
- #--------------------------------------------------------------------------
- def display_added_states(target, obj = nil)
- action_list = YEM::DEFAULT_ACTIONS::ADD_STATE
- @state_number = 0 if @state_number == nil
- for state in target.added_states
- perform_action_list(action_list, [target])
- @state_number += 1
- end
- @state_number = nil
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_removed_states
- #--------------------------------------------------------------------------
- def display_removed_states(target, obj = nil)
- action_list = YEM::DEFAULT_ACTIONS::REM_STATE
- @state_number = 0 if @state_number == nil
- for state in target.removed_states
- perform_action_list(action_list, [target])
- @state_number += 1
- end
- @state_number = nil
- end
- #--------------------------------------------------------------------------
- # overwrite method: display_remained_states
- #--------------------------------------------------------------------------
- def display_remained_states(target, obj = nil)
- action_list = YEM::DEFAULT_ACTIONS::DUR_STATE
- @state_number = 0 if @state_number == nil
- for state in target.remained_states
- perform_action_list(action_list, [target])
- @state_number += 1
- end
- @state_number = nil
- end
- end # Scene_Battle
- #===============================================================================
- #
- # END OF FILE
- #
- #===============================================================================