Party Leader Variable Identification System

● ARCHIVED · READ-ONLY
Started by Cutie Mark Keldeo 2 posts View original ↗
  1.  Party Leader Variable Identification System
    by Cutie Mark Keldeo​
     ​
    Introduction
     ​

    Behold... my very first submission of a... something to this community!  This was created primarily to fit my own project's needs, but with its potential usefulness, I thought I'd share.  This is a very simple script (or rather an update of a few methods) that stores the database number of the party leader in a variable whenever the party's formation is changed, or a character is added or removed.  This is literally all that the script does.  However, this allows events to recognize whether an actor is the first member of the party instead of simply being in the party.  The simplest way to set this up is via conditional branches based on the selected variable.

    Screenshots

    This is a "backstage" sort of script, so directly giving a screenshot of what it does isn't possible.  As you can see from these screenshots though, the event is giving a different message depending on which character is interacting with it.  In this example there is a conditional branch that displays a message based on the "Party Leader" variable.

    Spoiler
    Spoiler
    Script

    Spoiler
     # Party Leader Variable Identification System for RPG Maker VX Ace# By: Cutie Mark Keldeo## This script sets a variable to match the database number of the actor# currently leading your party.  This can be used for events that change# based on who is the party leader, as well as for some other scripts.  ## This script is made to be used with the default menu system (for changing the# party's formation), and therefore other systems that build off it. You may# encounter compatibility issues with certain menu scripts. Otherwise, this# script is made to be plug-and-play.## If using this script, please give credit to Cutie Mark Keldeo.  # This script is free to use for both non-commerical and commercial projects# without asking, so long as credit is given!  You may distrubte and / or # modify this script# so long as you give credit.  module Actor_ID_Setup    ID_Variable = 2 #This is the variable that will be changed to the lead actor's ID. end # Do not edit past this point unless you know what you are doing. module DataManager   # New game (sets variable to 0 if there are no actors)    def self.setup_new_game    create_game_objects    $game_party.setup_starting_members    $game_map.setup($data_system.start_map_id)    $game_player.moveto($data_system.start_x, $data_system.start_y)    $game_player.refresh          if $game_party.exists       $game_variables[Actor_ID_Setup::ID_Variable] = $game_party.members[0].id      else        $game_variables[Actor_ID_Setup::ID_Variable] = 0      end    Graphics.frame_count = 0  endend class Game_Party < Game_Unit   # * Add actor  def add_actor(actor_id)    @actors.push(actor_id) unless @actors.include?(actor_id)    $game_variables[Actor_ID_Setup::ID_Variable] =  $game_party.members[0].id    $game_player.refresh    $game_map.need_refresh = true  end  # * Remove actor    def remove_actor(actor_id)     @actors.delete(actor_id)      if $game_party.exists       $game_variables[Actor_ID_Setup::ID_Variable] = $game_party.members[0].id      else        $game_variables[Actor_ID_Setup::ID_Variable] = 0      end    $game_player.refresh    $game_map.need_refresh = true  endend # * change party formation class Window_MenuStatus < Window_Selectable  def process_ok    super    $game_party.menu_actor = $game_party.members[index]      $game_variables[Actor_ID_Setup::ID_Variable] =  $game_party.members[0].id   endend 
    installation / Compatibility
     ​
    This script should be placed above "Main" and below any alterations to how the party formation is handled, including custom menu systems.  It is plug and play with the default menu system.  I can also confirm it is compatible with the Sapphire Action System by Khas, as my project also employs this.  I have not tested this script with any menu systems other than the default; so long as a custom system is based on the default's method of handling the party formation.  Due to the script's simple nature, it should not interfere with any graphical effects.  

    Credit
     ​
    Please mention me, Cutie Mark Keldeo if using this script in your project.  It is free to use for both commercial and non-commercial projects without asking.  Feel free to distribute this script so long as credit is given. :)
  2. Fixed script format, credit Cutie Mark Keldeo.
    Code:
    # Party Leader Variable Identification System for RPG Maker VX Ace
    # By: Cutie Mark Keldeo
    #
    # This script sets a variable to match the database number of the actor
    # currently leading your party.  This can be used for events that change
    # based on who is the party leader, as well as for some other scripts. 
    #
    # This script is made to be used with the default menu system (for changing the
    # party's formation), and therefore other systems that build off it. You may
    # encounter compatibility issues with certain menu scripts. Otherwise, this
    # script is made to be plug-and-play.
    #
    # If using this script, please give credit to Cutie Mark Keldeo. 
    # This script is free to use for both non-commerical and commercial projects
    # without asking, so long as credit is given!  You may distrubte and / or
    # modify this script# so long as you give credit.
     
    module Actor_ID_Setup
     
      ID_Variable = 2 #This is the variable that will be changed to the lead actor's ID.
     
    end
     
    # Do not edit past this point unless you know what you are doing.
     
    module DataManager
     
     # New game (sets variable to 0 if there are no actors)
     
      def self.setup_new_game
        create_game_objects
        $game_party.setup_starting_members
        $game_map.setup($data_system.start_map_id)
        $game_player.moveto($data_system.start_x, $data_system.start_y)
        $game_player.refresh   
          if $game_party.exists
           $game_variables[Actor_ID_Setup::ID_Variable] = $game_party.members[0].id
          else
           $game_variables[Actor_ID_Setup::ID_Variable] = 0
          end
        Graphics.frame_count = 0
      end
    end
     
    class Game_Party < Game_Unit
     
      # * Add actor
      def add_actor(actor_id)
        @actors.push(actor_id) unless @actors.include?(actor_id)
        $game_variables[Actor_ID_Setup::ID_Variable] =  $game_party.members[0].id
        $game_player.refresh
        $game_map.need_refresh = true
      end
      # * Remove actor
     
      def remove_actor(actor_id)
        @actors.delete(actor_id)
          if $game_party.exists
           $game_variables[Actor_ID_Setup::ID_Variable] = $game_party.members[0].id
          else
           $game_variables[Actor_ID_Setup::ID_Variable] = 0
          end
        $game_player.refresh
        $game_map.need_refresh = true
      end
    end
     
    # * change party formation
     
    class Window_MenuStatus < Window_Selectable
      def process_ok
        super
        $game_party.menu_actor = $game_party.members[index]
          $game_variables[Actor_ID_Setup::ID_Variable] =  $game_party.members[0].id
      end
    end