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

Project1

 找回密码
 注册会员
搜索
查看: 1353|回复: 2
打印 上一主题 下一主题

[已经解决] 参战的角色和敌人人数这句话要怎么写???

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1288
在线时间
354 小时
注册时间
2009-9-14
帖子
328
跳转到指定楼层
1
发表于 2015-1-24 21:26:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  1. # ▼▲▼ XRXS65. CP制御ターンシステム ver.β ▼▲▼ built 201120
  2. # by 桜雅 在土

  3. #==============================================================================
  4. # □ カスタマイズポイント
  5. #==============================================================================
  6. module XRXS65
  7.   #
  8.   # 「バトルスピード」(数値が高いほど早い)
  9.   #
  10.   SPEED = 0.5
  11.   #
  12.   # 戦闘開始時 CP。 固定値と占有率
  13.   #
  14.   CP_PRESET_FIXNUM = 0
  15.   CP_PRESET_RATIO  = 0
  16.   #
  17.   # ターンコントローラ (nil  : カウント/ターンを有効。
  18.   #                     数値 : そのインデックスをもつエネミーが支配)
  19.   #
  20.   TC = 0
  21.   #
  22.   # カウント/ターン (TCが有効な場合は無視)
  23.   #
  24.   CPT = 40
  25.   #
  26.   # CP スキン
  27.   #
  28.   SKIN        = "123"  # スキンファイル名(Graphics/Windowskinsフォルダ)
  29.   LINE_HEIGHT =  6        # スキンの"一行"の縦幅[単位:ピクセル]
  30.   #
  31.   # 表示位置セッティング
  32.   #
  33.   X_OFFSET = 144    # 横位置
  34.   Y_OFFSET = 464    # 縦位置
  35.   ALIGN    =   1    #「位置揃え」(CPメーターの位置。0:左寄せ 1:中央 2:右寄せ)
  36.   MAX      =   4    # 確保するサイズ[単位:~人分]
  37.   #
  38.   # アクターコマンドがポップしたときの効果音
  39.   #
  40.   COMMAND_UP_SE = "Audio/SE/046-Book01.ogg"
  41. end
  42. #==============================================================================
  43. # --- CP メーターの描画情報の取得 --- (Game_Battlerにインクルードされます)
  44. #==============================================================================
  45. module XRXS_CP
  46.   #--------------------------------------------------------------------------
  47.   # ○ スキンライン (スキンの何行目を使うか)
  48.   #--------------------------------------------------------------------------
  49.   def cp_linetype
  50.     # CP フルの場合はスキンの 2 行目を使う
  51.     return 2 if self.cp_full?
  52.     # 通常はスキンの 1 行目を使う
  53.     return 1
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ○ メーター量[単位:%]
  57.   #--------------------------------------------------------------------------
  58.   def cp_lineamount
  59.     # 戦闘不能の場合は 0 %として表示させる
  60.     return 0 if self.dead?
  61.     # CP値を%値に変換して返却する
  62.     return 100 * self.cp / self.max_cp
  63.   end
  64. end
  65. #
  66. # カスタマイズポイントここまで。
  67. #------------------------------------------------------------------------------



  68. #==============================================================================
  69. # --- XRXS. CP機構 ---
  70. #==============================================================================
  71. module XRXS_CP_SYSTEM
  72.   #----------------------------------------------------------------------------
  73.   # ○ 合計 AGI の取得
  74.   #----------------------------------------------------------------------------
  75.   def self.total_agi
  76.     total = 0
  77.     for battler in $game_party.actors + $game_troop.enemies
  78.       total += battler.agi
  79.     end
  80.     return total
  81.   end
  82. end
  83. #==============================================================================
  84. # --- バトラーにCP機能を追加 モジュール ---
  85. #==============================================================================
  86. module XRXS_CP
  87.   #--------------------------------------------------------------------------
  88.   # ○ 最大 CP の取得
  89.   #--------------------------------------------------------------------------
  90.   def max_cp
  91.     return 65535
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ○ CP の取得と設定
  95.   #--------------------------------------------------------------------------
  96.   def cp
  97.     return @cp == nil ? @cp = 0 : @cp
  98.   end
  99.   def cp=(n)
  100.     @cp = [[n.to_i, 0].max, self.max_cp].min
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ○ CP 初期設定
  104.   #--------------------------------------------------------------------------
  105.   def cp_preset
  106.     percent = self.max_cp * XRXS65::CP_PRESET_RATIO * (rand(16) + 16) * self.agi / XRXS_CP_SYSTEM.total_agi / 24
  107.     self.cp = XRXS65::CP_PRESET_FIXNUM + percent
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # ○ CP カウントアップ
  111.   #--------------------------------------------------------------------------
  112.   def cp_update
  113.     self.cp += XRXS65::SPEED * 4096 * self.agi / XRXS_CP_SYSTEM.total_agi
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ○ CP 満タン?
  117.   #--------------------------------------------------------------------------
  118.   def cp_full?
  119.     return @cp == self.max_cp
  120.   end
  121. end
  122. class Game_Battler
  123.   include XRXS_CP
  124. end
  125. #==============================================================================
  126. # --- ガード機能 ---
  127. #==============================================================================
  128. class Game_Battler
  129.   #--------------------------------------------------------------------------
  130.   # ○ ガードフラグ
  131.   #--------------------------------------------------------------------------
  132.   def guarding=(n)
  133.     @guarding = n
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 防御中判定 [再定義]
  137.   #--------------------------------------------------------------------------
  138.   def guarding?
  139.     return @guarding
  140.   end
  141. end
  142. #==============================================================================
  143. # --- アクター「コマンド入力可能判定」:CPがないとコマンドしない ---
  144. #==============================================================================
  145. module XRXS_CP_INPUTABLE
  146.   def inputable?
  147.     return (self.cp_full? and super)
  148.   end
  149. end
  150. class Game_Actor < Game_Battler
  151.   include XRXS_CP_INPUTABLE
  152. end
  153. #==============================================================================
  154. # --- エネミー「行動可能判定」:CPがないとコマンドしない ---
  155. #==============================================================================
  156. module XRXS_CP_MOVABLE
  157.   def movable?
  158.     return (self.cp_full? and super)
  159.   end
  160. end
  161. class Game_Enemy < Game_Battler
  162.   include XRXS_CP_MOVABLE
  163. end
  164. #==============================================================================
  165. # --- 戦闘時 CPカウント ---
  166. #==============================================================================
  167. module XRXS_CP_Battle
  168.   #--------------------------------------------------------------------------
  169.   # ○ パーティ全員の CP を初期設定
  170.   #--------------------------------------------------------------------------
  171.   def cp_preset_party
  172.     for actor in $game_party.actors
  173.       actor.cp_preset
  174.     end
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # ○ トループ全員の CP を初期設定
  178.   #--------------------------------------------------------------------------
  179.   def cp_preset_troop
  180.     for enemy in $game_troop.enemies
  181.       enemy.cp_preset
  182.     end
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ○ バトラー全員の CP をカウントアップ
  186.   #--------------------------------------------------------------------------
  187.   def cp_update
  188.     for battler in $game_party.actors + $game_troop.enemies
  189.       battler.cp_update
  190.     end
  191.   end
  192. end
  193. class Scene_Battle
  194.   include XRXS_CP_Battle
  195. end
  196. #==============================================================================
  197. # ■ Scene_Battle
  198. #==============================================================================
  199. class Scene_Battle
  200.   #--------------------------------------------------------------------------
  201.   # ● メイン処理
  202.   #--------------------------------------------------------------------------
  203.   alias xrxs65_main main
  204.   def main
  205.     # エクストラスプライトの初期化
  206.     @extra_sprites = [] if @extra_sprites == nil
  207.     # CP の初期化
  208.     cp_preset_party
  209.     # CP メーターの作成
  210.     @cp_meters = CP_Meters.new
  211.     # CP メーターをエクストラスプライトへ登録
  212.     @extra_sprites.push(@cp_meters)
  213.     # 呼び戻す
  214.     xrxs65_main
  215.     # メーターの解放
  216.     @cp_meters.dispose
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● プレバトルフェーズ開始
  220.   #--------------------------------------------------------------------------
  221.   alias xrxs65_start_phase1 start_phase1
  222.   def start_phase1
  223.     # 呼び戻す
  224.     xrxs65_start_phase1
  225.     # CP の初期化
  226.     cp_preset_troop
  227.     # CP メーターの更新
  228.     @cp_meters.refresh
  229.     # インデックスを計算
  230.     @cp_escape_actor_command_index = @actor_command_window.height/32 - 1
  231.     # アクターコマンドウィンドウに追加
  232.   end
  233.   #--------------------------------------------------------------------------
  234.   # ● パーティコマンドフェーズ開始
  235.   #--------------------------------------------------------------------------
  236.   alias xrxs65_start_phase2 start_phase2
  237.   def start_phase2
  238.     # 呼び戻す
  239.     xrxs65_start_phase2
  240.     # パーティコマンドウィンドウを無効化
  241.     @party_command_window.active  = false
  242.     @party_command_window.visible = false
  243.     # 強制的にフェイズ 2 を保持
  244.     @phase = 2
  245.     # ただし、既に行動可能者が存在する場合は 3 へ
  246.     start_phase3 if anybody_movable?
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ○ CP制での ターンのカウント
  250.   #--------------------------------------------------------------------------
  251.   def cp_turn_count
  252.     $game_temp.battle_turn += 1
  253.     # バトルイベントの全ページを検索
  254.     for index in 0...$data_troops[@troop_id].pages.size
  255.       # このページのスパンが [ターン] の場合
  256.       if $data_troops[@troop_id].pages[index].span == 1
  257.         # 実行済みフラグをクリア
  258.         $game_temp.battle_event_flags[index] = false
  259.       end
  260.     end
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● フレーム更新 (パーティコマンドフェーズ)
  264.   #--------------------------------------------------------------------------
  265.   alias xrxs65_update_phase2 update_phase2
  266.   def update_phase2
  267.     # パーティコマンドウィンドウのインデックスを無効化
  268.     @party_command_window.index = -1
  269.     # 呼び戻す
  270.     xrxs65_update_phase2
  271.     # 例外補正
  272.     @turn_count_time = 1 if @turn_count_time == nil
  273.     # ターンのカウント
  274.     if @turn_count_time > 0
  275.       @turn_count_time -= 1
  276.       if @turn_count_time == 0
  277.         cp_turn_count
  278.         @turn_count_time = XRXS65::CPT if XRXS65::TC == nil
  279.       end
  280.     end
  281.     # CP のフレーム更新
  282.     cp_update
  283.     @cp_meters.refresh
  284.     # フル CP のバトラーが存在する場合、ターン開始
  285.     start_phase3 if anybody_movable?
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ○ フル CP バトラーが存在するか?
  289.   #--------------------------------------------------------------------------
  290.   def anybody_movable?
  291.     for battler in $game_party.actors + $game_troop.enemies
  292.       return true if battler.cp_full?
  293.     end
  294.     return false
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● アクターコマンドウィンドウのセットアップ
  298.   #--------------------------------------------------------------------------
  299.   alias xrxs65_phase3_setup_command_window phase3_setup_command_window
  300.   def phase3_setup_command_window
  301.     # 効果音の再生
  302.     Audio.se_play(XRXS65::COMMAND_UP_SE) rescue nil
  303.     # 呼び戻す
  304.     xrxs65_phase3_setup_command_window
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド)
  308.   #--------------------------------------------------------------------------
  309.   alias xrxs_bsp1_update_phase3_basic_command update_phase3_basic_command
  310.   def update_phase3_basic_command
  311.     # C ボタンが押された場合
  312.     if Input.trigger?(Input::C)
  313.       # アクターコマンドウィンドウのカーソル位置で分岐
  314.       case @actor_command_window.index
  315.       when @cp_escape_actor_command_index # 逃げる
  316.         if $game_temp.battle_can_escape
  317.           # 決定 SE を演奏
  318.           $game_system.se_play($data_system.decision_se)
  319.           # アクションを設定
  320.           @active_battler.current_action.kind = 0
  321.           @active_battler.current_action.basic = 4
  322.           # 次のアクターのコマンド入力へ
  323.           phase3_next_actor
  324.         else
  325.           # ブザー SE を演奏
  326.           $game_system.se_play($data_system.buzzer_se)
  327.         end
  328.         return
  329.       end
  330.     end
  331.     # 呼び戻す
  332.     xrxs_bsp1_update_phase3_basic_command
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ● メインフェーズ開始
  336.   #--------------------------------------------------------------------------
  337.   alias xrxs65_start_phase4 start_phase4
  338.   def start_phase4
  339.     # ターン数を引くことによって擬似的にカウントに変化を起こさせない
  340.     $game_temp.battle_turn -= 1
  341.     # フラグを退避
  342.     save_flags = $game_temp.battle_event_flags.dup
  343.     # 呼び戻す
  344.     xrxs65_start_phase4
  345.     # フラグを復旧
  346.     $game_temp.battle_event_flags = save_flags
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # ● 行動順序作成
  350.   #--------------------------------------------------------------------------
  351.   alias xrxs65_make_action_orders make_action_orders
  352.   def make_action_orders
  353.     # 呼び戻す
  354.     xrxs65_make_action_orders
  355.     # CPが不足している場合は @action_battlers から除外する
  356.     for battler in @action_battlers.dup
  357.       @action_battlers.delete(battler) unless battler.cp_full?
  358.     end
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  362.   #--------------------------------------------------------------------------
  363.   alias xrxs65_update_phase4_step2 update_phase4_step2
  364.   def update_phase4_step2
  365.     # ガードの解除
  366.     @active_battler.guarding = false
  367.     # CPの消費
  368.     @active_battler.cp = 0
  369.     # CP メーターの更新
  370.     @cp_meters.refresh
  371.     # 呼び戻す
  372.     xrxs65_update_phase4_step2
  373.     # 例外補正
  374.     return if @active_battler == nil
  375.     # ターンコントローラ
  376.     if @active_battler.is_a?(Game_Enemy) and @active_battler.index == XRXS65::TC
  377.       cp_turn_count
  378.     end
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # ● 基本アクション 結果作成
  382.   #--------------------------------------------------------------------------
  383.   alias xrxs65_make_basic_action_result make_basic_action_result
  384.   def make_basic_action_result
  385.     # 呼び戻す
  386.     xrxs65_make_basic_action_result
  387.     # 防御の場合
  388.     if @active_battler.current_action.basic == 1
  389.       @active_battler.guarding = true
  390.       return
  391.     end
  392.     # パーティの逃亡の場合
  393.     if @active_battler.current_action.basic == 4
  394.       # 逃走可能ではない場合
  395.       if $game_temp.battle_can_escape == false
  396.         # ブザー SE を演奏
  397.         $game_system.se_play($data_system.buzzer_se)
  398.         return
  399.       end
  400.       # パーティ全員の CP をクリア
  401.       for actor in $game_party.actors
  402.         actor.cp = 0
  403.       end
  404.       # CP メーターの更新
  405.       @cp_meters.refresh
  406.       # 逃走処理
  407.       update_phase2_escape
  408.       return
  409.     end
  410.   end
  411.   #--------------------------------------------------------------------------
  412.   # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  413.   #--------------------------------------------------------------------------
  414.   alias xrxs65_update_phase4_step5 update_phase4_step5
  415.   def update_phase4_step5
  416.     # 呼び戻す
  417.     xrxs65_update_phase4_step5
  418.     # CP メーターの更新
  419.     @cp_meters.refresh
  420.   end
  421. end
  422. #==============================================================================
  423. # --- CP メーターをまとめて管理するクラス、表示関係はすべてココ ---
  424. #==============================================================================
  425. class CP_Meters
  426.   #--------------------------------------------------------------------------
  427.   # ○ オブジェクト初期化
  428.   #--------------------------------------------------------------------------
  429.   def initialize
  430.     # メーター群の生成
  431.     @meters = []
  432.     for i in 0...$game_party.actors.size
  433.       make_meter(i)
  434.     end
  435.     refresh
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ○ リフレッシュ
  439.   #--------------------------------------------------------------------------
  440.   def refresh
  441.     # 戦闘メンバー数の変更を判別
  442.     for i in @meters.size...$game_party.actors.size
  443.       make_meter(i)
  444.     end
  445.     for i in [email protected]
  446.       @meters[i].dispose
  447.       @meters[i] = nil
  448.     end
  449.     @meters.compact!
  450.     # 表示更新
  451.     for i in 0...$game_party.actors.size
  452.       actor = $game_party.actors[i]
  453.       @meters[i].line   = actor.cp_linetype
  454.       @meters[i].amount = actor.cp_lineamount
  455.     end
  456.   end
  457.   #--------------------------------------------------------------------------
  458.   # ○ メーターひとつの生成
  459.   #--------------------------------------------------------------------------
  460.   def make_meter(i)
  461.     # スキンの取得
  462.     skin = RPG::Cache.windowskin(XRXS65::SKIN)
  463.     #
  464.     space = 640 / XRXS65::MAX
  465.     case XRXS65::ALIGN
  466.     when 0
  467.       actor_x = i * space + 4
  468.     when 1
  469.       actor_x = (space * ((XRXS65::MAX - $game_party.actors.size)/2.0 + i)).floor
  470.     when 2
  471.       actor_x = (i + XRXS65::MAX - $game_party.actors.size) * space + 4
  472.     end
  473.     meter = MeterSprite.new(skin, XRXS65::LINE_HEIGHT)
  474.     meter.x = actor_x + XRXS65::X_OFFSET - skin.width
  475.     meter.y = XRXS65::Y_OFFSET
  476.     @meters[i] = meter
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ○ 可視状態
  480.   #--------------------------------------------------------------------------
  481.   def visible=(b)
  482.     @meters.each{|sprite| sprite.visible = b }
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # ○ 解放
  486.   #--------------------------------------------------------------------------
  487.   def dispose
  488.     @meters.each{|sprite| sprite.dispose }
  489.   end
  490. end
  491. #==============================================================================
  492. # --- XRXS. レクタンギュラーメーター表示・極 ---
  493. #==============================================================================
  494. class MeterSprite < Sprite
  495.   #--------------------------------------------------------------------------
  496.   # ○ オブジェクト初期化
  497.   #--------------------------------------------------------------------------
  498.   def initialize(skin, line_height)
  499.     [url=home.php?mod=space&uid=81523]@skin[/url]   = skin
  500.     @width  = @skin.width
  501.     [url=home.php?mod=space&uid=291977]@height[/url] = line_height
  502.     [url=home.php?mod=space&uid=401263]@line[/url]   = 1
  503.     @amount = 0
  504.     @base_sprite = Sprite.new
  505.     @base_sprite.bitmap = @skin
  506.     @base_sprite.src_rect.set(0, 0, @width, @height)
  507.     @base_sprite.z = 601
  508.     super()
  509.     self.z = @base_sprite.z + 1
  510.     self.bitmap = @skin
  511.     self.line = 1
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # ○ 値の設定
  515.   #--------------------------------------------------------------------------
  516.   def line=(n)
  517.     @line = n
  518.     refresh
  519.   end
  520.   def amount=(n)
  521.     @amount = n
  522.     refresh
  523.   end
  524.   def refresh
  525.     self.src_rect.set(0, @line * @height, @width * @amount / 100, @height)
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   # ○ 座標の設定
  529.   #--------------------------------------------------------------------------
  530.   def x=(n)
  531.     super
  532.     @base_sprite.x = n
  533.   end
  534.   def y=(n)
  535.     super
  536.     @base_sprite.y = n
  537.   end
  538.   #--------------------------------------------------------------------------
  539.   # ○ 解放
  540.   #--------------------------------------------------------------------------
  541.   def dispose
  542.     @base_sprite.dispose
  543.     super
  544.   end
  545. end

复制代码

Lv3.寻梦者

梦石
0
星屑
1288
在线时间
354 小时
注册时间
2009-9-14
帖子
328
2
 楼主| 发表于 2015-1-24 21:28:30 | 只看该作者
我用了这个CP脚本,,,后来我发现如果参加战斗的人数越多,集齐的速度就越慢,,,如果敌我一共十多个人,那没回合集齐都要等半天。。。
后来我发现集齐速度的公式是这样的
self.cp += XRXS65::SPEED * 4096 * self.agi / XRXS_CP_SYSTEM.total_agi

因为除以XRXS_CP_SYSTEM.total_agi,,所以参战人数越多集齐的速度就越慢。。
我想要XRXS_CP_SYSTEM.total_agi除一下参战的敌我总人数,要怎么写?
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1288
在线时间
354 小时
注册时间
2009-9-14
帖子
328
3
 楼主| 发表于 2015-1-24 21:37:21 | 只看该作者
已经自己解决了,,,
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 15:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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