112 lines
4.1 KiB
JavaScript
112 lines
4.1 KiB
JavaScript
/*:
|
||
* @plugindesc コモンイベントを呼び出すと同時にCC表示用変数に値を代入するプラグイン
|
||
* @author Tokomagi
|
||
*
|
||
* @param commandCommonEventId
|
||
* @text コマンド毎のコモンイベントID設定
|
||
* @desc コマンドに対するコモンイベントIDを定義します。
|
||
* @default []
|
||
* @type struct<commandCommonEventId>[]
|
||
*
|
||
* @param InitVariableId
|
||
* @text CC表示用変数1インデックス
|
||
* @desc CC表示用変数1のインデックスを設定
|
||
* @default 61
|
||
* @type variable
|
||
*
|
||
* @help
|
||
* コモンイベントを呼び出すと同時にCC表示用変数に値を代入するプラグインです
|
||
*/
|
||
|
||
/*~struct~commandCommonEventId:
|
||
*
|
||
* @param command
|
||
* @text コマンド
|
||
* @desc プラグインコマンドを設定します。
|
||
* 半角英数字(_)で入力してください。
|
||
* @type string
|
||
*
|
||
* @param CommonEventId
|
||
* @text コモンイベントID
|
||
* @desc コマンドによって呼び出されるコモンイベントのIDを設定します。
|
||
* 半角数字(_)で入力してください。
|
||
* @type number
|
||
*/
|
||
(function() {
|
||
'use strict';
|
||
let pluginName = '0_CommonEventCall';
|
||
let parameters = PluginManager.parameters(pluginName);
|
||
|
||
var getParamNumber = function(paramNames, min, max) {
|
||
var value = getParamOther(paramNames);
|
||
if (arguments.length < 2) min = -Infinity;
|
||
if (arguments.length < 3) max = Infinity;
|
||
return (parseInt(value, 10) || 0).clamp(min, max);
|
||
};
|
||
|
||
var getParamOther = function(paramNames) {
|
||
if (!Array.isArray(paramNames)) paramNames = [paramNames];
|
||
for (var i = 0; i < paramNames.length; i++) {
|
||
var name = PluginManager.parameters(pluginName)[paramNames[i]];
|
||
if (name) return name;
|
||
}
|
||
return null;
|
||
};
|
||
|
||
//=============================================================================
|
||
// パラメータの取得と整形
|
||
//=============================================================================
|
||
var commandCommonEventId = JSON.parse(parameters["commandCommonEventId"] || "null");
|
||
var cmdLists = [];
|
||
if (commandCommonEventId) {
|
||
commandCommonEventId.forEach(function(elm) {
|
||
cmdLists.push(JSON.parse(elm));
|
||
});
|
||
}
|
||
|
||
let paramInitVariableId = getParamNumber(['InitVariableId', 'CC表示用変数1インデックス']);
|
||
|
||
//=============================================================================
|
||
// Game_Interpreter
|
||
// プラグインコマンドを追加定義します。
|
||
//=============================================================================
|
||
var getCommandName = function(command) {
|
||
return (command || '').toUpperCase();
|
||
};
|
||
|
||
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
|
||
Game_Interpreter.prototype.pluginCommand = function(command, args) {
|
||
_Game_Interpreter_pluginCommand.apply(this, arguments);
|
||
this.pluginCustomPictureCommands(command, args);
|
||
};
|
||
|
||
Game_Interpreter.prototype.pluginCustomPictureCommands = function(command, args) {
|
||
/*
|
||
switch (getCommandName(command)) {
|
||
case 'CG_CTL':
|
||
// CC表示用変数に引数を代入
|
||
for (let i = 0; i < args.length; i++) {
|
||
let VId = paramInitVariableId + i;
|
||
$gameVariables.setValue(VId, args[i]);
|
||
}
|
||
this.setupChild($dataCommonEvents[paramCommonEventsId].list, 0)
|
||
break;
|
||
}
|
||
*/
|
||
var cmd = cmdLists.filter(function(cmdList) {
|
||
return cmdList.command == getCommandName(command);
|
||
});
|
||
if (cmd[0]) {
|
||
// CC表示用変数に引数を代入
|
||
for (let i = 0; i < args.length; i++) {
|
||
let VId = paramInitVariableId + i;
|
||
$gameVariables.setValue(VId, args[i]);
|
||
}
|
||
this.setupChild($dataCommonEvents[cmd[0].CommonEventId].list, 0);
|
||
}
|
||
};
|
||
|
||
Game_Actor.prototype.shouldDisplayLevelUp = function() {
|
||
return false;
|
||
};
|
||
})();
|