KYUSEF'S PROFILE
Kyusef
0
Search
[RMMV] Create a scene
Hello to everyone, i am creating a window with all item info, but i don't know how i do to set to go to an other 'page' with right arrow. I try to use 'setHandler' method, but doesn't work... help me please
[RMMV] Help with script
Hello, i want to draw a bigger icon (4 times) on a window. I have edited the 'IconSet' file and i have written this code:
var iconIndex = item.iconIndex;
var bitmap = ImageManager.loadSystem('BigIconSet');
var pw = 128;
var ph = 128;
var sx = iconIndex % 16 * pw;
var sy = Math.floor(iconIndex / 16) * ph;
this.contents.blt(bitmap, sx, sy, pw, ph, 0, 0);
But just appear the empty window, someone can help me, please?
var iconIndex = item.iconIndex;
var bitmap = ImageManager.loadSystem('BigIconSet');
var pw = 128;
var ph = 128;
var sx = iconIndex % 16 * pw;
var sy = Math.floor(iconIndex / 16) * ph;
this.contents.blt(bitmap, sx, sy, pw, ph, 0, 0);
But just appear the empty window, someone can help me, please?
[RMMV] Probability to remove an enemy resistance
Hi, i want to create a weapon that has a chance to remove an enemy resistance for 2 turns. (For example, enemy A is immune to poison. The weapon has a chance to remove poison resistance from that enemy for 2 turns). Thanks.
[RMMV] YEP 58: Item Synthesis Help!
Hi, anyone can help me to do that if party has an item counts as synthetsized? Thanks.
//=============================================================================
// Yanfly Engine Plugins - Item Synthesis
// YEP_ItemSynthesis.js
//=============================================================================
var Imported = Imported || {};
Imported.YEP_ItemSynthesis = true;
var Yanfly = Yanfly || {};
Yanfly.IS = Yanfly.IS || {};
//=============================================================================
/*:
* @plugindesc v1.06 Players can now craft their own items in-game
* through an item synthesis system.
* @author Yanfly Engine Plugins
*
* @param ---General---
* @default
*
* @param Synthesis Command
* @desc This is the text used for going to the item synthesis menu.
* @default Synthesis
*
* @param Show Command
* @desc Show the Synthesis command in the main menu by default?
* NO - false YES - true
* @default true
*
* @param Enable Command
* @desc Enable the Synthesis command in the main menu by default?
* NO - false YES - true
* @default true
*
* @param Auto Place Command
* @desc Allow this plugin to decide the menu placement position?
* NO - false YES - true
* @default true
*
* @param ---Command Window---
* @default
*
* @param Item Command
* @desc The command text used for synthesizing items.
* @default Craft Item
*
* @param Weapon Command
* @desc The command text used for synthesizing weapons.
* @default Craft Weapon
*
* @param Armor Command
* @desc The command text used for synthesizing armors.
* @default Craft Armor
*
* @param Finish Command
* @desc The command text used for exiting the synthesis scene.
* @default Finish
*
* @param Text Alignment
* @desc How to align the text for the command window.
* left center right
* @default center
*
* @param ---Status Window---
* @default
*
* @param Collected Recipes
* @desc Text used to represent total recipes collected.
* Leave this blank if you don't wish to show this.
* @default Collected Recipes
*
* @param Crafted Items
* @desc Text used to represent total items crafted.
* Leave this blank if you don't wish to show this.
* @default Crafted Items
*
* @param Crafted Weapons
* @desc Text used to represent total weapons crafted.
* Leave this blank if you don't wish to show this.
* @default Crafted Weapons
*
* @param Crafted Armors
* @desc Text used to represent total armors crafted.
* Leave this blank if you don't wish to show this.
* @default Crafted Armors
*
* @param ---List Window---
* @default
*
* @param Equipped Recipes
* @desc Check recipes from equipped items?
* NO - false YES - true
* @default true
*
* @param Mask Unknown
* @desc Mask the names of items that haven't been created yet?
* NO - false YES - true
* @default true
*
* @param Mask Text
* @desc This will be used to mask over each letter for unknown item
* names that are to be synthesized.
* @default ?
*
* @param Mask Italic
* @desc Causes the name for unknown items to appear in italic.
* @default true
*
* @param Mask Help Text
* @desc This is the text that will be displayed in the help window
* if the item is masked.
* @default This item has not been synthesized yet.
*
* @param Ingredients Text
* @desc This is the text used to describe the Ingredients list.
* @default Ingredients
*
* @param Amount Text
* @desc This is the text used for the amount to synthesize.
* @default Quantity
*
* @param Quantity Text Size
* @desc This is the text size used for the item quantity.
* Default: 28
* @default 20
*
* @param ---Sound---
* @default
*
* @param Default SE
* @desc This is the default SE played when synthesizing an item.
* This is case sensitive. Do not include the extension.
* @default Twine
*
* @param Default Volume
* @desc This is the default volume when synthesizing an item.
* @default 100
*
* @param Default Pitch
* @desc This is the default pitch when synthesizing an item.
* @default 100
*
* @param Default Pan
* @desc This is the default pan when synthesizing an item.
* @default 0
*
* @help
* ============================================================================
* Introduction
* ============================================================================
*
* Item synthesis is now a pretty common aspect of most RPG's where the player
* can craft their own items after acquiring recipes. This plugin enables your
* players to be able to do that after acquiring the said recipes. Recipes can
* come in the form of items, weapons, and/or armors and transcribed in them
* are what items, weapons, and/or armors they can make. These items can be
* made from the main menu and/or synthesis locations!
*
* ============================================================================
* Notetags
* ============================================================================
*
* To allow the player the ability to craft a certain item, that item must be
* included in a recipe notetag in an item that the player possesses.
*
* Item, Weapon, and Armor Notetags:
* <Item Recipe: x>
* <Item Recipe: x, x, x>
* <Item Recipe: x to y>
* This will change this item into a recipe for x item(s). As long as this
* item is in possession by the party as a whole, item(s) x can be
* synthesized by the player provided that the player has the proper quantity
* of ingredients.
* * Note: Entries without names will not be included. Entries without both a
* synthesis cost and without an ingredient list will not be included.
*
* <Weapon Recipe: x>
* <Weapon Recipe: x, x, x>
* <Weapon Recipe: x to y>
* This will change this item into a recipe for x weapon(s). As long as this
* item is in possession by the party as a whole, weapon(s) x can be
* synthesized by the player provided that the player has the proper quantity
* of ingredients.
* * Note: Entries without names will not be included. Entries without both a
* synthesis cost and without an ingredient list will not be included.
*
* <Armor Recipe: x>
* <Armor Recipe: x, x, x>
* <Armor Recipe: x to y>
* This will change this item into a recipe for x armor(s). As long as this
* item is in possession by the party as a whole, armor(s) x can be
* synthesized by the player provided that the player has the proper quantity
* of ingredients.
* * Note: Entries without names will not be included. Entries without both a
* synthesis cost and without an ingredient list will not be included.
*
* <Synthesis Ingredients>
* item id
* item id: x
* weapon id
* weapon id: x
* armor id
* armor id: x
* gold: x
* named item
* named item: x
* </Synthesis Ingredients>
* Using the above tag in an item will set those items as the ingredients
* required for the player to synthesize. Replace "id" with the proper item,
* weapon, or armor ID's. If no ":x" is used, the database will register that
* as only needing 1 of that item as an ingredient. If "gold: x" is used,
* that will be the cost required to synthesize the item.
*
* If you are using named entries, priority will be given to the highest ID
* in the order of items, weapons, then armors.
*
* * Note: If you are using Item Core, Independent Items cannot become an
* ingredient for a recipe and will therefore be automatically omitted.
*
* <Mask Name: x>
* If you are masking unknown items' names, you can change the text shown for
* the unknown item with x. This will cause the game to use the mask name
* instead of the usual ??? (if that's what you're using) to mask the item.
* This can give a player a general idea of what they may be synthesizing
* such as "Strange Liquid" or "Weird Crystal".
*
* ============================================================================
* Plugin Commands
* ============================================================================
*
* The following are Plugin Commands you may use with events.
*
* Plugin Command:
* OpenSynthesis Opens up the Synthesis Scene from the field.
* ShowSynthesis Shows the Synthesis command from the main menu.
* HideSynthesis Hides the Synthesis command from the main menu.
* EnableSynthesis Enables the Synthesis command from the main menu.
* DisableSynthesis Disables the Synthesis command from the main menu.
*
* For those who wish to make the player synthesize only specific recipes, you
* can use the following command.
*
* OpenSynthesis Item 15 Recipe
* - or -
* OpenSynthesis Weapon 20 Recipe
* - or -
* OpenSynthesis Armor 30 Recipe
*
* This will make the synthesis menu, when opened up, only allow the recipes of
* the Item 15, Weapon 20, or Armor 30 without needing it and not showing the
* recipes of any recipe items within the player's inventory.
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 1.06:
* - Fixed an error with the calculation of total recipes.
*
* Version 1.05:
* - Updated for RPG Maker MV version 1.1.0.
*
* Version 1.04:
* - Added failsafes to prevent crashes from saved games that did not have this
* plugin already installed.
*
* Version 1.03a:
* - Fixed a bug that caused a crash for OpenSynthesis recipe commands.
* - Fixed an issue with recipe counts not appearing right.
*
* Version 1.02:
* - Added 'Equipped Recipes' plugin parameter. If enabled, this will allow the
* Item Synthesis menu to check your party's equipment to see if any of them
* are recipe holders.
*
* Version 1.01:
* - Fixed a bug with the synthesis gold costs taking more than they should.
* - Extended the OpenSynthesis plugin command. If you add Item, Weapon, or
* Armor after the command along with an ID, the synthesis menu will only show
* the items listed on the recipe for Item x, Weapon x, or Armor x.
*
* Version 1.00:
* - Finished Plugin!
*/
//=============================================================================
//=============================================================================
// Parameter Variables
//=============================================================================
Yanfly.Parameters = PluginManager.parameters('YEP_ItemSynthesis');
Yanfly.Param = Yanfly.Param || {};
Yanfly.Param.ISSynthCmd = String(Yanfly.Parameters);
Yanfly.Param.ISShowSynth = String(Yanfly.Parameters);
Yanfly.Param.ISEnableSynth = String(Yanfly.Parameters);
Yanfly.Param.ISAutoPlaceCmd = String(Yanfly.Parameters);
Yanfly.Param.ISItemCmd = String(Yanfly.Parameters);
Yanfly.Param.ISWeaponCmd = String(Yanfly.Parameters);
Yanfly.Param.ISArmorCmd = String(Yanfly.Parameters);
Yanfly.Param.ISFinishCmd = String(Yanfly.Parameters);
Yanfly.Param.ISTextAlign = String(Yanfly.Parameters);
Yanfly.Param.ISColRecipes = String(Yanfly.Parameters);
Yanfly.Param.ISCraftedItems = String(Yanfly.Parameters);
Yanfly.Param.ISCraftedWeapons = String(Yanfly.Parameters);
Yanfly.Param.ISCraftedArmors = String(Yanfly.Parameters);
Yanfly.Param.ISEquRecipes = eval(String(Yanfly.Parameters));
Yanfly.Param.ISMaskUnknown = String(Yanfly.Parameters);
Yanfly.Param.ISMaskText = String(Yanfly.Parameters);
Yanfly.Param.ISMaskItalic = String(Yanfly.Parameters);
Yanfly.Param.ISMaskHelpText = String(Yanfly.Parameters);
Yanfly.Param.ISIngredientsList = String(Yanfly.Parameters);
Yanfly.Param.ISAmountText = String(Yanfly.Parameters);
Yanfly.Param.ISQuantitySize = Number(Yanfly.Parameters);
Yanfly.Param.ISDefSEName = String(Yanfly.Parameters);
Yanfly.Param.ISDefVol = Number(Yanfly.Parameters);
Yanfly.Param.ISDefPitch = Number(Yanfly.Parameters);
Yanfly.Param.ISDefPant = Number(Yanfly.Parameters);
//=============================================================================
// DataManager
//=============================================================================
Yanfly.IS.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!Yanfly.IS.DataManager_isDatabaseLoaded.call(this)) return false;
if (!Yanfly._loaded_YEP_ItemSynthesis) {
this.processISNotetagsI($dataItems);
this.processISNotetagsW($dataWeapons);
this.processISNotetagsA($dataArmors);
Yanfly.IS.SynthesisRecipeCount = 0;
Yanfly.IS.SynthesisItemTotal = 0;
Yanfly.IS.SynthesisWeaponTotal = 0;
Yanfly.IS.SynthesisArmorTotal = 0;
this.processISNotetags1($dataItems, 0);
this.processISNotetags1($dataWeapons, 1);
this.processISNotetags1($dataArmors, 2);
Yanfly._loaded_YEP_ItemSynthesis = true;
}
return true;
};
DataManager.processISNotetagsI = function(group) {
if (Yanfly.ItemIdRef) return;
Yanfly.ItemIdRef = {};
for (var n = 1; n < group.length; n++) {
var obj = group;
if (obj.name.length <= 0) continue;
Yanfly.ItemIdRef = n;
}
};
DataManager.processISNotetagsW = function(group) {
if (Yanfly.WeaponIdRef) return;
Yanfly.WeaponIdRef = {};
for (var n = 1; n < group.length; n++) {
var obj = group;
if (obj.name.length <= 0) continue;
Yanfly.WeaponIdRef = n;
}
};
DataManager.processISNotetagsA = function(group) {
if (Yanfly.ArmorIdRef) return;
Yanfly.ArmorIdRef = {};
for (var n = 1; n < group.length; n++) {
var obj = group;
if (obj.name.length <= 0) continue;
Yanfly.ArmorIdRef = n;
}
};
DataManager.processISNotetags1 = function(group, type) {
var note1 = /<(?:ITEM RECIPE):*(\d+(?:\s*,\s*\d+)*)>/i;
var note2 = /<(?:ITEM RECIPE):(\d+)(?:THROUGH|to)(\d+)>/i;
var note3 = /<(?:WEAPON RECIPE):*(\d+(?:\s*,\s*\d+)*)>/i;
var note4 = /<(?:WEAPON RECIPE):(\d+)(?:THROUGH|to)(\d+)>/i;
var note5 = /<(?:ARMOR RECIPE):*(\d+(?:\s*,\s*\d+)*)>/i;
var note6 = /<(?:ARMOR RECIPE):(\d+)(?:THROUGH|to)(\d+)>/i;
var note7 = /<(?:SYNTHESIS INGREDIENTS)>/i;
var note8 = /<\/(?:SYNTHESIS INGREDIENTS)>/i;
var note9 = /<(?:MASK NAME):(.*)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group;
var notedata = obj.note.split(/+/);
obj.groupType = type;
obj.maskName = '';
obj.recipeItem = ;
obj.recipeWeapon = ;
obj.recipeArmor = ;
obj.synthCost = 0;
obj.synthIngredients = ;
var gatherIngredients = false;
obj.synthSeName = Yanfly.Param.ISDefSEName;
obj.synthSeVol = Yanfly.Param.ISDefVol;
obj.synthSePitch = Yanfly.Param.ISDefPitch;
obj.synthSePan = Yanfly.Param.ISDefPan;
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
var array = JSON.parse('');
obj.recipeItem = obj.recipeItem.concat(array);
} else if (line.match(note2)) {
var range = Yanfly.Util.getRange(parseInt(RegExp.$1),
parseInt(RegExp.$2));
obj.recipeItem = obj.recipeItem.concat(range);
} else if (line.match(note3)) {
var array = JSON.parse('');
obj.recipeWeapon = obj.recipeWeapon.concat(array);
} else if (line.match(note4)) {
var range = Yanfly.Util.getRange(parseInt(RegExp.$1),
parseInt(RegExp.$2));
obj.recipeWeapon = obj.recipeWeapon.concat(range);
} else if (line.match(note5)) {
var array = JSON.parse('');
obj.recipeArmor = obj.recipeArmor.concat(array);
} else if (line.match(note6)) {
var range = Yanfly.Util.getRange(parseInt(RegExp.$1),
parseInt(RegExp.$2));
obj.recipeArmor = obj.recipeArmor.concat(range);
} else if (line.match(note7)) {
gatherIngredients = true;
} else if (line.match(note8)) {
gatherIngredients = false;
} else if (line.match(note9)) {
obj.maskName = String(RegExp.$1);
} else if (gatherIngredients) {
this.addSynthesisIngredient(obj, line);
} else if (line.match(/<(?:SYNTHESIS SE):(.*)>/i)) {
obj.synthSeName = String(RegExp.$1);
} else if (line.match(/<(?:SYNTHESIS VOLUME):(\d+)>/i)) {
obj.synthSeVol = parseInt(RegExp.$1);
} else if (line.match(/<(?:SYNTHESIS PITCH):(\d+)>/i)) {
obj.synthSePitch = parseInt(RegExp.$1);
} else if (line.match(/<(?:SYNTHESIS PAN):(\d+)>/i)) {
obj.synthSePan = parseInt(RegExp.$1);
}
}
this.processRecipeCounts(obj);
}
};
DataManager.addSynthesisIngredient = function(obj, line) {
var ingType;
var ingId;
var ingValue = 1;
if (line.match(/GOLD:(\d+)/i)) {
obj.synthCost = parseInt(RegExp.$1);
return;
} else if (line.match(/ITEM(\d+):(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 0;
ingValue = parseInt(RegExp.$2);
} else if (line.match(/ITEM(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 0;
ingValue = 1;
} else if (line.match(/WEAPON(\d+):(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 1;
ingValue = parseInt(RegExp.$2);
} else if (line.match(/WEAPON(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 1;
ingValue = 1;
} else if (line.match(/ARMOR(\d+):(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 2;
ingValue = parseInt(RegExp.$2);
} else if (line.match(/ARMOR(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 2;
ingValue = 1;
} else if (line.match(/(.*):(\d+)/i)) {
var name = String(RegExp.$1).toUpperCase();
ingValue = parseInt(RegExp.$2);
if (Yanfly.ItemIdRef) {
ingId = Yanfly.ItemIdRef;
ingType = 0;
} else if (Yanfly.WeaponIdRef) {
ingId = Yanfly.WeaponIdRef;
ingType = 1;
} else if (Yanfly.ArmorIdRef) {
ingId = Yanfly.ArmorIdRef;
ingType = 2;
}
} else {
var name = line.toUpperCase();
ingValue = 1;
if (Yanfly.ItemIdRef) {
ingId = Yanfly.ItemIdRef;
ingType = 0;
} else if (Yanfly.WeaponIdRef) {
ingId = Yanfly.WeaponIdRef;
ingType = 1;
} else if (Yanfly.ArmorIdRef) {
ingId = Yanfly.ArmorIdRef;
ingType = 2;
}
}
if (!this.isSynthesisIngredientOk(ingId, ingType)) return;
var length = obj.synthIngredients.length;
obj.synthIngredients = ;
};
DataManager.isSynthesisIngredientOk = function(ingId, ingType) {
var item;
if (ingType === 0) item = $dataItems;
if (ingType === 1) item = $dataWeapons;
if (ingType === 2) item = $dataArmors;
if (!item) return false;
if (Imported.YEP_ItemCore && this.isIndependent(item)) return false;
return true;
};
DataManager.getSynthesisIngredient = function(item, index) {
var itemId = item.synthIngredients;
if (item.synthIngredients === 0) {
return $dataItems;
} else if (item.synthIngredients === 1) {
return $dataWeapons;
} if (item.synthIngredients === 2) {
return $dataArmors;
}
return null;
};
DataManager.getSynthesisQuantity = function(item, index) {
return item.synthIngredients;
};
DataManager.processRecipeCounts = function(obj) {
if (obj.recipeItem.length > 0 || obj.recipeWeapon.length > 0 ||
obj.recipeArmor.length > 0) {
Yanfly.IS.SynthesisRecipeCount += obj.recipeItem.length;
Yanfly.IS.SynthesisRecipeCount += obj.recipeWeapon.length;
Yanfly.IS.SynthesisRecipeCount += obj.recipeArmor.length;
}
if (obj.name === '') return;
if (obj.synthCost > 0 || obj.synthIngredients.length > 0) {
if (obj.groupType === 0) Yanfly.IS.SynthesisItemTotal += 1;
if (obj.groupType === 1) Yanfly.IS.SynthesisWeaponTotal += 1;
if (obj.groupType === 2) Yanfly.IS.SynthesisArmorTotal += 1;
}
};
//=============================================================================
// Game_System
//=============================================================================
Yanfly.IS.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
Yanfly.IS.Game_System_initialize.call(this);
this.initSynthesis();
};
Game_System.prototype.initSynthesis = function() {
this._showSynthesis = eval(Yanfly.Param.ISShowSynth);
this._enableSynthesis = eval(Yanfly.Param.ISEnableSynth);
this._synthedItems = ;
this._synthedWeapons = ;
this._synthedArmors = ;
};
Game_System.prototype.isShowSynthesis = function() {
return this._showSynthesis;
};
Game_System.prototype.isEnableSynthesis = function() {
return this._enableSynthesis;
};
Game_System.prototype.totalRecipes = function() {
var value = 0;
$gameParty.items().forEach(function(item) {
if (item.recipeItem && item.recipeItem.length > 0) {
value += item.recipeItem.length;
}
if (item.recipeWeapon && item.recipeWeapon.length > 0) {
value += item.recipeWeapon.length;
}
if (item.recipeArmor && item.recipeArmor.length > 0) {
value += item.recipeArmor.length;
}
}, this);
$gameParty.weapons().forEach(function(item) {
if (item.recipeItem && item.recipeItem.length > 0) {
value += item.recipeItem.length;
}
if (item.recipeWeapon && item.recipeWeapon.length > 0) {
value += item.recipeWeapon.length;
}
if (item.recipeArmor && item.recipeArmor.length > 0) {
value += item.recipeArmor.length;
}
}, this);
$gameParty.armors().forEach(function(item) {
if (item.recipeItem && item.recipeItem.length > 0) {
value += item.recipeItem.length;
}
if (item.recipeWeapon && item.recipeWeapon.length > 0) {
value += item.recipeWeapon.length;
}
if (item.recipeArmor && item.recipeArmor.length > 0) {
value += item.recipeArmor.length;
}
}, this);
return value;
};
Game_System.prototype.hasSynthed = function(item) {
if (!item) return false;
if (DataManager.isItem(item)) {
return this.synthedItems().contains(item.id);
} else if (DataManager.isWeapon(item)) {
return this.synthedWeapons().contains(item.id);
} else if (DataManager.isArmor(item)) {
return this.synthedArmors().contains(item.id);
}
return false;
};
Game_System.prototype.addSynth = function(item) {
if (!item) return false;
if (DataManager.isItem(item)) {
if (!this._synthedItems.contains(item.id)) {
this._synthedItems.push(item.id);
}
} else if (DataManager.isWeapon(item)) {
if (!this._synthedWeapons.contains(item.id)) {
this._synthedWeapons.push(item.id);
}
} else if (DataManager.isArmor(item)) {
if (!this._synthedArmors.contains(item.id)) {
this._synthedArmors.push(item.id);
}
}
};
Game_System.prototype.synthedItems = function() {
if (this._synthedItems === undefined) this._synthedItems = ;
return this._synthedItems;
};
Game_System.prototype.synthedWeapons = function() {
if (this._synthedWeapons === undefined) this._synthedWeapons = ;
return this._synthedWeapons;
};
Game_System.prototype.synthedArmors = function() {
if (this._synthedArmors === undefined) this._synthedArmors = ;
return this._synthedArmors;
};
Game_System.prototype.canSynthesize = function(item, times) {
if (!item) return false;
if ($gameParty.numItems(item) >= $gameParty.maxItems(item)) return false;
times = times || 1;
if (item.synthCost * times > $gameParty.gold()) return false;
for (var i = 0; i < item.synthIngredients.length; ++i) {
var ingredient = DataManager.getSynthesisIngredient(item, i);
var quantity = DataManager.getSynthesisQuantity(item, i);
if (quantity * times > $gameParty.numItems(ingredient)) return false;
}
return true;
};
Game_System.prototype.maxSynthesize = function(item) {
var maximum = $gameParty.maxItems(item) - $gameParty.numItems(item);
if (item.synthCost > 0) {
maximum = Math.min(maximum, $gameParty.gold() / item.synthCost);
}
for (var i = 0; i < item.synthIngredients.length; ++i) {
var ingredient = DataManager.getSynthesisIngredient(item, i);
var quantity = DataManager.getSynthesisQuantity(item, i);
maximum = Math.min(maximum, $gameParty.numItems(ingredient) / quantity);
}
return parseInt(Math.max(maximum, 0));
};
//=============================================================================
// Game_Interpreter
//=============================================================================
Yanfly.IS.Game_Interpreter_pluginCommand =
Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
Yanfly.IS.Game_Interpreter_pluginCommand.call(this, command, args)
if (command === 'OpenSynthesis') this.gotoSceneSynthesis(args);
if (command === 'ShowSynthesis') $gameSystem._showSynthesis = true;
if (command === 'HideSynthesis') $gameSystem._showSynthesis = false;
if (command === 'EnableSynthesis') $gameSystem._enableSynthesis = true;
if (command === 'DisableSynthesis') $gameSystem._enableSynthesis = false;
};
Game_Interpreter.prototype.gotoSceneSynthesis = function(args) {
if ($gameParty.inBattle()) return;
if (args && args.length >= 2) {
var text = args.toUpperCase();
var id = parseInt(args);
if (text === 'ITEM') {
$gameTemp._synthRecipe = $dataItems;
} else if (text === 'WEAPON') {
$gameTemp._synthRecipe = $dataWeapons;
} else if (text === 'ARMOR') {
$gameTemp._synthRecipe = $dataArmors;
}
}
SceneManager.push(Scene_Synthesis);
};
//=============================================================================
// Window_MenuCommand
//=============================================================================
Yanfly.IS.Window_MenuCommand_addOriginalCommands =
Window_MenuCommand.prototype.addOriginalCommands;
Window_MenuCommand.prototype.addOriginalCommands = function() {
Yanfly.IS.Window_MenuCommand_addOriginalCommands.call(this);
this.addSynthesisCommand();
};
Window_MenuCommand.prototype.addSynthesisCommand = function() {
if (!eval(Yanfly.Param.ISAutoPlaceCmd)) return;
if (!$gameSystem.isShowSynthesis()) return;
if (this.findSymbol('synthesis') > -1) return;
if ($gameSystem.totalRecipes() <= 0) return;
var text = Yanfly.Param.ISSynthCmd;
var enabled = $gameSystem.isEnableSynthesis();
this.addCommand(text, 'synthesis', enabled);
};
//=============================================================================
// Window_SynthesisCommand
//=============================================================================
function Window_SynthesisCommand() {
this.initialize.apply(this, arguments);
}
Window_SynthesisCommand.prototype = Object.create(Window_Command.prototype);
Window_SynthesisCommand.prototype.constructor = Window_SynthesisCommand;
Window_SynthesisCommand.prototype.initialize = function() {
Window_Command.prototype.initialize.call(this, 0, 0);
};
Window_SynthesisCommand.prototype.windowWidth = function() {
return 240;
};
Window_SynthesisCommand.prototype.numVisibleRows = function() {
return 4;
};
Window_SynthesisCommand.prototype.itemTextAlign = function() {
return Yanfly.Param.ISTextAlign;
};
Window_SynthesisCommand.prototype.makeCommandList = function() {
this.addItemCommands();
this.addCustomCommand();
this.addFinishCommand();
};
Window_SynthesisCommand.prototype.addItemCommands = function() {
if (Scene_Synthesis.availableItems().length > 0) {
this.addCommand(Yanfly.Param.ISItemCmd, 'item', true);
}
if (Scene_Synthesis.availableWeapons().length > 0) {
this.addCommand(Yanfly.Param.ISWeaponCmd, 'weapon', true);
}
if (Scene_Synthesis.availableArmors().length > 0) {
this.addCommand(Yanfly.Param.ISArmorCmd, 'armor', true);
}
};
Window_SynthesisCommand.prototype.addCustomCommand = function() {
};
Window_SynthesisCommand.prototype.addFinishCommand = function() {
this.addCommand(Yanfly.Param.ISFinishCmd, 'cancel', true);
};
//=============================================================================
// Window_SynthesisStatus
//=============================================================================
function Window_SynthesisStatus() {
this.initialize.apply(this, arguments);
}
Window_SynthesisStatus.prototype = Object.create(Window_Base.prototype);
Window_SynthesisStatus.prototype.constructor = Window_SynthesisStatus;
Window_SynthesisStatus.prototype.initialize = function(wx, wy, ww, wh) {
Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
this.refresh();
};
Window_SynthesisStatus.prototype.refresh = function() {
this.contents.clear();
var dy = 0;
dy = this.drawCollectedRecipes(dy);
dy = this.drawCraftedItems(dy);
dy = this.drawCraftedWeapons(dy);
dy = this.drawCraftedArmors(dy);
};
Window_SynthesisStatus.prototype.drawCollectedRecipes = function(dy) {
if (Yanfly.Param.ISColRecipes.length <= 0) return dy;
var dw = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISColRecipes, 0, dy, dw);
this.changeTextColor(this.normalColor());
var value = parseFloat($gameSystem.totalRecipes()) /
Yanfly.IS.SynthesisRecipeCount;
var text = String(parseInt(value * 100)) + '%';
this.drawText(text, 0, dy, dw, 'right');
dw -= this.textWidth('100%') + this.standardPadding() * 2;
var fmt = '%1/%2'
text = fmt.format($gameSystem.totalRecipes(),
Yanfly.IS.SynthesisRecipeCount);
this.drawText(text, 0, dy, dw, 'right');
return dy + this.lineHeight();
};
Window_SynthesisStatus.prototype.drawCraftedItems = function(dy) {
if (Yanfly.Param.ISCraftedItems.length <= 0) return dy;
var dw = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISCraftedItems, 0, dy, dw);
this.changeTextColor(this.normalColor());
var value = parseFloat($gameSystem.synthedItems().length) /
Math.max(1, Yanfly.IS.SynthesisItemTotal);
var text = String(parseInt(value * 100)) + '%';
this.drawText(text, 0, dy, dw, 'right');
dw -= this.textWidth('100%') + this.standardPadding() * 2;
var fmt = '%1/%2'
text = fmt.format($gameSystem.synthedItems().length,
Yanfly.IS.SynthesisItemTotal);
this.drawText(text, 0, dy, dw, 'right');
return dy + this.lineHeight();
};
Window_SynthesisStatus.prototype.drawCraftedWeapons = function(dy) {
if (Yanfly.Param.ISCraftedWeapons.length <= 0) return dy;
var dw = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISCraftedWeapons, 0, dy, dw);
this.changeTextColor(this.normalColor());
var value = parseFloat($gameSystem.synthedWeapons().length) /
Math.max(1, Yanfly.IS.SynthesisWeaponTotal);
var text = String(parseInt(value * 100)) + '%';
this.drawText(text, 0, dy, dw, 'right');
dw -= this.textWidth('100%') + this.standardPadding() * 2;
var fmt = '%1/%2'
text = fmt.format($gameSystem.synthedWeapons().length,
Yanfly.IS.SynthesisWeaponTotal);
this.drawText(text, 0, dy, dw, 'right');
return dy + this.lineHeight();
};
Window_SynthesisStatus.prototype.drawCraftedArmors = function(dy) {
if (Yanfly.Param.ISCraftedArmors.length <= 0) return dy;
var dw = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISCraftedArmors, 0, dy, dw);
this.changeTextColor(this.normalColor());
var value = parseFloat($gameSystem.synthedArmors().length) /
Math.max(1, Yanfly.IS.SynthesisArmorTotal);
var text = String(parseInt(value * 100)) + '%';
this.drawText(text, 0, dy, dw, 'right');
dw -= this.textWidth('100%') + this.standardPadding() * 2;
var fmt = '%1/%2'
text = fmt.format($gameSystem.synthedArmors().length,
Yanfly.IS.SynthesisArmorTotal);
this.drawText(text, 0, dy, dw, 'right');
return dy + this.lineHeight();
};
//=============================================================================
// Window_SynthesisList
//=============================================================================
function Window_SynthesisList() {
this.initialize.apply(this, arguments);
}
Window_SynthesisList.prototype = Object.create(Window_Selectable.prototype);
Window_SynthesisList.prototype.constructor = Window_SynthesisList;
Window_SynthesisList.prototype.initialize = function(commandWindow) {
this._commandWindow = commandWindow
var wy = commandWindow.y + commandWindow.height;
var ww = this.windowWidth();
var wh = Graphics.boxHeight - wy;
Window_Selectable.prototype.initialize.call(this, 0, wy, ww, wh);
this.refresh();
};
Window_SynthesisList.prototype.windowWidth = function() {
return Graphics.boxWidth / 2;
};
Window_SynthesisList.prototype.updateHelp = function() {
if (this._commandWindow.active) {
this._helpWindow.setText('');
} else if (eval(Yanfly.Param.ISMaskUnknown) &&
!$gameSystem.hasSynthed(this.item())) {
var text = Yanfly.Param.ISMaskHelpText;
if (this._helpWindow) this._helpWindow.setText(text);
} else {
this.setHelpWindowItem(this.item());
}
if (this._ingredients) {
this._ingredients.refresh(this.item());
}
};
Window_SynthesisList.prototype.item = function() {
return this._data;
};
Window_SynthesisList.prototype.isCurrentItemEnabled = function() {
return this.isEnabled(this.item());
};
Window_SynthesisList.prototype.isEnabled = function(item) {
if ($gamePlayer.isDebugThrough()) return true;
return $gameSystem.canSynthesize(item);
};
Window_SynthesisList.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
if (this._commandWindow) {
this.setCategory(this._commandWindow.currentSymbol())
}
};
Window_SynthesisList.prototype.setCategory = function(symbol) {
if (this._categorySymbol === symbol) return;
this._categorySymbol = symbol;
this.refresh();
};
Window_SynthesisList.prototype.refresh = function() {
if (this._commandWindow) {
this._categorySymbol = this._commandWindow.currentSymbol();
}
this.makeItemList();
this.createContents();
this.drawAllItems();
};
Window_SynthesisList.prototype.makeItemList = function() {
this._data = ;
if (this._commandWindow.currentSymbol() === 'item') {
this._data = Scene_Synthesis.availableItems();
} else if (this._commandWindow.currentSymbol() === 'weapon') {
this._data = Scene_Synthesis.availableWeapons();
} else if (this._commandWindow.currentSymbol() === 'armor') {
this._data = Scene_Synthesis.availableArmors();
}
};
Window_SynthesisList.prototype.maxItems = function() {
return this._data ? this._data.length : 1;
};
Window_SynthesisList.prototype.drawItem = function(index) {
var item = this._data;
if (!item) return;
this.resetFontSettings();
var rect = this.itemRect(index);
this.changePaintOpacity(this.isEnabled(item));
this.drawItemName(item, rect.x, rect.y, rect.width);
this.drawItemNumber(item, rect.x, rect.y, rect.width);
};
Window_SynthesisList.prototype.drawItemName = function(item, x, y, width) {
if (!item) return;
if ($gameSystem.hasSynthed(item)) {
Window_Base.prototype.drawItemName.call(this, item, x, y, width);
return;
}
var iconBoxWidth = Window_Base._iconWidth + 4;
this.resetTextColor();
this.drawIcon(item.iconIndex, x + 2, y + 2);
var text = item.name;
if (eval(Yanfly.Param.ISMaskUnknown)) {
this.contents.fontItalic = eval(Yanfly.Param.ISMaskItalic);
if (item.maskName !== '') {
text = item.maskName;
} else {
text = Yanfly.Util.maskString(text, Yanfly.Param.ISMaskText);
}
}
this.drawText(text, x + iconBoxWidth, y, width - iconBoxWidth);
this.contents.fontItalic = false;
};
Window_SynthesisList.prototype.drawItemNumber = function(item, wx, wy, ww) {
if (eval(Yanfly.Param.ISMaskUnknown) && !$gameSystem.hasSynthed(item)) {
return;
}
ww -= this.textPadding();
if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) {
var baseItem = DataManager.getBaseItem(item);
var value = $gameParty.numIndependentItems(baseItem);
var numItems = Yanfly.Util.toGroup(value);
} else {
var numItems = Yanfly.Util.toGroup($gameParty.numItems(item));
}
this.contents.fontSize = Yanfly.Param.ISQuantitySize;
this.drawText('\u00d7' + numItems, wx, wy, ww - 2, 'right');
};
//=============================================================================
// Window_SynthesisIngredients
//=============================================================================
function Window_SynthesisIngredients() {
this.initialize.apply(this, arguments);
}
Window_SynthesisIngredients.prototype = Object.create(Window_Base.prototype);
Window_SynthesisIngredients.prototype.constructor = Window_SynthesisIngredients;
Window_SynthesisIngredients.prototype.initialize = function(wx, wy, ww, wh) {
Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
};
Window_SynthesisIngredients.prototype.refresh = function(item) {
this.contents.clear();
if (!item) return;
this._item = item;
this.resetFontSettings();
this.resetTextColor();
this.drawItemIngredients(item, this.lineHeight());
};
Window_SynthesisIngredients.prototype.drawItemIngredients = function(item, wy) {
var ww = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISIngredientsList, 0, 0, ww, 'center');
this.changeTextColor(this.normalColor());
for (var i = 0; i < item.synthIngredients.length; ++i) {
wy = this.drawItemDetails(i, wy);
if (wy + this.lineheight > this.contents.height) break;
}
this.drawItemSynthCost(item, wy);
};
Window_SynthesisIngredients.prototype.drawItemDetails = function(index, wy) {
var ingredient = DataManager.getSynthesisIngredient(this._item, index);
var quantity = DataManager.getSynthesisQuantity(this._item, index);
var ww = this.contents.width;
if (!ingredient) return wy;
this.resetFontSettings();
this.drawItemName.call(this, ingredient, 0, wy, ww);
this.drawItemQuantity(index, wy);
return wy + this.lineHeight();
};
Window_SynthesisIngredients.prototype.drawItemQuantity = function(index, wy) {
var ingredient = DataManager.getSynthesisIngredient(this._item, index);
var quantity = DataManager.getSynthesisQuantity(this._item, index);
var ww = this.contents.width;
this.contents.fontSize = Yanfly.Param.ISQuantitySize;
this.changeTextColor(this.normalColor());
var num = '/' + Yanfly.Util.toGroup($gameParty.numItems(ingredient));
this.drawText(num, 0, wy, ww, 'right');
ww -= this.textWidth(num);
if ($gameParty.numItems(ingredient) >= quantity) {
this.changeTextColor(this.powerUpColor());
} else {
this.changeTextColor(this.powerDownColor());
}
var text = String(Yanfly.Util.toGroup(quantity));
this.drawText(text, 0, wy, ww, 'right');
}
Window_SynthesisIngredients.prototype.drawItemSynthCost = function(item, wy) {
if (item.synthCost <= 0) return;
this.resetFontSettings();
var value = item.synthCost;
var ww = this.contents.width - 4;
this.drawCurrencyValue(value, TextManager.currencyUnit, 0, wy, ww)
};
//=============================================================================
// Window_SynthesisNumber
//=============================================================================
function Window_SynthesisNumber() {
this.initialize.apply(this, arguments);
}
Window_SynthesisNumber.prototype = Object.create(Window_Selectable.prototype);
Window_SynthesisNumber.prototype.constructor = Window_SynthesisNumber;
Window_SynthesisNumber.prototype.initialize = function(ingredientsWindow) {
var wx = ingredientsWindow.x;
var wy = ingredientsWindow.y;
var ww = ingredientsWindow.width;
var wh = ingredientsWindow.height;
Window_Selectable.prototype.initialize.call(this, wx, wy, ww, wh);
this._index = 0;
this._item = null;
this._max = 1;
this._price = 0;
this._number = 1;
this._currencyUnit = TextManager.currencyUnit;
this.createButtons();
};
Window_SynthesisNumber.prototype.setup = function(item, max, price) {
this._item = item;
this._max = Math.max(1, Math.floor(max));
if ($gamePlayer.isDebugThrough()) this._max = $gameParty.maxItems(item);
this._price = price;
this._number = 1;
this.placeButtons();
this.updateButtonsVisiblity();
this.refresh();
};
Window_SynthesisNumber.prototype.setCurrencyUnit = function(currencyUnit) {
this._currencyUnit = currencyUnit;
this.refresh();
};
Window_SynthesisNumber.prototype.createButtons = function() {
var bitmap = ImageManager.loadSystem('ButtonSet');
var buttonWidth = 48;
var buttonHeight = 48;
this._buttons = ;
for (var i = 0; i < 5; i++) {
var button = new Sprite_Button();
var x = buttonWidth * i;
var w = buttonWidth * (i === 4 ? 2 : 1);
button.bitmap = bitmap;
button.setColdFrame(x, 0, w, buttonHeight);
button.setHotFrame(x, buttonHeight, w, buttonHeight);
button.visible = false;
this._buttons.push(button);
this.addChild(button);
}
this._buttons.setClickHandler(this.onButtonDown2.bind(this));
this._buttons.setClickHandler(this.onButtonDown.bind(this));
this._buttons.setClickHandler(this.onButtonUp.bind(this));
this._buttons.setClickHandler(this.onButtonUp2.bind(this));
this._buttons.setClickHandler(this.onButtonOk.bind(this));
};
Window_SynthesisNumber.prototype.placeButtons = function() {
var numButtons = this._buttons.length;
var spacing = 16;
var totalWidth = -spacing;
for (var i = 0; i < numButtons; i++) {
totalWidth += this._buttons.width + spacing;
}
var x = (this.width - totalWidth) / 2;
for (var j = 0; j < numButtons; j++) {
var button = this._buttons;
button.x = x;
button.y = this.buttonY();
x += button.width + spacing;
}
};
Window_SynthesisNumber.prototype.updateButtonsVisiblity = function() {
if (TouchInput.date > Input.date) {
this.showButtons();
} else {
this.hideButtons();
}
};
Window_SynthesisNumber.prototype.showButtons = function() {
for (var i = 0; i < this._buttons.length; i++) {
this._buttons.visible = true;
}
};
Window_SynthesisNumber.prototype.hideButtons = function() {
for (var i = 0; i < this._buttons.length; i++) {
this._buttons.visible = false;
}
};
Window_SynthesisNumber.prototype.refresh = function() {
this.contents.clear();
this.drawAmountText()
this.drawMultiplicationSign();
this.drawNumber();
this.drawIngredients();
};
Window_SynthesisNumber.prototype.drawAmountText = function() {
this.resetFontSettings();
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISAmountText, 0, 0, this.contents.width);
this.resetTextColor();
};
Window_SynthesisNumber.prototype.drawMultiplicationSign = function() {
var sign = '\u00d7';
var width = this.textWidth(sign);
var x = this.cursorX() - width * 2;
var y = this.itemY();
this.resetTextColor();
this.drawText(sign, x, y, width);
};
Window_SynthesisNumber.prototype.drawNumber = function() {
var x = this.cursorX();
var y = this.itemY();
var width = this.cursorWidth() - this.textPadding();
this.resetTextColor();
this.drawText(Yanfly.Util.toGroup(this._number), x, y, width, 'right');
};
Window_SynthesisNumber.prototype.drawIngredients = function() {
var wy = this.lineHeight();
for (var i = 0; i < this._item.synthIngredients.length; ++i) {
wy = this.drawItemDetails(i, wy);
if (wy + this.lineheight > this.contents.height) break;
}
this.drawItemSynthCost(this._item, wy);
};
Window_SynthesisNumber.prototype.drawItemDetails = function(index, wy) {
var ingredient = DataManager.getSynthesisIngredient(this._item, index);
var quantity = DataManager.getSynthesisQuantity(this._item, index);
var ww = this.contents.width;
if (!ingredient) return wy;
this.resetFontSettings();
this.drawItemName.call(this, ingredient, 0, wy, ww);
this.drawItemQuantity(index, wy);
return wy + this.lineHeight();
};
Window_SynthesisNumber.prototype.drawItemQuantity = function(index, wy) {
var ingredient = DataManager.getSynthesisIngredient(this._item, index);
var quantity = DataManager.getSynthesisQuantity(this._item, index);
quantity *= this.number();
var ww = this.contents.width;
this.contents.fontSize = Yanfly.Param.ISQuantitySize;
this.changeTextColor(this.normalColor());
var num = '/' + Yanfly.Util.toGroup($gameParty.numItems(ingredient));
this.drawText(num, 0, wy, ww, 'right');
ww -= this.textWidth(num);
if ($gameParty.numItems(ingredient) >= quantity) {
this.changeTextColor(this.powerUpColor());
} else {
this.changeTextColor(this.powerDownColor());
}
var text = String(Yanfly.Util.toGroup(quantity));
this.drawText(text, 0, wy, ww, 'right');
}
Window_SynthesisNumber.prototype.drawItemSynthCost = function(item, wy) {
if (item.synthCost <= 0) return;
this.resetFontSettings();
var value = item.synthCost * this.number();
var ww = this.contents.width - 4;
this.drawCurrencyValue(value, TextManager.currencyUnit, 0, wy, ww)
};
Window_SynthesisNumber.prototype.itemY = function() {
return 0;
};
Window_SynthesisNumber.prototype.priceY = function() {
return Math.round(this.contentsHeight() / 2 + this.lineHeight() / 2);
};
Window_SynthesisNumber.prototype.buttonY = function() {
return Math.round(this.priceY() + this.lineHeight() * 2.5);
};
Window_SynthesisNumber.prototype.cursorWidth = function() {
var digitWidth = this.textWidth('0');
return this.maxDigits() * digitWidth + this.textPadding() * 4;
};
Window_SynthesisNumber.prototype.cursorX = function() {
return this.contentsWidth() - this.cursorWidth() - this.textPadding();
};
Window_SynthesisNumber.prototype.maxDigits = function() {
if (this._item) {
var maxItem = parseInt($gameSystem.maxSynthesize(this._item));
maxItem = Math.max(1, maxItem);
if ($gamePlayer.isDebugThrough()) {
maxItem = $gameParty.maxItems(this._item);
}
return String(Yanfly.Util.toGroup(maxItem)).length;
}
return 2;
};
Window_SynthesisNumber.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
this.processNumberChange();
};
Window_SynthesisNumber.prototype.playOkSound = function() {
};
Window_SynthesisNumber.prototype.processNumberChange = function() {
if (this.isOpenAndActive()) {
if (Input.isRepeated('right')) {
this.changeNumber(1);
}
if (Input.isRepeated('left')) {
this.changeNumber(-1);
}
if (Input.isRepeated('up')) {
this.changeNumber(10);
}
if (Input.isRepeated('down')) {
this.changeNumber(-10);
}
}
};
Window_SynthesisNumber.prototype.changeNumber = function(amount) {
var lastNumber = this._number;
this._number = (this._number + amount).clamp(1, this._max);
if (this._number !== lastNumber) {
SoundManager.playCursor();
this.refresh();
}
};
Window_SynthesisNumber.prototype.updateCursor = function() {
this.setCursorRect(this.cursorX(), this.itemY(),
this.cursorWidth(), this.lineHeight());
};
Window_SynthesisNumber.prototype.onButtonUp = function() {
this.changeNumber(1);
};
Window_SynthesisNumber.prototype.onButtonUp2 = function() {
this.changeNumber(10);
};
Window_SynthesisNumber.prototype.onButtonDown = function() {
this.changeNumber(-1);
};
Window_SynthesisNumber.prototype.onButtonDown2 = function() {
this.changeNumber(-10);
};
Window_SynthesisNumber.prototype.onButtonOk = function() {
this.processOk();
};
Window_SynthesisNumber.prototype.number = function() {
return this._number;
};
//=============================================================================
// Scene_Menu
//=============================================================================
Yanfly.IS.Scene_Menu_createCommandWindow =
Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function() {
Yanfly.IS.Scene_Menu_createCommandWindow.call(this);
this._commandWindow.setHandler('synthesis',
this.commandSynthesis.bind(this));
};
Scene_Menu.prototype.commandSynthesis = function() {
SceneManager.push(Scene_Synthesis);
};
//=============================================================================
// Scene_Synthesis
//=============================================================================
function Scene_Synthesis() {
this.initialize.apply(this, arguments);
}
Scene_Synthesis.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Synthesis.prototype.constructor = Scene_Synthesis;
Scene_Synthesis.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_Synthesis.addSynthesisItem = function(obj, list) {
if (!obj) return;
if (obj.name.length <= 0) return;
if (obj.synthCost <= 0 && obj.synthIngredients.length <= 0) return;
if (list.contains(obj)) return;
list.push(obj);
};
Scene_Synthesis.getAvailableItems = function(type) {
var list = ;
var lib = this.availableLibrary();
var length = lib.length;
for (var i = 0; i < length; ++i) {
var set = lib;
this.getAvailableRecipes(set, type, list);
}
return list;
};
Scene_Synthesis.getAvailableRecipes = function(set, type, list) {
var length = set.length;
for (var i = 0; i < length; ++i) {
var item = set;
if (!item) continue;
if (type === 0 && item.recipeItem) {
this.getAvailableSynthesisItems(item.recipeItem, type, list);
} else if (type === 1 && item.recipeWeapon) {
this.getAvailableSynthesisItems(item.recipeWeapon, type, list);
} else if (type === 2 && item.recipeArmor) {
this.getAvailableSynthesisItems(item.recipeArmor, type, list);
}
}
};
Scene_Synthesis.getAvailableSynthesisItems = function(array, type, list) {
var length = array.length;
for (var i = 0; i < length; ++i) {
if (type === 0) var obj = $dataItems[array];
if (type === 1) var obj = $dataWeapons[array];
if (type === 2) var obj = $dataArmors[array];
this.addSynthesisItem(obj, list);
}
};
Scene_Synthesis.availableLibrary = function() {
if ($gameTemp._synthRecipe) {
return [];
}
var library = ;
library.push($gameParty.items());
library.push($gameParty.weapons());
library.push($gameParty.armors());
if (Yanfly.Param.ISEquRecipes) {
var length = $gameParty.allMembers().length;
for (var i = 0; i < length; ++i) {
var member = $gameParty.allMembers();
if (member) library.push(member.equips());
}
}
return library;
};
Scene_Synthesis.availableItems = function() {
var list = this.getAvailableItems(0);
return this.sortList(list);
};
Scene_Synthesis.availableWeapons = function() {
var list = this.getAvailableItems(1);
return this.sortList(list);
};
Scene_Synthesis.availableArmors = function() {
var list = this.getAvailableItems(2);
return this.sortList(list);
};
Scene_Synthesis.sortList = function(list) {
list.sort(function(a, b) {
var p1 = a.id;
var p2 = b.id;
if (p1 !== p2) {
return p1 - p2;
}
return b - a;
});
return list;
};
Scene_Synthesis.prototype.refreshWindows = function() {
this._statusWindow.refresh();
this._listWindow.refresh();
this._goldWindow.refresh();
this._ingredientsWindow.refresh(this._listWindow.item());
};
Scene_Synthesis.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createHelpWindow();
this.createCommandWindow();
this.createStatusWindow();
this.createListWindow();
this.createGoldWindow();
this.createIngredientsWindow();
this.createNumberWindow();
};
Scene_Synthesis.prototype.createCommandWindow = function() {
this._commandWindow = new Window_SynthesisCommand();
this._commandWindow.y = this._helpWindow.height;
this._commandWindow.setHandler('ok', this.onCommandOk.bind(this));
this._commandWindow.setHandler('cancel', this.onCancelOk.bind(this));
this.addWindow(this._commandWindow);
};
Scene_Synthesis.prototype.onCancelOk = function() {
$gameTemp._synthRecipe = undefined;
this.popScene();
};
Scene_Synthesis.prototype.createStatusWindow = function() {
var wx = this._commandWindow.width;
var wy = this._commandWindow.y;
var ww = Graphics.boxWidth - wx;
var wh = this._commandWindow.height;
this._statusWindow = new Window_SynthesisStatus(wx, wy, ww, wh);
this.addWindow(this._statusWindow);
};
Scene_Synthesis.prototype.createListWindow = function() {
this._listWindow = new Window_SynthesisList(this._commandWindow);
this._listWindow.setHandler('ok', this.onListOk.bind(this));
this._listWindow.setHandler('cancel', this.onListCancel.bind(this));
this._listWindow.setHelpWindow(this._helpWindow);
this.addWindow(this._listWindow);
};
Scene_Synthesis.prototype.createGoldWindow = function() {
var wx = this._listWindow.width;
this._goldWindow = new Window_Gold(wx, 0);
this._goldWindow.width = Graphics.boxWidth / 2;
this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height;
this._goldWindow.createContents();
this._goldWindow.refresh();
this.addWindow(this._goldWindow);
};
Scene_Synthesis.prototype.createIngredientsWindow = function() {
var wx = this._listWindow.width;
var wy = this._listWindow.y;
var ww = Graphics.boxWidth - wx;
var wh = Graphics.boxHeight - wy - this._goldWindow.height;
this._ingredientsWindow = new Window_SynthesisIngredients(wx, wy, ww, wh);
this._listWindow._ingredients = this._ingredientsWindow;
this.addWindow(this._ingredientsWindow);
};
Scene_Synthesis.prototype.createNumberWindow = function() {
this._numberWindow = new Window_SynthesisNumber(this._ingredientsWindow);
this._numberWindow.hide();
this._numberWindow.setHandler('ok', this.onNumberOk.bind(this));
this._numberWindow.setHandler('cancel', this.onNumberCancel.bind(this));
this.addWindow(this._numberWindow);
};
Scene_Synthesis.prototype.onCommandOk = function() {
this._listWindow.activate();
this._listWindow.select(0);
};
Scene_Synthesis.prototype.onListCancel = function() {
this._commandWindow.activate();
this._listWindow.select(-1);
this._listWindow.updateHelp();
};
Scene_Synthesis.prototype.onListOk = function() {
this._item = this._listWindow.item();
this._ingredientsWindow.hide();
this._numberWindow.setup(this._item, this.maxBuy(), this.buyingPrice());
this._numberWindow.setCurrencyUnit(this.currencyUnit());
this._numberWindow.show();
this._numberWindow.activate();
};
Scene_Synthesis.prototype.onNumberOk = function() {
this.playSynthesisSound();
this.doBuy(this._numberWindow.number());
this.endNumberInput();
this.refreshWindows();
};
Scene_Synthesis.prototype.playSynthesisSound = function() {
var se = {
name: this._item.synthSeName,
volume: this._item.synthSeVol,
pitch: this._item.synthSePitch,
pan: this._item.synthSePan
}
AudioManager.playSe(se);
};
Scene_Synthesis.prototype.doBuy = function(number) {
var price = number * this._item.synthCost;
$gameParty.loseGold(price);
for (var i = 0; i < this._item.synthIngredients.length; ++i) {
var ingredient = DataManager.getSynthesisIngredient(this._item, i);
var quantity = DataManager.getSynthesisQuantity(this._item, i);
quantity *= number;
if (!ingredient) continue;
$gameParty.loseItem(ingredient, quantity, false);
}
$gameParty.gainItem(this._item, number);
$gameSystem.addSynth(this._item);
};
Scene_Synthesis.prototype.endNumberInput = function() {
this._numberWindow.hide();
this._listWindow.activate();
this._ingredientsWindow.show();
};
Scene_Synthesis.prototype.onNumberCancel = function() {
SoundManager.playCancel();
this.endNumberInput();
};
Scene_Synthesis.prototype.maxBuy = function() {
return $gameSystem.maxSynthesize(this._item);
};
Scene_Synthesis.prototype.buyingPrice = function() {
return $gameSystem.maxSynthesize(this._item) * this._item.synthCost;
};
Scene_Synthesis.prototype.currencyUnit = function() {
return this._goldWindow.currencyUnit();
};
//=============================================================================
// New Function
//=============================================================================
Yanfly.Util = Yanfly.Util || {};
Yanfly.Util.getRange = function(n, m) {
var result = ;
for (var i = n; i <= m; ++i) result.push(i);
return result;
};
Yanfly.Util.maskString = function(str, mask) {
var text = mask;
if (mask.length === 1) {
text = Array(str.length + 1).join(mask);
return text;
} else {
return mask;
}
};
if (!Yanfly.Util.toGroup) {
Yanfly.Util.toGroup = function(inVal) {
return inVal;
}
};
//=============================================================================
// End of File
//=============================================================================
// Yanfly Engine Plugins - Item Synthesis
// YEP_ItemSynthesis.js
//=============================================================================
var Imported = Imported || {};
Imported.YEP_ItemSynthesis = true;
var Yanfly = Yanfly || {};
Yanfly.IS = Yanfly.IS || {};
//=============================================================================
/*:
* @plugindesc v1.06 Players can now craft their own items in-game
* through an item synthesis system.
* @author Yanfly Engine Plugins
*
* @param ---General---
* @default
*
* @param Synthesis Command
* @desc This is the text used for going to the item synthesis menu.
* @default Synthesis
*
* @param Show Command
* @desc Show the Synthesis command in the main menu by default?
* NO - false YES - true
* @default true
*
* @param Enable Command
* @desc Enable the Synthesis command in the main menu by default?
* NO - false YES - true
* @default true
*
* @param Auto Place Command
* @desc Allow this plugin to decide the menu placement position?
* NO - false YES - true
* @default true
*
* @param ---Command Window---
* @default
*
* @param Item Command
* @desc The command text used for synthesizing items.
* @default Craft Item
*
* @param Weapon Command
* @desc The command text used for synthesizing weapons.
* @default Craft Weapon
*
* @param Armor Command
* @desc The command text used for synthesizing armors.
* @default Craft Armor
*
* @param Finish Command
* @desc The command text used for exiting the synthesis scene.
* @default Finish
*
* @param Text Alignment
* @desc How to align the text for the command window.
* left center right
* @default center
*
* @param ---Status Window---
* @default
*
* @param Collected Recipes
* @desc Text used to represent total recipes collected.
* Leave this blank if you don't wish to show this.
* @default Collected Recipes
*
* @param Crafted Items
* @desc Text used to represent total items crafted.
* Leave this blank if you don't wish to show this.
* @default Crafted Items
*
* @param Crafted Weapons
* @desc Text used to represent total weapons crafted.
* Leave this blank if you don't wish to show this.
* @default Crafted Weapons
*
* @param Crafted Armors
* @desc Text used to represent total armors crafted.
* Leave this blank if you don't wish to show this.
* @default Crafted Armors
*
* @param ---List Window---
* @default
*
* @param Equipped Recipes
* @desc Check recipes from equipped items?
* NO - false YES - true
* @default true
*
* @param Mask Unknown
* @desc Mask the names of items that haven't been created yet?
* NO - false YES - true
* @default true
*
* @param Mask Text
* @desc This will be used to mask over each letter for unknown item
* names that are to be synthesized.
* @default ?
*
* @param Mask Italic
* @desc Causes the name for unknown items to appear in italic.
* @default true
*
* @param Mask Help Text
* @desc This is the text that will be displayed in the help window
* if the item is masked.
* @default This item has not been synthesized yet.
*
* @param Ingredients Text
* @desc This is the text used to describe the Ingredients list.
* @default Ingredients
*
* @param Amount Text
* @desc This is the text used for the amount to synthesize.
* @default Quantity
*
* @param Quantity Text Size
* @desc This is the text size used for the item quantity.
* Default: 28
* @default 20
*
* @param ---Sound---
* @default
*
* @param Default SE
* @desc This is the default SE played when synthesizing an item.
* This is case sensitive. Do not include the extension.
* @default Twine
*
* @param Default Volume
* @desc This is the default volume when synthesizing an item.
* @default 100
*
* @param Default Pitch
* @desc This is the default pitch when synthesizing an item.
* @default 100
*
* @param Default Pan
* @desc This is the default pan when synthesizing an item.
* @default 0
*
* @help
* ============================================================================
* Introduction
* ============================================================================
*
* Item synthesis is now a pretty common aspect of most RPG's where the player
* can craft their own items after acquiring recipes. This plugin enables your
* players to be able to do that after acquiring the said recipes. Recipes can
* come in the form of items, weapons, and/or armors and transcribed in them
* are what items, weapons, and/or armors they can make. These items can be
* made from the main menu and/or synthesis locations!
*
* ============================================================================
* Notetags
* ============================================================================
*
* To allow the player the ability to craft a certain item, that item must be
* included in a recipe notetag in an item that the player possesses.
*
* Item, Weapon, and Armor Notetags:
* <Item Recipe: x>
* <Item Recipe: x, x, x>
* <Item Recipe: x to y>
* This will change this item into a recipe for x item(s). As long as this
* item is in possession by the party as a whole, item(s) x can be
* synthesized by the player provided that the player has the proper quantity
* of ingredients.
* * Note: Entries without names will not be included. Entries without both a
* synthesis cost and without an ingredient list will not be included.
*
* <Weapon Recipe: x>
* <Weapon Recipe: x, x, x>
* <Weapon Recipe: x to y>
* This will change this item into a recipe for x weapon(s). As long as this
* item is in possession by the party as a whole, weapon(s) x can be
* synthesized by the player provided that the player has the proper quantity
* of ingredients.
* * Note: Entries without names will not be included. Entries without both a
* synthesis cost and without an ingredient list will not be included.
*
* <Armor Recipe: x>
* <Armor Recipe: x, x, x>
* <Armor Recipe: x to y>
* This will change this item into a recipe for x armor(s). As long as this
* item is in possession by the party as a whole, armor(s) x can be
* synthesized by the player provided that the player has the proper quantity
* of ingredients.
* * Note: Entries without names will not be included. Entries without both a
* synthesis cost and without an ingredient list will not be included.
*
* <Synthesis Ingredients>
* item id
* item id: x
* weapon id
* weapon id: x
* armor id
* armor id: x
* gold: x
* named item
* named item: x
* </Synthesis Ingredients>
* Using the above tag in an item will set those items as the ingredients
* required for the player to synthesize. Replace "id" with the proper item,
* weapon, or armor ID's. If no ":x" is used, the database will register that
* as only needing 1 of that item as an ingredient. If "gold: x" is used,
* that will be the cost required to synthesize the item.
*
* If you are using named entries, priority will be given to the highest ID
* in the order of items, weapons, then armors.
*
* * Note: If you are using Item Core, Independent Items cannot become an
* ingredient for a recipe and will therefore be automatically omitted.
*
* <Mask Name: x>
* If you are masking unknown items' names, you can change the text shown for
* the unknown item with x. This will cause the game to use the mask name
* instead of the usual ??? (if that's what you're using) to mask the item.
* This can give a player a general idea of what they may be synthesizing
* such as "Strange Liquid" or "Weird Crystal".
*
* ============================================================================
* Plugin Commands
* ============================================================================
*
* The following are Plugin Commands you may use with events.
*
* Plugin Command:
* OpenSynthesis Opens up the Synthesis Scene from the field.
* ShowSynthesis Shows the Synthesis command from the main menu.
* HideSynthesis Hides the Synthesis command from the main menu.
* EnableSynthesis Enables the Synthesis command from the main menu.
* DisableSynthesis Disables the Synthesis command from the main menu.
*
* For those who wish to make the player synthesize only specific recipes, you
* can use the following command.
*
* OpenSynthesis Item 15 Recipe
* - or -
* OpenSynthesis Weapon 20 Recipe
* - or -
* OpenSynthesis Armor 30 Recipe
*
* This will make the synthesis menu, when opened up, only allow the recipes of
* the Item 15, Weapon 20, or Armor 30 without needing it and not showing the
* recipes of any recipe items within the player's inventory.
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 1.06:
* - Fixed an error with the calculation of total recipes.
*
* Version 1.05:
* - Updated for RPG Maker MV version 1.1.0.
*
* Version 1.04:
* - Added failsafes to prevent crashes from saved games that did not have this
* plugin already installed.
*
* Version 1.03a:
* - Fixed a bug that caused a crash for OpenSynthesis recipe commands.
* - Fixed an issue with recipe counts not appearing right.
*
* Version 1.02:
* - Added 'Equipped Recipes' plugin parameter. If enabled, this will allow the
* Item Synthesis menu to check your party's equipment to see if any of them
* are recipe holders.
*
* Version 1.01:
* - Fixed a bug with the synthesis gold costs taking more than they should.
* - Extended the OpenSynthesis plugin command. If you add Item, Weapon, or
* Armor after the command along with an ID, the synthesis menu will only show
* the items listed on the recipe for Item x, Weapon x, or Armor x.
*
* Version 1.00:
* - Finished Plugin!
*/
//=============================================================================
//=============================================================================
// Parameter Variables
//=============================================================================
Yanfly.Parameters = PluginManager.parameters('YEP_ItemSynthesis');
Yanfly.Param = Yanfly.Param || {};
Yanfly.Param.ISSynthCmd = String(Yanfly.Parameters);
Yanfly.Param.ISShowSynth = String(Yanfly.Parameters);
Yanfly.Param.ISEnableSynth = String(Yanfly.Parameters);
Yanfly.Param.ISAutoPlaceCmd = String(Yanfly.Parameters);
Yanfly.Param.ISItemCmd = String(Yanfly.Parameters);
Yanfly.Param.ISWeaponCmd = String(Yanfly.Parameters);
Yanfly.Param.ISArmorCmd = String(Yanfly.Parameters);
Yanfly.Param.ISFinishCmd = String(Yanfly.Parameters);
Yanfly.Param.ISTextAlign = String(Yanfly.Parameters);
Yanfly.Param.ISColRecipes = String(Yanfly.Parameters);
Yanfly.Param.ISCraftedItems = String(Yanfly.Parameters);
Yanfly.Param.ISCraftedWeapons = String(Yanfly.Parameters);
Yanfly.Param.ISCraftedArmors = String(Yanfly.Parameters);
Yanfly.Param.ISEquRecipes = eval(String(Yanfly.Parameters));
Yanfly.Param.ISMaskUnknown = String(Yanfly.Parameters);
Yanfly.Param.ISMaskText = String(Yanfly.Parameters);
Yanfly.Param.ISMaskItalic = String(Yanfly.Parameters);
Yanfly.Param.ISMaskHelpText = String(Yanfly.Parameters);
Yanfly.Param.ISIngredientsList = String(Yanfly.Parameters);
Yanfly.Param.ISAmountText = String(Yanfly.Parameters);
Yanfly.Param.ISQuantitySize = Number(Yanfly.Parameters);
Yanfly.Param.ISDefSEName = String(Yanfly.Parameters);
Yanfly.Param.ISDefVol = Number(Yanfly.Parameters);
Yanfly.Param.ISDefPitch = Number(Yanfly.Parameters);
Yanfly.Param.ISDefPant = Number(Yanfly.Parameters);
//=============================================================================
// DataManager
//=============================================================================
Yanfly.IS.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!Yanfly.IS.DataManager_isDatabaseLoaded.call(this)) return false;
if (!Yanfly._loaded_YEP_ItemSynthesis) {
this.processISNotetagsI($dataItems);
this.processISNotetagsW($dataWeapons);
this.processISNotetagsA($dataArmors);
Yanfly.IS.SynthesisRecipeCount = 0;
Yanfly.IS.SynthesisItemTotal = 0;
Yanfly.IS.SynthesisWeaponTotal = 0;
Yanfly.IS.SynthesisArmorTotal = 0;
this.processISNotetags1($dataItems, 0);
this.processISNotetags1($dataWeapons, 1);
this.processISNotetags1($dataArmors, 2);
Yanfly._loaded_YEP_ItemSynthesis = true;
}
return true;
};
DataManager.processISNotetagsI = function(group) {
if (Yanfly.ItemIdRef) return;
Yanfly.ItemIdRef = {};
for (var n = 1; n < group.length; n++) {
var obj = group;
if (obj.name.length <= 0) continue;
Yanfly.ItemIdRef = n;
}
};
DataManager.processISNotetagsW = function(group) {
if (Yanfly.WeaponIdRef) return;
Yanfly.WeaponIdRef = {};
for (var n = 1; n < group.length; n++) {
var obj = group;
if (obj.name.length <= 0) continue;
Yanfly.WeaponIdRef = n;
}
};
DataManager.processISNotetagsA = function(group) {
if (Yanfly.ArmorIdRef) return;
Yanfly.ArmorIdRef = {};
for (var n = 1; n < group.length; n++) {
var obj = group;
if (obj.name.length <= 0) continue;
Yanfly.ArmorIdRef = n;
}
};
DataManager.processISNotetags1 = function(group, type) {
var note1 = /<(?:ITEM RECIPE):*(\d+(?:\s*,\s*\d+)*)>/i;
var note2 = /<(?:ITEM RECIPE):(\d+)(?:THROUGH|to)(\d+)>/i;
var note3 = /<(?:WEAPON RECIPE):*(\d+(?:\s*,\s*\d+)*)>/i;
var note4 = /<(?:WEAPON RECIPE):(\d+)(?:THROUGH|to)(\d+)>/i;
var note5 = /<(?:ARMOR RECIPE):*(\d+(?:\s*,\s*\d+)*)>/i;
var note6 = /<(?:ARMOR RECIPE):(\d+)(?:THROUGH|to)(\d+)>/i;
var note7 = /<(?:SYNTHESIS INGREDIENTS)>/i;
var note8 = /<\/(?:SYNTHESIS INGREDIENTS)>/i;
var note9 = /<(?:MASK NAME):(.*)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group;
var notedata = obj.note.split(/+/);
obj.groupType = type;
obj.maskName = '';
obj.recipeItem = ;
obj.recipeWeapon = ;
obj.recipeArmor = ;
obj.synthCost = 0;
obj.synthIngredients = ;
var gatherIngredients = false;
obj.synthSeName = Yanfly.Param.ISDefSEName;
obj.synthSeVol = Yanfly.Param.ISDefVol;
obj.synthSePitch = Yanfly.Param.ISDefPitch;
obj.synthSePan = Yanfly.Param.ISDefPan;
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
var array = JSON.parse('');
obj.recipeItem = obj.recipeItem.concat(array);
} else if (line.match(note2)) {
var range = Yanfly.Util.getRange(parseInt(RegExp.$1),
parseInt(RegExp.$2));
obj.recipeItem = obj.recipeItem.concat(range);
} else if (line.match(note3)) {
var array = JSON.parse('');
obj.recipeWeapon = obj.recipeWeapon.concat(array);
} else if (line.match(note4)) {
var range = Yanfly.Util.getRange(parseInt(RegExp.$1),
parseInt(RegExp.$2));
obj.recipeWeapon = obj.recipeWeapon.concat(range);
} else if (line.match(note5)) {
var array = JSON.parse('');
obj.recipeArmor = obj.recipeArmor.concat(array);
} else if (line.match(note6)) {
var range = Yanfly.Util.getRange(parseInt(RegExp.$1),
parseInt(RegExp.$2));
obj.recipeArmor = obj.recipeArmor.concat(range);
} else if (line.match(note7)) {
gatherIngredients = true;
} else if (line.match(note8)) {
gatherIngredients = false;
} else if (line.match(note9)) {
obj.maskName = String(RegExp.$1);
} else if (gatherIngredients) {
this.addSynthesisIngredient(obj, line);
} else if (line.match(/<(?:SYNTHESIS SE):(.*)>/i)) {
obj.synthSeName = String(RegExp.$1);
} else if (line.match(/<(?:SYNTHESIS VOLUME):(\d+)>/i)) {
obj.synthSeVol = parseInt(RegExp.$1);
} else if (line.match(/<(?:SYNTHESIS PITCH):(\d+)>/i)) {
obj.synthSePitch = parseInt(RegExp.$1);
} else if (line.match(/<(?:SYNTHESIS PAN):(\d+)>/i)) {
obj.synthSePan = parseInt(RegExp.$1);
}
}
this.processRecipeCounts(obj);
}
};
DataManager.addSynthesisIngredient = function(obj, line) {
var ingType;
var ingId;
var ingValue = 1;
if (line.match(/GOLD:(\d+)/i)) {
obj.synthCost = parseInt(RegExp.$1);
return;
} else if (line.match(/ITEM(\d+):(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 0;
ingValue = parseInt(RegExp.$2);
} else if (line.match(/ITEM(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 0;
ingValue = 1;
} else if (line.match(/WEAPON(\d+):(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 1;
ingValue = parseInt(RegExp.$2);
} else if (line.match(/WEAPON(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 1;
ingValue = 1;
} else if (line.match(/ARMOR(\d+):(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 2;
ingValue = parseInt(RegExp.$2);
} else if (line.match(/ARMOR(\d+)/i)) {
ingId = parseInt(RegExp.$1);
ingType = 2;
ingValue = 1;
} else if (line.match(/(.*):(\d+)/i)) {
var name = String(RegExp.$1).toUpperCase();
ingValue = parseInt(RegExp.$2);
if (Yanfly.ItemIdRef) {
ingId = Yanfly.ItemIdRef;
ingType = 0;
} else if (Yanfly.WeaponIdRef) {
ingId = Yanfly.WeaponIdRef;
ingType = 1;
} else if (Yanfly.ArmorIdRef) {
ingId = Yanfly.ArmorIdRef;
ingType = 2;
}
} else {
var name = line.toUpperCase();
ingValue = 1;
if (Yanfly.ItemIdRef) {
ingId = Yanfly.ItemIdRef;
ingType = 0;
} else if (Yanfly.WeaponIdRef) {
ingId = Yanfly.WeaponIdRef;
ingType = 1;
} else if (Yanfly.ArmorIdRef) {
ingId = Yanfly.ArmorIdRef;
ingType = 2;
}
}
if (!this.isSynthesisIngredientOk(ingId, ingType)) return;
var length = obj.synthIngredients.length;
obj.synthIngredients = ;
};
DataManager.isSynthesisIngredientOk = function(ingId, ingType) {
var item;
if (ingType === 0) item = $dataItems;
if (ingType === 1) item = $dataWeapons;
if (ingType === 2) item = $dataArmors;
if (!item) return false;
if (Imported.YEP_ItemCore && this.isIndependent(item)) return false;
return true;
};
DataManager.getSynthesisIngredient = function(item, index) {
var itemId = item.synthIngredients;
if (item.synthIngredients === 0) {
return $dataItems;
} else if (item.synthIngredients === 1) {
return $dataWeapons;
} if (item.synthIngredients === 2) {
return $dataArmors;
}
return null;
};
DataManager.getSynthesisQuantity = function(item, index) {
return item.synthIngredients;
};
DataManager.processRecipeCounts = function(obj) {
if (obj.recipeItem.length > 0 || obj.recipeWeapon.length > 0 ||
obj.recipeArmor.length > 0) {
Yanfly.IS.SynthesisRecipeCount += obj.recipeItem.length;
Yanfly.IS.SynthesisRecipeCount += obj.recipeWeapon.length;
Yanfly.IS.SynthesisRecipeCount += obj.recipeArmor.length;
}
if (obj.name === '') return;
if (obj.synthCost > 0 || obj.synthIngredients.length > 0) {
if (obj.groupType === 0) Yanfly.IS.SynthesisItemTotal += 1;
if (obj.groupType === 1) Yanfly.IS.SynthesisWeaponTotal += 1;
if (obj.groupType === 2) Yanfly.IS.SynthesisArmorTotal += 1;
}
};
//=============================================================================
// Game_System
//=============================================================================
Yanfly.IS.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
Yanfly.IS.Game_System_initialize.call(this);
this.initSynthesis();
};
Game_System.prototype.initSynthesis = function() {
this._showSynthesis = eval(Yanfly.Param.ISShowSynth);
this._enableSynthesis = eval(Yanfly.Param.ISEnableSynth);
this._synthedItems = ;
this._synthedWeapons = ;
this._synthedArmors = ;
};
Game_System.prototype.isShowSynthesis = function() {
return this._showSynthesis;
};
Game_System.prototype.isEnableSynthesis = function() {
return this._enableSynthesis;
};
Game_System.prototype.totalRecipes = function() {
var value = 0;
$gameParty.items().forEach(function(item) {
if (item.recipeItem && item.recipeItem.length > 0) {
value += item.recipeItem.length;
}
if (item.recipeWeapon && item.recipeWeapon.length > 0) {
value += item.recipeWeapon.length;
}
if (item.recipeArmor && item.recipeArmor.length > 0) {
value += item.recipeArmor.length;
}
}, this);
$gameParty.weapons().forEach(function(item) {
if (item.recipeItem && item.recipeItem.length > 0) {
value += item.recipeItem.length;
}
if (item.recipeWeapon && item.recipeWeapon.length > 0) {
value += item.recipeWeapon.length;
}
if (item.recipeArmor && item.recipeArmor.length > 0) {
value += item.recipeArmor.length;
}
}, this);
$gameParty.armors().forEach(function(item) {
if (item.recipeItem && item.recipeItem.length > 0) {
value += item.recipeItem.length;
}
if (item.recipeWeapon && item.recipeWeapon.length > 0) {
value += item.recipeWeapon.length;
}
if (item.recipeArmor && item.recipeArmor.length > 0) {
value += item.recipeArmor.length;
}
}, this);
return value;
};
Game_System.prototype.hasSynthed = function(item) {
if (!item) return false;
if (DataManager.isItem(item)) {
return this.synthedItems().contains(item.id);
} else if (DataManager.isWeapon(item)) {
return this.synthedWeapons().contains(item.id);
} else if (DataManager.isArmor(item)) {
return this.synthedArmors().contains(item.id);
}
return false;
};
Game_System.prototype.addSynth = function(item) {
if (!item) return false;
if (DataManager.isItem(item)) {
if (!this._synthedItems.contains(item.id)) {
this._synthedItems.push(item.id);
}
} else if (DataManager.isWeapon(item)) {
if (!this._synthedWeapons.contains(item.id)) {
this._synthedWeapons.push(item.id);
}
} else if (DataManager.isArmor(item)) {
if (!this._synthedArmors.contains(item.id)) {
this._synthedArmors.push(item.id);
}
}
};
Game_System.prototype.synthedItems = function() {
if (this._synthedItems === undefined) this._synthedItems = ;
return this._synthedItems;
};
Game_System.prototype.synthedWeapons = function() {
if (this._synthedWeapons === undefined) this._synthedWeapons = ;
return this._synthedWeapons;
};
Game_System.prototype.synthedArmors = function() {
if (this._synthedArmors === undefined) this._synthedArmors = ;
return this._synthedArmors;
};
Game_System.prototype.canSynthesize = function(item, times) {
if (!item) return false;
if ($gameParty.numItems(item) >= $gameParty.maxItems(item)) return false;
times = times || 1;
if (item.synthCost * times > $gameParty.gold()) return false;
for (var i = 0; i < item.synthIngredients.length; ++i) {
var ingredient = DataManager.getSynthesisIngredient(item, i);
var quantity = DataManager.getSynthesisQuantity(item, i);
if (quantity * times > $gameParty.numItems(ingredient)) return false;
}
return true;
};
Game_System.prototype.maxSynthesize = function(item) {
var maximum = $gameParty.maxItems(item) - $gameParty.numItems(item);
if (item.synthCost > 0) {
maximum = Math.min(maximum, $gameParty.gold() / item.synthCost);
}
for (var i = 0; i < item.synthIngredients.length; ++i) {
var ingredient = DataManager.getSynthesisIngredient(item, i);
var quantity = DataManager.getSynthesisQuantity(item, i);
maximum = Math.min(maximum, $gameParty.numItems(ingredient) / quantity);
}
return parseInt(Math.max(maximum, 0));
};
//=============================================================================
// Game_Interpreter
//=============================================================================
Yanfly.IS.Game_Interpreter_pluginCommand =
Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
Yanfly.IS.Game_Interpreter_pluginCommand.call(this, command, args)
if (command === 'OpenSynthesis') this.gotoSceneSynthesis(args);
if (command === 'ShowSynthesis') $gameSystem._showSynthesis = true;
if (command === 'HideSynthesis') $gameSystem._showSynthesis = false;
if (command === 'EnableSynthesis') $gameSystem._enableSynthesis = true;
if (command === 'DisableSynthesis') $gameSystem._enableSynthesis = false;
};
Game_Interpreter.prototype.gotoSceneSynthesis = function(args) {
if ($gameParty.inBattle()) return;
if (args && args.length >= 2) {
var text = args.toUpperCase();
var id = parseInt(args);
if (text === 'ITEM') {
$gameTemp._synthRecipe = $dataItems;
} else if (text === 'WEAPON') {
$gameTemp._synthRecipe = $dataWeapons;
} else if (text === 'ARMOR') {
$gameTemp._synthRecipe = $dataArmors;
}
}
SceneManager.push(Scene_Synthesis);
};
//=============================================================================
// Window_MenuCommand
//=============================================================================
Yanfly.IS.Window_MenuCommand_addOriginalCommands =
Window_MenuCommand.prototype.addOriginalCommands;
Window_MenuCommand.prototype.addOriginalCommands = function() {
Yanfly.IS.Window_MenuCommand_addOriginalCommands.call(this);
this.addSynthesisCommand();
};
Window_MenuCommand.prototype.addSynthesisCommand = function() {
if (!eval(Yanfly.Param.ISAutoPlaceCmd)) return;
if (!$gameSystem.isShowSynthesis()) return;
if (this.findSymbol('synthesis') > -1) return;
if ($gameSystem.totalRecipes() <= 0) return;
var text = Yanfly.Param.ISSynthCmd;
var enabled = $gameSystem.isEnableSynthesis();
this.addCommand(text, 'synthesis', enabled);
};
//=============================================================================
// Window_SynthesisCommand
//=============================================================================
function Window_SynthesisCommand() {
this.initialize.apply(this, arguments);
}
Window_SynthesisCommand.prototype = Object.create(Window_Command.prototype);
Window_SynthesisCommand.prototype.constructor = Window_SynthesisCommand;
Window_SynthesisCommand.prototype.initialize = function() {
Window_Command.prototype.initialize.call(this, 0, 0);
};
Window_SynthesisCommand.prototype.windowWidth = function() {
return 240;
};
Window_SynthesisCommand.prototype.numVisibleRows = function() {
return 4;
};
Window_SynthesisCommand.prototype.itemTextAlign = function() {
return Yanfly.Param.ISTextAlign;
};
Window_SynthesisCommand.prototype.makeCommandList = function() {
this.addItemCommands();
this.addCustomCommand();
this.addFinishCommand();
};
Window_SynthesisCommand.prototype.addItemCommands = function() {
if (Scene_Synthesis.availableItems().length > 0) {
this.addCommand(Yanfly.Param.ISItemCmd, 'item', true);
}
if (Scene_Synthesis.availableWeapons().length > 0) {
this.addCommand(Yanfly.Param.ISWeaponCmd, 'weapon', true);
}
if (Scene_Synthesis.availableArmors().length > 0) {
this.addCommand(Yanfly.Param.ISArmorCmd, 'armor', true);
}
};
Window_SynthesisCommand.prototype.addCustomCommand = function() {
};
Window_SynthesisCommand.prototype.addFinishCommand = function() {
this.addCommand(Yanfly.Param.ISFinishCmd, 'cancel', true);
};
//=============================================================================
// Window_SynthesisStatus
//=============================================================================
function Window_SynthesisStatus() {
this.initialize.apply(this, arguments);
}
Window_SynthesisStatus.prototype = Object.create(Window_Base.prototype);
Window_SynthesisStatus.prototype.constructor = Window_SynthesisStatus;
Window_SynthesisStatus.prototype.initialize = function(wx, wy, ww, wh) {
Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
this.refresh();
};
Window_SynthesisStatus.prototype.refresh = function() {
this.contents.clear();
var dy = 0;
dy = this.drawCollectedRecipes(dy);
dy = this.drawCraftedItems(dy);
dy = this.drawCraftedWeapons(dy);
dy = this.drawCraftedArmors(dy);
};
Window_SynthesisStatus.prototype.drawCollectedRecipes = function(dy) {
if (Yanfly.Param.ISColRecipes.length <= 0) return dy;
var dw = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISColRecipes, 0, dy, dw);
this.changeTextColor(this.normalColor());
var value = parseFloat($gameSystem.totalRecipes()) /
Yanfly.IS.SynthesisRecipeCount;
var text = String(parseInt(value * 100)) + '%';
this.drawText(text, 0, dy, dw, 'right');
dw -= this.textWidth('100%') + this.standardPadding() * 2;
var fmt = '%1/%2'
text = fmt.format($gameSystem.totalRecipes(),
Yanfly.IS.SynthesisRecipeCount);
this.drawText(text, 0, dy, dw, 'right');
return dy + this.lineHeight();
};
Window_SynthesisStatus.prototype.drawCraftedItems = function(dy) {
if (Yanfly.Param.ISCraftedItems.length <= 0) return dy;
var dw = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISCraftedItems, 0, dy, dw);
this.changeTextColor(this.normalColor());
var value = parseFloat($gameSystem.synthedItems().length) /
Math.max(1, Yanfly.IS.SynthesisItemTotal);
var text = String(parseInt(value * 100)) + '%';
this.drawText(text, 0, dy, dw, 'right');
dw -= this.textWidth('100%') + this.standardPadding() * 2;
var fmt = '%1/%2'
text = fmt.format($gameSystem.synthedItems().length,
Yanfly.IS.SynthesisItemTotal);
this.drawText(text, 0, dy, dw, 'right');
return dy + this.lineHeight();
};
Window_SynthesisStatus.prototype.drawCraftedWeapons = function(dy) {
if (Yanfly.Param.ISCraftedWeapons.length <= 0) return dy;
var dw = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISCraftedWeapons, 0, dy, dw);
this.changeTextColor(this.normalColor());
var value = parseFloat($gameSystem.synthedWeapons().length) /
Math.max(1, Yanfly.IS.SynthesisWeaponTotal);
var text = String(parseInt(value * 100)) + '%';
this.drawText(text, 0, dy, dw, 'right');
dw -= this.textWidth('100%') + this.standardPadding() * 2;
var fmt = '%1/%2'
text = fmt.format($gameSystem.synthedWeapons().length,
Yanfly.IS.SynthesisWeaponTotal);
this.drawText(text, 0, dy, dw, 'right');
return dy + this.lineHeight();
};
Window_SynthesisStatus.prototype.drawCraftedArmors = function(dy) {
if (Yanfly.Param.ISCraftedArmors.length <= 0) return dy;
var dw = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISCraftedArmors, 0, dy, dw);
this.changeTextColor(this.normalColor());
var value = parseFloat($gameSystem.synthedArmors().length) /
Math.max(1, Yanfly.IS.SynthesisArmorTotal);
var text = String(parseInt(value * 100)) + '%';
this.drawText(text, 0, dy, dw, 'right');
dw -= this.textWidth('100%') + this.standardPadding() * 2;
var fmt = '%1/%2'
text = fmt.format($gameSystem.synthedArmors().length,
Yanfly.IS.SynthesisArmorTotal);
this.drawText(text, 0, dy, dw, 'right');
return dy + this.lineHeight();
};
//=============================================================================
// Window_SynthesisList
//=============================================================================
function Window_SynthesisList() {
this.initialize.apply(this, arguments);
}
Window_SynthesisList.prototype = Object.create(Window_Selectable.prototype);
Window_SynthesisList.prototype.constructor = Window_SynthesisList;
Window_SynthesisList.prototype.initialize = function(commandWindow) {
this._commandWindow = commandWindow
var wy = commandWindow.y + commandWindow.height;
var ww = this.windowWidth();
var wh = Graphics.boxHeight - wy;
Window_Selectable.prototype.initialize.call(this, 0, wy, ww, wh);
this.refresh();
};
Window_SynthesisList.prototype.windowWidth = function() {
return Graphics.boxWidth / 2;
};
Window_SynthesisList.prototype.updateHelp = function() {
if (this._commandWindow.active) {
this._helpWindow.setText('');
} else if (eval(Yanfly.Param.ISMaskUnknown) &&
!$gameSystem.hasSynthed(this.item())) {
var text = Yanfly.Param.ISMaskHelpText;
if (this._helpWindow) this._helpWindow.setText(text);
} else {
this.setHelpWindowItem(this.item());
}
if (this._ingredients) {
this._ingredients.refresh(this.item());
}
};
Window_SynthesisList.prototype.item = function() {
return this._data;
};
Window_SynthesisList.prototype.isCurrentItemEnabled = function() {
return this.isEnabled(this.item());
};
Window_SynthesisList.prototype.isEnabled = function(item) {
if ($gamePlayer.isDebugThrough()) return true;
return $gameSystem.canSynthesize(item);
};
Window_SynthesisList.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
if (this._commandWindow) {
this.setCategory(this._commandWindow.currentSymbol())
}
};
Window_SynthesisList.prototype.setCategory = function(symbol) {
if (this._categorySymbol === symbol) return;
this._categorySymbol = symbol;
this.refresh();
};
Window_SynthesisList.prototype.refresh = function() {
if (this._commandWindow) {
this._categorySymbol = this._commandWindow.currentSymbol();
}
this.makeItemList();
this.createContents();
this.drawAllItems();
};
Window_SynthesisList.prototype.makeItemList = function() {
this._data = ;
if (this._commandWindow.currentSymbol() === 'item') {
this._data = Scene_Synthesis.availableItems();
} else if (this._commandWindow.currentSymbol() === 'weapon') {
this._data = Scene_Synthesis.availableWeapons();
} else if (this._commandWindow.currentSymbol() === 'armor') {
this._data = Scene_Synthesis.availableArmors();
}
};
Window_SynthesisList.prototype.maxItems = function() {
return this._data ? this._data.length : 1;
};
Window_SynthesisList.prototype.drawItem = function(index) {
var item = this._data;
if (!item) return;
this.resetFontSettings();
var rect = this.itemRect(index);
this.changePaintOpacity(this.isEnabled(item));
this.drawItemName(item, rect.x, rect.y, rect.width);
this.drawItemNumber(item, rect.x, rect.y, rect.width);
};
Window_SynthesisList.prototype.drawItemName = function(item, x, y, width) {
if (!item) return;
if ($gameSystem.hasSynthed(item)) {
Window_Base.prototype.drawItemName.call(this, item, x, y, width);
return;
}
var iconBoxWidth = Window_Base._iconWidth + 4;
this.resetTextColor();
this.drawIcon(item.iconIndex, x + 2, y + 2);
var text = item.name;
if (eval(Yanfly.Param.ISMaskUnknown)) {
this.contents.fontItalic = eval(Yanfly.Param.ISMaskItalic);
if (item.maskName !== '') {
text = item.maskName;
} else {
text = Yanfly.Util.maskString(text, Yanfly.Param.ISMaskText);
}
}
this.drawText(text, x + iconBoxWidth, y, width - iconBoxWidth);
this.contents.fontItalic = false;
};
Window_SynthesisList.prototype.drawItemNumber = function(item, wx, wy, ww) {
if (eval(Yanfly.Param.ISMaskUnknown) && !$gameSystem.hasSynthed(item)) {
return;
}
ww -= this.textPadding();
if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) {
var baseItem = DataManager.getBaseItem(item);
var value = $gameParty.numIndependentItems(baseItem);
var numItems = Yanfly.Util.toGroup(value);
} else {
var numItems = Yanfly.Util.toGroup($gameParty.numItems(item));
}
this.contents.fontSize = Yanfly.Param.ISQuantitySize;
this.drawText('\u00d7' + numItems, wx, wy, ww - 2, 'right');
};
//=============================================================================
// Window_SynthesisIngredients
//=============================================================================
function Window_SynthesisIngredients() {
this.initialize.apply(this, arguments);
}
Window_SynthesisIngredients.prototype = Object.create(Window_Base.prototype);
Window_SynthesisIngredients.prototype.constructor = Window_SynthesisIngredients;
Window_SynthesisIngredients.prototype.initialize = function(wx, wy, ww, wh) {
Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
};
Window_SynthesisIngredients.prototype.refresh = function(item) {
this.contents.clear();
if (!item) return;
this._item = item;
this.resetFontSettings();
this.resetTextColor();
this.drawItemIngredients(item, this.lineHeight());
};
Window_SynthesisIngredients.prototype.drawItemIngredients = function(item, wy) {
var ww = this.contents.width;
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISIngredientsList, 0, 0, ww, 'center');
this.changeTextColor(this.normalColor());
for (var i = 0; i < item.synthIngredients.length; ++i) {
wy = this.drawItemDetails(i, wy);
if (wy + this.lineheight > this.contents.height) break;
}
this.drawItemSynthCost(item, wy);
};
Window_SynthesisIngredients.prototype.drawItemDetails = function(index, wy) {
var ingredient = DataManager.getSynthesisIngredient(this._item, index);
var quantity = DataManager.getSynthesisQuantity(this._item, index);
var ww = this.contents.width;
if (!ingredient) return wy;
this.resetFontSettings();
this.drawItemName.call(this, ingredient, 0, wy, ww);
this.drawItemQuantity(index, wy);
return wy + this.lineHeight();
};
Window_SynthesisIngredients.prototype.drawItemQuantity = function(index, wy) {
var ingredient = DataManager.getSynthesisIngredient(this._item, index);
var quantity = DataManager.getSynthesisQuantity(this._item, index);
var ww = this.contents.width;
this.contents.fontSize = Yanfly.Param.ISQuantitySize;
this.changeTextColor(this.normalColor());
var num = '/' + Yanfly.Util.toGroup($gameParty.numItems(ingredient));
this.drawText(num, 0, wy, ww, 'right');
ww -= this.textWidth(num);
if ($gameParty.numItems(ingredient) >= quantity) {
this.changeTextColor(this.powerUpColor());
} else {
this.changeTextColor(this.powerDownColor());
}
var text = String(Yanfly.Util.toGroup(quantity));
this.drawText(text, 0, wy, ww, 'right');
}
Window_SynthesisIngredients.prototype.drawItemSynthCost = function(item, wy) {
if (item.synthCost <= 0) return;
this.resetFontSettings();
var value = item.synthCost;
var ww = this.contents.width - 4;
this.drawCurrencyValue(value, TextManager.currencyUnit, 0, wy, ww)
};
//=============================================================================
// Window_SynthesisNumber
//=============================================================================
function Window_SynthesisNumber() {
this.initialize.apply(this, arguments);
}
Window_SynthesisNumber.prototype = Object.create(Window_Selectable.prototype);
Window_SynthesisNumber.prototype.constructor = Window_SynthesisNumber;
Window_SynthesisNumber.prototype.initialize = function(ingredientsWindow) {
var wx = ingredientsWindow.x;
var wy = ingredientsWindow.y;
var ww = ingredientsWindow.width;
var wh = ingredientsWindow.height;
Window_Selectable.prototype.initialize.call(this, wx, wy, ww, wh);
this._index = 0;
this._item = null;
this._max = 1;
this._price = 0;
this._number = 1;
this._currencyUnit = TextManager.currencyUnit;
this.createButtons();
};
Window_SynthesisNumber.prototype.setup = function(item, max, price) {
this._item = item;
this._max = Math.max(1, Math.floor(max));
if ($gamePlayer.isDebugThrough()) this._max = $gameParty.maxItems(item);
this._price = price;
this._number = 1;
this.placeButtons();
this.updateButtonsVisiblity();
this.refresh();
};
Window_SynthesisNumber.prototype.setCurrencyUnit = function(currencyUnit) {
this._currencyUnit = currencyUnit;
this.refresh();
};
Window_SynthesisNumber.prototype.createButtons = function() {
var bitmap = ImageManager.loadSystem('ButtonSet');
var buttonWidth = 48;
var buttonHeight = 48;
this._buttons = ;
for (var i = 0; i < 5; i++) {
var button = new Sprite_Button();
var x = buttonWidth * i;
var w = buttonWidth * (i === 4 ? 2 : 1);
button.bitmap = bitmap;
button.setColdFrame(x, 0, w, buttonHeight);
button.setHotFrame(x, buttonHeight, w, buttonHeight);
button.visible = false;
this._buttons.push(button);
this.addChild(button);
}
this._buttons.setClickHandler(this.onButtonDown2.bind(this));
this._buttons.setClickHandler(this.onButtonDown.bind(this));
this._buttons.setClickHandler(this.onButtonUp.bind(this));
this._buttons.setClickHandler(this.onButtonUp2.bind(this));
this._buttons.setClickHandler(this.onButtonOk.bind(this));
};
Window_SynthesisNumber.prototype.placeButtons = function() {
var numButtons = this._buttons.length;
var spacing = 16;
var totalWidth = -spacing;
for (var i = 0; i < numButtons; i++) {
totalWidth += this._buttons.width + spacing;
}
var x = (this.width - totalWidth) / 2;
for (var j = 0; j < numButtons; j++) {
var button = this._buttons;
button.x = x;
button.y = this.buttonY();
x += button.width + spacing;
}
};
Window_SynthesisNumber.prototype.updateButtonsVisiblity = function() {
if (TouchInput.date > Input.date) {
this.showButtons();
} else {
this.hideButtons();
}
};
Window_SynthesisNumber.prototype.showButtons = function() {
for (var i = 0; i < this._buttons.length; i++) {
this._buttons.visible = true;
}
};
Window_SynthesisNumber.prototype.hideButtons = function() {
for (var i = 0; i < this._buttons.length; i++) {
this._buttons.visible = false;
}
};
Window_SynthesisNumber.prototype.refresh = function() {
this.contents.clear();
this.drawAmountText()
this.drawMultiplicationSign();
this.drawNumber();
this.drawIngredients();
};
Window_SynthesisNumber.prototype.drawAmountText = function() {
this.resetFontSettings();
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.ISAmountText, 0, 0, this.contents.width);
this.resetTextColor();
};
Window_SynthesisNumber.prototype.drawMultiplicationSign = function() {
var sign = '\u00d7';
var width = this.textWidth(sign);
var x = this.cursorX() - width * 2;
var y = this.itemY();
this.resetTextColor();
this.drawText(sign, x, y, width);
};
Window_SynthesisNumber.prototype.drawNumber = function() {
var x = this.cursorX();
var y = this.itemY();
var width = this.cursorWidth() - this.textPadding();
this.resetTextColor();
this.drawText(Yanfly.Util.toGroup(this._number), x, y, width, 'right');
};
Window_SynthesisNumber.prototype.drawIngredients = function() {
var wy = this.lineHeight();
for (var i = 0; i < this._item.synthIngredients.length; ++i) {
wy = this.drawItemDetails(i, wy);
if (wy + this.lineheight > this.contents.height) break;
}
this.drawItemSynthCost(this._item, wy);
};
Window_SynthesisNumber.prototype.drawItemDetails = function(index, wy) {
var ingredient = DataManager.getSynthesisIngredient(this._item, index);
var quantity = DataManager.getSynthesisQuantity(this._item, index);
var ww = this.contents.width;
if (!ingredient) return wy;
this.resetFontSettings();
this.drawItemName.call(this, ingredient, 0, wy, ww);
this.drawItemQuantity(index, wy);
return wy + this.lineHeight();
};
Window_SynthesisNumber.prototype.drawItemQuantity = function(index, wy) {
var ingredient = DataManager.getSynthesisIngredient(this._item, index);
var quantity = DataManager.getSynthesisQuantity(this._item, index);
quantity *= this.number();
var ww = this.contents.width;
this.contents.fontSize = Yanfly.Param.ISQuantitySize;
this.changeTextColor(this.normalColor());
var num = '/' + Yanfly.Util.toGroup($gameParty.numItems(ingredient));
this.drawText(num, 0, wy, ww, 'right');
ww -= this.textWidth(num);
if ($gameParty.numItems(ingredient) >= quantity) {
this.changeTextColor(this.powerUpColor());
} else {
this.changeTextColor(this.powerDownColor());
}
var text = String(Yanfly.Util.toGroup(quantity));
this.drawText(text, 0, wy, ww, 'right');
}
Window_SynthesisNumber.prototype.drawItemSynthCost = function(item, wy) {
if (item.synthCost <= 0) return;
this.resetFontSettings();
var value = item.synthCost * this.number();
var ww = this.contents.width - 4;
this.drawCurrencyValue(value, TextManager.currencyUnit, 0, wy, ww)
};
Window_SynthesisNumber.prototype.itemY = function() {
return 0;
};
Window_SynthesisNumber.prototype.priceY = function() {
return Math.round(this.contentsHeight() / 2 + this.lineHeight() / 2);
};
Window_SynthesisNumber.prototype.buttonY = function() {
return Math.round(this.priceY() + this.lineHeight() * 2.5);
};
Window_SynthesisNumber.prototype.cursorWidth = function() {
var digitWidth = this.textWidth('0');
return this.maxDigits() * digitWidth + this.textPadding() * 4;
};
Window_SynthesisNumber.prototype.cursorX = function() {
return this.contentsWidth() - this.cursorWidth() - this.textPadding();
};
Window_SynthesisNumber.prototype.maxDigits = function() {
if (this._item) {
var maxItem = parseInt($gameSystem.maxSynthesize(this._item));
maxItem = Math.max(1, maxItem);
if ($gamePlayer.isDebugThrough()) {
maxItem = $gameParty.maxItems(this._item);
}
return String(Yanfly.Util.toGroup(maxItem)).length;
}
return 2;
};
Window_SynthesisNumber.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
this.processNumberChange();
};
Window_SynthesisNumber.prototype.playOkSound = function() {
};
Window_SynthesisNumber.prototype.processNumberChange = function() {
if (this.isOpenAndActive()) {
if (Input.isRepeated('right')) {
this.changeNumber(1);
}
if (Input.isRepeated('left')) {
this.changeNumber(-1);
}
if (Input.isRepeated('up')) {
this.changeNumber(10);
}
if (Input.isRepeated('down')) {
this.changeNumber(-10);
}
}
};
Window_SynthesisNumber.prototype.changeNumber = function(amount) {
var lastNumber = this._number;
this._number = (this._number + amount).clamp(1, this._max);
if (this._number !== lastNumber) {
SoundManager.playCursor();
this.refresh();
}
};
Window_SynthesisNumber.prototype.updateCursor = function() {
this.setCursorRect(this.cursorX(), this.itemY(),
this.cursorWidth(), this.lineHeight());
};
Window_SynthesisNumber.prototype.onButtonUp = function() {
this.changeNumber(1);
};
Window_SynthesisNumber.prototype.onButtonUp2 = function() {
this.changeNumber(10);
};
Window_SynthesisNumber.prototype.onButtonDown = function() {
this.changeNumber(-1);
};
Window_SynthesisNumber.prototype.onButtonDown2 = function() {
this.changeNumber(-10);
};
Window_SynthesisNumber.prototype.onButtonOk = function() {
this.processOk();
};
Window_SynthesisNumber.prototype.number = function() {
return this._number;
};
//=============================================================================
// Scene_Menu
//=============================================================================
Yanfly.IS.Scene_Menu_createCommandWindow =
Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function() {
Yanfly.IS.Scene_Menu_createCommandWindow.call(this);
this._commandWindow.setHandler('synthesis',
this.commandSynthesis.bind(this));
};
Scene_Menu.prototype.commandSynthesis = function() {
SceneManager.push(Scene_Synthesis);
};
//=============================================================================
// Scene_Synthesis
//=============================================================================
function Scene_Synthesis() {
this.initialize.apply(this, arguments);
}
Scene_Synthesis.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Synthesis.prototype.constructor = Scene_Synthesis;
Scene_Synthesis.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_Synthesis.addSynthesisItem = function(obj, list) {
if (!obj) return;
if (obj.name.length <= 0) return;
if (obj.synthCost <= 0 && obj.synthIngredients.length <= 0) return;
if (list.contains(obj)) return;
list.push(obj);
};
Scene_Synthesis.getAvailableItems = function(type) {
var list = ;
var lib = this.availableLibrary();
var length = lib.length;
for (var i = 0; i < length; ++i) {
var set = lib;
this.getAvailableRecipes(set, type, list);
}
return list;
};
Scene_Synthesis.getAvailableRecipes = function(set, type, list) {
var length = set.length;
for (var i = 0; i < length; ++i) {
var item = set;
if (!item) continue;
if (type === 0 && item.recipeItem) {
this.getAvailableSynthesisItems(item.recipeItem, type, list);
} else if (type === 1 && item.recipeWeapon) {
this.getAvailableSynthesisItems(item.recipeWeapon, type, list);
} else if (type === 2 && item.recipeArmor) {
this.getAvailableSynthesisItems(item.recipeArmor, type, list);
}
}
};
Scene_Synthesis.getAvailableSynthesisItems = function(array, type, list) {
var length = array.length;
for (var i = 0; i < length; ++i) {
if (type === 0) var obj = $dataItems[array];
if (type === 1) var obj = $dataWeapons[array];
if (type === 2) var obj = $dataArmors[array];
this.addSynthesisItem(obj, list);
}
};
Scene_Synthesis.availableLibrary = function() {
if ($gameTemp._synthRecipe) {
return [];
}
var library = ;
library.push($gameParty.items());
library.push($gameParty.weapons());
library.push($gameParty.armors());
if (Yanfly.Param.ISEquRecipes) {
var length = $gameParty.allMembers().length;
for (var i = 0; i < length; ++i) {
var member = $gameParty.allMembers();
if (member) library.push(member.equips());
}
}
return library;
};
Scene_Synthesis.availableItems = function() {
var list = this.getAvailableItems(0);
return this.sortList(list);
};
Scene_Synthesis.availableWeapons = function() {
var list = this.getAvailableItems(1);
return this.sortList(list);
};
Scene_Synthesis.availableArmors = function() {
var list = this.getAvailableItems(2);
return this.sortList(list);
};
Scene_Synthesis.sortList = function(list) {
list.sort(function(a, b) {
var p1 = a.id;
var p2 = b.id;
if (p1 !== p2) {
return p1 - p2;
}
return b - a;
});
return list;
};
Scene_Synthesis.prototype.refreshWindows = function() {
this._statusWindow.refresh();
this._listWindow.refresh();
this._goldWindow.refresh();
this._ingredientsWindow.refresh(this._listWindow.item());
};
Scene_Synthesis.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createHelpWindow();
this.createCommandWindow();
this.createStatusWindow();
this.createListWindow();
this.createGoldWindow();
this.createIngredientsWindow();
this.createNumberWindow();
};
Scene_Synthesis.prototype.createCommandWindow = function() {
this._commandWindow = new Window_SynthesisCommand();
this._commandWindow.y = this._helpWindow.height;
this._commandWindow.setHandler('ok', this.onCommandOk.bind(this));
this._commandWindow.setHandler('cancel', this.onCancelOk.bind(this));
this.addWindow(this._commandWindow);
};
Scene_Synthesis.prototype.onCancelOk = function() {
$gameTemp._synthRecipe = undefined;
this.popScene();
};
Scene_Synthesis.prototype.createStatusWindow = function() {
var wx = this._commandWindow.width;
var wy = this._commandWindow.y;
var ww = Graphics.boxWidth - wx;
var wh = this._commandWindow.height;
this._statusWindow = new Window_SynthesisStatus(wx, wy, ww, wh);
this.addWindow(this._statusWindow);
};
Scene_Synthesis.prototype.createListWindow = function() {
this._listWindow = new Window_SynthesisList(this._commandWindow);
this._listWindow.setHandler('ok', this.onListOk.bind(this));
this._listWindow.setHandler('cancel', this.onListCancel.bind(this));
this._listWindow.setHelpWindow(this._helpWindow);
this.addWindow(this._listWindow);
};
Scene_Synthesis.prototype.createGoldWindow = function() {
var wx = this._listWindow.width;
this._goldWindow = new Window_Gold(wx, 0);
this._goldWindow.width = Graphics.boxWidth / 2;
this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height;
this._goldWindow.createContents();
this._goldWindow.refresh();
this.addWindow(this._goldWindow);
};
Scene_Synthesis.prototype.createIngredientsWindow = function() {
var wx = this._listWindow.width;
var wy = this._listWindow.y;
var ww = Graphics.boxWidth - wx;
var wh = Graphics.boxHeight - wy - this._goldWindow.height;
this._ingredientsWindow = new Window_SynthesisIngredients(wx, wy, ww, wh);
this._listWindow._ingredients = this._ingredientsWindow;
this.addWindow(this._ingredientsWindow);
};
Scene_Synthesis.prototype.createNumberWindow = function() {
this._numberWindow = new Window_SynthesisNumber(this._ingredientsWindow);
this._numberWindow.hide();
this._numberWindow.setHandler('ok', this.onNumberOk.bind(this));
this._numberWindow.setHandler('cancel', this.onNumberCancel.bind(this));
this.addWindow(this._numberWindow);
};
Scene_Synthesis.prototype.onCommandOk = function() {
this._listWindow.activate();
this._listWindow.select(0);
};
Scene_Synthesis.prototype.onListCancel = function() {
this._commandWindow.activate();
this._listWindow.select(-1);
this._listWindow.updateHelp();
};
Scene_Synthesis.prototype.onListOk = function() {
this._item = this._listWindow.item();
this._ingredientsWindow.hide();
this._numberWindow.setup(this._item, this.maxBuy(), this.buyingPrice());
this._numberWindow.setCurrencyUnit(this.currencyUnit());
this._numberWindow.show();
this._numberWindow.activate();
};
Scene_Synthesis.prototype.onNumberOk = function() {
this.playSynthesisSound();
this.doBuy(this._numberWindow.number());
this.endNumberInput();
this.refreshWindows();
};
Scene_Synthesis.prototype.playSynthesisSound = function() {
var se = {
name: this._item.synthSeName,
volume: this._item.synthSeVol,
pitch: this._item.synthSePitch,
pan: this._item.synthSePan
}
AudioManager.playSe(se);
};
Scene_Synthesis.prototype.doBuy = function(number) {
var price = number * this._item.synthCost;
$gameParty.loseGold(price);
for (var i = 0; i < this._item.synthIngredients.length; ++i) {
var ingredient = DataManager.getSynthesisIngredient(this._item, i);
var quantity = DataManager.getSynthesisQuantity(this._item, i);
quantity *= number;
if (!ingredient) continue;
$gameParty.loseItem(ingredient, quantity, false);
}
$gameParty.gainItem(this._item, number);
$gameSystem.addSynth(this._item);
};
Scene_Synthesis.prototype.endNumberInput = function() {
this._numberWindow.hide();
this._listWindow.activate();
this._ingredientsWindow.show();
};
Scene_Synthesis.prototype.onNumberCancel = function() {
SoundManager.playCancel();
this.endNumberInput();
};
Scene_Synthesis.prototype.maxBuy = function() {
return $gameSystem.maxSynthesize(this._item);
};
Scene_Synthesis.prototype.buyingPrice = function() {
return $gameSystem.maxSynthesize(this._item) * this._item.synthCost;
};
Scene_Synthesis.prototype.currencyUnit = function() {
return this._goldWindow.currencyUnit();
};
//=============================================================================
// New Function
//=============================================================================
Yanfly.Util = Yanfly.Util || {};
Yanfly.Util.getRange = function(n, m) {
var result = ;
for (var i = n; i <= m; ++i) result.push(i);
return result;
};
Yanfly.Util.maskString = function(str, mask) {
var text = mask;
if (mask.length === 1) {
text = Array(str.length + 1).join(mask);
return text;
} else {
return mask;
}
};
if (!Yanfly.Util.toGroup) {
Yanfly.Util.toGroup = function(inVal) {
return inVal;
}
};
//=============================================================================
// End of File
//=============================================================================
[RMMV] Action times and Yanfly CTB system
Hi, i need help to create a state that allow me to perform more than one action in a turn, because the 'Action Times' traits doesn't work with Yanfly CTB system. Thanks
Problem with item drop
Hi, i am trying to create a scan skill and i want that the player can see the item drop by enemy scanned. i write for example on script call: "target.makeDropItems().name", but an error appear if the item hasn't 100% chance to be dropped. Where i wrong? Thanks
Victor Engine Equip Set: Bug
Hello, in the plugin VE_EquipSet there is a bug when i try to call SceneManager.goto(Scene_Boot). It say: "Cannot read property 'set' of undefined". Someone can help me, please? Thank you.
Help with IavraSets and YEP_EquipCore plugins
Hi, i need help to add the name of the set (created with IavraSets plugin) and its description below the last equip slot (YEP_EquipCore).
IavraSets Plugin:
YEP_EquipCore Plugin
IavraSets Plugin:
/*:
* @plugindesc Adds equipment sets to the game, that provide bonuses depending on the number of items equipped.
* <Iavra Sets>
* @author Iavra
*
* @param Configuration
* @desc File path to the configuration file, that's used to load set bonuses.
* @default sets.json
*
* @param Stackable Bonuses
* @desc If set to true, all set bonuses stack. If false, only the highest applicable one gets applied.
* @default true
*
* @help
* To register one or more equipment sets, put a JSON file in your project folder and set the parameter "Configuration"
* to its file path. Following is a sample file containing 1 set:
*
* [
* {
* "name": "Testset",
* "description": "This is a test set.",
* "icon": 1,
* "items": [
* ,
*
* ],
* "traits": {
* "2":
* }
* }
* ]
*
* The sample set contains of the weapon #1 and armor #2 and doubles the "atk" parameter of an actor, if he has both
* equipped (equipping the weapon twice does NOT count). Set name, description and icon are not directly used by this
* plugin, but can be utilized by others.
*
* You can add all traits, that are available in the database (actors/classes/weapons/armors -> traits). Following is
* a table containing all codes:
*
* 11 Element Rate
* 12 Debuff Rate
* 13 State Rate
* 14 State Resist
* 20 Param Plus
* 21 Param Rate
* 22 XParam Plus
* 23 SParam Rate
* 31 Attack Element
* 32 Attack State
* 33 Attack Speed
* 34 Attack Times
* 41 Add Skill Type
* 42 Seal Skill Type
* 43 Add Skill
* 44 Seal Skill
* 62 Special Flag
*
* There are more trait codes, but i'm not sure, if and how they are working, but feel free to tinker around with them.
*
* Following is a table containing the dataIds for all params:
*
* 0 Max HP
* 1 Max MP
* 2 Attack Power
* 3 Defense Power
* 4 Magic Attack Power
* 5 Magic Defense Power
* 6 Agility
* 7 Luck
*
* Following is a table containing the dataIds for all xparams:
*
* 0 Hit Rate
* 1 Evasion Rate
* 2 Critical Rate
* 3 Critical Evasion Rate
* 4 Magic Evasion Rate
* 5 Magic Reflection Rate
* 6 Counter Attack Rate
* 7 HP Regeneration Rate
* 8 MP Regeneration Rate
* 9 TP Regeneration Rate
*
* Following is a table containing the dataIds for all sparams:
*
* 0 Target Rate
* 1 Guard Effect Rate
* 2 Recovery Effect Rate
* 3 Pharmacology
* 4 MP Cost Rate
* 5 TP Charge Rate
* 6 Physical Damage Rate
* 7 Magical Damage Rate
* 8 Floor Damage Rate
* 9 Experience Rate
*
* Following is a table containing the dataIds for special flags:
*
* 0 Auto Battle
* 1 Guard
* 2 Substitute
* 3 Preserve TP
*
* The plugin provides some script calls to interact with sets:
*
* IAVRA.SETS.sets(); Returns all registered sets.
* IAVRA.SETS.setsForItem(item); Returns all sets containing the given armor or weapon.
* IAVRA.SETS.setsForActor(actor); Returns all sets containing at least 1 item currently equipped to the given actor.
*
* Furthermore, each set has the following functions to interact with:
*
* set.numItemsEquipped(actor); Returns the number of items belonging to this set currently equipped to the actor.
* set.applicableTraits(actor); Returns all traits of the set, that are currently applied to the actor.
* set.name; The name of the set.
* set.description; The description of the set.
* set.icon; The icon index of the set.
* set.items; All items belonging to the set.
*/
var IAVRA = IAVRA || {};
(function($) {
"use strict";
/**
* Read plugin parameters independent from the actual filename.
*/
var _params = $plugins.filter(function(p) { return p.description.contains('<Iavra Sets>'); }).parameters;
var _param_config = _params;
var _param_stackable = _params.toLowerCase() === 'true';
/**
* New trait code, that defines value to be added to "paramPlus" to increase the base param values.
*/
var _trait_paramPlus = 20;
/**
* Holds the set data, before create set objects, since we have to wait for the database being loaded, first.
*/
var _data;
/**
* Holds all registered sets.
*/
var _sets = ;
/**
* Load the configuration file and store the data for later usage.
*/
var _loadData = function() {
var request = new XMLHttpRequest();
request.open('GET', _param_config);
request.overrideMimeType('application/json');
request.onload = function() { _data = JSON.parse(request.responseText); };
request.onerror = function() { throw new Error('There was an error loading the file.'); };
request.send();
};
/**
* Create set objects from the loaded data. If part of the data is invalid, log the error, but continue. Makes it
* easier to test configurations. Afterwards, clear the cached data object to free some memory, because it's not
* needed anymore.
*/
var _initialize = function() {
_data.forEach(function(data) {
try { _sets.push(new IAVRA.SETS.Set(data)); } catch(error) { console.warn('Invalid set data: ', error); }
});
_data = null;
};
/**
* Return the actual weapon/armor entries for the given item data.
*/
var _parseItems = function(data) {
return data.map(function(item) { switch(item) {
case 'weapon': return $dataWeapons[item];
case 'armor': return $dataArmors[item];
}})
};
/**
* Returns an array containing all traits of a given set data, ordered by the number of equipped items needed.
*/
var _parseTraits = function(data) {
return Object.keys(data).reduce(function(array, key) { array = data; return array; }, )
};
/**
* On refresh, store the actor sets and set bonuses inside the actor, so they don't have to be calculated every
* time a parameter or trait is accessed.
*/
var _refreshActor = function(actor) {
var sets = $.SETS.setsForActor(actor);
var traits = Array.prototype.concat.apply(, sets.map(function(s) { return s.applicableTraits(actor); }));
actor._iavra_sets = { sets: sets, traits: traits };
};
//=============================================================================
// IAVRA.SETS
//=============================================================================
$.SETS = {
/**
* Returns all registered sets.
*/
sets: function() { return _sets; },
/**
* Returns an array of all sets containing the given item.
*/
setsForItem: function(item) { return _sets.filter(function(s) { return s.items.contains(item); }); },
/**
* Returns an array of all sets, that are currently present on the given actor.
*/
setsForActor: function(actor) { return _sets.filter(function(s) { return s.numItemsEquipped(actor) > 0; }); },
/**
* Holds all information regarding the registered equipment sets.
*/
Set: function() { this.initialize.apply(this, arguments); }
};
//=============================================================================
// IAVRA.SETS.Set
//=============================================================================
(function($) {
/**
* Initialize a bunch of stuff from the given data.
*/
$.prototype.initialize = function(data) {
this._name = data.name;
this._description = data.description;
this._icon = parseInt(data.icon);
this._items = _parseItems(data.items);
this._traits = _parseTraits(data.traits);
};
/**
* Returns the number of items a given actor has equipped, that belong to this set.
*/
$.prototype.numItemsEquipped = function(actor) {
var e = actor.equips(); return this.items.filter(function(i) { return e.contains(i); }).length;
};
/**
* Returns the traits belonging to this set, that can be applied to the given actor depending on the number of
* set items they have equipped.
*/
$.prototype.applicableTraits = function(actor) {
var num = this.numItemsEquipped(actor), result = ;
for(var t = this._traits, i = t.length; i--; ) { if(t && i <= num) {
if(_param_stackable) { result = result.concat(t); } else { return t; }
} }
return result;
};
/**
* Defining some properties for encapsulation.
*/
Object.defineProperties($.prototype, {
name: { get: function() { return this._name; } },
description: { get: function() { return this._description; } },
icon: { get: function() { return this._icon; } },
items: { get: function() { return this._items; } }
});
})($.SETS.Set);
//=============================================================================
// Game_Actor
//=============================================================================
(function($) {
/**
* On refresh, store all sets and their traits applicable to this actor inside the object, so we don't need to
* calculate them every time we need to access a trait.
*/
var alias_refresh = $.prototype.refresh;
$.prototype.refresh = function() {
_refreshActor(this);
alias_refresh.call(this);
};
/**
* Also add all traits supplied by equipment sets.
*/
var alias_traitObjects = $.prototype.traitObjects;
$.prototype.traitObjects = function() {
return alias_traitObjects.call(this).concat(this._iavra_sets);
};
/**
* We have added a new trait id (20), that gets used to add constant values to the param base.
*/
var alias_paramPlus = $.prototype.paramPlus;
$.prototype.paramPlus = function(paramId) {
return alias_paramPlus.call(this, paramId) + this.traitsSum(_trait_paramPlus, paramId);
};
/**
* Contains all sets and set bonuses, that are currently applied to this actor. Gets updated during refresh.
*/
$.prototype._iavra_sets = { sets: , traits: };
})(Game_Actor);
//=============================================================================
// Scene_Boot
//=============================================================================
(function($) {
/**
* On create, start loading our configuration file.
*/
var alias_create = $.prototype.create;
$.prototype.create = function() { alias_create.call(this); _loadData(); };
/**
* Wait, until the configuration has been loaded.
*/
var alias_isReady = $.prototype.isReady;
$.prototype.isReady = function() { return (_data !== undefined) && alias_isReady.call(this); };
/**
* On start, parse the loaded data, since we need access to $dataWeapons and $dataArmors.
*/
var alias_start = $.prototype.start;
$.prototype.start = function() { _initialize(); alias_start.call(this); };
})(Scene_Boot);
//=============================================================================
// DataManager
//=============================================================================
(function($) {
/**
* When loading a game, refresh all set bonuses. This makes the plugin plug-and-play and allows to edit the
* configuration file without invalidating all savegames.
*/
var alias_loadGame = $.loadGame;
$.loadGame = function(savefileId) {
var result = alias_loadGame.call(this, savefileId);
$gameActors._data.forEach(function(actor) { if(actor) { _refreshActor(actor); } });
return result;
};
})(DataManager);
})(IAVRA);
* @plugindesc Adds equipment sets to the game, that provide bonuses depending on the number of items equipped.
* <Iavra Sets>
* @author Iavra
*
* @param Configuration
* @desc File path to the configuration file, that's used to load set bonuses.
* @default sets.json
*
* @param Stackable Bonuses
* @desc If set to true, all set bonuses stack. If false, only the highest applicable one gets applied.
* @default true
*
* @help
* To register one or more equipment sets, put a JSON file in your project folder and set the parameter "Configuration"
* to its file path. Following is a sample file containing 1 set:
*
* [
* {
* "name": "Testset",
* "description": "This is a test set.",
* "icon": 1,
* "items": [
* ,
*
* ],
* "traits": {
* "2":
* }
* }
* ]
*
* The sample set contains of the weapon #1 and armor #2 and doubles the "atk" parameter of an actor, if he has both
* equipped (equipping the weapon twice does NOT count). Set name, description and icon are not directly used by this
* plugin, but can be utilized by others.
*
* You can add all traits, that are available in the database (actors/classes/weapons/armors -> traits). Following is
* a table containing all codes:
*
* 11 Element Rate
* 12 Debuff Rate
* 13 State Rate
* 14 State Resist
* 20 Param Plus
* 21 Param Rate
* 22 XParam Plus
* 23 SParam Rate
* 31 Attack Element
* 32 Attack State
* 33 Attack Speed
* 34 Attack Times
* 41 Add Skill Type
* 42 Seal Skill Type
* 43 Add Skill
* 44 Seal Skill
* 62 Special Flag
*
* There are more trait codes, but i'm not sure, if and how they are working, but feel free to tinker around with them.
*
* Following is a table containing the dataIds for all params:
*
* 0 Max HP
* 1 Max MP
* 2 Attack Power
* 3 Defense Power
* 4 Magic Attack Power
* 5 Magic Defense Power
* 6 Agility
* 7 Luck
*
* Following is a table containing the dataIds for all xparams:
*
* 0 Hit Rate
* 1 Evasion Rate
* 2 Critical Rate
* 3 Critical Evasion Rate
* 4 Magic Evasion Rate
* 5 Magic Reflection Rate
* 6 Counter Attack Rate
* 7 HP Regeneration Rate
* 8 MP Regeneration Rate
* 9 TP Regeneration Rate
*
* Following is a table containing the dataIds for all sparams:
*
* 0 Target Rate
* 1 Guard Effect Rate
* 2 Recovery Effect Rate
* 3 Pharmacology
* 4 MP Cost Rate
* 5 TP Charge Rate
* 6 Physical Damage Rate
* 7 Magical Damage Rate
* 8 Floor Damage Rate
* 9 Experience Rate
*
* Following is a table containing the dataIds for special flags:
*
* 0 Auto Battle
* 1 Guard
* 2 Substitute
* 3 Preserve TP
*
* The plugin provides some script calls to interact with sets:
*
* IAVRA.SETS.sets(); Returns all registered sets.
* IAVRA.SETS.setsForItem(item); Returns all sets containing the given armor or weapon.
* IAVRA.SETS.setsForActor(actor); Returns all sets containing at least 1 item currently equipped to the given actor.
*
* Furthermore, each set has the following functions to interact with:
*
* set.numItemsEquipped(actor); Returns the number of items belonging to this set currently equipped to the actor.
* set.applicableTraits(actor); Returns all traits of the set, that are currently applied to the actor.
* set.name; The name of the set.
* set.description; The description of the set.
* set.icon; The icon index of the set.
* set.items; All items belonging to the set.
*/
var IAVRA = IAVRA || {};
(function($) {
"use strict";
/**
* Read plugin parameters independent from the actual filename.
*/
var _params = $plugins.filter(function(p) { return p.description.contains('<Iavra Sets>'); }).parameters;
var _param_config = _params;
var _param_stackable = _params.toLowerCase() === 'true';
/**
* New trait code, that defines value to be added to "paramPlus" to increase the base param values.
*/
var _trait_paramPlus = 20;
/**
* Holds the set data, before create set objects, since we have to wait for the database being loaded, first.
*/
var _data;
/**
* Holds all registered sets.
*/
var _sets = ;
/**
* Load the configuration file and store the data for later usage.
*/
var _loadData = function() {
var request = new XMLHttpRequest();
request.open('GET', _param_config);
request.overrideMimeType('application/json');
request.onload = function() { _data = JSON.parse(request.responseText); };
request.onerror = function() { throw new Error('There was an error loading the file.'); };
request.send();
};
/**
* Create set objects from the loaded data. If part of the data is invalid, log the error, but continue. Makes it
* easier to test configurations. Afterwards, clear the cached data object to free some memory, because it's not
* needed anymore.
*/
var _initialize = function() {
_data.forEach(function(data) {
try { _sets.push(new IAVRA.SETS.Set(data)); } catch(error) { console.warn('Invalid set data: ', error); }
});
_data = null;
};
/**
* Return the actual weapon/armor entries for the given item data.
*/
var _parseItems = function(data) {
return data.map(function(item) { switch(item) {
case 'weapon': return $dataWeapons[item];
case 'armor': return $dataArmors[item];
}})
};
/**
* Returns an array containing all traits of a given set data, ordered by the number of equipped items needed.
*/
var _parseTraits = function(data) {
return Object.keys(data).reduce(function(array, key) { array = data; return array; }, )
};
/**
* On refresh, store the actor sets and set bonuses inside the actor, so they don't have to be calculated every
* time a parameter or trait is accessed.
*/
var _refreshActor = function(actor) {
var sets = $.SETS.setsForActor(actor);
var traits = Array.prototype.concat.apply(, sets.map(function(s) { return s.applicableTraits(actor); }));
actor._iavra_sets = { sets: sets, traits: traits };
};
//=============================================================================
// IAVRA.SETS
//=============================================================================
$.SETS = {
/**
* Returns all registered sets.
*/
sets: function() { return _sets; },
/**
* Returns an array of all sets containing the given item.
*/
setsForItem: function(item) { return _sets.filter(function(s) { return s.items.contains(item); }); },
/**
* Returns an array of all sets, that are currently present on the given actor.
*/
setsForActor: function(actor) { return _sets.filter(function(s) { return s.numItemsEquipped(actor) > 0; }); },
/**
* Holds all information regarding the registered equipment sets.
*/
Set: function() { this.initialize.apply(this, arguments); }
};
//=============================================================================
// IAVRA.SETS.Set
//=============================================================================
(function($) {
/**
* Initialize a bunch of stuff from the given data.
*/
$.prototype.initialize = function(data) {
this._name = data.name;
this._description = data.description;
this._icon = parseInt(data.icon);
this._items = _parseItems(data.items);
this._traits = _parseTraits(data.traits);
};
/**
* Returns the number of items a given actor has equipped, that belong to this set.
*/
$.prototype.numItemsEquipped = function(actor) {
var e = actor.equips(); return this.items.filter(function(i) { return e.contains(i); }).length;
};
/**
* Returns the traits belonging to this set, that can be applied to the given actor depending on the number of
* set items they have equipped.
*/
$.prototype.applicableTraits = function(actor) {
var num = this.numItemsEquipped(actor), result = ;
for(var t = this._traits, i = t.length; i--; ) { if(t && i <= num) {
if(_param_stackable) { result = result.concat(t); } else { return t; }
} }
return result;
};
/**
* Defining some properties for encapsulation.
*/
Object.defineProperties($.prototype, {
name: { get: function() { return this._name; } },
description: { get: function() { return this._description; } },
icon: { get: function() { return this._icon; } },
items: { get: function() { return this._items; } }
});
})($.SETS.Set);
//=============================================================================
// Game_Actor
//=============================================================================
(function($) {
/**
* On refresh, store all sets and their traits applicable to this actor inside the object, so we don't need to
* calculate them every time we need to access a trait.
*/
var alias_refresh = $.prototype.refresh;
$.prototype.refresh = function() {
_refreshActor(this);
alias_refresh.call(this);
};
/**
* Also add all traits supplied by equipment sets.
*/
var alias_traitObjects = $.prototype.traitObjects;
$.prototype.traitObjects = function() {
return alias_traitObjects.call(this).concat(this._iavra_sets);
};
/**
* We have added a new trait id (20), that gets used to add constant values to the param base.
*/
var alias_paramPlus = $.prototype.paramPlus;
$.prototype.paramPlus = function(paramId) {
return alias_paramPlus.call(this, paramId) + this.traitsSum(_trait_paramPlus, paramId);
};
/**
* Contains all sets and set bonuses, that are currently applied to this actor. Gets updated during refresh.
*/
$.prototype._iavra_sets = { sets: , traits: };
})(Game_Actor);
//=============================================================================
// Scene_Boot
//=============================================================================
(function($) {
/**
* On create, start loading our configuration file.
*/
var alias_create = $.prototype.create;
$.prototype.create = function() { alias_create.call(this); _loadData(); };
/**
* Wait, until the configuration has been loaded.
*/
var alias_isReady = $.prototype.isReady;
$.prototype.isReady = function() { return (_data !== undefined) && alias_isReady.call(this); };
/**
* On start, parse the loaded data, since we need access to $dataWeapons and $dataArmors.
*/
var alias_start = $.prototype.start;
$.prototype.start = function() { _initialize(); alias_start.call(this); };
})(Scene_Boot);
//=============================================================================
// DataManager
//=============================================================================
(function($) {
/**
* When loading a game, refresh all set bonuses. This makes the plugin plug-and-play and allows to edit the
* configuration file without invalidating all savegames.
*/
var alias_loadGame = $.loadGame;
$.loadGame = function(savefileId) {
var result = alias_loadGame.call(this, savefileId);
$gameActors._data.forEach(function(actor) { if(actor) { _refreshActor(actor); } });
return result;
};
})(DataManager);
})(IAVRA);
YEP_EquipCore Plugin
//=============================================================================
// Yanfly Engine Plugins - Equip Core
// YEP_EquipCore.js
//=============================================================================
var Imported = Imported || {};
Imported.YEP_EquipCore = true;
var Yanfly = Yanfly || {};
Yanfly.Equip = Yanfly.Equip || {};
//=============================================================================
/*:
* @plugindesc v1.08 Allows for the equipment system to be more flexible to
* allow for unique equipment slots per class.
* @author Yanfly Engine Plugins
*
* @param ---General---
* @default
*
* @param Text Align
* @desc How to align the text for the command window.
* left center right
* @default center
*
* @param Finish Command
* @desc The command text used for exiting the equip scene.
* @default Finish
*
* @param Remove Text
* @desc The text used to display the "Remove" command in the equip
* item list.
* @default Remove
*
* @param Remove Icon
* @desc The icon used to display next to the "Remove" command in
* the equip item list.
* @default 16
*
* @param Empty Text
* @desc The text used to display an "Empty" piece of equipment.
* @default <Empty>
*
* @param Empty Icon
* @desc The icon used to display next to the "Empty" piece of
* equipment in the equipment list.
* @default 16
*
* @param ---Rules---
* @default
*
* @param Non-Removable Types
* @desc These types must always have an item equipped and cannot
* be empty. Separate the type ID's by a space.
* @default 1
*
* @param Non-Optimized Types
* @desc These types will be ignored when the actor optimizes
* equips. Separate the type ID's by a space.
* @default 5
*
* @help
* ============================================================================
* Introduction
* ============================================================================
*
* This plugin alters various aspects regarding equipment handling. The changes
* are as listed:
*
* 1. Scene_Equip
* Scene_Equip has been modified to look differently. This is primarily done to
* make the main menu scenes look uniform and keep everything familiar for
* players. Furthermore, the command window has been adjusted to be better fit
* for extension plugins in the future that may add commands to the command
* window and/or the scene.
*
* 2. Equipment Type Handling
* Characters will no longer have one universal equipment slot setting. Now,
* different classes can use different setups by simply adding a few notetags
* to the class notebox. Furthermore, equipment types in the past with matching
* names would be treated as separate types. Now, equipment types with matching
* names will be treated as the same type.
*
* 3. Equipment Rulings
* Now, certain equipment types can or cannot be removed. For example, this
* plugin can set it so that the Weapon slot must always have something
* equipped and that the player cannot manually leave it empty (the game, on
* the other hand, can achieve this through events). In addition to that,
* optimizing equipment can be restricted for certain equipment types, which
* are better off being decided manually (such as accessories).
*
* 4. Parameter Control
* Equipment parameters can now to be adjusted through notetags to have a large
* value or customized value (through code). This allows for equipment to no
* longer be static items, but instead, equipment can now be dynamic and may
* change over the course of the game.
*
* ============================================================================
* Notetags
* ============================================================================
*
* You can use the following notetags to change a class's equipment setup.
*
* Class Notetags:
* <Equip Slot: x> Example: <Equip Slot: 1, 2, 3, 4, 5, 5, 5, 5>
* <Equip Slot: x, x, x>
* Changes this class's equipment slots to x. Using repeating numbers makes
* it so that equipment type is duplicated and that the class can equip
* multiple equipment of that type. To find the Equipment Type ID, go to your
* database's Types tab and look for the ID type.
*
* If you don't like the above method for setting equipment slots, you can
* use the following notetags instead:
*
* <Equip Slot> Example: <Equip Slot>
* string Weapon
* string Armor
* string Accessory
* string Accessory
* </Equip Slot> </Equip Slot>
* Replace 'string' with the Equipment type's name entry. This is case
* sensitive so if the string does not match a name entry perfectly, the slot
* will not be granted to the class. Multiple copies of a name entry would
* mean the class can equip multiple equipment of that type. Everything works
* the same as the previous notetag.
*
* Weapon and Armor Notetags:
* <stat: +x>
* <stat: -x>
* Allows the piece of weapon or armor to gain or lose x amount of stat.
* Replace "stat" with "hp", "mp", "atk", "def", "mat", "mdf", "agi", or
* "luk" to alter that specific stat. This allows the piece of equipment
* to go past the editor's default limitation so long as the maximum value
* allows for it. Changes made here alter the base parameters.
*
* ============================================================================
* Lunatic Mode - Custom Parameters
* ============================================================================
*
* <Custom Parameters> Example: <Custom Parameters>
* code atk = $gameVariables.value(1);
* code mat = atk / 2;
* code all = $gameParty.members().length;
* code </Custom Parameters>
* </Code Parameters>
* Allows for parameters to have custom rates adjusted by code. The following
* parameters are defined: 'maxhp', 'maxmp', 'atk', 'def', 'mat', 'mdf',
* 'agi', 'luk', and 'all'. The 'all' parameter will affect all parameters.
* Changes made here do not alter the base parameters, but instead, are added
* onto the base parameters.
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 1.08:
* - Fixed a bug where changing an actor's equips would revive them if dead.
*
* Version 1.07:
* - Fixed a bug with 'Optimize' and 'Remove All' not refreshing windows.
*
* Version 1.06:
* - Fixed a bug with 'Change Equipment' event where it would only change the
* slot of the marked equipment rather than the slot type.
*
* Version 1.05:
* - Fixed an issue where unequipping items can kill actors.
*
* Version 1.04a:
* - Fixed a bug and rewrote the initializing equipment process.
*
* Version 1.03:
* - Fixed an bug that resulted in null object errors.
*
* Version 1.02:
* - Fixed an issue that did not keep HP and MP rates the same when using the
* optimize and clear commands.
*
* Version 1.01:
* - Fixed a bug that did not update the stats properly when compared.
*
* Version 1.00:
* - Finished plugin!
*/
//=============================================================================
//=============================================================================
// Parameter Variables
//=============================================================================
Yanfly.Parameters = PluginManager.parameters('YEP_EquipCore');
Yanfly.Param = Yanfly.Param || {};
Yanfly.Icon = Yanfly.Icon || {};
Yanfly.Param.EquipTextAlign = String(Yanfly.Parameters);
Yanfly.Param.EquipFinishCmd = String(Yanfly.Parameters);
Yanfly.Param.EquipRemoveText = String(Yanfly.Parameters);
Yanfly.Icon.RemoveEquip = Number(Yanfly.Parameters);
Yanfly.Param.EquipEmptyText = String(Yanfly.Parameters);
Yanfly.Icon.EmptyEquip = Number(Yanfly.Parameters);
Yanfly.Data = String(Yanfly.Parameters);
Yanfly.Data = Yanfly.Data.split(' ');
Yanfly.Param.EquipNonRemove = ;
for (Yanfly.i = 0; Yanfly.i < Yanfly.Data.length; ++Yanfly.i) {
Yanfly.Param.EquipNonRemove.push(parseInt(Yanfly.Data));
};
Yanfly.Data = String(Yanfly.Parameters);
Yanfly.Data = Yanfly.Data.split(' ');
Yanfly.Param.EquipNonOptimized = ;
for (Yanfly.i = 0; Yanfly.i < Yanfly.Data.length; ++Yanfly.i) {
Yanfly.Param.EquipNonOptimized.push(parseInt(Yanfly.Data));
};
//=============================================================================
// DataManager
//=============================================================================
Yanfly.Equip.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!Yanfly.Equip.DataManager_isDatabaseLoaded.call(this)) return false;
DataManager.processEquipNotetags1($dataClasses);
DataManager.processEquipNotetags2($dataWeapons);
DataManager.processEquipNotetags2($dataArmors);
return true;
};
DataManager.processEquipNotetags1 = function(group) {
var note1 = /<(?:EQUIP SLOT|equip slots):*(\d+(?:\s*,\s*\d+)*)>/i;
var note2 = /<(?:EQUIP SLOT|equip slots)>/i;
var note3 = /<\/(?:EQUIP SLOT|equip slots)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group;
var notedata = obj.note.split(/+/);
obj.equipSlots = ;
var equipSlots = false;
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
var array = JSON.parse('');
obj.equipSlots = obj.equipSlots.concat(array);
} else if (line.match(note2)) {
equipSlots = true;
} else if (line.match(note3)) {
equipSlots = false;
} else if (equipSlots && line.match(/*(.*)/i)) {
var name = String(RegExp.$1);
var slotId = $dataSystem.equipTypes.indexOf(name);
if (slotId >= 0) obj.equipSlots.push(slotId);
}
}
if (obj.equipSlots.length <= 0) this.setDefaultEquipSlots(obj);
}
};
DataManager.setDefaultEquipSlots = function(obj) {
for (var i = 1; i < $dataSystem.equipTypes.length; ++i) {
var name = $dataSystem.equipTypes;
var slotId = $dataSystem.equipTypes.indexOf(name);
if (slotId >= 0) obj.equipSlots.push(slotId);
}
};
DataManager.processEquipNotetags2 = function(group) {
var note1 = /<(?:PARAMETER EVAL|custom parameter|custom parameters)>/i;
var note2 = /<\/(?:PARAMETER EVAL|custom parameter|custom parameters)>/i;
var note3 = /<(.*):(\d+)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group;
var notedata = obj.note.split(/+/);
obj.parameterEval = '';
var parameterEval = false;
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
parameterEval = true;
} else if (line.match(note2)) {
parameterEval = false;
} else if (parameterEval) {
obj.parameterEval = obj.parameterEval + line + '\n';
} else if (line.match(note3)) {
var stat = String(RegExp.$1).toUpperCase();
var value = parseInt(RegExp.$2);
switch (stat) {
case 'HP':
case 'MAXHP':
case 'MAX HP':
obj.params = value;
break;
case 'MP':
case 'MAXMP':
case 'MAX MP':
case 'SP':
case 'MAXSP':
case 'MAX SP':
obj.params = value;
break;
case 'ATK':
case 'STR':
obj.params = value;
break;
case 'DEF':
obj.params = value;
break;
case 'MAT':
case 'INT' || 'SPI':
obj.params = value;
break;
case 'MDF':
case 'RES':
obj.params = value;
break;
case 'AGI':
case 'SPD':
obj.params = value;
break;
case 'LUK':
obj.params = value;
break;
}
}
}
}
};
//=============================================================================
// Game_Actor
//=============================================================================
Game_Actor.prototype.initEquips = function(equips) {
var equips = this.convertInitEquips(equips);
this.equipInitEquips(equips);
this.releaseUnequippableItems(true);
this.recoverAll();
this.refresh();
};
Game_Actor.prototype.convertInitEquips = function(equips) {
var items = ;
for (var i = 0; i < equips.length; ++i) {
var equipId = equips;
if (equipId <= 0) continue;
var equipType = $dataSystem.equipTypes;
if (equipType === $dataSystem.equipTypes ||
(i === 1 && this.isDualWield())) {
var equip = $dataWeapons;
} else {
var equip = $dataArmors;
}
items.push(equip);
}
return items;
};
Game_Actor.prototype.equipInitEquips = function(equips) {
var slots = this.equipSlots();
var maxSlots = slots.length;
this._equips = ;
for (var i = 0; i < maxSlots; ++i) {
this._equips = new Game_Item();
}
for (var i = 0; i < maxSlots; ++i) {
var slotType = slots;
var equip = this.grabInitEquips(equips, slotType);
if (this.canEquip(equip)) this._equips.setObject(equip);
}
};
Game_Actor.prototype.grabInitEquips = function(equips, slotType) {
var item = null;
for (var i = 0; i < equips.length; ++i) {
var equip = equips;
if (!equip) continue;
if (slotType === 1 && DataManager.isWeapon(equip)) {
item = equip;
break;
} else if (equip.etypeId === slotType) {
item = equip;
break;
}
}
if (item) equips = null;
return item;
};
Game_Actor.prototype.equipSlots = function() {
var slots = this.currentClass().equipSlots.slice();
if (slots.length >= 2 && this.isDualWield()) slots = 1;
return slots;
};
Yanfly.Equip.Game_Actor_equips = Game_Actor.prototype.equips;
Game_Actor.prototype.equips = function() {
for (var i = 0; i < this.currentClass().equipSlots.length; ++i) {
if (this._equips === undefined || this._equips === null) {
this._equips = new Game_Item();
}
}
return Yanfly.Equip.Game_Actor_equips.call(this);
};
Yanfly.Equip.Game_Actor_changeEquip = Game_Actor.prototype.changeEquip;
Game_Actor.prototype.changeEquip = function(slotId, item) {
if (!this._equips) this._equips = new Game_Item();
Yanfly.Equip.Game_Actor_changeEquip.call(this, slotId, item);
};
Yanfly.Equip.Game_Actor_forceChangeEquip =
Game_Actor.prototype.forceChangeEquip;
Game_Actor.prototype.forceChangeEquip = function(slotId, item) {
if (!this._equips) {
this._equips = new Game_Item();
this._equips.setEquip(this.equipSlots() === 1, 0);
}
Yanfly.Equip.Game_Actor_forceChangeEquip.call(this, slotId, item);
};
Yanfly.Equip.Game_Actor_isEquipChangeOk = Game_Actor.prototype.isEquipChangeOk;
Game_Actor.prototype.isEquipChangeOk = function(slotId) {
if ($gameTemp._clearEquipments) {
var typeId = this.equipSlots();
if (Yanfly.Param.EquipNonRemove.contains(typeId)) return false;
}
if ($gameTemp._optimizeEquipments) {
var typeId = this.equipSlots();
if (Yanfly.Param.EquipNonOptimized.contains(typeId)) return false;
}
return Yanfly.Equip.Game_Actor_isEquipChangeOk.call(this, slotId);
};
Yanfly.Equip.Game_Actor_paramPlus = Game_Actor.prototype.paramPlus;
Game_Actor.prototype.paramPlus = function(paramId) {
value = Yanfly.Equip.Game_Actor_paramPlus.call(this, paramId);
var equips = this.equips();
for (var i = 0; i < equips.length; i++) {
var item = equips;
if (!item) continue;
value += this.customParamPlus(item, paramId);
value += this.evalParamPlus(item, paramId);
}
return value;
};
Game_Actor.prototype.customParamPlus = function(item, paramId) {
return 0;
};
Game_Actor.prototype.evalParamPlus = function(item, paramId) {
if (!item) return 0;
if (!item.parameterEval || item.parameterEval === '') return 0;
var value = 0;
var hp = 0;
var maxhp = 0;
var mhp = 0;
var mp = 0;
var maxmp = 0;
var mmp = 0;
var sp = 0;
var maxsp = 0;
var msp = 0;
var atk = 0;
var str = 0;
var def = 0;
var mat = 0;
var int = 0;
var spi = 0;
var mdf = 0;
var res = 0;
var agi = 0;
var spd = 0;
var luk = 0;
var all = 0;
var a = this;
var user = this;
var s = $gameSwitches._data;
var v = $gameVariables._data;
eval(item.parameterEval);
switch (paramId) {
case 0:
value += hp + maxhp + mhp;
break;
case 1:
value += mp + maxmp + mmp + sp + maxsp + msp;
break;
case 2:
value += atk + str;
break;
case 3:
value += def;
break;
case 4:
value += mat + int + spi;
break;
case 5:
value += mdf + res;
break;
case 6:
value += agi + spd;
break;
case 7:
value += luk;
break;
}
return value + all;
};
//=============================================================================
// Game_Interpreter
//=============================================================================
// Change Equipment
Game_Interpreter.prototype.command319 = function() {
var actor = $gameActors.actor(this._params);
if (!actor) return true;
var index = actor.equipSlots().indexOf(this._params) + 1;
actor.changeEquipById(index, this._params);
return true;
};
//=============================================================================
// Window_EquipCommand
//=============================================================================
Window_EquipCommand.prototype.windowWidth = function() {
return 240;
};
Window_EquipCommand.prototype.maxCols = function() {
return 1;
};
Window_EquipCommand.prototype.windowHeight = function() {
return this.fittingHeight(this.numVisibleRows());
};
Window_EquipCommand.prototype.numVisibleRows = function() {
return 4;
};
Window_EquipCommand.prototype.itemTextAlign = function() {
return Yanfly.Param.EquipTextAlign;
};
Yanfly.Equip.Window_EquipCommand_makeCommandList =
Window_EquipCommand.prototype.makeCommandList;
Window_EquipCommand.prototype.makeCommandList = function() {
Yanfly.Equip.Window_EquipCommand_makeCommandList.call(this);
this.addCustomCommand();
this.addFinishCommand();
};
Window_EquipCommand.prototype.addCustomCommand = function() {
};
Window_EquipCommand.prototype.addFinishCommand = function() {
this.addCommand(Yanfly.Param.EquipFinishCmd, 'cancel');
};
//=============================================================================
// Window_EquipSlot
//=============================================================================
Yanfly.Equip.Window_EquipSlot_setActor = Window_EquipSlot.prototype.setActor;
Window_EquipSlot.prototype.setActor = function(actor) {
this.setSlotNameWidth(actor);
Yanfly.Equip.Window_EquipSlot_setActor.call(this, actor);
};
Window_EquipSlot.prototype.isEnabled = function(index) {
if (this._actor) {
return Yanfly.Equip.Game_Actor_isEquipChangeOk.call(this._actor, index);
} else {
return false;
}
};
Window_EquipSlot.prototype.drawItem = function(index) {
if (!this._actor) return;
var rect = this.itemRectForText(index);
this.changeTextColor(this.systemColor());
this.changePaintOpacity(this.isEnabled(index));
var ww1 = this._nameWidth;
this.drawText(this.slotName(index), rect.x, rect.y, ww1);
var ww2 = rect.width - ww1;
var item = this._actor.equips();
if (item) {
this.drawItemName(item, rect.x + ww1, rect.y, ww2);
} else {
this.drawEmptySlot(rect.x + ww1, rect.y, ww2);
}
this.changePaintOpacity(true);
};
Window_EquipSlot.prototype.setSlotNameWidth = function(actor) {
if (!actor) return;
this._nameWidth = 0;
for (var i = 0; i < actor.equipSlots().length; ++i) {
var text = $dataSystem.equipTypes[actor.equipSlots()] + ' ';
this._nameWidth = Math.max(this._nameWidth, this.textWidth(text));
}
};
Window_EquipSlot.prototype.drawEmptySlot = function(wx, wy, ww) {
this.changePaintOpacity(false);
var ibw = Window_Base._iconWidth + 4;
this.resetTextColor();
this.drawIcon(Yanfly.Icon.EmptyEquip, wx + 2, wy + 2);
var text = Yanfly.Param.EquipEmptyText;
this.drawText(text, wx + ibw, wy, ww - ibw);
};
//=============================================================================
// Window_EquipItem
//=============================================================================
Window_EquipItem.prototype.maxCols = function() {
return 1;
};
Yanfly.Equip.Window_EquipItem_setSlotId = Window_EquipItem.prototype.setSlotId;
Window_EquipItem.prototype.setSlotId = function(slotId) {
// do nothing
};
Yanfly.Equip.Window_EquipItem_includes = Window_EquipItem.prototype.includes;
Window_EquipItem.prototype.includes = function(item) {
if (item === null && this._actor && this._data.length > 0) {
var typeId = this._actor.equipSlots();
if (Yanfly.Param.EquipNonRemove.contains(typeId)) return false;
}
return Yanfly.Equip.Window_EquipItem_includes.call(this, item);
};
Yanfly.Equip.Window_EquipItem_isEnabled =
Window_EquipItem.prototype.isEnabled;
Window_EquipItem.prototype.isEnabled = function(item) {
if (item === null && this._actor) {
var typeId = this._actor.equipSlots();
if (Yanfly.Param.EquipNonRemove.contains(typeId)) return false;
}
return Yanfly.Equip.Window_EquipItem_isEnabled.call(this, item);
};
Yanfly.Equip.Window_EquipItem_drawItem = Window_EquipItem.prototype.drawItem;
Window_EquipItem.prototype.drawItem = function(index) {
var item = this._data;
if (item === null) {
this.drawRemoveEquip(index);
} else {
Yanfly.Equip.Window_EquipItem_drawItem.call(this, index);
}
};
Window_EquipItem.prototype.drawRemoveEquip = function(index) {
if (!this.isEnabled(null)) return;
var rect = this.itemRect(index);
rect.width -= this.textPadding();
this.changePaintOpacity(true);
var ibw = Window_Base._iconWidth + 4;
this.resetTextColor();
this.drawIcon(Yanfly.Icon.RemoveEquip, rect.x + 2, rect.y + 2);
var text = Yanfly.Param.EquipRemoveText;
this.drawText(text, rect.x + ibw, rect.y, rect.width - ibw);
};
//=============================================================================
// Window_StatCompare
//=============================================================================
function Window_StatCompare() {
this.initialize.apply(this, arguments);
}
Window_StatCompare.prototype = Object.create(Window_Base.prototype);
Window_StatCompare.prototype.constructor = Window_StatCompare;
Window_StatCompare.prototype.initialize = function(wx, wy, ww, wh) {
Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
this._actor = null;
this._tempActor = null;
this.refresh();
};
Window_StatCompare.prototype.createWidths = function() {
this._paramNameWidth = 0;
this._paramValueWidth = 0;
this._arrowWidth = this.textWidth('\u2192' + ' ');
var buffer = this.textWidth(' ');
for (var i = 0; i < 8; ++i) {
var value1 = this.textWidth(TextManager.param(i));
var value2 = this.textWidth(Yanfly.Util.toGroup(this._actor.paramMax(i)));
this._paramNameWidth = Math.max(value1, this._paramNameWidth);
this._paramValueWidth = Math.max(value2, this._paramValueWidth);
}
this._bonusValueWidth = this._paramValueWidth;
this._bonusValueWidth += this.textWidth('(+)') + buffer;
this._paramNameWidth += buffer;
this._paramValueWidth;
if (this._paramNameWidth + this._paramValueWidth * 2 + this._arrowWidth +
this._bonusValueWidth > this.contents.width) this._bonusValueWidth = 0;
};
Window_StatCompare.prototype.setActor = function(actor) {
if (this._actor === actor) return;
this._actor = actor;
this.createWidths();
this.refresh();
};
Window_StatCompare.prototype.refresh = function() {
this.contents.clear();
if (!this._actor) return;
for (var i = 0; i < 8; ++i) {
this.drawItem(0, this.lineHeight() * i, i);
}
};
Window_StatCompare.prototype.setTempActor = function(tempActor) {
if (this._tempActor === tempActor) return;
this._tempActor = tempActor;
this.refresh();
};
Window_StatCompare.prototype.drawItem = function(x, y, paramId) {
this.drawDarkRect(x, y, this.contents.width, this.lineHeight());
this.drawParamName(y, paramId);
this.drawCurrentParam(y, paramId);
this.drawRightArrow(y);
if (!this._tempActor) return;
this.drawNewParam(y, paramId);
this.drawParamDifference(y, paramId);
};
Window_StatCompare.prototype.drawDarkRect = function(dx, dy, dw, dh) {
var color = this.gaugeBackColor();
this.changePaintOpacity(false);
this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
this.changePaintOpacity(true);
};
Window_StatCompare.prototype.drawParamName = function(y, paramId) {
var x = this.textPadding();
this.changeTextColor(this.systemColor());
this.drawText(TextManager.param(paramId), x, y, this._paramNameWidth);
};
Window_StatCompare.prototype.drawCurrentParam = function(y, paramId) {
var x = this.contents.width - this.textPadding();
x -= this._paramValueWidth * 2 + this._arrowWidth + this._bonusValueWidth;
this.resetTextColor();
var actorparam = Yanfly.Util.toGroup(this._actor.param(paramId));
this.drawText(actorparam, x, y, this._paramValueWidth, 'right');
};
Window_StatCompare.prototype.drawRightArrow = function(y) {
var x = this.contents.width - this.textPadding();
x -= this._paramValueWidth + this._arrowWidth + this._bonusValueWidth;
var dw = this.textWidth('\u2192' + ' ');
this.changeTextColor(this.systemColor());
this.drawText('\u2192', x, y, dw, 'center');
};
Window_StatCompare.prototype.drawNewParam = function(y, paramId) {
var x = this.contents.width - this.textPadding();
x -= this._paramValueWidth + this._bonusValueWidth;
var newValue = this._tempActor.param(paramId);
var diffvalue = newValue - this._actor.param(paramId);
var actorparam = Yanfly.Util.toGroup(newValue);
this.changeTextColor(this.paramchangeTextColor(diffvalue));
this.drawText(actorparam, x, y, this._paramValueWidth, 'right');
};
Window_StatCompare.prototype.drawParamDifference = function(y, paramId) {
var x = this.contents.width - this.textPadding();
x -= this._bonusValueWidth;
var newValue = this._tempActor.param(paramId);
var diffvalue = newValue - this._actor.param(paramId);
if (diffvalue === 0) return;
var actorparam = Yanfly.Util.toGroup(newValue);
this.changeTextColor(this.paramchangeTextColor(diffvalue));
var text = Yanfly.Util.toGroup(diffvalue);
if (diffvalue > 0) {
text = ' (+' + text + ')';
} else {
text = ' (' + text + ')';
}
this.drawText(text, x, y, this._bonusValueWidth, 'left');
};
//=============================================================================
// Scene_Equip
//=============================================================================
Scene_Equip.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createHelpWindow();
this.createCommandWindow();
this.createStatusWindow();
this.createSlotWindow();
this.createItemWindow();
this.createCompareWindow();
this.refreshActor();
};
Scene_Equip.prototype.createCommandWindow = function() {
var wy = this._helpWindow.height;
this._commandWindow = new Window_EquipCommand(0, wy, 240);
this._commandWindow.setHelpWindow(this._helpWindow);
this._commandWindow.setHandler('equip', this.commandEquip.bind(this));
this._commandWindow.setHandler('optimize', this.commandOptimize.bind(this));
this._commandWindow.setHandler('clear', this.commandClear.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this._commandWindow.setHandler('pagedown', this.nextActor.bind(this));
this._commandWindow.setHandler('pageup', this.previousActor.bind(this));
this.addWindow(this._commandWindow);
};
Scene_Equip.prototype.createStatusWindow = function() {
var wx = this._commandWindow.width;
var wy = this._helpWindow.height;
var ww = Graphics.boxWidth - wx;
var wh = this._commandWindow.height;
this._statusWindow = new Window_SkillStatus(wx, wy, ww, wh);
this.addWindow(this._statusWindow);
};
Scene_Equip.prototype.createSlotWindow = function() {
var wy = this._commandWindow.y + this._commandWindow.height;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
this._slotWindow = new Window_EquipSlot(0, wy, ww, wh);
this._slotWindow.setHelpWindow(this._helpWindow);
this._slotWindow.setHandler('ok', this.onSlotOk.bind(this));
this._slotWindow.setHandler('cancel', this.onSlotCancel.bind(this));
this.addWindow(this._slotWindow);
};
Scene_Equip.prototype.createItemWindow = function() {
var wy = this._slotWindow.y;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
this._itemWindow = new Window_EquipItem(0, wy, ww, wh);
this._itemWindow.setHelpWindow(this._helpWindow);
this._itemWindow.setHandler('ok', this.onItemOk.bind(this));
this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
this._slotWindow.setItemWindow(this._itemWindow);
this.addWindow(this._itemWindow);
this._itemWindow.hide();
};
Scene_Equip.prototype.createCompareWindow = function() {
var wx = this._itemWindow.width;
var wy = this._itemWindow.y;
var ww = Graphics.boxWidth - wx;
var wh = Graphics.boxHeight - wy;
this._compareWindow = new Window_StatCompare(wx, wy, ww, wh);
this._slotWindow.setStatusWindow(this._compareWindow);
this._itemWindow.setStatusWindow(this._compareWindow);
this.addWindow(this._compareWindow);
};
Yanfly.Equip.Scene_Equip_refreshActor = Scene_Equip.prototype.refreshActor;
Scene_Equip.prototype.refreshActor = function() {
Yanfly.Equip.Scene_Equip_refreshActor.call(this);
this._compareWindow.setActor(this.actor());
};
Yanfly.Equip.Scene_Equip_commandOptimize =
Scene_Equip.prototype.commandOptimize;
Scene_Equip.prototype.commandOptimize = function() {
$gameTemp._optimizeEquipments = true;
var hpRate = this.actor().hp / Math.max(1, this.actor().mhp);
var mpRate = this.actor().mp / Math.max(1, this.actor().mmp);
Yanfly.Equip.Scene_Equip_commandOptimize.call(this);
$gameTemp._optimizeEquipments = false;
var max = this.actor().isDead() ? 0 : 1;
var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate));
this.actor().setHp(hpAmount);
this.actor().setMp(parseInt(this.actor().mmp * mpRate));
this._compareWindow.refresh();
this._statusWindow.refresh();
};
Yanfly.Equip.Scene_Equip_commandClear = Scene_Equip.prototype.commandClear;
Scene_Equip.prototype.commandClear = function() {
$gameTemp._clearEquipments = true;
var hpRate = this.actor().hp / Math.max(1, this.actor().mhp);
var mpRate = this.actor().mp / Math.max(1, this.actor().mmp);
Yanfly.Equip.Scene_Equip_commandClear.call(this);
$gameTemp._clearEquipments = false;
var max = this.actor().isDead() ? 0 : 1;
var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate));
this.actor().setHp(hpAmount);
this.actor().setMp(parseInt(this.actor().mmp * mpRate));
this._compareWindow.refresh();
this._statusWindow.refresh();
};
Yanfly.Equip.Scene_Equip_onSlotOk = Scene_Equip.prototype.onSlotOk;
Scene_Equip.prototype.onSlotOk = function() {
this._itemWindow._slotId = -1;
var slotId = this._slotWindow.index();
Yanfly.Equip.Window_EquipItem_setSlotId.call(this._itemWindow, slotId);
Yanfly.Equip.Scene_Equip_onSlotOk.call(this);
this._itemWindow.show();
};
Yanfly.Equip.Scene_Equip_onItemOk = Scene_Equip.prototype.onItemOk;
Scene_Equip.prototype.onItemOk = function() {
var hpRate = this.actor().hp / Math.max(1, this.actor().mhp);
var mpRate = this.actor().mp / Math.max(1, this.actor().mmp);
Yanfly.Equip.Scene_Equip_onItemOk.call(this);
var max = this.actor().isDead() ? 0 : 1;
var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate));
this.actor().setHp(hpAmount);
this.actor().setMp(parseInt(this.actor().mmp * mpRate));
this._itemWindow.hide();
this._statusWindow.refresh();
};
Yanfly.Equip.Scene_Equip_onItemCancel = Scene_Equip.prototype.onItemCancel;
Scene_Equip.prototype.onItemCancel = function() {
Yanfly.Equip.Scene_Equip_onItemCancel.call(this);
this._itemWindow.hide();
};
//=============================================================================
// Utilities
//=============================================================================
Yanfly.Util = Yanfly.Util || {};
if (!Yanfly.Util.toGroup) {
Yanfly.Util.toGroup = function(inVal) {
return inVal;
}
};
//=============================================================================
// End of File
//=============================================================================
// Yanfly Engine Plugins - Equip Core
// YEP_EquipCore.js
//=============================================================================
var Imported = Imported || {};
Imported.YEP_EquipCore = true;
var Yanfly = Yanfly || {};
Yanfly.Equip = Yanfly.Equip || {};
//=============================================================================
/*:
* @plugindesc v1.08 Allows for the equipment system to be more flexible to
* allow for unique equipment slots per class.
* @author Yanfly Engine Plugins
*
* @param ---General---
* @default
*
* @param Text Align
* @desc How to align the text for the command window.
* left center right
* @default center
*
* @param Finish Command
* @desc The command text used for exiting the equip scene.
* @default Finish
*
* @param Remove Text
* @desc The text used to display the "Remove" command in the equip
* item list.
* @default Remove
*
* @param Remove Icon
* @desc The icon used to display next to the "Remove" command in
* the equip item list.
* @default 16
*
* @param Empty Text
* @desc The text used to display an "Empty" piece of equipment.
* @default <Empty>
*
* @param Empty Icon
* @desc The icon used to display next to the "Empty" piece of
* equipment in the equipment list.
* @default 16
*
* @param ---Rules---
* @default
*
* @param Non-Removable Types
* @desc These types must always have an item equipped and cannot
* be empty. Separate the type ID's by a space.
* @default 1
*
* @param Non-Optimized Types
* @desc These types will be ignored when the actor optimizes
* equips. Separate the type ID's by a space.
* @default 5
*
* @help
* ============================================================================
* Introduction
* ============================================================================
*
* This plugin alters various aspects regarding equipment handling. The changes
* are as listed:
*
* 1. Scene_Equip
* Scene_Equip has been modified to look differently. This is primarily done to
* make the main menu scenes look uniform and keep everything familiar for
* players. Furthermore, the command window has been adjusted to be better fit
* for extension plugins in the future that may add commands to the command
* window and/or the scene.
*
* 2. Equipment Type Handling
* Characters will no longer have one universal equipment slot setting. Now,
* different classes can use different setups by simply adding a few notetags
* to the class notebox. Furthermore, equipment types in the past with matching
* names would be treated as separate types. Now, equipment types with matching
* names will be treated as the same type.
*
* 3. Equipment Rulings
* Now, certain equipment types can or cannot be removed. For example, this
* plugin can set it so that the Weapon slot must always have something
* equipped and that the player cannot manually leave it empty (the game, on
* the other hand, can achieve this through events). In addition to that,
* optimizing equipment can be restricted for certain equipment types, which
* are better off being decided manually (such as accessories).
*
* 4. Parameter Control
* Equipment parameters can now to be adjusted through notetags to have a large
* value or customized value (through code). This allows for equipment to no
* longer be static items, but instead, equipment can now be dynamic and may
* change over the course of the game.
*
* ============================================================================
* Notetags
* ============================================================================
*
* You can use the following notetags to change a class's equipment setup.
*
* Class Notetags:
* <Equip Slot: x> Example: <Equip Slot: 1, 2, 3, 4, 5, 5, 5, 5>
* <Equip Slot: x, x, x>
* Changes this class's equipment slots to x. Using repeating numbers makes
* it so that equipment type is duplicated and that the class can equip
* multiple equipment of that type. To find the Equipment Type ID, go to your
* database's Types tab and look for the ID type.
*
* If you don't like the above method for setting equipment slots, you can
* use the following notetags instead:
*
* <Equip Slot> Example: <Equip Slot>
* string Weapon
* string Armor
* string Accessory
* string Accessory
* </Equip Slot> </Equip Slot>
* Replace 'string' with the Equipment type's name entry. This is case
* sensitive so if the string does not match a name entry perfectly, the slot
* will not be granted to the class. Multiple copies of a name entry would
* mean the class can equip multiple equipment of that type. Everything works
* the same as the previous notetag.
*
* Weapon and Armor Notetags:
* <stat: +x>
* <stat: -x>
* Allows the piece of weapon or armor to gain or lose x amount of stat.
* Replace "stat" with "hp", "mp", "atk", "def", "mat", "mdf", "agi", or
* "luk" to alter that specific stat. This allows the piece of equipment
* to go past the editor's default limitation so long as the maximum value
* allows for it. Changes made here alter the base parameters.
*
* ============================================================================
* Lunatic Mode - Custom Parameters
* ============================================================================
*
* <Custom Parameters> Example: <Custom Parameters>
* code atk = $gameVariables.value(1);
* code mat = atk / 2;
* code all = $gameParty.members().length;
* code </Custom Parameters>
* </Code Parameters>
* Allows for parameters to have custom rates adjusted by code. The following
* parameters are defined: 'maxhp', 'maxmp', 'atk', 'def', 'mat', 'mdf',
* 'agi', 'luk', and 'all'. The 'all' parameter will affect all parameters.
* Changes made here do not alter the base parameters, but instead, are added
* onto the base parameters.
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 1.08:
* - Fixed a bug where changing an actor's equips would revive them if dead.
*
* Version 1.07:
* - Fixed a bug with 'Optimize' and 'Remove All' not refreshing windows.
*
* Version 1.06:
* - Fixed a bug with 'Change Equipment' event where it would only change the
* slot of the marked equipment rather than the slot type.
*
* Version 1.05:
* - Fixed an issue where unequipping items can kill actors.
*
* Version 1.04a:
* - Fixed a bug and rewrote the initializing equipment process.
*
* Version 1.03:
* - Fixed an bug that resulted in null object errors.
*
* Version 1.02:
* - Fixed an issue that did not keep HP and MP rates the same when using the
* optimize and clear commands.
*
* Version 1.01:
* - Fixed a bug that did not update the stats properly when compared.
*
* Version 1.00:
* - Finished plugin!
*/
//=============================================================================
//=============================================================================
// Parameter Variables
//=============================================================================
Yanfly.Parameters = PluginManager.parameters('YEP_EquipCore');
Yanfly.Param = Yanfly.Param || {};
Yanfly.Icon = Yanfly.Icon || {};
Yanfly.Param.EquipTextAlign = String(Yanfly.Parameters);
Yanfly.Param.EquipFinishCmd = String(Yanfly.Parameters);
Yanfly.Param.EquipRemoveText = String(Yanfly.Parameters);
Yanfly.Icon.RemoveEquip = Number(Yanfly.Parameters);
Yanfly.Param.EquipEmptyText = String(Yanfly.Parameters);
Yanfly.Icon.EmptyEquip = Number(Yanfly.Parameters);
Yanfly.Data = String(Yanfly.Parameters);
Yanfly.Data = Yanfly.Data.split(' ');
Yanfly.Param.EquipNonRemove = ;
for (Yanfly.i = 0; Yanfly.i < Yanfly.Data.length; ++Yanfly.i) {
Yanfly.Param.EquipNonRemove.push(parseInt(Yanfly.Data));
};
Yanfly.Data = String(Yanfly.Parameters);
Yanfly.Data = Yanfly.Data.split(' ');
Yanfly.Param.EquipNonOptimized = ;
for (Yanfly.i = 0; Yanfly.i < Yanfly.Data.length; ++Yanfly.i) {
Yanfly.Param.EquipNonOptimized.push(parseInt(Yanfly.Data));
};
//=============================================================================
// DataManager
//=============================================================================
Yanfly.Equip.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!Yanfly.Equip.DataManager_isDatabaseLoaded.call(this)) return false;
DataManager.processEquipNotetags1($dataClasses);
DataManager.processEquipNotetags2($dataWeapons);
DataManager.processEquipNotetags2($dataArmors);
return true;
};
DataManager.processEquipNotetags1 = function(group) {
var note1 = /<(?:EQUIP SLOT|equip slots):*(\d+(?:\s*,\s*\d+)*)>/i;
var note2 = /<(?:EQUIP SLOT|equip slots)>/i;
var note3 = /<\/(?:EQUIP SLOT|equip slots)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group;
var notedata = obj.note.split(/+/);
obj.equipSlots = ;
var equipSlots = false;
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
var array = JSON.parse('');
obj.equipSlots = obj.equipSlots.concat(array);
} else if (line.match(note2)) {
equipSlots = true;
} else if (line.match(note3)) {
equipSlots = false;
} else if (equipSlots && line.match(/*(.*)/i)) {
var name = String(RegExp.$1);
var slotId = $dataSystem.equipTypes.indexOf(name);
if (slotId >= 0) obj.equipSlots.push(slotId);
}
}
if (obj.equipSlots.length <= 0) this.setDefaultEquipSlots(obj);
}
};
DataManager.setDefaultEquipSlots = function(obj) {
for (var i = 1; i < $dataSystem.equipTypes.length; ++i) {
var name = $dataSystem.equipTypes;
var slotId = $dataSystem.equipTypes.indexOf(name);
if (slotId >= 0) obj.equipSlots.push(slotId);
}
};
DataManager.processEquipNotetags2 = function(group) {
var note1 = /<(?:PARAMETER EVAL|custom parameter|custom parameters)>/i;
var note2 = /<\/(?:PARAMETER EVAL|custom parameter|custom parameters)>/i;
var note3 = /<(.*):(\d+)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group;
var notedata = obj.note.split(/+/);
obj.parameterEval = '';
var parameterEval = false;
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
parameterEval = true;
} else if (line.match(note2)) {
parameterEval = false;
} else if (parameterEval) {
obj.parameterEval = obj.parameterEval + line + '\n';
} else if (line.match(note3)) {
var stat = String(RegExp.$1).toUpperCase();
var value = parseInt(RegExp.$2);
switch (stat) {
case 'HP':
case 'MAXHP':
case 'MAX HP':
obj.params = value;
break;
case 'MP':
case 'MAXMP':
case 'MAX MP':
case 'SP':
case 'MAXSP':
case 'MAX SP':
obj.params = value;
break;
case 'ATK':
case 'STR':
obj.params = value;
break;
case 'DEF':
obj.params = value;
break;
case 'MAT':
case 'INT' || 'SPI':
obj.params = value;
break;
case 'MDF':
case 'RES':
obj.params = value;
break;
case 'AGI':
case 'SPD':
obj.params = value;
break;
case 'LUK':
obj.params = value;
break;
}
}
}
}
};
//=============================================================================
// Game_Actor
//=============================================================================
Game_Actor.prototype.initEquips = function(equips) {
var equips = this.convertInitEquips(equips);
this.equipInitEquips(equips);
this.releaseUnequippableItems(true);
this.recoverAll();
this.refresh();
};
Game_Actor.prototype.convertInitEquips = function(equips) {
var items = ;
for (var i = 0; i < equips.length; ++i) {
var equipId = equips;
if (equipId <= 0) continue;
var equipType = $dataSystem.equipTypes;
if (equipType === $dataSystem.equipTypes ||
(i === 1 && this.isDualWield())) {
var equip = $dataWeapons;
} else {
var equip = $dataArmors;
}
items.push(equip);
}
return items;
};
Game_Actor.prototype.equipInitEquips = function(equips) {
var slots = this.equipSlots();
var maxSlots = slots.length;
this._equips = ;
for (var i = 0; i < maxSlots; ++i) {
this._equips = new Game_Item();
}
for (var i = 0; i < maxSlots; ++i) {
var slotType = slots;
var equip = this.grabInitEquips(equips, slotType);
if (this.canEquip(equip)) this._equips.setObject(equip);
}
};
Game_Actor.prototype.grabInitEquips = function(equips, slotType) {
var item = null;
for (var i = 0; i < equips.length; ++i) {
var equip = equips;
if (!equip) continue;
if (slotType === 1 && DataManager.isWeapon(equip)) {
item = equip;
break;
} else if (equip.etypeId === slotType) {
item = equip;
break;
}
}
if (item) equips = null;
return item;
};
Game_Actor.prototype.equipSlots = function() {
var slots = this.currentClass().equipSlots.slice();
if (slots.length >= 2 && this.isDualWield()) slots = 1;
return slots;
};
Yanfly.Equip.Game_Actor_equips = Game_Actor.prototype.equips;
Game_Actor.prototype.equips = function() {
for (var i = 0; i < this.currentClass().equipSlots.length; ++i) {
if (this._equips === undefined || this._equips === null) {
this._equips = new Game_Item();
}
}
return Yanfly.Equip.Game_Actor_equips.call(this);
};
Yanfly.Equip.Game_Actor_changeEquip = Game_Actor.prototype.changeEquip;
Game_Actor.prototype.changeEquip = function(slotId, item) {
if (!this._equips) this._equips = new Game_Item();
Yanfly.Equip.Game_Actor_changeEquip.call(this, slotId, item);
};
Yanfly.Equip.Game_Actor_forceChangeEquip =
Game_Actor.prototype.forceChangeEquip;
Game_Actor.prototype.forceChangeEquip = function(slotId, item) {
if (!this._equips) {
this._equips = new Game_Item();
this._equips.setEquip(this.equipSlots() === 1, 0);
}
Yanfly.Equip.Game_Actor_forceChangeEquip.call(this, slotId, item);
};
Yanfly.Equip.Game_Actor_isEquipChangeOk = Game_Actor.prototype.isEquipChangeOk;
Game_Actor.prototype.isEquipChangeOk = function(slotId) {
if ($gameTemp._clearEquipments) {
var typeId = this.equipSlots();
if (Yanfly.Param.EquipNonRemove.contains(typeId)) return false;
}
if ($gameTemp._optimizeEquipments) {
var typeId = this.equipSlots();
if (Yanfly.Param.EquipNonOptimized.contains(typeId)) return false;
}
return Yanfly.Equip.Game_Actor_isEquipChangeOk.call(this, slotId);
};
Yanfly.Equip.Game_Actor_paramPlus = Game_Actor.prototype.paramPlus;
Game_Actor.prototype.paramPlus = function(paramId) {
value = Yanfly.Equip.Game_Actor_paramPlus.call(this, paramId);
var equips = this.equips();
for (var i = 0; i < equips.length; i++) {
var item = equips;
if (!item) continue;
value += this.customParamPlus(item, paramId);
value += this.evalParamPlus(item, paramId);
}
return value;
};
Game_Actor.prototype.customParamPlus = function(item, paramId) {
return 0;
};
Game_Actor.prototype.evalParamPlus = function(item, paramId) {
if (!item) return 0;
if (!item.parameterEval || item.parameterEval === '') return 0;
var value = 0;
var hp = 0;
var maxhp = 0;
var mhp = 0;
var mp = 0;
var maxmp = 0;
var mmp = 0;
var sp = 0;
var maxsp = 0;
var msp = 0;
var atk = 0;
var str = 0;
var def = 0;
var mat = 0;
var int = 0;
var spi = 0;
var mdf = 0;
var res = 0;
var agi = 0;
var spd = 0;
var luk = 0;
var all = 0;
var a = this;
var user = this;
var s = $gameSwitches._data;
var v = $gameVariables._data;
eval(item.parameterEval);
switch (paramId) {
case 0:
value += hp + maxhp + mhp;
break;
case 1:
value += mp + maxmp + mmp + sp + maxsp + msp;
break;
case 2:
value += atk + str;
break;
case 3:
value += def;
break;
case 4:
value += mat + int + spi;
break;
case 5:
value += mdf + res;
break;
case 6:
value += agi + spd;
break;
case 7:
value += luk;
break;
}
return value + all;
};
//=============================================================================
// Game_Interpreter
//=============================================================================
// Change Equipment
Game_Interpreter.prototype.command319 = function() {
var actor = $gameActors.actor(this._params);
if (!actor) return true;
var index = actor.equipSlots().indexOf(this._params) + 1;
actor.changeEquipById(index, this._params);
return true;
};
//=============================================================================
// Window_EquipCommand
//=============================================================================
Window_EquipCommand.prototype.windowWidth = function() {
return 240;
};
Window_EquipCommand.prototype.maxCols = function() {
return 1;
};
Window_EquipCommand.prototype.windowHeight = function() {
return this.fittingHeight(this.numVisibleRows());
};
Window_EquipCommand.prototype.numVisibleRows = function() {
return 4;
};
Window_EquipCommand.prototype.itemTextAlign = function() {
return Yanfly.Param.EquipTextAlign;
};
Yanfly.Equip.Window_EquipCommand_makeCommandList =
Window_EquipCommand.prototype.makeCommandList;
Window_EquipCommand.prototype.makeCommandList = function() {
Yanfly.Equip.Window_EquipCommand_makeCommandList.call(this);
this.addCustomCommand();
this.addFinishCommand();
};
Window_EquipCommand.prototype.addCustomCommand = function() {
};
Window_EquipCommand.prototype.addFinishCommand = function() {
this.addCommand(Yanfly.Param.EquipFinishCmd, 'cancel');
};
//=============================================================================
// Window_EquipSlot
//=============================================================================
Yanfly.Equip.Window_EquipSlot_setActor = Window_EquipSlot.prototype.setActor;
Window_EquipSlot.prototype.setActor = function(actor) {
this.setSlotNameWidth(actor);
Yanfly.Equip.Window_EquipSlot_setActor.call(this, actor);
};
Window_EquipSlot.prototype.isEnabled = function(index) {
if (this._actor) {
return Yanfly.Equip.Game_Actor_isEquipChangeOk.call(this._actor, index);
} else {
return false;
}
};
Window_EquipSlot.prototype.drawItem = function(index) {
if (!this._actor) return;
var rect = this.itemRectForText(index);
this.changeTextColor(this.systemColor());
this.changePaintOpacity(this.isEnabled(index));
var ww1 = this._nameWidth;
this.drawText(this.slotName(index), rect.x, rect.y, ww1);
var ww2 = rect.width - ww1;
var item = this._actor.equips();
if (item) {
this.drawItemName(item, rect.x + ww1, rect.y, ww2);
} else {
this.drawEmptySlot(rect.x + ww1, rect.y, ww2);
}
this.changePaintOpacity(true);
};
Window_EquipSlot.prototype.setSlotNameWidth = function(actor) {
if (!actor) return;
this._nameWidth = 0;
for (var i = 0; i < actor.equipSlots().length; ++i) {
var text = $dataSystem.equipTypes[actor.equipSlots()] + ' ';
this._nameWidth = Math.max(this._nameWidth, this.textWidth(text));
}
};
Window_EquipSlot.prototype.drawEmptySlot = function(wx, wy, ww) {
this.changePaintOpacity(false);
var ibw = Window_Base._iconWidth + 4;
this.resetTextColor();
this.drawIcon(Yanfly.Icon.EmptyEquip, wx + 2, wy + 2);
var text = Yanfly.Param.EquipEmptyText;
this.drawText(text, wx + ibw, wy, ww - ibw);
};
//=============================================================================
// Window_EquipItem
//=============================================================================
Window_EquipItem.prototype.maxCols = function() {
return 1;
};
Yanfly.Equip.Window_EquipItem_setSlotId = Window_EquipItem.prototype.setSlotId;
Window_EquipItem.prototype.setSlotId = function(slotId) {
// do nothing
};
Yanfly.Equip.Window_EquipItem_includes = Window_EquipItem.prototype.includes;
Window_EquipItem.prototype.includes = function(item) {
if (item === null && this._actor && this._data.length > 0) {
var typeId = this._actor.equipSlots();
if (Yanfly.Param.EquipNonRemove.contains(typeId)) return false;
}
return Yanfly.Equip.Window_EquipItem_includes.call(this, item);
};
Yanfly.Equip.Window_EquipItem_isEnabled =
Window_EquipItem.prototype.isEnabled;
Window_EquipItem.prototype.isEnabled = function(item) {
if (item === null && this._actor) {
var typeId = this._actor.equipSlots();
if (Yanfly.Param.EquipNonRemove.contains(typeId)) return false;
}
return Yanfly.Equip.Window_EquipItem_isEnabled.call(this, item);
};
Yanfly.Equip.Window_EquipItem_drawItem = Window_EquipItem.prototype.drawItem;
Window_EquipItem.prototype.drawItem = function(index) {
var item = this._data;
if (item === null) {
this.drawRemoveEquip(index);
} else {
Yanfly.Equip.Window_EquipItem_drawItem.call(this, index);
}
};
Window_EquipItem.prototype.drawRemoveEquip = function(index) {
if (!this.isEnabled(null)) return;
var rect = this.itemRect(index);
rect.width -= this.textPadding();
this.changePaintOpacity(true);
var ibw = Window_Base._iconWidth + 4;
this.resetTextColor();
this.drawIcon(Yanfly.Icon.RemoveEquip, rect.x + 2, rect.y + 2);
var text = Yanfly.Param.EquipRemoveText;
this.drawText(text, rect.x + ibw, rect.y, rect.width - ibw);
};
//=============================================================================
// Window_StatCompare
//=============================================================================
function Window_StatCompare() {
this.initialize.apply(this, arguments);
}
Window_StatCompare.prototype = Object.create(Window_Base.prototype);
Window_StatCompare.prototype.constructor = Window_StatCompare;
Window_StatCompare.prototype.initialize = function(wx, wy, ww, wh) {
Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
this._actor = null;
this._tempActor = null;
this.refresh();
};
Window_StatCompare.prototype.createWidths = function() {
this._paramNameWidth = 0;
this._paramValueWidth = 0;
this._arrowWidth = this.textWidth('\u2192' + ' ');
var buffer = this.textWidth(' ');
for (var i = 0; i < 8; ++i) {
var value1 = this.textWidth(TextManager.param(i));
var value2 = this.textWidth(Yanfly.Util.toGroup(this._actor.paramMax(i)));
this._paramNameWidth = Math.max(value1, this._paramNameWidth);
this._paramValueWidth = Math.max(value2, this._paramValueWidth);
}
this._bonusValueWidth = this._paramValueWidth;
this._bonusValueWidth += this.textWidth('(+)') + buffer;
this._paramNameWidth += buffer;
this._paramValueWidth;
if (this._paramNameWidth + this._paramValueWidth * 2 + this._arrowWidth +
this._bonusValueWidth > this.contents.width) this._bonusValueWidth = 0;
};
Window_StatCompare.prototype.setActor = function(actor) {
if (this._actor === actor) return;
this._actor = actor;
this.createWidths();
this.refresh();
};
Window_StatCompare.prototype.refresh = function() {
this.contents.clear();
if (!this._actor) return;
for (var i = 0; i < 8; ++i) {
this.drawItem(0, this.lineHeight() * i, i);
}
};
Window_StatCompare.prototype.setTempActor = function(tempActor) {
if (this._tempActor === tempActor) return;
this._tempActor = tempActor;
this.refresh();
};
Window_StatCompare.prototype.drawItem = function(x, y, paramId) {
this.drawDarkRect(x, y, this.contents.width, this.lineHeight());
this.drawParamName(y, paramId);
this.drawCurrentParam(y, paramId);
this.drawRightArrow(y);
if (!this._tempActor) return;
this.drawNewParam(y, paramId);
this.drawParamDifference(y, paramId);
};
Window_StatCompare.prototype.drawDarkRect = function(dx, dy, dw, dh) {
var color = this.gaugeBackColor();
this.changePaintOpacity(false);
this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
this.changePaintOpacity(true);
};
Window_StatCompare.prototype.drawParamName = function(y, paramId) {
var x = this.textPadding();
this.changeTextColor(this.systemColor());
this.drawText(TextManager.param(paramId), x, y, this._paramNameWidth);
};
Window_StatCompare.prototype.drawCurrentParam = function(y, paramId) {
var x = this.contents.width - this.textPadding();
x -= this._paramValueWidth * 2 + this._arrowWidth + this._bonusValueWidth;
this.resetTextColor();
var actorparam = Yanfly.Util.toGroup(this._actor.param(paramId));
this.drawText(actorparam, x, y, this._paramValueWidth, 'right');
};
Window_StatCompare.prototype.drawRightArrow = function(y) {
var x = this.contents.width - this.textPadding();
x -= this._paramValueWidth + this._arrowWidth + this._bonusValueWidth;
var dw = this.textWidth('\u2192' + ' ');
this.changeTextColor(this.systemColor());
this.drawText('\u2192', x, y, dw, 'center');
};
Window_StatCompare.prototype.drawNewParam = function(y, paramId) {
var x = this.contents.width - this.textPadding();
x -= this._paramValueWidth + this._bonusValueWidth;
var newValue = this._tempActor.param(paramId);
var diffvalue = newValue - this._actor.param(paramId);
var actorparam = Yanfly.Util.toGroup(newValue);
this.changeTextColor(this.paramchangeTextColor(diffvalue));
this.drawText(actorparam, x, y, this._paramValueWidth, 'right');
};
Window_StatCompare.prototype.drawParamDifference = function(y, paramId) {
var x = this.contents.width - this.textPadding();
x -= this._bonusValueWidth;
var newValue = this._tempActor.param(paramId);
var diffvalue = newValue - this._actor.param(paramId);
if (diffvalue === 0) return;
var actorparam = Yanfly.Util.toGroup(newValue);
this.changeTextColor(this.paramchangeTextColor(diffvalue));
var text = Yanfly.Util.toGroup(diffvalue);
if (diffvalue > 0) {
text = ' (+' + text + ')';
} else {
text = ' (' + text + ')';
}
this.drawText(text, x, y, this._bonusValueWidth, 'left');
};
//=============================================================================
// Scene_Equip
//=============================================================================
Scene_Equip.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createHelpWindow();
this.createCommandWindow();
this.createStatusWindow();
this.createSlotWindow();
this.createItemWindow();
this.createCompareWindow();
this.refreshActor();
};
Scene_Equip.prototype.createCommandWindow = function() {
var wy = this._helpWindow.height;
this._commandWindow = new Window_EquipCommand(0, wy, 240);
this._commandWindow.setHelpWindow(this._helpWindow);
this._commandWindow.setHandler('equip', this.commandEquip.bind(this));
this._commandWindow.setHandler('optimize', this.commandOptimize.bind(this));
this._commandWindow.setHandler('clear', this.commandClear.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this._commandWindow.setHandler('pagedown', this.nextActor.bind(this));
this._commandWindow.setHandler('pageup', this.previousActor.bind(this));
this.addWindow(this._commandWindow);
};
Scene_Equip.prototype.createStatusWindow = function() {
var wx = this._commandWindow.width;
var wy = this._helpWindow.height;
var ww = Graphics.boxWidth - wx;
var wh = this._commandWindow.height;
this._statusWindow = new Window_SkillStatus(wx, wy, ww, wh);
this.addWindow(this._statusWindow);
};
Scene_Equip.prototype.createSlotWindow = function() {
var wy = this._commandWindow.y + this._commandWindow.height;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
this._slotWindow = new Window_EquipSlot(0, wy, ww, wh);
this._slotWindow.setHelpWindow(this._helpWindow);
this._slotWindow.setHandler('ok', this.onSlotOk.bind(this));
this._slotWindow.setHandler('cancel', this.onSlotCancel.bind(this));
this.addWindow(this._slotWindow);
};
Scene_Equip.prototype.createItemWindow = function() {
var wy = this._slotWindow.y;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
this._itemWindow = new Window_EquipItem(0, wy, ww, wh);
this._itemWindow.setHelpWindow(this._helpWindow);
this._itemWindow.setHandler('ok', this.onItemOk.bind(this));
this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
this._slotWindow.setItemWindow(this._itemWindow);
this.addWindow(this._itemWindow);
this._itemWindow.hide();
};
Scene_Equip.prototype.createCompareWindow = function() {
var wx = this._itemWindow.width;
var wy = this._itemWindow.y;
var ww = Graphics.boxWidth - wx;
var wh = Graphics.boxHeight - wy;
this._compareWindow = new Window_StatCompare(wx, wy, ww, wh);
this._slotWindow.setStatusWindow(this._compareWindow);
this._itemWindow.setStatusWindow(this._compareWindow);
this.addWindow(this._compareWindow);
};
Yanfly.Equip.Scene_Equip_refreshActor = Scene_Equip.prototype.refreshActor;
Scene_Equip.prototype.refreshActor = function() {
Yanfly.Equip.Scene_Equip_refreshActor.call(this);
this._compareWindow.setActor(this.actor());
};
Yanfly.Equip.Scene_Equip_commandOptimize =
Scene_Equip.prototype.commandOptimize;
Scene_Equip.prototype.commandOptimize = function() {
$gameTemp._optimizeEquipments = true;
var hpRate = this.actor().hp / Math.max(1, this.actor().mhp);
var mpRate = this.actor().mp / Math.max(1, this.actor().mmp);
Yanfly.Equip.Scene_Equip_commandOptimize.call(this);
$gameTemp._optimizeEquipments = false;
var max = this.actor().isDead() ? 0 : 1;
var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate));
this.actor().setHp(hpAmount);
this.actor().setMp(parseInt(this.actor().mmp * mpRate));
this._compareWindow.refresh();
this._statusWindow.refresh();
};
Yanfly.Equip.Scene_Equip_commandClear = Scene_Equip.prototype.commandClear;
Scene_Equip.prototype.commandClear = function() {
$gameTemp._clearEquipments = true;
var hpRate = this.actor().hp / Math.max(1, this.actor().mhp);
var mpRate = this.actor().mp / Math.max(1, this.actor().mmp);
Yanfly.Equip.Scene_Equip_commandClear.call(this);
$gameTemp._clearEquipments = false;
var max = this.actor().isDead() ? 0 : 1;
var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate));
this.actor().setHp(hpAmount);
this.actor().setMp(parseInt(this.actor().mmp * mpRate));
this._compareWindow.refresh();
this._statusWindow.refresh();
};
Yanfly.Equip.Scene_Equip_onSlotOk = Scene_Equip.prototype.onSlotOk;
Scene_Equip.prototype.onSlotOk = function() {
this._itemWindow._slotId = -1;
var slotId = this._slotWindow.index();
Yanfly.Equip.Window_EquipItem_setSlotId.call(this._itemWindow, slotId);
Yanfly.Equip.Scene_Equip_onSlotOk.call(this);
this._itemWindow.show();
};
Yanfly.Equip.Scene_Equip_onItemOk = Scene_Equip.prototype.onItemOk;
Scene_Equip.prototype.onItemOk = function() {
var hpRate = this.actor().hp / Math.max(1, this.actor().mhp);
var mpRate = this.actor().mp / Math.max(1, this.actor().mmp);
Yanfly.Equip.Scene_Equip_onItemOk.call(this);
var max = this.actor().isDead() ? 0 : 1;
var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate));
this.actor().setHp(hpAmount);
this.actor().setMp(parseInt(this.actor().mmp * mpRate));
this._itemWindow.hide();
this._statusWindow.refresh();
};
Yanfly.Equip.Scene_Equip_onItemCancel = Scene_Equip.prototype.onItemCancel;
Scene_Equip.prototype.onItemCancel = function() {
Yanfly.Equip.Scene_Equip_onItemCancel.call(this);
this._itemWindow.hide();
};
//=============================================================================
// Utilities
//=============================================================================
Yanfly.Util = Yanfly.Util || {};
if (!Yanfly.Util.toGroup) {
Yanfly.Util.toGroup = function(inVal) {
return inVal;
}
};
//=============================================================================
// End of File
//=============================================================================













