Advertisement
ICF-Soft

ICF-Soft Enemy Troops Extension 1.01 RPG Maker MV

Nov 15th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ICF-Soft Plugins - Enemy Troops Extension
  3. // ICFSoft_EnemyTroopExt.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.ICFSoft_ETroopEx = true;
  8.  
  9. var ICF = ICF || {};
  10. ICF.ETroopEx = ICF.ETroopEx || {};
  11. ICF.NotetagsProcessor = ICF.NotetagsProcessor || {};
  12.  
  13. ICF.ETroopEx.Version = 101; // 1.01
  14.  
  15. //=============================================================================
  16.  /*:
  17.  * @plugindesc v1.01c This plugin allows more conditions to battle events,
  18.  * add encounter conditions and to concatenate troops.
  19.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  20.  *
  21.  * @param Developer HaltJS
  22.  * @desc When true it throws an error if an custom page condition
  23.  * javascript doesn't work.   NO - false     YES - true
  24.  * @default false
  25.  *
  26.  * @help
  27.  * ============================================================================
  28.  * Introduction
  29.  *
  30.  * This is a plugin similar to ICF-Soft Event Extension, made to work with
  31.  * troops. I've decided to separate this because of the diferences between
  32.  * these so I can give different features each one.
  33.  * It uses switches and variables that can be needed inside a battle, like
  34.  * game ones, actor and party ones, battle ones, and enemy and troop ones.
  35.  *
  36.  * Plus you can add enemies from other troopIds.
  37.  *
  38.  * ============================================================================
  39.  * How to use
  40.  * ============================================================================
  41.  *
  42.  * To enable a page you must give it a condition, then add every extra
  43.  * condition to a page with a comment or note, same format as plugin commands:
  44.  *
  45.  * switch x x x x x x
  46.  * battleswitch x x x x x
  47.  * troopswitch x x
  48.  * partyswitch x x x
  49.  * partybattleswitch x x x
  50.  *
  51.  *  - Add specified game, battle, troop or party switch to conditions.
  52.  *    You can place all same-type switchs you need in same line.
  53.  *
  54.  * [prefix]variable x value
  55.  * [prefix]variablehigh x value
  56.  * [prefix]variableless x value
  57.  * [prefix]variablemax x value
  58.  * [prefix]variableequal x value
  59.  * [prefix]variabledif x value
  60.  *
  61.  *  - Add a variable condition. There are six types: min value, higher than,
  62.  *    lower than, max value, equal and not equal.
  63.  *    Optionaly you can add a prefix to use battle, troop, party and
  64.  *    partybattle variables this way:
  65.  *
  66.  * battlevariable x value
  67.  * troopvariable x value [min/max/avg]
  68.  * partybattlevariable x value [min/max/avg]
  69.  *
  70.  *  - Party and troop variables can have an extra parameter. If omited
  71.  *    it will check sum of members specified variables.
  72.  *    -min: check minimun of members specified variables.
  73.  *    -max: check maximun of members specified variables.
  74.  *    -avg: check average value of members specified variables.
  75.  *
  76.  *
  77.  * To add encounter conditions you can use these other comments:
  78.  *
  79.  * encounterswitch x x x
  80.  * encounteroffswitch x x
  81.  * encountermapswitch x x x x
  82.  * encounterpartyswitch x x x
  83.  *
  84.  *  - Add specified game, map or party switch to conditions.
  85.  *    You can also add game switchs that must be off.
  86.  *    You can place all same-type switchs you need in same line.
  87.  *
  88.  * encounter[opt]variable x value
  89.  * encounter[opt]variablehigh x value
  90.  * encounter[opt]variableless x value
  91.  * encounter[opt]variablemax x value
  92.  * encounter[opt]variableequal x value
  93.  * encounter[opt]variabledif x value
  94.  *
  95.  *  - Add a variable condition. There are six types: min value, higher than,
  96.  *    lower than, max value, equal and not equal.
  97.  *    Optionaly you can add an opt value to use map and party
  98.  *    variables this way:
  99.  *
  100.  * encountermapvariable x value
  101.  * encounterpartybattlevariable x value [min/max/avg]
  102.  *
  103.  *  - Party variables can have an extra parameter. If omited
  104.  *    it will check sum of members specified variables.
  105.  *    -min: check minimun of members specified variables.
  106.  *    -max: check maximun of members specified variables.
  107.  *    -avg: check average value of members specified variables.
  108.  *
  109.  *
  110.  * Also you can add enemies from another troop id by adding a comment
  111.  * no mather wich page.
  112.  *
  113.  * concatenate x x x x
  114.  * concatenate x to y
  115.  *
  116.  * ============================================================================
  117.  * Lunatic Mode
  118.  * ============================================================================
  119.  *
  120.  * You can use special conditions to a page or encounters by using javascript.
  121.  * There are inside a comment or note like others conditions and if you use more
  122.  * than one all will be merged.
  123.  *
  124.  * customreq: code
  125.  * encountercustomreq: code
  126.  *
  127.  *  result - this is where result is stored. By default is false.
  128.  *
  129.  * ============================================================================
  130.  * Parameters
  131.  * ============================================================================
  132.  *
  133.  * Developer HaltJS: This is a development variable usefull to check if there is
  134.  * a wrong javascript event condition.
  135.  * When true will throw an error when it found a wrong javascript in lunatic
  136.  * mode.
  137.  * When false it will be ignored and game continues.
  138.  *
  139.  * ============================================================================
  140.  * Incompatibilities
  141.  * ============================================================================
  142.  *
  143.  * It's incompatible with plugins that fully override troop setup.
  144.  *
  145.  * ============================================================================
  146.  * Known isues
  147.  * ============================================================================
  148.  *
  149.  * For non-full override troop setup plugins it must be placed before them
  150.  * or otherwise their setup will be ignored.
  151.  *
  152.  * ============================================================================
  153.  * Changelog
  154.  * ============================================================================
  155.  *
  156.  * Version 1.01:
  157.  * - Added encounter conditions.
  158.  *
  159.  * Version 1.00:
  160.  * - Finished plugin!
  161.  *
  162.  * ============================================================================
  163.  *
  164.  * For commercial and non-commercial games.
  165.  * Credit to ICF-Soft.
  166.  * This entire header must be included with plugin.
  167.  *
  168.  * ============================================================================
  169. */
  170. //=============================================================================
  171.  /*:es
  172.  * @plugindesc v1.01c Este complemento permite más condiciones en los eventos
  173.  * de batalla, condiciones para encuentros y concatenar tropas.
  174.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  175.  *
  176.  * @param Developer HaltJS
  177.  * @desc Si está activado salta cuando una función personalizada
  178.  * da error.   No - false   Si - true
  179.  * @default false
  180.  *
  181.  * @help
  182.  * ============================================================================
  183.  * Introducción
  184.  * ============================================================================
  185.  *
  186.  * Este plugin es similar a ICF-Soft Event Extension, pero para funcionar
  187.  * con tropas. Los hice separados debido a las diferencias existentes y
  188.  * así puedo poner diferentes características en cada uno.
  189.  * Usa interruptores y variables que puedan usarse en batalla, como los
  190.  * del juego, de personajes y enemigos y sus grupos, y de batalla.
  191.  *
  192.  * Además puedes agregar enemigos de otros grupos.
  193.  *
  194.  * ============================================================================
  195.  * Uso
  196.  * ============================================================================
  197.  *
  198.  * Para habilitar una página basta con darle una condición, y entonces añadir
  199.  * las condiciones mediante comentarios, el mismo formato que los comandos
  200.  * de complemento:
  201.  *
  202.  * switch x x x x x x
  203.  * battleswitch x x x x x
  204.  * troopswitch x x
  205.  * partyswitch x x x
  206.  * partybattleswitch x x x
  207.  *
  208.  *  - Añade interruptores del juego, batalla, troopa o del grupo.
  209.  *    Puedes poner todos los necesarios en la misma linea.
  210.  *
  211.  * [prefix]variable x value
  212.  * [prefix]variablehigh x value
  213.  * [prefix]variableless x value
  214.  * [prefix]variablemax x value
  215.  * [prefix]variableequal x value
  216.  * [prefix]variabledif x value
  217.  *
  218.  *  - Añade condición de variable. Hay seis tipos: mínimo, mayor que,
  219.  *    menor que, máximo, igual y diferente.
  220.  *    Opcionalmente puedes añadir un prefijo como battle (de batalla),
  221.  *    troop (de tropa), party (del grupo) y partybattle (de batalla del grupo):
  222.  *
  223.  * battlevariable x value
  224.  * troopvariable x value [min/max/avg]
  225.  * partybattlevariable x value [min/max/avg]
  226.  *
  227.  *  - Los de grupos pueden llevar un parámetro extra. Si se omite se usará
  228.  *    la suma de dicha variable por cada miembro.
  229.  *    -min: el mínimo del grupo.
  230.  *    -max: el máximo del grupo.
  231.  *    -avg: la media del grupo.
  232.  *
  233.  * Para añadir condiciones para que un encuentro enemigo pueda aparecer
  234.  * se utilizan los siguientes comentarios:
  235.  *
  236.  * encounterswitch x x x
  237.  * encounteroffswitch x x
  238.  * encountermapswitch x x x x
  239.  * encounterpartyswitch x x x
  240.  *
  241.  *  - Añade interruptores del juego, mapa o del grupo.
  242.  *    Tambien interruptores del juego que deban estar desactivados.
  243.  *    Puedes poner todos los necesarios en la misma linea.
  244.  *
  245.  * encounter[opt]variable x value
  246.  * encounter[opt]variablehigh x value
  247.  * encounter[opt]variableless x value
  248.  * encounter[opt]variablemax x value
  249.  * encounter[opt]variableequal x value
  250.  * encounter[opt]variabledif x value
  251.  *
  252.  *  - Añade condición de variable. Hay seis tipos: mínimo, mayor que,
  253.  *    menor que, máximo, igual y diferente.
  254.  *    Opcionalmente puedes añadir un valor en opt como map (de mapa),
  255.  *    o party (del grupo):
  256.  *
  257.  * encountermapvariable x value
  258.  * encounterpartybattlevariable x value [min/max/avg]
  259.  *
  260.  *  - Los de grupo pueden llevar un parámetro extra. Si se omite se usará
  261.  *    la suma de dicha variable por cada miembro.
  262.  *    -min: el mínimo del grupo.
  263.  *    -max: el máximo del grupo.
  264.  *    -avg: la media del grupo.
  265.  *
  266.  * Además puedes añadir enemigos de otro troopid mediante un comentario
  267.  * sin importar en qué página.
  268.  *
  269.  * concatenate x x x x
  270.  * concatenate x hasta y
  271.  *
  272.  * ============================================================================
  273.  * Lunatic Mode
  274.  * ============================================================================
  275.  *
  276.  * Puedes usar condiciones especiales en una página o encuentro mediante javascript.
  277.  * Se pone el código en una nota del mismo modo que las demás condiciones.
  278.  * Si usas más de una se juntarán todas.
  279.  *
  280.  * customreq: código
  281.  * encountercustomreq: código
  282.  *
  283.  *  result - aquí se almacena el resultado. Por defecto está desactivado.
  284.  *
  285.  * ============================================================================
  286.  * Parámetros
  287.  * ============================================================================
  288.  *
  289.  * Developer HaltJS: Esta es una variable de uso durante el desarrollo del juego
  290.  * útil cuando quieres comprobar si hay alguna función personalizada incorrecta.
  291.  * Cuando está activado al encontrar un error el juego se para.
  292.  * Cuando está desactivado ignora el error y el juego continúa.
  293.  *
  294.  * ============================================================================
  295.  * Incompatibilidades
  296.  * ============================================================================
  297.  *
  298.  * No es compatible con plugins que reemplacen por completo el troop setup.
  299.  *
  300.  * ============================================================================
  301.  * Problemas conocidos
  302.  * ============================================================================
  303.  *
  304.  * Para los plugins que no reemplazan por completo el troop setup, éste debe
  305.  * estar antes o les eliminará sus características.
  306.  *
  307.  * ============================================================================
  308.  * Historial de versiones
  309.  * ============================================================================
  310.  *
  311.  * Version 1.01:
  312.  * - Se han añadido condiciones para los encuentros.
  313.  *
  314.  * Version 1.00:
  315.  * - Complemento terminado.
  316.  *
  317.  * ============================================================================
  318.  *
  319.  * Para juegos comerciales y no comerciales.
  320.  * Se debe incluir a ICF-Soft en los créditos.
  321.  * Esta cabecera debe incluirse íntegramente con el plugin.
  322.  *
  323.  * ============================================================================
  324. */
  325. //=============================================================================
  326.  
  327. //=============================================================================
  328. // Parameter Variables
  329. //=============================================================================
  330.  
  331. ICF.Parameters = PluginManager.parameters('ICFSoft_EnemyTroopExt');
  332. ICF.Param = ICF.Param || {};
  333.  
  334. ICF.Param.ETroopExHalt = ICF.Parameters['Developer HaltJS'].toLowerCase() === "true";
  335.  
  336. if (!Imported.ICFSoft_MainUtility) {throw new Error('This plugin requires ICF-Soft Main Utility plugin version 1.01 to work.\nYou can download it at icfsoft.blogspot.com inside plugins section.');}
  337. if (ICF.MainUtility.Version < 101) {throw new Error('This plugin requires ICF-Soft Main Utility plugin version 1.01 to work.\nYou can download it at icfsoft.blogspot.com inside plugins section.');}
  338.  
  339. //=============================================================================
  340. // DataManager
  341. //=============================================================================
  342.  
  343. ICF.ETroopEx.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  344. DataManager.isDatabaseLoaded = function() {
  345.     if (!ICF.ETroopEx.DataManager_isDatabaseLoaded.call(this)) return false;
  346.     if (!ICF.ETroopEx.Procesed) {
  347.     ICF.NotetagsProcessor.eTroopEx($dataTroops);
  348.     ICF.ETroopEx.Procesed = true;
  349.     }
  350.     return true;
  351. };
  352.  
  353. ICF.NotetagsProcessor.eTroopEx = function(group) {
  354.     for (var n = 1; n < group.length; n++) {
  355.     var obj = group[n];
  356.     var pages = obj.pages;
  357.  
  358.     obj.concatenation = [];
  359.  
  360.     obj.switchs = [];
  361.     obj.offswitchs = [];
  362.     obj.mapswitchs = [];
  363.     obj.partyswitchs = [];
  364.     obj.vars = [];
  365.     obj.mapvars = [];
  366.     obj.partypvars = [];
  367.     obj.customreq = "";
  368.  
  369.     for (var i = 0; i < pages.length; i++) {
  370.         var page = pages[i];
  371.         page._switchs = [];
  372.         page._battleswitchs = [];
  373.         page._troopswitchs = [];
  374.         page._partyswitchs = [];
  375.         page._partybswitchs = [];
  376.         page._vars = [];
  377.         page._battlevars = [];
  378.         page._troopvars = [];
  379.         page._partyvars = [];
  380.         page._partybvars = [];
  381.         page._customreq = "";
  382.         for (j = 0; j < page.list.length; j += 1) {
  383.             var command = page.list[j];
  384.             if (command.code === 108) {
  385.                 ICF.TroopEx.Checking = 0;
  386.                 ICF.TroopEx.ProcessComment(page, obj, command.parameters[0]);
  387.             } else if (command.code === 408) {
  388.                 ICF.TroopEx.ProcessComment(page, obj, command.parameters[0]);
  389.             }
  390.         }
  391.  
  392.     }
  393.  
  394.  
  395.     }
  396. };
  397.  
  398. //=============================================================================
  399. // TroopEx Utilities
  400. //=============================================================================
  401.  
  402. ICF.ETroopEx.Checking = false;
  403.  
  404. ICF.ETroopEx.CustomSwitch = function(mapid, evid, switchname, value) {
  405.     var _key = [mapid, evid, switchname];
  406.     var _value = (value.toLowerCase() === "true");
  407.     $gameSelfSwitches.setValue(_key, _value);
  408. }
  409.  
  410. ICF.ETroopEx.ProcessComment = function(page, obj, content) {
  411.     var args = content.split(" ");
  412.     if (ICF.TroopEx.Checking == 1) {
  413.         page._customreq = page._customreq + content + '\n';
  414.     } else if (ICF.TroopEx.Checking == 2) {
  415.         obj.customreq = obj.customreq + content + '\n';
  416.     } else if (args[0] !== null && args[1] !== null) {
  417.         if (args[0].toLowerCase() == "switch") {
  418.             args.splice(0, 1);
  419.             page._switchs = page._switchs.concat(args);
  420.         } else if (args[0].toLowerCase() == "battleswitch") {
  421.             args.splice(0, 1);
  422.             page._battleswitchss = page._battleswitchs.concat(args);
  423.         } else if (args[0].toLowerCase() == "troopswitch") {
  424.             args.splice(0, 1);
  425.             page._troopswitchs = page._troopswitchs.concat(args);
  426.         } else if (args[0].toLowerCase() == "partyswitch") {
  427.             args.splice(0, 1);
  428.             page._partyswitchs = page._partyswitchs.concat(args);
  429.         } else if (args[0].toLowerCase() == "partybattleswitch") {
  430.             args.splice(0, 1);
  431.             page._partybswitchs = page._partybswitchs.concat(args);
  432.         } else if (args[0].toLowerCase().match(/((?:battle)|(?:troop)|(?:party)|(?:partybattle))?(variable)((?:high)|(?:less)|(?:min)|(?:max)|(?:equal)|(?:dif))?/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == args[0].length)) {
  433.             var code = (RegExp.$3 == "high")? 2 : (RegExp.$3 == "less")? 4 : (RegExp.$3 == "max")? 5 : (RegExp.$3 == "equal")? 0 : (RegExp.$3 == "dif")? 1 : 3;
  434.             if (RegExp.$1 == "battle") page._battlevars.push([code, args[1], args[2]]);
  435.             else if (RegExp.$1 == "troop") page._troopvars.push([code, args[1], args[2], args[3]]);
  436.             else if (RegExp.$1 == "party") page._partyvars.push([code, args[1], args[2], args[3]]);
  437.             else if (RegExp.$1 == "partybattle") page._partybvars.push([code, args[1], args[2], args[3]]);
  438.             else page._vars.push([code, args[1], args[2]]);
  439.         } else if (args[0].toLowerCase() == "encounterswitch") {
  440.             args.splice(0, 1);
  441.             obj.switchs = obj.switchs.concat(args);
  442.         } else if (args[0].toLowerCase() == "encounteroffswitch") {
  443.             args.splice(0, 1);
  444.             obj.offswitchs = obj.offswitchs.concat(args);
  445.         } else if (args[0].toLowerCase() == "encountermapswitch") {
  446.             args.splice(0, 1);
  447.             obj.mapswitchs = obj.mapswitchs.concat(args);
  448.         } else if (args[0].toLowerCase() == "encounterpartyswitch") {
  449.             args.splice(0, 1);
  450.             obj.partyswitchs = obj.partyswitchs.concat(args);
  451.         } else if (args[0].toLowerCase().match(/(encounter)((?:map)|(?:party))?(variable)((?:high)|(?:less)|(?:min)|(?:max)|(?:equal)|(?:dif))?/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length + RegExp.$4.length == args[0].length)) {
  452.             var code = (RegExp.$4 == "high")? 2 : (RegExp.$4 == "less")? 4 : (RegExp.$4 == "max")? 5 : (RegExp.$4 == "equal")? 0 : (RegExp.$4 == "dif")? 1 : 3;
  453.             if (RegExp.$1 == "battle") page._battlevars.push([code, args[1], args[2]]);
  454.             else if (RegExp.$2 == "map") obj.mapvars.push([code, args[1], args[2]]);
  455.             else if (RegExp.$2 == "party") obj.partypvars.push([code, args[1], args[2], args[3]]);
  456.             else obj.vars.push([code, args[1], args[2]]);
  457.         } else if (args[0].toLowerCase() == "customreq:") {
  458.             page._customreq = page._customreq + content.substring(10) + '\n';
  459.             ICF.Events.Checking = 1;
  460.         } else if (args[0].toLowerCase() == "encountercustomreq:") {
  461.             obj.customreq = obj.customreq + content.substring(19) + '\n';
  462.             ICF.Events.Checking = 2;
  463.         } else if (args[0].toLowerCase() == "concatenate") {
  464.             args.splice(0, 1);
  465.             args.extend().leaveNumbers();
  466.             obj.concatenation = obj.concatenation.concat(args);
  467.         }
  468.     }
  469. }
  470.  
  471. ICF.ETroopEx.CheckVar = function(code, value1, value2) {
  472.     switch (code) {
  473.         case 0:
  474.             return (value1 == value2); break;
  475.         case 1:
  476.             return (value1 !== value2); break;
  477.         case 2:
  478.             return (value1 > value2); break;
  479.         case 3:
  480.             return (value1 >= value2); break;
  481.         case 4:
  482.             return (value1 < value2); break;
  483.         case 5:
  484.             return (value1 <= value2); break;
  485.         default:
  486.             return false;
  487.     }
  488. }
  489.  
  490. //=============================================================================
  491. // Game_Troop
  492. //=============================================================================
  493.  
  494. Game_Troop.prototype.fulltroop = function() {
  495.     var fulltroop = $dataTroops[this._troopId].members;
  496.     var a = $dataTroops[this._troopId].concatenation;
  497.     for (i = 0; i < a.length; i += 1) {
  498.     fulltroop.concat($dataTroops[a[i]].members);
  499.     }
  500.     return fulltroop;
  501. };
  502.  
  503. Game_Troop.prototype.setup = function(troopId) {
  504.     this.clear();
  505.     this._troopId = troopId;
  506.     this._enemies = [];
  507.     this.fulltroop().forEach(function(member) {
  508.         if ($dataEnemies[member.enemyId]) {
  509.             var enemyId = member.enemyId;
  510.             var x = member.x;
  511.             var y = member.y;
  512.             var enemy = new Game_Enemy(enemyId, x, y);
  513.             if (member.hidden) {
  514.                 enemy.hide();
  515.             }
  516.             this._enemies.push(enemy);
  517.         }
  518.     }, this);
  519.     this.makeUniqueNames();
  520. };
  521.  
  522. ICF.ETroopEx.meetsConditions = Game_Troop.prototype.meetsConditions;
  523. Game_Troop.prototype.meetsConditions = function(page) {
  524.     if (!ICF.ETroopEx.meetsConditions.call(this, page)) return false;
  525.     for (i = 0; i < page._switchs.length; i += 1) {
  526.         if (!$gameSwitches.value(page._switchs[i])) {
  527.             return false;
  528.         }
  529.     }
  530.     for (i = 0; i < page._battleswitchs.length; i += 1) {
  531.         if (!$gameBattleSwitches.value([0, 0, page._battleswitchs[i]])) {
  532.             return false;
  533.         }
  534.     }
  535.     for (i = 0; i < page._troopswitchs.length; i += 1) {
  536.         if ($gameTroop.battleswitch(page._troopswitchs[i]) !== true) {
  537.             return false;
  538.         }
  539.     }
  540.     for (i = 0; i < page._partyswitchs.length; i += 1) {
  541.         if ($gameParty.selfswitch(page._partyswitchs[i]) !== true) {
  542.             return false;
  543.         }
  544.     }
  545.     for (i = 0; i < page._partybswitchs.length; i += 1) {
  546.         if ($gameParty.battleswitch(page._partybswitchs[i]) !== true) {
  547.             return false;
  548.         }
  549.     }
  550.     for (i = 0; i < page._vars.length; i += 1) {
  551.         if (!ICF.TroopEx.CheckVar(page._vars[i][0], $gameVariables.value(page._vars[i][1]), page._vars[i][2])) {
  552.             return false;
  553.         }
  554.     }
  555.     for (i = 0; i < page._battlevars.length; i += 1) {
  556.         var key = [0, 0, page._battlevars[i][1]];
  557.         if (!ICF.TroopEx.CheckVar(page._battlevars[i][0], $gameBattleVariables.value(key), page._battlevars[i][2])) {
  558.             return false;
  559.         }
  560.     }
  561.     for (i = 0; i < page._partyvars.length; i += 1) {
  562.         var code = -1;
  563.         if (!!page._partyvars[i][3]) {code = ["min", "max", "avg"].indexOf(page._partyvars[i][3].toLowerCase());}
  564.         if (code == 0) {if (!ICF.TroopEx.CheckVar(page._partyvars[i][0], $gameParty.minselfvariable(page._partyvars[i][1]), page._partyvars[i][2])) {
  565.             return false;}
  566.         } else if (code == 1) {if (!ICF.TroopEx.CheckVar(page._partyvars[i][0], $gameParty.maxselfvariable(page._partyvars[i][1]), page._partyvars[i][2])) {
  567.             return false;}
  568.         } else if (code == 2) {if (!ICF.TroopEx.CheckVar(page._partyvars[i][0], $gameParty.avgselfvariable(page._partyvars[i][1]), page._partyvars[i][2])) {
  569.             return false;}
  570.         } else {if (!ICF.TroopEx.CheckVar(page._partyvars[i][0], $gameParty.selfvariable(page._partyvars[i][1]), page._partyvars[i][2])) {
  571.             return false;}
  572.         }
  573.     }
  574.     for (i = 0; i < page._partybvars.length; i += 1) {
  575.         var code = -1;
  576.         if (!!page._partybvars[i][3]) {code = ["min", "max", "avg"].indexOf(page._partybvars[i][3].toLowerCase());}
  577.         if (code == 0) {if (!ICF.TroopEx.CheckVar(page._partybvars[i][0], $gameParty.minbattlevariable(page._partybvars[i][1]), page._partybvars[i][2])) {
  578.             return false;}
  579.         } else if (code == 1) {if (!ICF.TroopEx.CheckVar(page._partybvars[i][0], $gameParty.maxbattlevariable(page._partybvars[i][1]), page._partybvars[i][2])) {
  580.             return false;}
  581.         } else if (code == 2) {if (!ICF.TroopEx.CheckVar(page._partybvars[i][0], $gameParty.avgbattlevariable(page._partybvars[i][1]), page._partybvars[i][2])) {
  582.             return false;}
  583.         } else {if (!ICF.TroopEx.CheckVar(page._partybvars[i][0], $gameParty.battlevariable(page._partybvars[i][1]), page._partybvars[i][2])) {
  584.             return false;}
  585.         }
  586.     }
  587.     for (i = 0; i < page._troopvars.length; i += 1) {
  588.         var code = -1;
  589.         if (!!page._troopvars[i][3]) {code = ["min", "max", "avg"].indexOf(page._troopvars[i][3].toLowerCase());}
  590.         if (code == 0) {if (!ICF.TroopEx.CheckVar(page._troopvars[i][0], $gameTroop.minbattlevariable(page._troopvars[i][1]), page._troopvars[i][2])) {
  591.             return false;}
  592.         } else if (code == 1) {if (!ICF.TroopEx.CheckVar(page._troopvars[i][0], $gameTroop.maxbattlevariable(page._troopvars[i][1]), page._troopvars[i][2])) {
  593.             return false;}
  594.         } else if (code == 2) {if (!ICF.TroopEx.CheckVar(page._troopvars[i][0], $gameTroop.avgbattlevariable(page._troopvars[i][1]), page._troopvars[i][2])) {
  595.             return false;}
  596.         } else {if (!ICF.TroopEx.CheckVar(page._troopvars[i][0], $gameTroop.battlevariable(page._troopvars[i][1]), page._troopvars[i][2])) {
  597.             return false;}
  598.         }
  599.     }
  600.  
  601.     if (page._customreq != "") {
  602.         var result = false;
  603.         try {eval(page._customreq);}
  604.         catch (e) {if(ICF.Param.ETroopExHalt){throw new Error('Error in custom page condition for troop');}}
  605.         return result;
  606.     }
  607.  
  608.     return true;
  609. }
  610.  
  611. //-----------------------------------------------------------------------------
  612. //  Game_Player
  613. //-----------------------------------------------------------------------------
  614.  
  615. ICF.ETroopEx.EncounterConditions = Game_Player.prototype.meetsEncounterConditions;
  616. Game_Player.prototype.meetsEncounterConditions = function(encounter) {
  617.     if (!ICF.TroopEx.EncounterConditions.call(this, encounter)) return false;
  618.     var obj = $dataTroops[encounter.troopId];
  619.  
  620.     for (i = 0; i < obj.switchs.length; i += 1) {
  621.         if (!$gameSwitches.value(obj.switchs[i])) {
  622.             return false;
  623.         }
  624.     }
  625.     for (i = 0; i < obj.offswitchs.length; i += 1) {
  626.         if ($gameSwitches.value(obj.offswitchs[i])) {
  627.             return false;
  628.         }
  629.     }
  630.     for (i = 0; i < obj.mapswitchs.length; i += 1) {
  631.         var key = [this._mapId, 0, obj.mapswitchs[i]];
  632.         if ($gameSelfSwitches.value(key) !== true) {
  633.             return false;
  634.         }
  635.     }
  636.     for (i = 0; i < obj.partyswitchs.length; i += 1) {
  637.         if ($gameParty.selfswitch(obj.partyswitchs[i]) !== true) {
  638.             return false;
  639.         }
  640.     }
  641.     for (i = 0; i < obj.vars.length; i += 1) {
  642.         if (!ICF.TroopEx.CheckVar(obj.vars[i][0], $gameVariables.value(obj.vars[i][1]), obj.vars[i][2])) {
  643.             return false;
  644.         }
  645.     }
  646.     for (i = 0; i < obj.mapvars.length; i += 1) {
  647.         var key = [this._mapId, 0, obj.mapvars[i][1]];
  648.         if (!ICF.TroopEx.CheckVar(obj.mapvars[i][0], $gameSelfVariables.value(key), obj.mapvars[i][2])) {
  649.             return false;
  650.         }
  651.     }
  652.     for (i = 0; i < obj.partypvars.length; i += 1) {
  653.         var code = -1;
  654.         if (!!obj.partypvars[i][3]) {code = ["min", "max", "avg"].indexOf(obj.partypvars[i][3].toLowerCase());}
  655.         if (code == 0) {if (!ICF.TroopEx.CheckVar(obj.partypvars[i][0], $gameParty.minselfvariable(obj.partypvars[i][1]), obj.partypvars[i][2])) {
  656.             return false;}
  657.         } else if (code == 1) {if (!ICF.TroopEx.CheckVar(obj.partypvars[i][0], $gameParty.maxselfvariable(obj.partypvars[i][1]), obj.partypvars[i][2])) {
  658.             return false;}
  659.         } else if (code == 2) {if (!ICF.TroopEx.CheckVar(obj.partypvars[i][0], $gameParty.avgselfvariable(obj.partypvars[i][1]), obj.partypvars[i][2])) {
  660.             return false;}
  661.         } else {if (!ICF.TroopEx.CheckVar(obj.partypvars[i][0], $gameParty.selfvariable(obj.partypvars[i][1]), obj.partypvars[i][2])) {
  662.             return false;}
  663.         }
  664.     }
  665.  
  666.     if (obj.customreq != "") {
  667.         var result = false;
  668.         try {eval(obj.customreq);}
  669.         catch (e) {if(ICF.Param.ETroopExHalt){throw new Error('Error in custom page condition for troop');}}
  670.         return result;
  671.     }
  672.  
  673.     return true;
  674. };
  675.  
  676. //=============================================================================
  677. // End of File
  678. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement