9月に配信された RPGツクールMV アップデートVer.1.5.1配信開始 ですが、今更ながら Ver1.5.0 からの更新点のまとめです。
以前からGitHubのmdファイルとして自分の学習用の更新メモ RPGツクールMV JGSS 技術メモ を公開していますが、今回はより楽な Qiita で書いてみました。
rpg_core.js
おおきな変更はみられず。
plugins.sprite が決め打ちじゃなく this.pluginName を参照するようになったり、
renderer.setObjectRenderer(renderer.plugins.sprite); // ver1.5.0
renderer.setObjectRenderer(renderer.plugins[this.pluginName]); // ver1.5.1
PIXIのバージョンアップにあわせて以下が修正されています。
PIXI.GC_MODES.DEFAULT = PIXI.GC_MODES.AUTO; // ver1.5.0
PIXI.settings.GC_MODE = PIXI.GC_MODES.AUTO; // ver1.5.1
rpg_managers.js
BattleManager に _turnForced というフラグが追加されており、
BattleManager.initMembers = function() {
this._phase = 'init';
this._canEscape = false;
this._canLose = false;
this._battleTest = false;
this._eventCallback = null;
this._preemptive = false;
this._surprise = false;
this._actorIndex = -1;
this._actionForcedBattler = null;
this._mapBgm = null;
this._mapBgs = null;
this._actionBattlers = [];
this._subject = null;
this._action = null;
this._targets = [];
this._logWindow = null;
this._statusWindow = null;
this._spriteset = null;
this._escapeRatio = 0;
this._escaped = false;
this._rewards = {};
this._turnForced = false; // ver1.5.1で追加
};
それを参照するための関数が新規追加されています。
BattleManager.isForcedTurn = function () {
return this._turnForced;
};
またこのフラグは processForcedAction でONになり。
BattleManager.processForcedAction = function() {
if (this._actionForcedBattler) {
this._turnForced = true; // ver1.5.1で追加
this._subject = this._actionForcedBattler;
this._actionForcedBattler = null;
this.startAction();
this._subject.removeCurrentAction();
}
};
そして endTurn でOFFに戻るようです。
BattleManager.endTurn = function() {
this._phase = 'turnEnd';
this._preemptive = false;
this._surprise = false;
this.allBattleMembers().forEach(function(battler) {
battler.onTurnEnd();
this.refreshStatus();
this._logWindow.displayAutoAffectedStatus(battler);
this._logWindow.displayRegeneration(battler);
}, this);
if (this.isForcedTurn()) { // ver1.5.1で追加
this._turnForced = false; // ver1.5.1で追加
} // ver1.5.1で追加
};
つまり BattleManager.isForcedTurn() は、そのターン中に一度でも processForcedAction() が呼ばれたかどうか、つまりバトルイベントで「戦闘行動の強制」が指定されたターンかどうか、を確かめる関数なようです。
この関数は次の rpg_objects.js 内で使用されています。今回の修正は BattleManager.isForcedTurn() 関連だけです。
rpg_objects.js
上記の BattleManager の新規関数 isForcedTurn() がさっそく使用されています。これは「バトル中にイベントを発生させた際、ターンが経過したことになってしまう不具合を修正」のようですね。
// ver1.5.0
this.updateStateTurns();
this.updateBuffTurns();
// ver1.5.1
if (!BattleManager.isForcedTurn()) {
this.updateStateTurns();
this.updateBuffTurns();
}
また Game_Interpreter.prototype.command122 の処理も変更されています。
// ver1.5.0
case 2: // Random
value = this._params[4] + Math.randomInt(this._params[5] - this._params[4] + 1);
break;
// ver1.5.1
case 2: // Random
value = this._params[5] - this._params[4] + 1;
for (var i = this._params[0]; i <= this._params[1]; i++) {
this.operateVariable(i, this._params[2], this._params[4] + Math.randomInt(value));
}
return true;
break;
これは「変数の操作」でオペランドに「乱数」を選択したときに実施される処理です。
Ver1.5.0 では乱数をひとつ生成して代入処理に移行するのに対し、Ver1.5.1 のほうは代入処理もとりこんで、要素ごとに乱数を生成しているのがわかります。これは更新ページにある「変数操作コマンドで変数の範囲指定をした場合、乱数指定をしても範囲中の変数の値がすべて同一になってしまう不具合を修正」に該当するバグ修正ですね。
変更なし
以下のファイルは今回は特に変更がない模様。
- rpg_sprites.js
- rpg_windows.js
- rpg_scenes.js
まとめ
今回の js の修正は2つのバグを潰しただけ、でしたね。地道な修正ですが、継続して品質をあげていくのは大事なことです。