Advertisement
ICF-Soft

ICF-Soft Enemies Core 1.01 RPG Maker MV

Jan 13th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ICF-Soft Plugins - Enemies Core
  3. // ICFSoft_EnemiesCore.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.ICFSoft_EnemiesCore = true;
  8.  
  9. var ICF = ICF || {};
  10. ICF.EnemiesCore = ICF.EnemiesCore || {};
  11.  
  12. ICF.EnemiesCore.Version = 101; // 1.01
  13.  
  14. //=============================================================================
  15.  /*:
  16.  * @plugindesc v1.01 This plugin adds new features to enemies like classes,
  17.  * variations, actions and drop items for them.
  18.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  19.  *
  20.  * @help
  21.  * ============================================================================
  22.  * Introduction
  23.  *
  24.  * With this plugin you can add different variations to enemies that can
  25.  * affect traits, hue, image, exp, gold, name, etc.
  26.  * You can also add classes for them with traits.
  27.  *
  28.  * Plus you can give more conditions to enemy actions and add actions to
  29.  * classes and variations for them.
  30.  *
  31.  * ============================================================================
  32.  * How to use
  33.  * ============================================================================
  34.  *
  35.  * Like other plugins it works with notetags.
  36.  * There are current enemy notetags:
  37.  *
  38.  * <ENEMY CLASSES: x x x x>
  39.  * <ENEMY CLASSES: x to y>
  40.  *
  41.  *  - Add random classes. Enemy will get one of these classes.
  42.  *    You can add 0 for a chance of no class.
  43.  *
  44.  * <ENEMY ACTION skillId rating>
  45.  * <ENEMY ACTION skillId rating condition>
  46.  *
  47.  *  - Add an action to an enemy. You can give special conditions:
  48.  *    Turn n x
  49.  *    HP min max (there are rates)
  50.  *    MP min max (there are rates)
  51.  *    State x
  52.  *    Partylevel level
  53.  *    Switch x
  54.  *    [BATTLE|ENEMY|ENEMYSELF|TROOP|PARTY|PARTYBATTLE]Switch x
  55.  *    Var [equal|dif|high|min|less|max] x
  56.  *    [BATTLE|ENEMY|ENEMYSELF|TROOP|PARTY|PARTYBATTLE]Var x
  57.  *    [TROOP|PARTY|PARTYBATTLE]Var[MIN|MAX|AVG] x
  58.  *    Js javascript-code
  59.  *
  60.  *    You can use battleswitchs, enemybattleswitchs, etc.
  61.  *    You can use battlesvariables, enemybattlevariables, etc.
  62.  *    Troop, party and partybattlebattle variables can check sum, min,
  63.  *    max or average.
  64.  *    Every variable type allow to check for equal, different, higher,
  65.  *    minimum, lower or maximun to a value.
  66.  *
  67.  * <DROPITEM itemId ammount>
  68.  * <DROPITEM itemId ammount rate>
  69.  * <DROPITEM itemId ammount js javascript-code>
  70.  *
  71.  *  - Add an extra drop item for enemy:
  72.  *    Rate is a number between 0 and 1 with decimals.
  73.  *    You can use a formula to give a rate with javascript.
  74.  *
  75.  * You can add weapons and armor with dropweapon and droparmor insead
  76.  * of dropitem.
  77.  *
  78.  * To add enemy variations you can use these notetags:
  79.  *
  80.  * <ENEMY VARIATION>
  81.  * </ENEMY VARIATION>
  82.  *
  83.  * You can use these commands between tags:
  84.  *
  85.  * classes x x x
  86.  *
  87.  *  - Variation will use one of these classes avoiding default.
  88.  *
  89.  * prefix word
  90.  *
  91.  *  - Add a prefix to name.
  92.  *
  93.  * sufix word
  94.  *
  95.  *  - Add a sufix to name.
  96.  *
  97.  * chance number
  98.  *
  99.  *  - Add chance of being this variation. Minimun 1.
  100.  *
  101.  * action skillId rating
  102.  * action skillId rating condition
  103.  *
  104.  *  - Add actions for this variation. Will be combined with default list.
  105.  *    Same special conditions as usual.
  106.  *
  107.  * dropitem itemId ammount
  108.  * dropitem itemId ammount rate
  109.  * dropitem itemId ammount js javascript-code
  110.  *
  111.  *  - Add extra drop item for this variation. All drops are additive.
  112.  *    You can add weapons and armor with dropweapon and droparmor insead
  113.  *    of dropitem.
  114.  *
  115.  * exp number
  116.  * gold number
  117.  * battlerhue number
  118.  * battlername filename
  119.  *
  120.  *  - Changes default values.
  121.  *
  122.  * traits x
  123.  *
  124.  *  - Add a subtrait set taken from main utility notation.
  125.  *    Refer to main utility readme file. Example:
  126.  *    <SUBTRAITS MASTER> -Fire
  127.  *    elem_rate 1 1.5
  128.  *    11 2 0.5
  129.  *    31 2 0 -Fire attack element
  130.  *    <SUBTRAITS MASTER> -Cold
  131.  *    elem_rate 1 1.5
  132.  *    11 2 2.1
  133.  *    31 3 0 -Cold attack element
  134.  *    </SUBTRAITS MASTER>
  135.  *
  136.  * Enemy variations example:
  137.  *
  138.  * <ENEMY VARIATION>
  139.  * classes 2 3 5
  140.  * exp 500
  141.  * battlerhue 100
  142.  * traits 0
  143.  * prefix Fire
  144.  * action 5 3 battleswitch iscold
  145.  * <ENEMY VARIATION>
  146.  * traits 1
  147.  * prefix Cold
  148.  * action 7 3
  149.  * </ENEMY VARIATION>
  150.  *
  151.  *
  152.  * To add enemy class variations you can use these notetags:
  153.  *
  154.  * <CLASS VARIATION classId>
  155.  * </CLASS VARIATION>
  156.  *
  157.  * You can use these commands between tags:
  158.  *
  159.  * action skillId rating
  160.  * action skillId rating condition
  161.  *
  162.  *  - Add actions for this class variation. Will be combined with default list.
  163.  *    Same special conditions as usual.
  164.  *
  165.  * dropitem itemId ammount
  166.  * dropitem itemId ammount rate
  167.  * dropitem itemId ammount js javascript-code
  168.  *
  169.  *  - Add extra drop item for this class variation. All drops are additive.
  170.  *    You can add weapons and armor with dropweapon and droparmor insead
  171.  *    of dropitem.
  172.  *
  173.  *
  174.  * Class variations example:
  175.  *
  176.  * <CLASS VARIATION 2>
  177.  * action 1 3
  178.  * action 2 4 hp 0.1 0.5
  179.  * <CLASS VARIATION 3>
  180.  * action 10 5 mp 0.9 1
  181.  * </CLASS VARIATION>
  182.  *
  183.  * ============================================================================
  184.  * Incompatibilities
  185.  * ============================================================================
  186.  *
  187.  * There's no known incompatible plugins yet.
  188.  *
  189.  * ============================================================================
  190.  * Known isues
  191.  * ============================================================================
  192.  *
  193.  * Not yet.
  194.  *
  195.  * ============================================================================
  196.  * Changelog
  197.  * ============================================================================
  198.  *
  199.  * Version 1.01:
  200.  * - Improved enemy action contitions.
  201.  * - Added extra enemy drops for default, variations and classes.
  202.  * - Added enemy variation chances.
  203.  *
  204.  * Version 1.00:
  205.  * - Finished plugin!
  206.  *
  207.  * ============================================================================
  208.  *
  209.  * For commercial and non-commercial games.
  210.  * Credit to ICF-Soft.
  211.  * This entire header must be included with plugin.
  212.  *
  213.  * ============================================================================
  214. */
  215. //=============================================================================
  216.  /*:es
  217.  * @plugindesc v1.01 Este complemento añade nuevas características a los
  218.  * enemigos tales como clases, variaciones, acciones y objetos extra.
  219.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  220.  *
  221.  * @help
  222.  * ============================================================================
  223.  * Introducción
  224.  * ============================================================================
  225.  *
  226.  * Con este complemento puedes añadir variaciones diferente a los enemigos
  227.  * afectando los rasgos, experiencia, oro, nombre, etc.
  228.  * Añade incluso clases con sus rasgos.
  229.  *
  230.  * Además puedes darles más condiciones a las acciones de los enemigos y
  231.  * acciones para variaciones y clases específicas.
  232.  *
  233.  * ============================================================================
  234.  * Uso
  235.  * ============================================================================
  236.  *
  237.  * Igual que otros complementos funciona con etiquetas en las notas.
  238.  * Las hay para enemigos:
  239.  *
  240.  * <ENEMY CLASSES: x x x x>
  241.  * <ENEMY CLASSES: x hasta y>
  242.  *
  243.  *  - Añade una lista de clases. El enemigo será de una de ellas.
  244.  *    Puedes usar el 0 para que puede no tener ninguna.
  245.  *
  246.  * <ENEMY ACTION skillId rating>
  247.  * <ENEMY ACTION skillId rating condition>
  248.  *
  249.  *  - Añade una acción. Puedes usar condiciones especiales:
  250.  *    Turn n x
  251.  *    HP min max (valores entre 0 y 1)
  252.  *    MP min max (valores entre 0 y 1)
  253.  *    State x
  254.  *    Partylevel nivel
  255.  *    Switch x
  256.  *    [BATTLE|ENEMY|ENEMYSELF|TROOP|PARTY|PARTYBATTLE]Switch x
  257.  *    Var [equal|dif|high|min|less|max] x
  258.  *    [BATTLE|ENEMY|ENEMYSELF|TROOP|PARTY|PARTYBATTLE]Var x
  259.  *    [TROOP|PARTY|PARTYBATTLE]Var[MIN|MAX|AVG] x
  260.  *    Js javascript-code
  261.  *
  262.  *    Puedes usar interruptores de batalla, de enemigos, etc.
  263.  *    Puedes usar variables de batalla, de enemigos, etc.
  264.  *    Para las variables de grupos puedes comprobar la suma, el
  265.  *    mínimo, máximo o la media.
  266.  *    Todos los tipos de variable admiten las comprobaciones de
  267.  *    igual a, distinto a, mayor que, valor mínimo, menor que,
  268.  *    o valor máximo.
  269.  *
  270.  * <DROPITEM itemId ammount>
  271.  * <DROPITEM itemId ammount rate>
  272.  * <DROPITEM itemId ammount js javascript-code>
  273.  *
  274.  *  - Añade objetos extra al enemigo:
  275.  *    Rate es un número entre 0 y 1 con decimales.
  276.  *    Puedes usar una fórmula para definir la probabilidad.
  277.  *
  278.  * Puedes añadir armas y armaduras usando dropweapon y droparmor
  279.  * respectivamente en lugar de dropitem.
  280.  *
  281.  * Para añadir variaciones se usan las siguientes etiquetas:
  282.  *
  283.  * <ENEMY VARIATION>
  284.  * </ENEMY VARIATION>
  285.  *
  286.  * Y usar los siguientes comandos:
  287.  *
  288.  * classes x x x
  289.  *
  290.  *  - Se escogerá una de esas clases en lugar de las habituales.
  291.  *
  292.  * prefix word
  293.  *
  294.  *  - Añade un prefijo al nombre.
  295.  *
  296.  * sufix word
  297.  *
  298.  *  - Añade un sufijo al nombre.
  299.  *
  300.  * chance number
  301.  *
  302.  *  - Añade la probabilidad de que salga esta variación. Mínimo 1.
  303.  *
  304.  * action skillId rating
  305.  * action skillId rating condition
  306.  *
  307.  *  - Añade acciones para esa variación. Se combina con las normales.
  308.  *    Se usa el mismo tipo de condición que en las normales.
  309.  *
  310.  * dropitem itemId ammount
  311.  * dropitem itemId ammount rate
  312.  * dropitem itemId ammount js javascript-code
  313.  *
  314.  *  - Añade objetos extra esta variación. Todos son aditivos.
  315.  *    Puedes añadir armas y armaduras usando dropweapon y droparmor
  316.  *    respectivamente en lugar de dropitem.
  317.  *
  318.  * exp número
  319.  * gold número
  320.  * battlerhue número
  321.  * battlername archivo
  322.  *
  323.  *  - Cambia los valores.
  324.  *
  325.  * traits x
  326.  *
  327.  *  - Añade un conjunto de subrasgos de los que se crean con el main utility.
  328.  *    Puedes revisar el archivo léeme del main utility. Ejemplo:
  329.  *    <SUBTRAITS MASTER> -Fuego
  330.  *    elem_rate 1 1.5
  331.  *    11 2 0.5
  332.  *    31 2 0 -Ataque de fuego
  333.  *    <SUBTRAITS MASTER> -Frío
  334.  *    elem_rate 1 1.5
  335.  *    11 2 2.1
  336.  *    31 3 0 -Ataque de hielo
  337.  *    </SUBTRAITS MASTER>
  338.  *
  339.  * Ejemplo de variaciones:
  340.  *
  341.  * <ENEMY VARIATION>
  342.  * classes 2 3 5
  343.  * exp 500
  344.  * battlerhue 100
  345.  * traits 0
  346.  * prefix Fire
  347.  * action 5 3 battleswitch hace-frio
  348.  * <ENEMY VARIATION>
  349.  * traits 1
  350.  * prefix Cold
  351.  * action 7 3
  352.  * </ENEMY VARIATION>
  353.  *
  354.  *
  355.  * Para añadir variaciones en función de la clase usar las etiquetas:
  356.  *
  357.  * <CLASS VARIATION classId>
  358.  * </CLASS VARIATION>
  359.  *
  360.  * Existen los siguientes comandos actualmente:
  361.  *
  362.  * action skillId rating
  363.  * action skillId rating condition
  364.  *
  365.  *  - Añade acciones para esa clase. Se combina con el resto.
  366.  *    Se usa el mismo tipo de condición que en las normales.
  367.  *
  368.  * dropitem itemId ammount
  369.  * dropitem itemId ammount rate
  370.  * dropitem itemId ammount js javascript-code
  371.  *
  372.  *  - Añade objetos extra esta clase. Todos son aditivos.
  373.  *    Puedes añadir armas y armaduras usando dropweapon y droparmor
  374.  *    respectivamente en lugar de dropitem.
  375.  *
  376.  *
  377.  * Ejemplo de variantes de clases:
  378.  *
  379.  * <CLASS VARIATION 2>
  380.  * action 1 3
  381.  * action 2 4 hp 0.1 0.5
  382.  * <CLASS VARIATION 3>
  383.  * action 10 5 mp 0.9 1
  384.  * </CLASS VARIATION>
  385.  *
  386.  * ============================================================================
  387.  * Incompatibilidades
  388.  * ============================================================================
  389.  *
  390.  * No se conocen complementos que sean incompatibles hasta la fecha.
  391.  *
  392.  * ============================================================================
  393.  * Problemas conocidos
  394.  * ============================================================================
  395.  *
  396.  * Por el momento ninguno.
  397.  *
  398.  * ============================================================================
  399.  * Historial de versiones
  400.  * ============================================================================
  401.  *
  402.  * Versión 1.01:
  403.  * - Se han mejorado las condiciones para las acciones.
  404.  * - Se ha añadido objetos extra a los enemigos, variaciones y clases.
  405.  * - Se han añadido probabilidades a las variaciones.
  406.  *
  407.  * Versión 1.00:
  408.  * - Complemento terminado.
  409.  *
  410.  * ============================================================================
  411.  *
  412.  * Para juegos comerciales y no comerciales.
  413.  * Se debe incluir a ICF-Soft en los créditos.
  414.  * Esta cabecera debe incluirse íntegramente con el plugin.
  415.  *
  416.  * ============================================================================
  417. */
  418. //=============================================================================
  419.  
  420. //=============================================================================
  421. // Parameter Variables
  422. //=============================================================================
  423.  
  424. ICF.Parameters = PluginManager.parameters('ICFSoft_EnemiesCore');
  425. ICF.Param = ICF.Param || {};
  426.  
  427. if (!Imported.ICFSoft_MainUtility) {throw new Error('This plugin requires ICF-Soft Main Utility plugin version 1.02 to work.\nYou can download it at icfsoft.blogspot.com inside plugins section.');}
  428. if (ICF.MainUtility.Version < 102) {throw new Error('This plugin requires ICF-Soft Main Utility plugin version 1.02 to work.\nYou can download it at icfsoft.blogspot.com inside plugins section.');}
  429.  
  430. //=============================================================================
  431. // DataManager
  432. //=============================================================================
  433.  
  434. ICF.EnemiesCore.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  435. DataManager.isDatabaseLoaded = function() {
  436.     if (!ICF.EnemiesCore.DataManager_isDatabaseLoaded.call(this)) return false;
  437.     if (!ICF.EnemiesCore.Procesed) {
  438.     this.processEnemyCoreNotetags($dataEnemies);
  439.     ICF.EnemiesCore.Procesed = true;
  440.     }
  441.     return true;
  442. };
  443.  
  444. DataManager.processEnemyCoreNotetags = function(group) {
  445.   var note1 = /<(?:ENEMY VARIATION)>/i;
  446.   var note1b = /<\/(?:ENEMY VARIATION)>/i;
  447.   var note2 = /<(?:CLASS VARIATION )(\d+)>/i;
  448.   var note2b = /<\/(?:CLASS VARIATION)>/i;
  449.   var note3 = /<(?:ENEMY CLASSES):[ ]*(\w+(?:\s+\w+)*)[ ]*>/i;
  450.   var note4 = /<(?:ENEMY ACTION )(\d+) (\d+)(?: ((?:BATTLE)|(?:ENEMY)|(?:ENEMYSELF)|(?:TROOP)|(?:PARTY)|(?:PARTYBATTLE))?((?:TURN)|(?:HP)|(?:MP)|(?:STATE)|(?:PARTYLEVEL)|(?:SWITCH)|(?:VAR))((?:MIN)|(?:MAX)|(?:AVG))? (\w+(?:.\d+)?(?:\s+\w+(?:.\d+)?)*)(?:\s*))?>/i;
  451.   var note4b = /<(?:ENEMY ACTION )(\d+) (\d+) (?:JS) (.*)\s*>/i;
  452.   var note4c = /((?:BATTLE)|(?:ENEMY)|(?:ENEMYSELF)|(?:TROOP)|(?:PARTY)|(?:PARTYBATTLE))?((?:TURN)|(?:HP)|(?:MP)|(?:STATE)|(?:PARTYLEVEL)|(?:SWITCH)|(?:VAR))((?:MIN)|(?:MAX)|(?:AVG))?/i;
  453.   var note5 = /<(?:DROP)\s?((?:ITEM)|(?:WEAPON)|(?:ARMOR)) (\d+) (\d+)\s*(\d+(?:\.\d+)?)?>/i;
  454.   var note5b = /<(?:DROP)\s?((?:ITEM)|(?:WEAPON)|(?:ARMOR)) (\d+) (\d+) (?:JS) (.*)\s*>/i;
  455.  
  456.   for (var n = 1; n < group.length; n++) {
  457.     var obj = group[n];
  458.     var notedata = obj.note.split(/[\r\n]+/);
  459.  
  460.     obj.enemyVariations = [];
  461.     obj.enemyClasses = [];
  462.     obj.enemyClassVariations = {};
  463.  
  464.     obj.extraDrops = [];
  465.  
  466.     var ecFlag = false;
  467.     var ecFlag2 = false;
  468.  
  469.     var varIndex = -1;
  470.     var clsIndex = -1;
  471.  
  472.       for (var i = 0; i < notedata.length; i++) {
  473.         var line = notedata[i];
  474.         if (line.match(note1)) {
  475.             ecFlag = true;
  476.             varIndex++;
  477.             obj.enemyVariations[varIndex] = {};
  478.             obj.enemyVariations[varIndex].actions = [];
  479.             obj.enemyVariations[varIndex].extraDrops = [];
  480.         } else if (line.match(note1b)) {
  481.             ecFlag = false;
  482.         } else if (line.match(note2)) {
  483.             ecFlag2 = true;
  484.             clsIndex = RegExp.$1;
  485.             obj.enemyClassVariations[clsIndex] = {};
  486.             obj.enemyClassVariations[clsIndex].actions = [];
  487.             obj.enemyClassVariations[clsIndex].extraDrops = [];
  488.         } else if (line.match(note2b)) {
  489.             ecFlag2 = false;
  490.         } else if (line.match(note3)) {
  491.             obj.enemyClasses = obj.enemyClasses.concat(RegExp.$1.trim().split(/\s+/).extend().leaveNumbers());
  492.         } else if (line.match(note4)) {
  493.             var action = {skillId:Number(RegExp.$1), rating:Number(RegExp.$2)};
  494.             var condition = ["turn","hp","mp","state","partylevel","switch","var"].indexOf(RegExp.$4.toLowerCase()) + 1;
  495.             var conditionpf = ["battle","enemy","enemyself","troop","party","partybattle"].indexOf(RegExp.$3.toLowerCase()) + 1;
  496.             var conditionsf = ["min","max","avg"].indexOf(RegExp.$5.toLowerCase());
  497.             var array = RegExp.$6.split(' ');
  498.             if (condition > 0 && condition < 6) {
  499.                 action.conditionType = condition;
  500.                 action.conditionParam1 = Number(array[0]);
  501.                 action.conditionParam2 = Number(array[1]);
  502.             } else if (condition == 6) {
  503.                 action.conditionType = 6;
  504.                 action.conditionParam1 = array[0];
  505.                 action.conditionParam2 = conditionpf;
  506.             } else if (condition == 7) {
  507.                 action.conditionType = 7;
  508.                 action.conditionParam1 = array[0];
  509.                 action.conditionParam2 = (conditionpf < 4)? conditionpf : (conditionpf - 4) * 4 + 5 + conditionsf;
  510.                 action.conditionParam3 = (array.length == 2)? 3 : (!isNaN(Number(array[1])))? Number(array[1]) : ["equal","dif","high","min","less","max"].indexOf(array[1]);
  511.                 action.conditionParam4 = (array.length == 2)? array[1] : array[2];
  512.             }
  513.             obj.actions.push(action);
  514.         } else if (line.match(note4b)) {
  515.             var action = {skillId:Number(RegExp.$1), rating:Number(RegExp.$2), conditionType:8, conditionParam1:RegExp.$3.trim()};
  516.             obj.actions.push(action);
  517.         } else if (line.match(note5)) {
  518.             var drop = [];
  519.             drop[0] = ["item","weapon","armor"].indexOf(RegExp.$1) + 1;
  520.             drop[1] = Number(RegExp.$2);
  521.             drop[2] = Number(RegExp.$3);
  522.             drop[3] = Number(RegExp.$4);
  523.             obj.extraDrops.push(drop);
  524.         } else if (line.match(note5b)) {
  525.             var drop = [];
  526.             drop[0] = ["item","weapon","armor"].indexOf(RegExp.$1) + 1;
  527.             drop[1] = Number(RegExp.$2);
  528.             drop[2] = Number(RegExp.$3);
  529.             drop[3] = Number("js");
  530.             drop[4] = RegExp.$4;
  531.             obj.extraDrops.push(drop);
  532.         } else if (ecFlag) {
  533.             line = line.trim().split(/\s+/);
  534.             if (line.length > 0) {
  535.                 var command = line.shift().toLowerCase();
  536.                 if (command == "classes") {
  537.                     obj.enemyVariations[varIndex].classes = line.extend().leaveNumbers();
  538.                 } else if (command == "prefix") {
  539.                     obj.enemyVariations[varIndex].prefix = line.join(' ') + ' ';
  540.                 } else if (command == "sufix") {
  541.                     obj.enemyVariations[varIndex].sufix = ' ' + line.join(' ');
  542.                 } else if (command == "dropitem") {
  543.                     var drop = [1,Number(line[0]),Number(line[1])];
  544.                     if(!isNaN(Number(line[2]))) { drop[3] = Number(line[2]); }
  545.                     else if (Number(line[2]).toLowerCase() == "js") {
  546.                         drop[3] = "js";
  547.                         line.splice(0,3);
  548.                         drop[4] = line.join(" ");
  549.                     }
  550.                     obj.enemyVariations[varIndex].extraDrops.push(drop);
  551.                 } else if (command == "dropweapon") {
  552.                     var drop = [2,Number(line[0]),Number(line[1])];
  553.                     if(!isNaN(Number(line[2]))) { drop[3] = Number(line[2]); }
  554.                     else if (Number(line[2]).toLowerCase() == "js") {
  555.                         drop[3] = "js";
  556.                         line.splice(0,3);
  557.                         drop[4] = line.join(" ");
  558.                     }
  559.                     obj.enemyVariations[varIndex].extraDrops.push(drop);
  560.                 } else if (command == "droparmor") {
  561.                     var drop = [3,Number(line[0]),Number(line[1])];
  562.                     if(!isNaN(Number(line[2]))) { drop[3] = Number(line[2]); }
  563.                     else if (Number(line[2]).toLowerCase() == "js") {
  564.                         drop[3] = "js";
  565.                         line.splice(0,3);
  566.                         drop[4] = line.join(" ");
  567.                     }
  568.                     obj.enemyVariations[varIndex].extraDrops.push(drop);
  569.                 } else if (command == "action" && line.length > 1) {
  570.                     var action = {skillId:Number(line[0]), rating:Number(line[1])};
  571.                     if (line[2] && line[2].match(note4c)) {
  572.                         var condition = ["turn","hp","mp","state","partylevel","switch","var"].indexOf(RegExp.$2.toLowerCase()) + 1;
  573.                         var conditionpf = ["battle","enemy","enemyself","troop","party","partybattle"].indexOf(RegExp.$1.toLowerCase()) + 1;
  574.                         var conditionsf = ["min","max","avg"].indexOf(RegExp.$3.toLowerCase());
  575.                         if (condition > 0 && condition < 6) {
  576.                             action.conditionType = condition;
  577.                             action.conditionParam1 = Number(line[3]);
  578.                             action.conditionParam2 = Number(line[4]);
  579.                         } else if (condition == 6) {
  580.                             action.conditionType = 6;
  581.                             action.conditionParam1 = Number(line[3]);
  582.                             action.conditionParam2 = conditionpf;
  583.                         } else if (condition == 7) {
  584.                             action.conditionType = 7;
  585.                             action.conditionParam1 = Number(line[3]);
  586.                             action.conditionParam2 = (conditionpf < 4)? conditionpf : (conditionpf - 4) * 4 + 5 + conditionsf;
  587.                             action.conditionParam3 = (line.length == 5)? 3 : (!isNaN(Number(line[4])))? Number(line[4]) : ["equal","dif","high","min","less","max"].indexOf(line[4]);
  588.                             action.conditionParam4 = (line.length == 5)? line[4] : line[5];
  589.                         }
  590.                     } else if (line[2] && line[2].toLowerCase() == "js") {
  591.                         action.conditionType = 8;
  592.                         line.splice(0,3);
  593.                         action.conditionParam1 = line.join(" ");
  594.                     }
  595.                     obj.enemyVariations[varIndex].actions.push(action);
  596.                 } else if (line.length > 0) {
  597.                     obj.enemyVariations[varIndex][command] = line[0];
  598.                 } else if (["exp","gold","battlername","battlerhue","traits"].indexOf(command) < 0) {
  599.                     obj.enemyVariations[varIndex][command] = true;
  600.                 }
  601.             }
  602.         } else if (ecFlag2) {
  603.             line = line.trim().split(/\s+/);
  604.             if (line.length > 0) {
  605.                 var command = line.shift().toLowerCase();
  606.                 if (command == "action" && line.length > 1) {
  607.                     var action = {skillId:Number(line[0]), rating:Number(line[1])};
  608.                     if (line[2] && line[2].match(note4c)) {
  609.                         var condition = ["turn","hp","mp","state","partylevel","switch","var"].indexOf(RegExp.$2.toLowerCase()) + 1;
  610.                         var conditionpf = ["battle","enemy","enemyself","troop","party","partybattle"].indexOf(RegExp.$1.toLowerCase()) + 1;
  611.                         var conditionsf = ["min","max","avg"].indexOf(RegExp.$3.toLowerCase());
  612.                         if (condition > 0 && condition < 6) {
  613.                             action.conditionType = condition;
  614.                             action.conditionParam1 = Number(line[3]);
  615.                             action.conditionParam2 = Number(line[4]);
  616.                         } else if (condition == 6) {
  617.                             action.conditionType = 6;
  618.                             action.conditionParam1 = Number(line[3]);
  619.                             action.conditionParam2 = conditionpf;
  620.                         } else if (condition == 7) {
  621.                             action.conditionType = 7;
  622.                             action.conditionParam1 = Number(line[3]);
  623.                             action.conditionParam2 = (conditionpf < 4)? conditionpf : (conditionpf - 4) * 4 + 5 + conditionsf;
  624.                             action.conditionParam3 = (line.length == 5)? 3 : (!isNaN(Number(line[4])))? Number(line[4]) : ["equal","dif","high","min","less","max"].indexOf(line[4]);
  625.                             action.conditionParam4 = (line.length == 5)? line[4] : line[5];
  626.                         }
  627.                     } else if (line[2] && line[2].toLowerCase() == "js") {
  628.                         action.conditionType = 8;
  629.                         line.splice(0,3);
  630.                         action.conditionParam1 = line.join(" ");
  631.                     }
  632.                     obj.enemyClassVariations[clsIndex].actions.push(action);
  633.                 } else if (command == "dropitem") {
  634.                     var drop = [1,Number(line[0]),Number(line[1])];
  635.                     if(!isNaN(Number(line[2]))) { drop[3] = Number(line[2]); }
  636.                     else if (Number(line[2]).toLowerCase() == "js") {
  637.                         drop[3] = "js";
  638.                         line.splice(0,3);
  639.                         drop[4] = line.join(" ");
  640.                     }
  641.                     obj.enemyClassVariations[clsIndex].extraDrops.push(drop);
  642.                 } else if (command == "dropweapon") {
  643.                     var drop = [2,Number(line[0]),Number(line[1])];
  644.                     if(!isNaN(Number(line[2]))) { drop[3] = Number(line[2]); }
  645.                     else if (Number(line[2]).toLowerCase() == "js") {
  646.                         drop[3] = "js";
  647.                         line.splice(0,3);
  648.                         drop[4] = line.join(" ");
  649.                     }
  650.                     obj.enemyClassVariations[clsIndex].extraDrops.push(drop);
  651.                 } else if (command == "droparmor") {
  652.                     var drop = [3,Number(line[0]),Number(line[1])];
  653.                     if(!isNaN(Number(line[2]))) { drop[3] = Number(line[2]); }
  654.                     else if (Number(line[2]).toLowerCase() == "js") {
  655.                         drop[3] = "js";
  656.                         line.splice(0,3);
  657.                         drop[4] = line.join(" ");
  658.                     }
  659.                     obj.enemyClassVariations[clsIndex].extraDrops.push(drop);
  660.                 } else if (line.length > 0) {
  661.                     obj.enemyClassVariations[clsIndex][command] = line[0];
  662.                 } else {
  663.                     obj.enemyClassVariations[clsIndex][command] = true;
  664.                 }
  665.             }
  666.         }
  667.  
  668.       }
  669.       for (var i = 0; i < obj.enemyVariations.length; i++) {
  670.         if (!isNaN(Number(obj.enemyVariations[i].traits))) obj.enemyVariations[i].traits = obj.subtraits[obj.enemyVariations[i].traits].traits || [];
  671.         else if (!Array.isArray(obj.enemyVariations[i].traits)) obj.enemyVariations[i].traits = [];
  672.         if (!obj.enemyVariations[i].chance || obj.enemyVariations[i].chance < 1) obj.enemyVariations[i].chance = 1;
  673.       }
  674.   }
  675. };
  676.  
  677. //=============================================================================
  678. // Game_Enemy
  679. //=============================================================================
  680.  
  681. ICF.EnemiesCore.initEnemy = Game_Enemy.prototype.initMembers;
  682. Game_Enemy.prototype.initMembers = function() {
  683.     ICF.EnemiesCore.initEnemy.call(this);
  684.     this._classId = 0;
  685.     this._variation = {};
  686. };
  687.  
  688. ICF.EnemiesCore.setupEnemy = Game_Enemy.prototype.setup;
  689. Game_Enemy.prototype.setup = function(enemyId, x, y) {
  690.     var variations = $dataEnemies[enemyId].enemyVariations;
  691.     if (variations.length > 1) {
  692.     var allweight = 0;
  693.     var selected = 0;
  694.     for (var i = 0; i < variations.length; i++) {
  695.         allweight += variations[i].chance || 1;
  696.     }
  697.     allweight = Math.random() * allweight;
  698.     for (var i = 0; i < variations.length; i++) {
  699.         allweight -= variations[i].chance || 1;
  700.         if (allweight <= 0) {
  701.             selected = i;
  702.             break;
  703.         }
  704.     }
  705.     this._variation = variations[selected];
  706.     } else if (variations.length == 0) {
  707.     this._variation = variations[0];
  708.     }
  709.     var classes = this._variation.clasess || $dataEnemies[enemyId].enemyClasses;
  710.     if (classes.length > 0) this._classId = classes[Math.floor(Math.random() * classes.length)];
  711.     ICF.EnemiesCore.setupEnemy.call(this, enemyId, x, y);
  712. };
  713.  
  714. ICF.EnemiesCore.makeDropItems = Game_Enemy.prototype.makeDropItems;
  715. Game_Enemy.prototype.makeDropItems = function() {
  716.     var drops = ICF.EnemiesCore.makeDropItems.call(this);
  717.     var array = $dataEnemies[this._enemyId].extraDrops;
  718.     if (this._variation.extraDrops) array = array.concat(this._variation.extraDrops);
  719.     if (this._classId > 0 && this.classVariation()) array = array.concat(this.classVariation().extraDrops);
  720.     for (var i = 0; i < array.length; i++) {
  721.     if (array[i][3] == undefined) {
  722.         for (var j = 0; j < array[i][2]; j++) {
  723.             drops.concat(this.itemObject(array[i][0], array[i][1]));
  724.         }
  725.     } else if (array[i][3] == "js") {
  726.         if (Math.random() < (eval(array[i][4]) * this.dropItemRate())) for (var j = 0; j < array[i][2]; j++) {
  727.             drops.concat(this.itemObject(array[i][0], array[i][1]));
  728.         }
  729.     } else if (Math.random() < (array[i][3] * this.dropItemRate())) {
  730.         for (var j = 0; j < array[i][2]; j++) {
  731.             drops.concat(this.itemObject(array[i][0], array[i][1]));
  732.         }
  733.     }
  734.  
  735.     }
  736.     return drops;
  737. };
  738.  
  739. Game_Enemy.prototype.currentClass = function() {
  740.     return $dataClasses[this._classId];
  741. };
  742.  
  743. Game_Enemy.prototype.variation = function() {
  744.     return this._variation;
  745. };
  746.  
  747. Game_Enemy.prototype.classVariation = function() {
  748.     return $dataEnemies[this._enemyId].enemyClassVariations[this._classId];
  749. };
  750.  
  751. ICF.EnemiesCore.enemyTraits = Game_Enemy.prototype.traitObjects;
  752. Game_Enemy.prototype.traitObjects = function() {
  753.     return ICF.EnemiesCore.enemyTraits.call(this).concat(this._variation).concat((this._classId > 0)? $dataClasses[this._classId] : []);
  754. };
  755.  
  756. Game_Enemy.prototype.jsevalObjects = function() {
  757.     var objects = [this.enemy()];
  758.     if (this._classId > 0) objects.push($dataClasses[this._classId]);
  759.     objects = objects.concat(Game_Battler.prototype.jsevalObjects.call(this));
  760.     return objects.filter(function(obj) {
  761.         return Object.keys(obj.jsreactions).length > 0;
  762.     });
  763. };
  764. Game_Enemy.prototype.exp = function() {
  765.     return this._variation.exp || this.enemy().exp;
  766. };
  767.  
  768. Game_Enemy.prototype.gold = function() {
  769.     return this._variation.gold || this.enemy().gold;
  770. };
  771.  
  772. Game_Enemy.prototype.battlerName = function() {
  773.     return this._variation.battlername || this.enemy().battlerName;
  774. };
  775.  
  776. Game_Enemy.prototype.battlerHue = function() {
  777.     return this._variation.battlerhue || this.enemy().battlerHue;
  778. };
  779.  
  780. Game_Enemy.prototype.originalName = function() {
  781.     return (this._variation.prefix ? this._variation.prefix : '') + this.enemy().name + (this._variation.sufix ? this._variation.sufix : '');
  782. };
  783.  
  784. Game_Enemy.prototype.name = function() {
  785.     return this.originalName() + (this._plural ? ' ' + this._letter : '');
  786. };
  787.  
  788. Game_Enemy.prototype.meetsCondition = function(action) {
  789.     var param1 = action.conditionParam1;
  790.     var param2 = action.conditionParam2;
  791.     var param3 = action.conditionParam3;
  792.     var param4 = action.conditionParam4;
  793.     switch (action.conditionType) {
  794.     case 1:
  795.         return this.meetsTurnCondition(param1, param2);
  796.     case 2:
  797.         return this.meetsHpCondition(param1, param2);
  798.     case 3:
  799.         return this.meetsMpCondition(param1, param2);
  800.     case 4:
  801.         return this.meetsStateCondition(param1);
  802.     case 5:
  803.         return this.meetsPartyLevelCondition(param1);
  804.     case 6:
  805.         return this.meetsSwitchCondition(param1, param2);
  806.     case 7:
  807.         return this.meetsVariableCondition(param1, param2, param3, param4);
  808.     case 8:
  809.         return !!eval(param1);
  810.     default:
  811.         return true;
  812.     }
  813. };
  814.  
  815. Game_Enemy.prototype.meetsSwitchCondition = function(param1, param2) {
  816.     switch (param2) {
  817.     case 1:
  818.         return $gameBattleSwitches.value([0, 0, param1]);
  819.     case 2:
  820.         return this.battleswitch(param1);
  821.     case 3:
  822.         return this.selfswitch(param1);
  823.     case 4:
  824.         return $gameTroop.battleswitch(param1);
  825.     case 5:
  826.         return $gameParty.selfswitch(param1);
  827.     case 6:
  828.         return $gameParty.battleswitch(param1);
  829.     default:
  830.         return $gameSwitches.value(param1);
  831.     }
  832. };
  833.  
  834. Game_Enemy.prototype.meetsVariableCondition = function(param1, param2, param3, param4) {
  835.     switch (param2) {
  836.     case 1:
  837.         return ICF.EnemiesCore.CheckVar(param3, $gameBattleVariables.strictValue([0, 0, param1]), param4);
  838.     case 2:
  839.         return ICF.EnemiesCore.CheckVar(param3, this.strictbattlevariable(param1), param4);
  840.     case 3:
  841.         return ICF.EnemiesCore.CheckVar(param3, this.strictselfvariable(param1), param4);
  842.     case 4:
  843.         return ICF.EnemiesCore.CheckVar(param3, $gameTroop.battlevariable(param1), param4);
  844.     case 5:
  845.         return ICF.EnemiesCore.CheckVar(param3, $gameTroop.minbattlevariable(param1), param4);
  846.     case 6:
  847.         return ICF.EnemiesCore.CheckVar(param3, $gameTroop.maxbattlevariable(param1), param4);
  848.     case 7:
  849.         return ICF.EnemiesCore.CheckVar(param3, $gameTroop.avgbattlevariable(param1), param4);
  850.     case 8:
  851.         return ICF.EnemiesCore.CheckVar(param3, $gameParty.selfvariable(param1), param4);
  852.     case 9:
  853.         return ICF.EnemiesCore.CheckVar(param3, $gameParty.minselfvariable(param1), param4);
  854.     case 10:
  855.         return ICF.EnemiesCore.CheckVar(param3, $gameParty.maxselfvariable(param1), param4);
  856.     case 11:
  857.         return ICF.EnemiesCore.CheckVar(param3, $gameParty.avgselfvariable(param1), param4);
  858.     case 12:
  859.         return ICF.EnemiesCore.CheckVar(param3, $gameParty.battlevariable(param1), param4);
  860.     case 13:
  861.         return ICF.EnemiesCore.CheckVar(param3, $gameParty.minbattlevariable(param1), param4);
  862.     case 14:
  863.         return ICF.EnemiesCore.CheckVar(param3, $gameParty.maxbattlevariable(param1), param4);
  864.     case 15:
  865.         return ICF.EnemiesCore.CheckVar(param3, $gameParty.avgbattlevariable(param1), param4);
  866.     default:
  867.         return ICF.EnemiesCore.CheckVar(param3, $gameVariables.value(param1), param4);
  868.     }
  869. };
  870.  
  871. Game_Enemy.prototype.actionList = function() {
  872.     return this.enemy().actions.concat(this._variation.actions).concat((this.classVariation())? this.classVariation().actions : []);
  873. };
  874.  
  875. Game_Enemy.prototype.makeActions = function() {
  876.     Game_Battler.prototype.makeActions.call(this);
  877.     if (this.numActions() > 0) {
  878.         var actionList = this.actionList().filter(function(a) {
  879.             return this.isActionValid(a);
  880.         }, this);
  881.         if (actionList.length > 0) {
  882.             this.selectAllActions(actionList);
  883.         }
  884.     }
  885.     this.setActionState('waiting');
  886. };
  887.  
  888. //=============================================================================
  889. // Enemies Utilities
  890. //=============================================================================
  891.  
  892. ICF.EnemiesCore.CheckVar = function(code, value1, value2) {
  893.     switch (code) {
  894.         case 0:
  895.             return (value1 == value2); break;
  896.         case 1:
  897.             return (value1 !== value2); break;
  898.         case 2:
  899.             return (value1 > value2); break;
  900.         case 3:
  901.             return (value1 >= value2); break;
  902.         case 4:
  903.             return (value1 < value2); break;
  904.         case 5:
  905.             return (value1 <= value2); break;
  906.         default:
  907.             return false;
  908.     }
  909. }
  910.  
  911. //=============================================================================
  912. // End of File
  913. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement