RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[RESOLVED] Help with Leon's party changing script

0 Members and 1 Guest are viewing this topic.

*****
Rep:
Level 88
Illuminaudio
So the script is this

Code: [Select]
#===================================
#  Leon's Party Changing System
#----------------------------------------------------------------------
#  Instructions:  Place above main, but below all other default scripts.

#  Features: 
#    -Allows you to make a party of anywhere between 1 and 4,
#     and the extra party members are limitless.
#    -You use the default add or remove actors command to add or remove
#      actors.  If the party is full, it is added to the extras.
#    -Allows you to take a person from the party and add it to the extras area.
#     To do this, use:   $game_party.remove_actor_from_party(actor_id)
#    -You can set it to where the player can or cannot change the first actor (main character).
#      To do this, press Ctrl+F and search for Leon_Edit .
#   
#  Notes:
#    This setup uses SephirothSpawn's coding to simplify the cursor's position.
#
#
#===================================

#==================================================
#  Game_Party
#==================================================
class Game_Party

  attr_accessor :party_members
  attr_accessor :move
  attr_accessor :locked
 
  alias leon_partyswitch_gameactor_initialize initialize

  def initialize
    leon_partyswitch_gameactor_initialize
    @party_members = []
    @move = 0
    # Leon_Edit
    # Change the below to 'true' to make the first actor unchangable, but
    # if false, it will make it so you can change the first actor.
    @locked = true
  end
 
 
  def add_actor(actor_id)
    actor = $game_actors[actor_id]
    if @actors.size < 4
      unless @actors.include?(actor)
        @actors.push(actor)
        $game_player.refresh
      end
    else
      unless @party_members.include?(actor_id)
        @party_members.push(actor.id)
        $game_player.refresh
      end
    end
  end
 
  def remove_actor(actor_id)
    @actors.delete($game_actors[actor_id])
    @party_members.delete(actor_id)
    $game_player.refresh
  end
 
  def remove_actor_from_party(actor_id)
    if @actors.include?($game_actors[actor_id])
      unless @party_members.include?(actor_id)
        @party_members.push(actor_id)
        @party_members.sort!
        $game_player.refresh
      end
    end
    @actors.delete($game_actors[actor_id])
  end

end
#==================================================
#  END Game_Party
#==================================================

#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :cursor_height
  #--------------------------------------------------------------------------
  # * Alias Initialization
  #--------------------------------------------------------------------------
  alias custom_int initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    custom_int(x, y, width, height)
    @cursor_height = 32
  end
  #--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------
  def top_row
    # Divide y-coordinate of window contents transfer origin by 1 row
    # height of @cursor_height
    return self.oy / @cursor_height
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  # row : row shown on top
  #--------------------------------------------------------------------------
  def top_row=(row)
    # If row is less than 0, change it to 0
    if row < 0
      row = 0
    end
    # If row exceeds row_max - 1, change it to row_max - 1
    if row > row_max - 1
      row = row_max - 1
    end
    # Multiply 1 row height by 32 for y-coordinate of window contents
    # transfer origin
    self.oy = row * @cursor_height
  end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------
  def page_row_max
    # Subtract a frame height of 32 from the window height, and divide it by
    # 1 row height of @cursor_height
    return (self.height - 32) / @cursor_height
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # If cursor position is less than 0
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # Get current row
    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
    # Calculate cursor width
    cursor_width = self.width / @column_max - 32
    # Calculate cursor coordinates
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * @cursor_height - self.oy
    if self.active == true
      # Update cursor rectangle
      self.cursor_rect.set(x, y, cursor_width, @cursor_height)
    end
  end
end

#==============================================================================
# ** Window_Command
#==============================================================================
class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # * Unisable Item
  # index : item number
  #--------------------------------------------------------------------------
  def undisable_item(index)
    draw_item(index, normal_color)
  end
end
#============================================================


#==================================================
#  Window_Party_Info
#==================================================
class Window_Party_Info < Window_Base
  def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Tahoma"
    self.contents.font.size = 22
    refresh
  end

  def refresh
    self.contents.clear
    self.contents.draw_text(0, 0, 614, 32, "Please make a party of four or less.", 1)
  end
end
#==================================================
#  END Window_Party_Info
#==================================================


#==================================================
#  Window_Party_Slots
#==================================================
class Window_Party_Slots < Window_Selectable

  def initialize
    super(0, 64, 320, 416)
    @item_max = 4
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Tahoma"
    self.contents.font.size = 22
    self.index = 0
    self.active = true
    refresh
  end
 
  def actors
    if @data[index] != nil
      return @data[index]
    end
  end

  def refresh
    @data = []
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    for i in 0...$game_party.actors.size
      @data.push($game_party.actors[i])
    end
    @item_max = (@data.size + 1)
    if @item_max > 0
      if @item_max > 4
        @item_max = 4
      end
      self.contents = Bitmap.new(width - 32, row_max * 96)
      self.contents.font.name = "Tahoma"
      self.contents.font.size = 22
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
 
  def draw_item(index)
    @actor = @data[index]
    y = index * 96
    x = 4
    if @actor != nil
      draw_actor_hp(@actor, x + 100, y + 32)
      draw_actor_name(@actor, x + 100, y)
      draw_actor_sp(@actor, x + 100, y + 64)
      bitmap = RPG::Cache.character(@actor.character_name, @actor.character_hue)
      cw = bitmap.width / 4
      ch = bitmap.height / 4
      facing = 0
      src_rect = Rect.new($game_party.move * 32, facing * ch, cw, ch)
      self.contents.blt(x + 24, y + 32, bitmap, src_rect)
    end
  end
 
  def update_cursor_rect
    if @index > -1
      x = 0
      y = index * 96
      self.cursor_rect.set(x, y, (self.width - 32), 96)
    else
      self.cursor_rect.empty
    end
  end
 
end
#==================================================
#  END Window_Party_Slots
#==================================================


#==================================================
#  Window_Party_Extras
#==================================================
class Window_Party_Extras < Window_Selectable
  def initialize
    super(320, 64, 320, 416)
    self.cursor_height = 96
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Tahoma"
    self.contents.font.size = 22
    self.index = -1
    self.active = false
    refresh
  end
 
  def actors
    if @data != nil
      return @data[index]
    end
  end

  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...$game_party.party_members.size
      @data.push($game_actors[$game_party.party_members[i]])
    end
    @data.push(nil)
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 96)
      self.contents.font.name = "Tahoma"
      self.contents.font.size = 22
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
 
  def draw_item(index)
    @actor = @data[index]
    y = index * 96
    x = 4
    if @actor != nil
      draw_actor_hp(@actor, x + 100, y + 32)
      draw_actor_name(@actor, x + 100, y)
      draw_actor_sp(@actor, x + 100, y + 64)
      bitmap = RPG::Cache.character(@actor.character_name, @actor.character_hue)
      cw = bitmap.width / 4
      ch = bitmap.height / 4
      facing = 0
      src_rect = Rect.new($game_party.move * 32, facing * ch, cw, ch)
      self.contents.blt(x + 24, y + 32, bitmap, src_rect)
    end
  end
 
end
#===================================
#  END Window_Party_Extras
#===================================


#===================================
#  Scene_Party_Change
#===================================
class Scene_Party_Change
  def main
   
    @info_window = Window_Party_Info.new
    @slot_window = Window_Party_Slots.new
    @extra_window = Window_Party_Extras.new
    @wait_count = 0
   
    Graphics.transition
    loop do
      @wait_count += 1
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
   
    @info_window.dispose
    @slot_window.dispose
    @extra_window.dispose
  end
 
  def update
    @slot_window.update
    if @wait_count == 12
      if $game_party.move < 3
        $game_party.move += 1
        @slot_window.refresh
        @extra_window.refresh
        @wait_count = 0
      else
        $game_party.move = 0
        @slot_window.refresh
        @extra_window.refresh
        @wait_count = 0
      end
    end
   
    if @slot_window.active
      update_slot
      return
    end
   
    if @extra_window.active
      update_extra
      return
    end
  end
 
  def update_slot
    if Input.trigger?(Input::B)
      if $game_party.actors.size != 0
        $game_player.refresh
        $game_system.se_play($data_system.cancel_se)
        $scene = Scene_Map.new
        $game_party.move = 0
      else
        $game_system.se_play($data_system.buzzer_se)
      end
    end
   
    if Input.trigger?(Input::C)
      if $game_party.locked == true
        if @slot_window.index != 0
          $game_system.se_play($data_system.decision_se)
          @slot_window.active = false
          @extra_window.active = true
          @extra_window.index = 0
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      else
        $game_system.se_play($data_system.decision_se)
        @slot_window.active = false
        @extra_window.active = true
        @extra_window.index = 0
      end
    end
  end
 
  def update_extra
    @extra_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @slot_window.active = true
      @extra_window.active = false
      @extra_window.index = -1
    end
   
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      if @extra_window.actors == nil
        if $game_party.actors[@slot_window.index] != nil
          $game_party.party_members.push($game_party.actors[@slot_window.index].id)
          $game_party.remove_actor_from_party($game_party.actors[@slot_window.index].id)
          $game_party.party_members.sort!
          @slot_window.refresh
          @extra_window.refresh
          @slot_window.active = true
          @extra_window.active = false
          @extra_window.index = -1
        else
          @slot_window.active = true
          @extra_window.active = false
          @extra_window.index = -1
        end
      else
        if $game_party.actors[@slot_window.index] != nil
          hold = @extra_window.actors
          $game_party.party_members.push($game_party.actors[@slot_window.index].id)
          $game_party.actors[@slot_window.index] = hold
          $game_party.party_members.delete_at(@extra_window.index)
          $game_party.party_members.sort!
          @slot_window.refresh
          @extra_window.refresh
          @slot_window.active = true
          @extra_window.active = false
          @extra_window.index = -1
        else
          $game_party.actors[@slot_window.index] = @extra_window.actors
          $game_party.party_members.delete_at(@extra_window.index)
          $game_party.party_members.sort!
          @slot_window.refresh
          @extra_window.refresh
          @slot_window.active = true
          @extra_window.active = false
          @extra_window.index = -1
        end
      end
    end
  end
 
end

Then when I try to remove an actor from my party, the error is this
« Last Edit: December 15, 2007, 06:49:47 AM by Zeriab »

****
Rep:
Level 87
In my own little world...
lol, hey, I know that guy!
He's like one of my good friends.

I'll tell him about this topic if you want.

**
Rep:
Level 86
Did you load up an old save file, or did you make a new game after adding this script?

*****
Rep:
Level 88
Illuminaudio
 I'm pretty sure I loaded a previously saved file. Is that the problem?

Edit: Okay, in a new game, it works. Thanks.
« Last Edit: December 12, 2007, 09:59:10 PM by Dertt »

**
Rep:
Level 86
No prob.  the reason it doesnt work with a previous save file is it adds more to $game_party when initialized.  When you load a save file, it doesn't re-initialize.