Follower Distance

● ARCHIVED · READ-ONLY
Started by MechPen 36 posts Page 2 of 2 View original ↗
  1. MechPen said:
    Cae_SlopeMove overrides Game_Player.prototype.moveStraight. but I alias it so it should work if you load Cae_SlopeMove first and then MechPen_FollowerSpace.

    Does it not?
    @MechPen I put Cae_Slope Move on top of your plugin but it still doesn't work.
  2. So I've been using this plugin and I would need for the spacing to be a float like 1.5 to make my 64x64 character sprites not clip with each other (a spacing of 2 looks awkward) but it seems its not possible due to the spacing parameter requiring an int, is there a way to add additional spacing in pixels instead?
  3. Not really! RPG Maker by default is a tile based game. You may wish to look into a pixel movement plugin. those often have options for follower distance. Or at least could be editable.
  4. So this does not work with Pixel movement? I'm using Galv's and Qsprite but I can't get this pluggin to space my team. :(
  5. Any way you can make this so that followers also use the sprint animation from Visustella 8dir movecore? Right now the main character uses it, but the followers are powerwalking
  6. I also would love support for the VisuStella Events and Movement plugin! Fantastic work nonetheless :LZYgrin:
  7. Got this when load existing load game: 1705004475492.png


    EDIT:
    If the save file from new game, when it is loaded. The error was not appear.
  8. SLEEPERER said:
    EDIT:
    If the save file from new game, when it is loaded. The error was not appear.
    then you know the solution: start a new game

    When you add or remove a plugin, in most cases you are required to start a new game because most plugins only initialisa themselves on new game, making all older saves incompatible to the current save structure of the new plugin list.
  9. SLEEPERER said:
    Got this when load existing load game:

    It is possible to patch this so it works with existing saves.
    Open MechPen_FollowerSpace.js in a text editor.

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

    Replace with

    Game_Player.prototype.clearTransferInfo = function() { MechPen.FollowerSpace.Game_Player_clearTransferInfo.call(this); if (!this._lastPositions) { this._lastPositions = new Array(); } this.clearLastPositions(); };
  10. MechPen said:
    It is possible to patch this so it works with existing saves.
    Open MechPen_FollowerSpace.js in a text editor.

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

    Replace with

    Game_Player.prototype.clearTransferInfo = function() { MechPen.FollowerSpace.Game_Player_clearTransferInfo.call(this); if (!this._lastPositions) { this._lastPositions = new Array(); } this.clearLastPositions(); };
    I think I still have old saves. I will try this later and tell you the result.

    @Andar yeah, it's solved. But I will try MechPen's feedback.
  11. Can you dynamically change follower distance with a plugin command, or a state notetag, or something? Could be useful if you have a Magitek-like state where your player characters temporarily ride some mecha suits and need a larger follower distance for a time.
  12. ave36 said:
    Can you dynamically change follower distance with a plugin command, or a state notetag, or something? Could be useful if you have a Magitek-like state where your player characters temporarily ride some mecha suits and need a larger follower distance for a time.
    I want this too! I use 2 tiles distance only for pushing box puzzle so that the party member will not block the way. Other that case, I just want normal distance.
  13. Thank you for a great plugin. I would like to ask if there is a way to change distance via plugin command or script call in game? I use different characters size depending on location and would appreciate this very much!
    Thank you in advance!
    MechPen said:
    Follower Space ver 1.2

    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
    A Follow Distance setting of 2
    View attachment 141812


    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.

    As of 1.2, this also works in MZ.



    Script
    MechPen_FollowerSpace.js
    JavaScript:
    //=============================================================================
    // 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.2;
    
    //=============================================================================
    /*:
    * @target MV MZ
    * @plugindesc v1.2 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.2
    * - Not it works in MZ.
    * 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();
    };
    
    if (Utils.RPGMAKER_NAME == "MZ")
    {
    
    Game_Followers.prototype.synchronize = function(x, y, d) {
        for (const follower of this._data) {
            follower.locate(x, y);
            follower.setDirection(d);
        }
    };
    
    } else if (Utils.RPGMAKER_NAME == "MV")
    {
      
    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.
  14. Thanks, script call works perfectly. I use parallel common event to zoom characters depending on region. So when they are too big, they literally stick to each other.
    But I just realized that there is another big problem. I made mechanics to split party and change leader to play each character separately, using GabeMZ follower plugins. And it seems there is a plugin conflict.

    When MechPen space plugin is placed below Gabe's plugins - follower control doesn't work. And when I place it above, then MechPenFollowerSpace doesn't work.
    I tried to control followers via VZ EventMoveCore plugin, but the result is the same (

    Maybe you have an idea how to resolve this problem?

    MechPen said:
    You can use a script call to set the MechPen.Param.FollowerSpaceDistance variable but it won't be persisted in save games.

    Do it like
    MechPen.Param.FollowerSpaceDistance = 4;

    You could use something like https://galvs-scripts.com/2020/10/21/mz-auto-common-events/ or https://galvs-scripts.com/2017/01/23/mv-load-common-event/ to set this variable when the game is loaded, depending on the map?
  15. aniforce said:
    But I just realized that there is another big problem. I made mechanics to split party and change leader to play each character separately, using GabeMZ follower plugins. It seems there is a plugin conflict.


    Maybe you have an idea how to resolve this problem?

    Placing MechPen_FollowerSpace directly above GabeMZ_FollowersControl in a test project has them both working for me. I am able to Switch Follower Control and set a move route.

    If you have other plugins conflicting it might be a good idea to put MechPen_FollowerSpace near or at the top.