Advertisement
Kakakadafi

YEP_ExtraEnemyDrops

Jul 10th, 2016
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Yanfly Engine Plugins - Extra Enemy Drops
  3. // YEP_ExtraEnemyDrops.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.YEP_ExtraEnemyDrops = true;
  8.  
  9. var Yanfly = Yanfly || {};
  10. Yanfly.EED = Yanfly.EED || {};
  11.  
  12. //=============================================================================
  13.  /*:
  14.  * @plugindesc v1.05 Allows your enemies to drop more than just three
  15.  * items as per the editor's limit.
  16.  * @author Yanfly Engine Plugins
  17.  *
  18.  * @help
  19.  * ============================================================================
  20.  * Introduction
  21.  * ============================================================================
  22.  *
  23.  * By default, RPG Maker MV limits enemies to only drop up to 3 items max and
  24.  * at very limited drop rates. This plugin allows you to add more than 3 items
  25.  * at drop. In addition to having more than 3 drops, this plugin also allows
  26.  * you to expand the enemy drops to have conditional drops, drops that will
  27.  * only appear before the player if certain conditions are met.
  28.  *
  29.  * ============================================================================
  30.  * Generic Drop - Notetags
  31.  * ============================================================================
  32.  *
  33.  * Use the following notetags to determine extra enemy drops. These drops will
  34.  * drop normally without any special conditions other than having to go through
  35.  * and pass a random number generator.
  36.  *
  37.  * Enemy Notetags:
  38.  *   <Item x: y%>
  39.  *   <Weapon x: y%>
  40.  *   <Armor x: y%>
  41.  *   Adds item, weapon, or armor ID of x to the enemy's drop pool with a y%
  42.  *   chance of dropping the item. Insert multiples of this notetag to add more
  43.  *   drop items for the enemy drop pool.
  44.  *
  45.  *   <Enemy Drops>
  46.  *    Item x: y%
  47.  *    Weapon x: y%
  48.  *    Armor x: y%
  49.  *   </Enemy Drops>
  50.  *   Alternatively, using the above notetag format will allow you to group a
  51.  *   large number of enemy drops together. Replace x with the item, weapon, or
  52.  *   armor ID to give the item a drop rate of y%.
  53.  *
  54.  *   <Drop Pool>
  55.  *    Item x: y%
  56.  *    Weapon x: y%
  57.  *    Armor x: y%
  58.  *   </Drop Pool>
  59.  *   Alternatively, using the above notetag format will allow you to group a
  60.  *   large number of enemy drops together and add the randomly chosen one to
  61.  *   the enemy's drop pool. Replace x with the item, weapon, or armor ID to
  62.  *   give the item a drop rate of y%.
  63.  *
  64.  *   <Drop Potion: x%>
  65.  *   <Drop Short Sword: x%>
  66.  *   <Drop Feather Cap: x%>
  67.  *   If you prefer to use names instead, you can use the above format for the
  68.  *   notetags. This will make the named item have a drop rate of x%. If you
  69.  *   have multiple items in your database with the same name, priority will be
  70.  *   given to the item with the highest ID in the order of item, weapons, then
  71.  *   armors. Insert multiple multiples of this notetag to add more drop items
  72.  *   for the enemy drop pool.
  73.  *
  74.  *   <Enemy Drops>
  75.  *    Potion: x%
  76.  *    Short Sword: x%
  77.  *    Feather Cap: x%
  78.  *   </Enemy Drops>
  79.  *   Alternatively, you can write your notetag like such to group together a
  80.  *   list of named items. This will make the named item have a drop rate of x%.
  81.  *   If you have multiple items in your database with the same name, priority
  82.  *   will be given to the item with the highest ID in the order of item,
  83.  *   weapons, then armors. Insert multiple multiples of this notetag to add
  84.  *   more drop items for the enemy drop pool.
  85.  *
  86.  *   <Drop Pool>
  87.  *    Potion: x%
  88.  *    Short Sword: x%
  89.  *    Feather Cap: x%
  90.  *   </Drop Pool>
  91.  *   Alternatively, you can write your notetag like such to group together a
  92.  *   list of named items and add the randomly chosen one to the enemy's drop.
  93.  *   This will make the named item have a drop rate of x%. If you have multiple
  94.  *   items in your database with the same name, priority will be given to the
  95.  *   item with the highest ID in the order of item, weapons, then armors.
  96.  *   Insert multiple multiples of this notetag to add more drop items for the
  97.  *   enemy drop pool.
  98.  *
  99.  * ============================================================================
  100.  * Conditional Drop - Notetags
  101.  * ============================================================================
  102.  *
  103.  * Sometimes, you want certain conditions to be met before enemies will drop a
  104.  * specific item. These conditional drops would have a 0% chance otherwise. For
  105.  * each condition met, you can increase or decrease the drop rate. Use the
  106.  * below format to create a conditional drop.
  107.  *
  108.  * Enemy Notetags:
  109.  *   <Conditional Item x Drop>
  110.  *    condition: +y%
  111.  *    condition: -y%
  112.  *   </Conditional Item x Drop>
  113.  *
  114.  *   <Conditional Weapon x Drop>
  115.  *    condition: +y%
  116.  *    condition: -y%
  117.  *   </Conditional Weapon x Drop>
  118.  *
  119.  *   <Conditional Armor x Drop>
  120.  *    condition: +y%
  121.  *    condition: -y%
  122.  *   </Conditional Armor x Drop>
  123.  *   The above notetags will create the conditions for item, weapon, or armor x
  124.  *   to drop. Insert various conditions in between the notetags to produce the
  125.  *   conditional rate increases or decreases of y% for the drop.
  126.  *
  127.  *   <Conditional Named Drop>
  128.  *    condition: +y%
  129.  *    condition: -y%
  130.  *   </Conditional Named Drop>
  131.  *   If you prefer to name your drop, use the above format. If database entries
  132.  *   have matching names, priority will be given to the item with the highest
  133.  *   ID in the order of items, weapons, then armor. Insert various conditions
  134.  *   in between the notetags to produce the conditional rate increases or
  135.  *   decreases for y% for the drop.
  136.  *
  137.  * The following are various conditions you may use:
  138.  *
  139.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  140.  * ALIVE MEMBERS EVAL
  141.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  142.  * This checks the number of alive party members the player has when the drops
  143.  * are being calculated and made and runs it against an eval check.
  144.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  145.  * Example:   Alive Members > 1: +20%
  146.  *            Alive Members === 2: +25%
  147.  *            Alive Members <= 3: -30%
  148.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  149.  *
  150.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  151.  * ALWAYS
  152.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  153.  * This condition will always pass. This can be used as setting a base rate for
  154.  * the item drop.
  155.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  156.  * Example:   Always: +50%
  157.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  158.  *
  159.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  160.  * item x COUNT EVAL
  161.  * weapon x COUNT EVAL
  162.  * armor x COUNT EVAL
  163.  * named item COUNT EVAL
  164.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  165.  * This checks the quantity of specific items, weapons, armors, and/or named
  166.  * items you have. If you choose a named item and multiple database entries
  167.  * share the name of that named item, priority will be given to the highest ID
  168.  * in the order of items, weapons, and then armor.
  169.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  170.  * Example:   Item 1 Count > 1: +20%
  171.  *            Weapon 2 Count === 2: +25%
  172.  *            Armor 3 Count <= 3: -30%
  173.  *            Potion Count >= 4: +35%
  174.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  175.  *
  176.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  177.  * DEAD MEMBERS EVAL
  178.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  179.  * This checks the number of dead party members the player has when the drops
  180.  * are being calculated and made and runs it against an eval check.
  181.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  182.  * Example:   Dead Members > 1: +20%
  183.  *            Dead Members === 2: +25%
  184.  *            Dead Members <= 3: -30%
  185.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  186.  *
  187.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  188.  * DEATH TURN EVAL
  189.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  190.  * This will run an eval check to compare the turn number the enemy has died.
  191.  * This plugin requires the Battle Engine Core.
  192.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  193.  * Example:   Death Turn > 5: +10%
  194.  *            Death Turn === 5: +20%
  195.  *            Death Turn <= 4: +30%
  196.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  197.  *
  198.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  199.  * EVAL code
  200.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  201.  * This will run an eval check for the code you've inserted. If it returns true
  202.  * then the condition is met.
  203.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  204.  * Example:   Eval user.name() === 'Bat A': +30%
  205.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  206.  *
  207.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  208.  * LAST STRIKE SKILL X
  209.  * LAST STRIKE ITEM X
  210.  * LAST STRIKE named
  211.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  212.  * This checks to see if the last strike on the enemy is item x, skill x, or a
  213.  * named action. If a named action is used and multiple database entries share
  214.  * the name of the action, priority will be given to the highest ID in the
  215.  * order of skills then items.
  216.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  217.  * Example:   Last Strike Skill 40: +20%
  218.  *            Last Strike Item 50: -30%
  219.  *            Last Strike Firaga: +40%
  220.  *            Last Strike Ice Bomb: -50%
  221.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  222.  *
  223.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  224.  * PARTY MEMBERS EVAL
  225.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  226.  * This checks the number of party members (dead or alive) the player has when
  227.  * the drops are being calculated and made and runs it against an eval check.
  228.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  229.  * Example:   Party Members > 1: +20%
  230.  *            Party Members === 2: +25%
  231.  *            Party Members <= 3: -30%
  232.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  233.  *
  234.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  235.  * RANDOM X%
  236.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  237.  * This condition has a random x% chance to pass.
  238.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  239.  * Example:   Random 20%: +40%
  240.  *            Random 30%: -60%
  241.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  242.  *
  243.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  244.  * TIMES ELEMENT X STRUCK EVAL
  245.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  246.  * This compares the number of times the enemy has been struck by element x.
  247.  * You can also replace x with the name of the item.
  248.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  249.  * Example:   Times Element Fire Struck > 6: +10%
  250.  *            Times Element 3 Struck === 5: -10%
  251.  *            Times Element Thunder <= 4: +20%
  252.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  253.  *
  254.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  255.  * TIMES ITEM X STRUCK EVAL
  256.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  257.  * This compares the number of times the enemy has been struck by item x. You
  258.  * can also replace x with the name of the item.
  259.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  260.  * Example:   Times Item Bomb Struck > 6: +10%
  261.  *            Times Item 42 Struck === 5: -10%
  262.  *            Times Item Uni Struck <= 4: +20%
  263.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  264.  *
  265.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  266.  * TIMES SKILL X STRUCK EVAL
  267.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  268.  * This compares the number of times the enemy has been struck by skill x. You
  269.  * can also replace x with the name of the skill.
  270.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  271.  * Example:   Times Skill Firaga Struck > 6: +10%
  272.  *            Times Skill 40 Struck === 5: -10%
  273.  *            Times Skill Thundaga Struck <= 4: +20%
  274.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  275.  *
  276.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  277.  * TIMES STATE X STRUCK EVAL
  278.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  279.  * This compares the number of times the enemy has been struck by state x.
  280.  * You can also replace x with the name of the state.
  281.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  282.  * Example:   Times State 4 Struck > 6: +10%
  283.  *            Times State Blind Struck === 5: -10%
  284.  *            Times State Silence Struck <= 4: +20%
  285.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  286.  *
  287.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  288.  * TIMES STYPE X STRUCK EVAL
  289.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  290.  * This compares the number of times the enemy has been struck by skill type x.
  291.  * You can also replace x with the name of the skill type.
  292.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  293.  * Example:   Times SType 1 Struck > 6: +10%
  294.  *            Times SType Magic Struck === 5: -10%
  295.  *            Times SType Special Struck <= 4: +20%
  296.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  297.  *
  298.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  299.  * SWITCH X ON
  300.  * SWITCH X OFF
  301.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  302.  * Replace X with a switch ID. If switch X is ON or OFF, the condition is met.
  303.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  304.  * Example:   Switch 5 ON: +10%
  305.  *            Switch 6 OFF: -10%
  306.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  307.  *
  308.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  309.  * TURN EVAL
  310.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  311.  * This will run an eval check to compare the number of turns the battle has
  312.  * gone on for until the time the drops have been made.
  313.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  314.  * Example:   Turn > 5: +10%
  315.  *            Turn === 5: +20%
  316.  *            Turn <= 4: +30%
  317.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  318.  *
  319.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  320.  * VARIABLE X EVAL
  321.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  322.  * Replace X with a variable ID. This will run an eval check to compare the
  323.  * variable's value to see if it meets the conditions.
  324.  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  325.  * Example:   Variable 5 > 10: +20%
  326.  *            Variable 6 === 11: +25%
  327.  *            Variable 7 <= 12: -30%
  328.  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  329.  *
  330.  * ============================================================================
  331.  * Lunatic Mode - New JavaScript Functions~
  332.  * ============================================================================
  333.  *
  334.  * For those with JavaScript proficiency, you can make use of some of these
  335.  * newly added functions when you do an eval check for the enemy:
  336.  *
  337.  * enemy.deathTurn()
  338.  * This will return the turn the enemy died as an integer.
  339.  *
  340.  * enemy.killer()
  341.  * This will return the enemy's killer. If you would like to reference the
  342.  * killer's HP, it'd be enemy.killer().hp
  343.  *
  344.  * enemy.lastStruckAction()
  345.  * This will return either a skill or item that the enemy was last struck with.
  346.  *
  347.  * enemy.timesStruckSkill(skill ID)
  348.  * This will return a number value for the number of times it was struck by
  349.  * the skill referenced by the skill ID.
  350.  *
  351.  * enemy.timesStruckItem(item ID)
  352.  * This will return a number value for the number of times it was struck by
  353.  * the item referenced by the item ID.
  354.  *
  355.  * enemy.timesStruckSType(skill type ID)
  356.  * This will return a number value for the number of times it was struck by
  357.  * skills of the skill type ID.
  358.  *
  359.  * enemy.timesStruckState(state ID)
  360.  * This will return a number value for the number of times it was struck by
  361.  * the state referenced by the state ID.
  362.  *
  363.  * enemy.timesStruckElement(element ID)
  364.  * This will return a number value for the number of times it was struck by
  365.  * the element referenced by the element ID.
  366.  *
  367.  * ============================================================================
  368.  * Changelog
  369.  * ============================================================================
  370.  *
  371.  * Version v1.05:
  372.  * - Eval condition is given more priority as to not be triggered by other
  373.  * conditions.
  374.  *
  375.  * Version v1.04:
  376.  * - Updated for RPG Maker MV version 1.1.0.
  377.  *
  378.  * Version v1.03:
  379.  * - Fixed documentation errors.
  380.  * - Fixed a bug with the Turn Count condition.
  381.  *
  382.  * Version v1.02:
  383.  * - Fixed a bug that crashed the game when a conditional drop is made based
  384.  * off of an item count.
  385.  *
  386.  * Version v1.01:
  387.  * - Added a new section: Lunatic Mode - New JavaScript Functions to allow
  388.  * easier reference for the eval condition.
  389.  *
  390.  * Version v1.00:
  391.  * - Finished Plugin!
  392.  */
  393. //=============================================================================
  394.  
  395. //=============================================================================
  396. // Parameter Variables
  397. //=============================================================================
  398.  
  399. Yanfly.Parameters = PluginManager.parameters('YEP_ExtraEnemyDrops');
  400. Yanfly.Param = Yanfly.Param || {};
  401.  
  402. Yanfly.Param.Variables = String(Yanfly.Parameters['Variables']);
  403.  
  404. //=============================================================================
  405. // DataManager
  406. //=============================================================================
  407.  
  408. Yanfly.EED.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  409. DataManager.isDatabaseLoaded = function() {
  410.   if (!Yanfly.EED.DataManager_isDatabaseLoaded.call(this)) return false;
  411.   if (!Yanfly._loaded_YEP_ExtraEnemyDrops) {
  412.     this.processEEDNotetagsI($dataItems);
  413.     this.processEEDNotetagsW($dataWeapons);
  414.     this.processEEDNotetagsA($dataArmors);
  415.     this.processEEDNotetagsS($dataSkills);
  416.     this.processEEDNotetagsT($dataStates);
  417.     this.processEEDNotetagsSys($dataSystem);
  418.     this.processEEDNotetags1($dataEnemies);
  419.     Yanfly._loaded_YEP_ExtraEnemyDrops = true;
  420.   }
  421.   return true;
  422. };
  423.  
  424. DataManager.processEEDNotetagsI = function(group) {
  425.   if (Yanfly.ItemIdRef) return;
  426.   Yanfly.ItemIdRef = {};
  427.   for (var n = 1; n < group.length; n++) {
  428.     var obj = group[n];
  429.     if (obj.name.length <= 0) continue;
  430.     Yanfly.ItemIdRef[obj.name.toUpperCase()] = n;
  431.   }
  432. };
  433.  
  434. DataManager.processEEDNotetagsW = function(group) {
  435.   if (Yanfly.WeaponIdRef) return;
  436.   Yanfly.WeaponIdRef = {};
  437.   for (var n = 1; n < group.length; n++) {
  438.     var obj = group[n];
  439.     if (obj.name.length <= 0) continue;
  440.     Yanfly.WeaponIdRef[obj.name.toUpperCase()] = n;
  441.   }
  442. };
  443.  
  444. DataManager.processEEDNotetagsA = function(group) {
  445.   if (Yanfly.ArmorIdRef) return;
  446.   Yanfly.ArmorIdRef = {};
  447.   for (var n = 1; n < group.length; n++) {
  448.     var obj = group[n];
  449.     if (obj.name.length <= 0) continue;
  450.     Yanfly.ArmorIdRef[obj.name.toUpperCase()] = n;
  451.   }
  452. };
  453.  
  454. DataManager.processEEDNotetagsS = function(group) {
  455.   if (Yanfly.SkillIdRef) return;
  456.   Yanfly.SkillIdRef = {};
  457.   for (var n = 1; n < group.length; n++) {
  458.     var obj = group[n];
  459.     if (obj.name.length <= 0) continue;
  460.     Yanfly.SkillIdRef[obj.name.toUpperCase()] = n;
  461.   }
  462. };
  463.  
  464. DataManager.processEEDNotetagsT = function(group) {
  465.   if (Yanfly.StateIdRef) return;
  466.   Yanfly.StateIdRef = {};
  467.   for (var n = 1; n < group.length; n++) {
  468.     var obj = group[n];
  469.     if (obj.name.length <= 0) continue;
  470.     Yanfly.StateIdRef[obj.name.toUpperCase()] = n;
  471.   }
  472. };
  473.  
  474. DataManager.processEEDNotetagsSys = function(group) {
  475.   Yanfly.STypeIdRef = {};
  476.   for (var i = 1; i < group.skillTypes.length; ++i) {
  477.     var name = group.skillTypes[i].toUpperCase();
  478.     name = name.replace(/\\I\[(\d+)\]/gi, '');
  479.     Yanfly.STypeIdRef[name] = i;
  480.   }
  481.   Yanfly.ElementIdRef = {};
  482.   for (var i = 1; i < group.elements.length; ++i) {
  483.     var name = group.elements[i].toUpperCase();
  484.     name = name.replace(/\\I\[(\d+)\]/gi, '');
  485.     Yanfly.ElementIdRef[name] = i;
  486.   }
  487. };
  488.  
  489. DataManager.processEEDNotetags1 = function(group) {
  490.   var noteD1 = /<(?:ITEM|DROP ITEM)[ ](\d+):[ ](\d+)([%%])>/i;
  491.   var noteD2 = /<(?:WEAPON|DROP WEAPON)[ ](\d+):[ ](\d+)([%%])>/i;
  492.   var noteD3 = /<(?:ARMOR|DROP armor)[ ](\d+):[ ](\d+)([%%])>/i;
  493.   for (var n = 1; n < group.length; n++) {
  494.     var obj = group[n];
  495.     if (obj.dropsMade) continue;
  496.     var notedata = obj.note.split(/[\r\n]+/);
  497.  
  498.     obj.dropsMade = true;
  499.     obj.dropItemPool = [];
  500.     obj.conditionalDropItems = [];
  501.     var conditionalLines = [];
  502.     var evalMode = 'none';
  503.  
  504.     for (var i = 0; i < notedata.length; i++) {
  505.       var line = notedata[i];
  506.       if (line.match(noteD1)) {
  507.         var id = parseInt(RegExp.$1);
  508.         var rate = parseFloat(RegExp.$2) * 0.01;
  509.         this.createEnemyDrop(obj, id, rate, 1);
  510.       } else if (line.match(noteD2)) {
  511.         var id = parseInt(RegExp.$1);
  512.         var rate = parseFloat(RegExp.$2) * 0.01;
  513.         this.createEnemyDrop(obj, id, rate, 2);
  514.       } else if (line.match(noteD3)) {
  515.         var id = parseInt(RegExp.$1);
  516.         var rate = parseFloat(RegExp.$2) * 0.01;
  517.         this.createEnemyDrop(obj, id, rate, 3);
  518.       } else if (line.match(/<DROP[ ](.*):[ ](\d+)([%%])>/i)) {
  519.         var name = String(RegExp.$1).toUpperCase();
  520.         var rate = parseFloat(RegExp.$2) * 0.01;
  521.         if (Yanfly.ItemIdRef[name]) {
  522.           var id = Yanfly.ItemIdRef[name];
  523.           var kind = 1;
  524.         } else if (Yanfly.WeaponIdRef[name]) {
  525.           var id = Yanfly.WeaponIdRef[name];
  526.           var kind = 2;
  527.         } else if (Yanfly.ArmorIdRef[name]) {
  528.           var id = Yanfly.ArmorIdRef[name];
  529.           var kind = 3;
  530.         } else {
  531.           continue;
  532.         }
  533.         this.createEnemyDrop(obj, id, rate, kind);
  534.       } else if (line.match(/<(?:ENEMY DROP|ENEMY DROPS)>/i)) {
  535.         var evalMode = 'drops';
  536.       } else if (line.match(/<\/(?:ENEMY DROP|ENEMY DROPS)>/i)) {
  537.         var evalMode = 'none';
  538.       } else if (evalMode === 'drops') {
  539.         if (line.match(/ITEM[ ](\d+):[ ](\d+)([%%])/i)) {
  540.           var id = parseInt(RegExp.$1);
  541.           var rate = parseFloat(RegExp.$2) * 0.01;
  542.           this.createEnemyDrop(obj, id, rate, 1);
  543.         } else if (line.match(/WEAPON[ ](\d+):[ ](\d+)([%%])/i)) {
  544.           var id = parseInt(RegExp.$1);
  545.           var rate = parseFloat(RegExp.$2) * 0.01;
  546.           this.createEnemyDrop(obj, id, rate, 2);
  547.         } else if (line.match(/ARMOR[ ](\d+):[ ](\d+)([%%])/i)) {
  548.           var id = parseInt(RegExp.$1);
  549.           var rate = parseFloat(RegExp.$2) * 0.01;
  550.           this.createEnemyDrop(obj, id, rate, 3);
  551.         } else if (line.match(/(.*):[ ](\d+)([%%])/i)) {
  552.           var name = String(RegExp.$1).toUpperCase();
  553.           var rate = parseFloat(RegExp.$2) * 0.01;
  554.           if (Yanfly.ItemIdRef[name]) {
  555.             var id = Yanfly.ItemIdRef[name];
  556.             var kind = 1;
  557.           } else if (Yanfly.WeaponIdRef[name]) {
  558.             var id = Yanfly.WeaponIdRef[name];
  559.             var kind = 2;
  560.           } else if (Yanfly.ArmorIdRef[name]) {
  561.             var id = Yanfly.ArmorIdRef[name];
  562.             var kind = 3;
  563.           } else {
  564.             continue;
  565.           }
  566.           this.createEnemyDrop(obj, id, rate, kind);
  567.         }
  568.       } else if (line.match(/<(?:DROP POOL)>/i)) {
  569.         var evalMode = 'pool';
  570.       } else if (line.match(/<\/(?:DROP POOL)>/i)) {
  571.         var evalMode = 'none';
  572.       } else if (evalMode === 'pool') {
  573.         if (line.match(/ITEM[ ](\d+):[ ](\d+)([%%])/i)) {
  574.           var id = parseInt(RegExp.$1);
  575.           var rate = parseFloat(RegExp.$2) * 0.01;
  576.           this.createEnemyPool(obj, id, rate, 1);
  577.         } else if (line.match(/WEAPON[ ](\d+):[ ](\d+)([%%])/i)) {
  578.           var id = parseInt(RegExp.$1);
  579.           var rate = parseFloat(RegExp.$2) * 0.01;
  580.           this.createEnemyPool(obj, id, rate, 2);
  581.         } else if (line.match(/ARMOR[ ](\d+):[ ](\d+)([%%])/i)) {
  582.           var id = parseInt(RegExp.$1);
  583.           var rate = parseFloat(RegExp.$2) * 0.01;
  584.           this.createEnemyPool(obj, id, rate, 3);
  585.         } else if (line.match(/(.*):[ ](\d+)([%%])/i)) {
  586.           var name = String(RegExp.$1).toUpperCase();
  587.           var rate = parseFloat(RegExp.$2) * 0.01;
  588.           if (Yanfly.ItemIdRef[name]) {
  589.             var id = Yanfly.ItemIdRef[name];
  590.             var kind = 1;
  591.           } else if (Yanfly.WeaponIdRef[name]) {
  592.             var id = Yanfly.WeaponIdRef[name];
  593.             var kind = 2;
  594.           } else if (Yanfly.ArmorIdRef[name]) {
  595.             var id = Yanfly.ArmorIdRef[name];
  596.             var kind = 3;
  597.           } else {
  598.             continue;
  599.           }
  600.           this.createEnemyPool(obj, id, rate, kind);
  601.         }
  602.       } else if (line.match(/<CONDITIONAL[ ](.*)[ ]DROP>/i)) {
  603.         var evalMode = 'conditionalDrop';
  604.         conditionalLines = [];
  605.       } else if (line.match(/<\/CONDITIONAL[ ](.*)[ ]DROP>/i)) {
  606.         var evalMode = 'none';
  607.         var name = String(RegExp.$1).toUpperCase();
  608.         if (name.match(/ITEM[ ](\d+)/i)) {
  609.           var item = $dataItems[parseInt(RegExp.$1)];
  610.         } else if (name.match(/WEAPON[ ](\d+)/i)) {
  611.           var item = $dataWeapons[parseInt(RegExp.$1)];
  612.         } else if (name.match(/ARMOR[ ](\d+)/i)) {
  613.           var item = $dataArmors[parseInt(RegExp.$1)];
  614.         } else if (Yanfly.ItemIdRef[name]) {
  615.           var id = Yanfly.ItemIdRef[name];
  616.           var item = $dataItems[id];
  617.         } else if (Yanfly.WeaponIdRef[name]) {
  618.           var id = Yanfly.WeaponIdRef[name];
  619.           var item = $dataWeapons[id];
  620.         } else if (Yanfly.ArmorIdRef[name]) {
  621.           var id = Yanfly.ArmorIdRef[name];
  622.           var item = $dataArmors[id];
  623.         } else {
  624.           continue;
  625.         }
  626.         if (!item) continue;
  627.         var arr = [item, conditionalLines];
  628.         obj.conditionalDropItems.push(arr);
  629.         conditionalLines = [];
  630.       } else if (evalMode === 'conditionalDrop') {
  631.         conditionalLines.push(line);
  632.       }
  633.     }
  634.   }
  635. };
  636.  
  637. DataManager.createEnemyDrop = function(obj, dataId, rate, kind) {
  638.     var dropItem = {
  639.       dataId: dataId,
  640.       denominator: 1 / rate,
  641.       kind: kind
  642.     }
  643.     obj.dropItems.push(dropItem);
  644. };
  645.  
  646. DataManager.createEnemyPool = function(obj, dataId, rate, kind) {
  647.     var dropItem = {
  648.       dataId: dataId,
  649.       denominator: 1 / rate,
  650.       kind: kind
  651.     }
  652.     obj.dropItemPool.push(dropItem);
  653. };
  654.  
  655. //=============================================================================
  656. // Game_BattlerBase
  657. //=============================================================================
  658.  
  659. Yanfly.EED.Game_BattlerBase_addNewState =
  660.     Game_BattlerBase.prototype.addNewState;
  661. Game_BattlerBase.prototype.addNewState = function(stateId) {
  662.     Yanfly.EED.Game_BattlerBase_addNewState.call(this, stateId);
  663.     if (this.isEnemy()) this.markStruckState(stateId);
  664.     if (stateId === this.deathStateId() && this.isEnemy()) {
  665.         this.markDeathTurn();
  666.     }
  667. };
  668.  
  669. //=============================================================================
  670. // Game_Enemy
  671. //=============================================================================
  672.  
  673. Game_Enemy.prototype.makeDropItemPool = function() {
  674.     return this.enemy().dropItemPool.reduce(function(r, di) {
  675.         if (di.kind > 0 && Math.random() * di.denominator < this.dropItemRate()) {
  676.             return r.concat(this.itemObject(di.kind, di.dataId));
  677.         } else {
  678.             return r;
  679.         }
  680.     }.bind(this), []);
  681. };
  682.  
  683. Yanfly.EED.Game_Enemy_makeDropItems = Game_Enemy.prototype.makeDropItems;
  684. Game_Enemy.prototype.makeDropItems = function() {
  685.     var drops = Yanfly.EED.Game_Enemy_makeDropItems.call(this);
  686.     var pool = this.makeDropItemPool();
  687.     if (pool.length > 0) {
  688.         var index = Math.floor(Math.random() * ((pool.length - 1) + 1));
  689.         drops.push(pool[index]);
  690.     }
  691.     drops = drops.concat(this.makeConditionalDropItems());
  692.     return drops;
  693. };
  694.  
  695. Game_Enemy.prototype.makeConditionalDropItems = function() {
  696.     var drops = DropManager.setup(this);
  697.     return drops;
  698. };
  699.  
  700. Game_Enemy.prototype.markDeathTurn = function() {
  701.     if (this._selfTurnCount !== undefined) {
  702.       this._deathTurn = this._selfTurnCount;
  703.     } else {
  704.       this._deathTurn = $gameTroop.turnCount();
  705.     }
  706. };
  707.  
  708. Game_Enemy.prototype.markStruckState = function(id) {
  709.     this.createTimesStruck();
  710.     this._struckStates[id] = this._struckStates[id] || 0;
  711.     this._struckStates[id] = this._struckStates[id] + 1;
  712. };
  713.  
  714. Game_Enemy.prototype.deathTurn = function() {
  715.     return this._deathTurn || 0;
  716. };
  717.  
  718. Game_Enemy.prototype.createTimesStruck = function() {
  719.     if (this._struckSkills === undefined) this._struckSkills = {};
  720.     if (this._struckSType === undefined) this._struckSType = {};
  721.     if (this._struckItems === undefined) this._struckItems = {};
  722.     if (this._struckStates === undefined) this._struckStates = {};
  723.     if (this._struckElements === undefined) this._struckElements = {};
  724.     if (this._lastStruckId === undefined) this._lastStruckId = 0;
  725.     if (this._lastStruckSkill === undefined) this._lastStruckSkill = false;
  726.     if (this._lastStruckActor === undefined) this._lastStruckActor = null;
  727. };
  728.  
  729. Game_Enemy.prototype.lastStruckAction = function() {
  730.     if (this._lastStruckId === undefined) this.createTimesStruck();
  731.     if (this._lastStruckSkill === undefined) this.createTimesStruck();
  732.     if (this._lastStruckSkill) {
  733.       return $dataSkills[this._lastStruckId];
  734.     } else {
  735.       return $dataItems[this._lastStruckId];
  736.     }
  737. };
  738.  
  739. Game_Enemy.prototype.markStruckActions = function(item, subject) {
  740.     if (!item) return;
  741.     this.createTimesStruck();
  742.     this._lastStruckId = item.id;
  743.     this._lastStruckSkill = DataManager.isSkill(item);
  744.     this.markLastStruckActor(subject);
  745.     if (DataManager.isSkill(item)) {
  746.       this._struckSkills[item.id] = this._struckSkills[item.id] || 0;
  747.       this._struckSkills[item.id] = this._struckSkills[item.id] + 1;
  748.       this._struckSType[item.stypeId] = this._struckSType[item.stypeId] || 0;
  749.       this._struckSType[item.stypeId] = this._struckSType[item.stypeId] + 1;
  750.     }
  751.     if (DataManager.isItem(item)) {
  752.       this._struckItems[item.id] = this._struckItems[item.id] || 0;
  753.       this._struckItems[item.id] = this._struckItems[item.id] + 1;
  754.     }
  755.     this.markStruckElements(item, subject);
  756. };
  757.  
  758. Game_Enemy.prototype.killer = function() {
  759.     if (this._lastStruckActor > 0) {
  760.       return $gameActors.actor(this._lastStruckActor);
  761.     } else {
  762.       return this;
  763.     }
  764. };
  765.  
  766. Game_Enemy.prototype.markLastStruckActor = function(subject) {
  767.   if (subject && subject.isActor()) this._lastStruckActor = subject.actor().id;
  768. };
  769.  
  770. Game_Enemy.prototype.markStruckElements = function(item, subject) {
  771.     if (item.damage.elementId < 0) {
  772.       for (var i = 0; i < subject.attackElements().length; ++i) {
  773.         var eleId = subject.attackElements()[i];
  774.         this._struckElements[eleId] = this._struckElements[eleId] || 0;
  775.         this._struckElements[eleId] = this._struckElements[eleId] + 1;
  776.       }
  777.     } else {
  778.       var eleId = item.damage.elementId;
  779.       this._struckElements[eleId] = this._struckElements[eleId] || 0;
  780.       this._struckElements[eleId] = this._struckElements[eleId] + 1;
  781.     }
  782. };
  783.  
  784. Game_Enemy.prototype.timesStruckSkill = function(id) {
  785.     this.createTimesStruck();
  786.     return this._struckSkills[id] || 0;
  787. };
  788.  
  789. Game_Enemy.prototype.timesStruckItem = function(id) {
  790.     this.createTimesStruck();
  791.     return this._struckItems[id] || 0;
  792. };
  793.  
  794. Game_Enemy.prototype.timesStruckSType = function(id) {
  795.     this.createTimesStruck();
  796.     return this._struckSType[id] || 0;
  797. };
  798.  
  799. Game_Enemy.prototype.timesStruckState = function(id) {
  800.     this.createTimesStruck();
  801.     return this._struckStates[id] || 0;
  802. };
  803.  
  804. Game_Enemy.prototype.timesStruckElement = function(id) {
  805.     this.createTimesStruck();
  806.     return this._struckElements[id] || 0;
  807. };
  808.  
  809. //=============================================================================
  810. // Game_Action
  811. //=============================================================================
  812.  
  813. Yanfly.EED.Game_Action_applyItemUserEffect =
  814.     Game_Action.prototype.applyItemUserEffect;
  815. Game_Action.prototype.applyItemUserEffect = function(target) {
  816.     Yanfly.EED.Game_Action_applyItemUserEffect.call(this, target);
  817.     if (target && target.isEnemy()) {
  818.       target.markStruckActions(this.item(), this.subject());
  819.     }
  820. };
  821.  
  822. //=============================================================================
  823. // DropManager
  824. //=============================================================================
  825.  
  826. function DropManager() {
  827.     throw new Error('This is a static class');
  828. }
  829.  
  830. DropManager.setup = function(enemy) {
  831.     this._enemy = enemy;
  832.     this._data = this._enemy.enemy().conditionalDropItems;
  833.     this._drops = [];
  834.     this.makeConditionalDropItems();
  835.     return this._drops;
  836. };
  837.  
  838. DropManager.makeConditionalDropItems = function() {
  839.     var length = this._data.length;
  840.     if (length <= 0) return;
  841.     for (var i = 0; i < length; ++i) {
  842.       var data = this._data[i];
  843.       var item = data[0];
  844.       var conditions = data[1];
  845.       if (Math.random() < this.getConditionalRate(conditions)) {
  846.         this._drops.push(item);
  847.       }
  848.     }
  849. };
  850.  
  851. DropManager.getConditionalRate = function(conditions) {
  852.     var rate = 0;
  853.     var length = conditions.length;
  854.     for (var i = 0; i < length; ++i) {
  855.       var condition = conditions[i];
  856.       if (condition.match(/(.*):[ ]([\+\-]\d+)([%%])/i)) {
  857.         var line = String(RegExp.$1);
  858.         var value = parseFloat(RegExp.$2) * 0.01;
  859.         if (this.meetsLineCondition(line)) rate += value;
  860.       }
  861.     }
  862.     return rate;
  863. };
  864.  
  865. DropManager.meetsLineCondition = function(line) {
  866.     // EVAL
  867.     if (line.match(/EVAL[ ](.*)/i)) {
  868.       var line = String(RegExp.$1);
  869.       return this.conditionEval(line);
  870.     }
  871.     // ALIVE MEMBERS
  872.     if (line.match(/ALIVE MEMBERS[ ](.*)/i)) {
  873.       var line = String(RegExp.$1);
  874.       return this.conditionAliveMembers(line);
  875.     }
  876.     // ALWAYS
  877.     if (line.toUpperCase() === 'ALWAYS') {
  878.       return this.conditionAlways();
  879.     }
  880.     // COUNT
  881.     if (line.match(/(.*)[ ]COUNT[ ](.*)/i)) {
  882.       var line1 = String(RegExp.$1);
  883.       var line2 = String(RegExp.$2);
  884.       return this.conditionCount(line1, line2);
  885.     }
  886.     // DEAD MEMBERS
  887.     if (line.match(/DEAD MEMBERS[ ](.*)/i)) {
  888.       var line = String(RegExp.$1);
  889.       return this.conditionDeadMembers(line);
  890.     }
  891.     // DEATH TURN EVAL
  892.     if (line.match(/DEATH TURN[ ](.*)/i)) {
  893.       var line = String(RegExp.$1);
  894.       return this.conditionDeathTurn(line);
  895.     }
  896.     // LAST STRIKE
  897.     if (line.match(/LAST STRIKE[ ](.*)/i)) {
  898.       var line = String(RegExp.$1);
  899.       return this.conditionLastStrike(line);
  900.     }
  901.     // PARTY MEMBERS
  902.     if (line.match(/PARTY MEMBERS[ ](.*)/i)) {
  903.       var line = String(RegExp.$1);
  904.       return this.conditionPartyMembers(line);
  905.     }
  906.     // RANDOM X%
  907.     if (line.match(/RANDOM[ ](\d+)([%%])/i)) {
  908.       var rate = parseFloat(RegExp.$1) * 0.01;
  909.       return this.conditionRandom(rate);
  910.     }
  911.     // TIMES STRUCK
  912.     if (line.match(/TIMES[ ](.*)[ ]STRUCK[ ](.*)/i)) {
  913.       var line1 = String(RegExp.$1);
  914.       var line2 = String(RegExp.$2);
  915.       return this.conditionTimesStruck(line1, line2);
  916.     }
  917.     // SWITCH EVAL
  918.     if (line.match(/SWITCH[ ](\d+)[ ](.*)/i)) {
  919.       var switchId = parseInt(RegExp.$1);
  920.       var switchCase = String(RegExp.$2).toUpperCase();
  921.       return this.conditionSwitch(switchId, switchCase);
  922.     }
  923.     // TURN EVAL
  924.     if (line.match(/TURN[ ](.*)/i)) {
  925.       var line = String(RegExp.$1);
  926.       return this.conditionTurn(line);
  927.     }
  928.     // VARIABLE EVAL
  929.     if (line.match(/VARIABLE[ ](\d+)[ ](.*)/i)) {
  930.       var varId = parseInt(RegExp.$1);
  931.       var varLine = String(RegExp.$2).toUpperCase();
  932.       return this.conditionVariable(varId, varLine);
  933.     }
  934.     return false;
  935. };
  936.  
  937. DropManager.conditionAliveMembers = function(line) {
  938.     var user = this._enemy;
  939.     var enemy = this._enemy;
  940.     var a = this._enemy;
  941.     var s = $gameSwitches._data;
  942.     var v = $gameVariables._data;
  943.     value = eval('$gameParty.aliveMembers().length ' + line);
  944.     return value;
  945. };
  946.  
  947. DropManager.conditionAlways = function() {
  948.     return true;
  949. };
  950.  
  951. DropManager.conditionCount = function(line1, line2) {
  952.     var item = null;
  953.     if (line1.match(/ITEM[ ](\d+)/i)) {
  954.       item = $dataItems[parseInt(RegExp.$1)];
  955.     } else if (line1.match(/WEAPON[ ](\d+)/i)) {
  956.       item = $dataWeapons[parseInt(RegExp.$1)];
  957.     } else if (line1.match(/ARMOR[ ](\d+)/i)) {
  958.       item = $dataArmors[parseInt(RegExp.$1)];
  959.     } else if (Yanfly.ItemIdRef[line1.toUpperCase()]) {
  960.       item = $dataItems[Yanfly.ItemIdRef[line1.toUpperCase()]];
  961.     } else if (Yanfly.WeaponIdRef[line1.toUpperCase()]) {
  962.       item = $dataWeapons[Yanfly.WeaponIdRef[line1.toUpperCase()]];
  963.     } else if (Yanfly.ArmorIdRef[line1.toUpperCase()]) {
  964.       item = $dataArmors[Yanfly.ArmorIdRef[line1.toUpperCase()]];
  965.     }
  966.     if (!item) return false;
  967.     if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) {
  968.       var quantity = $gameParty.numIndependentItems(item);
  969.     } else {
  970.       var quantity = $gameParty.numItems(item);
  971.     }
  972.     var user = this._enemy;
  973.     var enemy = this._enemy;
  974.     var a = this._enemy;
  975.     var s = $gameSwitches._data;
  976.     var v = $gameVariables._data;
  977.     value = eval('quantity ' + line2);
  978.     return value;
  979. };
  980.  
  981. DropManager.conditionDeadMembers = function(line) {
  982.     var user = this._enemy;
  983.     var enemy = this._enemy;
  984.     var a = this._enemy;
  985.     var s = $gameSwitches._data;
  986.     var v = $gameVariables._data;
  987.     value = eval('$gameParty.deadMembers().length ' + line);
  988.     return value;
  989. };
  990.  
  991. DropManager.conditionDeathTurn = function(line) {
  992.     var user = this._enemy;
  993.     var enemy = this._enemy;
  994.     var a = this._enemy;
  995.     var s = $gameSwitches._data;
  996.     var v = $gameVariables._data;
  997.     value = eval('user.deathTurn() ' + line);
  998.     return value;
  999. };
  1000.  
  1001. DropManager.conditionLastStrike = function(line) {
  1002.     if (line.match(/SKILL[ ](\d+)/i)) {
  1003.       var id = parseInt(RegExp.$1);
  1004.       return this._enemy.lastStruckAction() === $dataSkills[id];
  1005.     } else if (line.match(/ITEM[ ](\d+)/i)) {
  1006.       var id = parseInt(RegExp.$1);
  1007.       return this._enemy.lastStruckAction() === $dataItems[id];
  1008.     } else if (Yanfly.SkillIdRef[line.toUpperCase()]) {
  1009.       var id = Yanfly.SkillIdRef[line.toUpperCase()];
  1010.       return this._enemy.lastStruckAction() === $dataSkills[id];
  1011.     } else if (Yanfly.ItemIdRef[line.toUpperCase()]) {
  1012.       var id = Yanfly.ItemIdRef[line.toUpperCase()];
  1013.       return this._enemy.lastStruckAction() === $dataItems[id];
  1014.     }
  1015.     return false;
  1016. };
  1017.  
  1018. DropManager.conditionPartyMembers = function(line) {
  1019.     var user = this._enemy;
  1020.     var enemy = this._enemy;
  1021.     var a = this._enemy;
  1022.     var s = $gameSwitches._data;
  1023.     var v = $gameVariables._data;
  1024.     value = eval('$gameParty.battleMembers().length ' + line);
  1025.     return value;
  1026. };
  1027.  
  1028. DropManager.conditionRandom = function(rate) {
  1029.     return Math.random() < rate;
  1030. };
  1031.  
  1032. DropManager.conditionSwitch = function(switchId, switchCase) {
  1033.     var condition = false;
  1034.     if (['ON', 'TRUE'].contains(switchCase)) condition = true;
  1035.     return $gameSwitches.value(switchId) === condition;
  1036. };
  1037.  
  1038. DropManager.conditionTimesStruck = function(line1, line2) {
  1039.     var times = this.getTimesStruck(line1);
  1040.     var user = this._enemy;
  1041.     var enemy = this._enemy;
  1042.     var a = this._enemy;
  1043.     var s = $gameSwitches._data;
  1044.     var v = $gameVariables._data;
  1045.     value = eval('times ' + line2);
  1046.     return value;
  1047. };
  1048.  
  1049. DropManager.getTimesStruck = function(line) {
  1050.     var times = 0;
  1051.     if (line.match(/SKILL[ ](\d+)/i)) {
  1052.       var id = parseInt(RegExp.$1);
  1053.       times = this._enemy.timesStruckSkill(id);
  1054.     } else if (line.match(/SKILL[ ](.*)/i)) {
  1055.       var name = String(RegExp.$1).toUpperCase();
  1056.       if (Yanfly.SkillIdRef[name]) {
  1057.         var id = Yanfly.SkillIdRef[name];
  1058.         times = this._enemy.timesStruckSkill(id);
  1059.       }
  1060.     } else if (line.match(/ITEM[ ](\d+)/i)) {
  1061.       var id = parseInt(RegExp.$1);
  1062.       times = this._enemy.timesStruckItem(id);
  1063.     } else if (line.match(/ITEM[ ](.*)/i)) {
  1064.       var name = String(RegExp.$1).toUpperCase();
  1065.       if (Yanfly.ItemIdRef[name]) {
  1066.         var id = Yanfly.ItemIdRef[name];
  1067.         times = this._enemy.timesStruckItem(id);
  1068.       }
  1069.     } else if (line.match(/STYPE[ ](\d+)/i)) {
  1070.       var id = parseInt(RegExp.$1);
  1071.       times = this._enemy.timesStruckSType(id);
  1072.     } else if (line.match(/STYPE[ ](.*)/i)) {
  1073.       var name = String(RegExp.$1).toUpperCase();
  1074.       if (Yanfly.STypeIdRef[name]) {
  1075.         var id = Yanfly.STypeIdRef[name];
  1076.         times = this._enemy.timesStruckSType(id);
  1077.       }
  1078.     } else if (line.match(/STATE[ ](\d+)/i)) {
  1079.       var id = parseInt(RegExp.$1);
  1080.       times = this._enemy.timesStruckState(id);
  1081.     } else if (line.match(/STATE[ ](.*)/i)) {
  1082.       var name = String(RegExp.$1).toUpperCase();
  1083.       if (Yanfly.StateIdRef[name]) {
  1084.         var id = Yanfly.StateIdRef[name];
  1085.         times = this._enemy.timesStruckState(id);
  1086.       }
  1087.     } else if (line.match(/ELEMENT[ ](\d+)/i)) {
  1088.       var id = parseInt(RegExp.$1);
  1089.       times = this._enemy.timesStruckElement(id);
  1090.     } else if (line.match(/ELEMENT[ ](.*)/i)) {
  1091.       var name = String(RegExp.$1).toUpperCase();
  1092.       if (Yanfly.ElementIdRef[name]) {
  1093.         var id = Yanfly.ElementIdRef[name];
  1094.         times = this._enemy.timesStruckElement(id);
  1095.       }
  1096.     }
  1097.     return times;
  1098. };
  1099.  
  1100. DropManager.conditionTurn = function(line) {
  1101.     var user = this._enemy;
  1102.     var enemy = this._enemy;
  1103.     var a = this._enemy;
  1104.     var s = $gameSwitches._data;
  1105.     var v = $gameVariables._data;
  1106.     value = eval('$gameTroop.turnCount() ' + line);
  1107.     return value;
  1108. };
  1109.  
  1110. DropManager.conditionVariable = function(varId, varLine) {
  1111.     var value = false;
  1112.     value = eval('$gameVariables.value(varId) ' + varLine);
  1113.     return value;
  1114. };
  1115.  
  1116. DropManager.conditionEval = function(line) {
  1117.     var user = this._enemy;
  1118.     var enemy = this._enemy;
  1119.     var a = this._enemy;
  1120.     var s = $gameSwitches._data;
  1121.     var v = $gameVariables._data;
  1122.     value = eval(line);
  1123.     return value;
  1124. };
  1125.  
  1126. //=============================================================================
  1127. // End of File
  1128. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement