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

Project1

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

[已经过期] xp的换人脚本 的问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
62 小时
注册时间
2014-5-5
帖子
7
跳转到指定楼层
1
发表于 2014-9-12 17:14:48 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

QQ截图20140912170522.png (248.71 KB, 下载次数: 5)

QQ截图20140912170522.png

Lv1.梦旅人

梦石
0
星屑
50
在线时间
62 小时
注册时间
2014-5-5
帖子
7
2
 楼主| 发表于 2014-9-12 18:08:55 | 只看该作者
求修改的地方:1.战斗死亡的角色不自动弹框要求更换待战人员 人死了就死了
                     2.出战的5人死掉后就game over 就算待战有人还活着 也over了
    就这两个问题~~谢谢
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1155
在线时间
12 小时
注册时间
2014-3-8
帖子
3
3
发表于 2015-6-21 08:11:34 | 只看该作者
我也想知道啊
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-23 01:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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