查看: 5669|回复: 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[pre lang="javascript"]//=============================================================================
// MPP_MoveRouteEX.js
//=============================================================================
// Copyright (c) 2016 Mokusei Penguin
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//=============================================================================

/*:
* @plugindesc 【ver.1.0】移動ルートに関するコマンド詰め合わせ。
* @author 木星ペンギン
*
* @help プラグインコマンド:
*   WaitRoute n           # イベントID n 番の移動が完了するまでウェイト
*                         # -1:プレイヤー, 0:このイベント
*
* 移動ルートのスクリプト:
*   movePos(x, y)         # 座標(x, y)に向かって移動します。
*   movePos(x, y, skip)
*   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座標の値を四捨五入して、最も近い整数にします。
*
*
* ●movePosの詳細
*  ・skip で true を設定した場合、移動できなかった時点で移動を中断します。
*  
*  ・[移動ルートの設定]のオプションにある[移動できない場合は飛ばす]には
*    チェックを入れないでください。
*  
*  ・プラグインパラメータで指定できる[Search Limit(移動できる距離)]が
*    一度に移動できる最大距離です。
*    現在位置からこの数値以上に遠い座標を指定することはできません。
*    一度で移動するのではなく複数回に分けて移動させてください。
*   
*  ・[Search Limit(移動できる距離)]を増やすことで一度に移動できる距離を
*    増やせますが、処理が重くなります。
*  
*  
* ●移動先座標の直接入力の詳細
*  ・x および y は大文字小文字どちらでも可能です。
*  
*  ・n の値はマイナスでも動作します。
*  
*  ・n の値は小数点以下の数値でも動作します。
*    ただし、座標の値が整数でない場合、通常の移動に支障が出るため、
*    小数点以下を使用した後はroundX等を使って整数に戻してください。
*  
*  ・スペースはあってもなくても動作しますが、2つ以上のスペースでは動作しません。
*  
*  ・衝突判定は一切しません。指定座標までまっすぐ移動します。
*    はしご、茂み、ダメージ床も無視されます。
*  
*  ・マップのループ移動には対応していません。
*  
*  ・マップの外の座標を指定した場合、キャラクターは画面の外まで移動します。
*  
* ●座標の四捨五入(roundX, roundY)の詳細
*  ・キャラクターの向き変更や歩行アニメは行いません。
*
* ================================
* 制作 : 木星ペンギン
* URL : http://woodpenguin.blog.fc2.com/
*
* @requiredAssets img/characters/Damage1
*
* @param Search Limit
* @desc 移動できる距離
* @default 12
*
*/

(function() {

var Alias = {};

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

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

//-----------------------------------------------------------------------------
// Game_Character

//125
Alias.GaCh_processMoveCommand = Game_Character.prototype.processMoveCommand;
Game_Character.prototype.processMoveCommand = function(command) {
    if (command.code === Game_Character.ROUTE_SCRIPT) {
        command = { code: command.code,
            parameters: [this.convertScript(command.parameters[0])] };
    }
    Alias.GaCh_processMoveCommand.call(this, command);
};

Game_Character.prototype.convertScript = function(script) {
    script = script.replace(/^movePos\(/, 'this.movePos(');
    script = script.replace(/^x\s?=\s?(-?\d+\.?\d*)/i, function() {
        return 'this.moveX(' + arguments[1] + ')';
    }.bind(this));
    script = script.replace(/^x\s?\+=\s?(-?\d+\.?\d*)/i, function() {
        var x = this._x + Number(arguments[1]);
        return 'this.moveX(' + x + ')';
    }.bind(this));
    script = script.replace(/^x\s?\-=\s?(-?\d+\.?\d*)/i, function() {
        var x = this._x - Number(arguments[1]);
        return 'this.moveX(' + x + ')';
    }.bind(this));
    script = script.replace(/^y\s?=\s?(-?\d+\.?\d*)/i, function() {
        return 'this.moveY(' + arguments[1] + ')';
    }.bind(this));
    script = script.replace(/^y\s?\+=\s?(-?\d+\.?\d*)/i, function() {
        var y = this._y + Number(arguments[1]);
        return 'this.moveY(' + y + ')';
    }.bind(this));
    script = script.replace(/^y\s?\-=\s?(-?\d+\.?\d*)/i, function() {
        var y = this._y - Number(arguments[1]);
        return 'this.moveY(' + y + ')';
    }.bind(this));
    script = script.replace(/^roundX/, 'this._x = Math.round(this._x)');
    script = script.replace(/^roundY/, 'this._y = Math.round(this._y)');
    return script;
};

Game_Character.prototype.movePos = function(x, y, skippable) {
    skippable = skippable || false;
    var direction = this.findDirectionTo(x, y);
    if (direction > 0) {
        this.moveStraight(direction);
        this.setMovementSuccess(false);
    } else if (Math.abs(this._x - x) + Math.abs(this._y - y) < searchLimit) {
        this.setMovementSuccess(skippable || this.pos(x, y));
    }
};

Game_Character.prototype.moveX = function(x) {
    if (this._x > x) this.setDirection(4);
    if (this._x < x) this.setDirection(6);
    this._x = x;
    this.resetStopCount();
};

Game_Character.prototype.moveY = function(y) {
    if (this._y < y) this.setDirection(2);
    if (this._y > y) this.setDirection(8);
    this._y = y;
    this.resetStopCount();
};

//558
Game_Character.prototype.searchLimit = function() {
    return searchLimit;
};

//-----------------------------------------------------------------------------
// Game_Interpreter

//1722
Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
    Alias.GaIn_pluginCommand.call(this, command, args);
    if (command === 'WaitRoute') {
        this._waitMode = 'route';
        this._character = this.character(Number(args[0]));
    }
};

})();
[/pre]
回复

使用道具 举报

梦石
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.

在本版发帖返回顶部