Da
Sparvy
//potete copiare e salvare tutto con estensione .js (javascript) e metterlo nella cartella plugin
//del vostro progetto
//=====================================================================
// SelectItemWeaponArmors (For RPG Maker MV)
//=====================================================================
/*:
* @plugindesc modify the select_item command of rpg maker to get
* selectable also weapons and armors
* @author Francesco Sammaritano *
* @param variabile
* @desc ID of variable where to store the number (1, 2 or 3) for select
* different tipe of items (items, weapons, armors).
* @default 6
*
*
* @help This plugin does not provide plugin commands.
*
* This plugin modify the select item command, but you have to give to
* "itemcategory" variable a value, of:
* 1 if you wanna show the normal select items;
* 2 if you wanna show a selection of weapons;
* 3 if you wanna show a selection of armors.
* and this variable ha to be set before that the command choose item is
* called, so it'll will run in function of it.
*
* Example: i wanna show to my player the standard select item window, so
* i'll give (in the way you want) to my "itemcategory" variable the value
* 1 and i'll insert after this line the command "select item" (you can set
* all this thing only using "control variable" and "Select Item" commands
* in rpg maker MV
*/
//-----------------------------------------------------------------------------
(function() {
var parameters = PluginManager.parameters('SelectWeaponcommand');
var variabile = Number(parameters['variabile']) != 0;
// LAVORO MIO MESSO AL SICURO!!! DA NON TOCCARE PERCHE' FUNZIONA!!!
function Window_EventItem() {
this.initialize.apply(this, arguments);
}
Window_EventItem.prototype = Object.create(Window_ItemList.prototype);
Window_EventItem.prototype.constructor = Window_EventItem;
Window_EventItem.prototype.initialize = function(messageWindow) {
this._messageWindow = messageWindow;
var width = Graphics.boxWidth;
var height = this.windowHeight();
Window_ItemList.prototype.initialize.call(this, 0, 0, width, height);
this.openness = 0;
this.deactivate();
this.setHandler('ok', this.onOk.bind(this));
this.setHandler('cancel', this.onCancel.bind(this));
};
Window_EventItem.prototype.windowHeight = function() {
return this.fittingHeight(this.numVisibleRows());
};
Window_EventItem.prototype.numVisibleRows = function() {
return 4;
};
Window_EventItem.prototype.start = function() {
this.refresh();
this.updatePlacement();
this.select(0);
this.open();
this.activate();
};
Window_EventItem.prototype.updatePlacement = function() {
if (this._messageWindow.y >= Graphics.boxHeight / 2) {
this.y = 0;
} else {
this.y = Graphics.boxHeight - this.height;
}
};
Window_EventItem.prototype.includes = function(item) { // Francesco, l'ho modificata per poter selezionare più tipi di oggetti.
var itypeId = $gameMessage.itemChoiceItypeId();
if ($gameVariables.value(variabile) == 2) {
return DataManager.isWeapon(item) /*&& item.itypeId === itypeId;*/ // francesco, prima era DataManager.isItem se non si toglie quel pezzo parte non spuntano armi!!!
};
if ($gameVariables.value(variabile) == 1) {
return DataManager.isItem(item) && item.itypeId === itypeId;
};
if ($gameVariables.value(variabile) == 3) {
return DataManager.isArmor(item) /*&& item.itypeId === itypeId;*/ // francesco, prima era DataManager.isItem se non si toglie quel pezzo parte non spuntano armi!!!
};
};
Window_EventItem.prototype.isEnabled = function(item) {
return true;
};
Window_EventItem.prototype.onOk = function() {
var item = this.item();
var itemId = item ? item.id : 0;
$gameVariables.setValue($gameMessage.itemChoiceVariableId(), itemId);
this._messageWindow.terminateMessage();
this.close();
};
Window_EventItem.prototype.onCancel = function() {
$gameVariables.setValue($gameMessage.itemChoiceVariableId(), 0);
this._messageWindow.terminateMessage();
this.close();
};
})();