查看: 4005|回复: 2

[已经解决] 求救!!请大神告知MV时间移动脚本【已解决】

[复制链接]
梦石
0
星屑
875
在线时间
290 小时
注册时间
2010-9-9
回帖
53
发表于 2016-3-18 02:52:50 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 czsRwind 于 2016-3-18 11:18 编辑

在VA的事件指令→设置移动路线→脚本。可以用moveto(x,y)设置自动移动。但是MV用moveto的时候,提示代码错误,请教下大神完整的脚本代码是什么。

点评

setPosition(x,y)  发表于 2016-3-18 08:03
梦石
0
星屑
1314
在线时间
904 小时
注册时间
2014-12-4
回帖
349
发表于 2016-3-18 08:09:49 | 显示全部楼层
本帖最后由 翻滚牛宝宝 于 2016-3-18 11:13 编辑

$gameMap.event(this._eventId).setPosition(x,y)
  1. //=============================================================================
  2. // Smart Pathfinding
  3. // by Shaz
  4. // Last Updated: 2015.10.26
  5. //=============================================================================

  6. /*:
  7. * @plugindesc Allows events or players to do smart Pathfinding
  8. * @author Shaz
  9. *
  10. * @help
  11. *
  12. * This is merely a fork of Shaz's SMARTPATH plugin. I've added some extra
  13. * functionality to be able to auto-cancel the pathfinding as well as to
  14. * have the event interpreter WAIT while the pathing takes place.
  15. *
  16. * Plugin Command:
  17. *  SmartPath eventId1 eventId2      # Makes event 1 find path to event 2
  18. *  SmartPath eventId x y            # Makes event find a path to location x, y
  19. *  SmartPath eventId cancel         # Cancel Pathfinding for event
  20. *
  21. *  event = number for specific event
  22. *  event = 0 for "this" event
  23. *  event = -1 for player
  24. *  event = $gameVariables.value(x) to get the event id from variable x
  25. *
  26. *  x, y = coordinates or $gameVariables.value(#) to use a variable coordinate
  27. *
  28. * Update by DragoonKain:
  29. *   Use Game_Interpreter.findEvent to allow specifying events by name.
  30. *   Added Wait, Auto_Cancel and Auto_Cancel_Near.
  31. */

  32. (function() {
  33.   var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  34.   Game_Interpreter.prototype.pluginCommand = function(command, args) {
  35.     _Game_Interpreter_pluginCommand.call(this, command, args);

  36.     if (command.toUpperCase() === 'SMARTPATH') {
  37.       subject = this.findEvent
  38.         ? this.findEvent(args[0])
  39.         : this.character(eval(args[0]));

  40.       if (args[1].toUpperCase() === 'CANCEL') {
  41.         subject.clearTarget();
  42.       } else if (args[1].toUpperCase() === 'WAIT') {
  43.         if (subject._target && !subject.isOnTarget(subject._targetX, subject._targetY)) {
  44.           this.wait(20);
  45.           this.jumpTo(this._index-1);
  46.         }
  47.       } else if (args[1].toUpperCase() == 'AUTO_CANCEL') {
  48.         subject.setTargetAutoCancel('on');
  49.       } else if (args[1].toUpperCase() == 'AUTO_CANCEL_NEAR') {
  50.         subject.setTargetAutoCancel('near');
  51.       } else if (args.length > 2) {
  52.         subject.setTarget(null, eval(args[1]), eval(args[2]));
  53.       } else {
  54.         var target = this.findEvent
  55.           ? this.findEvent(args[1])
  56.           : this.character(eval(args[1]));
  57.         subject.setTarget(target);
  58.       }
  59.     }
  60.   };

  61.   var _Game_CharacterBase_initMembers = Game_CharacterBase.prototype.initMembers;
  62.   Game_CharacterBase.prototype.initMembers = function() {
  63.     _Game_CharacterBase_initMembers.call(this);
  64.     this._target = null;
  65.     this._targetX = null;
  66.     this._targetY = null;
  67.     this._targetAutoCancel = false; // 'on', 'near', false
  68.     this._break = false;
  69.   };

  70.   Game_CharacterBase.prototype.setTarget = function(target, targetX, targetY) {
  71.     this._target = target;
  72.     if (this._target) {
  73.       this._targetX = this._target.x;
  74.       this._targetY = this._target.y;
  75.     } else {
  76.       this._targetX = targetX;
  77.       this._targetY = targetY;
  78.     }
  79.     this._targetAutoCancel = false;
  80.   };

  81.   Game_CharacterBase.prototype.setTargetAutoCancel = function(targetAutoCancel) {
  82.     this._targetAutoCancel = targetAutoCancel;
  83.   }

  84.   Game_CharacterBase.prototype.clearTarget = function() {
  85.     this._target = null;
  86.     this._targetX = null;
  87.     this._targetY = null;
  88.   };

  89.   Game_CharacterBase.prototype.isNearTarget = function(x, y) {
  90.     var isNear =    Math.abs(this.x - x) <= 1 &&
  91.                     Math.abs(this.y - y) <= 1;
  92.     return isNear;
  93.   }

  94.   Game_CharacterBase.prototype.isOnTarget = function(x, y) {
  95.     return this.x == x &&
  96.            this.y == y;
  97.   }

  98.   var _Game_CharacterBase_updateStop = Game_CharacterBase.prototype.updateStop;
  99.   Game_CharacterBase.prototype.updateStop = function() {
  100.     _Game_CharacterBase_updateStop.call(this);

  101.     if (this._target) {
  102.       this._targetX = this._target.x;
  103.       this._targetY = this._target.y;
  104.     }

  105.     if (this._targetX != null) {
  106.       direction = this.findDirectionTo(this._targetX, this._targetY);
  107.       if (direction > 0)
  108.       {
  109.         this.moveStraight(direction);
  110.       }
  111.     }

  112.     if (this._target && this._targetAutoCancel) {
  113.       if (this._targetAutoCancel.toUpperCase() === 'ON') {
  114.         if (this.isOnTarget(this._targetX, this._targetY)) {
  115.           this.clearTarget();
  116.         }
  117.       } else if (this._targetAutoCancel.toUpperCase() === 'NEAR') {
  118.         if (this.isNearTarget(this._targetX, this._targetY)) {
  119.           this.clearTarget();
  120.         }
  121.       }
  122.     }
  123.   };
  124. })();
复制代码

点评

用插件命令 SmartPath eventId x y  发表于 2016-3-18 11:13
VA的moveto不是这样吗?需要走过去的话找插件  发表于 2016-3-18 11:10
谢谢告知,不过这个的效果是直接设置事件位置的,事件直接跳往指定位置,没有移动动画哦  发表于 2016-3-18 10:46
回复

使用道具 举报

梦石
0
星屑
875
在线时间
290 小时
注册时间
2010-9-9
回帖
53
 楼主| 发表于 2016-3-18 11:17:34 | 显示全部楼层
翻滚牛宝宝 发表于 2016-3-18 08:09
$gameMap.event(this._eventId).setPosition(x,y)
//=================================================== ...

好的,谢谢大神
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部