SHARE
TWEET

Ao no Kiseki CBS 1

kirinelf Apr 2nd, 2012 2,026 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # ■ Ao no Kiseki Custom Battle System 17_2
  3. #   @version 0.28 12/03/08
  4. #   @author Saba Kan
  5. #   @translator kirinelf
  6. #------------------------------------------------------------------------------
  7. #  
  8. # ■ Usage
  9. #  ★★★★The skills numbered 001-010 in the database are needed.★★★★
  10. #  Please copy them and edit those copies instead.
  11. #
  12. #   Attack (001)   … Sets up charge times and delays for normal attacks.
  13. #                    If <delay> and <charge> tags aren't specified in a skill,
  14. #                    The values defined here will be used.
  15. #   Guard (002)    … The delay after guarding.
  16. #   Escape (003    … The delay after a failed escape.
  17. #   Battle Start (004) … The initial delay for each actor at the start of battle.
  18. #   Revive (005)   … The delay after being revived from death.
  19. #   Cancel (006)   … The delay after being interrupted.
  20. #   Pre-emptive Strike (007) … The same as Battle Start, but used for
  21. #                              preemptive strikes.
  22. #   Stop Movement(008) … The delay after recovering from a status effect
  23. #                        that makes you unable to move.
  24. #
  25. #  ★★★★Graphics Needed★★★★
  26. #   Please copy the contents of "Graphics/System" folder into your own.
  27. #   Also, if you want to erase the targetting image when an enemy is
  28. #   targetting an ally, please replace 'Target.png' with a transparent
  29. #   image.
  30. #
  31. # ■ Tags that can be placed in skill and item notetags.
  32. #   For more information, look at the sample skills.
  33. #   <delay> n  … The delay after using a skill.
  34. #                (Time taken before you can act again).
  35. #   <charge> n … How long it takes to charge/channel the skill before it's used.
  36. #   <chargemsg> string  … The message to show when the character
  37. #                         starts charging a skill.
  38. #                         Only used with a skill that has <charge>.
  39. #   <state> n     …   ID of the state to be inflicted on the character
  40. #                     charging the skill.
  41. #                     Removed when the skill finishes charging and is used.
  42. #                     Only used with a skill that has <charge>.
  43. #   <statescope> string  …  The targets affected by the state. Can have two
  44. #                           different strings: allenemies and allallies.
  45. #                           Both can be used together.
  46. #   <cancel>             …    Allows this skill/item to interrupt enemy skills.
  47. #   <cancelrate> n …  When <cancel> is used in a notetag, this determines
  48. #                                                   interruption rate. 100% rate when n = 100.
  49. #   <nocancel>           …  This skill can't be interrupted.
  50. #   <slow> n               …  This tag allows you to have skills that affect a actor's
  51. #                       turn directly.
  52. #                     For example: '<slow> 5' moves the actor's turn 5 turns down.
  53. #                                                 Can be negative to speed up actors.
  54. #   <slowrate> n         …    When <slow> is used in a notetag, this determines
  55. #                     delay rate. 100% rate when n = 100.
  56. #
  57. # ■ A summary of tags that can be placed in actor and enemy notetags.
  58. #   <nocancel> … This character can't be interrupted.
  59. #   <noslow>  … This character can't be slowed.
  60. #
  61. #==============================================================================
  62. module Saba
  63.   module Kiseki
  64.     # Default enemy unit graphic if not defined in enemy notetag.
  65.     DEFAULT_MONSTER_GRAPHIC_NAME = "Monster1"
  66.    
  67.     # Index number of the above.
  68.     DEFAULT_MONSTER_GRAPHIC_INDEX = 3
  69.    
  70.     # This sets the notetag to be used to define monster graphics.
  71.     # Enter like this in an enemy's notetag:
  72.           # <GRAPHIC_MARKER> <Filename> <index>
  73.           # E.g. GRAPHIC Monster2 2
  74.     GRAPHIC_MARKER = "GRAPHIC"
  75.    
  76.     # Influences the speed of actors. Please use an integer above 0. Percentage.
  77.     # Default: 100, 1.2x Faster: 120, Half Speed: 50
  78.     SPEED_INFLUENCE = 100 # %
  79.    
  80.     # Debug message display
  81.     # Allows you to view the agility and speed correction values of the actors
  82.           # I think, from looking at the code, it prints out your characters' agility,
  83.           # then the relative speed for the battle or something.
  84.     DEBUG = false
  85.    
  86.     # Default skill preparation message.
  87.     DEFAULT_PREPARE_MSG = "%s is preparing to use %s!"
  88.    
  89.     # Charging SE
  90.     OPERATE_SE_FILE = "Audio/SE/Heal4"
  91.     # Charging SE Volume
  92.     OPERATE_SE_VOLUME = 80
  93.     # Charging SE Pitch
  94.     OPERATE_SE_PITCH = 150
  95.   end
  96. end
  97.  
  98. #=========================================================================
  99. # Do not edit anything under this line unless you know what you're doing!
  100. #=========================================================================
  101.  
  102. class Scene_Battle
  103.   include Saba::Kiseki
  104.   #--------------------------------------------------------------------------
  105.   # ● 開始処理
  106.   #--------------------------------------------------------------------------
  107.   alias saba_kiseki_start start
  108.   def start
  109.     $game_party.clear_results
  110.     calculate_battlers_speed
  111.     OrderManager.init_unit
  112.     saba_kiseki_start
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ○ バトラーの速度偏差値を求めます。
  116.   #--------------------------------------------------------------------------
  117.   def calculate_battlers_speed
  118.     battlers = $game_party.battle_members + $game_troop.members
  119.    
  120.     total = 0.0
  121.     for battler in battlers
  122.       total += battler.agi
  123.     end
  124.    
  125.     mean = total / battlers.size
  126.     standard_deviation = 0.0
  127.  
  128.     for battler in battlers
  129.       standard_deviation += (battler.agi - mean) * (battler.agi - mean)
  130.     end
  131.    
  132.     standard_deviation /= battlers.size
  133.     standard_deviation = Math.sqrt(standard_deviation)
  134.     for battler in battlers
  135.       if standard_deviation != 0
  136.         battler.spd = ((battler.agi - mean) / standard_deviation) * 10
  137.       else
  138.         battler.spd = 0
  139.       end
  140.       battler.spd *= (SPEED_INFLUENCE / 100.0)
  141.       battler.spd += 50
  142.       msgbox battler.name + " Agi:" + battler.agi.to_s + " Speed:" + battler.spd.to_i.to_s if DEBUG
  143.     end
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ● パーティコマンド選択の開始
  147.   #--------------------------------------------------------------------------
  148.   def start_party_command_selection
  149.     unless scene_changing?
  150.       refresh_status
  151.       @status_window.unselect
  152.       @status_window.open
  153.       BattleManager.input_start
  154.       top_unit = OrderManager.top_unit
  155.       top_unit.battler.on_turn_start
  156.       refresh_status
  157.      
  158.       @log_window.display_auto_affected_status(top_unit.battler)
  159.       @log_window.wait_and_clear
  160.       next_command
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ● フレーム更新
  165.   #--------------------------------------------------------------------------
  166.   alias saba_kiseki_battle_update_basic update_basic
  167.   def update_basic
  168.     saba_kiseki_battle_update_basic
  169.     OrderManager.update
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● スキルウィンドウの作成
  173.   #--------------------------------------------------------------------------
  174.   alias saba_kiseki_battle_create_skill_window create_skill_window
  175.   def create_skill_window
  176.     saba_kiseki_battle_create_skill_window
  177.     @skill_window.set_handler(:change, method(:update_forecast))
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● アイテムウィンドウの作成
  181.   #--------------------------------------------------------------------------
  182.   alias saba_kiseki_battle_create_item_window create_item_window
  183.   def create_item_window
  184.     saba_kiseki_battle_create_item_window
  185.     @item_window.set_handler(:change, method(:update_forecast))
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● アクターコマンドウィンドウの作成
  189.   #--------------------------------------------------------------------------
  190.   alias saba_kiseki_battle_create_actor_command_window create_actor_command_window
  191.   def create_actor_command_window
  192.     saba_kiseki_battle_create_actor_command_window
  193.     @actor_command_window.set_handler(:change, method(:update_forecast))
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # ● アクターウィンドウの作成
  197.   #--------------------------------------------------------------------------
  198.   alias saba_kiseki_battle_create_actor_window create_actor_window
  199.   def create_actor_window
  200.     saba_kiseki_battle_create_actor_window
  201.     @actor_window.set_handler(:change, method(:update_selection))
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ● 敵キャラウィンドウの作成
  205.   #--------------------------------------------------------------------------
  206.   alias saba_kiseki_battle_create_enemy_window create_enemy_window
  207.   def create_enemy_window
  208.     saba_kiseki_battle_create_enemy_window
  209.     @enemy_window.set_handler(:change, method(:update_selection))
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ○ 選択状態の更新
  213.   #--------------------------------------------------------------------------
  214.   def update_selection
  215.     OrderManager.clear_selection
  216.     OrderManager.select(@enemy_window.enemy) if @enemy_window.active
  217.     OrderManager.select(@actor_window.actor) if @actor_window.active
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ○ 順番予測更新
  221.   #--------------------------------------------------------------------------
  222.   def update_forecast
  223.     OrderManager.clear_selection
  224.     actor = BattleManager.actor
  225.     case @actor_command_window.current_symbol
  226.       when :attack
  227.         item = $data_skills[actor.attack_skill_id]
  228.       when :guard
  229.         item = $data_skills[actor.guard_skill_id]
  230.       when :skill
  231.         item = @skill_window.item if @skill_window.visible
  232.       when :item
  233.         item = @item_window.item if @item_window.visible
  234.       when :escape
  235.         item = $data_skills[3]
  236.     end
  237.     return OrderManager.remove_forecast_unit if item == nil
  238.     update_forecast_item(item)
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ○ 指定のアイテムの順番予測更新
  242.   #--------------------------------------------------------------------------
  243.   def update_forecast_item(item)
  244.     battler = OrderManager.top_unit.battler
  245.     item = $data_skills[battler.attack_skill_id] if item == nil
  246.     operate_time = item.operate_time(battler)
  247.     unit = OrderManager.forecast_unit
  248.     return if unit && unit.battler == battler && unit.usable_item == item
  249.    
  250.     OrderManager.remove_forecast_unit
  251.    
  252.     if operate_time > 0 && ! OrderManager.top_unit.operate
  253.       if battler.state_operate_time == nil
  254.         OrderManager.insert(battler, operate_time, true, item, true)
  255.       else
  256.         OrderManager.insert(battler, battler.state_operate_time, true, item, true)
  257.       end
  258.       OrderManager.show_targeted(battler) if battler.enemy?
  259.     else
  260.       if battler.state_stiff_time == nil
  261.         stiff_time = item.stiff_time(battler)
  262.         OrderManager.insert(battler, stiff_time, true, item)
  263.       else
  264.         OrderManager.insert(battler, battler.state_stiff_time, true, item)
  265.       end
  266.     end
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● ターン開始
  270.   #--------------------------------------------------------------------------
  271.   alias saba_kiski_battle_turn_start turn_start
  272.   def turn_start
  273.     OrderManager.clear_selection
  274.     battler = OrderManager.top_unit.battler
  275.    
  276.     $game_troop.clear_results
  277.     $game_party.clear_results
  278.    
  279.     if battler.current_action != nil
  280.       item = battler.current_action.item
  281.       update_forecast_item(item)
  282.     else
  283.       update_forecast_item($data_skills[8])
  284.     end
  285.     saba_kiski_battle_turn_start
  286.     if item != nil && item.operate_time(battler) > 0 &&
  287.        OrderManager.top_unit.operate != true
  288.        play_operate_se
  289.        refresh_status
  290.       @log_window.display_prepare_item(battler, item)
  291.     end
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ○ 駆動SE再生
  295.   #--------------------------------------------------------------------------
  296.   def play_operate_se
  297.     Audio.se_play(OPERATE_SE_FILE, OPERATE_SE_VOLUME, OPERATE_SE_PITCH)
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● ターン終了
  301.   #--------------------------------------------------------------------------
  302.   def turn_end
  303.     all_battle_members.each do |battler|
  304.       battler.on_turn_end
  305.       if battler.result.status_affected?
  306.         refresh_status
  307.         @log_window.display_auto_affected_status(battler)
  308.         @log_window.wait_and_clear
  309.       end
  310.     end
  311.     BattleManager.turn_end
  312.     process_event
  313.     start_party_command_selection
  314.     calculate_battlers_speed
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● スキル/アイテムの使用
  318.   #--------------------------------------------------------------------------
  319.   alias saba_kiski_battle_use_item use_item
  320.   def use_item
  321.     saba_kiski_battle_use_item
  322.     return if @subject.current_action == nil
  323.     targets = @subject.current_action.make_targets.compact
  324.     targets.each do |target|
  325.       delay = target.result.delay_count
  326.       if delay != 0
  327.         OrderManager.delay_order(target, delay)
  328.         #@log_window.display_delay(target, delay)
  329.       end
  330.       unit = OrderManager.find_unit(target)
  331.       if unit && unit.cancel?
  332.         unit.battler.turn_count += 1
  333.         OrderManager.cancel(unit)
  334.       end
  335.     end
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● 戦闘行動終了時の処理
  339.   #--------------------------------------------------------------------------
  340.   alias saba_kiski_battle_process_action_end process_action_end
  341.   def process_action_end
  342.     OrderManager.update_delay_time
  343.     if BattleManager.battle_end?
  344.       OrderManager.remove_forecast_unit
  345.     end
  346.     saba_kiski_battle_process_action_end
  347.   end
  348. end
  349.  
  350. class Window_ActorCommand
  351.   def cancel_enabled?
  352.     return false
  353.   end
  354. end
  355.  
  356. class Spriteset_Battle
  357.   #--------------------------------------------------------------------------
  358.   # ● オブジェクト初期化
  359.   #--------------------------------------------------------------------------
  360.   alias saba_kiseki_battle_initialize initialize
  361.   def initialize
  362.     @battle_units = {}
  363.     saba_kiseki_battle_initialize
  364.     @viewport3.rect.height = Saba::Kiseki::ORDER_BAR_HEIGHT
  365.     @kiseki_sprite = Spriteset_Kiseki.new(@viewport3)
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● フレーム更新
  369.   #--------------------------------------------------------------------------
  370.   alias saba_kiseki_battle_update update
  371.   def update
  372.     saba_kiseki_battle_update
  373.     update_battle_unit
  374.     @kiseki_sprite.update if @kiseki_sprite
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ○ ユニット更新
  378.   #--------------------------------------------------------------------------
  379.   def update_battle_unit
  380.     remove_list = @battle_units.keys
  381.     OrderManager.units.each do |unit|
  382.       if @battle_units[unit] == nil
  383.         @battle_units[unit] = Spriteset_BattleUnit.new(@viewport3, unit)
  384.       else
  385.         remove_list.delete(unit)
  386.       end
  387.       @battle_units[unit].update
  388.     end
  389.     remove_list.each { |unit|
  390.       sprite = @battle_units[unit]
  391.       sprite.dispose
  392.       @battle_units.delete(unit)
  393.     }
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # ● 解放
  397.   #--------------------------------------------------------------------------
  398.   alias saba_kiseki_battle_dispose dispose
  399.   def dispose
  400.     @battle_units.values.each { |sprite| sprite.dispose }
  401.     @kiseki_sprite.dispose
  402.     saba_kiseki_battle_dispose
  403.   end
  404. end
  405.  
  406. class Window_Selectable
  407.   #--------------------------------------------------------------------------
  408.   # ● 項目の選択
  409.   #--------------------------------------------------------------------------
  410.   alias saba_kiseki_battle_select select
  411.   def select(index)
  412.     saba_kiseki_battle_select(index)
  413.     call_handler(:change)
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ● ウィンドウのアクティブ化
  417.   #--------------------------------------------------------------------------
  418.   def activate
  419.     super
  420.     call_handler(:change)
  421.     self
  422.   end
  423. end
  424.  
  425. class Game_ActionResult
  426.   #--------------------------------------------------------------------------
  427.   # ● 公開インスタンス変数
  428.   #--------------------------------------------------------------------------
  429.   attr_accessor :delay_count
  430.   attr_accessor :cancel
  431.   attr_accessor :fail_cancel
  432.   attr_accessor :anti_cancel
  433.   attr_accessor :fail_delay
  434.   attr_accessor :anti_delay
  435.   #--------------------------------------------------------------------------
  436.   # ● クリア
  437.   #--------------------------------------------------------------------------
  438.   alias saba_kiseki_battle_clear clear
  439.   def clear
  440.     saba_kiseki_battle_clear
  441.     @delay_count = 0
  442.     @cancel = false
  443.     @fail_cancel = false
  444.     @anti_cancel = false
  445.     @fail_delay = false
  446.     @anti_delay = false
  447.   end
  448. end
  449.  
  450. class Game_Battler
  451.   #--------------------------------------------------------------------------
  452.   # ● 公開インスタンス変数
  453.   #--------------------------------------------------------------------------
  454.   attr_accessor :spd
  455.   attr_accessor :turn_count
  456.   alias saba_kiseki_initialize initialize
  457.   def initialize
  458.     saba_kiseki_initialize
  459.     @spd = 50
  460.     @turn_count = 0
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ● スキル/アイテムの効果適用
  464.   #--------------------------------------------------------------------------
  465.   alias saba_kiseki_battle_item_apply item_apply
  466.   def item_apply(user, item)
  467.     saba_kiseki_battle_item_apply(user, item)
  468.     return unless $game_party.in_battle
  469.     if @result.hit?
  470.      
  471.       if user.actor? && item.is_a?(RPG::Skill) && item.id == 1
  472.         # 通常攻撃
  473.         total = 0
  474.         cancel = false
  475.         cancel_attack = false
  476.         delay_attack = false
  477.        
  478.         user.weapons.each do |weapon|
  479.           total += weapon.delay_count(user)
  480.           delay_attack |= weapon.delay_attack?
  481.           cancel |= weapon.cancel?
  482.           cancel_attack |= weapon.cancel_attack?
  483.         end
  484.         @result.delay_count = total
  485.         @result.cancel = cancel
  486.       else
  487.         @result.delay_count = item.delay_count(user)
  488.         delay_attack = item.delay_attack?
  489.         @result.cancel = item.cancel?
  490.         cancel_attack = item.cancel_attack?
  491.       end
  492.       char = actor? ? actor : enemy
  493.       @result.delay_count = 0 if char.anti_delay?
  494.       if @result.delay_count > 0
  495.         @result.delay_count = [@result.delay_count, OrderManager.max_delay_count(self)].min
  496.       elsif @result.delay_count < 0
  497.         @result.delay_count = [@result.delay_count, OrderManager.min_delay_count(self)].max
  498.       elsif delay_attack
  499.         if char.anti_delay?
  500.           @result.anti_delay = true
  501.         else
  502.           @result.fail_delay = true
  503.         end
  504.       end
  505.      
  506.       unit = OrderManager.find_unit(self)
  507.  
  508.       if unit && unit.operate
  509.         # 行動不能によるキャンセルチェック
  510.         if ! self.movable? || self.confusion?
  511.           @result.cancel = true
  512.         elsif char.anti_cancel? || unit.usable_item.anti_cancel?
  513.           # キャンセルが無効化された
  514.           @result.anti_cancel = true if cancel_attack
  515.           @result.cancel = false
  516.         elsif cancel_attack && ! @result.cancel
  517.           # キャンセル失敗
  518.           @result.fail_cancel = true
  519.           @result.cancel = false
  520.         end
  521.        
  522.       else
  523.         # もともと準備中でない
  524.         @result.cancel = false
  525.       end
  526.      
  527.      
  528.       if self.dead?
  529.         @result.anti_delay = false
  530.         @result.fail_delay = false
  531.         @result.delay_count = 0
  532.         @result.cancel = false
  533.         @result.anti_cancel = false
  534.         @result.fail_cancel = false
  535.       end
  536.      
  537.       @result.success = true if @result.delay_count != 0 || @result.cancel
  538.     end
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # ○ ターン開始処理
  542.   #--------------------------------------------------------------------------
  543.   def on_turn_start
  544.     regenerate_all
  545.     update_state_turns
  546.     update_buff_turns
  547.     remove_states_auto(2)
  548.     remove_buffs_auto
  549.     make_actions
  550.   end
  551.   #--------------------------------------------------------------------------
  552.   # ● ターン終了処理
  553.   #--------------------------------------------------------------------------
  554.   def on_turn_end
  555.     @result.clear
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # ● 戦闘行動終了時の処理
  559.   #--------------------------------------------------------------------------
  560.   def on_action_end
  561.     @result.clear
  562.     remove_states_auto(1)
  563.     @turn_count += 1
  564.   end
  565.   #--------------------------------------------------------------------------
  566.   # ○ ステートによる駆動時間を取得
  567.   #--------------------------------------------------------------------------
  568.   def state_operate_time
  569.     n = nil
  570.     states.reverse.each do |state|
  571.       if state.operate_formula
  572.         n = state.operate_time(self)
  573.       end
  574.     end
  575.     return n
  576.   end
  577.   #--------------------------------------------------------------------------
  578.   # ○ ステートによる硬直時間を取得
  579.   #--------------------------------------------------------------------------
  580.   def state_stiff_time
  581.     n = nil
  582.     states.reverse.each do |state|
  583.       if state.stiff_formula
  584.         n = state.stiff_time(self)
  585.       end
  586.     end
  587.     return n
  588.   end
  589. end
  590.  
  591. class << BattleManager
  592.   #--------------------------------------------------------------------------
  593.   # ● 次のコマンド入力へ
  594.   #--------------------------------------------------------------------------
  595.   def next_command
  596.     begin
  597.       if !actor || !actor.next_command
  598.         battler = OrderManager.top_unit.battler
  599.         unless battler.actor?
  600.           unless battler.current_action
  601.             OrderManager.top_unit.usable_item = $data_skills[1]
  602.             return false
  603.           end
  604.           OrderManager.top_unit.usable_item = battler.current_action.item
  605.           return false
  606.         end
  607.         return false if @actor_index == battler.index
  608.         @actor_index = battler.index
  609.         if OrderManager.top_unit.operate  # 発動
  610.           OrderManager.top_unit.remove_operate_state
  611.           battler.current_action.set_usable_item(OrderManager.top_unit.usable_item)
  612.           return false
  613.         end
  614.         return false if @actor_index >= $game_party.members.size
  615.       end
  616.     end until actor.inputable?
  617.     return true
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 行動順序の作成
  621.   #--------------------------------------------------------------------------
  622.   def make_action_orders
  623.     battler = OrderManager.top_unit.battler
  624.     if battler.current_action == nil || battler.current_action.item == nil
  625.       @action_battlers = [battler]
  626.     elsif battler.current_action.item.operate_time(battler) > 0 &&
  627.        OrderManager.top_unit.operate != true
  628.       # 発動待ち
  629.       OrderManager.top_unit.usable_item = battler.current_action.item
  630.       OrderManager.top_unit.add_operate_state
  631.       @action_battlers = []
  632.     else
  633.       @action_battlers = [battler]
  634.     end
  635.   end
  636.   #--------------------------------------------------------------------------
  637.   # ● ターン終了
  638.   #--------------------------------------------------------------------------
  639.   alias saba_kiseki_battle_turn_end turn_end
  640.   def turn_end
  641.     saba_kiseki_battle_turn_end
  642.     unit = OrderManager.top_unit
  643.     OrderManager.clear_forecast
  644.     OrderManager.update_top
  645.   end
  646. end
  647.  
  648.  
  649. class Game_Enemy
  650.   #--------------------------------------------------------------------------
  651.   # ● 戦闘行動の作成
  652.   #--------------------------------------------------------------------------
  653.   alias saba_kiseki_battke_make_actions make_actions
  654.   def make_actions
  655.     # 発動待ちを上書きしないように
  656.     unit = OrderManager.find_unit(self)
  657.     if unit && unit.operate
  658.       return
  659.     end
  660.     saba_kiseki_battke_make_actions
  661.   end
  662.   #--------------------------------------------------------------------------
  663.   # ● 行動条件合致判定[ターン数]
  664.   #--------------------------------------------------------------------------
  665.   def conditions_met_turns?(param1, param2)
  666.     n = @turn_count
  667.     #p name + " " + @turn_count.to_s
  668.     if param2 == 0
  669.       n == param1
  670.     else
  671.       n > 0 && n >= param1 && n % param2 == param1 % param2
  672.     end
  673.   end
  674. end
  675.  
  676. class Game_Actor
  677.   #--------------------------------------------------------------------------
  678.   # ● 戦闘行動の作成
  679.   #--------------------------------------------------------------------------
  680.   alias saba_kiseki_battke_make_actions make_actions
  681.   def make_actions
  682.     # 発動待ちを上書きしないように
  683.     unit = OrderManager.find_unit(self)
  684.     if unit && unit.operate
  685.       return
  686.     end
  687.     saba_kiseki_battke_make_actions
  688.   end
  689. end
  690.  
  691.  
  692. class Window_BattleActor
  693.   #--------------------------------------------------------------------------
  694.   # ○ 味方キャラオブジェクト取得
  695.   #--------------------------------------------------------------------------
  696.   def actor
  697.     $game_party.battle_members[@index]
  698.   end
  699. end
  700.  
  701. class << BattleManager
  702.   attr_reader :preemptive
  703.   attr_reader :surprise
  704.   attr_reader :phase
  705.   def battle_end?
  706.     return true if $game_party.members.empty?
  707.     return true if $game_party.all_dead?
  708.     return true if $game_troop.all_dead?
  709.     return true if aborting?
  710.     return false
  711.   end
  712. end
  713.  
  714. class Game_Action
  715.   #--------------------------------------------------------------------------
  716.   # ● 公開インスタンス変数
  717.   #--------------------------------------------------------------------------
  718.   attr_accessor :targets
  719.   attr_accessor :save_targets
  720.   #--------------------------------------------------------------------------
  721.   # ● クリア
  722.   #--------------------------------------------------------------------------
  723.   alias saba_kiseki_battle_clear clear
  724.   def clear
  725.     saba_kiseki_battle_clear
  726.     @targets = nil
  727.     save_targets = false
  728.   end
  729.   #--------------------------------------------------------------------------
  730.   # ● ターゲットの配列作成
  731.   #--------------------------------------------------------------------------
  732.   alias saba_kiseki_battle_make_targets make_targets
  733.   def make_targets
  734.     return @targets if @targets && @save_targets
  735.     @targets = saba_kiseki_battle_make_targets
  736.     return @targets
  737.   end
  738.   #--------------------------------------------------------------------------
  739.   # ● アイテムを設定
  740.   #--------------------------------------------------------------------------
  741.   def set_usable_item(item)
  742.     @item.object = item
  743.     self
  744.   end
  745. end
  746.  
  747. #==============================================================================
  748. # ■ Game_BattleUnit
  749. #------------------------------------------------------------------------------
  750. #  画面上に表示されるコマです。
  751. #==============================================================================
  752. class Game_BattleUnit
  753.   attr_accessor :battler
  754.   attr_accessor :forecast
  755.   attr_accessor :usable_item
  756.   attr_accessor :operate
  757.   attr_accessor :delay_time           # 待ち時間
  758.   attr_accessor :delay_time_decimal   # 待ち時間の小数
  759.   attr_accessor :x
  760.   attr_accessor :dest_y
  761.   attr_accessor :selected
  762.   attr_accessor :targeted
  763.   attr_reader :y
  764.   #--------------------------------------------------------------------------
  765.   # ○ オブジェクトを初期化します。
  766.   #  init_battler このユニットが表すバトラーオブジェクト
  767.   #  delay_time 行動までの待ち時間
  768.   #  forecast 行動の予想ユニットかどうかのフラグ
  769.   #  skill スキルの発動待ちかどうかのフラグ
  770.   #--------------------------------------------------------------------------
  771.   def initialize(battler, delay_time, forecast = false, usable_item = nil, operate = false)
  772.     @battler = battler
  773.     @delay_time = delay_time
  774.     @usable_item = usable_item
  775.     @forecast = forecast
  776.     @operate = operate
  777.     @dest_x = 0
  778.     @dest_y = 0
  779.     @speed_y = 1
  780.     @delay_time_decimal = 0
  781.     @x = @dest_x
  782.     @y = 0
  783.     @targeted = false
  784.     @selected = false
  785.   end
  786.   #--------------------------------------------------------------------------
  787.   # ○ 座標を更新
  788.   #--------------------------------------------------------------------------
  789.   def update
  790.     update_x
  791.     update_y
  792.   end
  793.   #--------------------------------------------------------------------------
  794.   # ○ x 座標を更新
  795.   #--------------------------------------------------------------------------
  796.   def update_x
  797.     @x = @dest_x if (@dest_x - @x).abs < 4
  798.     @x += 4 if @dest_x > @x
  799.     @x -= 4 if @dest_x < @x
  800.   end
  801.   #--------------------------------------------------------------------------
  802.   # ○ y 座標を更新
  803.   #--------------------------------------------------------------------------
  804.   def update_y
  805.     if (@dest_y - @y).abs < 3
  806.       @y = @dest_y
  807.       @speed_y = 1
  808.     else
  809.       @speed_y = 3
  810.     end
  811.     @y += @speed_y if @dest_y > @y
  812.     @y -= @speed_y if @dest_y < @y
  813.   end
  814.   #--------------------------------------------------------------------------
  815.   # ○ キャンセル
  816.   #--------------------------------------------------------------------------
  817.   def cancel
  818.     if @operate && @usable_item
  819.       @operate = false
  820.       remove_operate_state
  821.       return true
  822.     else
  823.       return false
  824.     end
  825.   end
  826.   #--------------------------------------------------------------------------
  827.   # ○ キャンセルチェック
  828.   #--------------------------------------------------------------------------
  829.   def cancel?
  830.     return @battler.result.cancel
  831.   end
  832.   #--------------------------------------------------------------------------
  833.   # ○ 他のユニットと待ち時間を比較するための値を返します。
  834.   #    他のユニット同一の値だと、ソート時に順番が入れ替わるおそれがあるので、
  835.   #    バトラー別に補正を掛けます。
  836.   #--------------------------------------------------------------------------
  837.   def delay_time_compare
  838.     return -1 if @delay_time == 0 && @forecast #即時効果
  839.     return @delay_time * 10000 + delay_time_decimal
  840.   end
  841.   def delay_time_decimal
  842.     return 4999 if @forecast
  843.     return @delay_time_decimal
  844.   end
  845.   #--------------------------------------------------------------------------
  846.   # ○ 待ち時間を設定
  847.   #--------------------------------------------------------------------------
  848.   def delay_time=(value)
  849.     @delay_time = value.round
  850.   end
  851.   #--------------------------------------------------------------------------
  852.   # ○ 順番を設定
  853.   #--------------------------------------------------------------------------
  854.   def index=(arg)
  855.     @index = arg
  856.     @dest_y = arg * Saba::Kiseki::UNIT_INTERVAL
  857.     @dest_y += Saba::Kiseki::MARGIN_CURRENT_BOTTOM if @index > 0
  858.     init_position if @x != 0
  859.   end
  860.   #--------------------------------------------------------------------------
  861.   # ○ 座標を初期化
  862.   #--------------------------------------------------------------------------
  863.   def init_position
  864.     @y = @dest_y
  865.   end
  866.   #--------------------------------------------------------------------------
  867.   # ○ 待ち時間に自動でかかるステートを設定
  868.   #--------------------------------------------------------------------------
  869.   def add_operate_state
  870.     @usable_item.operate_states.each {|s|
  871.       operate_state_targets.each { |b|
  872.         b.add_state(s)
  873.       }
  874.     }
  875.   end
  876.   #--------------------------------------------------------------------------
  877.   # ○ 待ち時間に自動でかかるステートを削除
  878.   #--------------------------------------------------------------------------
  879.   def remove_operate_state
  880.     @usable_item.operate_states.each {|s|
  881.       operate_state_targets.each { |b|
  882.         b.remove_state(s)
  883.       }
  884.     }
  885.   end
  886.   #--------------------------------------------------------------------------
  887.   # ○ 待ち時間に自動でかかるステート対象を取得
  888.   #--------------------------------------------------------------------------
  889.   def operate_state_targets
  890.     targets = []
  891.     if @usable_item.operate_states_for_friends_all?
  892.       targets += @battler.friends_unit.alive_members
  893.     end
  894.     if @usable_item.operate_states_for_opponents_all?
  895.       targets += @battler.opponents_unit.alive_members
  896.     end
  897.     targets = [@battler] if targets.empty?
  898.     return targets
  899.   end
  900.   #--------------------------------------------------------------------------
  901.   # ○ 攻撃対象を取得
  902.   #--------------------------------------------------------------------------
  903.   def targets
  904.     return [] unless @operate
  905.     battler.current_action.save_targets = true
  906.     battler.current_action.make_targets
  907.   end
  908. end
  909.  
  910. class RPG::BaseItem
  911.   #--------------------------------------------------------------------------
  912.   # ○ 駆動時間の取得
  913.   #--------------------------------------------------------------------------
  914.   def operate_time(battler)
  915.     operate_formula
  916.     return 0 if @operate_formula == nil
  917.     a = battler
  918.     c = $game_variables
  919.     return eval(@operate_formula).to_i
  920.   end
  921.   #--------------------------------------------------------------------------
  922.   # ○ 駆動時間計算式の取得
  923.   #--------------------------------------------------------------------------
  924.   def operate_formula
  925.     return @operate_formula if @get_operate_formula
  926.     @get_operate_formula = true
  927.     self.note.split(/[\r\n]+/).each do |line|
  928.       if line.index("<charge>") == 0
  929.         @operate_formula = line["<charge>".length..-1]
  930.         return @operate_formula
  931.       end
  932.     end
  933.     return nil if self.is_a?(RPG::State)
  934.     @operate_formula = $data_skills[1].operate_formula
  935.   end
  936.   #--------------------------------------------------------------------------
  937.   # ○ 硬直時間の取得
  938.   #--------------------------------------------------------------------------
  939.   def stiff_time(battler)
  940.     stiff_formula
  941.     return 0 if @stiff_formula == nil
  942.     a = battler
  943.     c = $game_variables
  944.     return eval(@stiff_formula)
  945.   end
  946.   #--------------------------------------------------------------------------
  947.   # ○ 硬直時間計算式の取得
  948.   #--------------------------------------------------------------------------
  949.   def stiff_formula
  950.     return @stiff_formula if @get_stiff_formula
  951.     @get_stiff_formula = true
  952.     self.note.split(/[\r\n]+/).each do |line|
  953.       if line.index("<delay>") == 0
  954.         @stiff_formula = line["<delay>".length..-1]
  955.         return @stiff_formula
  956.       end
  957.     end
  958.     return nil if self.is_a?(RPG::State)
  959.     @stiff_formula = $data_skills[1].stiff_formula
  960.   end
  961.   #--------------------------------------------------------------------------
  962.   # ○ ディレイ攻撃か?
  963.   #--------------------------------------------------------------------------
  964.   def delay_attack?
  965.     return delay_formula != nil
  966.   end
  967.   #--------------------------------------------------------------------------
  968.   # ○ ディレイ値の取得
  969.   #--------------------------------------------------------------------------
  970.   def delay_count(battler)
  971.     delay_formula
  972.     return 0 if @delay_formula == nil
  973.     a = battler
  974.     c = $game_variables
  975.     ret = eval(@delay_formula)
  976.     ret = 0 if rand(100)+1 > delay_percent(battler)
  977.     return ret
  978.   end
  979.   #--------------------------------------------------------------------------
  980.   # ○ ディレイ値計算式の取得
  981.   #--------------------------------------------------------------------------
  982.   def delay_formula
  983.     return @delay_formula if @get_delay_formula
  984.     @get_delay_formula = true
  985.     self.note.split(/[\r\n]+/).each do |line|
  986.       if line.index("<slow>") == 0
  987.         @delay_formula = line["<slow>".length..-1]
  988.         return @delay_formula
  989.       end
  990.       if line.index("<slow>") == 0
  991.         @delay_formula = line["<slow>".length..-1]
  992.         return @delay_formula
  993.       end
  994.     end
  995.     @delay_formula = $data_skills[1].delay_formula
  996.     return @delay_formula
  997.   end
  998.   #--------------------------------------------------------------------------
  999.   # ○ ディレイ率の取得
  1000.   #--------------------------------------------------------------------------
  1001.   def delay_percent(battler)
  1002.     delay_percent_formula
  1003.     return 100 if @delay_percent_formula == nil
  1004.     a = battler
  1005.     c = $game_variables
  1006.     return eval(@delay_percent_formula)
  1007.   end
  1008.   #--------------------------------------------------------------------------
  1009.   # ○ ディレイ率計算式の取得
  1010.   #--------------------------------------------------------------------------
  1011.   def delay_percent_formula
  1012.     return @delay_percent_formula if @get_delay_percent_formula
  1013.     @get_delay_percent_formula = true
  1014.     self.note.split(/[\r\n]+/).each do |line|
  1015.       if line.index("<slowrate>") == 0
  1016.         @delay_percent_formula = line["<slowrate>".length..-1]
  1017.         return @delay_percent_formula
  1018.       end
  1019.     end
  1020.     return @delay_percent_formula
  1021.   end
  1022.   #--------------------------------------------------------------------------
  1023.   # ○ キャンセル攻撃か?
  1024.   #--------------------------------------------------------------------------
  1025.   def cancel_attack?
  1026.     return note.include?("<cancel>")
  1027.   end
  1028.   #--------------------------------------------------------------------------
  1029.   # ○ キャンセル攻撃発動か?
  1030.   #--------------------------------------------------------------------------
  1031.   def cancel?
  1032.     return false if rand(100)+1 >= cancel_percent
  1033.     return cancel_attack?
  1034.   end
  1035.   #--------------------------------------------------------------------------
  1036.   # ○ キャンセル率の取得
  1037.   #--------------------------------------------------------------------------
  1038.   def cancel_percent
  1039.     cancel_percent_formula
  1040.     return 100 if @cancel_percent_formula == nil
  1041.     c = $game_variables
  1042.     return eval(@cancel_percent_formula)
  1043.   end
  1044.   #--------------------------------------------------------------------------
  1045.   # ○ キャンセル率計算式の取得
  1046.   #--------------------------------------------------------------------------
  1047.   def cancel_percent_formula
  1048.     return @cancel_percent_formula if @get_cancel_percent_formula
  1049.     @get_cancel_percent_formula = true
  1050.     self.note.split(/[\r\n]+/).each do |line|
  1051.       if line.index("<cancelrate>") == 0
  1052.         @cancel_percent_formula = line["<cancelrate>".length..-1]
  1053.         return @cancel_percent_formula
  1054.       end
  1055.     end
  1056.     return @cancel_percent_formula
  1057.   end
  1058.   #--------------------------------------------------------------------------
  1059.   # ○ ディレイ無効か?
  1060.   #--------------------------------------------------------------------------
  1061.   def anti_delay?
  1062.     return note.include?("<noslow>")
  1063.   end
  1064.   #--------------------------------------------------------------------------
  1065.   # ○ キャンセル不可か?
  1066.   #--------------------------------------------------------------------------
  1067.   def anti_cancel?
  1068.     return note.include?("<nocancel>")
  1069.   end
  1070.   #--------------------------------------------------------------------------
  1071.   # ○ 駆動待ちに自動でかかるステートリスト取得
  1072.   #--------------------------------------------------------------------------
  1073.   def operate_states
  1074.     return @operate_states if @operate_states
  1075.     self.note.split(/[\r\n]+/).each do |line|
  1076.       if line.index("<state>") == 0
  1077.         @operate_states = line["<state>".length..-1].split(",").collect { |s| s.to_i }
  1078.         return @operate_states
  1079.       end
  1080.     end
  1081.     @operate_states = []
  1082.     return @operate_states
  1083.   end
  1084.   #--------------------------------------------------------------------------
  1085.   # ○ 駆動待ちに自動でかかるステート対象が味方全体を含むか?
  1086.   #--------------------------------------------------------------------------
  1087.   def operate_states_for_opponents_all?
  1088.     self.note.split(/[\r\n]+/).each do |line|
  1089.       if line.index("<statescope>") == 0
  1090.         return line.include?("allenemies")
  1091.       end
  1092.     end
  1093.     return false
  1094.   end
  1095.   #--------------------------------------------------------------------------
  1096.   # ○ 駆動待ちに自動でかかるステート対象が敵全体を含むか?
  1097.   #--------------------------------------------------------------------------
  1098.   def operate_states_for_friends_all?
  1099.     self.note.split(/[\r\n]+/).each do |line|
  1100.       if line.index("<statescope>") == 0
  1101.         return line.include?("allallies")
  1102.       end
  1103.     end
  1104.     return false
  1105.   end
  1106.   #--------------------------------------------------------------------------
  1107.   # ○ スキル準備メッセージ取得
  1108.   #--------------------------------------------------------------------------
  1109.   def prepare_msg
  1110.     return @prepare_msg if @prepare_msg
  1111.     self.note.split(/[\r\n]+/).each do |line|
  1112.       if line.index("<chargemsg>") == 0
  1113.         @prepare_msg = line["<chargemsg>".length..-1]
  1114.         return @prepare_msg
  1115.       end
  1116.     end
  1117.     @prepare_msg = Saba::Kiseki::DEFAULT_PREPARE_MSG
  1118.     return @prepare_msg
  1119.   end
  1120. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top