ここまでいけたのですが、プラグインコマンドにて、256を別の数字へと変更したい場合はどうすれば良いのでしょうか?
ゲーム中に値を変更したい場合は、256を変数にする必要があります。
変数名は半角文字で数字記号以外から始まり、同じ名前が他になければなんでもいいです。
コード: 全て選択
var moveDeno = 256; // 変数の宣言 var 変数名 = 初期値;
Game_CharacterBase.prototype.distancePerFrame = function() {
return Math.pow(2, this.realMoveSpeed()) / moveDeno; // 変更したい箇所を変数に
};
このコードのCriticalAnimation、AnimationID、 FlashEffectを変更をすれば良いと思うのですが、何にしたら良いのか分かりません。
そのコードはプラグインパラメータを取得するコードなので、プラグインコマンドは別のコードになります。
ChangeMove set 200 のようなコマンドを作りたい場合は下記のようになります。
コード: 全て選択
var _Game_Interpreter_pluginCommand =
Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
// ここまで固定
if (command === 'ChangeMove') { // コマンド名を設定 (プラグイン名と同名が一般的)
switch (args[0]) { // 固定
case 'set': // 命令名を設定
moveDeno = Number(args[1]); // ここに処理を書きます
break; // caseの終了時に記述します
}
}
}
適当なプラグインからコピペして変更しています。
commandにChangeMove、args[0]にset、args[1]に200、が全て文字列で送られてきます。
args[1]は数値にしたいので、Number(args[1])で変換して変数に代入します。
最終的なコードです。
コード: 全て選択
(function(){
'use strict'
var moveDeno = 256;
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'ChangeMove') {
switch (args[0]) {
case 'set': moveDeno = Number(args[1]); break;
}
}
}
Game_CharacterBase.prototype.distancePerFrame = function() {
return Math.pow(2, this.realMoveSpeed()) / moveDeno;
};
})();