Follower Distance

MechPen

Warper
Member
Joined
Nov 4, 2018
Messages
4
Reaction score
10
First Language
English
Primarily Uses
RMMV
Follower Space ver 1.1

by me, MechPen


Here's a quick and easy plugin to change how many tiles the party members follow behind the leader. You might need this if your character sprites are wider or longer than 1 tile. Make that pony RPG!

Feature

- Change the distance that party members follow behind the leader.


Screenshots
followerSpace.png


How to Use

Place the plugin in the 'plugins' folder as usual. Add it to the project using the Plugin Manager. Adjust the Follower Distance parameter to the number of tiles you'd like the followers to be behind the leader.



Script
Code:
//=============================================================================
// MechPen Plugins - Followers Follow Less Close.
// MechPen_FollowerSpace.js
//=============================================================================

//It's important that this goes before anything otehr plug-in that modifies:
// Game_Follower.updateMove();

var Imported = Imported || {};
Imported.MechPen_FollowerSpace = true;

var MechPen = MechPen || {};
MechPen.FollowerSpace = MechPen.FollowerSpace || {};
MechPen.FollowerSpace.version = 1.1;

//=============================================================================
/*:
* @plugindesc v1.1 Lets party followers lag a set number of tiles behind.
* Useful if your character sprites are large (or fat :P ).
* @author MechPen
*
* @param Follower Distance
* @desc How many tiles are between each character.
* Default: 1
* @default 1
*
* @help
* Be sure to put this plug-in above any other plug-in that
* modifies Game_Follower.updateMove(); or else that plug-in might not work.
*
* Also: You can't set Follower Distance less than 1. It would make no sense to stack
* the followers like that!
* version 1.1
* - Fixed bug with Gathering, if the player hadn't walked enough to fill out his last positions.
* version 1.0
* - Finished plugin!
*/
//=============================================================================

MechPen.Parameters = PluginManager.parameters('MechPen_FollowerSpace');
MechPen.Param = MechPen.Param || {};
MechPen.Param.FollowerSpaceDistance = Math.max((Number(MechPen.Parameters['Follower Distance']) || 1), 1);

//=============================================================================
// Game_Player
//=============================================================================
MechPen.FollowerSpace.Game_Player_initialize = Game_Player.prototype.initialize;
Game_Player.prototype.initialize = function() {
    MechPen.FollowerSpace.Game_Player_initialize.call(this);
    this._lastPositions = new Array();
};

MechPen.FollowerSpace.Game_Player_clearTransferInfo = Game_Player.prototype.clearTransferInfo;
Game_Player.prototype.clearTransferInfo = function() {
    MechPen.FollowerSpace.Game_Player_clearTransferInfo.call(this);
    this.clearLastPositions();
};

Game_Player.prototype.getLastPositions = function() {
    return this._lastPositions;
};

Game_Player.prototype.popLastPositions = function() {
    this._lastPositions.pop();
};

Game_Player.prototype.clearLastPositions = function() {
    this._lastPositions.length = 0;
};

Game_Player.prototype.repeatLastPositions = function() {
    var currentPosition = [this.x, this.y];
    this._lastPositions.unshift(currentPosition)
};

MechPen.FollowerSpace.Game_Player_moveStraight = Game_Player.prototype.moveStraight;
Game_Player.prototype.moveStraight = function(d) {
    MechPen.FollowerSpace.Game_Player_moveStraight.call(this, d);
    if (this.isMovementSucceeded()) {
        var currentPosition = [this.x, this.y];
        this._lastPositions.unshift(currentPosition);
    }
};

MechPen.FollowerSpace.Game_Player_moveDiagonally = Game_Player.prototype.moveDiagonally;
Game_Player.prototype.moveDiagonally = function(horz, vert) {
    MechPen.FollowerSpace.Game_Player_moveDiagonally.call(this, horz, vert);
    if (this.isMovementSucceeded()) {
        var currentPosition = [this.x, this.y];
        this._lastPositions.unshift(currentPosition);
    }
};

//=============================================================================
// Game_Follower
//=============================================================================
Game_Follower.prototype.chasePlayerAtDistance = function(character, distance) {
    var spacesAway = distance;
    var spaces = $gamePlayer.getLastPositions();
    if (spaces.length < spacesAway) { return; }
 
    var sx = this.deltaXFrom(spaces[spacesAway - 1][0]);
    var sy = this.deltaYFrom(spaces[spacesAway - 1][1]);
    //TODO: reoptimize.
    if (Math.abs(sx) > 0 && Math.abs(sy) > 0) {
        this.moveDiagonally(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2);
    } else if (Math.abs(sx) > 0) {
        this.moveStraight(sx > 0 ? 4 : 6);
    } else if (Math.abs(sy) > 0) {
        this.moveStraight(sy > 0 ? 8 : 2);
    }
    this.setMoveSpeed($gamePlayer.realMoveSpeed());
};


//=============================================================================
// Game_Followers
//=============================================================================
Game_Followers.prototype.updateMove = function() {
    var spacing = 0;
    for (var i = 0; i < this._data.length; i++) {
        var precedingCharacter = (i > 0 ? this._data[i - 1] : $gamePlayer);
        spacing += MechPen.Param.FollowerSpaceDistance;
        this._data[i].chasePlayerAtDistance(precedingCharacter, spacing);
    }
 
    if ($gamePlayer.getLastPositions().length - 1 > spacing * (this._data[this._data.length - 1]._memberIndex + 1))
    {
        $gamePlayer.popLastPositions();
    }
 
    if (this.areGathering())
    {
        $gamePlayer.repeatLastPositions();
    }
};

MechPen.FollowerSpace.Game_Followers_jumpAll = Game_Followers.prototype.jumpAll;
Game_Followers.prototype.jumpAll = function() {
    MechPen.FollowerSpace.Game_Followers_jumpAll.call(this);
    $gamePlayer.clearLastPositions();
};

Game_Followers.prototype.synchronize = function(x, y, d) {
    this.forEach(function(follower) {
        follower.locate(x, y);
        follower.setDirection(d);
    }, this);
};


Terms of Use
This work is licensed under the MIT license.
 

Attachments

Last edited:

Featherbrain

Veteran
Veteran
Joined
Jan 12, 2020
Messages
30
Reaction score
22
First Language
English
Primarily Uses
RMMV
This is an awesome, much-needed plugin. Thanks!

It's a shot in the dark, but I have to ask: Any chance you might update this plugin to support a pixel movement mod like Analog Move? Analog Move is my favorite pixel movement plugin but lacks any parameters to control follower distance.

ETA: Nevermind, I figured out how to change follower distance in the Analog Move plugin myself. (It's shockingly easy.) FWIW, I posted it in the Analog Move thread here: https://forums.rpgmakerweb.com/index.php?threads/analog-move.49828/post-1066448

Anyway, great plugin!
 
Last edited:

Ascare

Villager
Member
Joined
Dec 14, 2017
Messages
9
Reaction score
5
First Language
German
Primarily Uses
RMMV
Good plugin! I'm using tall sprites (with 8 frames for each direction), they look better now with a distance of 2.
There is a visual bug though...when the player starts walking away, the followers start walking in place until the target distance is reached and then they start moving.
It would look better, if they would stand still first and start walking and moving when distance is met.
 

underkactus

Warper
Member
Joined
Jul 4, 2020
Messages
1
Reaction score
0
First Language
Spanish
Primarily Uses
RMMV
Thanks a lot!!
I really expected this plugin a long time ago,
thanks a lot again <3
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

12 done, 4-5 started. Now that the weekend is over, things will sloooowwwww down again proabably.
when you're completely done with someone's crap lol...
Ami
--- Survival For RPGist Part 3 ---

F.Healer: Here it is,I made the Simple Sandwich
Survivalist
: it's so Delicious!
Chef: Here you Go! My Gourmet Steak.
Survivalist: It's Super Delicious,Too!
F.Mage: I Made it for you!
F.Healer: Uhh...Charcoal?
F.Mage No,It's a Toast!
Chef: Did you Let it in 10 Minutes?
F.Mage: Maybe?

Forum statistics

Threads
103,033
Messages
996,814
Members
134,507
Latest member
juegostudios
Top