Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: nathmatt on May 07, 2010, 02:41:56 pm

Title: [XP] Party Swap
Post by: nathmatt on May 07, 2010, 02:41:56 pm
Party Swap
Authors: Nathmatt
Version: 1.01
Type: Party Controller
Key Term: Misc Add-on



Introduction
This script allows you have multiple parties and swap between the easily


Features




Screenshots

no screenshot


Demo
no demo


Script

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Party Swap by Nathmatt
# Version: 1.00
# Type: Party Controller
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Script Calls:
#
#   Party.new_party(var_id) - This stores the current party and player postion    
#                             in $game_varirables[var_id]
#  
#   Party.swap(var_id)      - This will swap the current party and positon with
#                             the 1 stored in $game_varirables[var_id]
#
#   Party.combine_party(var_id) - Adds money,gold,items,armor,and weapons from
#                                 $game_varirables[var_id] to the party
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  Party
#------------------------------------------------------------------------------
#  This module controls the party.
#==============================================================================
module Party

 
 def self.new_party(var_id)
   $game_variables[var_id] = [$game_party,$game_map.map_id,
   $game_player.x,$game_player.y,$game_player.direction]
   $game_party = Game_Party.new
 end
 
 def self.swap(var_id)
   par = [$game_party,$game_map.map_id,
   $game_player.x,$game_player.y,$game_player.direction]
   $game_party = $game_variables[var_id][0]
   $game_player.refresh
   $game_temp.player_transferring = true
   $game_temp.player_new_map_id = $game_variables[var_id][1]
   $game_temp.player_new_x = $game_variables[var_id][2]
   $game_temp.player_new_y = $game_variables[var_id][3]
   $game_temp.player_new_direction = $game_variables[var_id][4]
   $game_variables[var_id] = par
 end
 
 def self.combine_party(var_id)
   $game_variables[var_id][0].items.each_pair {| key, value |
   $game_party.gain_item(key, value)}
   $game_variables[var_id][0].weapons.each_pair {| key, value |
   $game_party.gain_weapon(key, value)}
   $game_variables[var_id][0].armors.each_pair {| key, value |
   $game_party.gain_armor(key, value)}
   $game_party.gain_gold($game_variables[var_id][0].gold)
 end
 
end
#============================================================================
# Game_Party
#----------------------------------------------------------------------------
# This class was enhanced to support accessing the parties inventory
#============================================================================
class Game_Party
 
 attr_reader   :items
 attr_reader   :weapons
 attr_reader   :armors
 
end



Instructions
in the script


Compatibility
Should not have any compatibility issues


Credits and Thanks




Author's Notes

If you have any suggestions or problems with the instructions post here
Title: Re: [XP] Party Swap
Post by: lonely_cubone on May 07, 2010, 03:40:13 pm
Great script, exactly what I was looking for! *levels*
Title: Re: [XP] Party Swap
Post by: SBR* on May 10, 2010, 11:34:33 am
Nice system! I actually was thinking about making something like this too, but I didn't know that $game_party holds every data of a party (like gold and steps)  :shy:, and, actually, I didn't even think of using $game_party for the players  double:shy:... This could be perfectly used for RMX-OS as multiple file system (I think). That was my first intention for my idea anyway... But why are you using $game_variables[var_id].items in the beginning of method combine_party of module Party? What does it do anyway?

-SBR*

EDIT: Level up!
Title: Re: [XP] Party Swap
Post by: nathmatt on May 10, 2010, 12:47:11 pm
That was put there during testing and i forgot to remove it.
Yes but i added the reader to the items, weapons, and armor at the end of the script.
Title: Re: [XP] Party Swap
Post by: SBR* on May 12, 2010, 04:37:43 am
Ah, now I see!
Title: Re: [XP] Party Swap
Post by: monstergrin on June 23, 2010, 10:14:58 pm
Okay, I am something of a scripting noob, so this might be a really basic question. How do you create another party to switch to? I can see how these scripts let you save your current one, and switch from that one to another, but currently I can't figure out how to make that other one exist in the first place.
Title: Re: [XP] Party Swap
Post by: nathmatt on June 24, 2010, 10:12:01 am
i forgot to add that this creates the new party

Party.new_party(var_id)
Title: Re: [XP] Party Swap
Post by: monstergrin on June 24, 2010, 12:34:24 pm
Okay! I got it to work. But after I switch to the other party, there's no actor or position information saved for it so I just get a blank square moving around from the same place the previous party was before the switch. How do I make content for the new party? Where do I put that information? (If I am asking questions that are answered elsewhere, I apologise.)
Title: Re: [XP] Party Swap
Post by: nathmatt on June 24, 2010, 12:53:29 pm
just use the event command  add actor
Title: Re: [XP] Party Swap
Post by: monstergrin on June 24, 2010, 05:07:06 pm
Wow, I don't know why that didn't occur to me. Anyway, the script works beautifully and does exactly what I need it to, so thank you very much!
Title: Re: [XP] Party Swap
Post by: SilverShadow737 on June 14, 2011, 03:22:26 am
Sorry for the bump, but when I try to combine two parties I get an error, "undefined method 'items' for #<Array:0x29e61c8>
If I comment out the items line error I get the same thing but for 'weapons' for #<Array:0x29067c8>
Same for 'armors' for #<Array:0x2906dc8>
Same for gold for a different arry # basically the entire combine script doesn't work.
I'm running this out of a new project, so there are no edited or added scripts.
Title: Re: [XP] Party Swap
Post by: G_G on June 14, 2011, 04:06:32 am
Replace these lines of code
def self.combine_party(var_id)
   $game_variables[var_id].items.each_pair {| key, value |
   $game_party.gain_item(key, value)}
   $game_variables[var_id].weapons.each_pair {| key, value |
   $game_party.gain_weapon(key, value)}
   $game_variables[var_id].armors.each_pair {| key, value |
   $game_party.gain_armor(key, value)}
   $game_party.gain_gold($game_variables[var_id].gold)
 end


With this.
def self.combine_party(var_id)
   $game_variables[var_id][0].items.each_pair {| key, value |
   $game_party.gain_item(key, value)}
   $game_variables[var_id][0].weapons.each_pair {| key, value |
   $game_party.gain_weapon(key, value)}
   $game_variables[var_id][0].armors.each_pair {| key, value |
   $game_party.gain_armor(key, value)}
   $game_party.gain_gold($game_variables[var_id][0].gold)
 end


See if that works.
Title: Re: [XP] Party Swap
Post by: nathmatt on June 14, 2011, 08:45:56 am
yea that should work i thought i tested this when i made it i guess not fully
Title: Re: [XP] Party Swap
Post by: SilverShadow737 on June 14, 2011, 04:05:11 pm
Works perfectly, thanks muchly!