设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 81|回复: 0

[转载发布] Follower Distance

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29925
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38778

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    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
    Spoiler: A Follow Distance setting of 2
    [/quote]


    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
    Spoiler: MechPen_FollowerSpace.js[quote]                JavaScript:       
    1. //=============================================================================
    2. // MechPen Plugins - Followers Follow Less Close.
    3. // MechPen_FollowerSpace.js
    4. //=============================================================================
    5. //It's important that this goes before anything otehr plug-in that modifies:
    6. // Game_Follower.updateMove();
    7. var Imported = Imported || {};
    8. Imported.MechPen_FollowerSpace = true;
    9. var MechPen = MechPen || {};
    10. MechPen.FollowerSpace = MechPen.FollowerSpace || {};
    11. MechPen.FollowerSpace.version = 1.2;
    12. //=============================================================================
    13. /*:
    14. * @target MV MZ
    15. * @plugindesc v1.2 Lets party followers lag a set number of tiles behind.
    16. * Useful if your character sprites are large (or fat :P ).
    17. * @author MechPen
    18. *
    19. * @param Follower Distance
    20. * @desc How many tiles are between each character.
    21. * Default: 1
    22. * @default 1
    23. *
    24. * @help
    25. * Be sure to put this plug-in above any other plug-in that
    26. * modifies Game_Follower.updateMove(); or else that plug-in might not work.
    27. *
    28. * Also: You can't set Follower Distance less than 1. It would make no sense to stack
    29. * the followers like that!
    30. * version 1.2
    31. * - Not it works in MZ.
    32. * version 1.1
    33. * - Fixed bug with Gathering, if the player hadn't walked enough to fill out his last positions.
    34. * version 1.0
    35. * - Finished plugin!
    36. */
    37. //=============================================================================
    38. MechPen.Parameters = PluginManager.parameters('MechPen_FollowerSpace');
    39. MechPen.Param = MechPen.Param || {};
    40. MechPen.Param.FollowerSpaceDistance = Math.max((Number(MechPen.Parameters['Follower Distance']) || 1), 1);
    41. //=============================================================================
    42. // Game_Player
    43. //=============================================================================
    44. MechPen.FollowerSpace.Game_Player_initialize = Game_Player.prototype.initialize;
    45. Game_Player.prototype.initialize = function() {
    46.     MechPen.FollowerSpace.Game_Player_initialize.call(this);
    47.     this._lastPositions = new Array();
    48. };
    49. MechPen.FollowerSpace.Game_Player_clearTransferInfo = Game_Player.prototype.clearTransferInfo;
    50. Game_Player.prototype.clearTransferInfo = function() {
    51.     MechPen.FollowerSpace.Game_Player_clearTransferInfo.call(this);
    52.     this.clearLastPositions();
    53. };
    54. Game_Player.prototype.getLastPositions = function() {
    55.     return this._lastPositions;
    56. };
    57. Game_Player.prototype.popLastPositions = function() {
    58.     this._lastPositions.pop();
    59. };
    60. Game_Player.prototype.clearLastPositions = function() {
    61.     this._lastPositions.length = 0;
    62. };
    63. Game_Player.prototype.repeatLastPositions = function() {
    64.     var currentPosition = [this.x, this.y];
    65.     this._lastPositions.unshift(currentPosition)
    66. };
    67. MechPen.FollowerSpace.Game_Player_moveStraight = Game_Player.prototype.moveStraight;
    68. Game_Player.prototype.moveStraight = function(d) {
    69.     MechPen.FollowerSpace.Game_Player_moveStraight.call(this, d);
    70.     if (this.isMovementSucceeded()) {
    71.         var currentPosition = [this.x, this.y];
    72.         this._lastPositions.unshift(currentPosition);
    73.     }
    74. };
    75. MechPen.FollowerSpace.Game_Player_moveDiagonally = Game_Player.prototype.moveDiagonally;
    76. Game_Player.prototype.moveDiagonally = function(horz, vert) {
    77.     MechPen.FollowerSpace.Game_Player_moveDiagonally.call(this, horz, vert);
    78.     if (this.isMovementSucceeded()) {
    79.         var currentPosition = [this.x, this.y];
    80.         this._lastPositions.unshift(currentPosition);
    81.     }
    82. };
    83. //=============================================================================
    84. // Game_Follower
    85. //=============================================================================
    86. Game_Follower.prototype.chasePlayerAtDistance = function(character, distance) {
    87.     var spacesAway = distance;
    88.     var spaces = $gamePlayer.getLastPositions();
    89.     if (spaces.length < spacesAway) { return; }
    90.     var sx = this.deltaXFrom(spaces[spacesAway - 1][0]);
    91.     var sy = this.deltaYFrom(spaces[spacesAway - 1][1]);
    92.     //TODO: reoptimize.
    93.     if (Math.abs(sx) > 0 && Math.abs(sy) > 0) {
    94.         this.moveDiagonally(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2);
    95.     } else if (Math.abs(sx) > 0) {
    96.         this.moveStraight(sx > 0 ? 4 : 6);
    97.     } else if (Math.abs(sy) > 0) {
    98.         this.moveStraight(sy > 0 ? 8 : 2);
    99.     }
    100.     this.setMoveSpeed($gamePlayer.realMoveSpeed());
    101. };
    102. //=============================================================================
    103. // Game_Followers
    104. //=============================================================================
    105. Game_Followers.prototype.updateMove = function() {
    106.     var spacing = 0;
    107.     for (var i = 0; i < this._data.length; i++) {
    108.         var precedingCharacter = (i > 0 ? this._data[i - 1] : $gamePlayer);
    109.         spacing += MechPen.Param.FollowerSpaceDistance;
    110.         this._data[i].chasePlayerAtDistance(precedingCharacter, spacing);
    111.     }
    112.     if ($gamePlayer.getLastPositions().length - 1 > spacing * (this._data[this._data.length - 1]._memberIndex + 1))
    113.     {
    114.         $gamePlayer.popLastPositions();
    115.     }
    116.     if (this.areGathering())
    117.     {
    118.         $gamePlayer.repeatLastPositions();
    119.     }
    120. };
    121. MechPen.FollowerSpace.Game_Followers_jumpAll = Game_Followers.prototype.jumpAll;
    122. Game_Followers.prototype.jumpAll = function() {
    123.     MechPen.FollowerSpace.Game_Followers_jumpAll.call(this);
    124.     $gamePlayer.clearLastPositions();
    125. };
    126. if (Utils.RPGMAKER_NAME == "MZ")
    127. {
    128. Game_Followers.prototype.synchronize = function(x, y, d) {
    129.     for (const follower of this._data) {
    130.         follower.locate(x, y);
    131.         follower.setDirection(d);
    132.     }
    133. };
    134. } else if (Utils.RPGMAKER_NAME == "MV")
    135. {
    136.    
    137. Game_Followers.prototype.synchronize = function(x, y, d) {
    138.     this.forEach(function(follower) {
    139.         follower.locate(x, y);
    140.         follower.setDirection(d);
    141.     }, this);
    142. };
    143. }
    复制代码



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


    本贴来自国际rpgmaker官方论坛作者:MechPen处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/follower-distance.120928/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 02:33 , Processed in 0.086743 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表