Black_Mage icon

Party Changer RMXP Script

Black_Mage | PRO | 12/28/14 05:01:23 PM UTC | 0 ⭐ | 4089 👁️ | Never ⏰ | []
Ruby |

22.02 KB

|

None

|

0 👍

/

0 👎

################################################################################
# Party Changer Script By Black Mage (Credit required to use)
# Version : 1.7
# https://burningwizard.wordpress.com/2014/12/28/party-changer-menu-script-rmxp-rgss/
#
# The set up :
# First, put this script on your game. After that, you just need to
# specify which characters that player can change in their party using this script call.
#      $partychange[Character Number In Database – 1] = true
#      $game_map.refresh
# Change the value into false if you want to remove them from the menu.
#
# To call the menu, put this on script call.
#      $scene = Scene_Party.new
#
#
# The version 1.2 above give you a menu mode called "Information Mode" where it
# include a profile of the character that is highlighted in the menu. Beware that this
# mode is highly customizable, so you need some knowledge on RGSS scripting to utilize
# to it upmost potential.
# To call this menu, put this on script call.
#      $scene = Scene_Party.new(0,1)
#
# If you have some knowledge on RGSS scripting, you may do edits to Profile Window
# located on line 435 onwards to make the Profile Window that you like.
#
#
# The version 1.3 above give you a large party menu mode. It's a menu that 
# compatible with some "Large Party" script out there.
# To call this menu, put this on script call.
#      $scene = Scene_Party.new(0,2)
#
# List of "Large Party" Script that has been tested :
#   - Dargor's Large Party Script
#
#
# The version 1.4 introduce lock feature.
# If you want to lock specific character so that he/she can't be added or removed
# from the party, simply use this script call.
#      $partylock[Character Number In Database – 1] = true
#      $game_map.refresh
# Change the value into false if you want to unlock them.
# Locked character will have their sprite a bit transparent on the menu.
#
#
# The version 1.5 has configuration to make reserved party members to gain EXP.
# Change the Percentage value on the script to determine how much EXP gained 
# for reserved party members.
# Note that locked party members aren't getting any EXP by default. Change Locked
# value on the script into true, to enable the locked members to gain EXP.
#
################################################################################
 
$partychange = []
$partylock = []
 
module Black
  module Black_EXP
    # Reserved Party EXP Percentage gained. Put 50 if you want them to get 50% 
    # of EXP gained by Main Party members.
    Percentage = 0
    # Determine whether Locked Party members receive EXP or not. Change to true
    # if you want Locked Party members to gain EXP.
    Locked = false
  end
end
 
class Scene_Party
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0, window_form = 0)
    @menu_index = menu_index
    @window_form = window_form
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make Help Window
    @help_window = Window_PartyHelp.new(@window_form)
    @help_window2 = Window_PartyHelp2.new(@window_form)
 
    # Make Party Change Window
    @partychange_window = Window_PartyChange.new(@window_form)
 
    if @window_form == 0
      @partychange_window.x = 0
    elsif @window_form == 1
      @partychange_window.x = 0
    elsif @window_form == 2
      @partychange_window.x = 260
    end
 
    if @window_form == 0
      @partychange_window.y = 240
    elsif @window_form == 1
      @partychange_window.y = 240
    elsif @window_form == 2
      @partychange_window.y = 64
    end
 
    @partychange_window.active = true
    @partychange_window.index = 0
    
    # Make party window
    @party_window = Window_Party.new(@window_form)
    @party_window.x = 0
    @party_window.y = 64
    
    # If mode 1 enabled
    if @window_form == 1
      @help_window3 = Window_PartyHelp3.new
      @profile_window = Window_Profile.new
    end
        
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @partychange_window.dispose
    @party_window.dispose
    @help_window.dispose
    @help_window2.dispose
 
    # If mode 1 enabled
    if @window_form == 1
      @help_window3.dispose
      @profile_window.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @partychange_window.update
    @party_window.update
    
    # Update the profile window if mode 1 is true
    if @window_form == 1
      @profile_window.update(@partychange_window.index)
    end
 
    # Update the party change window
    if @partychange_window.active
      update_partychange
      return
    end
  end
 
  #--------------------------------------------------------------------------
  # * Frame Update (when party window is active)
  #--------------------------------------------------------------------------
  def update_partychange
    # If B button was pressed
    if Input.trigger?(Input::B)
      if $game_party.actors.size == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Switch to map screen
        $scene = Scene_Map.new
        return
      end
    end
    if Input.trigger?(Input::C)
      @hero = @partychange_window.hero
 
      # If Hero is Nil
      if @hero == nil
        $game_system.se_play($data_system.decision_se)
        return
      end
        
      if $game_party.actors.include?($game_actors[@partychange_window.hero.id])
        return if $partylock[@partychange_window.hero.id - 1] == true
        $game_party.remove_actor(@partychange_window.hero.id)
        @party_window.dispose
        @party_window = Window_Party.new(@window_form)
        @party_window.x = 0
        @party_window.y = 64
        $game_system.se_play($data_system.decision_se)
        @party_window.refresh
        return
      else
        return if $partylock[@partychange_window.hero.id - 1] == true
        $game_party.add_actor(@partychange_window.hero.id)
        @party_window.dispose
        @party_window = Window_Party.new(@window_form)
        @party_window.x = 0
        @party_window.y = 64
        $game_system.se_play($data_system.decision_se)
        @party_window.refresh
        return
      end
    end
  end
end
 
##########
#Displaying the Party Change Window
##########
 
class Window_PartyChange < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(window_form = 0)
    @window_form = window_form
    case window_form
    when 0
      super(0, 0, 640, 240)
      @column_max = 7
    when 1
      super(0, 0, 380, 240)
      @column_max = 4
    when 2
      super(0, 0, 380, 416)
      @column_max = 4
    end
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Get Hero
  #--------------------------------------------------------------------------
  def hero
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    @lock = []
    if $partychange.size > 0
      for i in 0..$partychange.size
        if $partychange[i] == true
          @data.push($game_actors[i+1])
          if $partylock[i] == true
            @lock.push(true)
          else
            @lock.push(false)
          end
        end
      end
      @item_max = @data.size
      self.contents = Bitmap.new(width - 32, row_max * 112)
      for i in 0..(@item_max - 1)
        case @window_form
        when 0
          x = ((i) % 7 * (88)) + 40
          y = (((i)/7) * 112) + 70
        when 1
          x = ((i) % 4 * (88)) + 40
          y = (((i)/4) * 112) + 70
        when 2
          x = ((i) % 4 * (88)) + 40
          y = (((i)/4) * 90) + 70
        end
        actor = @data[i]
        bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
        cw = bitmap.width / 4
        ch = bitmap.height / 4
        src_rect = Rect.new(0, 0, cw, ch)
        if @lock[i] == true
          self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, 150)
        else
          self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  #Redefine Row
  def top_row
    if @window_form == 2
      return self.oy / 90
    else
      return self.oy / 112
    end
  end
  def top_row=(row)
    if row < 0
      row = 0
    end
    if row > row_max - 1
      row = row_max - 1
    end
    if @window_form == 2
      self.oy = row * 90
    else
      self.oy = row * 112
    end
  end
  def page_row_max
    if @window_form == 2
      return (self.height) / 90
    else
      return (self.height) / 112
    end
  end
 
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    # If current row is before top row
    if row < self.top_row
      # Scroll so that current row becomes top row
      self.top_row = row
    end
    # If current row is more to back than back row
    if row > self.top_row + (self.page_row_max - 1)
      # Scroll so that current row becomes back row
      self.top_row = row - (self.page_row_max - 1)
    end
    # If cursor position is less than 0
    case @window_form
    when 0
      self.cursor_rect.set(index % 7 * (88), (@index/7) * 110 - self.oy + ((@index/7) * 2), self.width - 560, 96)
    when 1
      self.cursor_rect.set(index % 4 * (88), (@index/4) * 110 - self.oy + ((@index/4) * 2), self.width - 300, 96)
    when 2
      self.cursor_rect.set(index % 4 * (88), (@index/4) * 88 - self.oy + ((@index/4) * 2), self.width - 300, 96)
    end
  end
 
end
 
 
 
##########
#Displaying current Party Window
##########
 
class Window_Party < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(window_form = 0)
    @window_form = window_form
    case window_form
    when 0
      super(0, 0, 640, 120)
      @column_max = 2
    when 1
      super(0, 0, 640, 120)
      @column_max = 2
    when 2
      super(0, 0, 260, 416)
      @column_max = 2
    end
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    @collumn_custom = 1
    case @window_form
 
    when 0
      for i in 0...$game_party.actors.size
        x = (i % 4 * (160)) + (64)
        y = (i/4) * 116
        actor = $game_party.actors[i]
        draw_actor_graphic(actor, x - 40, y + 80)
        draw_actor_name(actor, x - 50, y)
        draw_actor_level(actor, x - 10, y + 50)
      end
    when 1
      for i in 0...$game_party.actors.size
        x = (i % 4 * (160)) + (64)
        y = (i/4) * 116
        actor = $game_party.actors[i]
        draw_actor_graphic(actor, x - 40, y + 80)
        draw_actor_name(actor, x - 50, y)
        draw_actor_level(actor, x - 10, y + 50)
      end
    when 2
      for i in 0...$game_party.actors.size
        x = (i % 4 * (60)) + (64)
        y = (i/4) * 90
        actor = $game_party.actors[i]
        draw_actor_graphic(actor, x - 40, y + 70)
      end
    end
 
  end
end
 
 
##########
#Displaying Help Window
##########
 
class Window_PartyHelp < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(window_form = 0)
    case window_form
    when 0
      super(0, 0, 640, 64)
    when 1
      super(0, 0, 640, 64)
    when 2
      super(0, 0, 260, 64)
    end
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, self.width - 40, 32, 'Current Party', 1)
  end
end
 
class Window_PartyHelp2 < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(window_form = 0)
    case window_form
    when 0
      super(0, 184, 640, 56)
    when 1
      super(0, 184, 380, 56)
    when 2
      super(260, 0, 380, 64)
    end
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, self.width - 40, 28, 'Add or remove character', 1)
  end
end
 
class Window_PartyHelp3 < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(window_form = 0)
    super(380, 184, 260, 56)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, self.width - 40, 28, 'Character Profile', 1)
  end
end
 
 
##########
#The Customizable Character Profile
##########
 
class Window_Profile < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(380, 240, 260, 240)
    self.contents = Bitmap.new(width - 32, height - 32)
  end
  def update(index)
    
    #====================
    # Window Profile Customization
    #====================
    
    picture = true # Set to false if you don't want to use picture.
    x_pos = 100 # Denotes the possition of the text.
    x_pic = 0 # Denotes the possition of the picture.
    font_size = 22 # The font size. 22 is the default size.
    
    @index = index
    self.contents.clear
    
    @data = []
    # Get the actor data
    if $partychange.size > 0
      for i in 0..$partychange.size
        if $partychange[i] == true
          @data.push($game_actors[i+1])
        end
      end
    end
    
    if picture == true
      actor = @data[index]
      bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
      cw = bitmap.width
      ch = bitmap.height
      src_rect = Rect.new(0, 0, cw, ch)
      self.contents.blt(x_pic, 0, bitmap, src_rect)
    end
    
    # Do something
    if $partychange.size > 0
      self.contents.font.size = font_size
    
      self.contents.draw_text(x_pos, 0, 300, 24, 'Name : ' + @data[index].name, 0)
      
      case actor.id
      when 1
        age = '12'
      when 2
        age = '12'
      else
        age = '???'
      end
      self.contents.draw_text(x_pos, 24, 300, 24, 'Age : ' + age, 0)
      
      self.contents.draw_text(x_pos, 48, 300, 24, 'Class : ' + @data[index].class_name, 0)
      self.contents.draw_text(x_pos, 72, 300, 24, 'Level : ' + @data[index].level.to_s, 0)
 
      case actor.id
      when 1
        self.contents.draw_text(x_pos, 110, 300, 24, 'Story : I think', 0)
        self.contents.draw_text(x_pos, 134, 300, 24, 'this guy name', 0)
        self.contents.draw_text(x_pos, 158, 300, 24, 'is Aluxes.', 0)
      else
        self.contents.draw_text(x_pos, 110, 300, 24, 'Nothing to talk ', 0)
        self.contents.draw_text(x_pos, 134, 300, 24, 'about', 0)
      end
 
    end
  end
end
 
 
#--------------------------------------------------------------------------
# * Reserve Party EXP
#--------------------------------------------------------------------------
class Scene_Battle
  alias black_start_phase5 start_phase5
  def start_phase5
    black_start_phase5
    @percentage = Black::Black_EXP::Percentage
    @black_actors = []
    @black_actors_id = []
    for i in 0...$game_party.actors.size
      @black_actors_id.push($game_party.actors[i].id)
    end    
    for i in @black_actors_id
      @black_actors.push($game_actors[i])
    end
    
    # Get the EXP Value
    exp = 0
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP and amount of gold obtained
        exp += enemy.exp
      end
    end
    
    for i in 0...$partychange.size
      actor = $game_actors[i+1]
      # Check if the actor is already in party and already receive its share.
      if @black_actors.include?(actor)
      else
        # Check if the actor is on reserved list.
        if $partychange[i] == true
          # Check if the actor is not locked.
          if $partylock[i] != true
            if actor.cant_get_exp? == false
              last_level = actor.level
              actor.exp += (exp*@percentage)/100
              if actor.level > last_level
                @status_window.level_up(i)
              end
            end
          elsif $partylock[i] == true
            # If the actor is locked, check if he/she can receive EXP.
            if Black::Black_EXP::Locked == true
              if actor.cant_get_exp? == false
                last_level = actor.level
                actor.exp += (exp*@percentage)/100
                if actor.level > last_level
                  @status_window.level_up(i)
                end
              end
            end
          end
        end
      end      
    end    
  end
end
 
# FIX so that the reserved party is saved on the save file.
class Party_Change
  def initialize
    @partychange = $partychange
    @partylock = $partylock
    @partychangelength = $partychange.size
    @partylocklength = $partylock.size
  end
  def list(number)
    return @partychange[number]
  end
  def lock(number)
    return @partylock[number]
  end
  def list_length
    return @partychangelength
  end
  def lock_length
    return @partylocklength
  end
end
 
class Scene_Save < Scene_File
  def write_save_data(file)
    # Make character data for drawing save file
    characters = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push([actor.character_name, actor.character_hue])
    end
    # Write character data for drawing save file
    Marshal.dump(characters, file)
    # Wrire frame count for measuring play time
    Marshal.dump(Graphics.frame_count, file)
    # Increase save count by 1
    $game_system.save_count += 1
    # Save magic number
    # (A random value will be written each time saving with editor)
    $game_system.magic_number = $data_system.magic_number
    # Write each type of game object
    Marshal.dump($game_system, file)
    Marshal.dump($game_switches, file)
    Marshal.dump($game_variables, file)
    Marshal.dump($game_self_switches, file)
    Marshal.dump($game_screen, file)
    Marshal.dump($game_actors, file)
    Marshal.dump($game_party, file)
    Marshal.dump($game_troop, file)
    Marshal.dump($game_map, file)
    Marshal.dump($game_player, file)
    $party_change = Party_Change.new
    Marshal.dump($party_change, file)
  end
end
 
class Scene_Load < Scene_File
  #--------------------------------------------------------------------------
  # * Read Party Change Data
  #     file : file object for reading (opened)
  #--------------------------------------------------------------------------
  def read_save_data(file)
    # Read character data for drawing save file
    characters = Marshal.load(file)
    # Read frame count for measuring play time
    Graphics.frame_count = Marshal.load(file)
    # Read each type of game object
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    $party_change       = Marshal.load(file)
 
    for i in 0..($party_change.list_length - 1)
      $partychange[i] = $party_change.list(i)
    end
    for i in 0..($party_change.lock_length - 1)
      $partylock[i] = $party_change.lock(i)
    end    
    
    # If magic number is different from when saving
    # (if editing was added with editor)
    if $game_system.magic_number != $data_system.magic_number
      # Load map
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    # Refresh party members
    $game_party.refresh
  end
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎