Switch Party
Copern's Switch Party Members
Version 1.0
Introduction
Designed as a complement to Victors Follower Control but it can be used without it. Allows you to switch party members with a single comment and then revert it later. I made this just for a youtuber I frequently watch but was suggested I release it to the wild so here it is.
Features
[*]Switch the party members out for different ones
[*]Revert the party members back
Script
Spoiler Code:
#============================================================================== # Switch Party Members #------------------------------------------------------------------------------ # Author : Copern # # Version History: # 1.0 - 2012.07.07 > First release #------------------------------------------------------------------------------ # This script can be used to switch the party during an event/cutscene. At the # end of the event, the party can be reverted back to the original party if # desired. It is recommended to have party members on the same tile before # switching and reverting as the actors will visibly change on the map. #------------------------------------------------------------------------------ # Instructions: # Copy and paste this script into the Materials section of the script editor. #------------------------------------------------------------------------------ # Comment commands: # These are the tags to use in event comments # # <switch party: x1..xN> # Switches the party members to the specified actor ID's. # For example, <switch party: 3, 4, 7> or <switch party: 5, 6, 1, 9 -k> # x : Actor ID (starting from 1) # Optional Parameters # -k : Keep the currently stored party to revert to. # # <revert party> # Reverts to the currently stored party. # #------------------------------------------------------------------------------ # Additional instructions: # # The -k optional parameter can be used to switch the party multiple times and # revert to the party before the first switch. # # The current party is 1, 2, 3 # <switch party: 3, 5> # <switch party: 9, 6, 2 -k> # <switch party: 1, 8 -k> # <revert party> # The party will become 1, 2, 3 again. # #============================================================================== #============================================================================== # ** Game_Party #------------------------------------------------------------------------------ # Adds a new variable and switch party functions #============================================================================== class Game_Party < Game_Unit#---------------------------------------------------------------------------- # * Initialize # Add the actors_revert variable #---------------------------------------------------------------------------- alias :initialize_base_party :initialize def initialize initialize_base_party @actors_revert = [] end#---------------------------------------------------------------------------- # * Switch Party # Switches the party out with the new one. Replaces actors_revert with # the current party before switching unless the -k option is active. #---------------------------------------------------------------------------- def switch_party(actor_ids, options) @actors_revert.replace(@actors) if !options || @actors_revert.empty? @actors.replace(actor_ids) refresh_map end#---------------------------------------------------------------------------- # * Revert Party # Reverts the party to the one stored in actors_revert #---------------------------------------------------------------------------- def revert_party return unless !@actors_revert.empty? @actors.replace(@actors_revert) @actors_revert.clear refresh_map end#---------------------------------------------------------------------------- # * Refresh Map # Refreshes the map and party #---------------------------------------------------------------------------- def refresh_map $game_player.refresh $game_map.need_refresh = true end end #============================================================================== # ** Game_Interpreter #------------------------------------------------------------------------------ # Adds comment command parsing for switching parties #============================================================================== class Game_Interpreter#---------------------------------------------------------------------------- # * Command 108 # Inject comment command parsing #---------------------------------------------------------------------------- alias :command_108_base :command_108 def command_108 command_108_base comment_command end#---------------------------------------------------------------------------- # * Command Switch Party # Parses a switch party command #---------------------------------------------------------------------------- def command_switch_party matches = /<switch party: ((?:\d+,?\s*)+)(-k)?>/i.match(comments_s) return unless matches actor_ids = matches.scan(/\d+/).map(&:to_i) $game_party.switch_party(actor_ids, matches) end#---------------------------------------------------------------------------- # * Command Revert Party # Parses a revert party command #---------------------------------------------------------------------------- def command_revert_party $game_party.revert_party if comments_s =~ /<revert party>/i end #---------------------------------------------------------------------------- # * Comment Command # Begins parsing comment commands #---------------------------------------------------------------------------- def comment_command command_switch_party command_revert_party end#---------------------------------------------------------------------------- # * Comments_s # Create the comments string #---------------------------------------------------------------------------- def comments_s @comments ? @comments.join("\r\n") : "" end end
Instructions
Use these in comments in the event sequence.
<switch party: x1..xN>
Switches the entire party to the specified actor ID's.
For example, <switch party: 3, 4, 7> or <switch party: 5, 6, 1, 9 -k>
x : Actor ID (starting from 1)
Optional Parameters
-k : Keep the currently stored party to revert to.
<revert party>
Reverts the party to the currently stored party.
The -k optional parameter can be used to switch the party multiple times and revert to the party before the first switch.
The current party is 1, 2, 3
<switch party: 3, 5>
<switch party: 9, 6, 2 -k>
<switch party: 1, 8 -k>
<revert party>
The party will become 1, 2, 3 again
Credits
Victor's scripts as inspiration and ideas for this one.
Edit: I've renamed this to Switch Party Members since that more accurately describes what it does. If a mod could change the title I would be grateful.
本贴来自国际rpgmaker官方论坛作者:Copern处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/switch-party.3060/
页:
[1]