Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

change party leader script

anakol

Member

hey, i know this might make me sound retarded because i cant find this, but is there a script to change the party leader? i need one for my game, and im apparently too stupid to find it x.x a little help?
 
I wrote this a while back. It brings up a menu with the map behind it where the menu holds all current party members. Select a party member and the selected member will become the front member. Please credit if you decide to use the script.
Code:
#==============================================================================
# ** Scene_Front
#------------------------------------------------------------------------------
# This class handles frontline changing.
# Accessed through the menu and from call scripts.
# Made by Sarkilas.
#==============================================================================

class Scene_Front
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(r = 'menu')
    @r = r
  end
  #--------------------------------------------------------------------------
  # * Main process
  #--------------------------------------------------------------------------
  def main
    # Make mapset
    @map = Spriteset_Map.new
    # Insert command data
    data = []
    for i in 0...$game_party.actors.size
      if $game_party.actors[i].is_a?(Game_Actor)
        data.push($game_party.actors[i].name)
      end
    end
    # Make help window
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.set_text('Choose which character to control.')
    # Make the command window
    @command_window = Window_Command.new(160, data[0...data.size])
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 240 - @command_window.height / 2
    # Transition
    Graphics.transition
    # Main loop
    while $scene == self
      # Update graphics and input
      Graphics.update
      Input.update
      # Update command window
      @command_window.update
      # Update method
      update
    end
    # Freeze graphics
    Graphics.freeze
    # Dispose objects
    @map.dispose
    @help_window.dispose
    @command_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    # If input B: return to respective class
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Return to respective class
      case @r
      when 'menu'
        $scene = Scene_Menu.new(3)
      when 'map'
        $scene = Scene_Map.new
      end
    end
    # If input C: change new lead
    if Input.trigger?(Input::C)
      # Play cancel SE
      $game_system.se_play($data_system.decision_se)
      # Collect all actor data
      data = []
      for i in 0...$game_party.actors.size
        if $game_party.actors[i].is_a?(Game_Actor)
          data.push($game_party.actors[i])
        end
      end
      # Delete all actors
      for i in 1...$data_actors.size
        $game_party.remove_actor(i)
      end
      # Set up new actor array
      $game_party.add_actor(data[@command_window.index].id)
      # Add remaining party members
      for i in 0...data.size
        if data[i].id != $game_party.actors[0].id
          $game_party.add_actor(data[i].id)
        end
      end
      # Return to respective class
      case @r
      when 'menu'
        $scene = Scene_Menu.new(3)
      when 'map'
        $scene = Scene_Map.new
      end
    end
  end
end
Call it using:
Code:
$scene = Scene_Front.new
or if you want the screen to return to map:
Code:
$scene = Scene_Front.new('map')
Also note, that if you don't want this to be dynamic (like force a character to be the lead), remove all part members using the Change Party event command, then add them back in the decided order. Be sure to uncheck the Initialize box, though.

Hope this helps.
 
anakol":1uqooa90 said:
so how exactly would i call this?..ive never called a script before -_- and do i have to do it every time?

Open up the event you want to call it from. Then, go to the bottom right option on the third page, and insert the information that he gave you to call the script.
 
anakol":qiue9trm said:
so how exactly would i call this?..ive never called a script before -_- and do i have to do it every time? and is there a way to do it with a button press?
You can do it with a button press by using a common event with a parallel process and a keypress conditional branch that calls up the script. This script allows the player to select who to change the lead to, so as I mentioned earlier, use the Change Party commands if you want to force a lead-change.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top