Save-Point
KRefreshFormation - 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)
+--- Thread: KRefreshFormation (/thread-8592.html)



KRefreshFormation - kyonides - 11-11-2022

KRefreshFormation

XP + VX + ACE + MV

by Kyonides Arkanthes

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.

XP Version

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


VX & VX ACE Version

Code:
# * KRefreshFormation VX & ACE

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)
      Sound.play_cursor
      $game_party.swap_formation(:left)
    elsif Input.trigger?(Input::R)
      Sound.play_cursor
      $game_party.swap_formation(:right)
    end
    kyon_refresh_form_gm_plyr_up
  end
end


MV Version

Code:
//========================================================================================
// KRefreshFormation MV.js
//========================================================================================
/*:
* @plugindesc Change the Current Party's Formation with a Button!
* version 0.1.0
* @author Kyonides Arkanthes
*
* @param None
*
* @help Instructions:
*   While playing on the map, simply hit:
*     L or R buttons
*     PageUp or PageDown buttons
*/

Game_Party.prototype.swapFormation = function(dir) {
  if (this._actors.size < 2) { return; }
  if (dir == "left") {
    this._actors.push(this._actors.shift());
  } else if (dir == "right") {
    this._actors.unshift(this._actors.pop());
  }
  $gamePlayer.refresh();
};

const Game_Player_update_refresh_heroes = Game_Player.prototype.update;

Game_Player.prototype.update = function(sceneActive) {
  if (Input.isTriggered('pageup')) {
    SoundManager.playCursor();
    $gameParty.swapFormation("left");
  } else if (Input.isTriggered('pagedown')) {
    SoundManager.playCursor();
    $gameParty.swapFormation("right");
  }
  Game_Player_update_refresh_heroes.call(this, sceneActive);
};

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.