Save-Point
Dargor's Large Party script and shop menu - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Dargor's Large Party script and shop menu (/thread-4798.html)



Dargor's Large Party script and shop menu - Simon Greedwell - 08-28-2013

Greetings and salutations.

I decided to use Dargor's Large Party Script that allows more than 4 party members and I noticed that in the shop menu only the first 4 characters show up. I'm using the default shop script if you are wondering.

There's Dargor's script if needed:

Code:
#==============================================================================
# ** Large Party
#------------------------------------------------------------------------------
#  Author: Dargor
#  Version 1.3
#  02/08/2007
#==============================================================================

#==============================================================================
# ** Large Party Customization Module
#==============================================================================

module Dargor
  module Large_Party
    # Maximum number of actors allowed in the party
    Max_Size = 9
    # Battle status window refresh rate (used in phase5)
    Battle_Refresh_Rate = 32
  end
end

#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  This class handles temporary data that is not included with save data.
#  Refer to "$game_temp" for the instance of this class.
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :battle_actor_index  # @actor_index in battle scene
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias large_party_temp_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    large_party_temp_initialize
    @battle_actor_index = 0
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
#  and items. Refer to "$game_party" for the instance of this class.
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :max_size   # Max number of actors allowed in the party
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias large_party_initialize initialize
  alias large_party_add_actor add_actor
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    large_party_initialize
    @max_size = Dargor::Large_Party::Max_Size
  end
  #--------------------------------------------------------------------------
  # * Add an Actor
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def add_actor(actor_id)
    # Original method
    large_party_add_actor(actor_id)
    # Get actor
    actor = $game_actors[actor_id]
    # If the party has less than 4 members and this actor is not in the party
    if @actors.size < @max_size and not @actors.include?(actor)
      # Add actor
      @actors.push(actor)
      # Refresh player
      $game_player.refresh
    end
  end
end

#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
#  This sprite is used to display the battler.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias large_party_sprite_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Original method
    large_party_sprite_update
    # Set sprite coordinates
    if @battler.is_a?(Game_Actor)
      self.x = @battler.screen_x - ($game_temp.battle_actor_index / 4) * 640
    end
  end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within
#  the Scene_Battle class.
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias large_party_spriteset_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Cycle through all extra actors (4+)
    # Create/update sprites
    for i in 4...$game_party.actors.size
      if @actor_sprites[i].nil?
        @actor_sprites.push(Sprite_Battler.new(@viewport2))
      end
      @actor_sprites[i].battler = $game_party.actors[i]
    end
    # Original method
    large_party_spriteset_update
  end
end

#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays party member status on the menu screen.
#==============================================================================

class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias large_party_menu_status_initialize initialize
  alias large_party_menu_status_refresh refresh
  alias large_party_menu_status_update_cursor_rect update_cursor_rect
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Original method
    large_party_menu_status_initialize
    # Adjust contents height
    @item_max = $game_party.actors.size
    height = @item_max * 120
    self.contents = Bitmap.new(width - 32, height - 32)
    # Refresh
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(*args)
    # Original method
    large_party_menu_status_refresh(*args)
    # Adjust default height
    self.height = 480
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    large_party_menu_status_update_cursor_rect
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    cursor_width = self.width / @column_max - 32
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 116 - self.oy
    self.cursor_rect.set(x, y, cursor_width, 96)
  end
  #--------------------------------------------------------------------------
  # * Top Row
  #--------------------------------------------------------------------------
  def top_row
    return self.oy / 116
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  #     row : new row
  #--------------------------------------------------------------------------
  def top_row=(row)
    if row < 0
      row = 0
    end
    if row > row_max - 1
      row = row_max - 1
    end
    self.oy = row * 116
  end
  #--------------------------------------------------------------------------
  # * Page Row Max
  #--------------------------------------------------------------------------
  def page_row_max
    return 4
  end
end

#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
#  This window displays the status of all party members on the battle screen.
#==============================================================================

class Window_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias large_party_battle_status_initialize initialize
  alias large_party_battle_status_refresh refresh
  alias large_party_battle_status_update update
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @column_max = 4
    large_party_battle_status_initialize
    width = $game_party.actors.size * 160
    self.contents = Bitmap.new(width - 32, height - 32)
    self.width = 640
    @level_up_flags = []
    for i in 0...$game_party.actors.size
      @level_up_flags << false
    end
    @item_max = $game_party.actors.size
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Refresh contents when actors are added/removed in-battle
    if $game_party.actors.size != @item_max
      @item_max = $game_party.actors.size
      width = @item_max * 160
      self.contents = Bitmap.new(width - 32, height - 32)
      self.width = 640
    end
    large_party_battle_status_refresh
    column = $game_temp.battle_actor_index / 4
    self.ox = column * 640
  end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias large_party_phase3_setup_command_window phase3_setup_command_window
  alias large_party_update_phase4_step2 update_phase4_step2
  alias large_party_start_phase5 start_phase5
  alias large_party_update_phase5 update_phase5
  #--------------------------------------------------------------------------
  # * Actor Command Window Setup
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    $game_temp.battle_actor_index = @actor_index
    @status_window.refresh
    large_party_phase3_setup_command_window
    @actor_command_window.x = (@actor_index%4) * 160
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 2 : start action)
  #--------------------------------------------------------------------------
  def update_phase4_step2
    if @active_battler.is_a?(Game_Actor)
      $game_temp.battle_actor_index = @active_battler.index
      @status_window.refresh
    end
    large_party_update_phase4_step2
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 4 : animation for target)
  #--------------------------------------------------------------------------
  def update_phase4_step4
    if @target_battlers[0] != nil
      $game_temp.battle_actor_index = @target_battlers[0].index
      @status_window.refresh
    end
    # Animation for target
    for target in @target_battlers
      target.animation_id = @animation2_id
      target.animation_hit = (target.damage != "Miss")
    end
    # Animation has at least 8 frames, regardless of its length
    @wait_count = 8
    # Shift to step 5
    @phase4_step = 5
  end
  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  def start_phase5
    @actor_index = 0
    @status_wait = Graphics.frame_count
    large_party_start_phase5
  end
  #--------------------------------------------------------------------------
  # * Frame Update (after battle phase)
  #--------------------------------------------------------------------------
  def update_phase5
    refresh_rate = Dargor::Large_Party::Battle_Refresh_Rate
    if Graphics.frame_count >= @status_wait + refresh_rate
      $game_temp.battle_actor_index = @actor_index
      @status_window.refresh
      @status_wait = Graphics.frame_count
      max = ($game_party.actors.size.to_f/4).ceil * 4
      @actor_index = (@actor_index+1) % max
    end
    large_party_update_phase5
  end
end



RE: Dargor's Large Party script and shop menu - DerVVulfman - 08-28-2013

A little bit of exercise... Winking

Code:
#==============================================================================
# ** Large Party Scene Shop & Window Expansion
#------------------------------------------------------------------------------
#    by DerVVulfman
#    version 1.0
#    08-28-2013
#    RGSS / RPGMaker XP
#------------------------------------------------------------------------------
#
#    Requested by:  Simon Greedwell
#
#    Just a quick rewrite of the Shop Status window and Scene_Shop script to
#    allow Dargor's Large Party system work.  It should also work with other
#    similar large party systems for RPGMaker XP, but untried.  However, the
#    highlighting feature works even without the use of a large party system.
#
#    When in the Shop Buy window, hitting the L & R member cycling keys ( or
#    the Q & W on the keyboard ), you exit the Buy window & enter the status
#    window.  During this time,  all the members within the  window  will be
#    highlighted.  Use Up/Down keys to scroll through them.  ESC returns you
#    to the Buy window.
#
#==============================================================================



#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
#  This window displays number of items in possession and the actor's equipment
#  on the shop screen.
#==============================================================================

class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :index                    # Window Index
  attr_accessor :item_max                 # Window Max Items
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias large_party_shop_status_initialize initialize  
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Original method
    large_party_shop_status_initialize
    # Set Contents index
    @index = 0
    # Set Contents size
    @item_max = $game_party.actors.size
    # Refresh
    refresh    
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    return if @item.nil?
    case @item
    when RPG::Item    ; number = $game_party.item_number(@item.id)
    when RPG::Weapon  ; number = $game_party.weapon_number(@item.id)
    when RPG::Armor   ; number = $game_party.armor_number(@item.id)
    end
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 200, 32, "number in possession")
    self.contents.font.color = normal_color
    self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
    return if @item.is_a?(RPG::Item)
    # Create Start and End points for actor sorting
    start_count = 0 + @index
    end_count = start_count + 3
    end_count = $game_party.actors.size if end_count > $game_party.actors.size
    # Reset Line Count for Text Display
    line_count = 0
    # Equipment adding information
    for i in start_count..end_count
      # Get actor
      actor = $game_party.actors[i]
      # If equippable, use normal text color, otherwise use invalid text color
      self.contents.font.color = (actor.equippable?(@item)) ?
                                  normal_color : disabled_color
      # Draw actor's name
      self.contents.draw_text(4, 48 + 64 * line_count, 120, 32, actor.name)
      # Get current equipment
      if @item.is_a?(RPG::Weapon)
        # For Weapon
        item1 = $data_weapons[actor.weapon_id]
      else
        # For armor, branched on Armor kind
        case @item.kind
        when 0 ; item1 = $data_armors[actor.armor1_id]
        when 1 ; item1 = $data_armors[actor.armor2_id]
        when 2 ; item1 = $data_armors[actor.armor3_id]
        else ;   item1 = $data_armors[actor.armor4_id]
        end
      end
      # If equippable
      if actor.equippable?(@item)
        # If weapon
        if @item.is_a?(RPG::Weapon)
          atk1 = item1 != nil ? item1.atk : 0
          atk2 = @item != nil ? @item.atk : 0
          change = atk2 - atk1
        end
        # If armor
        if @item.is_a?(RPG::Armor)
          pdef1 = item1 != nil ? item1.pdef : 0
          mdef1 = item1 != nil ? item1.mdef : 0
          pdef2 = @item != nil ? @item.pdef : 0
          mdef2 = @item != nil ? @item.mdef : 0
          change = pdef2 - pdef1 + mdef2 - mdef1
        end
        # Draw parameter change values
        self.contents.draw_text(124, 48 + 64 * line_count, 112, 32,
          sprintf("%+d", change), 2)
      end
      # Draw item
      unless item1.nil?
        x = 4
        y = 80 + 64 * line_count
        bitmap = RPG::Cache.icon(item1.icon_name)
        opacity = self.contents.font.color == normal_color ? 255 : 128
        self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(x + 28, y, 212, 32, item1.name)
      end
      # Advance Line by 1
      line_count += 1
    end
    # Update Cursor Rectangle
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # Remove if window is inactive
    return self.cursor_rect.empty unless self.active
    # Update cursor rectangle
    self.cursor_rect.set(0, 48, 240, 256)
  end  
end



#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  This class performs shop screen processing.
#==============================================================================

class Scene_Shop
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias large_party_scene_shop_update update
  alias large_party_scene_shop_update_buy update_buy
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    large_party_scene_shop_update
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end  
  #--------------------------------------------------------------------------
  # * Frame Update (when buy window is active)
  #--------------------------------------------------------------------------
  def update_buy
    large_party_scene_shop_update_buy
    @status_window.active = false
    # If C button was pressed
    if Input.trigger?(Input::L) or Input.trigger?(Input::R)
      # Play decision SE
      $game_system.se_play($data_system.cursor_se)
      @status_window.active = true
      @buy_window.active = false
      @status_window.refresh
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when buy window is active)
  #--------------------------------------------------------------------------
  def update_status
    if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      max = @status_window.item_max - 4
      val = @status_window.index += 1
      val = max if val > max
      @status_window.index = val
      @status_window.refresh
    end
    if Input.repeat?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      val = @status_window.index -= 1
      val = 0 if val < 0
      @status_window.index = val
      @status_window.refresh
    end    
    # If C button was pressed
    if Input.trigger?(Input::B)
      # Play decision SE
      $game_system.se_play($data_system.cancel_se)
      @status_window.active = false
      @buy_window.active = true
      @status_window.refresh
      return
    end
  end  
end



RE: Dargor's Large Party script and shop menu - Simon Greedwell - 08-28-2013

A thousand thanks friend. I already tested and works perfectly.