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

Project1

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

[已经解决] RPG MAKER XP 怎么修改队伍人数4人以上?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
740
在线时间
1 小时
注册时间
2017-4-4
帖子
1
跳转到指定楼层
1
发表于 2017-4-8 14:15:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RPG MAKER XP 怎么修改队伍人数4人以上?(系统默认4人上限)脚本怎么修改?我被这个问题困扰好几天了

点评

这个问题挺麻烦的。加人是简单的。但是加人会影响很多因素,而默认是根据4人来设置的。你以后还会遇到由此引发的问题,比如修改坐标  发表于 2017-4-18 13:39

Lv5.捕梦者 (版主)

梦石
1
星屑
23984
在线时间
3339 小时
注册时间
2011-7-8
帖子
3926

开拓者

2
发表于 2017-4-8 18:25:51 | 只看该作者
建议弃疗……详情去看水区刚发的帖子
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1373
在线时间
295 小时
注册时间
2014-6-24
帖子
100
3
发表于 2017-4-9 20:25:55 | 只看该作者
这个不难实现,至于细节方面的自己改动一下,例如战斗指令,菜单角色的排版之类的

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

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

回复 支持 1 反对 0

使用道具 举报

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

本版积分规则

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

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

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

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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