设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1258|回复: 9

[已经过期] 关于cp制战斗的问题

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1293
在线时间
118 小时
注册时间
2017-7-14
帖子
148
发表于 2019-4-12 20:57:33 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
从oz大乱斗上扒下来个关于cp制战斗的脚本...然而实用后发现...某个战斗者行动后会将其他战斗者的进度条全部归零,示意图如下...脚本附下...想请教一下这是怎么回事...(说不定是我偷脚本没偷全呢233,为了阅读方便..省略了AX追加和按钮追加的脚本没发)...
RUBY 代码复制
  1. # ▼▲▼ XRXS65. CP制御ターンシステム ver.β ▼▲▼ built 201120
  2. # by 桜雅 在土
  3.  
  4. #==============================================================================
  5. # □ カスタマイズポイント
  6. #==============================================================================
  7. module XRXS65
  8.   #
  9.   # 「バトルスピード」(数値が高いほど早い)
  10.   #
  11.   SPEED = 1.0
  12.   #
  13.   # 戦闘開始時 CP。 固定値と占有率
  14.   #
  15.   CP_PRESET_FIXNUM = 0
  16.   CP_PRESET_RATIO  = 2.0
  17.   #
  18.   # ターンコントローラ (nil  : カウント/ターンを有効。
  19.   #                     数値 : そのインデックスをもつエネミーが支配)
  20.   #
  21.   TC = 0
  22.   #
  23.   # カウント/ターン (TCが有効な場合は無視)
  24.   #
  25.   CPT = 40
  26.   #
  27.   # CP スキン
  28.   #
  29.   SKIN        = "123"  # スキンファイル名(Graphics/Windowskinsフォルダ)
  30.   LINE_HEIGHT =  6        # スキンの"一行"の縦幅[単位:ピクセル]
  31.   #
  32.   # 表示位置セッティング
  33.   #
  34.   X_OFFSET = 144    # 横位置
  35.   Y_OFFSET = 464    # 縦位置
  36.   ALIGN    =   1    #「位置揃え」(CPメーターの位置。0:左寄せ 1:中央 2:右寄せ)
  37.   MAX      =   4    # 確保するサイズ[単位:~人分]
  38.   #
  39.   # アクターコマンドがポップしたときの効果音
  40.   #
  41.   COMMAND_UP_SE = "Audio/SE/046-Book01.ogg"
  42. end
  43. #==============================================================================
  44. # --- CP メーターの描画情報の取得 --- (Game_Battlerにインクルードされます)
  45. #==============================================================================
  46. module XRXS_CP
  47.   #--------------------------------------------------------------------------
  48.   # ○ スキンライン (スキンの何行目を使うか)
  49.   #--------------------------------------------------------------------------
  50.   def cp_linetype
  51.     # CP フルの場合はスキンの 2 行目を使う
  52.     return 2 if self.cp_full?
  53.     # 通常はスキンの 1 行目を使う
  54.     return 1
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ○ メーター量[単位:%]
  58.   #--------------------------------------------------------------------------
  59.   def cp_lineamount
  60.     # 戦闘不能の場合は 0 %として表示させる
  61.     return 0 if self.dead?
  62.     # CP値を%値に変換して返却する
  63.     return 100 * self.cp / self.max_cp
  64.   end
  65. end
  66. #
  67. # カスタマイズポイントここまで。
  68. #------------------------------------------------------------------------------
  69.  
  70.  
  71.  
  72. #==============================================================================
  73. # --- XRXS. CP機構 ---
  74. #==============================================================================
  75. module XRXS_CP_SYSTEM
  76.   #----------------------------------------------------------------------------
  77.   # ○ 合計 AGI の取得
  78.   #----------------------------------------------------------------------------
  79.   def self.total_agi
  80.     total = 0
  81.     for battler in $game_party.actors + $game_troop.enemies
  82.       total += battler.agi
  83.     end
  84.     return total
  85.   end
  86. end
  87. #==============================================================================
  88. # --- バトラーにCP機能を追加 モジュール ---
  89. #==============================================================================
  90. module XRXS_CP
  91.   #--------------------------------------------------------------------------
  92.   # ○ 最大 CP の取得
  93.   #--------------------------------------------------------------------------
  94.   def max_cp
  95.     return 65535
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ○ CP の取得と設定
  99.   #--------------------------------------------------------------------------
  100.   def cp
  101.     return @cp == nil ? @cp = 0 : @cp
  102.   end
  103.   def cp=(n)
  104.     @cp = [[n.to_i, 0].max, self.max_cp].min
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ○ CP 初期設定
  108.   #--------------------------------------------------------------------------
  109.   def cp_preset
  110.     percent = self.max_cp * XRXS65::CP_PRESET_RATIO * (rand(16) + 16) * self.agi / XRXS_CP_SYSTEM.total_agi / 24
  111.     self.cp = XRXS65::CP_PRESET_FIXNUM + percent
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ○ CP カウントアップ
  115.   #--------------------------------------------------------------------------
  116.   def cp_update
  117.     self.cp += XRXS65::SPEED * 4096 * self.agi / XRXS_CP_SYSTEM.total_agi
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ○ CP 満タン?
  121.   #--------------------------------------------------------------------------
  122.   def cp_full?
  123.     return @cp == self.max_cp
  124.   end
  125. end
  126. class Game_Battler
  127.   include XRXS_CP
  128. end
  129. #==============================================================================
  130. # --- ガード機能 ---
  131. #==============================================================================
  132. class Game_Battler
  133.   #--------------------------------------------------------------------------
  134.   # ○ ガードフラグ
  135.   #--------------------------------------------------------------------------
  136.   def guarding=(n)
  137.     @guarding = n
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ● 防御中判定 [再定義]
  141.   #--------------------------------------------------------------------------
  142.   def guarding?
  143.     return @guarding
  144.   end
  145. end
  146. #==============================================================================
  147. # --- アクター「コマンド入力可能判定」:CPがないとコマンドしない ---
  148. #==============================================================================
  149. module XRXS_CP_INPUTABLE
  150.   def inputable?
  151.     return (self.cp_full? and super)
  152.   end
  153. end
  154. class Game_Actor < Game_Battler
  155.   include XRXS_CP_INPUTABLE
  156. end
  157. #==============================================================================
  158. # --- エネミー「行動可能判定」:CPがないとコマンドしない ---
  159. #==============================================================================
  160. module XRXS_CP_MOVABLE
  161.   def movable?
  162.     return (self.cp_full? and super)
  163.   end
  164. end
  165. class Game_Enemy < Game_Battler
  166.   include XRXS_CP_MOVABLE
  167. end
  168. #==============================================================================
  169. # --- 戦闘時 CPカウント ---
  170. #==============================================================================
  171. module XRXS_CP_Battle
  172.   #--------------------------------------------------------------------------
  173.   # ○ パーティ全員の CP を初期設定
  174.   #--------------------------------------------------------------------------
  175.   def cp_preset_party
  176.     #p $game_party.actors.size
  177.     for actor in $game_party.actors
  178.       actor.cp_preset
  179.     end
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ○ トループ全員の CP を初期設定
  183.   #--------------------------------------------------------------------------
  184.   def cp_preset_troop
  185.     for enemy in $game_troop.enemies
  186.       enemy.cp_preset
  187.     end
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ○ バトラー全員の CP をカウントアップ
  191.   #--------------------------------------------------------------------------
  192.   def cp_update
  193.     #p $game_party.actors.size
  194.     for battler in $game_party.actors + $game_troop.enemies
  195.       battler.cp_update
  196.     end
  197.      @fuck_helper.cp_update if @fuck_helper != nil
  198.   end
  199. end
  200. class Scene_Battle
  201.   include XRXS_CP_Battle
  202. end
  203. #==============================================================================
  204. # ■ Scene_Battle
  205. #==============================================================================
  206. class Scene_Battle
  207.   #--------------------------------------------------------------------------
  208.   # ● メイン処理
  209.   #--------------------------------------------------------------------------
  210.   alias xrxs65_main main
  211.   def main
  212.     # エクストラスプライトの初期化
  213.     @extra_sprites = [] if @extra_sprites == nil
  214.     # CP の初期化
  215.     cp_preset_party
  216.     # CP メーターの作成
  217.     @cp_meters = CP_Meters.new
  218.     # CP メーターをエクストラスプライトへ登録
  219.     @extra_sprites.push(@cp_meters)
  220.     # 呼び戻す
  221. #    p $game_party.actors.size
  222.     xrxs65_main
  223.     # メーターの解放
  224.     @cp_meters.dispose
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ● プレバトルフェーズ開始
  228.   #--------------------------------------------------------------------------
  229.   alias xrxs65_start_phase1 start_phase1
  230.   def start_phase1
  231.     # 呼び戻す
  232.     xrxs65_start_phase1
  233.     # CP の初期化
  234.     cp_preset_troop
  235.     # CP メーターの更新
  236.     @cp_meters.refresh
  237.     # インデックスを計算
  238.     @cp_escape_actor_command_index = @actor_command_window.height/32 - 1
  239.     # アクターコマンドウィンドウに追加
  240.     @actor_command_window.add_command("逃跑")
  241.     if !$game_temp.battle_can_escape
  242.       @actor_command_window.disable_item(@cp_escape_actor_command_index)
  243.     end
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ● パーティコマンドフェーズ開始
  247.   #--------------------------------------------------------------------------
  248.   alias xrxs65_start_phase2 start_phase2
  249.   def start_phase2
  250.     # 呼び戻す
  251.     xrxs65_start_phase2
  252.     # パーティコマンドウィンドウを無効化
  253.     @party_command_window.active  = false
  254.     @party_command_window.visible = false
  255.     # 強制的にフェイズ 2 を保持
  256.     @phase = 2
  257.     # ただし、既に行動可能者が存在する場合は 3 へ
  258.     start_phase3 if anybody_movable?
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ○ CP制での ターンのカウント
  262.   #--------------------------------------------------------------------------
  263.   def cp_turn_count
  264.     $game_temp.battle_turn += 1
  265.     # バトルイベントの全ページを検索
  266.     for index in 0...$data_troops[@troop_id].pages.size
  267.       # このページのスパンが [ターン] の場合
  268.       if $data_troops[@troop_id].pages[index].span == 1
  269.         # 実行済みフラグをクリア
  270.         $game_temp.battle_event_flags[index] = false
  271.       end
  272.     end
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # ● フレーム更新 (パーティコマンドフェーズ)
  276.   #--------------------------------------------------------------------------
  277.   alias xrxs65_update_phase2 update_phase2
  278.   def update_phase2
  279.     # パーティコマンドウィンドウのインデックスを無効化
  280.     @party_command_window.index = -1
  281.     # 呼び戻す
  282.     xrxs65_update_phase2
  283.     # 例外補正
  284.     @turn_count_time = 1 if @turn_count_time == nil
  285.     # ターンのカウント
  286.     if @turn_count_time > 0
  287.       @turn_count_time -= 1
  288.       if @turn_count_time == 0
  289.         cp_turn_count
  290.         @turn_count_time = XRXS65::CPT if XRXS65::TC == nil
  291.       end
  292.     end
  293.     # CP のフレーム更新
  294.     cp_update
  295.     @cp_meters.refresh
  296.     # フル CP のバトラーが存在する場合、ターン開始
  297.     start_phase3 if anybody_movable?
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ○ フル CP バトラーが存在するか?
  301.   #--------------------------------------------------------------------------
  302.   def anybody_movable?
  303.     for battler in $game_party.actors + $game_troop.enemies
  304.       return true if battler.cp_full?
  305.     end
  306.     #p "Full" if @fuck_helper.cp_full?
  307.     if @fuck_helper != nil
  308.       return true if @fuck_helper.cp_full?
  309.     end
  310.     return false
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● アクターコマンドウィンドウのセットアップ
  314.   #--------------------------------------------------------------------------
  315.   alias xrxs65_phase3_setup_command_window phase3_setup_command_window
  316.   def phase3_setup_command_window
  317.     # 効果音の再生
  318.     Audio.se_play(XRXS65::COMMAND_UP_SE) rescue nil
  319.     # 呼び戻す
  320.     xrxs65_phase3_setup_command_window
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド)
  324.   #--------------------------------------------------------------------------
  325.   alias xrxs_bsp1_update_phase3_basic_command update_phase3_basic_command
  326.   def update_phase3_basic_command
  327.     # C ボタンが押された場合
  328.     if Input.trigger?(Input::C)
  329.       # アクターコマンドウィンドウのカーソル位置で分岐
  330.       case @actor_command_window.index
  331.       when @cp_escape_actor_command_index # 逃げる
  332.         if $game_temp.battle_can_escape
  333.           # 決定 SE を演奏
  334.           $game_system.se_play($data_system.decision_se)
  335.           # アクションを設定
  336.           @active_battler.current_action.kind = 0
  337.           @active_battler.current_action.basic = 4
  338.           # 次のアクターのコマンド入力へ
  339.           phase3_next_actor
  340.         else
  341.           # ブザー SE を演奏
  342.           $game_system.se_play($data_system.buzzer_se)
  343.         end
  344.         return
  345.       end
  346.     end
  347.     # 呼び戻す
  348.     xrxs_bsp1_update_phase3_basic_command
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● メインフェーズ開始
  352.   #--------------------------------------------------------------------------
  353.   alias xrxs65_start_phase4 start_phase4
  354.   def start_phase4
  355.     # ターン数を引くことによって擬似的にカウントに変化を起こさせない
  356.     $game_temp.battle_turn -= 1
  357.     # フラグを退避
  358.     save_flags = $game_temp.battle_event_flags.dup
  359.     # 呼び戻す
  360.     xrxs65_start_phase4
  361.     # フラグを復旧
  362.     $game_temp.battle_event_flags = save_flags
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 行動順序作成
  366.   #--------------------------------------------------------------------------
  367.   alias xrxs65_make_action_orders make_action_orders
  368.   def make_action_orders
  369.     # 呼び戻す
  370.     xrxs65_make_action_orders
  371.     # CPが不足している場合は @action_battlers から除外する
  372.     for battler in @action_battlers.dup
  373.       @action_battlers.delete(battler) unless battler.cp_full?# || battler.id == @fuck_helper.id
  374.     end
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  378.   #--------------------------------------------------------------------------
  379.   alias xrxs65_update_phase4_step2 update_phase4_step2
  380.   def update_phase4_step2
  381.     # ガードの解除
  382.     @active_battler.guarding = false
  383.     # CPの消費
  384.     @active_battler.cp = 0
  385.     #p @active_battler.name,@active_battler.cp
  386.     # CP メーターの更新
  387.     @cp_meters.refresh
  388.     # 呼び戻す
  389.     xrxs65_update_phase4_step2
  390.     # 例外補正
  391.     return if @active_battler == nil
  392.     # ターンコントローラ
  393.     if @active_battler.is_a?(Game_Enemy) and @active_battler.index == XRXS65::TC
  394.       cp_turn_count
  395.     end
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● 基本アクション 結果作成
  399.   #--------------------------------------------------------------------------
  400.   alias xrxs65_make_basic_action_result make_basic_action_result
  401.   def make_basic_action_result
  402.     # 呼び戻す
  403.     xrxs65_make_basic_action_result
  404.     # 防御の場合
  405.     if @active_battler.current_action.basic == 1
  406.       @active_battler.guarding = true
  407.       return
  408.     end
  409.     # パーティの逃亡の場合
  410.     if @active_battler.current_action.basic == 4
  411.       # 逃走可能ではない場合
  412.       if $game_temp.battle_can_escape == false
  413.         # ブザー SE を演奏
  414.         $game_system.se_play($data_system.buzzer_se)
  415.         return
  416.       end
  417.       # パーティ全員の CP をクリア
  418.       for actor in $game_party.actors
  419.         actor.cp = 0
  420.       end
  421.       # CP メーターの更新
  422.       @cp_meters.refresh
  423.       # 逃走処理
  424.       update_phase2_escape
  425.       return
  426.     end
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  430.   #--------------------------------------------------------------------------
  431.   alias xrxs65_update_phase4_step5 update_phase4_step5
  432.   def update_phase4_step5
  433.     # 呼び戻す
  434.     xrxs65_update_phase4_step5
  435.     # CP メーターの更新
  436.     @cp_meters.refresh
  437.   end
  438. end
  439. #==============================================================================
  440. # --- CP メーターをまとめて管理するクラス、表示関係はすべてココ ---
  441. #==============================================================================
  442. class CP_Meters
  443.   #--------------------------------------------------------------------------
  444.   # ○ オブジェクト初期化
  445.   #--------------------------------------------------------------------------
  446.   def initialize
  447.     # メーター群の生成
  448.     @meters = []
  449.     for i in 0...$game_party.actors.size
  450.       make_meter(i)
  451.     end
  452.     refresh
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # ○ リフレッシュ
  456.   #--------------------------------------------------------------------------
  457.   def refresh
  458.     # 戦闘メンバー数の変更を判別
  459.     for i in @meters.size...$game_party.actors.size
  460.       make_meter(i)
  461.     end
  462.     for i in $game_party.actors.size...@meters.size
  463.       @meters[i].dispose
  464.       @meters[i] = nil
  465.     end
  466.     @meters.compact!
  467.     # 表示更新
  468.     for i in 0...$game_party.actors.size
  469.       actor = $game_party.actors[i]
  470.       @meters[i].line   = actor.cp_linetype
  471.       @meters[i].amount = actor.cp_lineamount
  472.     end
  473.   end
  474.   #--------------------------------------------------------------------------
  475.   # ○ メーターひとつの生成
  476.   #--------------------------------------------------------------------------
  477.   def make_meter(i)
  478.     # スキンの取得
  479.     skin = RPG::Cache.windowskin(XRXS65::SKIN)
  480.     #
  481.     space = 640 / XRXS65::MAX
  482.     case XRXS65::ALIGN
  483.     when 0
  484.       actor_x = i * space + 4
  485.     when 1
  486.       actor_x = (space * ((XRXS65::MAX - $game_party.actors.size)/2.0 + i)).floor
  487.     when 2
  488.       actor_x = (i + XRXS65::MAX - $game_party.actors.size) * space + 4
  489.     end
  490.     meter = MeterSprite.new(skin, XRXS65::LINE_HEIGHT)
  491.     meter.x = actor_x + XRXS65::X_OFFSET - skin.width
  492.     meter.y = XRXS65::Y_OFFSET
  493.     @meters[i] = meter
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # ○ 可視状態
  497.   #--------------------------------------------------------------------------
  498.   def visible=(b)
  499.     @meters.each{|sprite| sprite.visible = b }
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # ○ 解放
  503.   #--------------------------------------------------------------------------
  504.   def dispose
  505.     @meters.each{|sprite| sprite.dispose }
  506.   end
  507. end
  508. #==============================================================================
  509. # --- XRXS. レクタンギュラーメーター表示・極 ---
  510. #==============================================================================
  511. class MeterSprite < Sprite
  512.   #--------------------------------------------------------------------------
  513.   # ○ オブジェクト初期化
  514.   #--------------------------------------------------------------------------
  515.   def initialize(skin, line_height)
  516.     @skin   = skin
  517.     @width  = @skin.width
  518.     @height = line_height
  519.     @line   = 1
  520.     @amount = 0
  521.     @base_sprite = Sprite.new
  522.     @base_sprite.bitmap = @skin
  523.     @base_sprite.src_rect.set(0, 0, @width, @height)
  524.     @base_sprite.z = 601
  525.     super()
  526.     self.z = @base_sprite.z + 1
  527.     self.bitmap = @skin
  528.     self.line = 1
  529.   end
  530.   #--------------------------------------------------------------------------
  531.   # ○ 値の設定
  532.   #--------------------------------------------------------------------------
  533.   def line=(n)
  534.     @line = n
  535.     refresh
  536.   end
  537.   def amount=(n)
  538.     @amount = n
  539.     refresh
  540.   end
  541.   def refresh
  542.     self.src_rect.set(0, @line * @height, @width * @amount / 100, @height)
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ○ 座標の設定
  546.   #--------------------------------------------------------------------------
  547.   def x=(n)
  548.     super
  549.     @base_sprite.x = n
  550.   end
  551.   def y=(n)
  552.     super
  553.     @base_sprite.y = n
  554.   end
  555.   #--------------------------------------------------------------------------
  556.   # ○ 解放
  557.   #--------------------------------------------------------------------------
  558.   def dispose
  559.     @base_sprite.dispose
  560.     super
  561.   end
  562. end
4CD~%8J%G%X]15BWX7U]DX0.png

Lv5.捕梦者 (版主)

梦石
1
星屑
23963
在线时间
3338 小时
注册时间
2011-7-8
帖子
3925

开拓者

发表于 2019-4-18 01:13:03 | 显示全部楼层
这段脚本的418-420行提到了在选择逃跑的适合清空全部的cp,但是和原版脚本不一样的地方是原版的逃跑是队伍技能,跟Game_BattleAction无关。

建议看看是不是哪里设置错了,按照此脚本,角色的第5个基本行动应该是逃跑。

点评

gg  发表于 2019-4-25 16:12
找了一个中午也不知道它在哪把cp值归零的==注释还全是日语..  发表于 2019-4-25 13:21
然而并不是触发这里==如果p这个部分的话就只会在逃跑的时候p出来...  发表于 2019-4-25 12:50
总之在这段代码附近p几个参数看看是不是确实触发了此处?  发表于 2019-4-24 23:35
就是说...敌人的行动也随着某个角色的行动结束重置了=  发表于 2019-4-24 13:03
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-3-29 18:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表