#=============================================================================== # # Yanfly Engine RD - Custom Turn Order # Last Date Updated: 2009.05.28 # Level: Normal, Hard, Lunatic # # This script allows you to adjust the values used to calculate turn order in # battle. In addition to calculating turn order differently, it also adds a new # stat called Delay, which in turn affects the battler's speed on an active # scale rather than a passive scale. # #=============================================================================== # Updates: # ---------------------------------------------------------------------------- # o 2009.05.28 - Bug fix. # o 2009.05.27 - Started script. #=============================================================================== # Instructions #=============================================================================== # # The following can be used for Skills and Items. # ----------------------------------------------- # # This will allow a skill or item to have more than 999 initiative or less # than -999 initiative. Uses the same speed mod in module. Use + for a positive # speed bonus and - for a negative speed bonus. # # and # This will delay the caster or target's next action by x speed. Use - for a # negative delay and + for an increase in initiative. # # The following can be used for Status Effects. # --------------------------------------------- # # This will set the rate of delay based on the speed variable (not the delay # variable). If you input 50 for x, then speed will be at 50% of what it would # normally be. # # # This will cause the state to adjust delay rate by a set amount. Use - for a # negative delay decrease and + for a positive delay increase. # #=============================================================================== # # Compatibility # - Incompatible: Any ATB and CTB systems obviously. # - Requires: # - Works With: # - Alias: Game_Battler: item_effect, skill_effect, initialize # - Overwrites: Game_BattleAction: make_speed # #=============================================================================== $imported = {} if $imported == nil $imported["CustomTurnOrder"] = true module YE module BATTLE module INITIATIVE #------------------------------------------------------------------------ # SPEED RELATED #------------------------------------------------------------------------ # Speed determines the order the battlers will act in. More speed means # quicker battlers. Less speed means slower battlers. It's simple. Here # are some options that'll allow you to adjust the basic speed modifiers. #------------------------------------------------------------------------ # This will set the base speed that all battlers start with. BASE_SPEED = 0.00 # This will dictate how much influence agility has over determining battle # order. These rules pertain only to agility. BASE_AGI_MOD = 1.00 # How much speed each point of agi gives. RAND_AGI_SET = 5 # Sets base random value for agility. RAND_AGI_MOD = 4 # Sets random modifier for agi. Set 0 to disable. # The next two multipliers determine the speed boost given per point of # skill initiative or item initiative. SKILL_SPEED_MOD = 1.00 ITEM_SPEED_MOD = 1.50 # This will determine how much speed guarding will give. GUARD_SPEED = 2000 # Originally, fast attack only affected normal attacks. Now, you can set # the property to affect other aspects governing the speed boost fast # attack gives. FAST_ATTACK_SPEED = 1000 # The speed given for fast attacking. FAST_ATTACK_ATTACK = true # Enables fast attack for attacking. FAST_ATTACK_GUARD = false # Enables fast attack for guarding. FAST_ATTACK_SKILL = true # Enables fast attack for skills. FAST_ATTACK_ITEMS = true # Enables fast attack for items. #------------------------------------------------------------------------ # DELAY RELATED #------------------------------------------------------------------------ # Delay is a new stat added with this script. It modifies when battlers' # calculated speed independent of agility. Unlike initiative modifiers, # delay allows a battler to actively affect another battler's delay for # better or for worse. #------------------------------------------------------------------------ # Set true to reset delay at the start of each battle. DELAY_RESET_BATTLE = true # Set true to reset delay when performing each action. DELAY_RESET_ACTION = true end end end #=============================================================================== # How to Use: Lunatic Mode #=============================================================================== # # # This will determine the custom speed initiative given by the skill or item # being used. # #=============================================================================== class Game_BattleAction def custom_speed(obj) speed = 0 case obj.custom_speed #--------------------------------------------------------------------------- # ////////////////////////////////////////////////////////////////////////// # This is where you begin adding in your own custom speed modifiers. #--------------------------------------------------------------------------- when 1 # If the battler is above 50% MaxHP, give more of a speed boost. if battler.hp > (battler.maxhp / 2) speed += 1000 else speed += 100 end when 2 #--------------------------------------------------------------------------- # This is the part you guys shouldn't touch afterwards. # ////////////////////////////////////////////////////////////////////////// #--------------------------------------------------------------------------- end return speed end #----------------------------------------------------------------------------- #-----This is the common modifier. It'll occur whenever speed is calculated. def common_speed speed = 0 return speed end #----------------------------------------------------------------------------- end class Game_Battler def custom_delay(user, obj) delay = 0 case obj.custom_delay #--------------------------------------------------------------------------- # ////////////////////////////////////////////////////////////////////////// # This is where you begin adding in your own custom delay modifiers. #--------------------------------------------------------------------------- when 1 # If the user is above 50% MaxHP, give more delay. if user.hp > (user.maxhp / 2) delay -= 1000 else delay -= 100 end when 2 #--------------------------------------------------------------------------- # This is the part you guys shouldn't touch afterwards. # ////////////////////////////////////////////////////////////////////////// #--------------------------------------------------------------------------- end return delay end end #=============================================================================== # 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. #=============================================================================== module YE module REGEXP module BASEITEM SPEED_BONUS = /<(?:SPEED_BONUS|speed bonus)[ ]*([\+\-]\d+)>/i CUSTOM_SPEED = /<(?:CUSTOM_SPEED|custom speed)[ ]*([\+\-]\d+)>/i DELAY_TARGET = /<(?:DELAY_TARGET|delay target)[ ]*([\+\-]\d+)>/i DELAY_CASTER = /<(?:DELAY_CASTER|delay caster)[ ]*([\+\-]\d+)>/i CUSTOM_DELAY = /<(?:CUSTOM_DELAY|custom delay)[ ]*([\+\-]\d+)>/i end module STATE DELAY_SET = /<(?:DELAY_SET|delay set)[ ]*([\+\-]\d+)>/i DELAY_PER = /<(?:DELAY_PER|delay per)[ ]*(\d+)>/i end end end #=============================================================================== # RPG::BaseItem #=============================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # Yanfly_Cache_Baseitem_CTO #-------------------------------------------------------------------------- def yanfly_cache_baseitem_cto @speed_bonus = 0; @custom_speed = 0; @delay_target = 0; @delay_caster = 0 @custom_delay = 0; self.note.split(/[\r\n]+/).each { |line| case line when YE::REGEXP::BASEITEM::SPEED_BONUS @speed_bonus = $1.to_i when YE::REGEXP::BASEITEM::CUSTOM_SPEED @custom_speed = $1.to_i when YE::REGEXP::BASEITEM::DELAY_TARGET @delay_target = $1.to_i when YE::REGEXP::BASEITEM::DELAY_CASTER @delay_caster = $1.to_i when YE::REGEXP::BASEITEM::CUSTOM_DELAY @custom_delay = $1.to_i end } end #-------------------------------------------------------------------------- # Definitions #-------------------------------------------------------------------------- def speed_bonus yanfly_cache_baseitem_cto if @speed_bonus == nil return @speed_bonus end def custom_speed yanfly_cache_baseitem_cto if @custom_speed == nil return @custom_speed end def delay_target yanfly_cache_baseitem_cto if @delay_target == nil return @delay_target end def delay_caster yanfly_cache_baseitem_cto if @delay_caster == nil return @delay_caster end def custom_delay yanfly_cache_baseitem_cto if @custom_delay == nil return @custom_delay end end #=============================================================================== # RPG::State #=============================================================================== class RPG::State #-------------------------------------------------------------------------- # Yanfly_Cache_State_CTO #-------------------------------------------------------------------------- def yanfly_cache_state_cto @delay_set = 0; @delay_per = 100 self.note.split(/[\r\n]+/).each { |line| case line when YE::REGEXP::STATE::DELAY_SET @delay_set = $1.to_i when YE::REGEXP::STATE::DELAY_PER @delay_per = $1.to_i end } end #-------------------------------------------------------------------------- # Definitions #-------------------------------------------------------------------------- def delay_set yanfly_cache_state_cto if @delay_set == nil return @delay_set end def delay_per yanfly_cache_state_cto if @delay_per == nil return @delay_per end end #=============================================================================== # Game_BattleAction #=============================================================================== class Game_BattleAction #-------------------------------------------------------------------------- # overwrite make_speed #-------------------------------------------------------------------------- def make_speed result = YE::BATTLE::INITIATIVE::BASE_SPEED result += battler.agi * YE::BATTLE::INITIATIVE::BASE_AGI_MOD result += rand(randset + battler.agi / randagi) unless randagi == 0 result += attack_bonus_speed if attack? result += skill.speed_bonus if skill? result += guard_bonus_speed if guard? result += item_bonus_speed if item? result += battler.delay result += common_speed for state in battler.states result *= state.delay_per / 100.0 end @speed = Integer(result) end #-------------------------------------------------------------------------- # random agility set #-------------------------------------------------------------------------- def randset return YE::BATTLE::INITIATIVE::RAND_AGI_SET end #-------------------------------------------------------------------------- # random agility mod #-------------------------------------------------------------------------- def randagi return YE::BATTLE::INITIATIVE::RAND_AGI_MOD end #-------------------------------------------------------------------------- # attack_bonus_speed #-------------------------------------------------------------------------- def attack_bonus_speed result = 0 if battler.fast_attack and YE::BATTLE::INITIATIVE::FAST_ATTACK_ATTACK result += YE::BATTLE::INITIATIVE::FAST_ATTACK_SPEED end return result end #-------------------------------------------------------------------------- # skill bonus speed #-------------------------------------------------------------------------- def skill_bonus_speed result = 0 if skill.speed_bonus > 0 result += skill.speed_bonus * YE::BATTLE::INITIATIVE::SKILL_SPEED_MOD else result += skill.speed * YE::BATTLE::INITIATIVE::SKILL_SPEED_MOD end if battler.fast_attack and YE::BATTLE::INITIATIVE::FAST_ATTACK_SKILL result += YE::BATTLE::INITIATIVE::FAST_ATTACK_SPEED end result += custom_speed(skill) if skill.custom_speed > 0 return result end #-------------------------------------------------------------------------- # guard_bonus_speed #-------------------------------------------------------------------------- def guard_bonus_speed result = 0 result += YE::BATTLE::INITIATIVE::GUARD_SPEED if battler.fast_attack and YE::BATTLE::INITIATIVE::FAST_ATTACK_GUARD result += YE::BATTLE::INITIATIVE::FAST_ATTACK_SPEED end return result end #-------------------------------------------------------------------------- # item_bonus_speed #-------------------------------------------------------------------------- def item_bonus_speed result = 0 if item.speed_bonus > 0 result += item.speed_bonus * YE::BATTLE::INITIATIVE::ITEM_SPEED_MOD else result += item.speed * YE::BATTLE::INITIATIVE::ITEM_SPEED_MOD end if battler.fast_attack and YE::BATTLE::INITIATIVE::FAST_ATTACK_ITEMS result += YE::BATTLE::INITIATIVE::FAST_ATTACK_SPEED end result += custom_speed(item) if item.custom_speed > 0 return result end end # Game_BattleAction #=============================================================================== # Game_Battler #=============================================================================== class Game_Battler #-------------------------------------------------------------------------- # Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :delay #-------------------------------------------------------------------------- # alias initialize #-------------------------------------------------------------------------- alias initialize_cto initialize unless $@ def initialize initialize_cto @delay = 0 end #-------------------------------------------------------------------------- # delay #-------------------------------------------------------------------------- def delay @delay = 0 if @delay == nil result = @delay for state in states result += state.delay_set end return Integer(result) end #-------------------------------------------------------------------------- # alias skill_effect #-------------------------------------------------------------------------- alias skill_effect_cto skill_effect unless $@ def skill_effect(user, skill) @delay += skill.delay_target perform_custom_delay(user, skill) skill_effect_cto(user, skill) end #-------------------------------------------------------------------------- # alias item_effect #-------------------------------------------------------------------------- alias item_effect_cto item_effect unless $@ def item_effect(user, item) @delay += item.delay_target perform_custom_delay(user, item) item_effect_cto(user, item) end #-------------------------------------------------------------------------- # perform custom delay #-------------------------------------------------------------------------- def perform_custom_delay(user, obj) return unless obj.custom_delay > 0 @delay += custom_delay(user, obj) end end # Game_Battler #=============================================================================== # Scene_Battle #=============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # alias process_battle_start #-------------------------------------------------------------------------- alias process_battle_start_cto process_battle_start unless $@ def process_battle_start process_battle_start_cto for member in $game_party.members member.delay = 0 if YE::BATTLE::INITIATIVE::DELAY_RESET_BATTLE end end #-------------------------------------------------------------------------- # alias execute_action #-------------------------------------------------------------------------- alias execute_action_cto execute_action unless $@ def execute_action @active_battler.delay = 0 if YE::BATTLE::INITIATIVE::DELAY_RESET_ACTION if @active_battler.action.skill? @active_battler.delay += @active_battler.action.skill.delay_caster elsif @active_battler.action.item? @active_battler.delay += @active_battler.action.item.delay_caster end execute_action_cto end end #=============================================================================== # # END OF FILE # #===============================================================================