Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Pacman Advanced Creative (PAC) Engine - Units
- # 6/7/2011
- # Type: System
- # Installation: Script calls, plug-n-play.
- # Level: Average
- #
- #===============================================================================
- #
- # Description:
- # So, for whatever reason you've decided to make a tedious puzzle which requires
- # multiple parties, or you want a more diverse story that can be played at any
- # which when time, or you just want some cool gimmick to give your game that
- # memorable touch. Look no further (because MA has a similar script), this
- # script is here to fulfill your insane needs.
- #
- #===============================================================================
- #
- # Instructions:
- # INSTALLATION
- # Paste above main, below materials, in the script editor (F11). Remember to
- # save upon exiting.
- # SCRIPT CALLS
- # $game_units[id] - accesses (creates if does not exist) the party located
- # in that ID.
- # $game_units[id] = x - Sets the party to x. X must be a Game_Party object.
- # $game_units.merge_units(id1, id2, id3)
- # - Merges units id1, id2 and id3 (may be omitted).
- # $game_units.merge_and_delete(id1, id2, id3)
- # - Merges id1, id2 and id3 (may be omitted) and deletes
- # id2 and id3 if included.
- # $game_units.delete_unit(id, id2)
- # - Deletes the specified ids. Id2 may be omitted.
- #
- # To change the actve party, use the following:
- # $game_party = $game_units[id] - Where id is the party you want to access.
- # $game_player.refresh
- #
- # By default, $game_units[0] holds the default, original party. Work with 1, 2,
- # 3 etc. to avoid messing with crucial game data. Don't use 0.
- #
- #===============================================================================
- #==============================================================================
- # ** Game_Party
- #------------------------------------------------------------------------------
- # This class handles the party. It includes information on amount of gold
- # and items. The instance of this class is referenced by $game_party.
- #==============================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # * Multiple Step Add
- #--------------------------------------------------------------------------
- def add_multiple_steps(amount)
- @steps += amount
- end
- end
- class Game_Units
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- @data = {0 => $game_party}
- end
- #--------------------------------------------------------------------------
- # * Retrieve Unit
- # id : ID of the unit
- #--------------------------------------------------------------------------
- def [](id)
- @data[id] = Game_Party.new if @data[id] == nil
- return @data[id]
- end
- #--------------------------------------------------------------------------
- # * Set Unit
- #--------------------------------------------------------------------------
- def []= (id, unit)
- return unless unit.class == Game_Party # Do nothing if not Game_Party.
- @data[id] = unit
- end
- #--------------------------------------------------------------------------
- # * Merge Processing
- # id1 : ID of the first party, where the merge is stored.
- # id2 : ID of the second party.
- # id3 : ID of the third party. May be omitted.
- #--------------------------------------------------------------------------
- def merge_units(id1, id2, id3=nil)
- new_unit = Game_Party.new # Set new unit
- u1 = self[id1] # Get old units.
- u2 = self[id2]
- u3 = self[id3]
- if id3 != nil # If id3 is used
- new_unit.gain_gold(u1.gold + u2.gold + u3.gold) # Gold
- (u1.members + u2.members + u3.members).each { |actor| # Actors
- new_unit.add_actor(actor.id) }
- (u1.items + u2.items + u3.items).uniq.each { |item| # Items
- new_unit.gain_item(item,u1.item_number(item) + u2.item_number(item) +
- u3.item_number(item))}
- new_unit.add_multiple_steps(u1.steps + u2.steps + u3.steps) # Steps
- else # If id3 is not used
- new_unit.gain_gold(u1.gold + u2.gold) # Gold
- (u1.members + u2.members).each { |actor| new_unit.add_actor (actor.id) }
- (u1.items + u2.items).uniq.each { |item| # Items
- new_unit.gain_item (item, u1.item_number(item) + u2.item_number(item)) }
- new_unit.add_multiple_steps(u1.steps + u2.steps) # Steps
- end
- new_unit.last_item_id = u1.last_item_id # Aesthetic stuff.
- new_unit.last_actor_index = u1.last_actor_index
- new_unit.last_target_index = u1.last_target_index
- return new_unit # Get new unit.
- end
- #--------------------------------------------------------------------------
- # * Merge and Delete Processing
- # id1 : ID of the first party, which will hold the merged data.
- # id2 : ID of the second party, which will be deleted.
- # id3 : ID of the third party. May be omitted; will be deleted.
- #--------------------------------------------------------------------------
- def merge_and_delete(id1, id2, id3=nil)
- if id3 != nil # If 3 is used
- @data[id1] = merge_units(id1, id2, id3) # Merge the 3.
- delete_unit(id2, id3) # Delete 2 and 3.
- else # If 3 is not used.
- @data[id1] = merge_units(id1, id2) # Merge the 2.
- delete_unit(id2) # Delete 2.
- end
- end
- #--------------------------------------------------------------------------
- # * Delete Processing
- # id1 : ID of the first party, which will be deleted.
- # id2 : ID of the second party, which may be omitted. It will be deleted.
- #--------------------------------------------------------------------------
- def delete_unit(id1, id2=nil)
- @data[id1] = nil # Null data.
- if id1 == @data.size - 1 # If this was the last in the array
- id1 -= 1 # Delete any nil objects between this ID and the next.
- while @data[id1] == nil
- @data.delete(id1)
- id1 -= 1
- end
- end
- if id2 != nil # Delete id2?
- @data[id2] = nil # Do the same.
- if id2 == @data.size - 1
- while @data[id2] == nil
- @data.delete(id2)
- id2 -= 1
- end
- end
- end
- end
- end
- #==============================================================================
- # ** Scene_Title
- #------------------------------------------------------------------------------
- # This class performs the title screen processing.
- #==============================================================================
- class Scene_Title < Scene_Base
- #--------------------------------------------------------------------------
- # alias listing
- #--------------------------------------------------------------------------
- alias pac_mulprt_create_game_objects create_game_objects
- #--------------------------------------------------------------------------
- # * Create Game Objects
- #--------------------------------------------------------------------------
- def create_game_objects
- pac_mulprt_create_game_objects
- $game_units = Game_Units.new
- end
- end
- #==============================================================================
- # ** Scene_File
- #------------------------------------------------------------------------------
- # This class performs the save and load screen processing.
- #==============================================================================
- class Scene_File
- #--------------------------------------------------------------------------
- # alias listing
- #--------------------------------------------------------------------------
- alias pac_mulun_write_save_data write_save_data
- alias pac_mulun_read_save_data read_save_data
- #--------------------------------------------------------------------------
- # * Write Save Data
- # file : write file object (opened)
- #--------------------------------------------------------------------------
- def write_save_data(file)
- pac_mulun_write_save_data(file)
- Marshal.dump($game_units, file)
- end
- #--------------------------------------------------------------------------
- # * Read Save Data
- # file : file object for reading (opened)
- #--------------------------------------------------------------------------
- def read_save_data(file)
- pac_mulun_read_save_data(file)
- $game_units = Marshal.load(file)
- end
- end
- #===============================================================================
- #
- # END OF SCRIPT
- #
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement