搜索附件  
同能RPG制作大师 附件中心 同能RM技术讨论区 RPG Maker XP 讨论区 【半原创】队伍系统(又名角色仓库): d1.png

【半原创】队伍系统(又名角色仓库): d1.png

 

【半原创】队伍系统(又名角色仓库):
很早就想做这个队伍系统了,应该有人做过类似的,不过还是自己做一个分享一下吧。应该有一定的实用价值。
内容还不是很完善,有时间会改进的。
具体的说明全在代码里了,在新的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. moduleRB::Party
  41.   # “换人”命令的术语
  42.   Words_Swap = "换人"
  43.   # 替补队员是否能在战斗胜利后获得 EXP 奖励,设置为 true 时可以获得奖励,设置
  44.   # 为 false 时则不能。
  45.   Get_Exp_Reserve = false
  46.   # 角色阵亡时,是否自动切换替补队员,设置为 true 则开启此功能。
  47.   Auto_Swap = false
  48. end
  49. class Game_Temp
  50.   attr_accessor :gain_exp_flag
  51. end
  52. class Game_Party
  53.   attr_reader :battle_actors
  54.   alias old_ini initialize
  55.   def initialize
  56.     @leader_id = 0
  57.     @battle_actors = []
  58.     old_ini
  59.   end
  60.   def leader
  61.     return@leader_id == 0 ? nil : $game_actors[@leader_id]
  62.   end
  63.   def set_leader(actor_id)
  64.     @leader_id = actor_id
  65.     $game_player.refresh
  66.     $game_map.need_refresh = true
  67.   end
  68.   def actors
  69.     all_flag = !$game_temp.in_battle || (RB::Party::Get_Exp_Reserve && $game_temp.gain_exp_flag)
  70.     return all_flag ? @actors : @battle_actors
  71.   end
  72.   def all_actors
  73.     return@actors
  74.   end
  75.   def reserved_actors
  76.     return@actors - @battle_actors
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 加入同伴
  80.   #     actor_id : 角色 ID
  81.   #--------------------------------------------------------------------------
  82.   def add_actor(actor_id)
  83.     # 获取角色
  84.     actor = $game_actors[actor_id]
  85.     # 同伴人数未满 4 人、本角色不在队伍中的情况下
  86.     unless@actors.include?(actor)
  87.       # 添加角色
  88.       @actors.push(actor)
  89.       @battle_actors.push(actor)if@battle_actors.size < 4
  90.       self.set_leader(actor.id)ifself.leader.nil?
  91.       # 还原主角
  92.       $game_player.refresh
  93.     end
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● 角色离开
  97.   #     actor_id : 角色 ID
  98.   #--------------------------------------------------------------------------
  99.   def remove_actor(actor_id)
  100.     actor = $game_actors[actor_id]
  101.     # 删除角色
  102.     @actors.delete(actor)
  103.     @battle_actors.delete(actor)
  104.     self.set_leader(self.actors[0].id)ifself.leader == actor
  105.     # 还原主角
  106.     $game_player.refresh
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● 设置初期同伴
  110.   #--------------------------------------------------------------------------
  111.   def setup_starting_members
  112.     @actors = []
  113.     @battle_actors = []
  114.     for i in$data_system.party_members
  115.       @actors.push($game_actors[i])
  116.       @battle_actors.push($game_actors[i])if@battle_actors.size < 4
  117.     end
  118.     self.set_leader(@actors[0].id)unless@actors.empty?
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 设置战斗测试用同伴
  122.   #--------------------------------------------------------------------------
  123.   def setup_battle_test_members
  124.     @actors = []
  125.     @battle_actors = []
  126.     for battler in$data_system.test_battlers
  127.       actor = $game_actors[battler.actor_id]
  128.       actor.level = battler.level
  129.       gain_weapon(battler.weapon_id, 1)
  130.       gain_armor(battler.armor1_id, 1)
  131.       gain_armor(battler.armor2_id, 1)
  132.       gain_armor(battler.armor3_id, 1)
  133.       gain_armor(battler.armor4_id, 1)
  134.       actor.equip(0, battler.weapon_id)
  135.       actor.equip(1, battler.armor1_id)
  136.       actor.equip(2, battler.armor2_id)
  137.       actor.equip(3, battler.armor3_id)
  138.       actor.equip(4, battler.armor4_id)
  139.       actor.recover_all
  140.       @actors.push(actor)
  141.       @battle_actors.push(actor)
  142.     end
  143.     @items = {}
  144.     for i in1...$data_items.size
  145.       if$data_items[i].name != ""
  146.         occasion = $data_items[i].occasion
  147.         if occasion == 0or occasion == 1
  148.           @items[i] = 99
  149.         end
  150.       end
  151.     end
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ● 同伴成员的还原
  155.   #--------------------------------------------------------------------------
  156.   def refresh
  157.     # 游戏数据载入后角色对像直接从 $game_actors
  158.     # 分离。
  159.     # 回避由于载入造成的角色再设置的问题。
  160.     new_actors = []
  161.     new_battle_actors = []
  162.     @actors.eachdo |actor|
  163.       if$data_actors[actor.id] != nil
  164.         new_actors.push($game_actors[actor.id])
  165.       end
  166.     end
  167.     @battle_actors.eachdo |actor|
  168.       if$data_actors[actor.id] != nil
  169.         new_battle_actors.push($game_actors[actor.id])
  170.       end
  171.     end
  172.     @actors = new_actors
  173.     @battle_actors = new_battle_actors
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● 全灭判定
  177.   #--------------------------------------------------------------------------
  178.   def all_dead?
  179.     # 同伴人数为 0 的情况下
  180.     ifself.actors.size == 0
  181.       returnfalse
  182.     end
  183.     # 同伴中无人 HP 在 0 以上
  184.     for actor inself.actors
  185.       if actor.hp > 0
  186.         returnfalse
  187.       end
  188.     end
  189.     # 全灭
  190.     returntrue
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● 对像角色的随机确定
  194.   #     hp0 : 限制为 HP 0 的角色
  195.   #--------------------------------------------------------------------------
  196.   def random_target_actor(hp0 = false)
  197.     # 初始化轮流
  198.     roulette = []
  199.     # 循环
  200.     for actor in@battle_actors
  201.       # 符合条件的场合
  202.       if(not hp0 and actor.exist?)or(hp0 and actor.hp0?)
  203.         # 获取角色职业的位置 [位置]
  204.         position = $data_classes[actor.class_id].position
  205.         # 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
  206.         n = 4 - position
  207.         # 添加角色的轮流 n 回
  208.         n.timesdo
  209.           roulette.push(actor)
  210.         end
  211.       end
  212.     end
  213.     # 轮流大小为 0 的情况
  214.     if roulette.size == 0
  215.       returnnil
  216.     end
  217.     # 转轮盘赌,决定角色
  218.     return roulette[rand(roulette.size)]
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ● 对像角色的顺序确定
  222.   #     actor_index : 角色索引
  223.   #--------------------------------------------------------------------------
  224.   def smooth_target_actor(actor_index)
  225.     # 取得对像
  226.     actor = @battle_actors[actor_index]
  227.     # 对像存在的情况下
  228.     if actor != niland actor.exist?
  229.       return actor
  230.     end
  231.     # 循环
  232.     for actor in@actors
  233.       # 对像存在的情况下
  234.       if actor.exist?
  235.         return actor
  236.       end
  237.     end
  238.   end
  239. end
  240. class Game_Actor
  241.   attr_reader :battle_disabled
  242.   def leader?
  243.     returnself == $game_party.leader
  244.   end
  245.   def active
  246.     return$game_party.battle_actors.include?(self)
  247.   end
  248.   def battle_disabled=(bool)
  249.     @battle_disabled = bool
  250.     $game_party.battle_actors.delete(self)if bool
  251.   end
  252. end
  253. class Game_Player
  254.   #--------------------------------------------------------------------------
  255.   # ● 刷新
  256.   #--------------------------------------------------------------------------
  257.   def refresh
  258.     # 同伴人数为 0 的情况下
  259.     if$game_party.actors.size == 0or$game_party.leader == nil
  260.       # 清除角色的文件名及对像
  261.       @character_name = ""
  262.       @character_hue = 0
  263.       # 分支结束
  264.       return
  265.     end
  266.     # 获取带头的角色
  267.     if$game_party.leader != nil
  268.       actor = $game_party.leader
  269.       # 设置角色的文件名及对像
  270.       @character_name = actor.character_name
  271.       @character_hue = actor.character_hue
  272.       # 初始化不透明度和合成方式子
  273.       @opacity = 255
  274.       @blend_type = 0
  275.     end
  276.   end
  277. end
  278. class Game_BattleAction
  279.   attr_accessor :reserved_actor_id
  280.   unless method_defined? :rb_clear_20150422
  281.     alias rb_clear_20150422 clear
  282.     def clear
  283.       rb_clear_20150422
  284.       @reserved_actor_id = 0
  285.     end
  286.   end
  287. end
  288. class Window_Base < Window
  289.   def draw_actor_battle_position(actor, x, y)
  290.     if actor.leader?
  291.       if actor.active
  292.         text = "领队|出战"
  293.       else
  294.         text = "领队"
  295.       end
  296.       color = knockout_color
  297.     else
  298.       color = disabled_color
  299.       if actor.battle_disabled
  300.         text = "无法出战"
  301.       elsif actor.active
  302.         text = "出战"
  303.         color = normal_color
  304.       else
  305.         text = "待机"
  306.       end
  307.     end
  308.     self.contents.font.color = color
  309.     self.contents.draw_text(x, y, 120, 32, text)
  310.   end
  311. end
  312. #==============================================================================
  313. # ■ Window_Selectable
  314. #------------------------------------------------------------------------------
  315. #  拥有光标的移动以及滚动功能的窗口类。
  316. #==============================================================================
  317. class Window_Selectable < Window_Base
  318.   #--------------------------------------------------------------------------
  319.   # ● 定义实例变量
  320.   #--------------------------------------------------------------------------
  321.   attr_accessor :row_height               # 行高
  322.   #--------------------------------------------------------------------------
  323.   # ● 初始画对像
  324.   #     x      : 窗口的 X 坐标
  325.   #     y      : 窗口的 Y 坐标
  326.   #     width  : 窗口的宽
  327.   #     height : 窗口的高
  328.   #     row_height : 行高 默认是32
  329.   #--------------------------------------------------------------------------
  330.   alias rb_initialize_20150421 initialize
  331.   def initialize(x, y, width, height, row_height = 32)
  332.     @row_height = row_height
  333.     rb_initialize_20150421(x, y, width, height)
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ● 获取开头行
  337.   #--------------------------------------------------------------------------
  338.   def top_row
  339.     # 将窗口内容的传送源 Y 坐标、1 行的高 @row_height 等分
  340.     returnself.oy / @row_height
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 设置开头行
  344.   #     row : 显示开头的行
  345.   #--------------------------------------------------------------------------
  346.   def top_row=(row)
  347.     # row 未满 0 的场合更正为 0
  348.     if row < 0
  349.       row = 0
  350.     end
  351.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  352.     if row > row_max - 1
  353.       row = row_max - 1
  354.     end
  355.     # row 1 行高的 @row_height 倍、窗口内容的传送源 Y 坐标
  356.     self.oy = row * @row_height
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # ● 获取 1 页可以显示的行数
  360.   #--------------------------------------------------------------------------
  361.   def page_row_max
  362.     # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 @row_height
  363.     return(self.height - 32) / @row_height
  364.   end
  365.   #--------------------------------------------------------------------------
  366.   # ● 更新光标举行
  367.   #--------------------------------------------------------------------------
  368.   def update_cursor_rect
  369.     # 光标位置不满 0 的情况下
  370.     if@index < 0
  371.       self.cursor_rect.empty
  372.       return
  373.     end
  374.     # 获取当前的行
  375.     row = @index / @column_max
  376.     # 当前行被显示开头行前面的情况下
  377.     if row < self.top_row
  378.       # 从当前行向开头行滚动
  379.       self.top_row = row
  380.     end
  381.     # 当前行被显示末尾行之后的情况下
  382.     if row > self.top_row + (self.page_row_max - 1)
  383.       # 从当前行向末尾滚动
  384.       self.top_row = row - (self.page_row_max - 1)
  385.     end
  386.     # 计算光标的宽
  387.     cursor_width = self.width / @column_max - 32
  388.     # 计算光标坐标
  389.     x = @index % @column_max * (cursor_width + 32)
  390.     y = @index / @column_max * @row_height - self.oy
  391.     # 更新国标矩形
  392.     self.cursor_rect.set(x, y, cursor_width, @row_height)
  393.   end
  394. end
  395. class Window_MenuStatus
  396.   def initialize
  397.     super(0, 0, 480, 480, 112)
  398.     refresh
  399.     self.active = false
  400.     self.index = -1
  401.   end
  402.   def refresh
  403.     ifself.contents != nil
  404.       self.contents.dispose
  405.       self.contents = nil
  406.     end
  407.     @item_max = $game_party.actors.size
  408.     self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112)
  409.     for i in0...$game_party.actors.size
  410.       x = 64
  411.       y = i * 112
  412.       actor = $game_party.actors[i]
  413.       draw_actor_graphic(actor, x - 40, y + 80)
  414.       draw_actor_name(actor, x, y)
  415.       draw_actor_class(actor, x + 144, y)
  416.       draw_actor_level(actor, x, y + 32)
  417.       draw_actor_state(actor, x + 90, y + 32)
  418.       draw_actor_exp(actor, x, y + 64)
  419.       draw_actor_hp(actor, x + 236, y + 32)
  420.       draw_actor_sp(actor, x + 236, y + 64)
  421.       draw_actor_battle_position(actor, x + 236, y)
  422.     end
  423.   end
  424.   def update_cursor_rect
  425.     super
  426.   end
  427. end
  428. class Window_Target
  429.   def initialize
  430.     super(0, 0, 336, 480, 112)
  431.     self.z += 10
  432.     @item_max = $game_party.actors.size
  433.     self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112)
  434.     refresh
  435.   end
  436.   def update_cursor_rect
  437.     super
  438.   end
  439. end
  440. class Window_ReservedActors < Window_Selectable
  441.   def initialize
  442.     super(0, 64, 640, 256, 112)
  443.     self.opacity = 160
  444.     self.index = 0
  445.     self.active = true
  446.     @column_max = 2
  447.     refresh
  448.   end
  449.   def actor
  450.     return@data[self.index]
  451.   end
  452.   def refresh
  453.     ifself.contents != nil
  454.       self.contents.dispose
  455.       self.contents = nil
  456.     end
  457.     @data = []
  458.     $game_party.all_actors.eachdo |actor|
  459.       @data  0
  460.       self.contents = Bitmap.new(width - 32, (@item_max + 1) / 2 * 128)
  461.       @data.each_with_indexdo |actor, index|
  462.         x = 4 + index % 2 * (288 + 32)
  463.         y = index / 2 * 112
  464.         draw_actor_graphic(actor, x + 16, y + 80)
  465.         draw_actor_hp(actor, x + 48, y + 20)
  466.         draw_actor_sp(actor, x + 48, y + 52)
  467.       end
  468.     end
  469.   end
  470.   def update_help
  471.     # 帮助窗口显示角色的状态
  472.     self.actor == nil ? @help_window.set_text("") : @help_window.set_actor(self.actor)
  473.   end
  474. end
  475. class Scene_Menu
  476.   unless method_defined? :rb_update_command_20150421
  477.     alias rb_update_command_20150421 update_command
  478.     def update_command
  479.       if Input.trigger?(Input::X)
  480.         $game_system.se_play($data_system.decision_se)
  481.         @command_window.active = false
  482.         @status_window.active = true
  483.         @status_window.index = 0
  484.         @leader_adjust = true
  485.         return
  486.       end
  487.       if Input.trigger?(Input::Y)
  488.         $game_system.se_play($data_system.decision_se)
  489.         @command_window.active = false
  490.         @status_window.active = true
  491.         @status_window.index = 0
  492.         @battler_adjust = true
  493.         return
  494.       end
  495.       rb_update_command_20150421
  496.     end
  497.   end
  498.   unless method_defined? :rb_update_status_20150421
  499.     alias rb_update_status_20150421 update_status
  500.     def update_status
  501.       if@leader_adjust
  502.         update_leader
  503.         return
  504.       end
  505.       if@battler_adjust
  506.         update_battler
  507.         return
  508.       end
  509.       rb_update_status_20150421
  510.     end
  511.   end
  512.   def update_leader
  513.     if Input.trigger?(Input::B)
  514.       $game_system.se_play($data_system.cancel_se)
  515.       @leader_adjust = false
  516.       @status_window.active = false
  517.       @status_window.index = -1
  518.       @command_window.active = true
  519.       return
  520.     end
  521.     if Input.trigger?(Input::C)
  522.       if$game_party.actors.size == 0
  523.         $game_system.se_play($data_system.buzzer_se)
  524.       else
  525.         $game_system.se_play($data_system.decision_se)
  526.         $game_party.set_leader($game_party.actors[@status_window.index].id)
  527.         @status_window.refresh
  528.       end
  529.     end
  530.   end
  531.   def update_battler
  532.     if Input.trigger?(Input::B)
  533.       $game_system.se_play($data_system.cancel_se)
  534.       @battler_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.       actor = $game_party.actors[@status_window.index]
  542.       if actor == nil || actor.battle_disabled ||
  543.         (actor.active && $game_party.battle_actors.size == 1) ||
  544.         (!actor.active && $game_party.battle_actors.size == 4)
  545.         $game_system.se_play($data_system.buzzer_se)
  546.       else
  547.         $game_system.se_play($data_system.decision_se)
  548.         actor.active ? $game_party.battle_actors.delete(actor) : $game_party.battle_actors.push(actor)
  549.         @status_window.refresh
  550.       end
  551.     end
  552.   end
  553. end
  554. class Scene_Battle
  555.   def generate_modified_command_window
  556.     if@actor_command_window != nil
  557.       @actor_command_window.dispose
  558.       @actor_command_window = nil
  559.     end
  560.     s1 = $data_system.words.attack
  561.     s2 = $data_system.words.skill
  562.     s3 = $data_system.words.guard
  563.     s4 = $data_system.words.item
  564.     s5 = RB::Party::Words_Swap
  565.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
  566.     @actor_command_window.y = 128
  567.     @actor_command_window.back_opacity = 160
  568.     @actor_command_window.active = false
  569.     @actor_command_window.visible = false
  570.     @modified_generated = true
  571.   end
  572.   unless method_defined? :rb_phase3_setup_command_window_20150422
  573.     alias rb_phase3_setup_command_window_20150422 phase3_setup_command_window
  574.     def phase3_setup_command_window
  575.       generate_modified_command_window unless@modified_generated
  576.       rb_phase3_setup_command_window_20150422
  577.     end
  578.   end
  579.   def make_auto_swap_actors
  580.     returnunlessRB::Party::Auto_Swap
  581.     available_actors = $game_party.reserved_actors.reject{|actor| actor.dead?}
  582.     dead_actors = $game_party.battle_actors.select{|actor| actor.dead?}
  583.     returnif available_actors.empty? || dead_actors.empty?
  584.     n = [available_actors.size, dead_actors.size].min
  585.     dead_actors.each_with_indexdo |actor, i|
  586.       breakif i >= n
  587.       actor.current_action.kind = 3
  588.       actor.current_action.reserved_actor_id = available_actors[i].id
  589.       @action_battlers  0and@active_battler.slip_damage?
  590.       @active_battler.slip_damage_effect
  591.       @active_battler.damage_pop = true
  592.     end
  593.     # 自然解除状态
  594.     @active_battler.remove_states_auto
  595.     # 刷新状态窗口
  596.     @status_window.refresh
  597.     # 移至步骤 2
  598.     @phase4_step = 2
  599.   end
  600.   def update_phase4_step2
  601.     # 如果不是强制行动
  602.     unless@active_battler.current_action.forcing
  603.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  604.       if@active_battler.restriction == 2or@active_battler.restriction == 3
  605.         # 设置行动为攻击
  606.         @active_battler.current_action.kind = 0
  607.         @active_battler.current_action.basic = 0
  608.       end
  609.       # 限制为 [不能行动] 的情况下
  610.       if@active_battler.restriction == 4 && !@auto_swap
  611.         # 清除行动强制对像的战斗者
  612.         $game_temp.forcing_battler = nil
  613.         # 移至步骤 1
  614.         @phase4_step = 1
  615.         return
  616.       end
  617.     end
  618.     # 清除对像战斗者
  619.     @target_battlers = []
  620.     # 行动种类分支
  621.     case@active_battler.current_action.kind
  622.     when0  # 基本
  623.       make_basic_action_result
  624.     when1  # 特技
  625.       make_skill_action_result
  626.     when2  # 物品
  627.       make_item_action_result
  628.     when3  # 换人
  629.       make_swap_action_result
  630.     end
  631.     # 移至步骤 3
  632.     if@phase4_step == 2
  633.       @phase4_step = 3
  634.     end
  635.   end
  636.   def make_swap_action_result
  637.     # 获取角色
  638.     @reserved_actor = $game_actors[@active_battler.current_action.reserved_actor_id]
  639.     # 无法替换的情况下
  640.     if@reserved_actor == nil || @reserved_actor.active
  641.       # 移至步骤 1
  642.       @phase4_step = 1
  643.       return
  644.     end
  645.     # 在帮助窗口显示文字
  646.     text = "与#{@reserved_actor.name}交换"
  647.     @help_window.set_text(text, 1)
  648.     # 设置动画 ID
  649.     @animation1_id = 0
  650.     index = $game_party.actors.index(@active_battler)
  651.     $game_party.actors[index] = @reserved_actor
  652.   end
  653.   unless method_defined? :rb_start_phase5_20150422
  654.     alias rb_start_phase5_20150422 start_phase5
  655.     def start_phase5
  656.       $game_temp.gain_exp_flag = true
  657.       rb_start_phase5_20150422
  658.       $game_temp.gain_exp_flag = false
  659.     end
  660.   end
  661. end
复制代码

截图效果如下:


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


附范例一枚:

             本帖来自P1论坛作者李少安,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=332273  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
【半原创】队伍系统(又名角色仓库): d1.png

QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

GMT+8, 2024-9-21 14:51 , Processed in 0.041169 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部