查看: 2563|回复: 3

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

[复制链接]
梦石
0
星屑
740
在线时间
1 小时
注册时间
2017-4-4
回帖
0
发表于 2017-4-8 14:15:25 | 显示全部楼层 |阅读模式

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

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

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

点评

这个问题挺麻烦的。加人是简单的。但是加人会影响很多因素,而默认是根据4人来设置的。你以后还会遇到由此引发的问题,比如修改坐标  发表于 2017-4-18 13:39
梦石
1
星屑
24088
在线时间
3339 小时
注册时间
2011-7-8
回帖
3862

开拓者

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

使用道具 举报

梦石
0
星屑
1381
在线时间
295 小时
注册时间
2014-6-24
回帖
93
发表于 2017-4-9 20:25:55 | 显示全部楼层
这个不难实现,至于细节方面的自己改动一下,例如战斗指令,菜单角色的排版之类的

  1. module LimBattlePlug

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

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

  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.     self.z = 9999
  142.     refresh
  143.     self.index = -1
  144.     self.active = false
  145.   end
  146.   # 刷新
  147.   def refresh
  148.     @item_max = $game_party.actors2.size
  149.     @data = []
  150.     $game_party.actors.each do |actor|
  151.       @data.push(actor)
  152.     end
  153.     $game_party.actors2.each do |actor|
  154.       @data.push(actor) if !@data.include?(actor)
  155.     end
  156.     if self.contents != nil
  157.       self.contents.clear
  158.       self.contents = nil
  159.     end
  160.     self.contents = Bitmap.new(608,@data.size*32)
  161.     x = 4
  162.     y = 0
  163.     @data.each do |actor|
  164.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  165.       rect = Rect.new(0,0,bitmap.width/4,31)
  166.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
  167.       draw_actor_name(actor,x+36,y)
  168.       draw_actor_level(actor,156,y)
  169.       draw_actor_hp(actor,x+256,y,96)
  170.       draw_actor_sp(actor,x+376,y,96)
  171.       if $game_party.actors.include?(actor)
  172.         self.contents.font.color = text_color(6)
  173.         cword = "出战"
  174.       else
  175.         self.contents.font.color = text_color(0)
  176.         cword = "待战"
  177.       end
  178.       self.contents.draw_text(x+550,y,60,32,cword)
  179.       y += 32
  180.     end
  181.   end
  182.   # 获取当前角色编号
  183.   def actor_id
  184.     return @data[self.index].id
  185.   end
  186.   # 刷新帮助
  187.   def update_help
  188.     @help_window.set_text(@data[self.index] == nil ?\
  189.                           "" : @data[self.index].name)
  190.   end
  191. end

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

  510. class Window_MenuStatus
  511.   def refresh
  512.     self.contents.clear
  513.     @item_max = $game_party.actors.size
  514.     self.contents = Bitmap.new(width - 32, row_max * 32)
  515.     for i in 0...$game_party.actors.size
  516.       x = 4
  517.       y = i * 32
  518.       actor = $game_party.actors[i]
  519.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  520.       rect = Rect.new(0,0,bitmap.width/4,31)
  521.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
  522.       draw_actor_name(actor, x+36, y)
  523.       #draw_actor_state(actor, x + 136,y)
  524.       draw_actor_level(actor, x + 136,y)
  525.       draw_actor_hp(actor, x + 236, y,96)
  526.       draw_actor_sp(actor, x + 336, y,96)
  527.     end
  528.   end
  529.   def update_cursor_rect
  530.     super
  531.   end
  532. end
复制代码

评分

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

查看全部评分

回复 1 0

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部