SHARE
TWEET

Ao no Kiseki CBS 6

kirinelf Apr 2nd, 2012 1,009 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2.       ★ Ao no Kiseki Custom Battle System - AT Bonus Plugin - ★
  3.  
  4.       Adds AT bonuses to the Ao no Kiseki Custom Battle System.
  5.       Please place the Bonus graphics in the Graphics/System folder.
  6.      
  7.       ● Bonuses ●======================================================
  8.       There are nine possible bonuses, randomly selected. They are:
  9.          
  10.       --------------------------------------------------------------------
  11.       Recover 10% HP at start of turn.
  12.       --------------------------------------------------------------------
  13.       Recover 50% HP at start of turn.
  14.       --------------------------------------------------------------------
  15.       Recover 10% MP at start of turn.
  16.       --------------------------------------------------------------------
  17.       Recover 50% MP at start of turn.
  18.       --------------------------------------------------------------------
  19.       Recover 10% TP at start of turn.
  20.       --------------------------------------------------------------------
  21.       Recover 50% TP at start of turn.
  22.       --------------------------------------------------------------------
  23.       Critical (All damage/healing effectiveness is multipled by 1.5)
  24.       --------------------------------------------------------------------
  25.       Perfect Guard (Cannot be damaged, Cannot be healed, No Cancel, State Immunity, No Slow)
  26.       --------------------------------------------------------------------
  27.       Rush (Act twice in a row)
  28.       ====================================================================
  29.      
  30.       ● Note ●========================================================
  31.       This script was developed for the Ao no Kiseki Custom Battle System.
  32.       Please contact PetitCure or Saba Kan for any queries regarding the system.
  33.       ====================================================================
  34.      
  35.       ※ The Ao no Kiseki Custom Battle System is still a work in progress.
  36.           Therefore, this script may change or become obselete in the future.
  37.      
  38.       ver0.11
  39.      
  40.       Last Update : 2012/01/24
  41.       01/24 : Added Critical Bonus text.
  42.       01/07 : Released to the public.
  43.      
  44.       Made for Saba Kan of http://petitrare.com/blog/
  45.       Written by Rokan of http://kaisou-ryouiki.sakura.ne.jp/
  46.           Translated by kirinelf
  47. =end
  48.  
  49. #===================================
  50. #  ● Configuration Block
  51. #===================================
  52. module Rokan
  53. module Kiseki_Plugin
  54.   # The variable that determines the rate of activation of the bonuses.
  55.   BCV = 10
  56.  
  57.   #-----------------------------------------------------------------------------
  58.   # The following section determines the activate rate of the bonuses.
  59.   # If 0, that bonus will not activate. All rates are relative to each other.
  60.   # Actual rate = (Rate)/(Total Rate)*100
  61.   #
  62.   # (For example. At BOP=0, there's a roughly 77% chance of there being no bonuses,
  63.   #  about 4% chances of there being 10% heals of HP, MP and TP, and about 1.5%
  64.   # chances of Critical, Perfect Guard and Rush) (Total rate = 130, sum of all rates)
  65.   #-----------------------------------------------------------------------------
  66.   # Variable Value =>
  67.   #   [No Bonus, 10% HP, 50% HP, 10% MP, 50% MP,
  68.   #                       10 TP, 50 TP, Critical, Perfect Guard, Rush],
  69.   #-----------------------------------------------------------------------------
  70.   BOP = { # No touchie.
  71.  
  72.     -1 => [  1,  0,  0,  0,  0,  0,  0,  0,  0,  0],
  73.      0 => [100,  5,  3,  5,  3,  5,  3,  2,  2,  2],
  74.      1 => [ 90,  3,  0,  3,  0,  3,  0,  2,  0,  0],
  75.      
  76.      } # Do not remove this.
  77.  
  78.   # Text that shows up when you get a critical bonus.
  79.   CriticalBonusText = "Critical Bonus!"
  80. end
  81. end
  82.  
  83. #=========================================================================
  84. # Do not edit anything under this line unless you know what you're doing!
  85. #=========================================================================
  86.  
  87. $rsi ||= {}
  88. $rsi["空の軌跡_ATボーナス"] = true
  89.  
  90. class RPG::UsableItem
  91.   #--------------------------------------------------------------------------
  92.   # ● 駆動時間の取得
  93.   #--------------------------------------------------------------------------
  94.   alias _kiseki_bonus_operate_time operate_time
  95.   def operate_time(battler)
  96.     if BonusManager.rash?
  97.       0
  98.     else
  99.       _kiseki_bonus_operate_time(battler)
  100.     end
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 硬直時間の取得
  104.   #--------------------------------------------------------------------------
  105.   alias _kiseki_bonus_stiff_time stiff_time
  106.   def stiff_time(battler)
  107.     if BonusManager.rash?
  108.       0
  109.     else
  110.       _kiseki_bonus_stiff_time(battler)
  111.     end
  112.   end
  113. end
  114.  
  115. class << BattleManager
  116.   #--------------------------------------------------------------------------
  117.   # ● セットアップ
  118.   #--------------------------------------------------------------------------
  119.   alias _kiseki_bonus_setup setup
  120.   def setup(troop_id, can_escape = true, can_lose = false)
  121.     _kiseki_bonus_setup(troop_id, can_escape, can_lose)
  122.     setup_bonus
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● ボーナスのセットアップ
  126.   #--------------------------------------------------------------------------
  127.   def setup_bonus
  128.     BonusManager.clear
  129.     BonusManager.init_bonus
  130.   end
  131. end
  132.  
  133. class << OrderManager
  134.   #--------------------------------------------------------------------------
  135.   # ● 先頭ユニットを削除し、次のユニットに入れ替えます。
  136.   #--------------------------------------------------------------------------
  137.   alias _kiseki_bonus_update_top update_top
  138.   def update_top
  139.     BonusManager.next_bonus
  140.     _kiseki_bonus_update_top
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 指定のバトラーの順番を遅らせる。
  144.   #--------------------------------------------------------------------------
  145.   alias _kiseki_bonus_delay_order delay_order
  146.   def delay_order(battler, value)
  147.     _kiseki_bonus_delay_order(battler, value) unless BonusManager.full_guard?
  148.   end
  149. end
  150.  
  151. module BonusManager
  152.   module_function
  153.   include Rokan::Kiseki_Plugin
  154.   #--------------------------------------------------------------------------
  155.   # ● オブジェクト初期化
  156.   #--------------------------------------------------------------------------
  157.   def init_manager
  158.     @rate_list = []
  159.     @bonus_list = []
  160.     clear
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● クリア
  164.   #--------------------------------------------------------------------------
  165.   def clear
  166.     @rate_list.clear
  167.     @bonus_list.clear
  168.     @sprites_listener = nil
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● クリティカル判定
  172.   #--------------------------------------------------------------------------
  173.   def critical?
  174.     get_bonus == 6 && $game_party.in_battle
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # ● 完全防御判定
  178.   #--------------------------------------------------------------------------
  179.   def full_guard?
  180.     get_bonus == 7 && $game_party.in_battle
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ● ラッシュ判定
  184.   #--------------------------------------------------------------------------
  185.   def rash?
  186.     get_bonus == 8
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● アクティブなボーナスの取得
  190.   #--------------------------------------------------------------------------
  191.   def get_bonus
  192.     @bonus_list[1]
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● インデックスを指定したボーナスの取得
  196.   #--------------------------------------------------------------------------
  197.   def get_bonus_with_index(index)
  198.     @bonus_list[index]
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 新たに追加するボーナスの取得
  202.   #--------------------------------------------------------------------------
  203.   def get_pop_bonus
  204.     case rand(@rate_list[9].last)
  205.     when @rate_list[0]; -1
  206.     when @rate_list[1];  0
  207.     when @rate_list[2];  1
  208.     when @rate_list[3];  2
  209.     when @rate_list[4];  3
  210.     when @rate_list[5];  4
  211.     when @rate_list[6];  5
  212.     when @rate_list[7];  6
  213.     when @rate_list[8];  7
  214.     when @rate_list[9];  8
  215.     else; -1
  216.     end
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● ボーナスの初期化
  220.   #--------------------------------------------------------------------------
  221.   def init_bonus
  222.     init_bonus_rate
  223.     @bonus_list.clear
  224.     10.times{@bonus_list << get_pop_bonus}
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ● ボーナス発生確率の初期化
  228.   #--------------------------------------------------------------------------
  229.   def init_bonus_rate
  230.     @rate_list.clear
  231.     first = last = 0
  232.     BOP[$game_variables[BCV]].each_with_index{|value, index|
  233.       last += value unless value.zero?
  234.       @rate_list << Range.new(first, last)
  235.       first = last
  236.     }
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● ボーナスを進める
  240.   #--------------------------------------------------------------------------
  241.   def next_bonus
  242.     @bonus_list.shift
  243.     @bonus_list << get_pop_bonus
  244.     @sprites_listener.next_bonus if @sprites_listener
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ● ボーナススプライトを可視化する
  248.   #--------------------------------------------------------------------------
  249.   def sprites_listener=(obj)
  250.     @sprites_listener = obj
  251.   end
  252. end
  253. BonusManager.init_manager
  254.  
  255. class Game_ActionResult
  256.   #--------------------------------------------------------------------------
  257.   # ● ダメージ値のクリティカル補正
  258.   #--------------------------------------------------------------------------
  259.   def critical_damage_values
  260.     @hp_damage = (@hp_damage * 1.5).to_i
  261.     @mp_damage = (@mp_damage * 1.5).to_i
  262.     @hp_drain = (@hp_drain * 1.5).to_i
  263.     @mp_drain = (@mp_drain * 1.5).to_i
  264.   end
  265. end
  266.  
  267. class Game_Battler
  268.   #--------------------------------------------------------------------------
  269.   # ● ダメージの処理
  270.   #--------------------------------------------------------------------------
  271.   alias _kiseki_bonus_execute_damage execute_damage
  272.   def execute_damage(user)
  273.     if BonusManager.critical?
  274.       @result.critical_damage_values
  275.     elsif BonusManager.full_guard?
  276.       @result.clear_damage_values
  277.       @result.cancel = false
  278.     end
  279.     _kiseki_bonus_execute_damage(user)
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # ● 使用効果[HP 回復] ※再定義
  283.   #--------------------------------------------------------------------------
  284.   def item_effect_recover_hp(user, item, effect)
  285.     value = (mhp * effect.value1 + effect.value2) * rec
  286.     value *= user.pha if item.is_a?(RPG::Item)
  287.     value *= 1.5 if BonusManager.critical? # 追加
  288.     value = value.to_i
  289.     @result.hp_damage -= value
  290.     @result.success = true
  291.     self.hp += value
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● 使用効果[MP 回復] ※再定義
  295.   #--------------------------------------------------------------------------
  296.   def item_effect_recover_mp(user, item, effect)
  297.     value = (mmp * effect.value1 + effect.value2) * rec
  298.     value *= user.pha if item.is_a?(RPG::Item)
  299.     value *= 1.5 if BonusManager.critical? # 追加
  300.     value = value.to_i
  301.     @result.mp_damage -= value
  302.     @result.success = true if value != 0
  303.     self.mp += value
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● 使用効果[TP 増加] ※再定義
  307.   #--------------------------------------------------------------------------
  308.   def item_effect_gain_tp(user, item, effect)
  309.     value = effect.value1.to_i
  310.     value *= 1.5 if BonusManager.critical? # 追加
  311.     @result.tp_damage -= value
  312.     @result.success = true if value != 0
  313.     self.tp += value
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● ステートの付加可能判定
  317.   #--------------------------------------------------------------------------
  318.   alias _kiseki_bonus_state_addable? state_addable?
  319.   def state_addable?(state_id)
  320.     _kiseki_bonus_state_addable?(state_id) && !BonusManager.full_guard?
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● 使用効果[ステート解除]
  324.   #--------------------------------------------------------------------------
  325.   alias _kiseki_bonus_item_effect_remove_state item_effect_remove_state
  326.   def item_effect_remove_state(user, item, effect)
  327.     _kiseki_bonus_item_effect_remove_state(user, item, effect) unless BonusManager.full_guard?
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   # ● ボーナスによる回復適用
  331.   #--------------------------------------------------------------------------
  332.   def bonus_recover_effect
  333.     @result.clear
  334.     @result.used = (0..5).include?(BonusManager.get_bonus)
  335.     case BonusManager.get_bonus
  336.     when 0
  337.       self.hp -= @result.hp_damage = -(mhp * 0.1).to_i
  338.     when 1
  339.       self.hp -= @result.hp_damage = -(mhp * 0.5).to_i
  340.     when 2
  341.       self.mp -= @result.mp_damage = -(mmp * 0.1).to_i
  342.     when 3
  343.       self.mp -= @result.mp_damage = -(mmp * 0.5).to_i
  344.     when 4
  345.       self.tp -= @result.tp_damage = -10
  346.     when 5
  347.       self.tp -= @result.tp_damage = -50
  348.     end
  349.   end
  350. end
  351.  
  352. class Bonus < Sprite
  353.   include Saba::Kiseki
  354.   #--------------------------------------------------------------------------
  355.   # ● オブジェクト初期化
  356.   #--------------------------------------------------------------------------
  357.   def initialize(viewport, index)
  358.     super(viewport)
  359.     @index = index
  360.     set_bitmap unless @index.zero?
  361.     if self.bitmap
  362.       self.x = MARGIN_LEFT + 40
  363.       self.y = set_new_y
  364.       self.z = 4
  365.       self.ox = self.bitmap.width / 2
  366.       self.oy = self.bitmap.height
  367.     end
  368.     self.opacity = 0
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ● ボーナスIDの取得
  372.   #--------------------------------------------------------------------------
  373.   def get_bonus
  374.     BonusManager.get_bonus_with_index(@index)
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● ビットマップのセット
  378.   #--------------------------------------------------------------------------
  379.   def set_bitmap
  380.     case get_bonus
  381.     when 0
  382.       self.bitmap = Cache.system("AT_BONUS_HP10")
  383.     when 1
  384.       self.bitmap = Cache.system("AT_BONUS_HP50")
  385.     when 2
  386.       self.bitmap = Cache.system("AT_BONUS_MP10")
  387.     when 3
  388.       self.bitmap = Cache.system("AT_BONUS_MP50")
  389.     when 4
  390.       self.bitmap = Cache.system("AT_BONUS_TP10")
  391.     when 5
  392.       self.bitmap = Cache.system("AT_BONUS_TP50")
  393.     when 6
  394.       self.bitmap = Cache.system("AT_BONUS_CRI")
  395.     when 7
  396.       self.bitmap = Cache.system("AT_BONUS_DUARD")
  397.     when 8
  398.       self.bitmap = Cache.system("AT_BONUS_RASH")
  399.     end
  400.   end
  401.   #--------------------------------------------------------------------------
  402.   # ● 移動先の y 座標を設定
  403.   #--------------------------------------------------------------------------
  404.   def set_new_y
  405.     @new_y = 32
  406.     @new_y += MARGIN_CURRENT_BOTTOM if @index > 1
  407.     @new_y += MARGIN_TOP + UNIT_INTERVAL * (@index-1)
  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ● フレーム更新
  411.   #--------------------------------------------------------------------------
  412.   def update
  413.     if self.bitmap
  414.       super
  415.       update_x
  416.       update_y
  417.       update_z
  418.       update_zoom
  419.       update_opacity
  420.     end
  421.   end
  422.   #--------------------------------------------------------------------------
  423.   # ● x 座標の更新
  424.   #--------------------------------------------------------------------------
  425.   def update_x
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ● y 座標の更新
  429.   #--------------------------------------------------------------------------
  430.   def update_y
  431.     if self.y != @new_y
  432.       self.y = [self.y - ((@new_y - self.y).abs < 3 ? 1 : 3), @new_y].max
  433.       flash_top_bonus if @index == 1 && self.y == @new_y
  434.     end
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # ● z 座標の更新
  438.   #--------------------------------------------------------------------------
  439.   def update_z
  440.     self.z = @index > 1 ?  4 : 7
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # ● 拡大率の更新
  444.   #--------------------------------------------------------------------------
  445.   def update_zoom
  446.     if (get_bonus == -1 || @index.zero?) && !self.zoom_x.zero?
  447.       self.zoom_x = self.zoom_y -= 0.05
  448.     end
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   # ● 透明度の更新
  452.   #--------------------------------------------------------------------------
  453.   def update_opacity
  454.     self.opacity += 12 if self.opacity != 255
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # ● ボーナスを進める
  458.   #--------------------------------------------------------------------------
  459.   def next_bonus
  460.     @index -= 1
  461.     set_new_y unless @index.zero?
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● 先頭に到達したボーナスをフラッシュさせてみる
  465.   #--------------------------------------------------------------------------
  466.   def flash_top_bonus
  467.     flash(Color.new(255, 255, 255, 196), 40)
  468.   end
  469. end
  470.  
  471. class Bonus_Spriteset
  472.   #--------------------------------------------------------------------------
  473.   # ● オブジェクト初期化
  474.   #--------------------------------------------------------------------------
  475.   def initialize(viewport)
  476.     @viewport = viewport
  477.     create_bonus
  478.   end
  479.   #--------------------------------------------------------------------------
  480.   # ● ボーナススプライトの生成
  481.   #--------------------------------------------------------------------------
  482.   def create_bonus
  483.     @bonus_sprites = []
  484.     10.times{|i| @bonus_sprites << Bonus.new(@viewport, i)}
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ● ボーナスを1つ進める
  488.   #--------------------------------------------------------------------------
  489.   def next_bonus
  490.     @bonus_sprites.shift.dispose
  491.     @bonus_sprites.each{|bonus| bonus.next_bonus}
  492.     @bonus_sprites << Bonus.new(@viewport, 8)
  493.   end
  494.   #--------------------------------------------------------------------------
  495.   # ● 解放
  496.   #--------------------------------------------------------------------------
  497.   def dispose
  498.     @bonus_sprites.each{|bonus| bonus.dispose}
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # ● フレーム更新
  502.   #--------------------------------------------------------------------------
  503.   def update
  504.     @bonus_sprites.each{|bonus| bonus.update}
  505.   end
  506. end
  507.  
  508. class Spriteset_Battle
  509.   #--------------------------------------------------------------------------
  510.   # ● オブジェクト初期化
  511.   #--------------------------------------------------------------------------
  512.   alias _kiseki_bonus_initialize initialize
  513.   def initialize
  514.     _kiseki_bonus_initialize
  515.     @bonus_spriteset = Bonus_Spriteset.new(@viewport3)
  516.     BonusManager.sprites_listener = @bonus_spriteset
  517.   end
  518.   #--------------------------------------------------------------------------
  519.   # ● フレーム更新
  520.   #--------------------------------------------------------------------------
  521.   alias _kiseki_bonus_update update
  522.   def update
  523.     _kiseki_bonus_update
  524.     @bonus_spriteset.update if @bonus_spriteset
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # ● 解放
  528.   #--------------------------------------------------------------------------
  529.   alias _kiseki_bonus_dispose dispose
  530.   def dispose
  531.     _kiseki_bonus_dispose
  532.     @bonus_spriteset.dispose
  533.   end
  534. end
  535.  
  536. class Window_BattleLog < Window_Selectable
  537.   include Rokan::Kiseki_Plugin
  538.   #--------------------------------------------------------------------------
  539.   # ● クリティカルヒットの表示
  540.   #--------------------------------------------------------------------------
  541.   alias _kiseki_bonus_display_critical display_critical
  542.   def display_critical(target, item)
  543.     display_critical_bonus
  544.     _kiseki_bonus_display_critical(target, item)
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # ● クリティカルボーナスの表示
  548.   #--------------------------------------------------------------------------
  549.   def display_critical_bonus
  550.     if BonusManager.critical?
  551.       add_text(CriticalBonusText)
  552.       wait
  553.     end
  554.   end
  555.   #--------------------------------------------------------------------------
  556.   # ● ボーナスによる回復結果の表示
  557.   #--------------------------------------------------------------------------
  558.   def display_bonus_recover(target)
  559.     if target.result.used
  560.       Sound.play_recovery
  561.       last_line_number = line_number
  562.       case BonusManager.get_bonus
  563.       when 0..1
  564.         add_text(target.result.hp_damage_text)
  565.       when 2..3
  566.         add_text(target.result.mp_damage_text)
  567.       when 4..5
  568.         add_text(target.result.tp_damage_text)
  569.       end
  570.       SceneManager.scene.refresh_status
  571.       wait
  572.       wait if line_number > last_line_number
  573.       back_to(last_line_number)
  574.     end
  575.   end
  576. end
  577.  
  578. class Scene_Battle < Scene_Base
  579.   #--------------------------------------------------------------------------
  580.   # ● パーティコマンド選択の開始
  581.   #--------------------------------------------------------------------------
  582.   alias _kiseki_bonus_start_party_command_selection start_party_command_selection
  583.   def start_party_command_selection
  584.     battler = OrderManager.top_unit.battler
  585.     battler.bonus_recover_effect
  586.     @log_window.display_bonus_recover(battler)
  587.     _kiseki_bonus_start_party_command_selection
  588.   end
  589. 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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top