The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: pliio8 on March 18, 2007, 07:38:44 PM

Title: Increasing maximun party size?
Post by: pliio8 on March 18, 2007, 07:38:44 PM
Does anyone know if they can increase the maximum party size and having them appear in the deafault battle system in XP PK?
Title: Re: Increasing maximun party size?
Post by: italianstal1ion on March 19, 2007, 03:57:56 AM
I found this to be a pretty useful script. It allows party changing also, but if you dont want that just make the max_battle size and max_party size the same number.

Note: It can be any amount of heroes(really, try like 50 its pretty awesome) But around 7 or 8 is when if your using gradients or anything the words just scramble together.

ALL CREDITS TO FOMAR1053 OF hbgames.org


Party Control

--------------------------------------------------------------------------------

This is basically a combination of my two scripts large party and party changing.
Meaning you can have as many people as you like in the party and choose how many take part in the battles, naturally it is game over if the battle party loses.

To use this script requires you to enter 2 numbers and either make the neccassary changes to spriteset battle or copy and paste the provided one.

First the main script.



class Game_Party
 
  Battle_Party_Size = 5
  Max_Party_Size = 10
 
  def max_party_size
    return Max_Party_Size
  end
 
  def max_party
    return Battle_Party_Size
  end
 
  def placement_correctment
    if @actors.size <= Battle_Party_Size
      return @actors.size
    else
      return Battle_Party_Size
    end
  end
 
  def add_actor(actor_id)
    actor = $game_actors[actor_id]
    if not @actors.include?(actor) and $game_party.actors.size < Max_Party_Size
      @actors.push(actor)
      $game_player.refresh
    end
  end
 
  def all_dead?
    if $game_party.actors.size == 0
      return false
    end
    for actor in @actors
      if actor.hp > 0
        return false
      end
      if actor.index >= 4
        return true
      end
    end
    return true
  end
 
end


class Window_BattleStatus < Window_Base
 
  def initialize
    super(0, 320, 640, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    unless $game_party.actors.size > 4
      @level_up_flags = [false, false, false, false]
    else
      @level_up_flags = []
      for i in 0...$game_party.placement_correctment
        @level_up_flags.push(false)
      end
    end
    refresh
  end
 
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      unless $game_party.actors.size > 4
        actor_x = i * 160 + 4
      else
        actor_x = i * (4 + (640/ $game_party.placement_correctment))
      end
      draw_actor_name(actor, actor_x, 0)
      draw_actor_hp(actor, actor_x, 32, 120)
      draw_actor_sp(actor, actor_x, 64, 120)
      if @level_up_flags[i]
        self.contents.font.color = normal_color
        self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
      else
        draw_actor_state(actor, actor_x, 96)
      end
    end
  end
end


class Game_Actor < Game_Battler
  def screen_x
    if self.index != nil
      unless $game_party.actors.size > 4
        return self.index * 160 + 80
      else
        return self.index * (640/ $game_party.placement_correctment) + (80/($game_party.placement_correctment/2))
      end
    else
      return 0
    end
  end
end


class Scene_Battle
  def phase3_next_actor
    begin
      if @active_battler != nil
        @active_battler.blink = false
      end
      if @actor_index == $game_party.placement_correctment-1
        start_phase4
        return
      end
      @actor_index += 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    end until @active_battler.inputable?
    phase3_setup_command_window
  end
 
  def phase3_setup_command_window
    @party_command_window.active = false
    @party_command_window.visible = false
    @actor_command_window.active = true
    @actor_command_window.visible = true
    unless $game_party.actors.size > 4
      @actor_command_window.x = @actor_index * 160
    else
      @actor_command_window.x = @actor_index * (640/$game_party.placement_correctment)
      if @actor_command_window.x > 480
        @actor_command_window.x = 480
      end
    end
    @actor_command_window.index = 0
  end
end


class Scene_Menu
 
  alias party_swap_update_command update_command
  def update_command
    party_swap_update_command
    if Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      @previous_index = @command_window.index
      @command_window.index = -1
      @command_window.active = false
      @status_window.active = true
      @status_window.index = @status_window.top_row
      return
    end
  end
 
  alias party_swap_update_status update_status
  def update_status
    if Input.trigger?(Input::B)
      unless @swapee != nil
        $game_system.se_play($data_system.cancel_se)
        if @command_window.index == -1
          @command_window.index = @previous_index
        end
        @command_window.active = true
        @status_window.active = false
        @status_window.index = -1
        return
      end
      @swapee = nil
      return
    end
    if Input.trigger?(Input::C) and @command_window.index == -1
      unless @swapee != nil
        @swapee = @status_window.index
        $game_system.se_play($data_system.decision_se)
        return
      end
      if @swapee == @status_window.index
        $game_system.se_play($data_system.decision_se)
        @swapee = nil
        return
      end
      $game_system.se_play($data_system.decision_se)
      party_ids = []
      for actor in $game_party.actors
        party_ids.push(actor.id)
      end
      swapee2 = @status_window.index
      if @swapee < swapee2
        for i in @swapee...party_ids.size
          $game_party.remove_actor(party_ids[i])
        end
        $game_party.add_actor(party_ids[swapee2])
        for i in (@swapee + 1)...party_ids.size
          unless i == swapee2
            $game_party.add_actor(party_ids[i])
          else
            $game_party.add_actor(party_ids[@swapee])
          end
        end
      else
        for i in swapee2...party_ids.size
          $game_party.remove_actor(party_ids[i])
        end
        $game_party.add_actor(party_ids[@swapee])
        for i in (swapee2 + 1)...party_ids.size
          unless i == @swapee
            $game_party.add_actor(party_ids[i])
          else
            $game_party.add_actor(party_ids[swapee2])
          end
        end
      end
      @swapee = nil
      @status_window.refresh
      return
    end
    if Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
      if @swapee == nil and @command_window.index == -1
        $game_system.se_play($data_system.cursor_se)
        @command_window.index = @previous_index
        @command_window.active = true
        @status_window.active = false
        @status_window.index = -1
      end
    end
    party_swap_update_status
  end
 
 
end

class Window_MenuStatus < Window_Selectable
 
  def initialize
    unless $game_party.actors.size > 4
      super(0, 0, 480, 480)
    else
      super(0, 0, 480, 160 * $game_party.actors.size)
    end
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    self.active = false
    self.index = -1
  end
 
  alias large_refresh refresh
  def refresh
    large_refresh
    self.height = 480
  end
 
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    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
 
  def top_row
    return self.oy / 116
  end
 
  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
 
  def page_row_max
    return 4
  end
end

class Game_Actor < Game_Battler
  def exist?
    return super == self.index < 4
  end
end











Next this bit refers to spriteset battle:
If you just want a copy and paste put this above main and below spriteset battle



#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within
#  the Scene_Battle class.
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :viewport1                # enemy viewport
  attr_reader   :viewport2                # actor viewport
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Make viewports
    @viewport1 = Viewport.new(0, 0, 640, 320)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport4 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 101
    @viewport3.z = 200
    @viewport4.z = 5000
    # Make battleback sprite
    @battleback_sprite = Sprite.new(@viewport1)
    # Make enemy sprites
    @enemy_sprites = []
    for enemy in $game_troop.enemies.reverse
      @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
    end
    # Make actor sprites
   
   
    @actor_sprites = []
    #@actor_sprites.push(Sprite_Battler.new(@viewport2))
    #@actor_sprites.push(Sprite_Battler.new(@viewport2))
    #@actor_sprites.push(Sprite_Battler.new(@viewport2))
    #@actor_sprites.push(Sprite_Battler.new(@viewport2))
   
   
    for i in 0...$game_party.max_party
      @actor_sprites.push(Sprite_Battler.new(@viewport2))
    end
   
   
   
    # Make weather
    @weather = RPG::Weather.new(@viewport1)
    # Make picture sprites
    @picture_sprites = []
    for i in 51..100
      @picture_sprites.push(Sprite_Picture.new(@viewport3,
        $game_screen.pictures[i]))
    end
    # Make timer sprite
    @timer_sprite = Sprite_Timer.new
    # Frame update
    update
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update actor sprite contents (corresponds with actor switching)
    #@actor_sprites[0].battler = $game_party.actors[0]
    #@actor_sprites[1].battler = $game_party.actors[1]
    #@actor_sprites[2].battler = $game_party.actors[2]
    #@actor_sprites[3].battler = $game_party.actors[3]
   
    for i in 0...$game_party.max_party
      @actor_sprites[i].battler = $game_party.actors[i]
    end
   
    # If battleback file name is different from current one
    if @battleback_name != $game_temp.battleback_name
      @battleback_name = $game_temp.battleback_name
      if @battleback_sprite.bitmap != nil
        @battleback_sprite.bitmap.dispose
      end
      @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
      @battleback_sprite.src_rect.set(0, 0, 640, 320)
    end
    # Update battler sprites
    for sprite in @enemy_sprites + @actor_sprites
      sprite.update
    end
    # Update weather graphic
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.update
    # Update picture sprites
    for sprite in @picture_sprites
      sprite.update
    end
    # Update timer sprite
    @timer_sprite.update
    # Set screen color tone and shake position
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    # Set screen flash color
    @viewport4.color = $game_screen.flash_color
    # Update viewports
    @viewport1.update
    @viewport2.update
    @viewport4.update
  end
end









Otherwise in spriteset battle find:



    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))

And replace it with:


    for i in 0...$game_party.max_party
      @actor_sprites.push(Sprite_Battler.new(@viewport2))
    end

Then find:


    @actor_sprites[0].battler = $game_party.actors[0]
    @actor_sprites[1].battler = $game_party.actors[1]
    @actor_sprites[2].battler = $game_party.actors[2]
    @actor_sprites[3].battler = $game_party.actors[3]

And replace it with:



    for i in 0...$game_party.max_party
      @actor_sprites[i].battler = $game_party.actors[i]
    end


And your done with this bit.






Ok now to use this script as I mentioned you have to pick two numbers.
At the top of the main script find


  Battle_Party_Size = 5
  Max_Party_Size = 10
That means 5 people are in a battle and upto 10 in the party.
So change the 5 to however many people will be taking part in the battle and the 10 to the maximum party size.
So enjoy this script
Title: Re: Increasing maximun party size?
Post by: Cutman on March 19, 2007, 10:51:45 PM
It isn't work me man? is that allright or I'm the one who failed copying it?

thx with the code, I need it, so, I will loking for your answer ;)

Bai Bai
Title: Re: Increasing maximun party size?
Post by: Cutman on March 19, 2007, 11:53:08 PM
No matter how hard I try, I can't make it work!!!

I need to paste overwrite the main codes or under the main codes?

(sorry, double post ñ.ñ)
Title: Re: Increasing maximun party size?
Post by: Kokowam on March 20, 2007, 12:04:02 AM
Slightly offtopic, but edit posts next time instead of double-posting :P
Title: Re: Increasing maximun party size?
Post by: italianstal1ion on March 20, 2007, 01:37:14 AM
ok first script place under all others. Second script, you place under spriteset_battle OR replace the script with the other code.
Title: Re: Increasing maximun party size?
Post by: Cutman on March 20, 2007, 11:05:06 PM
YAP!! It's working n_n I found my mistake ñ.ñ

But, I have a problem, there are 6 members on battle, the 5th & 6th members don't show the action box

What can I do?
Title: Re: Increasing maximun party size?
Post by: italianstal1ion on March 20, 2007, 11:20:01 PM
hmm really? Works fine for me, if your using something besides default or have an edited default battle system it might not work.
Title: Re: Increasing maximun party size?
Post by: Cutman on March 21, 2007, 12:23:43 AM
nop, there is an special script for that, if there is, please, quote the code for me here.
Title: Re: Increasing maximun party size?
Post by: Darkauthor on April 06, 2007, 09:57:35 PM
Any way to increase the max battle party size past 6? I always thought it was kinda silly that a 8+ party would only have 3 or 4 people fighting. What are the others doing? Cheering? Getting drunk? Placing bets on the winner? lol Having more than 6 may not be practical but I'd like to at least see how it works out.
Title: Re: Increasing maximun party size?
Post by: Darkauthor on April 09, 2007, 06:02:34 AM
Seems broken to me. When the battlers reach 0 hp their battler graphic fades but they can still be selected to attack. Also it makes all character stats (hp, mp etc) in the main menu and in the battle interface dissapear. Anyone have a better version of this?

Edit: Found an excellent script for having a bigger party but doesn't include increasing the size of the battle party which is something I'd like to do.
Title: Re: Increasing maximun party size?
Post by: Mizuti on April 19, 2007, 12:54:25 PM
I just tried using this script, but I seem to be having a problem. I have six characters in my party, but during battle the sixth member doesn't appear, and I can't see the HP/SP of the 5th member. Does anyone know what I need to do?