KYUSEF'S PROFILE
Kyusef
0
Search
Filter
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
//=============================================================================
[RMMV] Help: DoubleX Unison item doesn't work!
[RMMV] Problem with Yanfly battle core engine?
[RMMV] Help: DoubleX Unison item doesn't work!
[RMMV] Help: DoubleX Unison item doesn't work!
[RMMV] Multi elemental skill
The skill deals three separate damage, so just 1/3 of damage will be absorbed. I can't find a plugin for my case :(
[RMMV] Multi elemental skill
Unfortunally no, because i use absorb element plugin, so if i make a skill with fire, ice and thunder, an enemy must absorb just its element
[RMMV] Multi elemental skill
[RMMV] Help: DoubleX Unison item doesn't work!
Thank you for your reply. I have placed "Unison Item Default" below "Unison Item Config" (in the same plug in, right?) and i have added your code in the end of plugin, but it doesn't work: the character use the unison skill individually, and the next characters can attack as the plugin is turned off...













