// https://github.com/AlecYawata/TkoolMV_PluginCommandBook // Copyright (c) 2015 Alec // http://opensource.org/licenses/mit-license.php /*: * @plugindesc * @author 有志の皆さん * * @param 制御文字の拡張 * @desc このプラグインで使えるパラメータの制御文字を * 通常のメッセージなどで使用できるようにするか(はい/いいえ) * Default: はい * @default はい * * @param スクリプトに制御文字適用 * @desc スクリプト実行時に制御文字を使用できるようにするか(はい/いいえ) * Default: いいえ * @default いいえ * * @help */ (function(){ 'use strict'; Game_Interpreter.prototype.pluginCommandBook_unescape = function(text) { var wstringToString = function(text) { text = text.replace(/[0-9]/g, function(c) { return String.fromCharCode(c.charCodeAt(0) - 0xFEE0); }); return text; }; var getActorName = function(n) { var actor = n >= 1 ? $gameActors.actor(n) : null; return actor ? actor.name() : ''; }; var getPartyMemberName = function(n) { var actor = n >= 1 ? $gameParty.members()[n - 1] : null; return actor ? actor.name() : ''; }; var prevText = ""; text = text.replace(/\\/g, '\x1b'); while (prevText != text) { prevText = text; text = text.replace(/\x1b\x1b/g, '\\'); text = text.replace(/\x1bV\[([0-9\d]+)\]/gi, function() { return $gameVariables.value(parseInt(wstringToString(arguments[1]), 10)); }.bind(this)); text = text.replace(/\x1bN\[([0-9\d]+)\]/gi, function() { return getActorName(parseInt(wstringToString(arguments[1]), 10)); }.bind(this)); text = text.replace(/\x1bP\[([0-9\d]+)\]/gi, function() { return getPartyMemberName(parseInt(wstringToString(arguments[1]), 10)); }.bind(this)); text = text.replace(/\x1bG/gi, TextManager.currencyUnit); text = text.replace(/\x1bIn\[([0-9\d]+)\]/gi, function() { return $dataItems[parseInt(wstringToString(arguments[1]), 10)].name; }.bind(this)); text = text.replace(/\x1bNi\[([0-9\d]+)\]/gi, function() { return $dataItems[parseInt(wstringToString(arguments[1]), 10)].name; }.bind(this)); text = text.replace(/\x1bIp\[([0-9\d]+)\]/gi, function() { return $dataItems[parseInt(wstringToString(arguments[1]), 10)].price; }.bind(this)); text = text.replace(/\x1bPi\[([0-9\d]+)\]/gi, function() { return $dataItems[parseInt(wstringToString(arguments[1]), 10)].price; }.bind(this)); text = text.replace(/\x1bSn\[([0-9\d]+)\]/gi, function() { return $dataSkills[parseInt(wstringToString(arguments[1]), 10)].name; }.bind(this)); text = text.replace(/\x1bNs\[([0-9\d]+)\]/gi, function() { return $dataSkills[parseInt(wstringToString(arguments[1]), 10)].name; }.bind(this)); text = text.replace(/\x1bNc\[([0-9\d]+)\]/gi, function() { return $dataClasses[parseInt(wstringToString(arguments[1]), 10)].name; }.bind(this)); text = text.replace(/\x1bNt\[([0-9\d]+)\]/gi, function() { return $dataStates[parseInt(wstringToString(arguments[1]), 10)].name; }.bind(this)); text = text.replace(/\x1bNw\[([0-9\d]+)\]/gi, function() { return $dataWeapons[parseInt(wstringToString(arguments[1]), 10)].name; }.bind(this)); text = text.replace(/\x1bNa\[([0-9\d]+)\]/gi, function() { return $dataArmors[parseInt(wstringToString(arguments[1]), 10)].name; }.bind(this)); text = text.replace(/\x1bJs\[(.*)\]\x1bJs/gi, function() { try{ var value = eval(arguments[1]); if (value != null){return value}else{ console.log('制御文字 \\JS のパラメータでエラー 詳細:評価値が無い(null or undefined)'); return 0; } } catch(ex){ console.log( '制御文字 \\JS のパラメータでエラー 詳細: ' + ex.toString()); return 0; } }.bind(this)); } text = text.replace(/\x1bG/gi, TextManager.currencyUnit); return text; }; /** * 厳密な数値チェックを行います。引数が数値でなければ例外を発生されます。 * プラグインコマンド集では、例外が発生してもその場でゲームは中断されず * 実行したコマンドのみが無効になり、さらにテストプレーなら自動でデベロッパツールが起動します。 * * @method parseIntStrict * @param {Number} value * @param {String} errorMessage * @type Number * @return {Number} 数値に変換した結果 */ var parseIntStrict = function(value, errorMessage) { var result = parseInt(value, 10); if (isNaN(result)) throw Error('指定した値[' + value + ']が数値ではありません。' + errorMessage); return result; }; var parameters = PluginManager.parameters('JsScript204Set'); var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; Game_Interpreter.prototype.pluginCommand = function (command, args) { _Game_Interpreter_pluginCommand.call(this, command, args); if (command.length == 0) { return; } this.executePluginCommand(command, args); }; Game_Interpreter.prototype.executePluginCommand = function(command, args) { var methodName = 'pluginCommandBook_' + command; if (typeof this[methodName] === 'function') { for (var i=0; i 0; }; Game_Picture.prototype.setAngleDirect = function(value) { this._rotationSpeed = 0; this._angle = value % 360; }; var _Scene_Map_isMapTouchOk = Scene_Map.prototype.isMapTouchOk; Scene_Map.prototype.isMapTouchOk = function() { return (!$gameSystem._mapTouchDisable || $gameTemp.isDestinationValid()) && _Scene_Map_isMapTouchOk.call(this); }; var _Window_NumberInput_refresh = Window_NumberInput.prototype.refresh; Window_NumberInput.prototype.refresh = function() { if (this._number != null) this._number = this._number.clamp( $gameMessage._numInputMinValue, $gameMessage._numInputMaxValue); _Window_NumberInput_refresh.apply(this, arguments); }; var _Window_NumberInput_start = Window_NumberInput.prototype.start; Window_NumberInput.prototype.start = function() { _Window_NumberInput_start.apply(this, arguments); this.updateBackground(); }; var _Window_NumberInput_processOk = Window_NumberInput.prototype.processOk; Window_NumberInput.prototype.processOk = function() { _Window_NumberInput_processOk.apply(this, arguments); $gameMessage.clearNumInputRange(); }; var _Window_NumberInput_updatePlacement = Window_NumberInput.prototype.updatePlacement; Window_NumberInput.prototype.updatePlacement = function() { _Window_NumberInput_updatePlacement.apply(this, arguments); var positionType = $gameMessage.numInputPositionType(); this.width = this.windowWidth(); switch (positionType) { case 0: this.x = 0; break; case 1: this.x = (Graphics.boxWidth - this.width) / 2; break; case 2: this.x = Graphics.boxWidth - this.width; break; } }; var _Window_NumberInput_changeDigit = Window_NumberInput.prototype.changeDigit; Window_NumberInput.prototype.changeDigit = function(up) { if (this.maxItems() - this.index() < $gameMessage._numInputValidDigit) { return; } _Window_NumberInput_changeDigit.apply(this, arguments); }; Window_NumberInput.prototype.updateBackground = function() { this._background = $gameMessage.numInputBackground(); this.setBackgroundType(this._background); }; var _Sprite_Picture_initialize = Sprite_Picture.prototype.initialize; Sprite_Picture.prototype.initialize = function(pictureId) { _Sprite_Picture_initialize.apply(this, arguments); this.z = 0; }; var _Sprite_Picture_update = Sprite_Picture.prototype.update; Sprite_Picture.prototype.update = function() { _Sprite_Picture_update.call(this); if (this.visible) { var newZ = this.picture().z; if (newZ != this.z) { this.z = newZ; $gameScreen.needsSortPictures = true; } this.updateFrame(); } }; Sprite_Picture.prototype.updateFrame = function() { if (this.picture().isValidFrame()) { var p = this.picture(); this.setFrame(p._frameX, p._frameY, p._frameWidth, p._frameHeight); } }; var _Spriteset_Base_createUpperLayer = Spriteset_Base.prototype.createUpperLayer; Spriteset_Base.prototype.createUpperLayer = function() { _Spriteset_Base_createUpperLayer.apply(this, arguments); this.createAnimationContainer(); }; Spriteset_Base.prototype.createAnimationContainer = function() { this._animationContainer = new Sprite_Base(); this._animationId = 0; this.addChild(this._animationContainer); }; var _Spriteset_Base_update = Spriteset_Base.prototype.update; Spriteset_Base.prototype.update = function() { _Spriteset_Base_update.call(this); if ($gameScreen.needsSortPictures) { this.sortPictures(); $gameScreen.needsSortPictures = false; } this.updateAnimationContainer(); }; Spriteset_Base.prototype.updateAnimationContainer = function() { var id = $gameScreen.animationId; if (id > 0 && id < $dataAnimations.length) { this._animationContainer.x = $gameScreen.animationContainerX; this._animationContainer.y = $gameScreen.animationContainerY; this._animationContainer.startAnimation($dataAnimations[id], false, 0); this._animationId = id; $gameScreen.clearAnimation(); } if (!this._animationContainer.isAnimationPlaying() && this._animationId > 0) { if ($gameScreen.animationLoop) { this._animationContainer.startAnimation($dataAnimations[this._animationId], false, 0); } else { this._animationId = 0; } } }; Spriteset_Base.prototype.sortPictures = function() { this._pictureContainer.children.sort(this._comparePictureChildOrder.bind(this)); }; Spriteset_Base.prototype._comparePictureChildOrder = function(a, b) { if (a.z !== b.z) { return a.z - b.z; } else { return a._pictureId - b._pictureId; } }; })();