累计送礼: 0 个 累计收礼: 1 个 TA的每日心情 开心 2026-7-12 04:10
签到天数: 209 天
连续签到: 2 天
[LV.7]常住居民III
管理员
VIP
7
卡币
25563
OK点
16
推广点
0
同能卷
50
积分 32235
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:
// ============================================================================ // Pushy Map Events by Akumu Games // ============================================================================ // For: RPGMAKER MV // AG_PushyMapEvents.js // Version: 1.4.3 // Free to use for commercial and non commercial projects as long as proper credit is given. // ============================================================================ /*: * @plugindesc Marked events will attempt to move characters whenever they bump into each other in the map. * * @author Akumu Games * ============================================================================ * @param Behavior * @desc The type of pushy behavior: "push" or "makeway". * @default push * @param Disable Pushable Player Switch ID * @desc When this switch is turned ON, the player becomes unpushable. * @default 0 * @param Disable Pushable Events Switch ID * @desc When this switch is turned ON, all events on the map become unpushable. * @default 0 * ============================================================================ * @help * ============================================================================ * Intructions * ============================================================================ * * A map event can have assigned different actions to them: * Pushy -> Will apply the given behaviour to Pushable events and player. * Pushable -> Will react to Pushy events. * NPC -> Will check for map passability, even when its Through flag is ON. * To attach them, you need to tag the event by simply including the string/s * "<Pushy>" or "<Pushable>" or <"NPC"> somewhere in its note input field. * Keep in mind: * - Events can be both, Pushy and Pushable, at the same time. * - The player can be considered Pushable only (no tag). * - Pushable events cannot walk into a Pushy event location. * You can always turn ON the designated switches to disable these actions at any * time, if you require. Naturally, turning them OFF will resume their actions. * * Designed to work with same priority events with through flag ON so that they * won't overlap with the player sprite when possible, but it may have other * utilities. I'll leave that up to you :) Feel free to make any changes. * * ============================================================================ * Plugin Commands * ============================================================================ * * You can use the following plugin command to change the pushy behavior ingame: * SetPushyBehaviorTo <behavior> * Where <behavior> corresponds to either: * push -> Events will push the player until they hit a wall (default). * makeway -> Events will attempt to move the player out of their way. * * examples: SetPushyBehaviorTo push * SetPushyBehaviorTo makeway * * ============================================================================ */ //============================================================================= // Parameter Variables //============================================================================= (function() { var parameters = PluginManager.parameters('AG_PushyMapEvents'); var _pushyBehavior = String(parameters['Behavior'] || 'push'); var _disablePushablePlayerSwitch = Number(parameters['Disable Pushable Player Switch ID'] || 0); var _disablePushableEventsSwitch = Number(parameters['Disable Pushable Events Switch ID'] || 0); function isPushablePlayerDisabled(){ return $gameSwitches.value(_disablePushablePlayerSwitch); } function isPushableEventsDisabled(){ return $gameSwitches.value(_disablePushableEventsSwitch); } //============================================================================= // Game_Interpreter //============================================================================= var Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; Game_Interpreter.prototype.pluginCommand = function(command, args) { Game_Interpreter_pluginCommand.call(this, command, args) if (command === 'SetPushyBehaviorTo'){ if (args[0] === 'push'){ _pushyBehavior = 'push'; }else if(args[0] === 'makeway'){ _pushyBehavior = 'makeway'; } } }; //============================================================================= // Game_CharacterBase //============================================================================= Game_CharacterBase.prototype.isCollidedWithPushyEvents = function(x, y){ var events = $gameMap.eventsXy(x, y); return events.some(function(event) { return event.isPushy() || event.isBlock(); }); }; Game_CharacterBase.prototype.pushableEvents = function(x, y){ var events = $gameMap.eventsXy(x, y); return events.filter(function(event) { return event.isPushable(); }); }; Game_CharacterBase.prototype.directionLeft90 = function(dir) { switch (dir) { case 2: return 6; case 4: return 2; case 6: return 8; case 8: return 4; } }; var pushyMapEvents_Game_CharacterBase_canPass = Game_CharacterBase.prototype.canPass; Game_CharacterBase.prototype.canPass = function(x, y, d) { return this.isPushyPassable(x, y, d) && this.isNPCPassable(x, y, d) && pushyMapEvents_Game_CharacterBase_canPass.call(this, x, y, d); }; Game_CharacterBase.prototype.isPushyPassable = function(x, y, d) { if(!this.isPushableCharacterDisabled() && this.isPushable() && !this.isDebugThrough()){ var x2 = $gameMap.roundXWithDirection(x, d); var y2 = $gameMap.roundYWithDirection(y, d); return !this.isCollidedWithPushyEvents(x2, y2); } return true; }; Game_CharacterBase.prototype.isNPCPassable = function(x, y, d) { if(!isPushableEventsDisabled() && this.isNPC() && !this.isDebugThrough()){ return this.isMapPassable(x, y, d); } return true; }; Game_CharacterBase.prototype.isPushableCharacterDisabled = function() { return true; }; Game_CharacterBase.prototype.isPushable = function() { return false; }; Game_CharacterBase.prototype.isNPC = function() { return false; }; //============================================================================= // Game_Player //============================================================================= Game_Player.prototype.isPushableCharacterDisabled = function() { return isPushablePlayerDisabled(); }; Game_Player.prototype.isPushable = function() { return !isPushablePlayerDisabled(); }; //============================================================================= // Game_Event //============================================================================= var pushyMapEvents_Game_Event_update = Game_Event.prototype.update; Game_Event.prototype.update = function() { if(this.isPushy()){ if(!isPushableEventsDisabled()){ this.pushableEvents(this.x,this.y).forEach(function(event) { if(event._eventId != this._eventId) this.pushCharacter(event); },this); } if(!isPushablePlayerDisabled()){ this.pushCharacter($gamePlayer); } } pushyMapEvents_Game_Event_update.call(this); }; Game_Event.prototype.pushPlayer = function() { this.PushCharacter($gamePlayer); }; Game_Event.prototype.pushCharacter = function(character) { if(character.pos(this.x,this.y) && !character.isMoving()){ var new_direction; if(_pushyBehavior == 'makeway'){ new_direction = this.directionLeft90(this.direction()); if(!character.canPass(character.x,character.y,new_direction)){ new_direction = this.reverseDir(new_direction); if(!character.canPass(character.x,character.y,new_direction)){ new_direction = this.reverseDir(this.direction()); if(!character.canPass(character.x,character.y,new_direction)) new_direction = this.direction(); } } }else{ new_direction = this.direction(); if(!character.canPass(character.x,character.y,new_direction)){ new_direction = this.directionLeft90(this.direction()); if(!character.canPass(character.x,character.y,new_direction)){ new_direction = this.reverseDir(new_direction); if(!character.canPass(character.x,character.y,new_direction)) new_direction = this.reverseDir(this.direction()); } } } if(!character.isDirectionFixed()){ character.setDirection(this.reverseDir(new_direction)); character.moveBackward(); }else{ character.moveStraight(new_direction); } } }; Game_Event.prototype.isPushableCharacterDisabled = function() { return isPushableEventsDisabled(); }; Game_Event.prototype.isPushy = function() { return this.event().note.indexOf('<Pushy>') != -1; }; Game_Event.prototype.isBlock = function() { return this.event().note.indexOf('<Block>') != -1; }; Game_Event.prototype.isPushable = function() { return this.event().note.indexOf('<Pushable>') != -1 && !isPushableEventsDisabled(); }; Game_Event.prototype.isNPC = function() { return this.event().note.indexOf('<NPC>') != -1; }; })(); 复制代码
(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