Switch Party

Copern

Villager
Member
Joined
Jul 6, 2012
Messages
8
Reaction score
7
First Language
English
Primarily Uses
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

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[1].scan(/\d+/).map(&:to_i)
	$game_party.switch_party(actor_ids, matches[2])
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.
 
Last edited by a moderator:

AmnesiacJack

Some Dude
Member
Joined
May 4, 2012
Messages
17
Reaction score
1
First Language
English
Primarily Uses
This was extremely useful for ensuring cutscenes came out the right way if the player changed the formation of the party at all, at least for me.
 

MooshraKun

Making Dreams Stand Up
Veteran
Joined
Jul 11, 2012
Messages
238
Reaction score
11
First Language
Lokota
So like lets say I have a party.but want to take them out so the player can expiereience a new charcater's story but them the first party meets the new one and they can merge,but the first party still has the original stats and weapons and armour and so on? Is this how it works if not please tell me I don't exactly understand english to our best ability.
 
Last edited by a moderator:

Copern

Villager
Member
Joined
Jul 6, 2012
Messages
8
Reaction score
7
First Language
English
Primarily Uses
You can switch out all the party members to the new ones with one comment. Then when the two meet in an event, you can add them all in with another comment. Yes, the characters will keep the equipment and experience they had when switching.

However, it will not be an entirely new party, the "new" party members will share gold and items from the "old" party members. If you need separate gold and items for each party, then you'll need to use something like Tsukihime's Player Switch or similar.
 

MooshraKun

Making Dreams Stand Up
Veteran
Joined
Jul 11, 2012
Messages
238
Reaction score
11
First Language
Lokota
Oh ok I was just wondering thanks for the advice I will check out his script.
 

Latest Threads

Latest Profile Posts

Holy cow... work is demanding and I'm back in college. I'm kind of scared of my dad right now after the incident, but at least I don't live with him all the time. Anyway, working on Fandom Scouts and my FNAF character set. The FNAF sprites are actually going to be used in the game... unfortunately the enemy sprites are FNAF World traces, so no sharing those.
The honeymoon period is over with Cyberpunk 2077, It sadly doesnt live up to the hype, pretty graphics arent everything (especially when I cant even do something as simple as changing the radio station over!). Replaying Breath of the wild has reminded me what a good game really looks like, plus that one has good glitches!....
Ami


Maybe...a Drinkable Water Plant or something?

Forum statistics

Threads
107,686
Messages
1,031,432
Members
139,803
Latest member
Siegfried
Top