Plugin MV


SUBMITTED BY: Guest

DATE: April 9, 2021, 1:57 a.m.

FORMAT: JavaScript

SIZE: 2.0 kB

HITS: 532

  1. /*:
  2. * @author Fabio Smuu
  3. * @plugindesc Bloquear passagem por evento.
  4. *
  5. * @help
  6. * User o comando "Plugin Command" da aba 3 em Advanced.
  7. * Escreva: Barreira x,y x,y x,y
  8. *
  9. * Exemplo:
  10. * Se o evento estiver em 8, 9
  11. * Ao usar Barreira -1,-3 0,-1 1,-5
  12. * O evento bloquearar as posições: 7,6 8,8 e 9,4
  13. */
  14. (function() {
  15. const _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand
  16. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  17. _Game_Interpreter_pluginCommand.call(this, command, args)
  18. if (command === 'Barreira') {
  19. args.map(arg => {
  20. let [x, y] = arg.split(',')
  21. console.log(x, y)
  22. })
  23. }
  24. }
  25. function getEventCommands(eventId) {
  26. let barreiras = []
  27. $gameMap.events().filter(event => event.list().find(list => {
  28. if (list.code === 356) {
  29. let args = list.parameters[0].split(' ')
  30. if (args.shift() === 'Barreira') {
  31. let a = args.map(arg => [
  32. event.x + parseInt(arg.split(',')[0]),
  33. event.y + parseInt(arg.split(',')[1])
  34. ])
  35. barreiras.push(a)
  36. }
  37. }
  38. }))
  39. return barreiras
  40. .reduce((a,b) => a.concat(b), [])
  41. .reduce((a, b) => a.includes(b) ? a : [...a, b], [])
  42. //let cmd = $gameMap.eventsXy(6, 8)[0].list().find(e => e.code === 356)
  43. //console.log(cmd)
  44. }
  45. Game_Event.prototype.canPass = function(x, y, d) {
  46. let x2 = $gameMap.roundXWithDirection(x, d)
  47. let y2 = $gameMap.roundYWithDirection(y, d)
  48. let barreiras = getEventCommands(this.eventId())
  49. let parar = barreiras.some(b => b[0] === x2 && b[1] === y2)
  50. if(parar) return false
  51. /*let id = $gameMap.eventIdXy(x2, y2) || -1
  52. if (id != -1 && this.eventId() != $gameMap.eventIdXy(x2, y2)) {
  53. return false
  54. }*/
  55. return (
  56. !$gameMap.isValid(x2, y2)
  57. || this.isThrough()
  58. || this.isDebugThrough()
  59. || !this.isMapPassable(x, y, d)
  60. || this.isCollidedWithCharacters(x2, y2)
  61. ) ? false : true
  62. }
  63. })();

comments powered by Disqus