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

Project1

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

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

[复制链接]

Lv4.逐梦者

梦石
0
星屑
13566
在线时间
3845 小时
注册时间
2013-7-18
帖子
2307
跳转到指定楼层
1
发表于 2016-9-9 16:08:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 y967 于 2016-9-10 19:11 编辑

RUBY 代码复制
  1. module LimBattlePlug
  2.  
  3. # 队伍最大人数
  4. MaxPartySize = 8
  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,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


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

RUBY 代码复制
  1. #==============================================================================
  2. # ■ Scene_Battle (分割定义 4)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的类。
  5. #==============================================================================
  6.  
  7. class Scene_Battle
  8.   #--------------------------------------------------------------------------
  9.   # ● 开始主回合
  10.   #--------------------------------------------------------------------------
  11.   def start_phase4
  12.     # 转移到回合 4
  13.     @phase = 4
  14.     # 回合数计数
  15.     $game_temp.battle_turn += 1
  16.     # 搜索全页的战斗事件
  17.     for index in 0...$data_troops[@troop_id].pages.size
  18.       # 获取事件页
  19.       page = $data_troops[@troop_id].pages[index]
  20.       # 本页的范围是 [回合] 的情况下
  21.       if page.span == 1
  22.         # 设置已经执行标志
  23.         $game_temp.battle_event_flags[index] = false
  24.       end
  25.     end
  26.     # 设置角色为非选择状态
  27.     @actor_index = -1
  28.     @active_battler = nil
  29.     # 有效化同伴指令窗口
  30.     @party_command_window.active = false
  31.     @party_command_window.visible = false
  32.     # 无效化角色指令窗口
  33.     @actor_command_window.active = false
  34.     @actor_command_window.visible = false
  35.     # 设置主回合标志
  36.     $game_temp.battle_main_phase = true
  37.     # 生成敌人行动
  38.     for enemy in $game_troop.enemies
  39.       enemy.make_action
  40.     end
  41.     # 生成行动顺序
  42.     make_action_orders
  43.     # 移动到步骤 1
  44.     @phase4_step = 1
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● 生成行动循序
  48.   #--------------------------------------------------------------------------
  49.   def make_action_orders
  50.     # 初始化序列 @action_battlers
  51.     @action_battlers = []
  52.     # 添加敌人到 @action_battlers 序列
  53.     for enemy in $game_troop.enemies
  54.       @action_battlers.push(enemy)
  55.     end
  56.     # 添加角色到 @action_battlers 序列
  57.     for actor in $game_party.actors
  58.       @action_battlers.push(actor)
  59.     end
  60.     # 确定全体的行动速度
  61.     for battler in @action_battlers
  62.       battler.make_action_speed
  63.     end
  64.     # 按照行动速度从大到小排列
  65.     @action_battlers.sort! {|a,b|
  66.       b.current_action.speed - a.current_action.speed }
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 刷新画面 (主回合)
  70.   #--------------------------------------------------------------------------
  71.   def update_phase4
  72.     case @phase4_step
  73.     when 1
  74.       update_phase4_step1
  75.     when 2
  76.       update_phase4_step2
  77.     when 3
  78.       update_phase4_step3
  79.     when 4
  80.       update_phase4_step4
  81.     when 5
  82.       update_phase4_step5
  83.     when 6
  84.       update_phase4_step6
  85.     end
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 刷新画面 (主回合步骤 1 : 准备行动)
  89.   #--------------------------------------------------------------------------
  90.   def update_phase4_step1
  91.     # 隐藏帮助窗口
  92.     @help_window.visible = false
  93.     # 判定胜败
  94.     if judge
  95.       # 胜利或者失败的情况下 : 过程结束
  96.       return
  97.     end
  98.     # 强制行动的战斗者不存在的情况下
  99.     if $game_temp.forcing_battler == nil
  100.       # 设置战斗事件
  101.       setup_battle_event
  102.       # 执行战斗事件中的情况下
  103.       if $game_system.battle_interpreter.running?
  104.         return
  105.       end
  106.     end
  107.     # 强制行动的战斗者存在的情况下
  108.     if $game_temp.forcing_battler != nil
  109.       # 在头部添加后移动
  110.       @action_battlers.delete($game_temp.forcing_battler)
  111.       @action_battlers.unshift($game_temp.forcing_battler)
  112.     end
  113.     # 未行动的战斗者不存在的情况下 (全员已经行动)
  114.     if @action_battlers.size == 0
  115.       # 开始同伴命令回合
  116.       start_phase2
  117.       return
  118.     end
  119.     # 初始化动画 ID 和公共事件 ID
  120.     @animation1_id = 0
  121.     @animation2_id = 0
  122.     @common_event_id = 0
  123.     # 未行动的战斗者移动到序列的头部
  124.     @active_battler = @action_battlers.shift
  125.     # 如果已经在战斗之外的情况下
  126.     if @active_battler.index == nil
  127.       return
  128.     end
  129.     # 连续伤害
  130.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  131.       @active_battler.slip_damage_effect
  132.       @active_battler.damage_pop = true
  133.     end
  134.     # 自然解除状态
  135.     @active_battler.remove_states_auto
  136.     # 刷新状态窗口
  137.     @status_window.refresh
  138.     # 移至步骤 2
  139.     @phase4_step = 2
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  143.   #--------------------------------------------------------------------------
  144.   def update_phase4_step2
  145.     # 如果不是强制行动
  146.     unless @active_battler.current_action.forcing
  147.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  148.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  149.         # 设置行动为攻击
  150.         @active_battler.current_action.kind = 0
  151.         @active_battler.current_action.basic = 0
  152.       end
  153.       # 限制为 [不能行动] 的情况下
  154.       if @active_battler.restriction == 4
  155.         # 清除行动强制对像的战斗者
  156.         $game_temp.forcing_battler = nil
  157.         # 移至步骤 1
  158.         @phase4_step = 1
  159.         return
  160.       end
  161.     end
  162.     # 清除对像战斗者
  163.     @target_battlers = []
  164.     # 行动种类分支
  165.     case @active_battler.current_action.kind
  166.     when 0  # 基本
  167.       make_basic_action_result
  168.     when 1  # 特技
  169.       make_skill_action_result
  170.     when 2  # 物品
  171.       make_item_action_result
  172.     end
  173.     # 移至步骤 3
  174.     if @phase4_step == 2
  175.       @phase4_step = 3
  176.     end
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 生成基本行动结果
  180.   #--------------------------------------------------------------------------
  181.   def make_basic_action_result
  182.     # 攻击的情况下
  183.     if @active_battler.current_action.basic == 0
  184.       # 设置攻击 ID
  185.       @animation1_id = @active_battler.animation1_id
  186.       @animation2_id = @active_battler.animation2_id
  187.       # 行动方的战斗者是敌人的情况下
  188.       if @active_battler.is_a?(Game_Enemy)
  189.         if @active_battler.restriction == 3
  190.           target = $game_troop.random_target_enemy
  191.         elsif @active_battler.restriction == 2
  192.           target = $game_party.random_target_actor
  193.         else
  194.           index = @active_battler.current_action.target_index
  195.           target = $game_party.smooth_target_actor(index)
  196.         end
  197.       end
  198.       # 行动方的战斗者是角色的情况下
  199.       if @active_battler.is_a?(Game_Actor)
  200.         if @active_battler.restriction == 3
  201.           target = $game_party.random_target_actor
  202.         elsif @active_battler.restriction == 2
  203.           target = $game_troop.random_target_enemy
  204.         else
  205.           index = @active_battler.current_action.target_index
  206.           target = $game_troop.smooth_target_enemy(index)
  207.         end
  208.       end
  209.       # 设置对像方的战斗者序列
  210.       @target_battlers = [target]
  211.       # 应用通常攻击效果
  212.       for target in @target_battlers
  213.         target.attack_effect(@active_battler)
  214.       end
  215.       return
  216.     end
  217.     # 防御的情况下
  218.     if @active_battler.current_action.basic == 1
  219.       # 帮助窗口显示"防御"
  220.       @help_window.set_text($data_system.words.guard, 1)
  221.       return
  222.     end
  223.     # 逃跑的情况下
  224.     if @active_battler.is_a?(Game_Enemy) and
  225.        @active_battler.current_action.basic == 2
  226.       #  帮助窗口显示"逃跑"
  227.       @help_window.set_text("逃跑", 1)
  228.       # 逃跑
  229.       @active_battler.escape
  230.       return
  231.     end
  232.     # 什么也不做的情况下
  233.     if @active_battler.current_action.basic == 3
  234.       # 清除强制行动对像的战斗者
  235.       $game_temp.forcing_battler = nil
  236.       # 移至步骤 1
  237.       @phase4_step = 1
  238.       return
  239.     end
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ● 设置物品或特技对像方的战斗者
  243.   #     scope : 特技或者是物品的范围
  244.   #--------------------------------------------------------------------------
  245.   def set_target_battlers(scope)
  246.     # 行动方的战斗者是敌人的情况下
  247.     if @active_battler.is_a?(Game_Enemy)
  248.       # 效果范围分支
  249.       case scope
  250.       when 1  # 敌单体
  251.         index = @active_battler.current_action.target_index
  252.         @target_battlers.push($game_party.smooth_target_actor(index))
  253.       when 2  # 敌全体
  254.         for actor in $game_party.actors
  255.           if actor.exist?
  256.             @target_battlers.push(actor)
  257.           end
  258.         end
  259.       when 3  # 我方单体
  260.         index = @active_battler.current_action.target_index
  261.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  262.       when 4  # 我方全体
  263.         for enemy in $game_troop.enemies
  264.           if enemy.exist?
  265.             @target_battlers.push(enemy)
  266.           end
  267.         end
  268.       when 5  # 我方单体 (HP 0)
  269.         index = @active_battler.current_action.target_index
  270.         enemy = $game_troop.enemies[index]
  271.         if enemy != nil and enemy.hp0?
  272.           @target_battlers.push(enemy)
  273.         end
  274.       when 6  # 我方全体 (HP 0)
  275.         for enemy in $game_troop.enemies
  276.           if enemy != nil and enemy.hp0?
  277.             @target_battlers.push(enemy)
  278.           end
  279.         end
  280.       when 7  # 使用者
  281.         @target_battlers.push(@active_battler)
  282.       end
  283.     end
  284.     # 行动方的战斗者是角色的情况下
  285.     if @active_battler.is_a?(Game_Actor)
  286.       # 效果范围分支
  287.       case scope
  288.       when 1  # 敌单体
  289.         index = @active_battler.current_action.target_index
  290.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  291.       when 2  # 敌全体
  292.         for enemy in $game_troop.enemies
  293.           if enemy.exist?
  294.             @target_battlers.push(enemy)
  295.           end
  296.         end
  297.       when 3  # 我方单体
  298.         index = @active_battler.current_action.target_index
  299.         @target_battlers.push($game_party.smooth_target_actor(index))
  300.       when 4  # 我方全体
  301.         for actor in $game_party.actors
  302.           if actor.exist?
  303.             @target_battlers.push(actor)
  304.           end
  305.         end
  306.       when 5  # 我方单体 (HP 0)
  307.         index = @active_battler.current_action.target_index
  308.         actor = $game_party.actors[index]
  309.         if actor != nil and actor.hp0?
  310.           @target_battlers.push(actor)
  311.         end
  312.       when 6  # 我方全体 (HP 0)
  313.         for actor in $game_party.actors
  314.           if actor != nil and actor.hp0?
  315.             @target_battlers.push(actor)
  316.           end
  317.         end
  318.       when 7  # 使用者
  319.         @target_battlers.push(@active_battler)
  320.       end
  321.     end
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # ● 生成特技行动结果
  325.   #--------------------------------------------------------------------------
  326.   def make_skill_action_result
  327.     # 获取特技
  328.     @skill = $data_skills[@active_battler.current_action.skill_id]
  329.     # 如果不是强制行动
  330.     unless @active_battler.current_action.forcing
  331.       # 因为 SP 耗尽而无法使用的情况下
  332.       unless @active_battler.skill_can_use?(@skill.id)
  333.         # 清除强制行动对像的战斗者
  334.         $game_temp.forcing_battler = nil
  335.         # 移至步骤 1
  336.         @phase4_step = 1
  337.         return
  338.       end
  339.     end
  340.  
  341.  
  342.  
  343.  
  344.  
  345. # 消耗 SP
  346.     @active_battler.sp -= @skill.sp_cost
  347.  
  348.      if @skill.element_set.include?(20) #  ★消耗绝技值
  349.       @active_battler.tp -= 100
  350.     end
  351.  
  352.  
  353.     # 刷新状态窗口
  354.     @status_window.refresh
  355.     # 在帮助窗口显示特技名
  356.     @help_window.set_text(@skill.name, 1)
  357.     # 设置动画 ID
  358.     @animation1_id = @skill.animation1_id
  359.     @animation2_id = @skill.animation2_id
  360.     # 设置公共事件 ID
  361.     @common_event_id = @skill.common_event_id
  362.     # 设置对像侧战斗者
  363.     set_target_battlers(@skill.scope)
  364.     # 应用特技效果
  365.     for target in @target_battlers
  366.       target.skill_effect(@active_battler, @skill)
  367.     end
  368.  
  369.  
  370.  
  371.  
  372.  
  373.     #================================================================
  374.     if @active_battler.is_a?(Game_Actor)
  375.       $game_temp.actor_skill[@active_battler.id] = @skill.id#只改了这么三行
  376.     end
  377.     #================================================================
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 生成物品行动结果
  388.   #--------------------------------------------------------------------------
  389.   def make_item_action_result
  390.     # 获取物品
  391.     @item = $data_items[@active_battler.current_action.item_id]
  392.     # 因为物品耗尽而无法使用的情况下
  393.     unless $game_party.item_can_use?(@item.id)
  394.       # 移至步骤 1
  395.       @phase4_step = 1
  396.       return
  397.     end
  398.     # 消耗品的情况下
  399.     if @item.consumable
  400.       # 使用的物品减 1
  401.       $game_party.lose_item(@item.id, 1)
  402.     end
  403.     # 在帮助窗口显示物品名
  404.     @help_window.set_text(@item.name, 1)
  405.     # 设置动画 ID
  406.     @animation1_id = @item.animation1_id
  407.     @animation2_id = @item.animation2_id
  408.     # 设置公共事件 ID
  409.     @common_event_id = @item.common_event_id
  410.     # 确定对像
  411.     index = @active_battler.current_action.target_index
  412.     target = $game_party.smooth_target_actor(index)
  413.     # 设置对像侧战斗者
  414.     set_target_battlers(@item.scope)
  415.     # 应用物品效果
  416.     for target in @target_battlers
  417.       target.item_effect(@item)
  418.     end
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  422.   #--------------------------------------------------------------------------
  423.   def update_phase4_step3
  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.   # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  436.   #--------------------------------------------------------------------------
  437.   def update_phase4_step4
  438.     # 对像方动画
  439.     for target in @target_battlers
  440.       target.animation_id = @animation2_id
  441.       target.animation_hit = (target.damage != "Miss")
  442.     end
  443.     # 限制动画长度、最低 8 帧
  444.     @wait_count = 8
  445.     # 移至步骤 5
  446.     @phase4_step = 5
  447.   end
  448.   #--------------------------------------------------------------------------
  449.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  450.   #--------------------------------------------------------------------------
  451.   def update_phase4_step5
  452.     # 隐藏帮助窗口
  453.     @help_window.visible = false
  454.     # 刷新状态窗口
  455.     @status_window.refresh
  456.     # 显示伤害
  457.     for target in @target_battlers
  458.       if target.damage != nil
  459.         target.damage_pop = true
  460.       end
  461.     end
  462.     # 移至步骤 6
  463.     @phase4_step = 6
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  467.   #--------------------------------------------------------------------------
  468.   def update_phase4_step6
  469.     # 清除强制行动对像的战斗者
  470.     $game_temp.forcing_battler = nil
  471.     # 公共事件 ID 有效的情况下
  472.     if @common_event_id > 0
  473.       # 设置事件
  474.       common_event = $data_common_events[@common_event_id]
  475.       $game_system.battle_interpreter.setup(common_event.list, 0)
  476.     end
  477.     # 移至步骤 1
  478.     @phase4_step = 1
  479.   end
  480. end


全局战斗.zip

1.08 MB, 下载次数: 67

山岚野人,快人快语,礼数不周,还望海涵....

Lv1.梦旅人

路人党员

梦石
0
星屑
52
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
2
发表于 2016-9-9 18:45:10 | 只看该作者
请搜索战斗中换人
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
帖子
337
3
发表于 2016-9-9 18:56:34 | 只看该作者
可以在战斗菜单多加一个选项,然后写相应的命令
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
帖子
337
4
发表于 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
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
帖子
337
5
发表于 2016-9-12 16:47:01 | 只看该作者
你让我仔细研究一下
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
帖子
337
6
发表于 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 塞糖

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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