Project1

标题: 求大神帮忙,两个脚本冲突了 [打印本页]

作者: stidus    时间: 2014-5-26 20:28
标题: 求大神帮忙,两个脚本冲突了
游戏中用到了一个CP条脚本和技能冷却脚本,现在的情况应该是CP条脚本修改了原本的回合机制,使技能冷却脚本失效。
求各位大神来帮忙看看有没办法让他们同时能生效
CP条脚本
RUBY 代码复制
  1. #========================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #========================================================================
  4. #========================================================================
  5. # ▼▲▼ XRXS_BP 1. CP制導入 ver..23 ▼▲▼
  6. # by 桜雅 在土, 和希
  7. #------------------------------------------------------------------------
  8. # □ カスタマイズポイント
  9. #========================================================================
  10. module XRXS_BP1
  11.   #
  12.   # 对齐方式。0:左 1:中央 2:右
  13.   #
  14.   ALIGN = 0
  15.   #
  16.   # 人数
  17.   #
  18.   MAX = 4
  19. end
  20. class Scene_Battle_CP
  21.   #
  22.   # 战斗速度
  23.   #
  24.   BATTLE_SPEED = 2.0
  25.   #
  26.   # 战斗开始的时候气槽百分比
  27.   #
  28.   START_CP_PERCENT = 0
  29. end
  30. class Scene_Battle
  31.   # 效果音效,可以自己添加
  32.   DATA_SYSTEM_COMMAND_UP_SE = ""
  33.   # 各项数值功能消耗的CP值
  34.   CP_COST_BASIC_ACTIONS = 0 # 基础共同
  35.   CP_COST_SKILL_ACTION = 65535 # 技能
  36.   CP_COST_ITEM_ACTION = 65535 # 物品
  37.   CP_COST_BASIC_ATTACK = 65535 # 攻撃
  38.   CP_COST_BASIC_GUARD = 65535 # 防御
  39.   CP_COST_BASIC_NOTHING = 65535 # 不做任何事情
  40.   CP_COST_BASIC_ESCAPE = 65535 # 逃跑
  41. end
  42. #========================================================================
  43. # --- XRXS.コマンドウィンドウ?コマンド追加機構 ---
  44. #------------------------------------------------------------------------
  45. # Window_Commandクラスに add_command メソッドを追加します。
  46. #========================================================================
  47. module XRXS_Window_Command_Add_Command
  48.   #----------------------------------------------------------------------
  49.   # ○ コマンドを追加
  50.   #----------------------------------------------------------------------
  51.   def add_command(command)
  52.     # 初期化されていない場合、無効化判別用の配列 [url=home.php?mod=space&uid=249395]@disabled[/url] の初期化
  53.     #
  54.     if @disabled == nil
  55.       @disabled = []
  56.     end
  57.     if @commands.size != @disabled.size
  58.       for i in [email]0...@commands.size[/email]
  59.         @disabled[i] = false
  60.       end
  61.     end
  62.     #
  63.     # 追加
  64.     #
  65.     @commands.push(command)
  66.     @disabled.push(false)
  67.     @item_max = @commands.size
  68.     self.y -= 32
  69.     self.height += 32
  70.     self.contents.dispose
  71.     self.contents = nil
  72.     self.contents = Bitmap.new(self.width - 32, @item_max * 32)
  73.     refresh
  74.     for i in [email]0...@commands.size[/email]
  75.       if @disabled[i]
  76.         disable_item(i)
  77.       end
  78.     end
  79.   end
  80.   #----------------------------------------------------------------------
  81.   # ○ 項目の無効化
  82.   # index : 項目番号
  83.   #----------------------------------------------------------------------
  84.   def disable_item(index)
  85.     if @disabled == nil
  86.       @disabled = []
  87.     end
  88.     @disabled[index] = true
  89.     draw_item(index, disabled_color)
  90.   end
  91. end
  92. class Window_Command < Window_Selectable
  93.   #----------------------------------------------------------------------
  94.   # ○ インクルード
  95.   #----------------------------------------------------------------------
  96.   include XRXS_Window_Command_Add_Command
  97.   #----------------------------------------------------------------------
  98.   # ● 項目の無効化
  99.   # index : 項目番号
  100.   #----------------------------------------------------------------------
  101.   def disable_item(index)
  102.     super
  103.   end
  104. end
  105. #========================================================================
  106. # □ Scene_Battle_CP
  107. #========================================================================
  108. class Scene_Battle_CP
  109.   #----------------------------------------------------------------------
  110.   # ○ 公開インスタンス変数
  111.   #----------------------------------------------------------------------
  112.   attr_accessor :stop # CP加算ストップ
  113.   #----------------------------------------------------------------------
  114.   # ○ オブジェクトの初期化
  115.   #----------------------------------------------------------------------
  116.   def initialize
  117.     @battlers = []
  118.     @cancel = false
  119.     @stop = false
  120.     @agi_total = 0
  121.     # 配列 count_battlers を初期化
  122.     count_battlers = []
  123.     # エネミーを配列 count_battlers に追加
  124.     for enemy in $game_troop.enemies
  125.       count_battlers.push(enemy)
  126.     end
  127.     # アクターを配列 count_battlers に追加
  128.     for actor in $game_party.actors
  129.       count_battlers.push(actor)
  130.     end
  131.     for battler in count_battlers
  132.       @agi_total += battler.agi
  133.     end
  134.     for battler in count_battlers
  135.       battler.cp = [[65535 * START_CP_PERCENT * (rand(15) + 85) * 4 * battler.agi / @agi_total / 10000, 0].max, 65535].min
  136.     end
  137.   end
  138.   #----------------------------------------------------------------------
  139.   # ○ CPカウントアップ
  140.   #----------------------------------------------------------------------
  141.   def update
  142.     # ストップされているならリターン
  143.     return if @stop
  144.     #
  145.     for battler in $game_party.actors + $game_troop.enemies
  146.       # 行動出来なければ無視
  147.       if battler.dead? == true
  148.         battler.cp = 0
  149.         next
  150.       end
  151.       battler.cp = [[battler.cp + BATTLE_SPEED * 4096 * battler.agi / @agi_total, 0].max, 65535].min
  152.     end
  153.   end
  154.   #----------------------------------------------------------------------
  155.   # ○ CPカウントの開始
  156.   #----------------------------------------------------------------------
  157.   def stop
  158.     @cancel = true
  159.     if @cp_thread != nil then
  160.       @cp_thread.join
  161.       @cp_thread = nil
  162.     end
  163.   end
  164. end
  165. #========================================================================
  166. # ■ Game_Battler
  167. #========================================================================
  168. class Game_Battler
  169.   attr_accessor :now_guarding # 現在防御中フラグ
  170.   attr_accessor :cp # 現在CP
  171.   attr_accessor :slip_state_update_ban # スリップ?ステート自動処理の禁止
  172.   #----------------------------------------------------------------------
  173.   # ○ CP の変更
  174.   #-----------------------------------------------------------------------
  175.   def cp=(p)
  176.     @cp = [[p, 0].max, 65535].min
  177.   end
  178.   #----------------------------------------------------------------------
  179.   # ● 防御中判定 [ 再定義 ]
  180.   #----------------------------------------------------------------------
  181.   def guarding?
  182.     return @now_guarding
  183.   end
  184.   #----------------------------------------------------------------------
  185.   # ● コマンド入力可能判定
  186.   #----------------------------------------------------------------------
  187.   alias xrxs_bp1_inputable? inputable?
  188.   def inputable?
  189.     bool = xrxs_bp1_inputable?
  190.     return (bool and (@cp >= 65535))
  191.   end
  192.   #----------------------------------------------------------------------
  193.   # ● ステート [スリップダメージ] 判定
  194.   #----------------------------------------------------------------------
  195.   alias xrxs_bp1_slip_damage? slip_damage?
  196.   def slip_damage?
  197.     return false if @slip_state_update_ban
  198.     return xrxs_bp1_slip_damage?
  199.   end
  200.   #----------------------------------------------------------------------
  201.   # ● ステート自然解除 (ターンごとに呼び出し)
  202.   #----------------------------------------------------------------------
  203.   alias xrxs_bp1_remove_states_auto remove_states_auto
  204.   def remove_states_auto
  205.     return if @slip_state_update_ban
  206.     xrxs_bp1_remove_states_auto
  207.   end
  208. end
  209. #========================================================================
  210. # ■ Game_Actor
  211. #========================================================================
  212. class Game_Actor < Game_Battler
  213.   #----------------------------------------------------------------------
  214.   # ● セットアップ
  215.   #----------------------------------------------------------------------
  216.   alias xrxs_bp1_setup setup
  217.   def setup(actor_id)
  218.     xrxs_bp1_setup(actor_id)
  219.     @cp = 0
  220.     @now_guarding = false
  221.     @slip_state_update_ban = false
  222.   end
  223. end
  224. #========================================================================
  225. # ■ Game_Enemy
  226. #========================================================================
  227. class Game_Enemy < Game_Battler
  228.   #----------------------------------------------------------------------
  229.   # ● オブジェクト初期化
  230.   #----------------------------------------------------------------------
  231.   alias xrxs_bp1_initialize initialize
  232.   def initialize(troop_id, member_index)
  233.     xrxs_bp1_initialize(troop_id, member_index)
  234.     @cp = 0
  235.     @now_guarding = false
  236.     @slip_state_update_ban = false
  237.   end
  238. end
  239. class Window_All < Window_Base
  240.   def initialize
  241.     super(0,0,640,480)
  242.     self.opacity = 0
  243.     self.contents = Bitmap.new(width - 32, height - 32)
  244.     refresh
  245.   end
  246.   def refresh
  247.     self.contents.clear
  248.     for actor in $game_troop.enemies
  249.       next if !actor.exist?
  250.       draw_actor_cp_meter(actor, actor.screen_x-50, actor.screen_y-50, 60, 0)
  251.     end
  252.   end
  253.   #----------------------------------------------------------------------
  254.   # ○ CPメーター の描画
  255.   #----------------------------------------------------------------------
  256.   def draw_actor_cp_meter(actor, x, y, width = 156, type = 0)
  257.     self.contents.font.color = system_color
  258.     self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  259.     if actor.cp == nil
  260.       actor.cp = 0
  261.     end
  262.     w = width * [actor.cp,65535].min / 65535
  263.     self.contents.fill_rect(x, y+28, w,1, Color.new(255, 255, 128, 255))
  264.     self.contents.fill_rect(x, y+29, w,1, Color.new(255, 255, 0, 255))
  265.     self.contents.fill_rect(x, y+30, w,1, Color.new(192, 192, 0, 255))
  266.     self.contents.fill_rect(x, y+31, w,1, Color.new(128, 128, 0, 255))
  267.   end  
  268. end
  269. #========================================================================
  270. # ■ Window_BattleStatus
  271. #========================================================================
  272. class Window_BattleStatus < Window_Base
  273.   #-----------------------------------------------------------------------
  274.   # ○ 公開インスタンス変数
  275.   #----------------------------------------------------------------------
  276.   attr_accessor :update_cp_only # CPメーターのみの更新
  277.   #----------------------------------------------------------------------
  278.   # ● オブジェクト初期化
  279.   #----------------------------------------------------------------------
  280.   alias xrxs_bp1_initialize initialize
  281.   def initialize
  282.     @update_cp_only = false
  283.     @wall = Window_All.new
  284.     xrxs_bp1_initialize
  285.   end
  286.   def dispose
  287.     super
  288.     @wall.dispose
  289.   end
  290.   #----------------------------------------------------------------------
  291.   # ● リフレッシュ
  292.   #----------------------------------------------------------------------
  293.   alias xrxs_bp1_refresh refresh
  294.   def refresh
  295.     unless @update_cp_only
  296.       xrxs_bp1_refresh
  297.     end
  298.     refresh_cp
  299.     @wall.refresh
  300.   end
  301.   #----------------------------------------------------------------------
  302.   # ○ リフレッシュ(CPのみ)
  303.   #----------------------------------------------------------------------
  304.   def refresh_cp
  305.     for i in 0...$game_party.actors.size
  306.       actor = $game_party.actors[i]
  307.       width = [self.width*3/4 / XRXS_BP1::MAX, 80].max
  308.       space = self.width / XRXS_BP1::MAX
  309.       case XRXS_BP1::ALIGN
  310.       when 0
  311.         actor_x = i * space + 4
  312.       when 1
  313.         actor_x = (space * ((XRXS_BP1::MAX - $game_party.actors.size)/2.0 + i)).floor
  314.       when 2
  315.         actor_x = (i + XRXS_BP1::MAX - $game_party.actors.size) * space + 4
  316.       end
  317.       actor_x += self.x
  318.       draw_actor_cp_meter(actor, actor_x, 96, width, 0)
  319.     end
  320.   end
  321.   #----------------------------------------------------------------------
  322.   # ○ CPメーター の描画
  323.   #----------------------------------------------------------------------
  324.   def draw_actor_cp_meter(actor, x, y, width = 156, type = 0)
  325.     self.contents.font.color = system_color
  326.     self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  327.     if actor.cp == nil
  328.       actor.cp = 0
  329.     end
  330.     w = width * [actor.cp,65535].min / 65535
  331.     self.contents.fill_rect(x, y+28, w,1, Color.new(255, 255, 128, 255))
  332.     self.contents.fill_rect(x, y+29, w,1, Color.new(255, 255, 0, 255))
  333.     self.contents.fill_rect(x, y+30, w,1, Color.new(192, 192, 0, 255))
  334.     self.contents.fill_rect(x, y+31, w,1, Color.new(128, 128, 0, 255))
  335.   end
  336. end
  337. #========================================================================
  338. # ■ Scene_Battle
  339. #========================================================================
  340. class Scene_Battle
  341.   #----------------------------------------------------------------------
  342.   # ● フレーム更新
  343.   #----------------------------------------------------------------------
  344.   alias xrxs_bp1_update update
  345.   def update
  346.     xrxs_bp1_update
  347.     # CP更新
  348.     @cp_thread.update
  349.   end
  350.   #----------------------------------------------------------------------
  351.   # ● バトル終了
  352.   # result : 結果 (0:勝利 1:敗北 2:逃走)
  353.   #----------------------------------------------------------------------
  354.   alias xrxs_bp1_battle_end battle_end
  355.   def battle_end(result)
  356.     # CPカウントを停止する
  357.     @cp_thread.stop
  358.     # 呼び戻す
  359.     xrxs_bp1_battle_end(result)
  360.   end
  361.   #----------------------------------------------------------------------
  362.   # ● プレバトルフェーズ開始
  363.   #----------------------------------------------------------------------
  364.   alias xrxs_bp1_start_phase1 start_phase1
  365.   def start_phase1
  366.     @agi_total = 0
  367.     # CP加算を開始する
  368.     @cp_thread = Scene_Battle_CP.new
  369.     # インデックスを計算
  370.     @cp_escape_actor_command_index = @actor_command_window.height/32 - 1
  371.     # アクターコマンドウィンドウに追加
  372.     @actor_command_window.add_command("逃跑")
  373.     if !$game_temp.battle_can_escape
  374.       @actor_command_window.disable_item(@cp_escape_actor_command_index)
  375.     end
  376.     # 呼び戻す
  377.     xrxs_bp1_start_phase1
  378.   end
  379.   #----------------------------------------------------------------------
  380.   # ● パーティコマンドフェーズ開始
  381.   #----------------------------------------------------------------------
  382.   alias xrxs_bp1_start_phase2 start_phase2
  383.   def start_phase2
  384.     xrxs_bp1_start_phase2
  385.     @party_command_window.active = false
  386.     @party_command_window.visible = false
  387.     # CP加算を再開する
  388.     @cp_thread.stop = false
  389.     # 次へ
  390.     start_phase3
  391.   end
  392.   #----------------------------------------------------------------------
  393.   # ● アクターコマンドウィンドウのセットアップ
  394.   #----------------------------------------------------------------------
  395.   alias xrxs_bp1_phase3_setup_command_window phase3_setup_command_window
  396.   def phase3_setup_command_window
  397.     # CPスレッドを一時停止する
  398.     @cp_thread.stop = true
  399.     # ウィンドウのCP更新
  400.     @status_window.refresh_cp
  401.     # @active_battlerの防御を解除
  402.     @active_battler.now_guarding = false
  403.     # 効果音の再生
  404.     Audio.se_play(DATA_SYSTEM_COMMAND_UP_SE) if DATA_SYSTEM_COMMAND_UP_SE != ""
  405.     # 呼び戻す
  406.     xrxs_bp1_phase3_setup_command_window
  407.   end
  408.   #----------------------------------------------------------------------
  409.   # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド)
  410.   #----------------------------------------------------------------------
  411.   alias xrxs_bsp1_update_phase3_basic_command update_phase3_basic_command
  412.   def update_phase3_basic_command
  413.     # C ボタンが押された場合
  414.     if Input.trigger?(Input::C)
  415.       # アクターコマンドウィンドウのカーソル位置で分岐
  416.       case @actor_command_window.index
  417.       when @cp_escape_actor_command_index # 逃げる
  418.         if $game_temp.battle_can_escape
  419.           # 決定 SE を演奏
  420.           $game_system.se_play($data_system.decision_se)
  421.           # アクションを設定
  422.           @active_battler.current_action.kind = 0
  423.           @active_battler.current_action.basic = 4
  424.           # 次のアクターのコマンド入力へ
  425.           phase3_next_actor
  426.         else
  427.           # ブザー SE を演奏
  428.           $game_system.se_play($data_system.buzzer_se)
  429.         end
  430.         return
  431.       end
  432.     end
  433.     xrxs_bsp1_update_phase3_basic_command
  434.   end
  435.   #----------------------------------------------------------------------
  436.   # ● メインフェーズ開始
  437.   #----------------------------------------------------------------------
  438.   alias xrxs_bp1_start_phase4 start_phase4
  439.   def start_phase4
  440.     # 呼び戻す
  441.     xrxs_bp1_start_phase4
  442.     # CPスレッドを一時停止する
  443.     unless @action_battlers.empty?
  444.       @cp_thread.stop = true
  445.     end
  446.   end
  447.   #----------------------------------------------------------------------
  448.   # ● 行動順序作成
  449.   #----------------------------------------------------------------------
  450.   alias xrxs_bp1_make_action_orders make_action_orders
  451.   def make_action_orders
  452.     xrxs_bp1_make_action_orders
  453.     # 全員のCPを確認
  454.     exclude_battler = []
  455.     for battler in @action_battlers
  456.       # CPが不足している場合は @action_battlers から除外する
  457.       if battler.cp < 65535
  458.         exclude_battler.push(battler)
  459.       end
  460.     end
  461.     @action_battlers -= exclude_battler
  462.   end
  463.   #----------------------------------------------------------------------
  464.   # ● フレーム更新 (メインフェーズ ステップ 1 : アクション準備)
  465.   #----------------------------------------------------------------------
  466.   alias xrxs_bp1_update_phase4_step1 update_phase4_step1
  467.   def update_phase4_step1
  468.     # 初期化
  469.     @phase4_act_continuation = 0
  470.     # 勝敗判定
  471.     if judge
  472.       @cp_thread.stop
  473.       # 勝利または敗北の場合 : メソッド終了
  474.       return
  475.     end
  476.     # 未行動バトラー配列の先頭から取得
  477.     @active_battler = @action_battlers[0]
  478.     # ステータス更新をCPだけに限定。
  479.     @status_window.update_cp_only = true
  480.     # ステート更新を禁止。
  481.     @active_battler.slip_state_update_ban = true if @active_battler != nil
  482.     # 戻す
  483.     xrxs_bp1_update_phase4_step1
  484.     # @status_windowがリフレッシュされなかった場合は手動でリフレッシュ(CPのみ)
  485.     if @phase4_step != 2
  486.       # リフレッシュ
  487.       @status_window.refresh
  488.       # 軽量化:たったコレだけΣ(?w?
  489.       Graphics.frame_reset
  490.     end
  491.     # 禁止を解除
  492.     @status_window.update_cp_only = false
  493.     @active_battler.slip_state_update_ban = false if @active_battler != nil
  494.   end
  495.   #----------------------------------------------------------------------
  496.   # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  497.   #----------------------------------------------------------------------
  498.   alias xrxs_bp1_update_phase4_step2 update_phase4_step2
  499.   def update_phase4_step2
  500.     # 強制アクションでなければ
  501.     unless @active_battler.current_action.forcing
  502.       # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合
  503.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  504.         # アクションに攻撃を設定
  505.         @active_battler.current_action.kind = 0
  506.         @active_battler.current_action.basic = 0
  507.       end
  508.       # 制約が [行動できない] の場合
  509.       if @active_battler.restriction == 4
  510.         # アクション強制対象のバトラーをクリア
  511.         $game_temp.forcing_battler = nil
  512.         if @phase4_act_continuation == 0 and @active_battler.cp >= 65535
  513.           # ステート自然解除
  514.           @active_battler.remove_states_auto
  515.           # CP消費
  516.           @active_battler.cp -= 65535
  517.           # ステータスウィンドウをリフレッシュ
  518.           @status_window.refresh
  519.         end
  520.         # ステップ 1 に移行
  521.         @phase4_step = 1
  522.         return
  523.       end
  524.     end
  525.     # アクションの種別で分岐
  526.     case @active_battler.current_action.kind
  527.     when 0
  528.       # 攻撃?防御?逃げる?何もしない時の共通消費CP
  529.       @active_battler.cp -= CP_COST_BASIC_ACTIONS if @phase4_act_continuation == 0
  530.     when 1
  531.       # スキル使用時の消費CP
  532.       @active_battler.cp -= CP_COST_SKILL_ACTION if @phase4_act_continuation == 0
  533.     when 2
  534.       # アイテム使用時の消費CP
  535.       @active_battler.cp -= CP_COST_ITEM_ACTION if @phase4_act_continuation == 0
  536.     end
  537.     # ステート自然解除
  538.     @active_battler.remove_states_auto
  539.     # 呼び戻す
  540.     xrxs_bp1_update_phase4_step2
  541.   end
  542.   #----------------------------------------------------------------------
  543.   # ● 基本アクション 結果作成
  544.   #----------------------------------------------------------------------
  545.   alias xrxs_bp1_make_basic_action_result make_basic_action_result
  546.   def make_basic_action_result
  547.     # 攻撃の場合
  548.     if @active_battler.current_action.basic == 0 and @phase4_act_continuation == 0
  549.       @active_battler.cp -= CP_COST_BASIC_ATTACK # 攻撃時のCP消費
  550.     end
  551.     # 防御の場合
  552.     if @active_battler.current_action.basic == 1 and @phase4_act_continuation == 0
  553.       @active_battler.cp -= CP_COST_BASIC_GUARD # 防御時のCP消費
  554.       # @active_battlerの防御をON
  555.       @active_battler.now_guarding = true
  556.     end
  557.     # 敵の逃げるの場合
  558.     if @active_battler.is_a?(Game_Enemy) and
  559.         @active_battler.current_action.basic == 2 and @phase4_act_continuation == 0
  560.       @active_battler.cp -= CP_COST_BASIC_ESCAPE # 逃走時のCP消費
  561.     end
  562.     # 何もしないの場合
  563.     if @active_battler.current_action.basic == 3 and @phase4_act_continuation == 0
  564.       @active_battler.cp -= CP_COST_BASIC_NOTHING # 何もしない時のCP消費
  565.     end
  566.     # 逃げるの場合
  567.     if @active_battler.current_action.basic == 4 and @phase4_act_continuation == 0
  568.       @active_battler.cp -= CP_COST_BASIC_ESCAPE # 逃走時のCP消費
  569.       # 逃走可能ではない場合
  570.       if $game_temp.battle_can_escape == false
  571.         # ブザー SE を演奏
  572.         $game_system.se_play($data_system.buzzer_se)
  573.         return
  574.       end
  575.       # 逃走処理
  576.       update_phase2_escape
  577.       return
  578.     end
  579.     # 呼び戻す
  580.     xrxs_bp1_make_basic_action_result
  581.   end
  582.   #----------------------------------------------------------------------
  583.   # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  584.   #----------------------------------------------------------------------
  585.   alias xrxs_bp1_update_phase4_step6 update_phase4_step6
  586.   def update_phase4_step6
  587.     # スリップダメージ
  588.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  589.       @active_battler.slip_damage_effect
  590.       @active_battler.damage_pop = true
  591.       # ステータスウィンドウをリフレッシュ
  592.       @status_window.refresh
  593.     end
  594.     # 呼び戻す
  595.     xrxs_bp1_update_phase4_step6
  596.   end
  597. end
  598. #======================================================================
  599. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  600. #======================================================================



技能冷却脚本
RUBY 代码复制
  1. #=======================================================================
  2. #  豪华版技能冷却系统 By 绿发的Eclair
  3. #  使用方法:在特技名称后面用半角逗号分割,写上冷却回合数。
  4. #  比如 十字斩,10 就是特技 十字斩 冷却10个回合了。
  5. #  注意这个冷却是敌我通用的,不只是我方,敌人也不会使用冷却中的技能哦。
  6. #  不想让特技窗口中显示冷却回合数, $冷却时间显示 = false 就行了。
  7. #  冲突性:存在,但是除了RTAB外似乎整合难度不大。
  8. #=======================================================================
  9. $冷却时间显示 = true
  10. module RPG
  11.   class Skill
  12.   def cold
  13.     return @name.split(/,/)[1]
  14.   end
  15.   def name(actor = nil)
  16.     if $冷却时间显示 and actor != nil and actor.cold[@id] != nil
  17.       a = (@name.split(/,/)[0] == nil ? 0 : @name.split(/,/)[0])
  18.       return a + "(" + actor.cold[@id].to_s + "回合冷却)"
  19.     else
  20.       return (@name.split(/,/)[0] == nil ? 0 : @name.split(/,/)[0])
  21.     end
  22.   end
  23.   end
  24. end
  25. class Game_Battler
  26.   attr_accessor :cold
  27.   alias initialize_cold :initialize
  28.   def initialize
  29.     @cold = {}
  30.     initialize_cold
  31.   end
  32.   def set_cold(key,val)
  33.     return if @cold[key] == nil
  34.     @cold[key] += val
  35.     @cold.delete(key) if @cold[key] <= 0
  36.   end
  37.   alias skill_can_use_addcold :skill_can_use?
  38.   def skill_can_use?(skill_id)
  39.     return false if @cold[skill_id] != nil
  40.     skill_can_use_addcold(skill_id)
  41.   end
  42. end
  43. class Scene_Battle
  44.   alias make_skill_action_result_addcold :make_skill_action_result
  45.   def make_skill_action_result
  46.     make_skill_action_result_addcold
  47.     if @skill.cold.to_i != 0
  48.     @active_battler.cold[@skill.id] = @skill.cold.to_i
  49.     end
  50.   end
  51.   alias start_phase4_addcold :start_phase4
  52.   def start_phase4
  53.     for i in $game_party.actors + $game_troop.enemies
  54.       for j in i.cold.keys
  55.       i.set_cold(j,-1)
  56.       end  
  57.     end  
  58.     start_phase4_addcold
  59.   end   
  60. end  
  61. class Window_Skill < Window_Selectable
  62.     def draw_item(index)
  63.     skill = @data[index]
  64.     if @actor.skill_can_use?(skill.id)
  65.       self.contents.font.color = normal_color
  66.     else
  67.       self.contents.font.color = disabled_color
  68.     end
  69.     x = 4 + index % 2 * (288 + 32)
  70.     y = index / 2 * 32
  71.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  72.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  73.     bitmap = RPG::Cache.icon(skill.icon_name)
  74.     opacity = self.contents.font.color == normal_color ? 255 : 128
  75.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  76.     if $scene.is_a?(Scene_Battle)
  77.     self.contents.draw_text(x + 28, y, 204, 32, skill.name(@actor), 0)
  78.     else
  79.     self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  80.     end
  81.     self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  82.   end
  83. end
  84.  
  85. class Game_Enemy < Game_Battler
  86.     def make_action
  87.     # 清除当前行动
  88.     self.current_action.clear
  89.     # 无法行动的情况
  90.     unless self.movable?
  91.       # 过程结束
  92.       return
  93.     end
  94.     # 抽取现在有效的行动
  95.     available_actions = []
  96.     rating_max = 0
  97.     for action in self.actions
  98.       # 确认回合条件
  99.       n = $game_temp.battle_turn
  100.       a = action.condition_turn_a
  101.       b = action.condition_turn_b
  102.       if (b == 0 and n != a) or
  103.          (b > 0 and (n < 1 or n < a or n % b != a % b))
  104.         next
  105.       end
  106.       # 确认 HP 条件
  107.       if self.hp * 100.0 / self.maxhp > action.condition_hp
  108.         next
  109.       end
  110.       if self.cold[action.skill_id] != nil
  111.         next
  112.       end
  113.       # 确认等级条件
  114.       if $game_party.max_level < action.condition_level
  115.         next
  116.       end
  117.       # 确认开关条件
  118.       switch_id = action.condition_switch_id
  119.       if switch_id > 0 and $game_switches[switch_id] == false
  120.         next
  121.       end
  122.       # 符合条件 : 添加本行动
  123.       available_actions.push(action)
  124.       if action.rating > rating_max
  125.         rating_max = action.rating
  126.       end
  127.     end
  128.     # 最大概率值作为 3 合计计算(0 除外)
  129.     ratings_total = 0
  130.     for action in available_actions
  131.       if action.rating > rating_max - 3
  132.         ratings_total += action.rating - (rating_max - 3)
  133.       end
  134.     end
  135.     # 概率合计不为 0 的情况下
  136.     if ratings_total > 0
  137.       # 生成随机数
  138.       value = rand(ratings_total)
  139.       # 设置对应生成随机数的当前行动
  140.       for action in available_actions
  141.         if action.rating > rating_max - 3
  142.           if value < action.rating - (rating_max - 3)
  143.             self.current_action.kind = action.kind
  144.             self.current_action.basic = action.basic
  145.             self.current_action.skill_id = action.skill_id
  146.             self.current_action.decide_random_target_for_enemy
  147.             return
  148.           else
  149.             value -= action.rating - (rating_max - 3)
  150.           end
  151.         end
  152.       end
  153.     end
  154.   end
  155. end
  156. #=======================================================================
  157. #豪华版技能冷却系统
  158. #=======================================================================

作者: kakarot    时间: 2014-5-28 04:52
本帖最后由 kakarot 于 2014-5-27 21:54 编辑

小白飘过~

LZ说的没错,两个start_phase4的定义冲突了,导致CP条没涨多少冷却时间已经被刷完了

参考改法:
冷却脚本里start_phase4的下面脚本注释或者删掉:

  1. #    for i in $game_party.actors + $game_troop.enemies
  2. #      for j in i.cold.keys
  3. #      i.set_cold(j,-1)
  4. #      end  
  5. #    end  
复制代码
然后CP脚本里start_phase4的@cp_thread.stop = true之后加上

  1.      for i in $game_party.actors + $game_troop.enemies
  2.         for j in i.cold.keys
  3.           for k in @action_battlers
  4.             if k == i
  5.               i.set_cold(j,-1)
  6.             end
  7.           end
  8.         end  
  9.       end
复制代码

作者: stidus    时间: 2014-5-28 13:03
kakarot 发表于 2014-5-28 04:52
小白飘过~

LZ说的没错,两个start_phase4的定义冲突了,导致CP条没涨多少冷却时间已经被刷完了

多谢解答{:6_416:},我我现在在纠结是用这个技能冷却角本 还是用状态做的技能冷却脚本。这个脚本工作量小,但用状态做的话,可以很简单的制作出清空冷却时间的效果。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1