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.00 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
- *
- * @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.
- *
- * This new formula makes more things important and gives extra depth in
- * tactics.
- *
- * Now you can make magic resistance, bulletproof and so on.
- *
- * ============================================================================
- * 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.
- *
- * <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: must be an integer where 100 is normal, 50 is half,
- * 200 is double, etc...
- *
- * <SKILL RESISTANCES: x rate>
- * <SKILL RESISTANCES: x rate, x rate>
- *
- * - Add all skill resistances needed in one line.
- * rate: must be an integer where 100 is normal, 50 is half,
- * 200 is double, etc...
- *
- * Skill resistance triggers on every skill that came with skilltype.
- *
- * Weapon resistance triggers on physical skills and weapon using skills.
- *
- * ============================================================================
- * 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.
- *
- * ============================================================================
- * Incompatibilities
- * ============================================================================
- *
- * There's no known incompatible plugins yet.
- *
- * ============================================================================
- * Known isues
- * ============================================================================
- *
- * It overrides every other element system that comes after.
- *
- * ============================================================================
- *
- * Commercial use avaiable.
- * Credit to ICF-Soft.
- * This entire header must be included with plugin.
- *
- * ============================================================================
- */
- //=============================================================================
- /*:es
- * @plugindesc v1.00 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
- *
- * @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.
- *
- * 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.
- *
- * ============================================================================
- * 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.
- *
- * <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: debe ser un número entero, 100 es normal, 50 es la mitad,
- * 200 es doble, etc...
- *
- * <SKILL RESISTANCES: x rate>
- * <SKILL RESISTANCES: x rate, x rate>
- *
- * - Añade todas las resistencias a las habilidades en una linea.
- * rate: debe ser un número entero, 100 es normal, 50 es la mitad,
- * 200 es 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.
- *
- * ============================================================================
- * 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.
- *
- * ============================================================================
- * Incompatibilidades
- * ============================================================================
- *
- * No se conocen complementos que sean incompatibles hasta la fecha.
- *
- * ============================================================================
- * Problemas conocidos
- * ============================================================================
- *
- * Se sobreescribe cualquier sistema de elementos que se haya puesto antes.
- *
- * ============================================================================
- *
- * Se permite el uso comercial.
- * 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']);
- //=============================================================================
- // Constants
- //=============================================================================
- Game_BattlerBase.TRAIT_SK_ELEMENT_RATE = 15;
- Game_BattlerBase.TRAIT_WP_ELEMENT_RATE = 16;
- Game_BattlerBase.TRAIT_ELEMENT_ABSORB = 17;
- Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT = 35;
- //=============================================================================
- // 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+(?:\s*,\s*\d+\s+\d+)*)>/i;
- var note4 = /<(?:WEAPON RESISTANCES):[ ]*(\d+\s+\d+(?:\s*,\s*\d+\s+\d+)*)>/i;
- for (var n = 1; n < group.length; n++) {
- var obj = group[n];
- var notedata = obj.note.split(/[\r\n]+/);
- obj.elementAbsorb = [];
- 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+/g) + ']');
- for (var il = 0; il < (array.length - 1); il += 2) {
- obj.traits.push({code:15, dataId:array[il], value:array[il + 1] * 0.01});
- }
- } else if (line.match(note4)) {
- var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
- for (var il = 0; il < (array.length - 1); il += 2) {
- obj.traits.push({code:16, dataId:array[il], value:array[il + 1] * 0.01});
- }
- }
- }
- }
- };
- //=============================================================================
- // Game_BattlerBase
- //=============================================================================
- Game_BattlerBase.prototype.elementAbsorb = function(elementId) {
- return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_ABSORB, 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}
- }
- 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_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.elementsMinRate = function(target, elements) {
- if (elements.length > 0) {
- return Math.min.apply(null, elements.map(function(elementId) {
- return target.elementRate(elementId);
- }, this));
- } else {
- return 1;
- }
- };
- Game_Action.prototype.elementsAverageRate = function(target, elements) {
- if (elements.length > 0) {
- return elements.reduce(function(r, element) {
- return r + target.elementRate(element);
- }, 0) / elements.length;
- } else {
- return 1;
- }
- };
- Game_Action.prototype.wpElementsMaxRate = function(target, wpelements) {
- if (wpelements.length > 0) {
- return Math.max.apply(null, wpelements.map(function(wpelementId) {
- return target.elWeaponRate(wpelementId);
- }, this));
- } else {
- return 1;
- }
- };
- Game_Action.prototype.wpElementsAverageRate = function(target, wpelements) {
- if (wpelements.length > 0) {
- return wpelements.reduce(function(r, wpelement) {
- return r + target.elWeaponRate(wpelement);
- }, 0) / wpelements.length;
- } else {
- return 1;
- }
- };
- Game_Action.prototype.calcWeaponElementRate = function(target) {
- var rate = 1;
- var wpns = this.subject().wpAttackElements();
- if (wpns > 0) {
- if (ICF.Param.ElementBlend == 0) {
- rate = this.wpElementsAverageRate(target, wpns);
- } else {
- rate = this.wpElementsMaxRate(target, wpns);
- }
- }
- 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());
- } else {
- rate = this.elementsMaxRate(target, this.subject().attackElements());
- rate2 = this.elementsMinRate(target, this.subject().attackElements());
- if (ICF.Param.ElementBlend == 2 && rate2 < 0) rate = rate2;
- }
- } else {
- rate = target.elementRate(this.item().damage.elementId);
- }
- if (this.isSkill()) {
- if (this.item().stypeId > 0) {
- rate2 = target.elSkillRate(this.item().stypeId);
- 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;}
- }
- }
- return rate;
- };
- //=============================================================================
- // End of File
- //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement