Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // ICF-Soft Plugins - Element Core
- // ICFSoft_ElementCore.js
- //=============================================================================
- var Imported = Imported || {};
- Imported.ICFSoft_ElementCore = true;
- var ICF = ICF || {};
- ICF.ElementCore = ICF.ElementCore || {};
- //=============================================================================
- /*:
- * @plugindesc v1.01b This plugin adds an advanced element system.
- * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
- *
- * @param Elements Blend
- * @desc How to apply when there are more than one element.
- * 0 - Average 1 - Normal 2 - Absorb first
- * @default 2
- *
- * @param Absorbtion Mode
- * @desc How to treat element absorbtion.
- * 0 - Absolute 1 - Relative
- * @default 1
- *
- * @param Curse Absorb Mode
- * @desc How to treat element curse for absorbing elements.
- * 0 - Fixed 1 - Additive 2 - Relative
- * @default 2
- *
- * @param Curse Absorb Factor
- * @desc Used factor to treat element curse for absorbing elements.
- * @default -0.1
- *
- * @param Curse Absorb Min
- * @desc Minimun rate.
- * @default 0.1
- *
- * @param Curse Neutral
- * @desc Fixed rate for element curse on neutral elements.
- * Also max rate for absorbtion and nin rate for normal.
- * @default 2
- *
- * @param Curse Normal Mode
- * @desc How to treat element curse for normal elements.
- * 0 - Fixed 1 - Additive 2 - Relative
- * @default 1
- *
- * @param Curse Normal Factor
- * @desc Used factor to treat element curse for normal elements.
- * @default 1
- *
- * @help
- * ============================================================================
- * Introduction
- * ============================================================================
- *
- * Defalut element system in RPG Maker MV is limited and doesn't allow
- * absorbtion.
- *
- * With this plugin you can use not only elements but skill and weapon types
- * plus element absorbtion. Also is element/skill/weapon enhaces added.
- *
- * This new formula makes more things important and gives extra depth in
- * tactics.
- *
- * Now you can make magic resistance, bulletproof and so on.
- *
- * New element curse feature allows to change element absorbtion into
- * weakness.
- *
- * ============================================================================
- * How to use
- * ============================================================================
- *
- * It works with notetags. These can be used in actors, classes, enemies,
- * weapons, armors and states.
- *
- * <ELEMENT ABSORB: x>
- * <ELEMENT ABSORB: x, x>
- *
- * - Add all elements that can be absorbed in one line.
- *
- * <ELEMENT CURSES: x>
- * <ELEMENT CURSES: x, x>
- *
- * - Add all element curses in one line.
- *
- * <WEAPON ELEMENTS: x>
- * <WEAPON ELEMENTS: x, x>
- *
- * - Add all weapon elements that are used in one line.
- * Usefull for enemies and for unarmed actors.
- * 0 is barehands. Used for actors when need a weapontype but hasn't one.
- *
- * <WEAPON RESISTANCES: x rate>
- * <WEAPON RESISTANCES: x rate, x rate>
- *
- * - Add all weapon resistances needed in one line.
- * rate: can be decimal where 1 is normal, 0.5 is half,
- * 2 is double, etc...
- *
- * <SKILL RESISTANCES: x rate>
- * <SKILL RESISTANCES: x rate, x rate>
- *
- * - Add all skill resistances needed in one line.
- * rate: can be decimal where 1 is normal, 0.5 is half,
- * 2 is double, etc...
- *
- * Skill resistance triggers on every skill that came with skilltype.
- *
- * Weapon resistance triggers on physical skills and weapon using skills.
- *
- * <ELEMENT ENHANCES: x rate>
- * <ELEMENT ENHANCES: x rate, x rate>
- * <SKILL ENHANCES: x rate>
- * <SKILL ENHANCES: x rate, x rate>
- * <WEAPON ENHANCES: x rate>
- * <WEAPON ENHANCES: x rate, x rate>
- *
- * - Add all element, skill and weapon enhacements needed in one line.
- * rate: can be decimal where 1 is normal, 0.5 is half,
- * 2 is double, etc...
- *
- * ============================================================================
- * Params
- * ============================================================================
- *
- * Elements Blend:
- *
- * Behavior when more than one element are used.
- *
- * 0 - Average: Calcs entire element average.
- * 1 - Normal: Strongest element takes priority.
- * 2 - Absorb first: If there is an absorbing element will take priority.
- *
- * Absorbtion Mode:
- *
- * How element absorbtion is treated changes the way players must choose
- * equipment.
- *
- * 0 - Absolute: Element defense increase absorbtion.
- * 1 - Relative: Element defense reduces absorbtion same way as damage.
- *
- * There are some parameters for element curse.
- *
- * Curse Absorb Mode / Curse Normal Mode:
- *
- * When rate is different than cero, either for absorbtion, resistance,
- * normal or weak, it needs a calculation based on actual rate.
- * You can use a different mode for negative and positive values.
- *
- * 0 - Fixed: Rate will be substituyed with factor.
- * 1 - Additive: Will increase rate with factor.
- * 2 - Relative: Will multiply rate with factor.
- *
- * Curse Absorb Factor / Curse Normal Factor:
- *
- * The factor that will be used to calc rate.
- *
- * Curse Absorb Min:
- *
- * A min rate for absorb.
- *
- * Curse Neutral:
- *
- * Neutral is when rate is equal to cero, inmunity.
- * This is a fixed rate so it needs to change to a another fixed rate.
- * It's also used as max rate when absorb and min rate for else.
- *
- * ============================================================================
- * Incompatibilities
- * ============================================================================
- *
- * There's no known incompatible plugins yet.
- *
- * ============================================================================
- * Known isues
- * ============================================================================
- *
- * It overrides every other element system that comes after.
- *
- * ============================================================================
- * Changelog
- * ============================================================================
- *
- * Version 1.01:
- * - Improved formula.
- * - Added element curse.
- * - Added element/skill/weapon enhace.
- * - Changed how rates must be used inside notetags.
- *
- * Version 1.00:
- * - Finished plugin!
- *
- * ============================================================================
- *
- * For commercial and non-commercial games.
- * Credit to ICF-Soft.
- * This entire header must be included with plugin.
- *
- * ============================================================================
- */
- //=============================================================================
- /*:es
- * @plugindesc v1.01b Este complemento añade un sistema de elementos
- * avanzado.
- * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
- *
- * @param Elements Blend
- * @desc Qué hacer cuando se usa más de un elemento.
- * 0 - Media 1 - Normal 2 - Absorbción primero
- * @default 2
- *
- * @param Absorbtion Mode
- * @desc El modo en el que se absorben los elementos.
- * 0 - Absoluto 1 - Relativo
- * @default 1
- *
- * @param Curse Absorb Mode
- * @desc Como tratar la maldición elemental ante la absorción.
- * 0 - Fijo 1 - Aditivo 2 - Relativo
- * @default 2
- *
- * @param Curse Absorb Factor
- * @desc Factor a usar para calcular el daño.
- * @default -0.1
- *
- * @param Curse Absorb Min
- * @desc Valor mínimo.
- * @default 0.1
- *
- * @param Curse Neutral
- * @desc Valor fijo cuando se es inmune al elemento.
- * Además valor máximo en la absorción y mínimo en el resto.
- * @default 2
- *
- * @param Curse Normal Mode
- * @desc Como tratar la maldición elemental normalmente.
- * 0 - Fijo 1 - Aditivo 2 - Relativo
- * @default 1
- *
- * @param Curse Normal Factor
- * @desc Factor a usar para calcular el daño.
- * @default 1
- *
- * @help
- * ============================================================================
- * Introducción
- * ============================================================================
- *
- * El sistema de elementos que viene predeterminado en RPG Maker MV es limitado
- * y no permite la absorbción.
- *
- * Con este complemento puedes usar no sólo elementos sino también tipos de
- * habilidades y armas además de la absorbción de elementos y la bonificación
- * de elementos, habilidades y armas.
- *
- * Esta nueva fórmula da importancia a más opciones y da profundidad extra
- * en las tácticas.
- *
- * Ahora puedes utilizar resistencia a la magia, antibalas y más cosas similares.
- *
- * La nueva maldición elemental permite volver debilidad cualquier elemento
- * incluso cuando es absorbido.
- *
- * ============================================================================
- * Uso
- * ============================================================================
- *
- * Funciona con etiquetas en las notas. Pueden usarse en actores, clases,
- * enemigos, armas, armaduras y estados alterados.
- *
- * <ELEMENT ABSORB: x>
- * <ELEMENT ABSORB: x, x>
- *
- * - Añade todos los elementos que puede absorber en una linea.
- *
- * <ELEMENT CURSES: x>
- * <ELEMENT CURSES: x, x>
- *
- * - Añade todas las maldiciones elementales en una linea.
- *
- * <WEAPON ELEMENTS: x>
- * <WEAPON ELEMENTS: x, x>
- *
- * - Añade todos los tipos de arma que se utilizan en una linea.
- * Útil para enemigos y los actores que no lleven armas.
- * 0 son los puños. Se utiliza cuando un actor necesita un tipo de arma
- * pero no está disponible ninguno.
- *
- * <WEAPON RESISTANCES: x rate>
- * <WEAPON RESISTANCES: x rate, x rate>
- *
- * - Añade todas las resistencias a las armas en una linea.
- * rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
- * 2 es el doble, etc...
- *
- * <SKILL RESISTANCES: x rate>
- * <SKILL RESISTANCES: x rate, x rate>
- *
- * - Añade todas las resistencias a las habilidades en una linea.
- * rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
- * 2 es el doble, etc...
- *
- * La resistencia a las habilidades se activa en las habilidades que incluyan
- * categoría.
- *
- * La resistencia a las armas se activa en las habilidades físicas y las que
- * utilizan arma.
- *
- * <ELEMENT ENHANCES: x rate>
- * <ELEMENT ENHANCES: x rate, x rate>
- * <SKILL ENHANCES: x rate>
- * <SKILL ENHANCES: x rate, x rate>
- * <WEAPON ENHANCES: x rate>
- * <WEAPON ENHANCES: x rate, x rate>
- *
- * - Añade todas las bonificaciones de elementos, habilidades y armas
- * necesarias en una linea.
- * rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
- * 2 es el doble, etc...
- *
- * ============================================================================
- * Parámetros
- * ============================================================================
- *
- * Elements Blend:
- *
- * El comportamiento cuando se usan más de un elemento.
- *
- * 0 - Media: Calcula la media.
- * 1 - Normal: El elemento más dañino toma prioridad.
- * 2 - Absorción primero: Si un elemento es absorbible tendrá prioridad.
- *
- * Absorbtion Mode:
- *
- * El modo en el que los elementos son absorbidos cambia el modo en el que
- * el jugador debe seleccionar el equipamiento.
- *
- * 0 - Absoluto: La defensa elemental incrementa la absorbción.
- * 1 - Relativo: La defensa elemental reduce tanto la absorbción
- * como el daño.
- *
- * Para la maldición elemental se usan los siguientes parámetros:
- *
- * Curse Absorb Mode / Curse Normal Mode:
- *
- * Para daño negativo (absorción) y daño positivo (normal, débil o resistente)
- * se usan calculos distintos basado en el valor actual y un factor.
- *
- * 0 - Fijo: El factor será el nuevo valor.
- * 1 - Aditivo: Al valor se le añade el factor.
- * 2 - Relativo: El valor se multiplica por el factor.
- *
- * Curse Absorb Factor / Curse Normal Factor:
- *
- * El factor usado para calcular.
- *
- * Curse Absorb Min:
- *
- * El valor mínimo para el elemento absorbido.
- *
- * Curse Neutral:
- *
- * El valor que tomará cuando se es inmune. Al ser fijo se sustituye por
- * otro valor fijo.
- * Además se usa como término medio entre absorción y daño.
- *
- * ============================================================================
- * Incompatibilidades
- * ============================================================================
- *
- * No se conocen complementos que sean incompatibles hasta la fecha.
- *
- * ============================================================================
- * Problemas conocidos
- * ============================================================================
- *
- * Se sobreescribe cualquier sistema de elementos que se haya puesto antes.
- *
- * ============================================================================
- * Historial de versiones
- * ============================================================================
- *
- * Versión 1.01:
- * - Se ha mejorado la fórmula de cálculo.
- * - Se ha añadido la maldición elemental.
- * - Se ha añadido bonificación de elemento/habilidad/arma.
- * - Se ha cambiado el modo en que se usan las etiquetas de las notas.
- *
- * Versión 1.00:
- * - Complemento terminado.
- *
- * ============================================================================
- *
- * Para juegos comerciales y no comerciales.
- * Se debe incluir a ICF-Soft en los créditos.
- * Esta cabecera debe incluirse íntegramente con el plugin.
- *
- * ============================================================================
- */
- //=============================================================================
- //=============================================================================
- // Parameter Variables
- //=============================================================================
- ICF.Parameters = PluginManager.parameters('ICFSoft_ElementCore');
- ICF.Param = ICF.Param || {};
- ICF.Param.ElementBlend = Number(ICF.Parameters['Elements Blend']);
- ICF.Param.ElementAbsorbM = Number(ICF.Parameters['Absorbtion Mode']);
- ICF.Param.ElementCurseAbsM = Number(ICF.Parameters['Curse Absorb Mode']);
- ICF.Param.ElementCurseAbsF = Number(ICF.Parameters['Curse Absorb Factor']);
- ICF.Param.ElementCurseAbsMin = Number(ICF.Parameters['Curse Absorb Min']);
- ICF.Param.ElementCurseNeutral = Number(ICF.Parameters['Curse Neutral']);
- ICF.Param.ElementCurseMode = Number(ICF.Parameters['Curse Normal Mode']);
- ICF.Param.ElementCurseFactor = Number(ICF.Parameters['Curse Normal Factor']);
- //=============================================================================
- // Constants
- //=============================================================================
- Game_BattlerBase.TRAIT_SK_ELEMENT_RATE = 15;
- Game_BattlerBase.TRAIT_WP_ELEMENT_RATE = 16;
- Game_BattlerBase.TRAIT_ELEMENT_ABSORB = 17;
- Game_BattlerBase.TRAIT_ELEMENT_CURSE = 18;
- Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT = 35;
- Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE = 36;
- //=============================================================================
- // DataManager
- //=============================================================================
- ICF.ElementCore.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
- DataManager.isDatabaseLoaded = function() {
- if (!ICF.ElementCore.DataManager_isDatabaseLoaded.call(this)) return false;
- if (!ICF.ElementCore.Procesed) {
- DataManager.processEleCoreNotetags($dataActors);
- DataManager.processEleCoreNotetags($dataClasses);
- DataManager.processEleCoreNotetags($dataEnemies);
- DataManager.processEleCoreNotetags($dataWeapons);
- DataManager.processEleCoreNotetags($dataArmors);
- DataManager.processEleCoreNotetags($dataStates);
- ICF.ElementCore.Procesed = true;
- }
- return true;
- };
- DataManager.processEleCoreNotetags = function(group) {
- var note1 = /<(?:ELEMENT ABSORB):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
- var note2 = /<(?:WEAPON ELEMENTS):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
- var note3 = /<(?:SKILL RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
- var note4 = /<(?:WEAPON RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
- var note5 = /<(?:ELEMENT CURSES):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
- var note6 = /<(?:ELEMENT ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
- var note7 = /<(?:SKILL ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
- var note8 = /<(?:WEAPON ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
- for (var n = 1; n < group.length; n++) {
- var obj = group[n];
- var notedata = obj.note.split(/[\r\n]+/);
- for (var i = 0; i < notedata.length; i++) {
- var line = notedata[i];
- if (line.match(note1)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
- for (var il = 0; il < array.length; il++) {
- obj.traits.push({code:17, dataId:array[il], value:0});
- }
- } else if (line.match(note2)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
- for (var il = 0; il < array.length; il++) {
- obj.traits.push({code:35, dataId:array[il], value:0});
- }
- } else if (line.match(note3)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
- for (var il = 0; il < (array.length - 1); il += 2) {
- obj.traits.push({code:15, dataId:array[il], value:array[il + 1]});
- }
- } else if (line.match(note4)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
- for (var il = 0; il < (array.length - 1); il += 2) {
- obj.traits.push({code:16, dataId:array[il], value:array[il + 1]});
- }
- } else if (line.match(note5)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
- for (var il = 0; il < array.length; il++) {
- obj.traits.push({code:18, dataId:array[il], value:0});
- }
- } else if (line.match(note6)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
- for (var il = 0; il < (array.length - 1); il += 2) {
- obj.traits.push({code:36, dataId:array[il], value:array[il + 1]});
- }
- } else if (line.match(note7)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
- for (var il = 0; il < (array.length - 1); il += 2) {
- obj.traits.push({code:36, dataId:array[il] + 2000, value:array[il + 1]});
- }
- } else if (line.match(note8)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
- for (var il = 0; il < (array.length - 1); il += 2) {
- obj.traits.push({code:36, dataId:array[il] + 4000, value:array[il + 1]});
- }
- }
- }
- }
- };
- //=============================================================================
- // Game_BattlerBase
- //=============================================================================
- Game_BattlerBase.prototype.elementEnhace = function(elementId) {
- return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, elementId);
- };
- Game_BattlerBase.prototype.skillEnhace = function(stypeId) {
- return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, stypeId + 2000);
- };
- Game_BattlerBase.prototype.weaponEnhace = function(wtypeId) {
- return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, wtypeId + 4000);
- };
- Game_BattlerBase.prototype.elementAbsorb = function(elementId) {
- return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_ABSORB, elementId).length > 0);
- };
- Game_BattlerBase.prototype.elementCurse = function(elementId) {
- return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_CURSE, elementId).length > 0);
- };
- ICF.ElementCore.Game_BtlrBase_elementRate = Game_BattlerBase.prototype.elementRate;
- Game_BattlerBase.prototype.elementRate = function(elementId) {
- var result = ICF.ElementCore.Game_BtlrBase_elementRate.call(this, elementId);
- if (this.elementAbsorb(elementId)) {
- if (ICF.Param.ElementAbsorbM == 0) {result = Math.min(result - 2.0, -0.01);}
- else {result *= -1}
- }
- if (this.elementCurse(elementId)) {
- if (result < 0) {
- if (ICF.Param.ElementCurseAbsM == 0) return ICF.Param.ElementCurseAbsF;
- else if (ICF.Param.ElementCurseAbsM == 1) {
- result += ICF.Param.ElementCurseAbsF;
- return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
- } else {
- result *= ICF.Param.ElementCurseAbsF;
- return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
- }
- } else if (result == 0) {
- return ICF.Param.ElementCurseNeutral;
- } else {
- if (ICF.Param.ElementCurseMode == 0) return Math.max(result, ICF.Param.ElementCurseFactor);
- else if (ICF.Param.ElementCurseMode == 1) {
- result += ICF.Param.ElementCurseFactor;
- return Math.max(result, ICF.Param.ElementCurseNeutral);
- } else {
- result *= ICF.Param.ElementCurseFactor;
- return Math.max(result, ICF.Param.ElementCurseNeutral);
- }
- }
- }
- return result;
- };
- Game_BattlerBase.prototype.elSkillRate = function(stypeId) {
- return this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE, stypeId);
- };
- Game_BattlerBase.prototype.elWeaponRate = function(wtypeId) {
- return this.traitsPi(Game_BattlerBase.TRAIT_WP_ELEMENT_RATE, wtypeId);
- };
- Game_BattlerBase.prototype.wpAttackElements = function() {
- var wpns = this.traitsSet(Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT);
- wpns.sort(function(a, b){return a-b});
- for (i = wpns.length - 1; i > 0; i -= 1) {
- if (wpns[i] == wpns[i - 1]) wpns.splice(i,1);
- }
- return wpns;
- };
- Game_BattlerBase.prototype.ADVelementRate = function(elementId, subject) {
- return this.elementRate(elementId) * (subject == undefined)? 1 : subject.elementEnhace(elementId);
- };
- Game_BattlerBase.prototype.ADVelSkillRate = function(stypeId, subject) {
- return this.elSkillRate(stypeId) * (subject == undefined)? 1 : subject.skillEnhace(stypeId);
- };
- Game_BattlerBase.prototype.ADVelWeaponRate = function(wtypeId, subject) {
- return this.elWeaponRate(wtypeId) * (subject == undefined)? 1 : subject.weaponEnhace(wtypeId);
- };
- //=============================================================================
- // Game_Actor
- //=============================================================================
- Game_Actor.prototype.wpAttackElements = function() {
- var wpns = [];
- if (this.weapons().length > 0) {
- wpns = this.weapons().reduce(function(r, obj) {
- return r.concat([obj.wtypeId]);
- }, []);
- wpns.sort(function(a, b){return a-b});
- for (i = wpns.length - 1; i > 0; i -= 1) {
- if (wpns[i] == wpns[i - 1]) wpns.splice(i,1);
- }
- return wpns;
- }
- wpns = Game_BattlerBase.prototype.wpAttackElements.call(this);
- if (wpns.length == 0) wpns[0] = 0;
- return wpns;
- };
- //=============================================================================
- // Game_Action
- //=============================================================================
- Game_Action.prototype.elementsMaxRate = function(target, elements, subject) {
- if (elements.length > 0) {
- return Math.max.apply(null, elements.map(function(elementId) {
- return target.ADVelementRate(elementId, subject);
- }, this));
- } else {
- return 1;
- }
- };
- Game_Action.prototype.elementsMinRate = function(target, elements, subject) {
- if (elements.length > 0) {
- return Math.min.apply(null, elements.map(function(elementId) {
- return target.ADVelementRate(elementId, subject);
- }, this));
- } else {
- return 1;
- }
- };
- Game_Action.prototype.elementsAverageRate = function(target, elements, subject) {
- if (elements.length > 0) {
- return elements.reduce(function(r, element) {
- return r + target.ADVelementRate(element, subject);
- }, 0) / elements.length;
- } else {
- return 1;
- }
- };
- Game_Action.prototype.wpElementsMaxRate = function(target, wpelements, subject) {
- if (wpelements.length > 0) {
- return Math.max.apply(null, wpelements.map(function(wpelementId) {
- return target.ADVelWeaponRate(wpelementId, subject);
- }, this));
- } else {
- return 1;
- }
- };
- Game_Action.prototype.wpElementsAverageRate = function(target, wpelements, subject) {
- if (wpelements.length > 0) {
- return wpelements.reduce(function(r, wpelement) {
- return r + target.ADVelWeaponRate(wpelement, subject);
- }, 0) / wpelements.length;
- } else {
- return 1;
- }
- };
- Game_Action.prototype.calcWeaponElementRate = function(target) {
- var rate = 1;
- var wpns = this.subject().wpAttackElements();
- if (wpns.length > 0) {
- if (ICF.Param.ElementBlend == 0) {
- rate = this.wpElementsAverageRate(target, wpns, this.subject());
- } else {
- rate = this.wpElementsMaxRate(target, wpns, this.subject());
- }
- }
- return rate;
- };
- Game_Action.prototype.calcElementRate = function(target) {
- var rate = 1;
- var rate2 = 0;
- if (this.item().damage.elementId < 0) {
- if (ICF.Param.ElementBlend == 0) {
- rate = this.elementsAverageRate(target, this.subject().attackElements(), this.subject());
- } else {
- rate = this.elementsMaxRate(target, this.subject().attackElements(), this.subject());
- rate2 = this.elementsMinRate(target, this.subject().attackElements(), this.subject());
- if (ICF.Param.ElementBlend == 2 && rate2 < 0) rate = rate2;
- }
- } else {
- rate = target.ADVelementRate(this.item().damage.elementId, this.subject());
- }
- if (this.isSkill()) {
- if ((this.item().stypeId > 0)&&(this.isMagical())) {
- rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
- if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
- else {rate += rate2 - 1;}
- }
- if ((this.isPhysical())||(this.item().damage.elementId < 0)) {
- rate2 = this.calcWeaponElementRate(target) + rate;
- if (rate2 > 2) {rate = rate2 - 1;}
- else {rate = rate2 / 2;}
- }
- if ((this.item().stypeId > 0)&&(!this.isMagical())) {
- rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
- if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
- else {rate += rate2 - 1;}
- }
- }
- return rate;
- };
- //=============================================================================
- // End of File
- //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement