/*: * @author Fabio Smuu * @plugindesc Bloquear passagem por evento. * * @help * User o comando "Plugin Command" da aba 3 em Advanced. * Escreva: Barreira x,y x,y x,y * * Exemplo: * Se o evento estiver em 8, 9 * Ao usar Barreira -1,-3 0,-1 1,-5 * O evento bloquearar as posições: 7,6 8,8 e 9,4 */ (function() { const _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand Game_Interpreter.prototype.pluginCommand = function(command, args) { _Game_Interpreter_pluginCommand.call(this, command, args) if (command === 'Barreira') { args.map(arg => { let [x, y] = arg.split(',') console.log(x, y) }) } } function getEventCommands(eventId) { let barreiras = [] $gameMap.events().filter(event => event.list().find(list => { if (list.code === 356) { let args = list.parameters[0].split(' ') if (args.shift() === 'Barreira') { let a = args.map(arg => [ event.x + parseInt(arg.split(',')[0]), event.y + parseInt(arg.split(',')[1]) ]) barreiras.push(a) } } })) return barreiras .reduce((a,b) => a.concat(b), []) .reduce((a, b) => a.includes(b) ? a : [...a, b], []) //let cmd = $gameMap.eventsXy(6, 8)[0].list().find(e => e.code === 356) //console.log(cmd) } Game_Event.prototype.canPass = function(x, y, d) { let x2 = $gameMap.roundXWithDirection(x, d) let y2 = $gameMap.roundYWithDirection(y, d) let barreiras = getEventCommands(this.eventId()) let parar = barreiras.some(b => b[0] === x2 && b[1] === y2) if(parar) return false /*let id = $gameMap.eventIdXy(x2, y2) || -1 if (id != -1 && this.eventId() != $gameMap.eventIdXy(x2, y2)) { return false }*/ return ( !$gameMap.isValid(x2, y2) || this.isThrough() || this.isDebugThrough() || !this.isMapPassable(x, y, d) || this.isCollidedWithCharacters(x2, y2) ) ? false : true } })();