Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Pacman Advanced Creative (PAC) Engine - Party Management System
- # 19/6/2011
- # Type: Scene
- # Installation: Script calls.
- # Level: Average
- #
- #===============================================================================
- #
- # Description:
- # VX limits your party to having 4 members. Isn't that terrible? This script
- # won't give you more members in your party, rather be able to change them
- # throughout the game at the player's call. Read the instructions to find out
- # more.
- #
- #===============================================================================
- #
- # Instructions:
- # INSTALLATION
- # Paste above main, below materials, in the script editor (F11). Make sure you
- # save upon exiting.
- # SCRIPT CALLS
- # $data_actors[ID].found = true/false
- # Where ID is the ID of an actor in the database. This places an actor in the
- # reserves party, ready for selection by the player if true, and takes them
- # out if false.
- # $data_actors[ID].unavailable = true/false
- # Makes actor with the specified ID unavailable to the player in the reserves
- # party if true. If false, makes them available.
- # $data_actors[ID].required = true/false
- # Locks actor with specified ID to the actual party, ergo mandatory to the
- # player, if true. Unlocks the character if false.
- # For each of these calls you can use, instead of $data_actors[ID],
- # $game_party.members[position].actor.found/unavailable/required to perform
- # the action for the actor in that position in the party, starting with 0 as
- # the party leader.
- # $game_party.party_menu_disabled = true/false
- # This will change the access of the command if PAC Main Menu is being used.
- # $scene = Scene_Party.new
- # Simply calls the Party Management scene. By default, there is no menu option
- # for the party scene, but it is simple to add if you are using PAC Main Menu,
- # and still quite easy if you are using the default menu system.
- #
- #===============================================================================
- #
- # This script requires no editing. Do not edit anything in this script
- # unless you are a compenent scripter. Should you edit without any scripting
- # education, it may result in me tutting at you for getting it wrong.
- #
- #===============================================================================
- $imported = {} if $imported == nil
- $imported["PAC_Party"] = true
- module PAC::MENU
- PARTY_SWITCH = Input::X # Button which will switch between equip and status
- # display in the party scene.
- end
- #==============================================================================
- # ** RPG::Actor
- #------------------------------------------------------------------------------
- # Data class for actors.
- #==============================================================================
- class RPG::Actor
- #--------------------------------------------------------------------------
- # Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :found
- attr_accessor :unavailable
- attr_accessor :required
- #--------------------------------------------------------------------------
- # * Setup
- #--------------------------------------------------------------------------
- def setup
- @found = false
- @unavailable = false
- @required = false
- end
- end
- #==============================================================================
- # ** 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
- #--------------------------------------------------------------------------
- # Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :party_menu_disabled
- #--------------------------------------------------------------------------
- # alias listing
- #--------------------------------------------------------------------------
- alias pac_party_initialize initialize
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- pac_party_initialize
- @party_menu_disabled = false
- end
- end
- #==============================================================================
- # ** Game_Actors
- #------------------------------------------------------------------------------
- # This class handles the actor array. The instance of this class is
- # referenced by $game_actors.
- #==============================================================================
- class Game_Actors
- #--------------------------------------------------------------------------
- # Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :data
- #--------------------------------------------------------------------------
- # alias listing
- #--------------------------------------------------------------------------
- alias pac_pms_act_initialize initialize
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- pac_pms_act_initialize
- $data_actors.each do |actor|
- actor.setup if actor
- @data[actor.id] = Game_Actor.new(actor.id) if actor
- end
- end
- end
- #==============================================================================
- # ** Window_CurrentMember
- #------------------------------------------------------------------------------
- # This window displays the current party member in the party scene.
- #==============================================================================
- class Window_CurrentMember < Window_Base
- #--------------------------------------------------------------------------
- # Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :mode
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(member = nil, mode = 0)
- super(304, 80, 192, 256)
- create_contents
- @member = member
- @mode = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get member
- #--------------------------------------------------------------------------
- def member
- return @member
- end
- #--------------------------------------------------------------------------
- # * Set Member
- #--------------------------------------------------------------------------
- def set_member(member)
- old_member = @member
- @member = member
- refresh if old_member != @member
- end
- #--------------------------------------------------------------------------
- # * Set modes
- #--------------------------------------------------------------------------
- def set_mode(mode)
- @mode = mode if [0, 1].include?(mode)
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- return unless @member
- x, y = 0, 0
- self.draw_actor_face(@member, x, y, 48)
- self.draw_actor_name(@member, x + 52, y)
- self.draw_actor_class(@member, x + 52, y + WLH)
- self.draw_actor_level(@member, x, y + WLH*2)
- case @mode
- when 0
- self.draw_icon(142, self.contents.width - 24, y + WLH*2)
- self.contents.draw_text(x, y + WLH*2, self.contents.width - 12, WLH,
- 'Equip', 2)
- self.draw_actor_hp(@member, x, y + WLH*3, 160)
- self.draw_actor_mp(@member, x, y + WLH*4, 160)
- self.draw_actor_parameter(@member, x, y + WLH*5, 0)
- self.draw_actor_parameter(@member, x, y + WLH*6, 1)
- self.draw_actor_parameter(@member, x, y + WLH*7, 2)
- self.draw_actor_parameter(@member, x, y + WLH*8, 3)
- when 1
- self.draw_icon(143, self.contents.width - 24, y + WLH*2)
- self.contents.draw_text(x, y + WLH*2, self.contents.width - 12, WLH,
- 'Stat', 2)
- for i in 0...@member.equips.size
- item = @member.equips[i]
- self.draw_item_name(item, x, y + WLH*(3+i), true)
- end
- end
- end
- end
- #==============================================================================
- # ** Window_CurrentParty
- #------------------------------------------------------------------------------
- # This window displays the current party selected in the party scene.
- #==============================================================================
- class Window_CurrentParty < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(48, 80, 256, 64)
- @item_max = 4
- @column_max = @item_max
- create_contents
- self.index = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get member
- #--------------------------------------------------------------------------
- def member
- return $game_party.members[self.index]
- end
- #--------------------------------------------------------------------------
- # * Refresh window
- #--------------------------------------------------------------------------
- def refresh
- for i in 0...@item_max
- rect = item_rect(i)
- self.contents.clear_rect(rect)
- end
- for i in 0...$game_party.members.size
- rect = item_rect(i)
- bitmap = Cache.character($game_party.members[i].character_name)
- sign = $game_party.members[i].character_name[/^[\!\$]./]
- if sign != nil and sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = $game_party.members[i].character_index
- src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
- if $game_party.members[i].actor.unavailable
- self.contents.blt(rect.x, rect.y, bitmap, src_rect, 128)
- else
- self.contents.blt(rect.x, rect.y, bitmap, src_rect, 255)
- end
- if $game_party.members[i].actor.required
- lock_bitmap = Cache.system("Locked")
- self.contents.blt(rect.x + rect.width - lock_bitmap.width,
- rect.y + rect.height - lock_bitmap.height,lock_bitmap,lock_bitmap.rect)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Get rectangle for displaying items
- # index : item number
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = (contents.width + @spacing) / @column_max - @spacing
- rect.height = 32
- rect.x = index % @column_max * (rect.width + @spacing)
- rect.y = index / @column_max * 32
- return rect
- end
- end
- #==============================================================================
- # ** Window_SelectMember
- #------------------------------------------------------------------------------
- # This window displays the currently selected member in the party scene.
- #==============================================================================
- class Window_SelectMember < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(48, 144, 256, 192)
- calculate_actors
- @item_max = @actors.size + 1
- @column_max = 4
- self.index = -1
- self.active = false
- refresh
- end
- #--------------------------------------------------------------------------
- # * Calculate Actors
- #--------------------------------------------------------------------------
- def calculate_actors
- @actors = []
- for a in $game_actors.data
- if a != nil and a.actor.found and !$game_party.members.include?(a)
- @actors << a
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Get member
- #--------------------------------------------------------------------------
- def member
- return @actors[self.index]
- end
- #--------------------------------------------------------------------------
- # * Refresh Window
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- calculate_actors
- @item_max = @actors.size + 1
- for i in 0...@actors.size
- rect = item_rect(i)
- bitmap = Cache.character(@actors[i].character_name)
- sign = @actors[i].character_name[/^[\!\$]./]
- if sign != nil and sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = @actors[i].character_index
- src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
- if @actors[i].actor.unavailable
- self.contents.blt(rect.x, rect.y, bitmap, src_rect, 128)
- else
- self.contents.blt(rect.x, rect.y, bitmap, src_rect, 255)
- end
- if @actors[i].actor.required
- lock_bitmap = Cache.system("Locked")
- self.contents.blt(rect.x + rect.width - lock_bitmap.width,
- rect.y + rect.height - lock_bitmap.height,lock_bitmap,lock_bitmap.rect)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Get rectangle for displaying items
- # index : item number
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = (contents.width + @spacing) / @column_max - @spacing
- rect.height = 32
- rect.x = index % @column_max * (rect.width + @spacing)
- rect.y = index / @column_max * 32
- return rect
- end
- end
- #==============================================================================
- # ** Scene_File
- #------------------------------------------------------------------------------
- # This class performs the save and load screen processing.
- #==============================================================================
- class Scene_File < Scene_Base
- #--------------------------------------------------------------------------
- # alias listing
- #--------------------------------------------------------------------------
- alias pac_pms_file_write_save_data write_save_data
- alias pac_pms_file_read_save_data read_save_data
- #--------------------------------------------------------------------------
- # * Write Save Data
- # file : write file object (opened)
- #--------------------------------------------------------------------------
- def write_save_data(file)
- pac_pms_file_write_save_data(file)
- Marshal.dump($data_actors, file)
- end
- #--------------------------------------------------------------------------
- # * Read Save Data
- # file : file object for reading (opened)
- #--------------------------------------------------------------------------
- def read_save_data(file)
- pac_pms_file_read_save_data(file)
- $data_actors = Marshal.load(file)
- end
- end
- #==============================================================================
- # ** Scene_Title
- #------------------------------------------------------------------------------
- # This class performs the title screen processing.
- #==============================================================================
- class Scene_Title < Scene_Base
- #--------------------------------------------------------------------------
- # alias listing
- #--------------------------------------------------------------------------
- alias pac_pms_ttl_command_new_game command_new_game
- #--------------------------------------------------------------------------
- # * Command: New Game
- #--------------------------------------------------------------------------
- def command_new_game
- pac_pms_ttl_command_new_game
- $game_party.members.each {|s| s.actor.found = true if s}
- end
- end
- #==============================================================================
- # ** Scene_Party
- #------------------------------------------------------------------------------
- # This class performs the party screen processing.
- #==============================================================================
- class Scene_Party < Scene_Base
- include PAC::MENU
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(from_map = true, from_menu = false)
- @from_map = from_map
- @from_menu = from_menu
- end
- #--------------------------------------------------------------------------
- # * Start processing
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- create_windows
- end
- #--------------------------------------------------------------------------
- # * Create windows
- #--------------------------------------------------------------------------
- def create_windows
- @member_window = Window_CurrentMember.new
- @party_window = Window_CurrentParty.new
- @party_window.active = true
- @selectable_window = Window_SelectMember.new
- end
- #--------------------------------------------------------------------------
- # * Window update
- #--------------------------------------------------------------------------
- def update_windows
- @member_window.update
- @party_window.update
- @selectable_window.update
- if @party_window.active
- @member_window.set_member(@party_window.member)
- elsif @selectable_window.active
- @member_window.set_member(@selectable_window.member)
- end
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- super
- @member_window.dispose
- @party_window.dispose
- @selectable_window.dispose
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- update_windows
- update_input
- end
- #--------------------------------------------------------------------------
- # * Update Command Input
- #--------------------------------------------------------------------------
- def update_input
- if Input.trigger?(PARTY_SWITCH) # If the button is being pressed...
- if @member_window.mode == 1 # If equip mode is on,
- @member_window.set_mode(0) # Activate stats mode.
- elsif @member_window.mode == 0 # If stats mode is on,
- @member_window.set_mode(1) # Activate equip mode.
- end
- end
- if @party_window.active # If the party member is active
- if Input.trigger?(Input::B) # If you want to leave,
- if $game_party.members.size == 0 # If party is empty,
- Sound.play_buzzer # Bee-bow.
- return # No soup for you
- else
- Sound.play_cancel # Bloop.
- if @from_map
- $scene = Scene_Map.new
- elsif @from_menu
- if $imported["PAC_Menu 1.7"]
- $scene = Scene_Menu.new
- else
- $scene = Scene_Menu.new(4)
- end
- end
- end
- elsif Input.trigger?(Input::C) # If you want to do something,
- member = @party_window.member # do stuff.
- if member != nil
- if member.actor.unavailable or member.actor.required
- Sound.play_buzzer
- return
- end
- end
- Sound.play_decision
- @party_window.active = false
- @selectable_window.active = true
- @selectable_window.index = 0
- end
- elsif @selectable_window.active
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @selectable_window.index = -1
- @selectable_window.active = false
- @party_window.active = true
- elsif Input.trigger?(Input::C)
- member = @selectable_window.member
- if member != nil
- if member.actor.unavailable
- Sound.play_buzzer
- return
- end
- end
- Sound.play_decision
- if @party_window.member != nil
- $game_party.remove_actor(@party_window.member.id)
- end
- if @selectable_window.member != nil
- $game_party.add_actor(@selectable_window.member.id)
- end
- @selectable_window.refresh
- @party_window.refresh
- @selectable_window.index = -1
- @selectable_window.active = false
- @party_window.active = true
- end
- end
- end
- end
- #===============================================================================
- #
- # END OF SCRIPT
- #
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement