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

[转载发布] [AG] Pushy Map Events

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

    连续签到: 2 天

    [LV.7]常住居民III

    5778

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 昨天 15:36 | 显示全部楼层 |阅读模式
    Pushy Map Events
    by Akumu Games (me)

    Description:
    This plugin makes marked events attempt to move characters whenever they bump into each other in the map. You can assign different actions and behaviors, as well as disable them at any time.
    Instructions about how to use it are explained in more detail inside.

    Plugin:
    Spoiler                Code:       
    1. // ============================================================================
    2. // Pushy Map Events by Akumu Games
    3. // ============================================================================
    4. // For: RPGMAKER MV
    5. // AG_PushyMapEvents.js
    6. // Version: 1.4.3
    7. // Free to use for commercial and non commercial projects as long as proper credit is given.
    8. // ============================================================================
    9. /*:
    10. * @plugindesc Marked events will attempt to move characters whenever they bump into each other in the map.
    11. *
    12. * @author Akumu Games
    13. * ============================================================================
    14. * @param Behavior
    15. * @desc The type of pushy behavior: "push" or "makeway".
    16. * @default push
    17. * @param Disable Pushable Player Switch ID
    18. * @desc When this switch is turned ON, the player becomes unpushable.
    19. * @default 0
    20. * @param Disable Pushable Events Switch ID
    21. * @desc When this switch is turned ON, all events on the map become unpushable.
    22. * @default 0
    23. * ============================================================================
    24. * @help
    25. * ============================================================================
    26. * Intructions
    27. * ============================================================================
    28. *
    29. * A map event can have assigned different actions to them:
    30. *      Pushy    -> Will apply the given behaviour to Pushable events and player.
    31. *      Pushable -> Will react to Pushy events.
    32. *      NPC      -> Will check for map passability, even when its Through flag is ON.
    33. * To attach them, you need to tag the event by simply including the string/s
    34. * "<Pushy>" or "<Pushable>" or <"NPC"> somewhere in its note input field.
    35. * Keep in mind:
    36. *      - Events can be both, Pushy and Pushable, at the same time.
    37. *      - The player can be considered Pushable only (no tag).
    38. *      - Pushable events cannot walk into a Pushy event location.
    39. * You can always turn ON the designated switches to disable these actions at any
    40. * time, if you require. Naturally, turning them OFF will resume their actions.
    41. *
    42. * Designed to work with same priority events with through flag ON so that they
    43. * won't overlap with the player sprite when possible, but it may have other
    44. * utilities. I'll leave that up to you :) Feel free to make any changes.
    45. *
    46. * ============================================================================
    47. * Plugin Commands
    48. * ============================================================================
    49. *
    50. * You can use the following plugin command to change the pushy behavior ingame:
    51. *      SetPushyBehaviorTo <behavior>
    52. * Where <behavior> corresponds to either:
    53. *      push    -> Events will push the player until they hit a wall (default).
    54. *      makeway -> Events will attempt to move the player out of their way.
    55. *
    56. *    examples: SetPushyBehaviorTo push
    57. *              SetPushyBehaviorTo makeway
    58. *
    59. * ============================================================================
    60. */
    61. //=============================================================================
    62. // Parameter Variables
    63. //=============================================================================
    64. (function() {
    65.    var parameters = PluginManager.parameters('AG_PushyMapEvents');
    66.    var _pushyBehavior = String(parameters['Behavior'] || 'push');
    67.    var _disablePushablePlayerSwitch = Number(parameters['Disable Pushable Player Switch ID'] || 0);
    68.    var _disablePushableEventsSwitch = Number(parameters['Disable Pushable Events Switch ID'] || 0);
    69.    function isPushablePlayerDisabled(){
    70.        return $gameSwitches.value(_disablePushablePlayerSwitch);
    71.    }
    72.    function isPushableEventsDisabled(){
    73.        return $gameSwitches.value(_disablePushableEventsSwitch);
    74.    }
    75. //=============================================================================
    76. // Game_Interpreter
    77. //=============================================================================
    78.    var Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    79.    Game_Interpreter.prototype.pluginCommand = function(command, args) {
    80.        Game_Interpreter_pluginCommand.call(this, command, args)
    81.        if (command === 'SetPushyBehaviorTo'){
    82.            if (args[0] === 'push'){
    83.                _pushyBehavior = 'push';
    84.            }else if(args[0] === 'makeway'){
    85.                _pushyBehavior = 'makeway';
    86.            }
    87.        }
    88.    };
    89. //=============================================================================
    90. // Game_CharacterBase
    91. //=============================================================================
    92.    Game_CharacterBase.prototype.isCollidedWithPushyEvents = function(x, y){
    93.        var events = $gameMap.eventsXy(x, y);
    94.        return events.some(function(event) {
    95.            return event.isPushy() || event.isBlock();
    96.        });
    97.    };
    98.    Game_CharacterBase.prototype.pushableEvents = function(x, y){
    99.        var events = $gameMap.eventsXy(x, y);
    100.        return events.filter(function(event) {
    101.            return event.isPushable();
    102.        });
    103.    };
    104.    Game_CharacterBase.prototype.directionLeft90 = function(dir) {
    105.        switch (dir) {
    106.        case 2:
    107.            return 6;
    108.        case 4:
    109.            return 2;
    110.        case 6:
    111.            return 8;
    112.        case 8:
    113.            return 4;
    114.        }
    115.    };
    116.    var pushyMapEvents_Game_CharacterBase_canPass = Game_CharacterBase.prototype.canPass;
    117.    Game_CharacterBase.prototype.canPass = function(x, y, d) {
    118.        return this.isPushyPassable(x, y, d) && this.isNPCPassable(x, y, d) && pushyMapEvents_Game_CharacterBase_canPass.call(this, x, y, d);
    119.    };
    120.    Game_CharacterBase.prototype.isPushyPassable = function(x, y, d) {
    121.        if(!this.isPushableCharacterDisabled() && this.isPushable() && !this.isDebugThrough()){
    122.            var x2 = $gameMap.roundXWithDirection(x, d);
    123.            var y2 = $gameMap.roundYWithDirection(y, d);
    124.            return !this.isCollidedWithPushyEvents(x2, y2);
    125.        }
    126.        return true;
    127.    };
    128.    Game_CharacterBase.prototype.isNPCPassable = function(x, y, d) {
    129.        if(!isPushableEventsDisabled() && this.isNPC() && !this.isDebugThrough()){
    130.            return this.isMapPassable(x, y, d);
    131.        }
    132.        return true;
    133.    };
    134.    Game_CharacterBase.prototype.isPushableCharacterDisabled = function() {
    135.        return true;
    136.    };
    137.    Game_CharacterBase.prototype.isPushable = function() {
    138.        return false;
    139.    };
    140.    Game_CharacterBase.prototype.isNPC = function() {
    141.        return false;
    142.    };
    143. //=============================================================================
    144. // Game_Player
    145. //=============================================================================
    146.    Game_Player.prototype.isPushableCharacterDisabled = function() {
    147.        return isPushablePlayerDisabled();
    148.    };
    149.    Game_Player.prototype.isPushable = function() {
    150.        return !isPushablePlayerDisabled();
    151.    };
    152. //=============================================================================
    153. // Game_Event
    154. //=============================================================================
    155.    var pushyMapEvents_Game_Event_update = Game_Event.prototype.update;
    156.    Game_Event.prototype.update = function() {
    157.        if(this.isPushy()){
    158.            if(!isPushableEventsDisabled()){
    159.                this.pushableEvents(this.x,this.y).forEach(function(event) {
    160.                    if(event._eventId != this._eventId) this.pushCharacter(event);
    161.                },this);
    162.            }
    163.            if(!isPushablePlayerDisabled()){
    164.                this.pushCharacter($gamePlayer);
    165.            }
    166.        }
    167.        pushyMapEvents_Game_Event_update.call(this);
    168.    };
    169.    Game_Event.prototype.pushPlayer = function() {
    170.        this.PushCharacter($gamePlayer);
    171.    };
    172.    Game_Event.prototype.pushCharacter = function(character) {
    173.        if(character.pos(this.x,this.y) && !character.isMoving()){
    174.            var new_direction;
    175.            if(_pushyBehavior == 'makeway'){
    176.                new_direction = this.directionLeft90(this.direction());
    177.                if(!character.canPass(character.x,character.y,new_direction)){
    178.                    new_direction = this.reverseDir(new_direction);
    179.                    if(!character.canPass(character.x,character.y,new_direction)){
    180.                        new_direction = this.reverseDir(this.direction());
    181.                        if(!character.canPass(character.x,character.y,new_direction))
    182.                            new_direction = this.direction();
    183.                    }
    184.                }
    185.            }else{
    186.                new_direction = this.direction();
    187.                if(!character.canPass(character.x,character.y,new_direction)){
    188.                    new_direction = this.directionLeft90(this.direction());
    189.                    if(!character.canPass(character.x,character.y,new_direction)){
    190.                        new_direction = this.reverseDir(new_direction);
    191.                        if(!character.canPass(character.x,character.y,new_direction))
    192.                            new_direction = this.reverseDir(this.direction());
    193.                    }
    194.                }
    195.            }
    196.            if(!character.isDirectionFixed()){
    197.                character.setDirection(this.reverseDir(new_direction));
    198.                character.moveBackward();
    199.            }else{
    200.                character.moveStraight(new_direction);
    201.            }
    202.        }
    203.    };
    204.    Game_Event.prototype.isPushableCharacterDisabled = function() {
    205.        return isPushableEventsDisabled();
    206.    };
    207.    Game_Event.prototype.isPushy = function() {
    208.        return this.event().note.indexOf('<Pushy>') != -1;
    209.    };
    210.    Game_Event.prototype.isBlock = function() {
    211.        return this.event().note.indexOf('<Block>') != -1;
    212.    };
    213.    Game_Event.prototype.isPushable = function() {
    214.        return this.event().note.indexOf('<Pushable>') != -1 && !isPushableEventsDisabled();
    215.    };
    216.    Game_Event.prototype.isNPC = function() {
    217.        return this.event().note.indexOf('<NPC>') != -1;
    218.    };
    219. })();
    复制代码





    (save as "AG_PushyMapEvents.js" in your plugins folder)

    Credits:
    Author: Akumu Games

    Notes:
    This is my first plugin ever released xD It's rather simple, but I'm proud on how it turned out. It gives a nice little touch to how characters move in the map. I hope it's of use



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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-26 03:55 , Processed in 0.112477 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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