查看: 8567|回复: 12

[原创发布] 【半原创】队伍系统(又名角色仓库)

[复制链接]
梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2013-9-14 11:05:28 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 RyanBern 于 2015-10-17 22:18 编辑

很早就想做这个队伍系统了,应该有人做过类似的,不过还是自己做一个分享一下吧。应该有一定的实用价值。
内容还不是很完善,有时间会改进的。
具体的说明全在代码里了,在新的RMXP工程中可以正常运行。


最近炒的第二顿冷饭,这个人物仓库系统重新写了一下。增添了战斗换人的若干内容,修复了一些BUG。
新功能没用做特别多,因为功能越多脚本冲突越大,你懂的。如果外挂脚本过多,很可能需要整合才可使用。
如果已经使用了旧脚本,则强烈建议用这个新版本的队伍系统。
2.0 版本使用方法依然在脚本当中,这次附上了范例。
测试次数较少,如果发现错误欢迎报告。
  1. #=============================================================================
  2. # 队伍系统 Ver 2.1
  3. #-----------------------------------------------------------------------------
  4. # 类似于 Aveyond 的队伍系统(根据阿月系列的游戏产生的灵感)
  5. # By :RyanBern
  6. #-----------------------------------------------------------------------------
  7. # 功能特色:
  8. #-----------------------------------------------------------------------------
  9. # 1.更改队伍中成员的最大数量,有四名出战队员,但是替补队员可以有很多个。
  10. # 2.对 Game_Party 的队员设置和 Scene_Battle 的部分方法有较大改动,可能造成脚本
  11. #   冲突。
  12. # 3.为队伍增加“领队”角色,作为“领队”的成员在地图上显示他的图形。
  13. # 4.在战斗命令中增添“换人”命令,可以将替补队员换上场。
  14. # 5.如果队伍的出战队员全部阵亡,则直接判定玩家全灭,不管有无替补队员。但是如果
  15. #   在地图上,则是所有队员阵亡才会被判定全灭。
  16. # 6.事件编译器中,对全体同伴的处理均包括对替补队员的处理。
  17. # 7.(Ver 2.1)战斗中可以设置自动替换阵亡队员,自动替换的时机为所有该行动的成员
  18. #   行动完毕之后。注意,如果某个队员的行动本来就是“换人”,不过他在回合开始后
  19. #   才阵亡,那么他本轮的替换指令将作废。
  20. #-----------------------------------------------------------------------------
  21. # 使用方法:
  22. #-----------------------------------------------------------------------------
  23. # 1.粘贴到默认脚本后面,Main组前面即可。
  24. # 2.在菜单中,左侧窗口被激活时,按 A 键可以改变领队(leader)的设置,按 S 键
  25. #   可以改变出战的队员。
  26. # 3.为队员设置“无法出战”的状态,即该队员不能被设置为出战队员。具体方法是
  27. #   使用事件脚本,例如,让 1 号角色无法出战:
  28. #   $game_actors[1].battle_disabled = true
  29. #   让 1 号角色恢复可以出战的状态:
  30. #   $game_actors[1].battle_disabled = false
  31. #   ###
  32. # 4.可在下方设置替补队员在战斗胜利之后是否获得 EXP 奖励。
  33. #-----------------------------------------------------------------------------
  34. # 更新记录:
  35. #   2015.04.22 : 重构脚本,增加战斗换人功能。
  36. #   2015.10.09 : 增加阵亡队员自动替换替补队员的功能。
  37. #=============================================================================
  38. module RB
  39. end

  40. module RB::Party
  41.   # “换人”命令的术语
  42.   Words_Swap = "换人"
  43.   
  44.   # 替补队员是否能在战斗胜利后获得 EXP 奖励,设置为 true 时可以获得奖励,设置
  45.   # 为 false 时则不能。
  46.   Get_Exp_Reserve = false
  47.   
  48.   # 角色阵亡时,是否自动切换替补队员,设置为 true 则开启此功能。
  49.   Auto_Swap = false
  50. end

  51. class Game_Temp
  52.   attr_accessor :gain_exp_flag
  53. end

  54. class Game_Party
  55.   attr_reader :battle_actors
  56.   alias old_ini initialize
  57.   def initialize
  58.     @leader_id = 0
  59.     @battle_actors = []
  60.     old_ini
  61.   end
  62.   def leader
  63.     return @leader_id == 0 ? nil : $game_actors[@leader_id]
  64.   end
  65.   def set_leader(actor_id)
  66.     @leader_id = actor_id
  67.     $game_player.refresh
  68.     $game_map.need_refresh = true
  69.   end
  70.   def actors
  71.     all_flag = !$game_temp.in_battle || (RB::Party::Get_Exp_Reserve && $game_temp.gain_exp_flag)
  72.     return all_flag ? @actors : @battle_actors
  73.   end
  74.   def all_actors
  75.     return @actors
  76.   end
  77.   def reserved_actors
  78.     return @actors - @battle_actors
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 加入同伴
  82.   #     actor_id : 角色 ID
  83.   #--------------------------------------------------------------------------
  84.   def add_actor(actor_id)
  85.     # 获取角色
  86.     actor = $game_actors[actor_id]
  87.     # 同伴人数未满 4 人、本角色不在队伍中的情况下
  88.     unless @actors.include?(actor)
  89.       # 添加角色
  90.       @actors.push(actor)
  91.       @battle_actors.push(actor) if @battle_actors.size < 4
  92.       self.set_leader(actor.id) if self.leader.nil?
  93.       # 还原主角
  94.       $game_player.refresh
  95.     end
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 角色离开
  99.   #     actor_id : 角色 ID
  100.   #--------------------------------------------------------------------------
  101.   def remove_actor(actor_id)
  102.     actor = $game_actors[actor_id]
  103.     # 删除角色
  104.     @actors.delete(actor)
  105.     @battle_actors.delete(actor)
  106.     self.set_leader(self.actors[0].id) if self.leader == actor
  107.     # 还原主角
  108.     $game_player.refresh
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 设置初期同伴
  112.   #--------------------------------------------------------------------------
  113.   def setup_starting_members
  114.     @actors = []
  115.     @battle_actors = []
  116.     for i in $data_system.party_members
  117.       @actors.push($game_actors[i])
  118.       @battle_actors.push($game_actors[i]) if @battle_actors.size < 4
  119.     end
  120.     self.set_leader(@actors[0].id) unless @actors.empty?
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 设置战斗测试用同伴
  124.   #--------------------------------------------------------------------------
  125.   def setup_battle_test_members
  126.     @actors = []
  127.     @battle_actors = []
  128.     for battler in $data_system.test_battlers
  129.       actor = $game_actors[battler.actor_id]
  130.       actor.level = battler.level
  131.       gain_weapon(battler.weapon_id, 1)
  132.       gain_armor(battler.armor1_id, 1)
  133.       gain_armor(battler.armor2_id, 1)
  134.       gain_armor(battler.armor3_id, 1)
  135.       gain_armor(battler.armor4_id, 1)
  136.       actor.equip(0, battler.weapon_id)
  137.       actor.equip(1, battler.armor1_id)
  138.       actor.equip(2, battler.armor2_id)
  139.       actor.equip(3, battler.armor3_id)
  140.       actor.equip(4, battler.armor4_id)
  141.       actor.recover_all
  142.       @actors.push(actor)
  143.       @battle_actors.push(actor)
  144.     end
  145.     @items = {}
  146.     for i in 1...$data_items.size
  147.       if $data_items[i].name != ""
  148.         occasion = $data_items[i].occasion
  149.         if occasion == 0 or occasion == 1
  150.           @items[i] = 99
  151.         end
  152.       end
  153.     end
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 同伴成员的还原
  157.   #--------------------------------------------------------------------------
  158.   def refresh
  159.     # 游戏数据载入后角色对像直接从 $game_actors
  160.     # 分离。
  161.     # 回避由于载入造成的角色再设置的问题。
  162.     new_actors = []
  163.     new_battle_actors = []
  164.     @actors.each do |actor|
  165.       if $data_actors[actor.id] != nil
  166.         new_actors.push($game_actors[actor.id])
  167.       end
  168.     end
  169.     @battle_actors.each do |actor|
  170.       if $data_actors[actor.id] != nil
  171.         new_battle_actors.push($game_actors[actor.id])
  172.       end
  173.     end
  174.     @actors = new_actors
  175.     @battle_actors = new_battle_actors
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 全灭判定
  179.   #--------------------------------------------------------------------------
  180.   def all_dead?
  181.     # 同伴人数为 0 的情况下
  182.     if self.actors.size == 0
  183.       return false
  184.     end
  185.     # 同伴中无人 HP 在 0 以上
  186.     for actor in self.actors
  187.       if actor.hp > 0
  188.         return false
  189.       end
  190.     end
  191.     # 全灭
  192.     return true
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● 对像角色的随机确定
  196.   #     hp0 : 限制为 HP 0 的角色
  197.   #--------------------------------------------------------------------------
  198.   def random_target_actor(hp0 = false)
  199.     # 初始化轮流
  200.     roulette = []
  201.     # 循环
  202.     for actor in @battle_actors
  203.       # 符合条件的场合
  204.       if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
  205.         # 获取角色职业的位置 [位置]
  206.         position = $data_classes[actor.class_id].position
  207.         # 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
  208.         n = 4 - position
  209.         # 添加角色的轮流 n 回
  210.         n.times do
  211.           roulette.push(actor)
  212.         end
  213.       end
  214.     end
  215.     # 轮流大小为 0 的情况
  216.     if roulette.size == 0
  217.       return nil
  218.     end
  219.     # 转轮盘赌,决定角色
  220.     return roulette[rand(roulette.size)]
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # ● 对像角色的顺序确定
  224.   #     actor_index : 角色索引
  225.   #--------------------------------------------------------------------------
  226.   def smooth_target_actor(actor_index)
  227.     # 取得对像
  228.     actor = @battle_actors[actor_index]
  229.     # 对像存在的情况下
  230.     if actor != nil and actor.exist?
  231.       return actor
  232.     end
  233.     # 循环
  234.     for actor in @actors
  235.       # 对像存在的情况下
  236.       if actor.exist?
  237.         return actor
  238.       end
  239.     end
  240.   end

  241. end

  242. class Game_Actor
  243.   attr_reader :battle_disabled
  244.   def leader?
  245.     return self == $game_party.leader
  246.   end
  247.   def active
  248.     return $game_party.battle_actors.include?(self)
  249.   end
  250.   def battle_disabled=(bool)
  251.     @battle_disabled = bool
  252.     $game_party.battle_actors.delete(self) if bool
  253.   end
  254. end

  255. class Game_Player
  256.   #--------------------------------------------------------------------------
  257.   # ● 刷新
  258.   #--------------------------------------------------------------------------
  259.   def refresh
  260.     # 同伴人数为 0 的情况下
  261.     if $game_party.actors.size == 0 or $game_party.leader == nil
  262.       # 清除角色的文件名及对像
  263.       @character_name = ""
  264.       @character_hue = 0
  265.       # 分支结束
  266.       return
  267.     end
  268.     # 获取带头的角色
  269.     if $game_party.leader != nil
  270.       actor = $game_party.leader
  271.       # 设置角色的文件名及对像
  272.       @character_name = actor.character_name
  273.       @character_hue = actor.character_hue
  274.       # 初始化不透明度和合成方式子
  275.       @opacity = 255
  276.       @blend_type = 0
  277.     end
  278.   end
  279. end

  280. class Game_BattleAction
  281.   attr_accessor :reserved_actor_id
  282.   unless method_defined? :rb_clear_20150422
  283.     alias rb_clear_20150422 clear
  284.     def clear
  285.       rb_clear_20150422
  286.       @reserved_actor_id = 0
  287.     end
  288.   end
  289. end

  290. class Window_Base < Window
  291.   def draw_actor_battle_position(actor, x, y)
  292.     if actor.leader?
  293.       if actor.active
  294.         text = "领队|出战"
  295.       else
  296.         text = "领队"
  297.       end
  298.       color = knockout_color
  299.     else
  300.       color = disabled_color
  301.       if actor.battle_disabled
  302.         text = "无法出战"
  303.       elsif actor.active
  304.         text = "出战"
  305.         color = normal_color
  306.       else
  307.         text = "待机"
  308.       end
  309.     end
  310.     self.contents.font.color = color
  311.     self.contents.draw_text(x, y, 120, 32, text)
  312.   end
  313. end

  314. #==============================================================================
  315. # ■ Window_Selectable
  316. #------------------------------------------------------------------------------
  317. #  拥有光标的移动以及滚动功能的窗口类。
  318. #==============================================================================

  319. class Window_Selectable < Window_Base
  320.   #--------------------------------------------------------------------------
  321.   # ● 定义实例变量
  322.   #--------------------------------------------------------------------------
  323.   attr_accessor :row_height               # 行高
  324.   #--------------------------------------------------------------------------
  325.   # ● 初始画对像
  326.   #     x      : 窗口的 X 坐标
  327.   #     y      : 窗口的 Y 坐标
  328.   #     width  : 窗口的宽
  329.   #     height : 窗口的高
  330.   #     row_height : 行高 默认是32
  331.   #--------------------------------------------------------------------------
  332.   alias rb_initialize_20150421 initialize
  333.   def initialize(x, y, width, height, row_height = 32)
  334.     @row_height = row_height
  335.     rb_initialize_20150421(x, y, width, height)
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● 获取开头行
  339.   #--------------------------------------------------------------------------
  340.   def top_row
  341.     # 将窗口内容的传送源 Y 坐标、1 行的高 @row_height 等分
  342.     return self.oy / @row_height
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # ● 设置开头行
  346.   #     row : 显示开头的行
  347.   #--------------------------------------------------------------------------
  348.   def top_row=(row)
  349.     # row 未满 0 的场合更正为 0
  350.     if row < 0
  351.       row = 0
  352.     end
  353.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  354.     if row > row_max - 1
  355.       row = row_max - 1
  356.     end
  357.     # row 1 行高的 @row_height 倍、窗口内容的传送源 Y 坐标
  358.     self.oy = row * @row_height
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● 获取 1 页可以显示的行数
  362.   #--------------------------------------------------------------------------
  363.   def page_row_max
  364.     # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 @row_height
  365.     return (self.height - 32) / @row_height
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● 更新光标举行
  369.   #--------------------------------------------------------------------------
  370.   def update_cursor_rect
  371.     # 光标位置不满 0 的情况下
  372.     if @index < 0
  373.       self.cursor_rect.empty
  374.       return
  375.     end
  376.     # 获取当前的行
  377.     row = @index / @column_max
  378.     # 当前行被显示开头行前面的情况下
  379.     if row < self.top_row
  380.       # 从当前行向开头行滚动
  381.       self.top_row = row
  382.     end
  383.     # 当前行被显示末尾行之后的情况下
  384.     if row > self.top_row + (self.page_row_max - 1)
  385.       # 从当前行向末尾滚动
  386.       self.top_row = row - (self.page_row_max - 1)
  387.     end
  388.     # 计算光标的宽
  389.     cursor_width = self.width / @column_max - 32
  390.     # 计算光标坐标
  391.     x = @index % @column_max * (cursor_width + 32)
  392.     y = @index / @column_max * @row_height - self.oy
  393.     # 更新国标矩形
  394.     self.cursor_rect.set(x, y, cursor_width, @row_height)
  395.   end
  396. end

  397. class Window_MenuStatus
  398.   def initialize
  399.     super(0, 0, 480, 480, 112)
  400.     refresh
  401.     self.active = false
  402.     self.index = -1
  403.   end
  404.   def refresh
  405.     if self.contents != nil
  406.       self.contents.dispose
  407.       self.contents = nil
  408.     end
  409.     @item_max = $game_party.actors.size
  410.     self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112)
  411.     for i in 0...$game_party.actors.size
  412.       x = 64
  413.       y = i * 112
  414.       actor = $game_party.actors[i]
  415.       draw_actor_graphic(actor, x - 40, y + 80)
  416.       draw_actor_name(actor, x, y)
  417.       draw_actor_class(actor, x + 144, y)
  418.       draw_actor_level(actor, x, y + 32)
  419.       draw_actor_state(actor, x + 90, y + 32)
  420.       draw_actor_exp(actor, x, y + 64)
  421.       draw_actor_hp(actor, x + 236, y + 32)
  422.       draw_actor_sp(actor, x + 236, y + 64)
  423.       draw_actor_battle_position(actor, x + 236, y)
  424.     end
  425.   end
  426.   def update_cursor_rect
  427.     super
  428.   end
  429. end

  430. class Window_Target
  431.   def initialize
  432.     super(0, 0, 336, 480, 112)
  433.     self.z += 10
  434.     @item_max = $game_party.actors.size
  435.     self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112)
  436.     refresh
  437.   end
  438.   def update_cursor_rect
  439.     super
  440.   end
  441. end

  442. class Window_ReservedActors < Window_Selectable
  443.   def initialize
  444.     super(0, 64, 640, 256, 112)
  445.     self.opacity = 160
  446.     self.index = 0
  447.     self.active = true
  448.     @column_max = 2
  449.     refresh
  450.   end
  451.   def actor
  452.     return @data[self.index]
  453.   end
  454.   def refresh
  455.     if self.contents != nil
  456.       self.contents.dispose
  457.       self.contents = nil
  458.     end
  459.     @data = []
  460.     $game_party.all_actors.each do |actor|
  461.       @data << actor unless actor.active || actor.battle_disabled
  462.     end
  463.     @item_max = @data.size
  464.     if @item_max > 0
  465.       self.contents = Bitmap.new (width - 32, (@item_max + 1) / 2 * 128)
  466.       @data.each_with_index do |actor, index|
  467.         x = 4 + index % 2 * (288 + 32)
  468.         y = index / 2 * 112
  469.         draw_actor_graphic(actor, x + 16, y + 80)
  470.         draw_actor_hp(actor, x + 48, y + 20)
  471.         draw_actor_sp(actor, x + 48, y + 52)
  472.       end
  473.     end
  474.   end
  475.   def update_help
  476.     # 帮助窗口显示角色的状态
  477.     self.actor == nil ? @help_window.set_text("") : @help_window.set_actor(self.actor)
  478.   end
  479. end

  480. class Scene_Menu
  481.   unless method_defined? :rb_update_command_20150421
  482.     alias rb_update_command_20150421 update_command
  483.     def update_command
  484.       if Input.trigger?(Input::X)
  485.         $game_system.se_play($data_system.decision_se)
  486.         @command_window.active = false
  487.         @status_window.active = true
  488.         @status_window.index = 0
  489.         @leader_adjust = true
  490.         return
  491.       end
  492.       if Input.trigger?(Input::Y)
  493.         $game_system.se_play($data_system.decision_se)
  494.         @command_window.active = false
  495.         @status_window.active = true
  496.         @status_window.index = 0
  497.         @battler_adjust = true
  498.         return
  499.       end
  500.       rb_update_command_20150421
  501.     end
  502.   end
  503.   unless method_defined? :rb_update_status_20150421
  504.     alias rb_update_status_20150421 update_status
  505.     def update_status
  506.       if @leader_adjust
  507.         update_leader
  508.         return
  509.       end
  510.       if @battler_adjust
  511.         update_battler
  512.         return
  513.       end
  514.       rb_update_status_20150421
  515.     end
  516.   end
  517.   def update_leader
  518.     if Input.trigger?(Input::B)
  519.       $game_system.se_play($data_system.cancel_se)
  520.       @leader_adjust = false
  521.       @status_window.active = false
  522.       @status_window.index = -1
  523.       @command_window.active = true
  524.       return
  525.     end
  526.     if Input.trigger?(Input::C)
  527.       if $game_party.actors.size == 0
  528.         $game_system.se_play($data_system.buzzer_se)
  529.       else
  530.         $game_system.se_play($data_system.decision_se)
  531.         $game_party.set_leader($game_party.actors[@status_window.index].id)
  532.         @status_window.refresh
  533.       end
  534.     end
  535.   end
  536.   def update_battler
  537.     if Input.trigger?(Input::B)
  538.       $game_system.se_play($data_system.cancel_se)
  539.       @battler_adjust = false
  540.       @status_window.active = false
  541.       @status_window.index = -1
  542.       @command_window.active = true
  543.       return
  544.     end
  545.     if Input.trigger?(Input::C)
  546.       actor = $game_party.actors[@status_window.index]
  547.       if actor == nil || actor.battle_disabled ||
  548.         (actor.active && $game_party.battle_actors.size == 1) ||
  549.         (!actor.active && $game_party.battle_actors.size == 4)
  550.         $game_system.se_play($data_system.buzzer_se)
  551.       else
  552.         $game_system.se_play($data_system.decision_se)
  553.         actor.active ? $game_party.battle_actors.delete(actor) : $game_party.battle_actors.push(actor)
  554.         @status_window.refresh
  555.       end
  556.     end
  557.   end
  558. end

  559. class Scene_Battle
  560.   def generate_modified_command_window
  561.     if @actor_command_window != nil
  562.       @actor_command_window.dispose
  563.       @actor_command_window = nil
  564.     end
  565.     s1 = $data_system.words.attack
  566.     s2 = $data_system.words.skill
  567.     s3 = $data_system.words.guard
  568.     s4 = $data_system.words.item
  569.     s5 = RB::Party::Words_Swap
  570.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
  571.     @actor_command_window.y = 128
  572.     @actor_command_window.back_opacity = 160
  573.     @actor_command_window.active = false
  574.     @actor_command_window.visible = false
  575.     @modified_generated = true
  576.   end
  577.   unless method_defined? :rb_phase3_setup_command_window_20150422
  578.     alias rb_phase3_setup_command_window_20150422 phase3_setup_command_window
  579.     def phase3_setup_command_window
  580.       generate_modified_command_window unless @modified_generated
  581.       rb_phase3_setup_command_window_20150422
  582.     end
  583.   end
  584.   def make_auto_swap_actors
  585.     return unless RB::Party::Auto_Swap
  586.     available_actors = $game_party.reserved_actors.reject{|actor| actor.dead?}
  587.     dead_actors = $game_party.battle_actors.select{|actor| actor.dead?}
  588.     return if available_actors.empty? || dead_actors.empty?
  589.     n = [available_actors.size, dead_actors.size].min
  590.     dead_actors.each_with_index do |actor, i|
  591.       break if i >= n
  592.       actor.current_action.kind = 3
  593.       actor.current_action.reserved_actor_id = available_actors[i].id
  594.       @action_battlers << actor
  595.     end
  596.   end
  597.   def update_phase3_basic_command
  598.     # 按下 B 键的情况下
  599.     if Input.trigger?(Input::B)
  600.       # 演奏取消 SE
  601.       $game_system.se_play($data_system.cancel_se)
  602.       # 转向前一个角色的指令输入
  603.       phase3_prior_actor
  604.       return
  605.     end
  606.     # 按下 C 键的情况下
  607.     if Input.trigger?(Input::C)
  608.       # 角色指令窗口光标位置分之
  609.       case @actor_command_window.index
  610.       when 0  # 攻击
  611.         # 演奏确定 SE
  612.         $game_system.se_play($data_system.decision_se)
  613.         # 设置行动
  614.         @active_battler.current_action.kind = 0
  615.         @active_battler.current_action.basic = 0
  616.         # 开始选择敌人
  617.         start_enemy_select
  618.       when 1  # 特技
  619.         # 演奏确定 SE
  620.         $game_system.se_play($data_system.decision_se)
  621.         # 设置行动
  622.         @active_battler.current_action.kind = 1
  623.         # 开始选择特技
  624.         start_skill_select
  625.       when 2  # 防御
  626.         # 演奏确定 SE
  627.         $game_system.se_play($data_system.decision_se)
  628.         # 设置行动
  629.         @active_battler.current_action.kind = 0
  630.         @active_battler.current_action.basic = 1
  631.         # 转向下一位角色的指令输入
  632.         phase3_next_actor
  633.       when 3  # 物品
  634.         # 演奏确定 SE
  635.         $game_system.se_play($data_system.decision_se)
  636.         # 设置行动
  637.         @active_battler.current_action.kind = 2
  638.         # 开始选择物品
  639.         start_item_select
  640.       when 4  # 换人
  641.         $game_system.se_play($data_system.decision_se)
  642.         @active_battler.current_action.kind = 3
  643.         start_reserved_actor_select
  644.       end
  645.       return
  646.     end
  647.   end
  648.   unless method_defined? :rb_update_phase3_20150422
  649.     alias rb_update_phase3_20150422 update_phase3
  650.     def update_phase3
  651.       if @actor_window != nil
  652.         update_phase3_reserved_actor_select
  653.         return
  654.       end
  655.       rb_update_phase3_20150422
  656.     end
  657.   end
  658.   def start_reserved_actor_select
  659.     # 生成特技窗口
  660.     @actor_window = Window_ReservedActors.new
  661.     # 关联帮助窗口
  662.     @actor_window.help_window = @help_window
  663.     @help_window.visible = true
  664.     # 无效化角色指令窗口
  665.     @actor_command_window.active = false
  666.     @actor_command_window.visible = false
  667.   end
  668.   def end_reserved_actor_select
  669.     # 释放特技窗口
  670.     @actor_window.dispose
  671.     @actor_window = nil
  672.     # 隐藏帮助窗口
  673.     @help_window.visible = false
  674.     # 有效化角色指令窗口
  675.     @actor_command_window.active = true
  676.     @actor_command_window.visible = true
  677.   end
  678.   def update_phase3_reserved_actor_select
  679.     @actor_window.visible = true
  680.     # 刷新特技窗口
  681.     @actor_window.update
  682.     # 按下 B 键的情况下
  683.     if Input.trigger?(Input::B)
  684.       # 演奏取消 SE
  685.       $game_system.se_play($data_system.cancel_se)
  686.       # 结束特技选择
  687.       end_reserved_actor_select
  688.       return
  689.     end
  690.     # 按下 C 键的情况下
  691.     if Input.trigger?(Input::C)
  692.       # 获取特技选择窗口现在选择的特技的数据
  693.       @reserved_actor = @actor_window.actor
  694.       # 无法使用的情况下
  695.       if @reserved_actor == nil
  696.         # 演奏冻结 SE
  697.         $game_system.se_play($data_system.buzzer_se)
  698.         return
  699.       end
  700.       # 演奏确定 SE
  701.       $game_system.se_play($data_system.decision_se)
  702.       # 设置行动
  703.       @active_battler.current_action.reserved_actor_id = @reserved_actor.id
  704.       # 设置特技窗口为不可见状态
  705.       @actor_window.visible = false
  706.       end_reserved_actor_select
  707.       phase3_next_actor
  708.       return
  709.     end
  710.   end
  711.   def update_phase4_step1
  712.     # 隐藏帮助窗口
  713.     @help_window.visible = false
  714.     # 判定胜败
  715.     if judge
  716.       # 胜利或者失败的情况下 : 过程结束
  717.       return
  718.     end
  719.     # 强制行动的战斗者不存在的情况下
  720.     if $game_temp.forcing_battler == nil
  721.       # 设置战斗事件
  722.       setup_battle_event
  723.       # 执行战斗事件中的情况下
  724.       if $game_system.battle_interpreter.running?
  725.         return
  726.       end
  727.     end
  728.     # 强制行动的战斗者存在的情况下
  729.     if $game_temp.forcing_battler != nil
  730.       # 在头部添加后移动
  731.       @action_battlers.delete($game_temp.forcing_battler)
  732.       @action_battlers.unshift($game_temp.forcing_battler)
  733.     end
  734.     # 未行动的战斗者不存在的情况下 (全员已经行动)
  735.     if @action_battlers.size == 0
  736.       make_auto_swap_actors
  737.       if @action_battlers.empty?
  738.         @auto_swap = false
  739.         # 开始同伴命令回合
  740.         start_phase2
  741.         return
  742.       else
  743.         @auto_swap = true
  744.       end
  745.     end
  746.     # 初始化动画 ID 和公共事件 ID
  747.     @animation1_id = 0
  748.     @animation2_id = 0
  749.     @common_event_id = 0
  750.     # 未行动的战斗者移动到序列的头部
  751.     @active_battler = @action_battlers.shift
  752.     # 如果已经在战斗之外的情况下
  753.     if @active_battler.index == nil
  754.       return
  755.     end
  756.     # 连续伤害
  757.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  758.       @active_battler.slip_damage_effect
  759.       @active_battler.damage_pop = true
  760.     end
  761.     # 自然解除状态
  762.     @active_battler.remove_states_auto
  763.     # 刷新状态窗口
  764.     @status_window.refresh
  765.     # 移至步骤 2
  766.     @phase4_step = 2
  767.   end
  768.   def update_phase4_step2
  769.     # 如果不是强制行动
  770.     unless @active_battler.current_action.forcing
  771.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  772.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  773.         # 设置行动为攻击
  774.         @active_battler.current_action.kind = 0
  775.         @active_battler.current_action.basic = 0
  776.       end
  777.       # 限制为 [不能行动] 的情况下
  778.       if @active_battler.restriction == 4 && !@auto_swap
  779.         # 清除行动强制对像的战斗者
  780.         $game_temp.forcing_battler = nil
  781.         # 移至步骤 1
  782.         @phase4_step = 1
  783.         return
  784.       end
  785.     end
  786.     # 清除对像战斗者
  787.     @target_battlers = []
  788.     # 行动种类分支
  789.     case @active_battler.current_action.kind
  790.     when 0  # 基本
  791.       make_basic_action_result
  792.     when 1  # 特技
  793.       make_skill_action_result
  794.     when 2  # 物品
  795.       make_item_action_result
  796.     when 3  # 换人
  797.       make_swap_action_result
  798.     end
  799.     # 移至步骤 3
  800.     if @phase4_step == 2
  801.       @phase4_step = 3
  802.     end
  803.   end
  804.   def make_swap_action_result
  805.     # 获取角色
  806.     @reserved_actor = $game_actors[@active_battler.current_action.reserved_actor_id]
  807.     # 无法替换的情况下
  808.     if @reserved_actor == nil || @reserved_actor.active
  809.       # 移至步骤 1
  810.       @phase4_step = 1
  811.       return
  812.     end
  813.     # 在帮助窗口显示文字
  814.     text = "与#{@reserved_actor.name}交换"
  815.     @help_window.set_text(text, 1)
  816.     # 设置动画 ID
  817.     @animation1_id = 0
  818.     index = $game_party.actors.index(@active_battler)
  819.     $game_party.actors[index] = @reserved_actor
  820.   end
  821.   unless method_defined? :rb_start_phase5_20150422
  822.     alias rb_start_phase5_20150422 start_phase5
  823.     def start_phase5
  824.       $game_temp.gain_exp_flag = true
  825.       rb_start_phase5_20150422
  826.       $game_temp.gain_exp_flag = false
  827.     end
  828.   end
  829. end

复制代码

截图效果如下:
1.png
2.png
这个换人的效果比较短,只是角色闪了一下,人就换好了。目前正在改进当中。

换人瞬间

换人瞬间


附范例一枚:
Project6.rar (198.82 KB, 下载次数: 329)

评分

参与人数 1星屑 +200 收起 理由
feizhaodan + 200 奖赏条例

查看全部评分

梦石
0
星屑
50
在线时间
11 小时
注册时间
2013-10-6
回帖
26
发表于 2013-10-24 13:49:07 | 显示全部楼层
谢谢lz分享

评分

参与人数 1星屑 +15 收起 理由
欧买歌 + 15 - 15 理由:纯水

查看全部评分

回复

使用道具 举报

梦石
0
星屑
222
在线时间
57 小时
注册时间
2007-8-2
回帖
20
发表于 2015-4-21 20:21:43 | 显示全部楼层
用替换队友事件休战的角色不能离开。。可以解决下么

点评

脚本重写完毕,请到主楼上复制新脚本即可。  发表于 2015-4-22 21:39
此脚本正在改版重写,这个问题在解决当中。  发表于 2015-4-21 21:43
回复

使用道具 举报

【欧皇】

梦石
3
星屑
2055
在线时间
1004 小时
注册时间
2013-8-19
回帖
3040

开拓者

发表于 2015-4-21 22:12:53 | 显示全部楼层
我记得有一个类似的,比楼主的更自由,有更多选项供脚本用户选择,就是因为出战的全灭后无视替补人员直接gameover我才不用的,对不起,楼主的我也不会用了……
QQ:2223942063
Q群:365819625
贪吃方1.4
回复

使用道具 举报

梦石
0
星屑
50
在线时间
29 小时
注册时间
2015-3-7
回帖
11
发表于 2015-4-23 14:04:04 | 显示全部楼层
怎么换人啊,按A和S貌似都没反应的样子

点评

这样啊,我还以为是对着人物按A或S呢  发表于 2015-4-24 17:20
按A或S之后,光标会跑到右边的状态栏里面,这时候用空格切换。  发表于 2015-4-23 14:15
回复

使用道具 举报

梦石
0
星屑
674
在线时间
5 小时
注册时间
2015-5-16
回帖
4
发表于 2015-5-30 13:54:37 | 显示全部楼层
刚开始接触,研究一下
回复

使用道具 举报

梦石
0
星屑
462
在线时间
871 小时
注册时间
2014-5-5
回帖
914
发表于 2015-6-3 23:15:58 | 显示全部楼层
商店购买只显示前4个角色,不知能否显示全部角色?
另外能否请版主帮我整合下,我有个脚本和你这冲突了

Project6.rar

300.53 KB, 下载次数: 47

回复

使用道具 举报

梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

 楼主| 发表于 2015-6-4 09:16:05 | 显示全部楼层
邪月长啸 发表于 2015-6-3 23:15
商店购买只显示前4个角色,不知能否显示全部角色?
另外能否请版主帮我整合下,我有个脚本和你这冲突了
...

Scripts.rxdata (135.26 KB, 下载次数: 71)
显示全部角色排版会出问题,这里就没有做。
另外脚本已经整合完毕。

评分

参与人数 1星屑 +60 收起 理由
邪月长啸 + 60 非常感谢

查看全部评分

回复

使用道具 举报

梦石
0
星屑
94
在线时间
157 小时
注册时间
2006-7-2
回帖
250
发表于 2015-9-11 07:34:00 | 显示全部楼层
谢谢大神的角色仓库脚本,很好地解决了队伍人数超过上限的问题。
不过我在用“自动战斗”脚本的时候出现了冲突,换人功能无法正常使用
还望求解

https://rpg.blue/thread-383273-1-1.html
甘泉幻想物语 试玩版4.0
https://rpg.blue/forum.php?mod=viewthread&tid=369490&page=1&extra=#pid2534710
回复

使用道具 举报

梦石
0
星屑
50
在线时间
23 小时
注册时间
2015-8-10
回帖
12
发表于 2015-9-26 16:12:23 | 显示全部楼层
其实我觉得这个脚本还是稍稍有一点不实用的地方,因为一个队员死亡后就无法换人了,请问有没有可能做到死亡后可以用其他队员替换掉他呢?谢谢

点评

你要的功能已经改好,请到主楼查看。测试次数较少因此有BUG请务必通知我。  发表于 2015-10-9 15:16
谢谢QUQ!刚好有工程需要用  发表于 2015-10-7 12:35
你说的这个问题还需要再设计一下。最近有一些时间,我在国庆期间更新一下吧。  发表于 2015-9-27 09:45
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部