查看: 1839|回复: 0

[已经过期] CP制战斗脚本与换人、怒气脚本冲突

[复制链接]
梦石
0
星屑
50
在线时间
41 小时
注册时间
2013-10-27
回帖
13
发表于 2014-11-16 12:38:19 | 显示全部楼层 |阅读模式

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

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

×
CP制战斗脚本加入以后,发现每个角色的怒气槽变成了几万多,但是轮到某个角色攻击的时候,怒气槽又恢复到10,但是过了回合之后又变成几万多,这是怎么回事,加了CP制战斗脚本后,换人按钮按去按去没反应,只有角色死亡之后才会自动显示换人界面o(╯□╰)o,放脚本,请大大们解答
这是换人脚本
  1. module LimBattlePlug

  2. # 队伍最大人数
  3. MaxPartySize = 12

  4. # 出战人数
  5. MaxBattlerSize = 4

  6. # 换人语句
  7. WordChangeBattler = "换人"

  8. # 换人时播放的动画
  9. AnimationChangeBattler = 26

  10. end

  11. class Game_BattleAction
  12.   attr_accessor :change_to_battler
  13.   # 初始化
  14.   alias lbp_initialize initialize
  15.   def initialize
  16.     lbp_initialize
  17.     @change_to_battler = 0
  18.   end
  19.   # 欲更换角色编号
  20.   def set_change_battler
  21.     @kind = 3
  22.   end
  23.   # 判断行动是否为更换角色
  24.   def is_change_battler?
  25.     return (@kind == 3)
  26.   end
  27. end

  28. class Game_Party
  29.   include LimBattlePlug
  30.   attr_reader :actors2
  31.   alias lpb_initialize initialize
  32.   def initialize
  33.     lpb_initialize
  34.     @actors2 = []
  35.   end
  36.   # 角色加入
  37.   def add_actor(actor_id)
  38.     actor = $game_actors[actor_id]
  39.     if @actors.size < MaxPartySize and not @actors.include?(actor)
  40.       @actors.push(actor)
  41.       $game_player.refresh
  42.     end
  43.   end
  44.   # 设置战斗的角色
  45.   def set_actor_to_battle
  46.     @actors2 = []
  47.     @actors.each do |actor|
  48.       @actors2.push(actor)
  49.     end
  50.     @actors = []
  51.     dead_actor = []
  52.     @actors2.each do |actor|
  53.       if !actor.dead?
  54.         @actors.push(actor)
  55.       else
  56.         dead_actor.push(actor)
  57.       end
  58.       break if @actors.size == MaxBattlerSize
  59.     end
  60.     if @actors.size < MaxBattlerSize
  61.       for actor in dead_actor
  62.         @actors.push(actor)
  63.         break if @actors.size == MaxBattlerSize
  64.       end
  65.     end
  66.   end
  67.   # 还原战斗的角色
  68.   def set_actor_to_normal
  69.     @actors = []
  70.     @actors2.each do |actor|
  71.       @actors.push(actor)
  72.     end
  73.   end
  74.   # 获取角色id数组
  75.   def get_actors_id
  76.     id = []
  77.     @actors.each{|actor|id.push(actor.id)}
  78.     return id
  79.   end
  80.   # 获取角色id数组
  81.   def get_actors2_id
  82.     id = []
  83.     @actors2.each{|actor|id.push(actor.id)}
  84.     return id
  85.   end
  86.   # 兑换角色
  87.   def change_actor(index,id)
  88.     @actors[index] = $game_actors[id]
  89.   end
  90.   # 全灭判定
  91.   def all_dead?
  92.     # 同伴人数为 0 的情况下
  93.     if $game_party.actors.size == 0
  94.       return false
  95.     end
  96.     # 同伴中无人 HP 在 0 以上
  97.     for actor in @actors2
  98.       if actor.hp > 0
  99.         return false
  100.       end
  101.     end
  102.     for actor in @actors
  103.       if actor.hp > 0
  104.         return false
  105.       end
  106.     end
  107.     # 全灭
  108.     return true
  109.   end
  110.   # 其他角色
  111.   def other_actors
  112.     actors = []
  113.     @actors2.each{|actor|actors.push(actor) if !@actors.include?(actor)}
  114.     return actors
  115.   end
  116.   # 角色位置互换
  117.   def change_actor_pos(id1,id2)
  118.     actor_id = []
  119.     @actors.each do |actor|
  120.       actor_id.push(actor.id)
  121.     end
  122.     return if !actor_id.include?(id1) and !actor_id.include?(id2)
  123.     id1_index = id2_index = -1
  124.     (0...actor_id.size).each do |i|
  125.       if actor_id[i] == id1
  126.         id1_index = i
  127.       elsif actor_id[i] == id2
  128.         id2_index = i
  129.       end
  130.     end
  131.     temp_actor = @actors[id1_index]
  132.     @actors[id1_index] = @actors[id2_index]
  133.     @actors[id2_index] = temp_actor
  134.   end
  135. end

  136. class Window_Actor < Window_Selectable
  137.   # 初始化
  138.   def initialize
  139.     super(0,64,640,256)
  140.     self.back_opacity = 160
  141.     refresh
  142.     self.index = -1
  143.     self.active = false
  144.   end
  145.   # 刷新
  146.   def refresh
  147.     @item_max = $game_party.actors2.size
  148.     @data = []
  149.     $game_party.actors.each do |actor|
  150.       @data.push(actor)
  151.     end
  152.     $game_party.actors2.each do |actor|
  153.       @data.push(actor) if !@data.include?(actor)
  154.     end
  155.     if self.contents != nil
  156.       self.contents.clear
  157.       self.contents = nil
  158.     end
  159.     self.contents = Bitmap.new(608,@data.size*32)
  160.     x = 4
  161.     y = 0
  162.     @data.each do |actor|
  163.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  164.       rect = Rect.new(0,0,bitmap.width/4,31)
  165.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
  166.       draw_actor_name(actor,x+36,y)
  167.       draw_actor_state(actor,156,y)
  168.       draw_actor_hp(actor,x+256,y,96)
  169.       draw_actor_sp(actor,x+376,y,96)
  170.       if $game_party.actors.include?(actor)
  171.         self.contents.font.color = text_color(6)
  172.         cword = "出战"
  173.       else
  174.         self.contents.font.color = text_color(0)
  175.         cword = "待战"
  176.       end
  177.       self.contents.draw_text(x+496,y,60,32,cword)
  178.       y += 32
  179.     end
  180.   end
  181.   # 获取当前角色编号
  182.   def actor_id
  183.     return @data[self.index].id
  184.   end
  185.   # 刷新帮助
  186.   def update_help
  187.     @help_window.set_text(@data[self.index] == nil ?\
  188.                           "" : @data[self.index].name)
  189.   end
  190. end

  191. class Scene_Battle
  192.   include LimBattlePlug
  193.   # 初始化
  194.   def initialize
  195.     $game_party.set_actor_to_battle
  196.   end
  197.   # 主处理
  198.   def main
  199.     # 初始化战斗用的各种暂时数据
  200.     $game_temp.in_battle = true
  201.     $game_temp.battle_turn = 0
  202.     $game_temp.battle_event_flags.clear
  203.     $game_temp.battle_abort = false
  204.     $game_temp.battle_main_phase = false
  205.     $game_temp.battleback_name = $game_map.battleback_name
  206.     $game_temp.forcing_battler = nil
  207.     # 初始化战斗用事件解释器
  208.     $game_system.battle_interpreter.setup(nil, 0)
  209.     # 准备队伍
  210.     @troop_id = $game_temp.battle_troop_id
  211.     $game_troop.setup(@troop_id)
  212.     # 生成角色命令窗口
  213.     s1 = $data_system.words.attack
  214.     s2 = $data_system.words.skill
  215.     s3 = $data_system.words.guard
  216.     s4 = $data_system.words.item
  217.     s5 = WordChangeBattler
  218.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4,s5])
  219.     @actor_command_window.y = 128
  220.     @actor_command_window.back_opacity = 160
  221.     @actor_command_window.active = false
  222.     @actor_command_window.visible = false
  223.     # 生成其它窗口
  224.     @party_command_window = Window_PartyCommand.new
  225.     @help_window = Window_Help.new
  226.     @help_window.back_opacity = 160
  227.     @help_window.visible = false
  228.     @status_window = Window_BattleStatus.new
  229.     @message_window = Window_Message.new
  230.     # 生成活动块
  231.     @spriteset = Spriteset_Battle.new
  232.     # 初始化等待计数
  233.     @wait_count = 0
  234.     # 执行过渡
  235.     if $data_system.battle_transition == ""
  236.       Graphics.transition(20)
  237.     else
  238.       Graphics.transition(40, "Graphics/Transitions/" +
  239.         $data_system.battle_transition)
  240.     end
  241.     # 开始自由战斗回合
  242.     start_phase1
  243.     # 主循环
  244.     loop do
  245.       # 刷新游戏画面
  246.       Graphics.update
  247.       # 刷新输入信息
  248.       Input.update
  249.       # 刷新画面
  250.       update
  251.       # 如果画面切换的话就中断循环
  252.       if $scene != self
  253.         break
  254.       end
  255.     end
  256.     # 刷新地图
  257.     $game_map.refresh
  258.     # 准备过渡
  259.     Graphics.freeze
  260.     # 释放窗口
  261.     @actor_command_window.dispose
  262.     @party_command_window.dispose
  263.     @help_window.dispose
  264.     @status_window.dispose
  265.     @message_window.dispose
  266.     if @skill_window != nil
  267.       @skill_window.dispose
  268.     end
  269.     if @item_window != nil
  270.       @item_window.dispose
  271.     end
  272.     if @actor_window != nil
  273.       @actor_window.dispose
  274.     end
  275.     if @result_window != nil
  276.       @result_window.dispose
  277.     end
  278.     # 释放活动块
  279.     @spriteset.dispose
  280.     # 标题画面切换中的情况
  281.     if $scene.is_a?(Scene_Title)
  282.       # 淡入淡出画面
  283.       Graphics.transition
  284.       Graphics.freeze
  285.     end
  286.     # 战斗测试或者游戏结束以外的画面切换中的情况
  287.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  288.       $scene = nil
  289.     end
  290.   end
  291.   # 战斗结束
  292.   alias lpb_battle_end battle_end
  293.   def battle_end(n)
  294.     lpb_battle_end(n)
  295.     $game_party.set_actor_to_normal
  296.   end
  297.   # 开始回合3
  298.   alias lbp_start_phase3 start_phase3
  299.   def start_phase3
  300.     @changed_battler_id = []
  301.     lbp_start_phase3
  302.   end
  303.   # 刷新角色命令回合画面
  304.   def update_phase3
  305.     # 敌人光标有效的情况下
  306.     if @enemy_arrow != nil
  307.       update_phase3_enemy_select
  308.     # 角色光标有效的情况下
  309.     elsif @actor_arrow != nil
  310.       update_phase3_actor_select
  311.     # 特技窗口有效的情况下
  312.     elsif @skill_window != nil
  313.       update_phase3_skill_select
  314.     # 物品窗口有效的情况下
  315.     elsif @item_window != nil
  316.       update_phase3_item_select
  317.     elsif @actor_window != nil
  318.       update_phase3_battler_select
  319.     # 角色指令窗口有效的情况下
  320.     elsif @actor_command_window.active
  321.       update_phase3_basic_command
  322.     end
  323.   end
  324.   # 角色基本命令
  325.   def update_phase3_basic_command
  326.     # 按下 B 键的情况下
  327.     if Input.trigger?(Input::B)
  328.       # 演奏取消 SE
  329.       $game_system.se_play($data_system.cancel_se)
  330.       # 转向前一个角色的指令输入
  331.       phase3_prior_actor
  332.       return
  333.     end
  334.     # 按下 C 键的情况下
  335.     if Input.trigger?(Input::C)
  336.       # 角色指令窗口光标位置分之
  337.       case @actor_command_window.index
  338.       when 0  # 攻击
  339.         # 演奏确定 SE
  340.         $game_system.se_play($data_system.decision_se)
  341.         # 设置行动
  342.         @active_battler.current_action.kind = 0
  343.         @active_battler.current_action.basic = 0
  344.         # 开始选择敌人
  345.         start_enemy_select
  346.       when 1  # 特技
  347.         # 演奏确定 SE
  348.         $game_system.se_play($data_system.decision_se)
  349.         # 设置行动
  350.         @active_battler.current_action.kind = 1
  351.         # 开始选择特技
  352.         start_skill_select
  353.       when 2  # 防御
  354.         # 演奏确定 SE
  355.         $game_system.se_play($data_system.decision_se)
  356.         # 设置行动
  357.         @active_battler.current_action.kind = 0
  358.         @active_battler.current_action.basic = 1
  359.         # 转向下一位角色的指令输入
  360.         phase3_next_actor
  361.       when 3  # 物品
  362.         # 演奏确定 SE
  363.         $game_system.se_play($data_system.decision_se)
  364.         # 设置行动
  365.         @active_battler.current_action.kind = 2
  366.         # 开始选择物品
  367.         start_item_select
  368.       when 4 # 换人
  369.         $game_system.se_play($data_system.decision_se)
  370.         @active_battler.current_action.set_change_battler
  371.         start_battler_select
  372.       end
  373.       return
  374.     end
  375.   end
  376.   # 开始角色选择
  377.   def start_battler_select
  378.     @actor_window = Window_Actor.new
  379.     @actor_window.active = true
  380.     @actor_window.index = 0
  381.     @actor_window.help_window = @help_window
  382.     @actor_command_window.active = false
  383.     @actor_command_window.visible = false
  384.   end
  385.   # 结束角色选择
  386.   def end_battler_select
  387.     @actor_window.dispose
  388.     @actor_window = nil
  389.     @help_window.visible = false
  390.     @actor_command_window.active = true
  391.     @actor_command_window.visible = true
  392.   end
  393.   # 刷新角色选择
  394.   def update_phase3_battler_select
  395.     @actor_window.visible = true
  396.     @actor_window.update
  397.     if Input.trigger?(Input::B)
  398.       $game_system.se_play($data_system.cancel_se)
  399.       end_battler_select
  400.       return
  401.     end
  402.     if Input.trigger?(Input::C)
  403.       actor_id = @actor_window.actor_id
  404.       if $game_party.get_actors_id.include?(actor_id) or
  405.          $game_actors[actor_id].dead? or
  406.          @changed_battler_id.include?(actor_id)
  407.         $game_system.se_play($data_system.buzzer_se)
  408.         return
  409.       end
  410.       $game_system.se_play($data_system.decision_se)
  411.       @active_battler.current_action.change_to_battler = actor_id
  412.       @changed_battler_id.push(actor_id)
  413.       end_battler_select
  414.       phase3_next_actor
  415.       return
  416.     end
  417.   end
  418.   # 行动方动画
  419.   def update_phase4_step3
  420.     if @active_battler.current_action.is_change_battler?
  421.       @animation1_id = AnimationChangeBattler
  422.       @target_battlers = []
  423.     end
  424.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  425.     if @animation1_id == 0
  426.       @active_battler.white_flash = true
  427.     else
  428.       @active_battler.animation_id = @animation1_id
  429.       @active_battler.animation_hit = true
  430.     end
  431.     # 移至步骤 4
  432.     @phase4_step = 4
  433.   end
  434.   # 对象方动画
  435.   def update_phase4_step4
  436.     if @active_battler.current_action.is_change_battler?
  437.       actor1_id = @active_battler.current_action.change_to_battler
  438.       actor2_id = @active_battler.id
  439.       (0...$game_party.actors.size).each do |i|
  440.         if $game_party.actors[i].id == actor2_id
  441.           $game_party.change_actor(i,actor1_id)
  442.           @active_battler = $game_actors[actor1_id]
  443.           @status_window.refresh
  444.         end
  445.       end
  446.     end
  447.     # 对像方动画
  448.     for target in @target_battlers
  449.       target.animation_id = @animation2_id
  450.       target.animation_hit = (target.damage != "Miss")
  451.     end
  452.     # 限制动画长度、最低 8 帧
  453.     @wait_count = 8
  454.     # 移至步骤 5
  455.     @phase4_step = 5
  456.   end
  457.   # 公共事件
  458.   def update_phase4_step6
  459.     @target_battlers.each do |target|
  460.       if target.is_a?(Game_Actor) and target.dead? and
  461.          !$game_party.other_actors.all?{|actor|actor.dead?}
  462.         @actor_window = Window_Actor.new
  463.         @actor_window.index = 0
  464.         @actor_window.active = true
  465.         @actor_window.help_window = @help_window
  466.         actor_id = -1
  467.         loop do
  468.           Graphics.update
  469.           Input.update
  470.           @actor_window.update
  471.           if Input.trigger?(Input::C)
  472.             actor = $game_actors[@actor_window.actor_id]
  473.             if actor.dead? or
  474.                (@changed_battler_id.include?(actor.id) and
  475.                 target.current_action.change_to_battler != actor.id) or
  476.                $game_party.actors.include?(actor)
  477.               $game_system.se_play($data_system.buzzer_se)
  478.             else
  479.               actor_id = actor.id
  480.             end
  481.           end
  482.           break if actor_id >= 0
  483.         end
  484.         @actor_window.visible = false
  485.         @actor_window.dispose
  486.         @actor_window = nil
  487.         @help_window.visible = false
  488.         (0...$game_party.actors.size).each do |i|
  489.           if $game_party.actors[i].id == target.id
  490.             $game_party.change_actor(i,actor_id)
  491.             @status_window.refresh
  492.           end
  493.         end
  494.       end
  495.     end
  496.     # 清除强制行动对像的战斗者
  497.     $game_temp.forcing_battler = nil
  498.     # 公共事件 ID 有效的情况下
  499.     if @common_event_id > 0
  500.       # 设置事件
  501.       common_event = $data_common_events[@common_event_id]
  502.       $game_system.battle_interpreter.setup(common_event.list, 0)
  503.     end
  504.     # 移至步骤 1
  505.     @phase4_step = 1
  506.   end
  507. end

  508. class Window_MenuStatus
  509.   def refresh
  510.     self.contents.clear
  511.     @item_max = $game_party.actors.size
  512.     for i in 0...$game_party.actors.size
  513.       x = 4
  514.       y = i * 32
  515.       actor = $game_party.actors[i]
  516.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  517.       rect = Rect.new(0,0,bitmap.width/4,31)
  518.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
  519.       draw_actor_name(actor, x+36, y)
  520.       draw_actor_state(actor, x + 136,y)
  521.       draw_actor_hp(actor, x + 236, y,96)
  522.       draw_actor_sp(actor, x + 336, y,96)
  523.     end
  524.   end
  525.   def update_cursor_rect
  526.     super
  527.   end
  528. end
复制代码

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

  3. #==============================================================================
  4. # □ カスタマイズポイント
  5. #==============================================================================
  6. module XRXS65
  7.   #
  8.   # 「バトルスピード」(数値が高いほど早い)
  9.   #
  10.   SPEED = 4.0
  11.   #
  12.   # 戦闘開始時 CP。 固定値と占有率
  13.   #
  14.   CP_PRESET_FIXNUM = 0
  15.   CP_PRESET_RATIO  = 2.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      =   12   # 確保するサイズ[単位:~人分]
  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.     self.cp = [self.cp,self.max_cp].min
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ○ CP 満タン?
  118.   #--------------------------------------------------------------------------
  119.   def cp_full?
  120.     return @cp == self.max_cp
  121.   end
  122. end
  123. class Game_Battler
  124.   include XRXS_CP
  125. end
  126. #==============================================================================
  127. # --- ガード機能 ---
  128. #==============================================================================
  129. class Game_Battler
  130.   #--------------------------------------------------------------------------
  131.   # ○ ガードフラグ
  132.   #--------------------------------------------------------------------------
  133.   def guarding=(n)
  134.     @guarding = n
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 防御中判定 [再定義]
  138.   #--------------------------------------------------------------------------
  139.   def guarding?
  140.     return @guarding
  141.   end
  142. end
  143. #==============================================================================
  144. # --- アクター「コマンド入力可能判定」:CPがないとコマンドしない ---
  145. #==============================================================================
  146. module XRXS_CP_INPUTABLE
  147.   def inputable?
  148.     return (self.cp_full? and super)
  149.   end
  150. end
  151. class Game_Actor < Game_Battler
  152.   include XRXS_CP_INPUTABLE
  153. end
  154. #==============================================================================
  155. # --- エネミー「行動可能判定」:CPがないとコマンドしない ---
  156. #==============================================================================
  157. module XRXS_CP_MOVABLE
  158.   def movable?
  159.     return (self.cp_full? and super)
  160.   end
  161. end
  162. class Game_Enemy < Game_Battler
  163.   include XRXS_CP_MOVABLE
  164. end
  165. #==============================================================================
  166. # --- 戦闘時 CPカウント ---
  167. #==============================================================================
  168. module XRXS_CP_Battle
  169.   #--------------------------------------------------------------------------
  170.   # ○ パーティ全員の CP を初期設定
  171.   #--------------------------------------------------------------------------
  172.   def cp_preset_party
  173.     for actor in $game_party.actors
  174.       actor.cp_preset
  175.     end
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ○ トループ全員の CP を初期設定
  179.   #--------------------------------------------------------------------------
  180.   def cp_preset_troop
  181.     for enemy in $game_troop.enemies
  182.       enemy.cp_preset
  183.     end
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ○ バトラー全員の CP をカウントアップ
  187.   #--------------------------------------------------------------------------
  188.   def cp_update
  189.     for battler in $game_party.actors + $game_troop.enemies
  190.       battler.cp_update
  191.     end
  192.   end
  193. end
  194. class Scene_Battle
  195.   include XRXS_CP_Battle
  196. end
  197. #==============================================================================
  198. # ■ Scene_Battle
  199. #==============================================================================
  200. class Scene_Battle
  201.   #--------------------------------------------------------------------------
  202.   # ● メイン処理
  203.   #--------------------------------------------------------------------------
  204.   alias xrxs65_main main
  205.   def main
  206.     # エクストラスプライトの初期化
  207.     @extra_sprites = [] if @extra_sprites == nil
  208.     # CP の初期化
  209.     cp_preset_party
  210.     # CP メーターの作成
  211.     @cp_meters = CP_Meters.new
  212.     # CP メーターをエクストラスプライトへ登録
  213.     @extra_sprites.push(@cp_meters)
  214.     # 呼び戻す
  215.     xrxs65_main
  216.     # メーターの解放
  217.     @cp_meters.dispose
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● プレバトルフェーズ開始
  221.   #--------------------------------------------------------------------------
  222.   
  223. alias xrxs65_start_phase1 start_phase1
  224.   def start_phase1
  225.     # 呼び戻す
  226.     xrxs65_start_phase1
  227.     # CP の初期化
  228.     cp_preset_troop
  229.     # CP メーターの更新
  230.     @cp_meters.refresh
  231.     # インデックスを計算
  232.     @cp_escape_actor_command_index = 4#@actor_command_window.height/32 - 1
  233.     # アクターコマンドウィンドウに追加
  234.     #@actor_command_window.add_command("逃跑")
  235.     #if !$game_temp.battle_can_escape
  236.     #  @actor_command_window.disable_item(@cp_escape_actor_command_index)
  237.     #end
  238.   end

  239.   #--------------------------------------------------------------------------
  240.   # ● パーティコマンドフェーズ開始
  241.   #--------------------------------------------------------------------------
  242.   alias xrxs65_start_phase2 start_phase2
  243.   def start_phase2
  244.     # 呼び戻す
  245.     xrxs65_start_phase2
  246.     # パーティコマンドウィンドウを無効化
  247.     @party_command_window.active  = false
  248.     @party_command_window.visible = false
  249.     # 強制的にフェイズ 2 を保持
  250.     @phase = 2
  251.     # ただし、既に行動可能者が存在する場合は 3 へ
  252.     start_phase3 if anybody_movable?
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ○ CP制での ターンのカウント
  256.   #--------------------------------------------------------------------------
  257.   def cp_turn_count
  258.     $game_temp.battle_turn += 1
  259.     # バトルイベントの全ページを検索
  260.     for index in 0...$data_troops[@troop_id].pages.size
  261.       # このページのスパンが [ターン] の場合
  262.       if $data_troops[@troop_id].pages[index].span == 1
  263.         # 実行済みフラグをクリア
  264.         $game_temp.battle_event_flags[index] = false
  265.       end
  266.     end
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● フレーム更新 (パーティコマンドフェーズ)
  270.   #--------------------------------------------------------------------------
  271.   alias xrxs65_update_phase2 update_phase2
  272.   def update_phase2
  273.     # パーティコマンドウィンドウのインデックスを無効化
  274.     @party_command_window.index = -1
  275.     # 呼び戻す
  276.     xrxs65_update_phase2
  277.     # 例外補正
  278.     @turn_count_time = 1 if @turn_count_time == nil
  279.     # ターンのカウント
  280.     if @turn_count_time > 0
  281.       @turn_count_time -= 1
  282.       if @turn_count_time == 0
  283.         cp_turn_count
  284.         @turn_count_time = XRXS65::CPT if XRXS65::TC == nil
  285.       end
  286.     end
  287.     # CP のフレーム更新
  288.     cp_update
  289.     @cp_meters.refresh
  290.     # フル CP のバトラーが存在する場合、ターン開始
  291.     start_phase3 if anybody_movable?
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ○ フル CP バトラーが存在するか?
  295.   #--------------------------------------------------------------------------
  296.   def anybody_movable?
  297.     for battler in $game_party.actors + $game_troop.enemies
  298.       return true if battler.cp_full?
  299.     end
  300.     return false
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● アクターコマンドウィンドウのセットアップ
  304.   #--------------------------------------------------------------------------
  305.   alias xrxs65_phase3_setup_command_window phase3_setup_command_window
  306.   def phase3_setup_command_window
  307.     # 効果音の再生
  308.     Audio.se_play(XRXS65::COMMAND_UP_SE) rescue nil
  309.     # 呼び戻す
  310.     xrxs65_phase3_setup_command_window
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド)
  314.   #--------------------------------------------------------------------------
  315.   alias xrxs_bsp1_update_phase3_basic_command update_phase3_basic_command
  316.   def update_phase3_basic_command
  317.     # C ボタンが押された場合
  318.     if Input.trigger?(Input::C)
  319.       # アクターコマンドウィンドウのカーソル位置で分岐
  320.       case @actor_command_window.index
  321.       when @cp_escape_actor_command_index # 逃げる
  322.         if $game_temp.battle_can_escape
  323.           # 決定 SE を演奏
  324.           $game_system.se_play($data_system.decision_se)
  325.           # アクションを設定
  326.           @active_battler.current_action.kind = 0
  327.           @active_battler.current_action.basic = 4
  328.           # 次のアクターのコマンド入力へ
  329.           phase3_next_actor
  330.         else
  331.           # ブザー SE を演奏
  332.           $game_system.se_play($data_system.buzzer_se)
  333.         end
  334.         return
  335.       end
  336.     end
  337.     # 呼び戻す
  338.     xrxs_bsp1_update_phase3_basic_command
  339.   end
  340.   #--------------------------------------------------------------------------
  341.   # ● メインフェーズ開始
  342.   #--------------------------------------------------------------------------
  343.   alias xrxs65_start_phase4 start_phase4
  344.   def start_phase4
  345.     # ターン数を引くことによって擬似的にカウントに変化を起こさせない
  346.     $game_temp.battle_turn -= 1
  347.     # フラグを退避
  348.     save_flags = $game_temp.battle_event_flags.dup
  349.     # 呼び戻す
  350.     xrxs65_start_phase4
  351.     # フラグを復旧
  352.     $game_temp.battle_event_flags = save_flags
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● 行動順序作成
  356.   #--------------------------------------------------------------------------
  357.   alias xrxs65_make_action_orders make_action_orders
  358.   def make_action_orders
  359.     # 呼び戻す
  360.     xrxs65_make_action_orders
  361.     # CPが不足している場合は @action_battlers から除外する
  362.     for battler in @action_battlers.dup
  363.       @action_battlers.delete(battler) unless battler.cp_full?
  364.     end
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  368.   #--------------------------------------------------------------------------
  369.   alias xrxs65_update_phase4_step2 update_phase4_step2
  370.   def update_phase4_step2
  371.     # ガードの解除
  372.     @active_battler.guarding = false
  373.     # CPの消費
  374.     @active_battler.cp = 0
  375.     # CP メーターの更新
  376.     @cp_meters.refresh
  377.     # 呼び戻す
  378.     xrxs65_update_phase4_step2
  379.     # 例外補正
  380.     return if @active_battler == nil
  381.     # ターンコントローラ
  382.     if @active_battler.is_a?(Game_Enemy) and @active_battler.index == XRXS65::TC
  383.       cp_turn_count
  384.     end
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 基本アクション 結果作成
  388.   #--------------------------------------------------------------------------
  389.   alias xrxs65_make_basic_action_result make_basic_action_result
  390.   def make_basic_action_result
  391.     # 呼び戻す
  392.     xrxs65_make_basic_action_result
  393.     # 防御の場合
  394.     if @active_battler.current_action.basic == 1
  395.       @active_battler.guarding = true
  396.       return
  397.     end
  398.     # パーティの逃亡の場合
  399.     if @active_battler.current_action.basic == 4
  400.       # 逃走可能ではない場合
  401.       if $game_temp.battle_can_escape == false
  402.         # ブザー SE を演奏
  403.         $game_system.se_play($data_system.buzzer_se)
  404.         return
  405.       end
  406.       # パーティ全員の CP をクリア
  407.       for actor in $game_party.actors
  408.         actor.cp = 0
  409.       end
  410.       # CP メーターの更新
  411.       @cp_meters.refresh
  412.       # 逃走処理
  413.       update_phase2_escape
  414.       return
  415.     end
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  419.   #--------------------------------------------------------------------------
  420.   alias xrxs65_update_phase4_step5 update_phase4_step5
  421.   def update_phase4_step5
  422.     # 呼び戻す
  423.     xrxs65_update_phase4_step5
  424.     # CP メーターの更新
  425.     @cp_meters.refresh
  426.   end
  427. end
  428. #==============================================================================
  429. # --- CP メーターをまとめて管理するクラス、表示関係はすべてココ ---
  430. #==============================================================================
  431. class CP_Meters
  432.   #--------------------------------------------------------------------------
  433.   # ○ オブジェクト初期化
  434.   #--------------------------------------------------------------------------
  435.   def initialize
  436.     # メーター群の生成
  437.     @meters = []
  438.     for i in 0...$game_party.actors.size
  439.       make_meter(i)
  440.     end
  441.     refresh
  442.   end
  443.   #--------------------------------------------------------------------------
  444.   # ○ リフレッシュ
  445.   #--------------------------------------------------------------------------
  446.   def refresh
  447.     # 戦闘メンバー数の変更を判別
  448.     for i in @meters.size...$game_party.actors.size
  449.       make_meter(i)
  450.     end
  451.     for i in $[email]game_party.actors.size...@meters.size[/email]
  452.       @meters[i].dispose
  453.       @meters[i] = nil
  454.     end
  455.     @meters.compact!
  456.     # 表示更新
  457.     for i in 0...$game_party.actors.size
  458.       actor = $game_party.actors[i]
  459.       @meters[i].line   = actor.cp_linetype
  460.       @meters[i].amount = actor.cp_lineamount
  461.     end
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ○ メーターひとつの生成
  465.   #--------------------------------------------------------------------------
  466.   def make_meter(i)
  467.     # スキンの取得
  468.     skin = RPG::Cache.windowskin(XRXS65::SKIN)
  469.     #
  470.     space = 640 / XRXS65::MAX
  471.     case XRXS65::ALIGN
  472.     when 0
  473.       actor_x = i * space + 4
  474.     when 1
  475.       actor_x = (space * ((XRXS65::MAX - $game_party.actors.size)/2.0 + i)).floor
  476.     when 2
  477.       actor_x = (i + XRXS65::MAX - $game_party.actors.size) * space + 4
  478.     end
  479.     meter = MeterSprite.new(skin, XRXS65::LINE_HEIGHT)
  480.     meter.x = actor_x + XRXS65::X_OFFSET - skin.width
  481.     meter.y = XRXS65::Y_OFFSET
  482.     @meters[i] = meter
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # ○ 可視状態
  486.   #--------------------------------------------------------------------------
  487.   def visible=(b)
  488.     @meters.each{|sprite| sprite.visible = b }
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # ○ 解放
  492.   #--------------------------------------------------------------------------
  493.   def dispose
  494.     @meters.each{|sprite| sprite.dispose }
  495.   end
  496. end
  497. #==============================================================================
  498. # --- XRXS. レクタンギュラーメーター表示・極 ---
  499. #==============================================================================
  500. class MeterSprite < Sprite
  501.   #--------------------------------------------------------------------------
  502.   # ○ オブジェクト初期化
  503.   #--------------------------------------------------------------------------
  504.   def initialize(skin, line_height)
  505.     @skin   = skin
  506.     @width  = @skin.width
  507.     @height = line_height
  508.     @line   = 1
  509.     @amount = 0
  510.     @base_sprite = Sprite.new
  511.     @base_sprite.bitmap = @skin
  512.     @base_sprite.src_rect.set(0, 0, @width, @height)
  513.     @base_sprite.z = 601
  514.     super()
  515.     self.z = @base_sprite.z + 1
  516.     self.bitmap = @skin
  517.     self.line = 1
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # ○ 値の設定
  521.   #--------------------------------------------------------------------------
  522.   def line=(n)
  523.     @line = n
  524.     refresh
  525.   end
  526.   def amount=(n)
  527.     @amount = n
  528.     refresh
  529.   end
  530.   def refresh
  531.     self.src_rect.set(0, @line * @height, @width * @amount / 100, @height)
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # ○ 座標の設定
  535.   #--------------------------------------------------------------------------
  536.   def x=(n)
  537.     super
  538.     @base_sprite.x = n
  539.   end
  540.   def y=(n)
  541.     super
  542.     @base_sprite.y = n
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ○ 解放
  546.   #--------------------------------------------------------------------------
  547.   def dispose
  548.     @base_sprite.dispose
  549.     super
  550.   end
  551. end
复制代码

怒气脚本是更改了好多原始脚本得来的,就为这事头疼。

点评

有变量重复了,找到重复的,新建一个再修改  发表于 2015-1-8 14:50
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部