Save-Point
KRefreshFormation XP - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: KRefreshFormation XP (/thread-8592.html)



KRefreshFormation XP - kyonides - 11-11-2022

KRefreshFormation XP

by Kyonides

Introduction

You can press L or R buttons to change the current formation while walking through the map.
In the RPG Maker series, PageUp and PageDown buttons serve the same purpose as L and R, respectively.

Code:
# * KRefreshFormation XP

class Game_Party
  def swap_formation(dir)
    return if @actors.size < 2
    if dir == :left
      @actors << @actors.shift
    elsif dir == :right
      @actors.unshift @actors.pop
    end
    $game_player.refresh
  end
end

class Game_Player
  alias :kyon_refresh_form_gm_plyr_up :update
  def update
    if Input.trigger?(Input::L)
      $game_system.se_play($data_system.cursor_se)
      $game_party.swap_formation(:left)
    elsif Input.trigger?(Input::R)
      $game_system.se_play($data_system.cursor_se)
      $game_party.swap_formation(:right)
    end
    kyon_refresh_form_gm_plyr_up
  end
end

Terms & Conditions

Free for use in any kind of project. There is nothing else you should know about them.


RE: KRefreshFormation - Kain Nobel - 11-11-2022

Cool to see this done for all the 'Makers, many thank yous!

One feature you could add is to auto-swap forward when the lead character dies.
(In my game, when I was using followers, dead followers were removed from the entourage.)

Also, the ability to let the developer lock the main character from being moved around in the menus.
(In my game, the lead character is the only one programmed with all the action animations. That's why I lock him in key scenes. In other cases, anybody can be lead and different leads have different field map specialties which requires them to be locked as lead player from time to time.)

Not to complicate things, just thinking of how I personally use stuff and I'd imagine others could possibly have similar use cases.

As a sister script, you could make a "designated leader" script. Leader ID = 0 (whoever is index 0 of the party is designated leader), Leader ID >= 1 (leader is actor with ID#). If leader is removed from party, it defaults 0 again.