Skip to content

Instantly share code, notes, and snippets.

@KyoPanda
Last active June 17, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KyoPanda/87e577a09413094dcfa0ccd04f1ff7b4 to your computer and use it in GitHub Desktop.
Save KyoPanda/87e577a09413094dcfa0ccd04f1ff7b4 to your computer and use it in GitHub Desktop.
Allows you assign variables to items, weapons or armors quantity in the party inventory before you open the Gameus Quest System's menu.
/*:
* @plugindesc
* Allows you assign variables to items, weapons or armors quantity in the
* party inventory before you open the Gameus Quest System's menu.
*
* @author Kyo Panda
*
* @param items
* @text Items
* @desc Maps items to variables.
* @type struct<ItemVariable>[]
*
* @param weapons
* @text Weapons
* @desc Maps weapons to variables.
* @type struct<WeaponVariable>[]
*
* @param armors
* @text Armors
* @desc Maps armors to variables.
* @type struct<ArmorVariable>[]
*
* @help
*
* MIT License
*
* Copyright (c) 2017 Kyo Panda
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*:pt
* @plugindesc
* Permite que você defina variáveis a quantidade de itens, armas ou
* armaduras do grupo antes de abrir o menu do Gameus Quest System.
*
* @author Kyo Panda
*
* @param items
* @text Itens
* @desc Mapeia itens a variáveis.
* @type struct<ItemVariable>[]
*
* @param weapons
* @text Armas
* @desc Mapeia armas a variáveis
* @type struct<WeaponVariable>[]
*
* @param armors
* @text Armaduras
* @desc Mapeia armaduras a variáveis.
* @type struct<ArmorVariable>[]
*
* @help
*
* MIT License
*
* Copyright (c) 2017 Kyo Panda
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*~struct~ItemVariable:
* @param id
* @text Item
* @type item
*
* @param variable
* @text Variable
* @type variable
*/
/*~struct~WeaponVariable:
* @param id
* @text Weapon
* @type weapon
*
* @param variable
* @text Variable
* @type variable
*/
/*~struct~ArmorVariable:
* @param id
* @text Armor
* @type armor
*
* @param variable
* @text Variable
* @type variable
*/
(function() {
'use strict';
var Imported = window.Imported || {};
Imported.Kyo_GQSVariableAssign = true;
var Kyo = window.Kyo || {};
Kyo.GQSVariableAssign = {};
Kyo.GQSVariableAssign.version = '1.0.0-beta';
var $ = Kyo.GQSVariableAssign;
$._params = (function() {
var params = PluginManager.parameters('Kyo_GQSVariableAssign');
var data = {
items: [],
weapons: [],
armors: []
};
['items', 'weapons', 'armors'].forEach(function(type) {
JSON.parse((params[type] || '[]')).forEach(function(item) {
var _item = JSON.parse(item);
_item.id = Number(_item.id);
_item.variable = Number(_item.variable);
if (!_item.id || !_item.variable) {
return;
}
data[type].push(_item);
});
}, this);
return data;
}());
var _Scene_Menu_commandQuest = Scene_Menu.prototype.commandQuest;
Scene_Menu.prototype.commandQuest = function() {
['items', 'armors', 'weapons'].forEach(function(type) {
$gameParty[type]().forEach(function(item) {
$._params[type].forEach(function(data) {
if (item.id !== data.id) {
return;
}
var value = $gameParty.numItems(item);
$gameVariables.setValue(data.variable, value);
}, this);
}, this);
}, this);
_Scene_Menu_commandQuest.apply(this, arguments);
};
window.Imported = Imported;
window.Kyo = Kyo;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment