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

Project1

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

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
41 小时
注册时间
2013-10-27
帖子
22
跳转到指定楼层
1
发表于 2014-11-16 12:38:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
CP制战斗脚本加入以后,发现每个角色的怒气槽变成了几万多,但是轮到某个角色攻击的时候,怒气槽又恢复到10,但是过了回合之后又变成几万多,这是怎么回事,加了CP制战斗脚本后,换人按钮按去按去没反应,只有角色死亡之后才会自动显示换人界面o(╯□╰)o,放脚本,请大大们解答
这是换人脚本
RUBY 代码复制
  1. module LimBattlePlug
  2.  
  3. # 队伍最大人数
  4. MaxPartySize = 12
  5.  
  6. # 出战人数
  7. MaxBattlerSize = 4
  8.  
  9. # 换人语句
  10. WordChangeBattler = "换人"
  11.  
  12. # 换人时播放的动画
  13. AnimationChangeBattler = 26
  14.  
  15. end
  16.  
  17. class Game_BattleAction
  18.   attr_accessor :change_to_battler
  19.   # 初始化
  20.   alias lbp_initialize initialize
  21.   def initialize
  22.     lbp_initialize
  23.     @change_to_battler = 0
  24.   end
  25.   # 欲更换角色编号
  26.   def set_change_battler
  27.     @kind = 3
  28.   end
  29.   # 判断行动是否为更换角色
  30.   def is_change_battler?
  31.     return (@kind == 3)
  32.   end
  33. end
  34.  
  35. class Game_Party
  36.   include LimBattlePlug
  37.   attr_reader :actors2
  38.   alias lpb_initialize initialize
  39.   def initialize
  40.     lpb_initialize
  41.     @actors2 = []
  42.   end
  43.   # 角色加入
  44.   def add_actor(actor_id)
  45.     actor = $game_actors[actor_id]
  46.     if @actors.size < MaxPartySize and not @actors.include?(actor)
  47.       @actors.push(actor)
  48.       $game_player.refresh
  49.     end
  50.   end
  51.   # 设置战斗的角色
  52.   def set_actor_to_battle
  53.     @actors2 = []
  54.     @actors.each do |actor|
  55.       @actors2.push(actor)
  56.     end
  57.     @actors = []
  58.     dead_actor = []
  59.     @actors2.each do |actor|
  60.       if !actor.dead?
  61.         @actors.push(actor)
  62.       else
  63.         dead_actor.push(actor)
  64.       end
  65.       break if @actors.size == MaxBattlerSize
  66.     end
  67.     if @actors.size < MaxBattlerSize
  68.       for actor in dead_actor
  69.         @actors.push(actor)
  70.         break if @actors.size == MaxBattlerSize
  71.       end
  72.     end
  73.   end
  74.   # 还原战斗的角色
  75.   def set_actor_to_normal
  76.     @actors = []
  77.     @actors2.each do |actor|
  78.       @actors.push(actor)
  79.     end
  80.   end
  81.   # 获取角色id数组
  82.   def get_actors_id
  83.     id = []
  84.     @actors.each{|actor|id.push(actor.id)}
  85.     return id
  86.   end
  87.   # 获取角色id数组
  88.   def get_actors2_id
  89.     id = []
  90.     @actors2.each{|actor|id.push(actor.id)}
  91.     return id
  92.   end
  93.   # 兑换角色
  94.   def change_actor(index,id)
  95.     @actors[index] = $game_actors[id]
  96.   end
  97.   # 全灭判定
  98.   def all_dead?
  99.     # 同伴人数为 0 的情况下
  100.     if $game_party.actors.size == 0
  101.       return false
  102.     end
  103.     # 同伴中无人 HP 在 0 以上
  104.     for actor in @actors2
  105.       if actor.hp > 0
  106.         return false
  107.       end
  108.     end
  109.     for actor in @actors
  110.       if actor.hp > 0
  111.         return false
  112.       end
  113.     end
  114.     # 全灭
  115.     return true
  116.   end
  117.   # 其他角色
  118.   def other_actors
  119.     actors = []
  120.     @actors2.each{|actor|actors.push(actor) if !@actors.include?(actor)}
  121.     return actors
  122.   end
  123.   # 角色位置互换
  124.   def change_actor_pos(id1,id2)
  125.     actor_id = []
  126.     @actors.each do |actor|
  127.       actor_id.push(actor.id)
  128.     end
  129.     return if !actor_id.include?(id1) and !actor_id.include?(id2)
  130.     id1_index = id2_index = -1
  131.     (0...actor_id.size).each do |i|
  132.       if actor_id[i] == id1
  133.         id1_index = i
  134.       elsif actor_id[i] == id2
  135.         id2_index = i
  136.       end
  137.     end
  138.     temp_actor = @actors[id1_index]
  139.     @actors[id1_index] = @actors[id2_index]
  140.     @actors[id2_index] = temp_actor
  141.   end
  142. end
  143.  
  144. class Window_Actor < Window_Selectable
  145.   # 初始化
  146.   def initialize
  147.     super(0,64,640,256)
  148.     self.back_opacity = 160
  149.     refresh
  150.     self.index = -1
  151.     self.active = false
  152.   end
  153.   # 刷新
  154.   def refresh
  155.     @item_max = $game_party.actors2.size
  156.     @data = []
  157.     $game_party.actors.each do |actor|
  158.       @data.push(actor)
  159.     end
  160.     $game_party.actors2.each do |actor|
  161.       @data.push(actor) if !@data.include?(actor)
  162.     end
  163.     if self.contents != nil
  164.       self.contents.clear
  165.       self.contents = nil
  166.     end
  167.     self.contents = Bitmap.new(608,@data.size*32)
  168.     x = 4
  169.     y = 0
  170.     @data.each do |actor|
  171.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  172.       rect = Rect.new(0,0,bitmap.width/4,31)
  173.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
  174.       draw_actor_name(actor,x+36,y)
  175.       draw_actor_state(actor,156,y)
  176.       draw_actor_hp(actor,x+256,y,96)
  177.       draw_actor_sp(actor,x+376,y,96)
  178.       if $game_party.actors.include?(actor)
  179.         self.contents.font.color = text_color(6)
  180.         cword = "出战"
  181.       else
  182.         self.contents.font.color = text_color(0)
  183.         cword = "待战"
  184.       end
  185.       self.contents.draw_text(x+496,y,60,32,cword)
  186.       y += 32
  187.     end
  188.   end
  189.   # 获取当前角色编号
  190.   def actor_id
  191.     return @data[self.index].id
  192.   end
  193.   # 刷新帮助
  194.   def update_help
  195.     @help_window.set_text(@data[self.index] == nil ?\
  196.                           "" : @data[self.index].name)
  197.   end
  198. end
  199.  
  200. class Scene_Battle
  201.   include LimBattlePlug
  202.   # 初始化
  203.   def initialize
  204.     $game_party.set_actor_to_battle
  205.   end
  206.   # 主处理
  207.   def main
  208.     # 初始化战斗用的各种暂时数据
  209.     $game_temp.in_battle = true
  210.     $game_temp.battle_turn = 0
  211.     $game_temp.battle_event_flags.clear
  212.     $game_temp.battle_abort = false
  213.     $game_temp.battle_main_phase = false
  214.     $game_temp.battleback_name = $game_map.battleback_name
  215.     $game_temp.forcing_battler = nil
  216.     # 初始化战斗用事件解释器
  217.     $game_system.battle_interpreter.setup(nil, 0)
  218.     # 准备队伍
  219.     @troop_id = $game_temp.battle_troop_id
  220.     $game_troop.setup(@troop_id)
  221.     # 生成角色命令窗口
  222.     s1 = $data_system.words.attack
  223.     s2 = $data_system.words.skill
  224.     s3 = $data_system.words.guard
  225.     s4 = $data_system.words.item
  226.     s5 = WordChangeBattler
  227.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4,s5])
  228.     @actor_command_window.y = 128
  229.     @actor_command_window.back_opacity = 160
  230.     @actor_command_window.active = false
  231.     @actor_command_window.visible = false
  232.     # 生成其它窗口
  233.     @party_command_window = Window_PartyCommand.new
  234.     @help_window = Window_Help.new
  235.     @help_window.back_opacity = 160
  236.     @help_window.visible = false
  237.     @status_window = Window_BattleStatus.new
  238.     @message_window = Window_Message.new
  239.     # 生成活动块
  240.     @spriteset = Spriteset_Battle.new
  241.     # 初始化等待计数
  242.     @wait_count = 0
  243.     # 执行过渡
  244.     if $data_system.battle_transition == ""
  245.       Graphics.transition(20)
  246.     else
  247.       Graphics.transition(40, "Graphics/Transitions/" +
  248.         $data_system.battle_transition)
  249.     end
  250.     # 开始自由战斗回合
  251.     start_phase1
  252.     # 主循环
  253.     loop do
  254.       # 刷新游戏画面
  255.       Graphics.update
  256.       # 刷新输入信息
  257.       Input.update
  258.       # 刷新画面
  259.       update
  260.       # 如果画面切换的话就中断循环
  261.       if $scene != self
  262.         break
  263.       end
  264.     end
  265.     # 刷新地图
  266.     $game_map.refresh
  267.     # 准备过渡
  268.     Graphics.freeze
  269.     # 释放窗口
  270.     @actor_command_window.dispose
  271.     @party_command_window.dispose
  272.     @help_window.dispose
  273.     @status_window.dispose
  274.     @message_window.dispose
  275.     if @skill_window != nil
  276.       @skill_window.dispose
  277.     end
  278.     if @item_window != nil
  279.       @item_window.dispose
  280.     end
  281.     if @actor_window != nil
  282.       @actor_window.dispose
  283.     end
  284.     if @result_window != nil
  285.       @result_window.dispose
  286.     end
  287.     # 释放活动块
  288.     @spriteset.dispose
  289.     # 标题画面切换中的情况
  290.     if $scene.is_a?(Scene_Title)
  291.       # 淡入淡出画面
  292.       Graphics.transition
  293.       Graphics.freeze
  294.     end
  295.     # 战斗测试或者游戏结束以外的画面切换中的情况
  296.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  297.       $scene = nil
  298.     end
  299.   end
  300.   # 战斗结束
  301.   alias lpb_battle_end battle_end
  302.   def battle_end(n)
  303.     lpb_battle_end(n)
  304.     $game_party.set_actor_to_normal
  305.   end
  306.   # 开始回合3
  307.   alias lbp_start_phase3 start_phase3
  308.   def start_phase3
  309.     @changed_battler_id = []
  310.     lbp_start_phase3
  311.   end
  312.   # 刷新角色命令回合画面
  313.   def update_phase3
  314.     # 敌人光标有效的情况下
  315.     if @enemy_arrow != nil
  316.       update_phase3_enemy_select
  317.     # 角色光标有效的情况下
  318.     elsif @actor_arrow != nil
  319.       update_phase3_actor_select
  320.     # 特技窗口有效的情况下
  321.     elsif @skill_window != nil
  322.       update_phase3_skill_select
  323.     # 物品窗口有效的情况下
  324.     elsif @item_window != nil
  325.       update_phase3_item_select
  326.     elsif @actor_window != nil
  327.       update_phase3_battler_select
  328.     # 角色指令窗口有效的情况下
  329.     elsif @actor_command_window.active
  330.       update_phase3_basic_command
  331.     end
  332.   end
  333.   # 角色基本命令
  334.   def update_phase3_basic_command
  335.     # 按下 B 键的情况下
  336.     if Input.trigger?(Input::B)
  337.       # 演奏取消 SE
  338.       $game_system.se_play($data_system.cancel_se)
  339.       # 转向前一个角色的指令输入
  340.       phase3_prior_actor
  341.       return
  342.     end
  343.     # 按下 C 键的情况下
  344.     if Input.trigger?(Input::C)
  345.       # 角色指令窗口光标位置分之
  346.       case @actor_command_window.index
  347.       when 0  # 攻击
  348.         # 演奏确定 SE
  349.         $game_system.se_play($data_system.decision_se)
  350.         # 设置行动
  351.         @active_battler.current_action.kind = 0
  352.         @active_battler.current_action.basic = 0
  353.         # 开始选择敌人
  354.         start_enemy_select
  355.       when 1  # 特技
  356.         # 演奏确定 SE
  357.         $game_system.se_play($data_system.decision_se)
  358.         # 设置行动
  359.         @active_battler.current_action.kind = 1
  360.         # 开始选择特技
  361.         start_skill_select
  362.       when 2  # 防御
  363.         # 演奏确定 SE
  364.         $game_system.se_play($data_system.decision_se)
  365.         # 设置行动
  366.         @active_battler.current_action.kind = 0
  367.         @active_battler.current_action.basic = 1
  368.         # 转向下一位角色的指令输入
  369.         phase3_next_actor
  370.       when 3  # 物品
  371.         # 演奏确定 SE
  372.         $game_system.se_play($data_system.decision_se)
  373.         # 设置行动
  374.         @active_battler.current_action.kind = 2
  375.         # 开始选择物品
  376.         start_item_select
  377.       when 4 # 换人
  378.         $game_system.se_play($data_system.decision_se)
  379.         @active_battler.current_action.set_change_battler
  380.         start_battler_select
  381.       end
  382.       return
  383.     end
  384.   end
  385.   # 开始角色选择
  386.   def start_battler_select
  387.     @actor_window = Window_Actor.new
  388.     @actor_window.active = true
  389.     @actor_window.index = 0
  390.     @actor_window.help_window = @help_window
  391.     @actor_command_window.active = false
  392.     @actor_command_window.visible = false
  393.   end
  394.   # 结束角色选择
  395.   def end_battler_select
  396.     @actor_window.dispose
  397.     @actor_window = nil
  398.     @help_window.visible = false
  399.     @actor_command_window.active = true
  400.     @actor_command_window.visible = true
  401.   end
  402.   # 刷新角色选择
  403.   def update_phase3_battler_select
  404.     @actor_window.visible = true
  405.     @actor_window.update
  406.     if Input.trigger?(Input::B)
  407.       $game_system.se_play($data_system.cancel_se)
  408.       end_battler_select
  409.       return
  410.     end
  411.     if Input.trigger?(Input::C)
  412.       actor_id = @actor_window.actor_id
  413.       if $game_party.get_actors_id.include?(actor_id) or
  414.          $game_actors[actor_id].dead? or
  415.          @changed_battler_id.include?(actor_id)
  416.         $game_system.se_play($data_system.buzzer_se)
  417.         return
  418.       end
  419.       $game_system.se_play($data_system.decision_se)
  420.       @active_battler.current_action.change_to_battler = actor_id
  421.       @changed_battler_id.push(actor_id)
  422.       end_battler_select
  423.       phase3_next_actor
  424.       return
  425.     end
  426.   end
  427.   # 行动方动画
  428.   def update_phase4_step3
  429.     if @active_battler.current_action.is_change_battler?
  430.       @animation1_id = AnimationChangeBattler
  431.       @target_battlers = []
  432.     end
  433.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  434.     if @animation1_id == 0
  435.       @active_battler.white_flash = true
  436.     else
  437.       @active_battler.animation_id = @animation1_id
  438.       @active_battler.animation_hit = true
  439.     end
  440.     # 移至步骤 4
  441.     @phase4_step = 4
  442.   end
  443.   # 对象方动画
  444.   def update_phase4_step4
  445.     if @active_battler.current_action.is_change_battler?
  446.       actor1_id = @active_battler.current_action.change_to_battler
  447.       actor2_id = @active_battler.id
  448.       (0...$game_party.actors.size).each do |i|
  449.         if $game_party.actors[i].id == actor2_id
  450.           $game_party.change_actor(i,actor1_id)
  451.           @active_battler = $game_actors[actor1_id]
  452.           @status_window.refresh
  453.         end
  454.       end
  455.     end
  456.     # 对像方动画
  457.     for target in @target_battlers
  458.       target.animation_id = @animation2_id
  459.       target.animation_hit = (target.damage != "Miss")
  460.     end
  461.     # 限制动画长度、最低 8 帧
  462.     @wait_count = 8
  463.     # 移至步骤 5
  464.     @phase4_step = 5
  465.   end
  466.   # 公共事件
  467.   def update_phase4_step6
  468.     @target_battlers.each do |target|
  469.       if target.is_a?(Game_Actor) and target.dead? and
  470.          !$game_party.other_actors.all?{|actor|actor.dead?}
  471.         @actor_window = Window_Actor.new
  472.         @actor_window.index = 0
  473.         @actor_window.active = true
  474.         @actor_window.help_window = @help_window
  475.         actor_id = -1
  476.         loop do
  477.           Graphics.update
  478.           Input.update
  479.           @actor_window.update
  480.           if Input.trigger?(Input::C)
  481.             actor = $game_actors[@actor_window.actor_id]
  482.             if actor.dead? or
  483.                (@changed_battler_id.include?(actor.id) and
  484.                 target.current_action.change_to_battler != actor.id) or
  485.                $game_party.actors.include?(actor)
  486.               $game_system.se_play($data_system.buzzer_se)
  487.             else
  488.               actor_id = actor.id
  489.             end
  490.           end
  491.           break if actor_id >= 0
  492.         end
  493.         @actor_window.visible = false
  494.         @actor_window.dispose
  495.         @actor_window = nil
  496.         @help_window.visible = false
  497.         (0...$game_party.actors.size).each do |i|
  498.           if $game_party.actors[i].id == target.id
  499.             $game_party.change_actor(i,actor_id)
  500.             @status_window.refresh
  501.           end
  502.         end
  503.       end
  504.     end
  505.     # 清除强制行动对像的战斗者
  506.     $game_temp.forcing_battler = nil
  507.     # 公共事件 ID 有效的情况下
  508.     if @common_event_id > 0
  509.       # 设置事件
  510.       common_event = $data_common_events[@common_event_id]
  511.       $game_system.battle_interpreter.setup(common_event.list, 0)
  512.     end
  513.     # 移至步骤 1
  514.     @phase4_step = 1
  515.   end
  516. end
  517.  
  518. class Window_MenuStatus
  519.   def refresh
  520.     self.contents.clear
  521.     @item_max = $game_party.actors.size
  522.     for i in 0...$game_party.actors.size
  523.       x = 4
  524.       y = i * 32
  525.       actor = $game_party.actors[i]
  526.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  527.       rect = Rect.new(0,0,bitmap.width/4,31)
  528.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
  529.       draw_actor_name(actor, x+36, y)
  530.       draw_actor_state(actor, x + 136,y)
  531.       draw_actor_hp(actor, x + 236, y,96)
  532.       draw_actor_sp(actor, x + 336, y,96)
  533.     end
  534.   end
  535.   def update_cursor_rect
  536.     super
  537.   end
  538. end

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

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

点评

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

本版积分规则

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

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

GMT+8, 2024-9-22 11:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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