查看: 5728|回复: 4

[有事请教] 求教事件移动脚本

[复制链接]
梦石
0
星屑
178
在线时间
21 小时
注册时间
2018-4-16
回帖
4
发表于 2018-4-20 09:06:32 | 显示全部楼层 |阅读模式

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

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

×
事件的设置移动路线功能没有指定坐标有点麻烦
设置了一个并列执行NPC在不停的来回走动,想在触发开关后去到指定位置
由于触发开关的时间不一定,触发时NPC所在位置不一定,而想让它走到指定位置用设置移动路线的话
目前能想到的只能用循环嵌套判断事件坐标X,Y后再做设置移动路线一步步边走边判断
搜了一下帖子貌似XP可以在设置移动路线里用脚本self.x=x  self.y=y直接实现走到指定位置
MV的脚本是用什么参数呢,还是只能用循环判断的方法?
梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2018-4-20 09:11:13 | 显示全部楼层
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2018-4-20 09:19:44 | 显示全部楼层
本帖最后由 tseyik 于 2018-4-20 09:22 编辑

http://woodpenguin.web.fc2.com/MV_Plugin/MoveRouteEX.html
MoveRouteEX.jpg
◆[プラグインコマンド]にて以下のコマンドを使用することで、指定したキャラクターの移動ルートが終了するまでウェイトをかけます。
WaitRoute id         イベントid番の移動ルートが終了するまでウェイト
-1:プレイヤー、0:このイベント

◆[移動ルートの設定]の[スクリプト]にて、以下のコマンドが使用できます。
movePos(x, y)
movePos(x, y, skip)         座標(x,y)に向かって移動
詳細はプラグインのヘルプ参照
x = n         X座標 n まで移動します。
x += n         現在のX座標から n マス右に移動します。
x -= n         現在のX座標から n マス左に移動します。
y = n         Y座標 n まで移動します。
y += n         現在のY座標から n マス下に移動します。
y -= n         現在のY座標から n マス上に移動します。
roundX         X座標の値を四捨五入して、最も近い整数にします。
roundY         Y座標の値を四捨五入して、最も近い整数にします。

需科學上網
MPP_MoveRouteEX.js
  1. //=============================================================================
  2. // MPP_MoveRouteEX.js
  3. //=============================================================================
  4. // Copyright (c) 2016 Mokusei Penguin
  5. // Released under the MIT license
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. //=============================================================================

  8. /*:
  9. * @plugindesc 【ver.1.0】移動ルートに関するコマンド詰め合わせ。
  10. * @author 木星ペンギン
  11. *
  12. * @help プラグインコマンド:
  13. *   WaitRoute n           # イベントID n 番の移動が完了するまでウェイト
  14. *                         # -1:プレイヤー, 0:このイベント
  15. *
  16. * 移動ルートのスクリプト:
  17. *   movePos(x, y)         # 座標(x, y)に向かって移動します。
  18. *   movePos(x, y, skip)
  19. *   x = n                 # X座標 n まで移動します。
  20. *   x += n                # 現在のX座標から n マス右に移動します。
  21. *   x -= n                # 現在のX座標から n マス左に移動します。
  22. *   y = n                 # Y座標 n まで移動します。
  23. *   y += n                # 現在のY座標から n マス下に移動します。
  24. *   y -= n                # 現在のY座標から n マス上に移動します。
  25. *   roundX                # X座標の値を四捨五入して、最も近い整数にします。
  26. *   roundY                # Y座標の値を四捨五入して、最も近い整数にします。
  27. *
  28. *
  29. * ●movePosの詳細
  30. *  ・skip で true を設定した場合、移動できなかった時点で移動を中断します。
  31. *  
  32. *  ・[移動ルートの設定]のオプションにある[移動できない場合は飛ばす]には
  33. *    チェックを入れないでください。
  34. *  
  35. *  ・プラグインパラメータで指定できる[Search Limit(移動できる距離)]が
  36. *    一度に移動できる最大距離です。
  37. *    現在位置からこの数値以上に遠い座標を指定することはできません。
  38. *    一度で移動するのではなく複数回に分けて移動させてください。
  39. *   
  40. *  ・[Search Limit(移動できる距離)]を増やすことで一度に移動できる距離を
  41. *    増やせますが、処理が重くなります。
  42. *  
  43. *  
  44. * ●移動先座標の直接入力の詳細
  45. *  ・x および y は大文字小文字どちらでも可能です。
  46. *  
  47. *  ・n の値はマイナスでも動作します。
  48. *  
  49. *  ・n の値は小数点以下の数値でも動作します。
  50. *    ただし、座標の値が整数でない場合、通常の移動に支障が出るため、
  51. *    小数点以下を使用した後はroundX等を使って整数に戻してください。
  52. *  
  53. *  ・スペースはあってもなくても動作しますが、2つ以上のスペースでは動作しません。
  54. *  
  55. *  ・衝突判定は一切しません。指定座標までまっすぐ移動します。
  56. *    はしご、茂み、ダメージ床も無視されます。
  57. *  
  58. *  ・マップのループ移動には対応していません。
  59. *  
  60. *  ・マップの外の座標を指定した場合、キャラクターは画面の外まで移動します。
  61. *  
  62. * ●座標の四捨五入(roundX, roundY)の詳細
  63. *  ・キャラクターの向き変更や歩行アニメは行いません。
  64. *
  65. * ================================
  66. * 制作 : 木星ペンギン
  67. * URL : [url]http://woodpenguin.blog.fc2.com/[/url]
  68. *
  69. * @requiredAssets img/characters/Damage1
  70. *
  71. * @param Search Limit
  72. * @desc 移動できる距離
  73. * @default 12
  74. *
  75. */

  76. (function() {

  77. var Alias = {};

  78. var parameters = PluginManager.parameters('MPP_MoveRouteEX');

  79. var searchLimit = Number(parameters['Search Limit']);

  80. //-----------------------------------------------------------------------------
  81. // Game_Character

  82. //125
  83. Alias.GaCh_processMoveCommand = Game_Character.prototype.processMoveCommand;
  84. Game_Character.prototype.processMoveCommand = function(command) {
  85.     if (command.code === Game_Character.ROUTE_SCRIPT) {
  86.         command = { code: command.code,
  87.             parameters: [this.convertScript(command.parameters[0])] };
  88.     }
  89.     Alias.GaCh_processMoveCommand.call(this, command);
  90. };

  91. Game_Character.prototype.convertScript = function(script) {
  92.     script = script.replace(/^movePos\(/, 'this.movePos(');
  93.     script = script.replace(/^x\s?=\s?(-?\d+\.?\d*)/i, function() {
  94.         return 'this.moveX(' + arguments[1] + ')';
  95.     }.bind(this));
  96.     script = script.replace(/^x\s?\+=\s?(-?\d+\.?\d*)/i, function() {
  97.         var x = this._x + Number(arguments[1]);
  98.         return 'this.moveX(' + x + ')';
  99.     }.bind(this));
  100.     script = script.replace(/^x\s?\-=\s?(-?\d+\.?\d*)/i, function() {
  101.         var x = this._x - Number(arguments[1]);
  102.         return 'this.moveX(' + x + ')';
  103.     }.bind(this));
  104.     script = script.replace(/^y\s?=\s?(-?\d+\.?\d*)/i, function() {
  105.         return 'this.moveY(' + arguments[1] + ')';
  106.     }.bind(this));
  107.     script = script.replace(/^y\s?\+=\s?(-?\d+\.?\d*)/i, function() {
  108.         var y = this._y + Number(arguments[1]);
  109.         return 'this.moveY(' + y + ')';
  110.     }.bind(this));
  111.     script = script.replace(/^y\s?\-=\s?(-?\d+\.?\d*)/i, function() {
  112.         var y = this._y - Number(arguments[1]);
  113.         return 'this.moveY(' + y + ')';
  114.     }.bind(this));
  115.     script = script.replace(/^roundX/, 'this._x = Math.round(this._x)');
  116.     script = script.replace(/^roundY/, 'this._y = Math.round(this._y)');
  117.     return script;
  118. };

  119. Game_Character.prototype.movePos = function(x, y, skippable) {
  120.     skippable = skippable || false;
  121.     var direction = this.findDirectionTo(x, y);
  122.     if (direction > 0) {
  123.         this.moveStraight(direction);
  124.         this.setMovementSuccess(false);
  125.     } else if (Math.abs(this._x - x) + Math.abs(this._y - y) < searchLimit) {
  126.         this.setMovementSuccess(skippable || this.pos(x, y));
  127.     }
  128. };

  129. Game_Character.prototype.moveX = function(x) {
  130.     if (this._x > x) this.setDirection(4);
  131.     if (this._x < x) this.setDirection(6);
  132.     this._x = x;
  133.     this.resetStopCount();
  134. };

  135. Game_Character.prototype.moveY = function(y) {
  136.     if (this._y < y) this.setDirection(2);
  137.     if (this._y > y) this.setDirection(8);
  138.     this._y = y;
  139.     this.resetStopCount();
  140. };

  141. //558
  142. Game_Character.prototype.searchLimit = function() {
  143.     return searchLimit;
  144. };

  145. //-----------------------------------------------------------------------------
  146. // Game_Interpreter

  147. //1722
  148. Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  149. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  150.     Alias.GaIn_pluginCommand.call(this, command, args);
  151.     if (command === 'WaitRoute') {
  152.         this._waitMode = 'route';
  153.         this._character = this.character(Number(args[0]));
  154.     }
  155. };

  156. })();
复制代码
回复

使用道具 举报

梦石
0
星屑
178
在线时间
21 小时
注册时间
2018-4-16
回帖
4
 楼主| 发表于 2018-4-20 09:26:11 | 显示全部楼层
汪汪 发表于 2018-4-20 09:11
https://rpg.blue/thread-405972-1-1.html

感谢回复,我试了用并行那个,虽然做到了移动到指定位置,但是在频率5,移速2倍的情况下该事件的走动会断断续续的而且行走动画不连贯啊,看来只能用循环判断的方式了

点评

试了试还可以啊.....  发表于 2018-4-22 11:43
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部