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

Project1

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

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

[复制链接]

Lv4.逐梦者 (版主)

梦石
0
星屑
9497
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

跳转到指定楼层
1
发表于 2013-9-14 11:05:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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


最近炒的第二顿冷饭,这个人物仓库系统重新写了一下。增添了战斗换人的若干内容,修复了一些BUG。
新功能没用做特别多,因为功能越多脚本冲突越大,你懂的。如果外挂脚本过多,很可能需要整合才可使用。
如果已经使用了旧脚本,则强烈建议用这个新版本的队伍系统。
2.0 版本使用方法依然在脚本当中,这次附上了范例。
测试次数较少,如果发现错误欢迎报告。
RUBY 代码复制
  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.  
  41. module RB::Party
  42.   # “换人”命令的术语
  43.   Words_Swap = "换人"
  44.  
  45.   # 替补队员是否能在战斗胜利后获得 EXP 奖励,设置为 true 时可以获得奖励,设置
  46.   # 为 false 时则不能。
  47.   Get_Exp_Reserve = false
  48.  
  49.   # 角色阵亡时,是否自动切换替补队员,设置为 true 则开启此功能。
  50.   Auto_Swap = false
  51. end
  52.  
  53. class Game_Temp
  54.   attr_accessor :gain_exp_flag
  55. end
  56.  
  57. class Game_Party
  58.   attr_reader :battle_actors
  59.   alias old_ini initialize
  60.   def initialize
  61.     @leader_id = 0
  62.     @battle_actors = []
  63.     old_ini
  64.   end
  65.   def leader
  66.     return @leader_id == 0 ? nil : $game_actors[@leader_id]
  67.   end
  68.   def set_leader(actor_id)
  69.     @leader_id = actor_id
  70.     $game_player.refresh
  71.     $game_map.need_refresh = true
  72.   end
  73.   def actors
  74.     all_flag = !$game_temp.in_battle || (RB::Party::Get_Exp_Reserve && $game_temp.gain_exp_flag)
  75.     return all_flag ? @actors : @battle_actors
  76.   end
  77.   def all_actors
  78.     return @actors
  79.   end
  80.   def reserved_actors
  81.     return @actors - @battle_actors
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ● 加入同伴
  85.   #     actor_id : 角色 ID
  86.   #--------------------------------------------------------------------------
  87.   def add_actor(actor_id)
  88.     # 获取角色
  89.     actor = $game_actors[actor_id]
  90.     # 同伴人数未满 4 人、本角色不在队伍中的情况下
  91.     unless @actors.include?(actor)
  92.       # 添加角色
  93.       @actors.push(actor)
  94.       @battle_actors.push(actor) if @battle_actors.size < 4
  95.       self.set_leader(actor.id) if self.leader.nil?
  96.       # 还原主角
  97.       $game_player.refresh
  98.     end
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 角色离开
  102.   #     actor_id : 角色 ID
  103.   #--------------------------------------------------------------------------
  104.   def remove_actor(actor_id)
  105.     actor = $game_actors[actor_id]
  106.     # 删除角色
  107.     @actors.delete(actor)
  108.     @battle_actors.delete(actor)
  109.     self.set_leader(self.actors[0].id) if self.leader == actor
  110.     # 还原主角
  111.     $game_player.refresh
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 设置初期同伴
  115.   #--------------------------------------------------------------------------
  116.   def setup_starting_members
  117.     @actors = []
  118.     @battle_actors = []
  119.     for i in $data_system.party_members
  120.       @actors.push($game_actors[i])
  121.       @battle_actors.push($game_actors[i]) if @battle_actors.size < 4
  122.     end
  123.     self.set_leader(@actors[0].id) unless @actors.empty?
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 设置战斗测试用同伴
  127.   #--------------------------------------------------------------------------
  128.   def setup_battle_test_members
  129.     @actors = []
  130.     @battle_actors = []
  131.     for battler in $data_system.test_battlers
  132.       actor = $game_actors[battler.actor_id]
  133.       actor.level = battler.level
  134.       gain_weapon(battler.weapon_id, 1)
  135.       gain_armor(battler.armor1_id, 1)
  136.       gain_armor(battler.armor2_id, 1)
  137.       gain_armor(battler.armor3_id, 1)
  138.       gain_armor(battler.armor4_id, 1)
  139.       actor.equip(0, battler.weapon_id)
  140.       actor.equip(1, battler.armor1_id)
  141.       actor.equip(2, battler.armor2_id)
  142.       actor.equip(3, battler.armor3_id)
  143.       actor.equip(4, battler.armor4_id)
  144.       actor.recover_all
  145.       @actors.push(actor)
  146.       @battle_actors.push(actor)
  147.     end
  148.     @items = {}
  149.     for i in 1...$data_items.size
  150.       if $data_items[i].name != ""
  151.         occasion = $data_items[i].occasion
  152.         if occasion == 0 or occasion == 1
  153.           @items[i] = 99
  154.         end
  155.       end
  156.     end
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 同伴成员的还原
  160.   #--------------------------------------------------------------------------
  161.   def refresh
  162.     # 游戏数据载入后角色对像直接从 $game_actors
  163.     # 分离。
  164.     # 回避由于载入造成的角色再设置的问题。
  165.     new_actors = []
  166.     new_battle_actors = []
  167.     @actors.each do |actor|
  168.       if $data_actors[actor.id] != nil
  169.         new_actors.push($game_actors[actor.id])
  170.       end
  171.     end
  172.     @battle_actors.each do |actor|
  173.       if $data_actors[actor.id] != nil
  174.         new_battle_actors.push($game_actors[actor.id])
  175.       end
  176.     end
  177.     @actors = new_actors
  178.     @battle_actors = new_battle_actors
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ● 全灭判定
  182.   #--------------------------------------------------------------------------
  183.   def all_dead?
  184.     # 同伴人数为 0 的情况下
  185.     if self.actors.size == 0
  186.       return false
  187.     end
  188.     # 同伴中无人 HP 在 0 以上
  189.     for actor in self.actors
  190.       if actor.hp > 0
  191.         return false
  192.       end
  193.     end
  194.     # 全灭
  195.     return true
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # ● 对像角色的随机确定
  199.   #     hp0 : 限制为 HP 0 的角色
  200.   #--------------------------------------------------------------------------
  201.   def random_target_actor(hp0 = false)
  202.     # 初始化轮流
  203.     roulette = []
  204.     # 循环
  205.     for actor in @battle_actors
  206.       # 符合条件的场合
  207.       if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
  208.         # 获取角色职业的位置 [位置]
  209.         position = $data_classes[actor.class_id].position
  210.         # 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
  211.         n = 4 - position
  212.         # 添加角色的轮流 n 回
  213.         n.times do
  214.           roulette.push(actor)
  215.         end
  216.       end
  217.     end
  218.     # 轮流大小为 0 的情况
  219.     if roulette.size == 0
  220.       return nil
  221.     end
  222.     # 转轮盘赌,决定角色
  223.     return roulette[rand(roulette.size)]
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 对像角色的顺序确定
  227.   #     actor_index : 角色索引
  228.   #--------------------------------------------------------------------------
  229.   def smooth_target_actor(actor_index)
  230.     # 取得对像
  231.     actor = @battle_actors[actor_index]
  232.     # 对像存在的情况下
  233.     if actor != nil and actor.exist?
  234.       return actor
  235.     end
  236.     # 循环
  237.     for actor in @actors
  238.       # 对像存在的情况下
  239.       if actor.exist?
  240.         return actor
  241.       end
  242.     end
  243.   end
  244.  
  245. end
  246.  
  247. class Game_Actor
  248.   attr_reader :battle_disabled
  249.   def leader?
  250.     return self == $game_party.leader
  251.   end
  252.   def active
  253.     return $game_party.battle_actors.include?(self)
  254.   end
  255.   def battle_disabled=(bool)
  256.     @battle_disabled = bool
  257.     $game_party.battle_actors.delete(self) if bool
  258.   end
  259. end
  260.  
  261. class Game_Player
  262.   #--------------------------------------------------------------------------
  263.   # ● 刷新
  264.   #--------------------------------------------------------------------------
  265.   def refresh
  266.     # 同伴人数为 0 的情况下
  267.     if $game_party.actors.size == 0 or $game_party.leader == nil
  268.       # 清除角色的文件名及对像
  269.       @character_name = ""
  270.       @character_hue = 0
  271.       # 分支结束
  272.       return
  273.     end
  274.     # 获取带头的角色
  275.     if $game_party.leader != nil
  276.       actor = $game_party.leader
  277.       # 设置角色的文件名及对像
  278.       @character_name = actor.character_name
  279.       @character_hue = actor.character_hue
  280.       # 初始化不透明度和合成方式子
  281.       @opacity = 255
  282.       @blend_type = 0
  283.     end
  284.   end
  285. end
  286.  
  287. class Game_BattleAction
  288.   attr_accessor :reserved_actor_id
  289.   unless method_defined? :rb_clear_20150422
  290.     alias rb_clear_20150422 clear
  291.     def clear
  292.       rb_clear_20150422
  293.       @reserved_actor_id = 0
  294.     end
  295.   end
  296. end
  297.  
  298. class Window_Base < Window
  299.   def draw_actor_battle_position(actor, x, y)
  300.     if actor.leader?
  301.       if actor.active
  302.         text = "领队|出战"
  303.       else
  304.         text = "领队"
  305.       end
  306.       color = knockout_color
  307.     else
  308.       color = disabled_color
  309.       if actor.battle_disabled
  310.         text = "无法出战"
  311.       elsif actor.active
  312.         text = "出战"
  313.         color = normal_color
  314.       else
  315.         text = "待机"
  316.       end
  317.     end
  318.     self.contents.font.color = color
  319.     self.contents.draw_text(x, y, 120, 32, text)
  320.   end
  321. end
  322.  
  323. #==============================================================================
  324. # ■ Window_Selectable
  325. #------------------------------------------------------------------------------
  326. #  拥有光标的移动以及滚动功能的窗口类。
  327. #==============================================================================
  328.  
  329. class Window_Selectable < Window_Base
  330.   #--------------------------------------------------------------------------
  331.   # ● 定义实例变量
  332.   #--------------------------------------------------------------------------
  333.   attr_accessor :row_height               # 行高
  334.   #--------------------------------------------------------------------------
  335.   # ● 初始画对像
  336.   #     x      : 窗口的 X 坐标
  337.   #     y      : 窗口的 Y 坐标
  338.   #     width  : 窗口的宽
  339.   #     height : 窗口的高
  340.   #     row_height : 行高 默认是32
  341.   #--------------------------------------------------------------------------
  342.   alias rb_initialize_20150421 initialize
  343.   def initialize(x, y, width, height, row_height = 32)
  344.     @row_height = row_height
  345.     rb_initialize_20150421(x, y, width, height)
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● 获取开头行
  349.   #--------------------------------------------------------------------------
  350.   def top_row
  351.     # 将窗口内容的传送源 Y 坐标、1 行的高 @row_height 等分
  352.     return self.oy / @row_height
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● 设置开头行
  356.   #     row : 显示开头的行
  357.   #--------------------------------------------------------------------------
  358.   def top_row=(row)
  359.     # row 未满 0 的场合更正为 0
  360.     if row < 0
  361.       row = 0
  362.     end
  363.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  364.     if row > row_max - 1
  365.       row = row_max - 1
  366.     end
  367.     # row 1 行高的 @row_height 倍、窗口内容的传送源 Y 坐标
  368.     self.oy = row * @row_height
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ● 获取 1 页可以显示的行数
  372.   #--------------------------------------------------------------------------
  373.   def page_row_max
  374.     # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 @row_height
  375.     return (self.height - 32) / @row_height
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # ● 更新光标举行
  379.   #--------------------------------------------------------------------------
  380.   def update_cursor_rect
  381.     # 光标位置不满 0 的情况下
  382.     if @index < 0
  383.       self.cursor_rect.empty
  384.       return
  385.     end
  386.     # 获取当前的行
  387.     row = @index / @column_max
  388.     # 当前行被显示开头行前面的情况下
  389.     if row < self.top_row
  390.       # 从当前行向开头行滚动
  391.       self.top_row = row
  392.     end
  393.     # 当前行被显示末尾行之后的情况下
  394.     if row > self.top_row + (self.page_row_max - 1)
  395.       # 从当前行向末尾滚动
  396.       self.top_row = row - (self.page_row_max - 1)
  397.     end
  398.     # 计算光标的宽
  399.     cursor_width = self.width / @column_max - 32
  400.     # 计算光标坐标
  401.     x = @index % @column_max * (cursor_width + 32)
  402.     y = @index / @column_max * @row_height - self.oy
  403.     # 更新国标矩形
  404.     self.cursor_rect.set(x, y, cursor_width, @row_height)
  405.   end
  406. end
  407.  
  408. class Window_MenuStatus
  409.   def initialize
  410.     super(0, 0, 480, 480, 112)
  411.     refresh
  412.     self.active = false
  413.     self.index = -1
  414.   end
  415.   def refresh
  416.     if self.contents != nil
  417.       self.contents.dispose
  418.       self.contents = nil
  419.     end
  420.     @item_max = $game_party.actors.size
  421.     self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112)
  422.     for i in 0...$game_party.actors.size
  423.       x = 64
  424.       y = i * 112
  425.       actor = $game_party.actors[i]
  426.       draw_actor_graphic(actor, x - 40, y + 80)
  427.       draw_actor_name(actor, x, y)
  428.       draw_actor_class(actor, x + 144, y)
  429.       draw_actor_level(actor, x, y + 32)
  430.       draw_actor_state(actor, x + 90, y + 32)
  431.       draw_actor_exp(actor, x, y + 64)
  432.       draw_actor_hp(actor, x + 236, y + 32)
  433.       draw_actor_sp(actor, x + 236, y + 64)
  434.       draw_actor_battle_position(actor, x + 236, y)
  435.     end
  436.   end
  437.   def update_cursor_rect
  438.     super
  439.   end
  440. end
  441.  
  442. class Window_Target
  443.   def initialize
  444.     super(0, 0, 336, 480, 112)
  445.     self.z += 10
  446.     @item_max = $game_party.actors.size
  447.     self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112)
  448.     refresh
  449.   end
  450.   def update_cursor_rect
  451.     super
  452.   end
  453. end
  454.  
  455. class Window_ReservedActors < Window_Selectable
  456.   def initialize
  457.     super(0, 64, 640, 256, 112)
  458.     self.opacity = 160
  459.     self.index = 0
  460.     self.active = true
  461.     @column_max = 2
  462.     refresh
  463.   end
  464.   def actor
  465.     return @data[self.index]
  466.   end
  467.   def refresh
  468.     if self.contents != nil
  469.       self.contents.dispose
  470.       self.contents = nil
  471.     end
  472.     @data = []
  473.     $game_party.all_actors.each do |actor|
  474.       @data << actor unless actor.active || actor.battle_disabled
  475.     end
  476.     @item_max = @data.size
  477.     if @item_max > 0
  478.       self.contents = Bitmap.new (width - 32, (@item_max + 1) / 2 * 128)
  479.       @data.each_with_index do |actor, index|
  480.         x = 4 + index % 2 * (288 + 32)
  481.         y = index / 2 * 112
  482.         draw_actor_graphic(actor, x + 16, y + 80)
  483.         draw_actor_hp(actor, x + 48, y + 20)
  484.         draw_actor_sp(actor, x + 48, y + 52)
  485.       end
  486.     end
  487.   end
  488.   def update_help
  489.     # 帮助窗口显示角色的状态
  490.     self.actor == nil ? @help_window.set_text("") : @help_window.set_actor(self.actor)
  491.   end
  492. end
  493.  
  494. class Scene_Menu
  495.   unless method_defined? :rb_update_command_20150421
  496.     alias rb_update_command_20150421 update_command
  497.     def update_command
  498.       if Input.trigger?(Input::X)
  499.         $game_system.se_play($data_system.decision_se)
  500.         @command_window.active = false
  501.         @status_window.active = true
  502.         @status_window.index = 0
  503.         @leader_adjust = true
  504.         return
  505.       end
  506.       if Input.trigger?(Input::Y)
  507.         $game_system.se_play($data_system.decision_se)
  508.         @command_window.active = false
  509.         @status_window.active = true
  510.         @status_window.index = 0
  511.         @battler_adjust = true
  512.         return
  513.       end
  514.       rb_update_command_20150421
  515.     end
  516.   end
  517.   unless method_defined? :rb_update_status_20150421
  518.     alias rb_update_status_20150421 update_status
  519.     def update_status
  520.       if @leader_adjust
  521.         update_leader
  522.         return
  523.       end
  524.       if @battler_adjust
  525.         update_battler
  526.         return
  527.       end
  528.       rb_update_status_20150421
  529.     end
  530.   end
  531.   def update_leader
  532.     if Input.trigger?(Input::B)
  533.       $game_system.se_play($data_system.cancel_se)
  534.       @leader_adjust = false
  535.       @status_window.active = false
  536.       @status_window.index = -1
  537.       @command_window.active = true
  538.       return
  539.     end
  540.     if Input.trigger?(Input::C)
  541.       if $game_party.actors.size == 0
  542.         $game_system.se_play($data_system.buzzer_se)
  543.       else
  544.         $game_system.se_play($data_system.decision_se)
  545.         $game_party.set_leader($game_party.actors[@status_window.index].id)
  546.         @status_window.refresh
  547.       end
  548.     end
  549.   end
  550.   def update_battler
  551.     if Input.trigger?(Input::B)
  552.       $game_system.se_play($data_system.cancel_se)
  553.       @battler_adjust = false
  554.       @status_window.active = false
  555.       @status_window.index = -1
  556.       @command_window.active = true
  557.       return
  558.     end
  559.     if Input.trigger?(Input::C)
  560.       actor = $game_party.actors[@status_window.index]
  561.       if actor == nil || actor.battle_disabled ||
  562.         (actor.active && $game_party.battle_actors.size == 1) ||
  563.         (!actor.active && $game_party.battle_actors.size == 4)
  564.         $game_system.se_play($data_system.buzzer_se)
  565.       else
  566.         $game_system.se_play($data_system.decision_se)
  567.         actor.active ? $game_party.battle_actors.delete(actor) : $game_party.battle_actors.push(actor)
  568.         @status_window.refresh
  569.       end
  570.     end
  571.   end
  572. end
  573.  
  574. class Scene_Battle
  575.   def generate_modified_command_window
  576.     if @actor_command_window != nil
  577.       @actor_command_window.dispose
  578.       @actor_command_window = nil
  579.     end
  580.     s1 = $data_system.words.attack
  581.     s2 = $data_system.words.skill
  582.     s3 = $data_system.words.guard
  583.     s4 = $data_system.words.item
  584.     s5 = RB::Party::Words_Swap
  585.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
  586.     @actor_command_window.y = 128
  587.     @actor_command_window.back_opacity = 160
  588.     @actor_command_window.active = false
  589.     @actor_command_window.visible = false
  590.     @modified_generated = true
  591.   end
  592.   unless method_defined? :rb_phase3_setup_command_window_20150422
  593.     alias rb_phase3_setup_command_window_20150422 phase3_setup_command_window
  594.     def phase3_setup_command_window
  595.       generate_modified_command_window unless @modified_generated
  596.       rb_phase3_setup_command_window_20150422
  597.     end
  598.   end
  599.   def make_auto_swap_actors
  600.     return unless RB::Party::Auto_Swap
  601.     available_actors = $game_party.reserved_actors.reject{|actor| actor.dead?}
  602.     dead_actors = $game_party.battle_actors.select{|actor| actor.dead?}
  603.     return if available_actors.empty? || dead_actors.empty?
  604.     n = [available_actors.size, dead_actors.size].min
  605.     dead_actors.each_with_index do |actor, i|
  606.       break if i >= n
  607.       actor.current_action.kind = 3
  608.       actor.current_action.reserved_actor_id = available_actors[i].id
  609.       @action_battlers << actor
  610.     end
  611.   end
  612.   def update_phase3_basic_command
  613.     # 按下 B 键的情况下
  614.     if Input.trigger?(Input::B)
  615.       # 演奏取消 SE
  616.       $game_system.se_play($data_system.cancel_se)
  617.       # 转向前一个角色的指令输入
  618.       phase3_prior_actor
  619.       return
  620.     end
  621.     # 按下 C 键的情况下
  622.     if Input.trigger?(Input::C)
  623.       # 角色指令窗口光标位置分之
  624.       case @actor_command_window.index
  625.       when 0  # 攻击
  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 = 0
  631.         # 开始选择敌人
  632.         start_enemy_select
  633.       when 1  # 特技
  634.         # 演奏确定 SE
  635.         $game_system.se_play($data_system.decision_se)
  636.         # 设置行动
  637.         @active_battler.current_action.kind = 1
  638.         # 开始选择特技
  639.         start_skill_select
  640.       when 2  # 防御
  641.         # 演奏确定 SE
  642.         $game_system.se_play($data_system.decision_se)
  643.         # 设置行动
  644.         @active_battler.current_action.kind = 0
  645.         @active_battler.current_action.basic = 1
  646.         # 转向下一位角色的指令输入
  647.         phase3_next_actor
  648.       when 3  # 物品
  649.         # 演奏确定 SE
  650.         $game_system.se_play($data_system.decision_se)
  651.         # 设置行动
  652.         @active_battler.current_action.kind = 2
  653.         # 开始选择物品
  654.         start_item_select
  655.       when 4  # 换人
  656.         $game_system.se_play($data_system.decision_se)
  657.         @active_battler.current_action.kind = 3
  658.         start_reserved_actor_select
  659.       end
  660.       return
  661.     end
  662.   end
  663.   unless method_defined? :rb_update_phase3_20150422
  664.     alias rb_update_phase3_20150422 update_phase3
  665.     def update_phase3
  666.       if @actor_window != nil
  667.         update_phase3_reserved_actor_select
  668.         return
  669.       end
  670.       rb_update_phase3_20150422
  671.     end
  672.   end
  673.   def start_reserved_actor_select
  674.     # 生成特技窗口
  675.     @actor_window = Window_ReservedActors.new
  676.     # 关联帮助窗口
  677.     @actor_window.help_window = @help_window
  678.     @help_window.visible = true
  679.     # 无效化角色指令窗口
  680.     @actor_command_window.active = false
  681.     @actor_command_window.visible = false
  682.   end
  683.   def end_reserved_actor_select
  684.     # 释放特技窗口
  685.     @actor_window.dispose
  686.     @actor_window = nil
  687.     # 隐藏帮助窗口
  688.     @help_window.visible = false
  689.     # 有效化角色指令窗口
  690.     @actor_command_window.active = true
  691.     @actor_command_window.visible = true
  692.   end
  693.   def update_phase3_reserved_actor_select
  694.     @actor_window.visible = true
  695.     # 刷新特技窗口
  696.     @actor_window.update
  697.     # 按下 B 键的情况下
  698.     if Input.trigger?(Input::B)
  699.       # 演奏取消 SE
  700.       $game_system.se_play($data_system.cancel_se)
  701.       # 结束特技选择
  702.       end_reserved_actor_select
  703.       return
  704.     end
  705.     # 按下 C 键的情况下
  706.     if Input.trigger?(Input::C)
  707.       # 获取特技选择窗口现在选择的特技的数据
  708.       @reserved_actor = @actor_window.actor
  709.       # 无法使用的情况下
  710.       if @reserved_actor == nil
  711.         # 演奏冻结 SE
  712.         $game_system.se_play($data_system.buzzer_se)
  713.         return
  714.       end
  715.       # 演奏确定 SE
  716.       $game_system.se_play($data_system.decision_se)
  717.       # 设置行动
  718.       @active_battler.current_action.reserved_actor_id = @reserved_actor.id
  719.       # 设置特技窗口为不可见状态
  720.       @actor_window.visible = false
  721.       end_reserved_actor_select
  722.       phase3_next_actor
  723.       return
  724.     end
  725.   end
  726.   def update_phase4_step1
  727.     # 隐藏帮助窗口
  728.     @help_window.visible = false
  729.     # 判定胜败
  730.     if judge
  731.       # 胜利或者失败的情况下 : 过程结束
  732.       return
  733.     end
  734.     # 强制行动的战斗者不存在的情况下
  735.     if $game_temp.forcing_battler == nil
  736.       # 设置战斗事件
  737.       setup_battle_event
  738.       # 执行战斗事件中的情况下
  739.       if $game_system.battle_interpreter.running?
  740.         return
  741.       end
  742.     end
  743.     # 强制行动的战斗者存在的情况下
  744.     if $game_temp.forcing_battler != nil
  745.       # 在头部添加后移动
  746.       @action_battlers.delete($game_temp.forcing_battler)
  747.       @action_battlers.unshift($game_temp.forcing_battler)
  748.     end
  749.     # 未行动的战斗者不存在的情况下 (全员已经行动)
  750.     if @action_battlers.size == 0
  751.       make_auto_swap_actors
  752.       if @action_battlers.empty?
  753.         @auto_swap = false
  754.         # 开始同伴命令回合
  755.         start_phase2
  756.         return
  757.       else
  758.         @auto_swap = true
  759.       end
  760.     end
  761.     # 初始化动画 ID 和公共事件 ID
  762.     @animation1_id = 0
  763.     @animation2_id = 0
  764.     @common_event_id = 0
  765.     # 未行动的战斗者移动到序列的头部
  766.     @active_battler = @action_battlers.shift
  767.     # 如果已经在战斗之外的情况下
  768.     if @active_battler.index == nil
  769.       return
  770.     end
  771.     # 连续伤害
  772.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  773.       @active_battler.slip_damage_effect
  774.       @active_battler.damage_pop = true
  775.     end
  776.     # 自然解除状态
  777.     @active_battler.remove_states_auto
  778.     # 刷新状态窗口
  779.     @status_window.refresh
  780.     # 移至步骤 2
  781.     @phase4_step = 2
  782.   end
  783.   def update_phase4_step2
  784.     # 如果不是强制行动
  785.     unless @active_battler.current_action.forcing
  786.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  787.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  788.         # 设置行动为攻击
  789.         @active_battler.current_action.kind = 0
  790.         @active_battler.current_action.basic = 0
  791.       end
  792.       # 限制为 [不能行动] 的情况下
  793.       if @active_battler.restriction == 4 && !@auto_swap
  794.         # 清除行动强制对像的战斗者
  795.         $game_temp.forcing_battler = nil
  796.         # 移至步骤 1
  797.         @phase4_step = 1
  798.         return
  799.       end
  800.     end
  801.     # 清除对像战斗者
  802.     @target_battlers = []
  803.     # 行动种类分支
  804.     case @active_battler.current_action.kind
  805.     when 0  # 基本
  806.       make_basic_action_result
  807.     when 1  # 特技
  808.       make_skill_action_result
  809.     when 2  # 物品
  810.       make_item_action_result
  811.     when 3  # 换人
  812.       make_swap_action_result
  813.     end
  814.     # 移至步骤 3
  815.     if @phase4_step == 2
  816.       @phase4_step = 3
  817.     end
  818.   end
  819.   def make_swap_action_result
  820.     # 获取角色
  821.     @reserved_actor = $game_actors[@active_battler.current_action.reserved_actor_id]
  822.     # 无法替换的情况下
  823.     if @reserved_actor == nil || @reserved_actor.active
  824.       # 移至步骤 1
  825.       @phase4_step = 1
  826.       return
  827.     end
  828.     # 在帮助窗口显示文字
  829.     text = "与#{@reserved_actor.name}交换"
  830.     @help_window.set_text(text, 1)
  831.     # 设置动画 ID
  832.     @animation1_id = 0
  833.     index = $game_party.actors.index(@active_battler)
  834.     $game_party.actors[index] = @reserved_actor
  835.   end
  836.   unless method_defined? :rb_start_phase5_20150422
  837.     alias rb_start_phase5_20150422 start_phase5
  838.     def start_phase5
  839.       $game_temp.gain_exp_flag = true
  840.       rb_start_phase5_20150422
  841.       $game_temp.gain_exp_flag = false
  842.     end
  843.   end
  844. end

截图效果如下:


这个换人的效果比较短,只是角色闪了一下,人就换好了。目前正在改进当中。


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

评分

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

查看全部评分

Lv1.梦旅人

梦石
0
星屑
50
在线时间
11 小时
注册时间
2013-10-6
帖子
27
2
发表于 2013-10-24 13:49:07 | 只看该作者
谢谢lz分享

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
220
在线时间
55 小时
注册时间
2007-8-2
帖子
21
3
发表于 2015-4-21 20:21:43 | 只看该作者
用替换队友事件休战的角色不能离开。。可以解决下么

点评

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

使用道具 举报

Lv4.逐梦者

【欧皇】

梦石
3
星屑
2035
在线时间
1004 小时
注册时间
2013-8-19
帖子
3486

开拓者

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
29 小时
注册时间
2015-3-7
帖子
13
5
发表于 2015-4-23 14:04:04 | 只看该作者
怎么换人啊,按A和S貌似都没反应的样子

点评

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
674
在线时间
5 小时
注册时间
2015-5-16
帖子
4
6
发表于 2015-5-30 13:54:37 | 只看该作者
刚开始接触,研究一下
回复 支持 反对

使用道具 举报

Lv1.梦旅人

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

Project6.rar

300.53 KB, 下载次数: 47

回复 支持 反对

使用道具 举报

Lv4.逐梦者 (版主)

梦石
0
星屑
9497
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

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

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

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
94
在线时间
157 小时
注册时间
2006-7-2
帖子
299
9
发表于 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
回复 支持 反对

使用道具 举报

Lv1.梦旅人

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

点评

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 00:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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