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

Project1

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

[已经过期] 换人脚本如果中毒死亡就卡死的问题怎么解决?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
32 小时
注册时间
2014-2-4
帖子
26
跳转到指定楼层
1
发表于 2015-7-31 12:34:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
        我找到了一个换人脚本,但是里面一旦有一个出战角色是因中毒死亡就不会弹出换人的信息,然后卡住。(BGM之类还是照常播放的)该怎么办?

        这里是我用的换人脚本:
RUBY 代码复制
  1. module LimBattlePlug
  2.  
  3. # 队伍最大人数
  4. MaxPartySize = 7
  5.  
  6. # 出战人数
  7. MaxBattlerSize = 1
  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,1024,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.skill    #这里是技能,修改BY:北少
  223.     s2 = $data_system.words.guard    #这里是防御,不喜欢自己删去,修改by:北少
  224.     s3 = $data_system.words.item     #这里是物品,修改BY:北少
  225.     s4 = WordChangeBattler           #这里是换人,修改BY:北少
  226.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  227.     @actor_command_window.y = 128
  228.     @actor_command_window.back_opacity = 160
  229.     @actor_command_window.active = false
  230.     @actor_command_window.visible = false
  231.     # 生成其它窗口
  232.     @party_command_window = Window_PartyCommand.new
  233.     @help_window = Window_Help.new
  234.     @help_window.back_opacity = 160
  235.     @help_window.visible = false
  236.     @status_window = Window_BattleStatus.new
  237.     @message_window = Window_Message.new
  238.     # 生成活动块
  239.     @spriteset = Spriteset_Battle.new
  240.     # 初始化等待计数
  241.     @wait_count = 0
  242.     # 执行过渡
  243.     if $data_system.battle_transition == ""
  244.       Graphics.transition(20)
  245.     else
  246.       Graphics.transition(40, "Graphics/Transitions/" +
  247.         $data_system.battle_transition)
  248.     end
  249.     # 开始自由战斗回合
  250.     start_phase1
  251.     # 主循环
  252.     loop do
  253.       # 刷新游戏画面
  254.       Graphics.update
  255.       # 刷新输入信息
  256.       Input.update
  257.       # 刷新画面
  258.       update
  259.       # 如果画面切换的话就中断循环
  260.       if $scene != self
  261.         break
  262.       end
  263.     end
  264.     # 刷新地图
  265.     $game_map.refresh
  266.     # 准备过渡
  267.     Graphics.freeze
  268.     # 释放窗口
  269.     @actor_command_window.dispose
  270.     @party_command_window.dispose
  271.     @help_window.dispose
  272.     @status_window.dispose
  273.     @message_window.dispose
  274.     if @skill_window != nil
  275.       @skill_window.dispose
  276.     end
  277.     if @item_window != nil
  278.       @item_window.dispose
  279.     end
  280.     if @actor_window != nil
  281.       @actor_window.dispose
  282.     end
  283.     if @result_window != nil
  284.       @result_window.dispose
  285.     end
  286.     # 释放活动块
  287.     @spriteset.dispose
  288.     # 标题画面切换中的情况
  289.     if $scene.is_a?(Scene_Title)
  290.       # 淡入淡出画面
  291.       Graphics.transition
  292.       Graphics.freeze
  293.     end
  294.     # 战斗测试或者游戏结束以外的画面切换中的情况
  295.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  296.       $scene = nil
  297.     end
  298.   end
  299.   # 战斗结束
  300.   alias lpb_battle_end battle_end
  301.   def battle_end(n)
  302.     lpb_battle_end(n)
  303.     $game_party.set_actor_to_normal
  304.   end
  305.   # 开始回合3
  306.   alias lbp_start_phase3 start_phase3
  307.   def start_phase3
  308.     @changed_battler_id = []
  309.     lbp_start_phase3
  310.   end
  311.   # 刷新角色命令回合画面
  312.   def update_phase3
  313.     # 敌人光标有效的情况下
  314.     if @enemy_arrow != nil
  315.       update_phase3_enemy_select
  316.     # 角色光标有效的情况下
  317.     elsif @actor_arrow != nil
  318.       update_phase3_actor_select
  319.     # 特技窗口有效的情况下
  320.     elsif @skill_window != nil
  321.       update_phase3_skill_select
  322.     # 物品窗口有效的情况下
  323.     elsif @item_window != nil
  324.       update_phase3_item_select
  325.     elsif @actor_window != nil
  326.       update_phase3_battler_select
  327.     # 角色指令窗口有效的情况下
  328.     elsif @actor_command_window.active
  329.       update_phase3_basic_command
  330.     end
  331.   end
  332.   # 角色基本命令
  333.   def update_phase3_basic_command
  334.     # 按下 B 键的情况下
  335.     if Input.trigger?(Input::B)
  336.       # 演奏取消 SE
  337.       $game_system.se_play($data_system.cancel_se)
  338.       # 转向前一个角色的指令输入
  339.       phase3_prior_actor
  340.       return
  341.     end
  342.     # 按下 C 键的情况下
  343.     if Input.trigger?(Input::C)
  344.       # 角色指令窗口光标位置分之
  345.       case @actor_command_window.index
  346.       when 0  # 特技
  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 1  # 防御
  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 2  # 物品
  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 3 # 换人
  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.  
  509. class Window_MenuStatus
  510.   def refresh
  511.     self.contents.clear
  512.     @item_max = $game_party.actors.size
  513.     for i in 0...$game_party.actors.size
  514.       x = 4
  515.       y = i * 32
  516.       actor = $game_party.actors[i]
  517.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  518.       rect = Rect.new(0,0,bitmap.width/4,31)
  519.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
  520.       draw_actor_name(actor, x+36, y)
  521.       draw_actor_state(actor, x + 136,y)
  522.       draw_actor_hp(actor, x + 236, y,96)
  523.       draw_actor_sp(actor, x + 336, y,96)
  524.     end
  525.   end
  526.   def update_cursor_rect
  527.     super
  528.   end
  529. end

Lv1.梦旅人

梦石
0
星屑
50
在线时间
32 小时
注册时间
2014-2-4
帖子
26
2
 楼主| 发表于 2015-7-31 12:37:13 | 只看该作者
游戏里面经常会遇到擅长中毒之类技能的对手……这个问题如果存在的话会非常蛋疼…………
回复 支持 反对

使用道具 举报

Lv4.逐梦者

素材区好人

梦石
3
星屑
7344
在线时间
3526 小时
注册时间
2011-7-21
帖子
2281

极短24参与极短23参与极短22参与极短21参与

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
32 小时
注册时间
2014-2-4
帖子
26
4
 楼主| 发表于 2015-8-1 08:53:33 | 只看该作者
无忧谷主幻 发表于 2015-7-31 21:48
给你我的战斗换人,虽然我也没试过
module LimBattlePlug

= =不行……你这个更那啥……四个里面中毒死一个就结束游戏了……另外三个还是全盛状态……
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-23 07:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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