查看: 5431|回复: 7

[有事请教] 请问MV有8方向走的插件吗?

[复制链接]
梦石
0
星屑
22794
在线时间
2623 小时
注册时间
2015-7-4
回帖
918
发表于 2017-11-3 13:42:49 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

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

×
如题,超讨厌有直线距离不走非走个直角弯道,个人有点强迫症,网上找来找去总找不到。有的请帮忙,感谢!
梦石
10
星屑
7635
在线时间
684 小时
注册时间
2017-1-9
回帖
596

我没有哭开拓者

发表于 2017-11-3 17:10:28 | 显示全部楼层
萌新要善用搜索&优先去本区图书馆里查查
下面是大佬的插件集合的链接https://rpg.blue/thread-384599-1-1.html
这个B天天摸鱼,快点来个谁把他从被窝里拖出来
回复

使用道具 举报

梦石
0
星屑
22794
在线时间
2623 小时
注册时间
2015-7-4
回帖
918
 楼主| 发表于 2017-11-3 21:41:35 | 显示全部楼层
世界第一中二 发表于 2017-11-3 17:10
萌新要善用搜索&优先去本区图书馆里查查
下面是大佬的插件集合的链接https://rpg.blue/thread-384599-1-1.h ...

这个试过了,鼠标点击还是绕弯路啊!有没有鼠标8方向寻路的?论坛有些隐藏的搜不到啊!
回复

使用道具 举报

梦石
0
星屑
215
在线时间
252 小时
注册时间
2010-10-30
回帖
47
发表于 2017-11-5 15:06:00 | 显示全部楼层
像素移动?!
回复

使用道具 举报

梦石
0
星屑
7427
在线时间
948 小时
注册时间
2017-9-27
回帖
566
发表于 2017-11-5 17:17:22 | 显示全部楼层
我把手头收集的几个同类插件挨个试了一遍,感觉这个用起来是最舒服的。
GALV_DiagonalMovement.7z (3.35 KB, 下载次数: 127)


  1. //-----------------------------------------------------------------------------
  2. //  Galv's Diagonal Movement
  3. //-----------------------------------------------------------------------------
  4. //  For: RPGMAKER MV
  5. //  GALV_DiagonalMovement.js
  6. //-----------------------------------------------------------------------------
  7. //  2017-01-16 - Version 1.5 - added diagonal charset in the 'turn toward
  8. //                           - character' move route command
  9. //  2016-10-05 - Version 1.4 - modified how diag speed was coded for
  10. //                             compatibility purposes
  11. //  2016-08-26 - Version 1.3 - changed alias methods
  12. //                           - fixed turn direction move route after diag move
  13. //  2016-05-17 - Version 1.2 - diagonal block option added to prevent moving
  14. //                           - diagonally past blocking tiles.
  15. //                           - added ability to disable diagonal movement
  16. //                           - during game
  17. //  2016-02-04 - Version 1.1 - added option to slow diagonal move speed
  18. //  2015-12-12 - Version 1.0 - release
  19. //-----------------------------------------------------------------------------
  20. //  Terms can be found at:
  21. //  galvs-scripts.com
  22. //-----------------------------------------------------------------------------

  23. var Imported = Imported || {};
  24. Imported.Galv_DiagonalMovement = true;

  25. var Galv = Galv || {};
  26. Galv.DM = Galv.DM || {};

  27. //-----------------------------------------------------------------------------
  28. /*:
  29. * @plugindesc (v.1.5) Just a basic diagonal movement plugin. Written for compatibility with other Galv plugins.
  30. *
  31. * @author Galv - galvs-scripts.com
  32. *
  33. * @param Diagonal Mouse
  34. * @desc true or false for diagonal pathfinding movement on mouse click. true may conflict with pathfinding plugins.
  35. * @default false
  36. *
  37. * @param Diagonal Charset
  38. * @desc true or false if you want to use diagonal charactersets (see help for more)
  39. * @default true
  40. *
  41. * @param Diagonal Speed
  42. * @desc % of move speed characters move while travelling diagonally
  43. * @default 90
  44. *
  45. * @param Block Diagonal
  46. * @desc true or false - if diagonal movement is blocked when moving past an impassable tile or not.
  47. * @default false
  48. *
  49. * @help
  50. *   Galv's Diagonal Movement
  51. * ----------------------------------------------------------------------------
  52. * Plug and play. If this doesn't play nice with other plugins, try putting it
  53. * at the top of the plugin list. It overwrites the default diagonal function.
  54. *
  55. * If this conflicts with other pathfinding plugins you might have, change
  56. * 'Diagonal Mouse' setting to false.
  57. *
  58. * When 'Diagonal Charsets' is true, the plugin will change the sprite if the
  59. * character is on a diagonal. The new sprite used will be in the position
  60. * directly below the selected character graphic. This means that only sprites
  61. * on the top of a character sheet will be able to have diagonal graphics.
  62. *
  63. * Sprites on the bottom will not have diagonal graphics.
  64. * ----------------------------------------------------------------------------
  65. *   SCRIPT CALL
  66. * ----------------------------------------------------------------------------
  67. *
  68. *   $gameSystem.disableVert = true;   // DISABLE diagonal movement
  69. *
  70. *   $gameSystem.disableVert = false;  // ENABLE diagonal movement
  71. *
  72. * ----------------------------------------------------------------------------
  73. */


  74. //-----------------------------------------------------------------------------
  75. //  CODE STUFFS
  76. //-----------------------------------------------------------------------------



  77. (function() {
  78. Galv.DM.mouseMove = PluginManager.parameters('Galv_DiagonalMovement')["Diagonal Mouse"].toLowerCase() == 'true';
  79. Galv.DM.diagGraphic = PluginManager.parameters('Galv_DiagonalMovement')["Diagonal Charset"].toLowerCase() == 'true';
  80. Galv.DM.diagMod = Number(PluginManager.parameters('Galv_DiagonalMovement')["Diagonal Speed"]) * 0.01;       
  81. Galv.DM.diagBlocked = PluginManager.parameters('Galv_DiagonalMovement')["Block Diagonal"].toLowerCase() == 'true';

  82. Game_CharacterBase.prototype._cframes = 3;

  83. Galv.DM.Game_CharacterBase_realMoveSpeed = Game_CharacterBase.prototype.realMoveSpeed;
  84. Game_CharacterBase.prototype.realMoveSpeed = function() {
  85.         var spd = Galv.DM.Game_CharacterBase_realMoveSpeed.call(this);
  86.         return this._diagDir ? spd * Galv.DM.diagMod : spd;
  87. };

  88. // overwrite
  89. Game_Follower.prototype.realMoveSpeed = function() {
  90.         return $gamePlayer.realMoveSpeed();
  91. };

  92. Galv.DM.getHorzVertDirs = function(direction) {
  93.         switch (direction) {
  94.                 case 1: return [4,2];
  95.                 case 3: return [6,2];
  96.                 case 7: return [4,8];
  97.                 case 9: return [6,8];
  98.                 default: return [0,0];
  99.         };
  100. };

  101. Galv.DM.getDir = function(horz,vert) {
  102.         if (horz == 4 && vert == 2) return 1;
  103.         if (horz == 6 && vert == 2) return 3;
  104.         if (horz == 4 && vert == 8) return 7;
  105.         if (horz == 6 && vert == 8) return 9;
  106.         return 0;
  107. };

  108. Galv.DM.diagRow = {
  109.         3: 0,
  110.         1: 1,
  111.         9: 2,
  112.         7: 3
  113. };

  114. Galv.DM.Game_CharacterBase_moveStraight = Game_CharacterBase.prototype.moveStraight;
  115. Game_CharacterBase.prototype.moveStraight = function(d) {
  116.         this._diagDir = false;
  117.         Galv.DM.Game_CharacterBase_moveStraight.call(this,d);
  118. };

  119. Galv.DM.Game_CharacterBase_setDirection = Game_CharacterBase.prototype.setDirection;
  120. Game_CharacterBase.prototype.setDirection = function(d) {
  121.         if (this._diagStraigten) this._diagDir = false;
  122.         Galv.DM.Game_CharacterBase_setDirection.call(this,d);
  123. };

  124. if (Galv.DM.diagBlocked) {
  125.         Game_Player.prototype.canPassDiagonally = function(x, y, horz, vert) {
  126.                 var x2 = $gameMap.roundXWithDirection(x, horz);
  127.                 var y2 = $gameMap.roundYWithDirection(y, vert);
  128.                 if (this.canPass(x, y, vert) && this.canPass(x, y2, horz) && this.canPass(x, y, horz) && this.canPass(x2, y, vert)) {
  129.                         return true;
  130.                 };
  131.                 return false;
  132.         };
  133. };

  134. Galv.DM.Game_Player_canPassDiagonally = Game_Player.prototype.canPassDiagonally;
  135. Game_Player.prototype.canPassDiagonally = function(x, y, horz, vert) {
  136.         if ($gameSystem.disableVert) return false;
  137.         return Galv.DM.Game_Player_canPassDiagonally.call(this,x,y,horz,vert);
  138. };

  139. // OVERWRITE
  140. Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
  141.         var diag = this.canPassDiagonally(this._x, this._y, horz, vert);
  142.     var norm = this.canPass(this._x, this._y, horz) || this.canPass(this._x, this._y, vert);
  143.        
  144.         if (diag) {
  145.                 this._diagDir = Galv.DM.getDir(horz,vert);
  146.         this._x = $gameMap.roundXWithDirection(this._x, horz);
  147.         this._y = $gameMap.roundYWithDirection(this._y, vert);
  148.         this._realX = $gameMap.xWithDirection(this._x, this.reverseDir(horz));
  149.         this._realY = $gameMap.yWithDirection(this._y, this.reverseDir(vert));
  150.         this.increaseSteps();
  151.         } else if (norm) {
  152.                 this._diagDir = false;
  153.                 this.moveStraight(this.getOtherdir(horz,vert));
  154.     };
  155.        
  156.         this._diagStraigten = false;
  157.     if (this._direction === this.reverseDir(horz)) this.setDirection(horz);
  158.     if (this._direction === this.reverseDir(vert)) this.setDirection(vert);
  159.         this._diagStraigten = true;
  160. };

  161. Game_CharacterBase.prototype.getOtherdir = function(horz, vert) {
  162.     return this.canPass(this._x, this._y, horz) ? horz : vert;
  163. };

  164. // OVERWRITE
  165. Game_Player.prototype.getInputDirection = function() {
  166.     return Input.dir8;
  167. };

  168. Galv.DM.Game_Player_executeMove = Game_Player.prototype.executeMove;
  169. Game_Player.prototype.executeMove = function(direction) {
  170.         if (direction % 2 == 0) {
  171.             Galv.DM.Game_Player_executeMove.call(this,direction);
  172.         } else if (Math.abs(direction % 2) == 1) {
  173.                 var dirArray = Galv.DM.getHorzVertDirs(direction);
  174.                 this.moveDiagonally(dirArray[0],dirArray[1]);
  175.         };
  176. };



  177. // If using Diaonal Charset
  178. if (Galv.DM.diagGraphic) {
  179. Galv.DM.Sprite_Character_characterPatternY = Sprite_Character.prototype.characterPatternY;
  180. Sprite_Character.prototype.characterPatternY = function() {
  181.         if (!this._isBigCharacter && this._character._diagDir && this._character.characterIndex() < 4) {
  182.                 return Galv.DM.diagRow[this._character._diagDir];
  183.         } else {
  184.             return Galv.DM.Sprite_Character_characterPatternY.call(this);
  185.         };
  186. };

  187. Galv.DM.Sprite_Character_characterBlockX = Sprite_Character.prototype.characterBlockX;
  188. Sprite_Character.prototype.characterBlockX = function() {
  189.         if (!this._isBigCharacter && this._character._diagDir && this._character.characterIndex() < 4) {
  190.                 var index = this._character.characterIndex() + 4;
  191.         return index % 4 * this._character._cframes;
  192.         } else {       
  193.             return Galv.DM.Sprite_Character_characterBlockX.call(this);
  194.         };

  195. };

  196. Galv.DM.Sprite_Character_characterBlockY = Sprite_Character.prototype.characterBlockY;
  197. Sprite_Character.prototype.characterBlockY = function() {
  198.         if (!this._isBigCharacter && this._character._diagDir && this._character.characterIndex() < 4) {
  199.                 var index = this._character.characterIndex() + 4;
  200.         return Math.floor(index / 4) * 4;
  201.         } else {       
  202.             return Galv.DM.Sprite_Character_characterBlockY.call(this);
  203.         };

  204. };
  205. };
  206. // end if using diagonal charset


  207. // turn toward character on diagonal
  208. // OVERWRITE
  209. Game_Character.prototype.turnTowardCharacter = function(character) {
  210.     var sx = this.deltaXFrom(character.x);
  211.     var sy = this.deltaYFrom(character.y);
  212.        
  213.         var absSx = Math.abs(sx);
  214.         var absSy = Math.abs(sy);

  215.         if (absSx == absSy) {
  216.                 if (sx < 0) {
  217.                         this._diagDir = sy > 0 ? 9 : 3;
  218.                 } else if (sx > 0) {
  219.                         this._diagDir = sy > 0 ? 7 : 1;
  220.                 }
  221.         } else {
  222.                 this._diagDir = 0;
  223.         };
  224.         if (absSx > absSy) {
  225.                this.setDirection(sx > 0 ? 4 : 6);
  226.     } else if (sy !== 0) {
  227.         this.setDirection(sy > 0 ? 8 : 2);
  228.     }
  229. };






  230. // If using diagonal mouse movement:

  231. if (Galv.DM.mouseMove) {
  232. Galv.DM.Game_Character_findDirectionTo = Game_Character.prototype.findDirectionTo;
  233. // OVERWRITE
  234. Game_Character.prototype.findDirectionTo = function(goalX, goalY) {
  235.         if ($gameSystem.disableVert) {
  236.                 return Galv.DM.Game_Character_findDirectionTo.call(this,goalX,goalY);
  237.         } else {
  238.                 var searchLimit = this.searchLimit();
  239.                 var mapWidth = $gameMap.width();
  240.                 var nodeList = [];
  241.                 var openList = [];
  242.                 var closedList = [];
  243.                 var start = {};
  244.                 var best = start;
  245.        
  246.                 if (this.x === goalX && this.y === goalY) {
  247.                         return 0;
  248.                 }
  249.        
  250.                 start.parent = null;
  251.                 start.x = this.x;
  252.                 start.y = this.y;
  253.                 start.g = 0;
  254.                 start.f = $gameMap.distance(start.x, start.y, goalX, goalY);
  255.                 nodeList.push(start);
  256.                 openList.push(start.y * mapWidth + start.x);
  257.        
  258.                 while (nodeList.length > 0) {
  259.                         var bestIndex = 0;
  260.                         for (var i = 0; i < nodeList.length; i++) {
  261.                                 if (nodeList[i].f < nodeList[bestIndex].f) {
  262.                                         bestIndex = i;
  263.                                 }
  264.                         }
  265.        
  266.                         var current = nodeList[bestIndex];
  267.                         var x1 = current.x;
  268.                         var y1 = current.y;
  269.                         var pos1 = y1 * mapWidth + x1;
  270.                         var g1 = current.g;
  271.        
  272.                         nodeList.splice(bestIndex, 1);
  273.                         openList.splice(openList.indexOf(pos1), 1);
  274.                         closedList.push(pos1);
  275.        
  276.                         if (current.x === goalX && current.y === goalY) {
  277.                                 best = current;
  278.                                 goaled = true;
  279.                                 break;
  280.                         }
  281.        
  282.                         if (g1 >= searchLimit) {
  283.                                 continue;
  284.                         }
  285.        
  286.        
  287.                         for (var j = 0; j < 9; j++) {
  288.                                 var direction = 1 + j;
  289.                                
  290.                                 if (direction === 5) continue;
  291.                                
  292.                                 var diag = Math.abs(direction % 2) == 1;
  293.                                 var dirs = Galv.DM.getHorzVertDirs(direction);
  294.                                 var horz = dirs[0];
  295.                                 var vert = dirs[1];
  296.                                
  297.                                 if (diag && this.canPassDiagonally(x1, y1, horz, vert) && (this.canPass(x1, y1, horz) || this.canPass(x1, y1, vert))) {
  298.                                         // If can go diagonally and a horizontal dir isn't blocking
  299.                                         var x2 = $gameMap.roundXWithDirection(x1, horz);
  300.                                         var y2 = $gameMap.roundYWithDirection(y1, vert);
  301.                                 } else if (this.canPass(x1, y1, direction)) {
  302.                                         var x2 = $gameMap.roundXWithDirection(x1, direction);
  303.                                         var y2 = $gameMap.roundYWithDirection(y1, direction);
  304.                                 } else {
  305.                                         continue;
  306.                                 };
  307.        
  308.                                 var pos2 = y2 * mapWidth + x2;
  309.        
  310.                                 if (closedList.contains(pos2)) {
  311.                                         continue;
  312.                                 }
  313.        
  314.                                 var g2 = g1 + 1;
  315.                                 var index2 = openList.indexOf(pos2);
  316.        
  317.                                 if (index2 < 0 || g2 < nodeList[index2].g) {
  318.                                         var neighbor;
  319.                                         if (index2 >= 0) {
  320.                                                 neighbor = nodeList[index2];
  321.                                         } else {
  322.                                                 neighbor = {};
  323.                                                 nodeList.push(neighbor);
  324.                                                 openList.push(pos2);
  325.                                         }
  326.                                         neighbor.parent = current;
  327.                                         neighbor.x = x2;
  328.                                         neighbor.y = y2;
  329.                                         neighbor.g = g2;
  330.                                         neighbor.f = g2 + $gameMap.distance(x2, y2, goalX, goalY);
  331.                                         if (!best || neighbor.f - neighbor.g < best.f - best.g) {
  332.                                                 best = neighbor;
  333.                                         }
  334.                                 }
  335.                         }
  336.                 }
  337.        
  338.                 var node = best;
  339.                 while (node.parent && node.parent !== start) {
  340.                         node = node.parent;
  341.                 }
  342.        
  343.                 var deltaX1 = $gameMap.deltaX(node.x, start.x);
  344.                 var deltaY1 = $gameMap.deltaY(node.y, start.y);
  345.                
  346.                
  347.                 if (deltaY1 > 0 && deltaX1 > 0) {
  348.                         return 3;
  349.                 } else if (deltaY1 > 0 && deltaX1 < 0) {
  350.                         return 1;
  351.                 } else if (deltaY1 < 0 && deltaX1 < 0) {
  352.                         return 7;
  353.                 } else if (deltaY1 < 0 && deltaX1 > 0) {
  354.                         return 9;
  355.                 };
  356.                
  357.                
  358.                 if (deltaY1 > 0) {
  359.                         return 2;
  360.                 } else if (deltaX1 < 0) {
  361.                         return 4;
  362.                 } else if (deltaX1 > 0) {
  363.                         return 6;
  364.                 } else if (deltaY1 < 0) {
  365.                         return 8;
  366.                 }
  367.        
  368.                 var deltaX2 = this.deltaXFrom(goalX);
  369.                 var deltaY2 = this.deltaYFrom(goalY);
  370.                
  371.                
  372.                 if (Math.abs(deltaX2) > Math.abs(deltaY2)) {
  373.                         return deltaX2 > 0 ? 4 : 6;
  374.                 } else if (deltaY2 !== 0) {
  375.                         return deltaY2 > 0 ? 8 : 2;
  376.                 }
  377.        
  378.                 return 0;
  379.         };
  380. };
  381. };

  382. })();
复制代码

回复

使用道具 举报

梦石
0
星屑
22794
在线时间
2623 小时
注册时间
2015-7-4
回帖
918
 楼主| 发表于 2017-11-20 11:12:39 | 显示全部楼层
梦想家大魔王 发表于 2017-11-5 17:17
我把手头收集的几个同类插件挨个试了一遍,感觉这个用起来是最舒服的。

哎呀!插件好是好,但是跟Alpha ABS有冲突呀,求个兼容版。通通拜谢!
回复

使用道具 举报

梦石
0
星屑
16296
在线时间
4017 小时
注册时间
2015-9-14
回帖
1322

开拓者

发表于 2017-11-20 16:03:30 | 显示全部楼层
最好用.有開關4方/8方通行插件.
Yami_8DirEx.js Yami_8DirEx.zip (2.72 KB, 下载次数: 157)
https://rpg.blue/data/attachment/album/202003/28/021323lltgrsvfytfwuya5.gif
回复 1 0

使用道具 举报

梦石
0
星屑
22794
在线时间
2623 小时
注册时间
2015-7-4
回帖
918
 楼主| 发表于 2017-11-20 21:45:38 | 显示全部楼层
wabcmcc 发表于 2017-11-20 16:03
最好用.有開關4方/8方通行插件.
Yami_8DirEx.js

谢谢!又一个作者,又多了冲突的可能,前面那个我已经解决兼容性问题了,这个留以后研究。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部