查看: 2889|回复: 21

[已经过期] 战斗换人脚本和一键打怪冲突

[复制链接]
梦石
0
星屑
17566
在线时间
4250 小时
注册时间
2013-7-18
回帖
2491
发表于 2016-9-9 16:08:15 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 y967 于 2016-9-10 19:11 编辑
  1. module LimBattlePlug

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

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

  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
复制代码


下面是一键打怪脚本 ,只有这里Scene_Battle 4 ●改,第374行出错,其他都没问题

  1. #==============================================================================
  2. # ■ Scene_Battle (分割定义 4)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的类。
  5. #==============================================================================

  6. class Scene_Battle
  7.   #--------------------------------------------------------------------------
  8.   # ● 开始主回合
  9.   #--------------------------------------------------------------------------
  10.   def start_phase4
  11.     # 转移到回合 4
  12.     @phase = 4
  13.     # 回合数计数
  14.     $game_temp.battle_turn += 1
  15.     # 搜索全页的战斗事件
  16.     for index in 0...$data_troops[@troop_id].pages.size
  17.       # 获取事件页
  18.       page = $data_troops[@troop_id].pages[index]
  19.       # 本页的范围是 [回合] 的情况下
  20.       if page.span == 1
  21.         # 设置已经执行标志
  22.         $game_temp.battle_event_flags[index] = false
  23.       end
  24.     end
  25.     # 设置角色为非选择状态
  26.     @actor_index = -1
  27.     @active_battler = nil
  28.     # 有效化同伴指令窗口
  29.     @party_command_window.active = false
  30.     @party_command_window.visible = false
  31.     # 无效化角色指令窗口
  32.     @actor_command_window.active = false
  33.     @actor_command_window.visible = false
  34.     # 设置主回合标志
  35.     $game_temp.battle_main_phase = true
  36.     # 生成敌人行动
  37.     for enemy in $game_troop.enemies
  38.       enemy.make_action
  39.     end
  40.     # 生成行动顺序
  41.     make_action_orders
  42.     # 移动到步骤 1
  43.     @phase4_step = 1
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 生成行动循序
  47.   #--------------------------------------------------------------------------
  48.   def make_action_orders
  49.     # 初始化序列 @action_battlers
  50.     @action_battlers = []
  51.     # 添加敌人到 @action_battlers 序列
  52.     for enemy in $game_troop.enemies
  53.       @action_battlers.push(enemy)
  54.     end
  55.     # 添加角色到 @action_battlers 序列
  56.     for actor in $game_party.actors
  57.       @action_battlers.push(actor)
  58.     end
  59.     # 确定全体的行动速度
  60.     for battler in @action_battlers
  61.       battler.make_action_speed
  62.     end
  63.     # 按照行动速度从大到小排列
  64.     @action_battlers.sort! {|a,b|
  65.       b.current_action.speed - a.current_action.speed }
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 刷新画面 (主回合)
  69.   #--------------------------------------------------------------------------
  70.   def update_phase4
  71.     case @phase4_step
  72.     when 1
  73.       update_phase4_step1
  74.     when 2
  75.       update_phase4_step2
  76.     when 3
  77.       update_phase4_step3
  78.     when 4
  79.       update_phase4_step4
  80.     when 5
  81.       update_phase4_step5
  82.     when 6
  83.       update_phase4_step6
  84.     end
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 刷新画面 (主回合步骤 1 : 准备行动)
  88.   #--------------------------------------------------------------------------
  89.   def update_phase4_step1
  90.     # 隐藏帮助窗口
  91.     @help_window.visible = false
  92.     # 判定胜败
  93.     if judge
  94.       # 胜利或者失败的情况下 : 过程结束
  95.       return
  96.     end
  97.     # 强制行动的战斗者不存在的情况下
  98.     if $game_temp.forcing_battler == nil
  99.       # 设置战斗事件
  100.       setup_battle_event
  101.       # 执行战斗事件中的情况下
  102.       if $game_system.battle_interpreter.running?
  103.         return
  104.       end
  105.     end
  106.     # 强制行动的战斗者存在的情况下
  107.     if $game_temp.forcing_battler != nil
  108.       # 在头部添加后移动
  109.       @action_battlers.delete($game_temp.forcing_battler)
  110.       @action_battlers.unshift($game_temp.forcing_battler)
  111.     end
  112.     # 未行动的战斗者不存在的情况下 (全员已经行动)
  113.     if @action_battlers.size == 0
  114.       # 开始同伴命令回合
  115.       start_phase2
  116.       return
  117.     end
  118.     # 初始化动画 ID 和公共事件 ID
  119.     @animation1_id = 0
  120.     @animation2_id = 0
  121.     @common_event_id = 0
  122.     # 未行动的战斗者移动到序列的头部
  123.     @active_battler = @action_battlers.shift
  124.     # 如果已经在战斗之外的情况下
  125.     if @active_battler.index == nil
  126.       return
  127.     end
  128.     # 连续伤害
  129.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  130.       @active_battler.slip_damage_effect
  131.       @active_battler.damage_pop = true
  132.     end
  133.     # 自然解除状态
  134.     @active_battler.remove_states_auto
  135.     # 刷新状态窗口
  136.     @status_window.refresh
  137.     # 移至步骤 2
  138.     @phase4_step = 2
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  142.   #--------------------------------------------------------------------------
  143.   def update_phase4_step2
  144.     # 如果不是强制行动
  145.     unless @active_battler.current_action.forcing
  146.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  147.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  148.         # 设置行动为攻击
  149.         @active_battler.current_action.kind = 0
  150.         @active_battler.current_action.basic = 0
  151.       end
  152.       # 限制为 [不能行动] 的情况下
  153.       if @active_battler.restriction == 4
  154.         # 清除行动强制对像的战斗者
  155.         $game_temp.forcing_battler = nil
  156.         # 移至步骤 1
  157.         @phase4_step = 1
  158.         return
  159.       end
  160.     end
  161.     # 清除对像战斗者
  162.     @target_battlers = []
  163.     # 行动种类分支
  164.     case @active_battler.current_action.kind
  165.     when 0  # 基本
  166.       make_basic_action_result
  167.     when 1  # 特技
  168.       make_skill_action_result
  169.     when 2  # 物品
  170.       make_item_action_result
  171.     end
  172.     # 移至步骤 3
  173.     if @phase4_step == 2
  174.       @phase4_step = 3
  175.     end
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 生成基本行动结果
  179.   #--------------------------------------------------------------------------
  180.   def make_basic_action_result
  181.     # 攻击的情况下
  182.     if @active_battler.current_action.basic == 0
  183.       # 设置攻击 ID
  184.       @animation1_id = @active_battler.animation1_id
  185.       @animation2_id = @active_battler.animation2_id
  186.       # 行动方的战斗者是敌人的情况下
  187.       if @active_battler.is_a?(Game_Enemy)
  188.         if @active_battler.restriction == 3
  189.           target = $game_troop.random_target_enemy
  190.         elsif @active_battler.restriction == 2
  191.           target = $game_party.random_target_actor
  192.         else
  193.           index = @active_battler.current_action.target_index
  194.           target = $game_party.smooth_target_actor(index)
  195.         end
  196.       end
  197.       # 行动方的战斗者是角色的情况下
  198.       if @active_battler.is_a?(Game_Actor)
  199.         if @active_battler.restriction == 3
  200.           target = $game_party.random_target_actor
  201.         elsif @active_battler.restriction == 2
  202.           target = $game_troop.random_target_enemy
  203.         else
  204.           index = @active_battler.current_action.target_index
  205.           target = $game_troop.smooth_target_enemy(index)
  206.         end
  207.       end
  208.       # 设置对像方的战斗者序列
  209.       @target_battlers = [target]
  210.       # 应用通常攻击效果
  211.       for target in @target_battlers
  212.         target.attack_effect(@active_battler)
  213.       end
  214.       return
  215.     end
  216.     # 防御的情况下
  217.     if @active_battler.current_action.basic == 1
  218.       # 帮助窗口显示"防御"
  219.       @help_window.set_text($data_system.words.guard, 1)
  220.       return
  221.     end
  222.     # 逃跑的情况下
  223.     if @active_battler.is_a?(Game_Enemy) and
  224.        @active_battler.current_action.basic == 2
  225.       #  帮助窗口显示"逃跑"
  226.       @help_window.set_text("逃跑", 1)
  227.       # 逃跑
  228.       @active_battler.escape
  229.       return
  230.     end
  231.     # 什么也不做的情况下
  232.     if @active_battler.current_action.basic == 3
  233.       # 清除强制行动对像的战斗者
  234.       $game_temp.forcing_battler = nil
  235.       # 移至步骤 1
  236.       @phase4_step = 1
  237.       return
  238.     end
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 设置物品或特技对像方的战斗者
  242.   #     scope : 特技或者是物品的范围
  243.   #--------------------------------------------------------------------------
  244.   def set_target_battlers(scope)
  245.     # 行动方的战斗者是敌人的情况下
  246.     if @active_battler.is_a?(Game_Enemy)
  247.       # 效果范围分支
  248.       case scope
  249.       when 1  # 敌单体
  250.         index = @active_battler.current_action.target_index
  251.         @target_battlers.push($game_party.smooth_target_actor(index))
  252.       when 2  # 敌全体
  253.         for actor in $game_party.actors
  254.           if actor.exist?
  255.             @target_battlers.push(actor)
  256.           end
  257.         end
  258.       when 3  # 我方单体
  259.         index = @active_battler.current_action.target_index
  260.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  261.       when 4  # 我方全体
  262.         for enemy in $game_troop.enemies
  263.           if enemy.exist?
  264.             @target_battlers.push(enemy)
  265.           end
  266.         end
  267.       when 5  # 我方单体 (HP 0)
  268.         index = @active_battler.current_action.target_index
  269.         enemy = $game_troop.enemies[index]
  270.         if enemy != nil and enemy.hp0?
  271.           @target_battlers.push(enemy)
  272.         end
  273.       when 6  # 我方全体 (HP 0)
  274.         for enemy in $game_troop.enemies
  275.           if enemy != nil and enemy.hp0?
  276.             @target_battlers.push(enemy)
  277.           end
  278.         end
  279.       when 7  # 使用者
  280.         @target_battlers.push(@active_battler)
  281.       end
  282.     end
  283.     # 行动方的战斗者是角色的情况下
  284.     if @active_battler.is_a?(Game_Actor)
  285.       # 效果范围分支
  286.       case scope
  287.       when 1  # 敌单体
  288.         index = @active_battler.current_action.target_index
  289.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  290.       when 2  # 敌全体
  291.         for enemy in $game_troop.enemies
  292.           if enemy.exist?
  293.             @target_battlers.push(enemy)
  294.           end
  295.         end
  296.       when 3  # 我方单体
  297.         index = @active_battler.current_action.target_index
  298.         @target_battlers.push($game_party.smooth_target_actor(index))
  299.       when 4  # 我方全体
  300.         for actor in $game_party.actors
  301.           if actor.exist?
  302.             @target_battlers.push(actor)
  303.           end
  304.         end
  305.       when 5  # 我方单体 (HP 0)
  306.         index = @active_battler.current_action.target_index
  307.         actor = $game_party.actors[index]
  308.         if actor != nil and actor.hp0?
  309.           @target_battlers.push(actor)
  310.         end
  311.       when 6  # 我方全体 (HP 0)
  312.         for actor in $game_party.actors
  313.           if actor != nil and actor.hp0?
  314.             @target_battlers.push(actor)
  315.           end
  316.         end
  317.       when 7  # 使用者
  318.         @target_battlers.push(@active_battler)
  319.       end
  320.     end
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● 生成特技行动结果
  324.   #--------------------------------------------------------------------------
  325.   def make_skill_action_result
  326.     # 获取特技
  327.     @skill = $data_skills[@active_battler.current_action.skill_id]
  328.     # 如果不是强制行动
  329.     unless @active_battler.current_action.forcing
  330.       # 因为 SP 耗尽而无法使用的情况下
  331.       unless @active_battler.skill_can_use?(@skill.id)
  332.         # 清除强制行动对像的战斗者
  333.         $game_temp.forcing_battler = nil
  334.         # 移至步骤 1
  335.         @phase4_step = 1
  336.         return
  337.       end
  338.     end
  339.    


  340.    
  341.    
  342. # 消耗 SP
  343.     @active_battler.sp -= @skill.sp_cost
  344.    
  345.      if @skill.element_set.include?(20) #  ★消耗绝技值
  346.       @active_battler.tp -= 100
  347.     end
  348.    
  349.    
  350.     # 刷新状态窗口
  351.     @status_window.refresh
  352.     # 在帮助窗口显示特技名
  353.     @help_window.set_text(@skill.name, 1)
  354.     # 设置动画 ID
  355.     @animation1_id = @skill.animation1_id
  356.     @animation2_id = @skill.animation2_id
  357.     # 设置公共事件 ID
  358.     @common_event_id = @skill.common_event_id
  359.     # 设置对像侧战斗者
  360.     set_target_battlers(@skill.scope)
  361.     # 应用特技效果
  362.     for target in @target_battlers
  363.       target.skill_effect(@active_battler, @skill)
  364.     end
  365.    
  366.    
  367.    
  368.    
  369.    
  370.     #================================================================
  371.     if @active_battler.is_a?(Game_Actor)
  372.       $game_temp.actor_skill[@active_battler.id] = @skill.id#只改了这么三行
  373.     end
  374.     #================================================================
  375.    
  376.    
  377.    
  378.    
  379.    
  380.    
  381.    
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   # ● 生成物品行动结果
  385.   #--------------------------------------------------------------------------
  386.   def make_item_action_result
  387.     # 获取物品
  388.     @item = $data_items[@active_battler.current_action.item_id]
  389.     # 因为物品耗尽而无法使用的情况下
  390.     unless $game_party.item_can_use?(@item.id)
  391.       # 移至步骤 1
  392.       @phase4_step = 1
  393.       return
  394.     end
  395.     # 消耗品的情况下
  396.     if @item.consumable
  397.       # 使用的物品减 1
  398.       $game_party.lose_item(@item.id, 1)
  399.     end
  400.     # 在帮助窗口显示物品名
  401.     @help_window.set_text(@item.name, 1)
  402.     # 设置动画 ID
  403.     @animation1_id = @item.animation1_id
  404.     @animation2_id = @item.animation2_id
  405.     # 设置公共事件 ID
  406.     @common_event_id = @item.common_event_id
  407.     # 确定对像
  408.     index = @active_battler.current_action.target_index
  409.     target = $game_party.smooth_target_actor(index)
  410.     # 设置对像侧战斗者
  411.     set_target_battlers(@item.scope)
  412.     # 应用物品效果
  413.     for target in @target_battlers
  414.       target.item_effect(@item)
  415.     end
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  419.   #--------------------------------------------------------------------------
  420.   def update_phase4_step3
  421.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  422.     if @animation1_id == 0
  423.       @active_battler.white_flash = true
  424.     else
  425.       @active_battler.animation_id = @animation1_id
  426.       @active_battler.animation_hit = true
  427.     end
  428.     # 移至步骤 4
  429.     @phase4_step = 4
  430.   end
  431.   #--------------------------------------------------------------------------
  432.   # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  433.   #--------------------------------------------------------------------------
  434.   def update_phase4_step4
  435.     # 对像方动画
  436.     for target in @target_battlers
  437.       target.animation_id = @animation2_id
  438.       target.animation_hit = (target.damage != "Miss")
  439.     end
  440.     # 限制动画长度、最低 8 帧
  441.     @wait_count = 8
  442.     # 移至步骤 5
  443.     @phase4_step = 5
  444.   end
  445.   #--------------------------------------------------------------------------
  446.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  447.   #--------------------------------------------------------------------------
  448.   def update_phase4_step5
  449.     # 隐藏帮助窗口
  450.     @help_window.visible = false
  451.     # 刷新状态窗口
  452.     @status_window.refresh
  453.     # 显示伤害
  454.     for target in @target_battlers
  455.       if target.damage != nil
  456.         target.damage_pop = true
  457.       end
  458.     end
  459.     # 移至步骤 6
  460.     @phase4_step = 6
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  464.   #--------------------------------------------------------------------------
  465.   def update_phase4_step6
  466.     # 清除强制行动对像的战斗者
  467.     $game_temp.forcing_battler = nil
  468.     # 公共事件 ID 有效的情况下
  469.     if @common_event_id > 0
  470.       # 设置事件
  471.       common_event = $data_common_events[@common_event_id]
  472.       $game_system.battle_interpreter.setup(common_event.list, 0)
  473.     end
  474.     # 移至步骤 1
  475.     @phase4_step = 1
  476.   end
  477. end
复制代码


全局战斗.zip

1.08 MB, 下载次数: 67

退隐....

路人党员

梦石
0
星屑
52
在线时间
2276 小时
注册时间
2010-12-30
回帖
3011
发表于 2016-9-9 18:45:10 | 显示全部楼层
请搜索战斗中换人
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到engshun@1ppl.me咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
回帖
308
发表于 2016-9-9 18:56:34 | 显示全部楼层
可以在战斗菜单多加一个选项,然后写相应的命令
回复

使用道具 举报

梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
回帖
308
发表于 2016-9-9 21:52:31 | 显示全部楼层
把374行开始的三行擦了就没有问题了

点评

我编辑到附件了  发表于 2016-9-10 19:12
你能不能把工程发来?我把战斗换人删了,还是有错,这就要看其他地方怎么写的了 这三句话意义是什么我也不知道,actor_skill我不知道它是怎么定义的  发表于 2016-9-10 15:51
我用了 一键打怪脚本啊  发表于 2016-9-10 12:08
Q键好像本来就没什么反应,在哪个场景点Q键?  发表于 2016-9-10 10:09
擦了是可以了,但一键打怪不能用了,就是Q键使用上一次使用的技能,因为换了人,不是那个人物了  发表于 2016-9-10 09:38
回复

使用道具 举报

梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
回帖
308
发表于 2016-9-12 16:47:01 | 显示全部楼层
你让我仔细研究一下
回复

使用道具 举报

梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
回帖
308
发表于 2016-9-18 17:35:25 | 显示全部楼层
这样行不行?
不过改出战人数,换人动画要直接到脚本中去改了
我把换人中的那段Scene_battle搞到Scene_battle改里面去了,所以换人的那段Scene_battle可以直接删了

全局战斗改.rar

1.09 MB, 下载次数: 71

点评

好的我自己再研究下,谢谢  发表于 2016-9-19 16:52
就是圆圈的那几个加换人,我说错了  发表于 2016-9-19 15:25
没有看到五角星,我的原来的是圆圈,你是说你修改了那几个+换人,还有新增了三个?  发表于 2016-9-19 07:26
我该的就是那几个打五角星的,还有换人的那几个  发表于 2016-9-18 22:10
你还要整合什么脚本?  发表于 2016-9-18 22:08

评分

参与人数 1星屑 +45 收起 理由
y967 + 45 塞糖

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部