Advertisement
Unconnected42

RPG Maker Plug-in - Ammunition System v. 1.1.6

Dec 11th, 2016
309
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Ammunition System, ver1.1.6
  3. //   by Unconnected42
  4. // UNCO_AmmunitionSystem.js
  5. // Last Updated : 2016/11/16
  6. //=============================================================================
  7.  
  8. var Imported = Imported || {};
  9. Imported.UNCO_AmmunitionSystem = true;
  10.  
  11. var Unco = Unco || {};
  12. Unco.AS = Unco.AS || {};
  13.  
  14.  
  15. //=============================================================================
  16.  /*:
  17.  * @plugindesc  Allows skills to need ammunition.
  18.  * <Unco Ammo>
  19.  * @author Unconnected42
  20.  *
  21.  * @param Show Ammo Left When Actor Command
  22.  * @desc If set as 'true', show how much ammunition is left for main attack at the top of the screen, during actor command selection.
  23.  * @default true
  24.  *
  25.  * @param Show Ammo Left In Help Window
  26.  * @desc  If set as 'true', show how much ammunition is left for a skill in its description.
  27.  * @default true
  28.  *
  29.  * @param Help Window Ammo Text
  30.  * @desc  Default text to be displayed in skill description before ammunition amounts.
  31.  * @default Ammunition left
  32.  *
  33.  * @param Show Ammo Left In Skill Window
  34.  * @desc In skill window, show how much ammunition is left together with the cost if set at 'true'.
  35.  * @default false
  36.  *
  37.  * @param No Ammo Icon
  38.  * @desc  Id of the default icon to be displayed when there is no more ammunition and several types of ammunition are possible.
  39.  * @default 16
  40.  *
  41.  * @param Gold Ammo Icon
  42.  * @desc  Id of the icon to be displayed for gold costs.
  43.  * @default 313
  44.  *
  45.  * @param Ammo Font Size
  46.  * @desc Font size of the ammunition amounts in skill window and gauge.
  47.  * @default 20
  48.  *
  49.  * @param Ammo Font Color
  50.  * @desc Font color of the ammunition amounts in skill window and gauge.
  51.  * @default 6
  52.  *
  53.  * @param Show Ammo Left In Actor Command Window
  54.  * @desc If set at true, will display how much ammo is left just next to the attack command.
  55.  * @default false
  56.  *
  57.  * @param Compact Cost Display
  58.  * @desc If set at true, the amount of needed ammo will be displayed on the icon.
  59.  * @default false
  60.  *
  61.  * @help
  62.  * ============================================
  63.  * Introduction
  64.  * ============================================
  65.  *
  66.  * ver1.1.6
  67.  *
  68.  * This plug-in will allow skills or weapons to require the consumption of
  69.  * ammunition, components, etc. in order to work. The cost is  paid each
  70.  * time the skill is used, together with MP/TP costs, or each time the
  71.  * normal attack is used in the case of weapons.
  72.  * The ammunition can be either gold, items or equipments (armours, weapons), or
  73.  * a mix.
  74.  *
  75.  * However, things work differently depending on what type of cost is considered.
  76.  * - items : if several types of items are marked as required as ammunition
  77.  *   for a given skill/weapon, *ALL* of the corresponding prices must be
  78.  *   paid each time the skill/weapon is used.
  79.  * - equipment : the equipment needs to be equipped in order for the skill/weapon
  80.  *   to work. If several types of equipments are marked as required as ammunition
  81.  *   for a given skill/weapon, *ONLY* the cost of the one that is *CURRENTLY
  82.  *   EQUIPPED* will be paid. That means a weapon/skill can be able to use
  83.  *   different interchangeable ammunition types.
  84.  * - Gold cost is straightforward in how it functions.
  85.  *
  86.  * You can also define skills which can change the type of ammunition
  87.  * equipped even during combat, in the case of armour-type ammunition.
  88.  * Then, your hero can use an action to change his/her ammunition type !
  89.  *
  90.  * ============================================
  91.  * Known Compatibility Issues
  92.  * ============================================
  93.  *
  94.  * This plug-in should be placed under all plug-ins that you are using,
  95.  * especially Yanfly's since it actually uses some of their features if
  96.  * they are present.
  97.  * Known exceptions to that rule :
  98.  * - Yanfly's Skill Cooldown
  99.  * - Jay's Dual Techs.
  100.  *   -> Ammunition should be placed above these two plug-ins.
  101.  * This might also be the case for other plug-ins whenever
  102.  * the modification of skill costs is concerned.
  103.  * On the contrary, the following plug-ins MUST be placed above :
  104.  * - Bobstah's BattleCommandList.
  105.  *
  106.  *
  107.  * This plug-in in the present version should be fully compatible
  108.  * with Yanfly's ItemCore Independent Items feature.
  109.  * Therefore, ammunition of any kind can either be independent or
  110.  * not (for the latter case, use a <Not Independent Item> notetag
  111.  * in the ammunition notebox if you are using ItemCore and a max
  112.  * number of items > 0).
  113.  *
  114.  * ============================================
  115.  * Use
  116.  * ============================================
  117.  *
  118.  * + Declaring a weapon/skill to need ammunition
  119.  * ---------------------------------------------
  120.  * Lines to put in either Weapon notebox or Skill notebox for defining costs :
  121.  *   <Gold Cost: c>
  122.  *   <Ammo i Item: c>  (for items ammo)
  123.  *   <Ammo i Equip: c>  (for armors ammo)
  124.  *   <Ammo i Weapon: c>  (for weapons ammo)
  125.  * ... where i is the ID of the ammunition item/armor and c is the cost
  126.  * required for one use.
  127.  * Disclaimer concerning weapon-type ammunition:
  128.  * In its present state it is intended to be used for weapons that would be
  129.  * their own ammo, like throwing knives, shurikens, etc.
  130.  * In theory, however, it *should* be possible to use as ammo for a weapon
  131.  * a different weapon, provided both of them are equipped, but this possibility
  132.  * has yet to be playtested...
  133.  *
  134.  * + Declaring a skill that serves for equipping ammo (during combat)
  135.  * ------------------------------------------------------------------
  136.  * To create a skill that will change the type of ammunition equipped:
  137.  *   <Ammo i Load>
  138.  * ... where i is the ID of the ammunition armor.
  139.  * The following syntax is also authorized:
  140.  *   <Ammo i Load: s>
  141.  * ...where s is the specific slot to be equipped.
  142.  * This syntax is kept only for compatibility reasons, so that people
  143.  * who defined their tags for older versions of the script that did
  144.  * not support the simpler syntax are not forced to change.
  145.  * If your actor(s) have for example the following equipment types:
  146.  *     Weapon, Shield, Head, Body, Accessory, Ammunition
  147.  * ... then the slot number would be 6.
  148.  * Note 1: this is meant to be used during battle, when equip menu is not
  149.  * accessible, if you want your actors to be able to switch ammunition.
  150.  * Note 2: it is necessary to define one skill per type of ammunition.
  151.  * Note 3: it is possible to use this tag for equipping any kind of armor, and
  152.  * not just ammunition.
  153.  * Also, the Load feature currently does not work with weapon-type ammo.
  154.  *
  155.  * + Ammo equipment with charges
  156.  * -----------------------------
  157.  * For an armor- or weapon-type ammunition, you can allow each ammo item to
  158.  * provide a given number of uses instead of being consumed after just one use.
  159.  * Declare the following tag in the ammo equipment notebox:
  160.  *   <Ammo Charges: n>
  161.  * ... where 'n' is the wished number of charges the item possesses.
  162.  * This tag will only actually be used if you are using Yanfly's ItemCore and
  163.  * the item is an independent item.
  164.  * The equipped ammo item has a certain number of charges, and at each use, this
  165.  * is this number that will be reduced, instead of the number of ammo items.
  166.  * When the number of charges hits zero, the item is unequipped, without
  167.  * being returned to inventory. No other item of same type will be equipped even
  168.  * if available in inventory.
  169.  *
  170.  * Instead of having an empty ammunition equipment simply disappear,
  171.  * it is possible to have a specific item be created in the inventory (which
  172.  * then represent the empty equipment).
  173.  * Use the following tag:
  174.  *   <Ammo Charges Empty : i>
  175.  * ...when 'i' is the id of the item to be created.
  176.  * Note that this will be a normal item, not an equipment.
  177.  *
  178.  * + Determining skill's availability depending on a game switch
  179.  * -------------------------------------------------------------
  180.  * You can also now have skill availability depend on a game switch status, with
  181.  * the following tag to put in a skill's notebox:
  182.  *   <Game Switch: n>
  183.  * If the game switch number 'n' is set at false, the skill cannot be used.
  184.  * This might be useful, for example, if you are also using the crafting
  185.  * extension of this plug-in and wish to make crafting available only
  186.  * in certain places/situations.
  187.  *
  188.  * ============================================
  189.  * Displaying Ammunition Amounts & Costs
  190.  * ============================================
  191.  *
  192.  * A given ammunition type is almost always represented by its icon when it
  193.  * is necessary (either to display a cost or a remaining amount).
  194.  * Ammo costs for skills are indicated together with "normal" TP/MP costs.
  195.  *
  196.  * There are several solutions for displaying the remaining ammunition amount
  197.  * so that the player knows where he stands.
  198.  * Most of them are turned on through the plug-in parameters.
  199.  *
  200.  * - For weapons :
  201.  *   + The number of ammunition left can be displayed at the
  202.  *     top of the screen when the actor command menu is active.
  203.  *     This is the default option.
  204.  *   + The number of ammunition left can be displayed in the
  205.  *     command window, just next to the "Attack" option.
  206.  *     No icon in that case.
  207.  *   + If you are using Yanfly's SkillCore plug-in, you can use the following
  208.  *     notetag in the weapon note :
  209.  *         <Swap Gauge n: AMMO>
  210.  *     ...where n is the number of the gauge you want to replace.
  211.  *     Instead of a normal HP/MP/TP gauge, you will then have the amount of
  212.  *     ammunition left for the currently equipped weapon.
  213.  * - For skills :
  214.  *   + The remaining amount for each ammunition type can be showed
  215.  *     together with cost in the skill window.
  216.  *   + It can also be displayed after the skill description, in the help
  217.  *     window. This is the default option.
  218.  *     In that case, you should keep the skill description within one unique
  219.  *     line with no line-break at the end, or else the remaining ammo will
  220.  *     not be visible.
  221.  *
  222.  * The text before ammunition left amounts can be customized with the following
  223.  *   notetag in the skill notebox:
  224.  *   <Ammo Left Text: xxx>
  225.  *   ... with xxx being your custom text.
  226.  * The name of the ammunition type can be displayed along with its icon with
  227.  * the following notetag in the weapon/skill notebox:
  228.  *   <Show Ammo Name>
  229.  *
  230.  * Also, in the case of equipment ammunition, several types of
  231.  * ammunition are possible but only one (the one equipped) will be displayed
  232.  * in any skill/help/etc window (or gauge). When there is no more ammunition,
  233.  * the system normally would not know which icon to use !
  234.  * There is a default icon for that, but you can put the following notetag
  235.  * in skill/weapon notebox to define which icon will be used :
  236.  *   <No Ammo Icon: i>
  237.  *   ... with i being the icon number.
  238.  * It is also possible to add details about the ammunition type currently
  239.  * equipped by adding the following notetag in the ammo notebox :
  240.  *   <Ammo Window Desc: xxx>
  241.  * Where 'xxx' is the description you want to give to your ammo.
  242.  * This description will show up in the skill help window and the ammunition
  243.  * window visible during actor command selection.
  244.  * Please that if you deactivate the ammo window or the display of remaining
  245.  * ammo amount with the corresponding plug-in parameters, you will of course
  246.  * not see any description of ammunition !
  247.  *
  248.  * ============================================
  249.  * Change Log
  250.  * ============================================
  251.  *
  252.  * - 2016-11-16 : ver1.1.5 : maked ammo displayed even for normal attack if necessary.
  253.  * - 2016-11-15 : ver1.1.5 : fixed compatibility with Yanfly's Weapon Unleash.
  254.  * - 2016-06-11 : ver1.1.4 : fixed compatibility with Yanfly's ItemCore version 1.24
  255.  * - 2016-02-17 : ver1.1.3 : (supposedly?) corrected a bug that causes crashes
  256.  *   when enemy attacks in some situations.
  257.  * - 2015-12-15 : ver1.1.2 : yet another bug correction.
  258.  * - 2015-12-15 : ver1.1.1 : corrected a bug that caused zero cost equip ammunition
  259.  *   to be unequippable.
  260.  * - 2015-12-09 : ver1.1.0 : charged ammunition can now 'create' an 'empty' item when
  261.  *   their charge number is reduced to zero. Also, charged ammunition will show
  262.  *   their remaining charges in equip windows.
  263.  * - 2015-11-29 : ver1.0.0 : added charged ammunition feature. Fixed a (generally
  264.  *   silent) bug that could make skills availables even in case of unsufficient
  265.  *   ammunition in some rare cases.
  266.  * - 2015-11-26 : ver0.4.4 : fixed an issue that caused equip-type ammo to be
  267.  *   equippable when it should not in some situations.
  268.  * - 2015-11-24 : ver0.4.3b : fixed an issue that caused ammo not to be consumed
  269.  *   in some situations when using older versions of Yanfly's ATB.
  270.  * - 2015-11-21 : ver0.4.3 : the previous changes made actually break the ammo cost
  271.  *   implementation when ammo are NOT independent items, causing the ammo to be
  272.  *   simply unequipped... Corrected now.
  273.  * - 2015-11-20 : ver0.4.2 : correction of the 'reload skills' feature so that
  274.  *   indicating the correct equip slot for equip ammunition is no more necessary.
  275.  *   Slight modification of how the cost of equip ammunition is managed internally,
  276.  *   so that it works more logically when independent ammo with variance is used.
  277.  * - 2015-11-15 : ver0.4.1 : corrected a bug causing a crash during battle when
  278.  *   no weapon is equipped and the ammo amount is displayed next to attack command.
  279.  *   Also corrected a bug that could make the displayed cost in attack command incorrect.
  280.  * - 2015-11-15 : ver0.4.0 : added compact cost display, game switch dependency,
  281.  *   and weapon-type ammunition (for now, it is strongly recommended to use it only
  282.  *   for weapons using themselves as ammo, such as throwing knives). Added extension Crafting System.
  283.  *
  284.  */
  285. //=============================================================================
  286.  
  287. //=============================================================================
  288. // Parameter Variables
  289. //=============================================================================
  290.  
  291. Unco.Parameters = $plugins.filter(function(p) {
  292.         return p.description.contains('<Unco Ammo>');
  293.     })[0].parameters; //Copied from Ellye, who thanks Iavra
  294. Unco.Param = Unco.Param || {};
  295.  
  296. Unco.Param.showAmmoLeftActorCommand = String(Unco.Parameters['Show Ammo Left When Actor Command']).toLowerCase();
  297. Unco.Param.showAmmoLeft = String(Unco.Parameters['Show Ammo Left In Skill Window']).toLowerCase();
  298. Unco.Param.ammoFontSize = Number(Unco.Parameters['Ammo Font Size']);
  299. Unco.Param.ammoFontColor = Number(Unco.Parameters['Ammo Font Color']);
  300. Unco.Param.showAmmoLeftInDesc = String(Unco.Parameters['Show Ammo Left In Help Window']).toLowerCase();
  301. Unco.Param.descAmmoLeftText = String(Unco.Parameters['Help Window Ammo Text']);
  302. Unco.Param.defaultNoAmmoIconId = parseInt(String(Unco.Parameters['No Ammo Icon']));
  303. Unco.Param.goldAmmoIconId = parseInt(String(Unco.Parameters['Gold Ammo Icon']));
  304. Unco.Param.showAmmoLeftForAttack = String(Unco.Parameters['Show Ammo Left In Actor Command Window']).toLowerCase();
  305. Unco.Param.compactCostDisplay = String(Unco.Parameters['Compact Cost Display']).toLowerCase();
  306.  
  307. //=============================================================================
  308. // DataManager
  309. //=============================================================================
  310.  
  311. Unco.AS.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  312. DataManager.isDatabaseLoaded = function() {
  313.    if (!Unco.AS.DataManager_isDatabaseLoaded.call(this)) return false;
  314.    if (Imported.YEP_ItemCore && (Yanfly.Param.ItemMaxArmors > 0)) {
  315.       this.processUncoAmmoChargesNotetags($dataArmors);
  316.    }
  317.    if (Imported.YEP_ItemCore && (Yanfly.Param.ItemMaxWeapons > 0)) {
  318.       this.processUncoAmmoChargesNotetags($dataWeapons);
  319.    }
  320.    this.processUncoItemAmmoNotetags($dataSkills);
  321.    this.processUncoSwitchNotetags($dataSkills);
  322.    this.processUncoGoldCostNotetags($dataSkills);
  323.    this.processUncoAmmoTextNotetags($dataSkills);
  324.    this.processUncoEquipAmmoNotetags($dataSkills);
  325.    this.processUncoAmmoLoadNotetags($dataSkills);
  326.    this.processUncoAmmoTextNotetags($dataWeapons);
  327.    this.processUncoItemAmmoNotetags($dataWeapons);
  328.    this.processUncoEquipAmmoNotetags($dataWeapons);
  329.    this.processUncoAmmoDescNotetags($dataArmors);
  330.    return true;
  331. };
  332.  
  333. DataManager.processUncoAmmoChargesNotetags = function(group) {
  334.    for (var n = 1; n < group.length; n++) {
  335.       var obj = group[n];
  336.       if (!DataManager.isIndependent(obj)) continue;
  337.       var notedata = obj.note.split(/[\r\n]+/);
  338.  
  339.       for (var i = 0; i < notedata.length; i++) {
  340.          var line = notedata[i];
  341.          if (line.match(/<(?:AMMO)[ ](?:CHARGES):[ ](\d+)>/i)) {
  342.             var value = parseInt(RegExp.$1);
  343.             if (!isNaN(value) && (value > 0)) {
  344.                obj.ammoCharges = value;
  345.                obj.ammoCurrentCharges = value;
  346.             }
  347.          }
  348.          if (line.match(/<(?:AMMO)[ ](?:CHARGES)[ ](?:EMPTY):[ ](\d+)>/i)) {
  349.             var value = parseInt(RegExp.$1);
  350.             if (!isNaN(value) && (value > 0)) {
  351.                obj.ammoMorphIfEmpty = value;
  352.             }
  353.          }
  354.       }
  355.    }
  356. }
  357.  
  358. DataManager.processUncoSwitchNotetags = function(group) {
  359.    for (var n = 1; n < group.length; n++) {
  360.       var obj = group[n];
  361.       var notedata = obj.note.split(/[\r\n]+/);
  362.      
  363.       obj.ammoGameSwitch = [];
  364.  
  365.       for (var i = 0; i < notedata.length; i++) {
  366.          var line = notedata[i];
  367.          if (line.match(/<(?:GAME)[ ](?:SWITCH):[ ](\d+)>/i)) {
  368.             var value = parseInt(RegExp.$1);
  369.             if (!isNaN(value)) {
  370.                obj.ammoGameSwitch[value] = true;
  371.             }
  372.          }
  373.       }
  374.    }
  375. }
  376.  
  377. DataManager.processUncoGoldCostNotetags = function(group) {
  378.    for (var n = 1; n < group.length; n++) {
  379.       var obj = group[n];
  380.       var notedata = obj.note.split(/[\r\n]+/);
  381.  
  382.       for (var i = 0; i < notedata.length; i++) {
  383.          var line = notedata[i];
  384.          if (line.match(/<(?:GOLD)[ ](?:COST):[ ](\d+)>/i)) {
  385.             var value = parseInt(RegExp.$1);
  386.             if (!isNaN(value)) {
  387.                obj.goldCost = value;
  388.             }
  389.          }
  390.       }
  391.    }
  392. }
  393.  
  394. DataManager.processUncoItemAmmoNotetags = function(group) {
  395.    for (var n = 1; n < group.length; n++) {
  396.       var obj = group[n];
  397.       var notedata = obj.note.split(/[\r\n]+/);
  398.  
  399.       obj.itemAmmoCost = [];
  400.  
  401.       for (var i = 0; i < notedata.length; i++) {
  402.          var line = notedata[i];
  403.          if (line.match(/<(?:AMMO)[ ](\d+)[ ](?:ITEM):[ ](\d+)>/i)) {
  404.             var index = parseInt(RegExp.$1);
  405.             var value = parseInt(RegExp.$2);
  406.             if ( (!isNaN(index)) && (!isNaN(value)) ) {
  407.                obj.itemAmmoCost[index] = value;
  408.                if (DataManager.isWeapon(obj)) {
  409.                   if (typeof $dataItems[index].isItemAmmoForWeapon === 'undefined') $dataItems[index].isItemAmmoForWeapon = [];
  410.                   $dataItems[index].isItemAmmoForWeapon[obj.id] = value;
  411.                } else {
  412.                   if (typeof $dataItems[index].isItemAmmoForSkill === 'undefined') $dataItems[index].isItemAmmoForSkill = [];
  413.                   $dataItems[index].isItemAmmoForSkill[obj.id] = value;
  414.                }
  415.             }
  416.          }
  417.       }
  418.    }
  419. }
  420.  
  421. DataManager.processUncoEquipAmmoNotetags = function(group) {
  422.    for (var n = 1; n < group.length; n++) {
  423.       var obj = group[n];
  424.       var notedata = obj.note.split(/[\r\n]+/);
  425.  
  426.       obj.equipAmmoCost = [];
  427.       obj.equipChargeAmmoCost = [];
  428.       obj.weaponAmmoCost = [];
  429.       obj.weaponChargeAmmoCost = [];
  430.  
  431.       for (var i = 0; i < notedata.length; i++) {
  432.          var line = notedata[i];
  433.          if (line.match(/<(?:AMMO)[ ](\d+)[ ](?:EQUIP):[ ](\d+)>/i)) {
  434.             var index = parseInt(RegExp.$1);
  435.             var value = parseInt(RegExp.$2);
  436.             if ( (!isNaN(index)) && (!isNaN(value)) ) {
  437.                if ($dataArmors[index].ammoCharges) {
  438.                   obj.equipChargeAmmoCost[index] = value;
  439.                } else {
  440.                   obj.equipAmmoCost[index] = value;
  441.                }
  442.                if (DataManager.isWeapon(obj)) {
  443.                   if (typeof $dataArmors[index].isEquipAmmoForWeapon === 'undefined') $dataArmors[index].isEquipAmmoForWeapon = [];
  444.                   $dataArmors[index].isEquipAmmoForWeapon[obj.id] = value;
  445.                } else {
  446.                   if (typeof $dataArmors[index].isEquipAmmoForSkill === 'undefined') $dataArmors[index].isEquipAmmoForSkill = [];
  447.                   $dataArmors[index].isEquipAmmoForSkill[obj.id] = value;
  448.                }
  449.             }
  450.          }
  451.          if (line.match(/<(?:AMMO)[ ](\d+)[ ](?:WEAPON):[ ](\d+)>/i)) {
  452.             var index = parseInt(RegExp.$1);
  453.             var value = parseInt(RegExp.$2);
  454.             if ( (!isNaN(index)) && (!isNaN(value)) ) {
  455.                if ($dataWeapons[index].ammoCharges) {
  456.                   obj.weaponChargeAmmoCost[index] = value;
  457.                } else {
  458.                   obj.weaponAmmoCost[index] = value;
  459.                }
  460.                if (DataManager.isWeapon(obj)) {
  461.                   if (typeof $dataWeapons[index].isWeaponAmmoForWeapon === 'undefined') $dataWeapons[index].isWeaponAmmoForWeapon = [];
  462.                   $dataWeapons[index].isWeaponAmmoForWeapon[obj.id] = value;
  463.                } else {
  464.                   if (typeof $dataWeapons[index].isWeaponAmmoForSkill === 'undefined') $dataWeapons[index].isWeaponAmmoForSkill = [];
  465.                   $dataWeapons[index].isWeaponAmmoForSkill[obj.id] = value;
  466.                }
  467.             }
  468.          }
  469.       }
  470.    }
  471. }
  472.  
  473. DataManager.isItemAmmo = function(item) {
  474.    return this.isItem(item) && (item.isItemAmmoForWeapon || item.isItemAmmoForSkill);
  475. };
  476. DataManager.isEquipAmmo = function(item) {
  477.    return this.isArmor(item) && (item.isEquipAmmoForWeapon || item.isEquipAmmoForSkill);
  478. };
  479. DataManager.isWeaponAmmo = function(item) {
  480.    return this.isWeapon(item) && (item.isWeaponAmmoForWeapon || item.isWeaponAmmoForSkill);
  481. };
  482. DataManager.isAmmo = function(item) {
  483.    return (this.isItemAmmo(item) || this.isEquipAmmo(item) || this.isWeaponAmmo(item));
  484. };
  485.  
  486. DataManager.processUncoAmmoTextNotetags = function(group) {
  487.    for (var n = 1; n < group.length; n++) {
  488.       var obj = group[n];
  489.       var notedata = obj.note.split(/[\r\n]+/);
  490.       for (var i = 0; i < notedata.length; i++) {
  491.          var line = notedata[i];
  492.          if (line.match(/<(?:AMMO)[ ](?:LEFT)[ ](?:TEXT):[ ](.*)>/i)) {
  493.             obj.ammoText = String(RegExp.$1);
  494.          }
  495.          if (line.match(/<(?:NO)[ ](?:AMMO)[ ](?:ICON):[ ](\d+)>/i)) {
  496.             obj.noAmmoIconId = parseInt(RegExp.$1);
  497.          }
  498.          if (line.match(/<(?:SHOW)[ ](?:AMMO)[ ](?:NAME)>/i)) {
  499.             obj.showAmmoName = true;
  500.          }
  501.       }
  502.    }
  503. };
  504.  
  505. DataManager.processUncoAmmoLoadNotetags = function(group) {
  506.    for (var n = 1; n < group.length; n++) {
  507.       var obj = group[n];
  508.       var notedata = obj.note.split(/[\r\n]+/);
  509.       for (var i = 0; i < notedata.length; i++) {
  510.          var line = notedata[i];
  511.          if (line.match(/<(?:AMMO)[ ](\d+)[ ](?:LOAD):[ ](\d+)>/i)) {
  512.             var index = parseInt(RegExp.$1);
  513.             var equid = parseInt(RegExp.$2);
  514.             if ( (!isNaN(index)) && (!isNaN(equid)) ) {
  515.                obj.ammoLoadIndex = index;
  516.                obj.ammoLoadSlot = equid;
  517.             }
  518.          }
  519.          if (line.match(/<(?:AMMO)[ ](\d+)[ ](?:LOAD)>/i)) {
  520.             var index = parseInt(RegExp.$1);
  521.             if (!isNaN(index)) {
  522.                obj.ammoLoadIndex = index;
  523.                obj.ammoLoadSlot = 0;
  524.             }
  525.          }
  526.       }
  527.    }
  528. };
  529.  
  530. DataManager.processUncoAmmoDescNotetags = function(group) {
  531.    for (var n = 1; n < group.length; n++) {
  532.       var obj = group[n];
  533.       var notedata = obj.note.split(/[\r\n]+/);
  534.       for (var i = 0; i < notedata.length; i++) {
  535.          var line = notedata[i];
  536.          if (line.match(/<(?:AMMO)[ ](?:WINDOW)[ ](?:DESC):[ ](.*)>/i)) {
  537.             obj.ammoDesc = String(RegExp.$1);
  538.          }
  539.       }
  540.    }
  541. };
  542.  
  543. Unco.AS.hasAmmoCost = function(obj) {
  544.     if (typeof obj.goldCost == "number") {
  545.         if (obj.goldCost > 0) return true;
  546.     }
  547.     if (typeof obj.equipAmmoCost != "undefined") {
  548.         if (obj.equipAmmoCost.length > 0) return true;
  549.     }
  550.     if (typeof obj.equipChargeAmmoCost != "undefined") {
  551.         if (obj.equipChargeAmmoCost.length > 0) return true;
  552.     }
  553.     if (typeof obj.weaponAmmoCost != "undefined") {
  554.         if (obj.weaponAmmoCost.length > 0) return true;
  555.     }
  556.     if (typeof obj.weaponChargeAmmoCost != "undefined") {
  557.         if (obj.weaponChargeAmmoCost.length > 0) return true;
  558.     }
  559.     if (typeof obj.itemAmmoCost != "undefined") {
  560.         if (obj.itemAmmoCost.length > 0) return true;
  561.     }
  562.     if (typeof obj.ammoGameSwitch != "undefined") {
  563.         if (obj.ammoGameSwitch.length > 0) return true;
  564.     }
  565.     return false;
  566. }
  567.  
  568. //=============================================================================
  569. // Game_Actor
  570. //=============================================================================
  571.  
  572. Game_Actor.prototype.equippableSlotsFor = function(item) {
  573.    var emptySlots = [];
  574.    var equippedSlots = [];
  575.    for (var s in this.equipSlots()) {
  576.       if (this.equipSlots()[s] === item.etypeId) {
  577.          if (this.equips()[s] === null) {
  578.             emptySlots.push(parseInt(s)+1);
  579.          } else {
  580.             equippedSlots.push(parseInt(s)+1);
  581.          }
  582.       }
  583.    }
  584.    return emptySlots.concat(equippedSlots);
  585. }
  586.  
  587. //=============================================================================
  588. // Game_BattlerBase
  589. //=============================================================================
  590.  
  591. Unco.AS.Game_BattlerBase_canEquipArmor = Game_BattlerBase.prototype.canEquipArmor;
  592. Game_BattlerBase.prototype.canEquipArmor = function(item) {
  593.    if (typeof $dataArmors[item.id].isEquipAmmoForWeapon !== 'undefined') {
  594.       var ok = false;
  595.       if (this._equips[0].itemId() > 0) {
  596.          var EquippedWeaponId = ( (typeof $dataWeapons[this._equips[0].itemId()].baseItemId === 'undefined') ? this._equips[0].itemId() : $dataWeapons[this._equips[0].itemId()].baseItemId );
  597.          for (var weaponId in $dataArmors[item.id].isEquipAmmoForWeapon) {
  598.             weaponId = parseInt(weaponId);
  599.             var ammoCost = parseInt( $dataArmors[item.id].isEquipAmmoForWeapon[weaponId] );
  600.             ammoCost = (isNaN(ammoCost)) ? -1 : ammoCost ;
  601.             if ((weaponId === EquippedWeaponId) && (ammoCost > -1)) {
  602.                ok = true;
  603.                break;
  604.             }
  605.          }
  606.       }
  607.       if (ok === false) return false;
  608.    }
  609.    return Unco.AS.Game_BattlerBase_canEquipArmor.call(this,item);
  610. };
  611.  
  612. Unco.AS.Game_BattlerBase_canEquipWeapon = Game_BattlerBase.prototype.canEquipWeapon;
  613. Game_BattlerBase.prototype.canEquipWeapon = function(item) {
  614.    if (typeof $dataWeapons[item.id].isWeaponAmmoForWeapon !== 'undefined') {
  615.       var ok = false;
  616.       var wantedWeaponId = ( (typeof $dataWeapons[item.id].baseItemId === 'undefined') ? item.id : $dataWeapons[item.id].baseItemId );
  617.       var EquippedWeaponId = 0;
  618.       if (this._equips[0].itemId() > 0) {
  619.          EquippedWeaponId = ( (typeof $dataWeapons[this._equips[0].itemId()].baseItemId === 'undefined') ? this._equips[0].itemId() : $dataWeapons[this._equips[0].itemId()].baseItemId );
  620.       }
  621.       for (var weaponId in $dataWeapons[item.id].isWeaponAmmoForWeapon) {
  622.          weaponId = parseInt(weaponId);
  623.          var ammoCost = parseInt( $dataWeapons[item.id].isWeaponAmmoForWeapon[weaponId] );
  624.          ammoCost = (isNaN(ammoCost)) ? -1 : ammoCost ;
  625.          if (this._equips[0].itemId() > 0) {
  626.             if ((weaponId === EquippedWeaponId) && (ammoCost > -1)) {
  627.                ok = true;
  628.                break;
  629.             }
  630.          }
  631.          if (weaponId === wantedWeaponId) {
  632.             ok = true;
  633.             break;
  634.          }
  635.       }
  636.       if (ok === false) return false;
  637.    }
  638.    return Unco.AS.Game_BattlerBase_canEquipWeapon.call(this,item);
  639. };
  640.  
  641. Game_Party.prototype.getItemAmount = function(baseItem) {
  642.    if (!baseItem) return 0;
  643.    var amount = 0;
  644.    if (Imported.YEP_ItemCore) {
  645.       var maxItems = 0;
  646.       if (DataManager.isItem(baseItem)) {
  647.          maxItems = Yanfly.Param.ItemMaxItems;
  648.       }
  649.       if (DataManager.isWeapon(baseItem))  {
  650.          maxItems = Yanfly.Param.ItemMaxWeapons;
  651.       }
  652.       if (DataManager.isArmor(baseItem))  {
  653.          maxItems = Yanfly.Param.ItemMaxArmors;
  654.       }        
  655.       if (maxItems > 0) {
  656.          var nonIndep;
  657.          if (typeof baseItem.nonIndepdent === "boolean") nonIndep = baseItem.nonIndepdent;
  658.          if (typeof baseItem.nonIndependent === "boolean") nonIndep = baseItem.nonIndependent;
  659.          if (nonIndep === false) {
  660.             if (DataManager.isItem(baseItem)) {
  661.                baseItem = ( baseItem.baseItemId ? $dataItems[baseItem.baseItemId] : baseItem );
  662.                var group = this.items();
  663.             }
  664.             if (DataManager.isWeapon(baseItem))  {
  665.                baseItem = ( baseItem.baseItemId ? $dataWeapons[baseItem.baseItemId] : baseItem );
  666.                var group = this.weapons();
  667.             }
  668.             if (DataManager.isArmor(baseItem))  {
  669.                baseItem = ( baseItem.baseItemId ? $dataArmors[baseItem.baseItemId] : baseItem );
  670.                var group = this.armors();
  671.             }        
  672.             var baseItemId = baseItem.id;
  673.             for (var i = 0; i < group.length; ++i) {
  674.                var item = group[i];
  675.                if (!item) continue;
  676.                if (!item.baseItemId) continue;
  677.                if (item.baseItemId !== baseItemId) continue;
  678.                amount += 1;
  679.             }
  680.             return amount;
  681.          }
  682.       }
  683.    }
  684.    if ( DataManager.isItem(baseItem) && $gameParty._items[baseItem.id]) amount = $gameParty._items[baseItem.id];
  685.    if ( DataManager.isArmor(baseItem) && $gameParty._armors[baseItem.id]) amount = $gameParty._armors[baseItem.id];
  686.    if ( DataManager.isWeapon(baseItem) && $gameParty._weapons[baseItem.id]) amount = $gameParty._weapons[baseItem.id];
  687.    return amount;
  688. }
  689.  
  690. Unco.AS.Game_BattlerBase_canPaySkillCost =
  691.    Game_BattlerBase.prototype.canPaySkillCost;
  692. Game_BattlerBase.prototype.canPaySkillCost = function(skill) {
  693.    if (this.isActor()) {
  694.       if (!this.canPaySkillAmmoCost(skill)) return false;
  695.    }
  696.    return Unco.AS.Game_BattlerBase_canPaySkillCost.call(this, skill);
  697. };
  698.  
  699. Game_BattlerBase.prototype.getAmmoCurrentCharges = function(item) {
  700.    if (!item) return 0;
  701.    if (Imported.YEP_ItemCore) {
  702.       if (!DataManager.isIndependent(item)) return 0;
  703.       for (var i in this.equips()) {
  704.          if ((typeof this.equips()[i] !== 'undefined') && (this.equips()[i] !== null)) {
  705.             if (typeof this.equips()[i].baseItemId !== 'undefined') {
  706.                if ((this.equips()[i].baseItemId === item.id) && (this.equips()[i]._dataClass === item._dataClass)) {
  707.                   return this.equips()[i].ammoCurrentCharges;
  708.                }
  709.             }        
  710.          }
  711.       }
  712.    }
  713.    return 0;
  714. };
  715.  
  716. Game_BattlerBase.prototype.addAmmoCurrentCharges = function(item,amount) {
  717.    if (!item) return;
  718.    if (Imported.YEP_ItemCore) {
  719.       if (!DataManager.isIndependent(item)) return 0;
  720.       for (var i in this.equips()) {
  721.          if ((typeof this.equips()[i] !== 'undefined') && (this.equips()[i] !== null)) {
  722.             if (typeof this.equips()[i].baseItemId !== 'undefined') {
  723.                if ((this.equips()[i].baseItemId === item.id) && (this.equips()[i]._dataClass === item._dataClass)) {
  724.                   this.equips()[i].ammoCurrentCharges = parseInt(this.equips()[i].ammoCurrentCharges);
  725.                   this.equips()[i].ammoCharges = parseInt(this.equips()[i].ammoCharges);
  726.                   this.equips()[i].ammoCurrentCharges += amount;
  727.                   if (this.equips()[i].ammoCurrentCharges > this.equips()[i].ammoCharges) {
  728.                      this.equips()[i].ammoCurrentCharges = this.equips()[i].ammoCharges;
  729.                   }
  730.                   if (this.equips()[i].ammoCurrentCharges < 0) {
  731.                      this.equips()[i].ammoCurrentCharges = 0;
  732.                   }
  733.                   break;
  734.                }
  735.             }        
  736.          }
  737.       }
  738.    }
  739. };
  740.  
  741. Game_BattlerBase.prototype.fillAmmoCharges = function(item) {
  742.    if (!item) return;
  743.    if (Imported.YEP_ItemCore) {
  744.       if (!DataManager.isIndependent(item)) return 0;
  745.       for (var i in this.equips()) {
  746.          if ((typeof this.equips()[i] !== 'undefined') && (this.equips()[i] !== null)) {
  747.             if (typeof this.equips()[i].baseItemId !== 'undefined') {
  748.                if (this.equips()[i].baseItemId === item.id) {
  749.                   this.equips()[i].ammoCurrentCharges = this.equips()[i].ammoCharges;
  750.                }
  751.             }        
  752.          }
  753.       }
  754.    }
  755. };
  756.  
  757. Game_BattlerBase.prototype.canPaySkillAmmoCost = function(skill) {
  758.    if (skill.id === this.attackSkillId()) {
  759.       if (typeof this._equips !== 'undefined') {
  760.          if (this._equips[0]._itemId > 0) {
  761.             if ( !Unco.AS.hasAmmoCost(skill) ) {
  762.                skill = $dataWeapons[ ( (typeof $dataWeapons[this._equips[0]._itemId].baseItemId === 'undefined') ? this._equips[0]._itemId : $dataWeapons[this._equips[0]._itemId].baseItemId ) ];
  763.             }
  764.          }
  765.       }
  766.    }
  767.    for (var switchId in skill.ammoGameSwitch) {
  768.       switchId = parseInt(switchId);
  769.       if (!isNaN(switchId) && (switchId > 0)) {
  770.          if ($gameSwitches.value(switchId) === false) {
  771.             return false;
  772.          }
  773.       }
  774.    }
  775.    if (!this.canPaySkillReloadAmmoCost(skill)) return false;
  776.    if (!this.canPaySkillItemAmmoCost(skill)) return false;
  777.    if (!this.canPaySkillEquipAmmoCost(skill)) return false;
  778.    if (!this.canPaySkillEquipChargeAmmoCost(skill)) return false;
  779.    return true;
  780. };
  781.  
  782. Game_BattlerBase.prototype.canPaySkillReloadAmmoCost = function(skill) {
  783.    if ((typeof skill.ammoLoadIndex === 'number') && (typeof skill.ammoLoadSlot === 'number')) {
  784.       if (this.hasArmor($dataArmors[skill.ammoLoadIndex]) || ($gameParty.getItemAmount($dataArmors[skill.ammoLoadIndex]) < 1)) {
  785.          return false;
  786.       }
  787.    }
  788.    return true;
  789. };
  790.  
  791. Game_BattlerBase.prototype.canPaySkillItemAmmoCost = function(skill) {
  792.    if (typeof skill.goldCost === 'number') {
  793.       if (skill.goldCost > $gameParty.gold()) {
  794.          return false;
  795.       }
  796.    }
  797.    for (var ammoId in skill.itemAmmoCost) {
  798.       ammoId = parseInt(ammoId);
  799.       if (!isNaN(ammoId) && (ammoId > 0)) {
  800.          var nbOwned = $gameParty.getItemAmount($dataItems[ammoId]);
  801.          if (skill.itemAmmoCost[ammoId] > nbOwned) {
  802.             return false;
  803.          }
  804.       }
  805.    }
  806.    return true;
  807. };
  808.  
  809. Game_BattlerBase.prototype.canPaySkillEquipAmmoCost = function(skill) {
  810.    if (!this.canPaySkillArmorAmmoCost(skill)) return false;
  811.    if (!this.canPaySkillWeaponAmmoCost(skill)) return false;
  812.    return true;
  813. };
  814.  
  815. Game_BattlerBase.prototype.canPaySkillArmorAmmoCost = function(skill) {
  816.    var retVal = true;
  817.    for (var ammoId in skill.equipAmmoCost) {
  818.       ammoId = parseInt(ammoId);
  819.       if (!isNaN(ammoId) && (ammoId > 0)) {
  820.          if (this.hasArmor($dataArmors[ammoId])) {
  821.             skill.equipAmmoCost[ammoId] = parseInt(skill.equipAmmoCost[ammoId]);
  822.             if (!isNaN(skill.equipAmmoCost[ammoId])) {
  823.                var nbOwned = 1+$gameParty.getItemAmount($dataArmors[ammoId]);
  824.                if (skill.equipAmmoCost[ammoId] <= nbOwned) {
  825.                   return true;
  826.                } else retVal = false;
  827.             } else retVal = false;
  828.          } else retVal = false;
  829.       }
  830.    }
  831.    return retVal;
  832. };
  833.  
  834. Game_BattlerBase.prototype.canPaySkillWeaponAmmoCost = function(skill) {
  835.    var retVal = true;
  836.    for (var ammoId in skill.weaponAmmoCost) {
  837.       ammoId = parseInt(ammoId);
  838.       if (!isNaN(ammoId) && (ammoId > 0)) {
  839.          if (this.hasWeapon($dataWeapons[ammoId])) {
  840.             skill.weaponAmmoCost[ammoId] = parseInt(skill.weaponAmmoCost[ammoId]);
  841.             if (!isNaN(skill.weaponAmmoCost[ammoId])) {
  842.                var nbOwned = 1+$gameParty.getItemAmount($dataWeapons[ammoId]);
  843.                if (skill.weaponAmmoCost[ammoId] <= nbOwned) {
  844.                   return true;
  845.                } else retVal = false;
  846.             } else retVal = false;
  847.          } else retVal = false;
  848.       }
  849.    }
  850.    return retVal;
  851. };
  852.  
  853. Game_BattlerBase.prototype.canPaySkillEquipChargeAmmoCost = function(skill) {
  854.    if (!this.canPaySkillArmorChargeAmmoCost(skill)) return false;
  855.    if (!this.canPaySkillWeaponChargeAmmoCost(skill)) return false;
  856.    return true;
  857. };
  858.  
  859. Game_BattlerBase.prototype.canPaySkillArmorChargeAmmoCost = function(skill) {
  860.    var retVal = true;
  861.    for (var ammoId in skill.equipChargeAmmoCost) {
  862.       ammoId = parseInt(ammoId);
  863.       if (!isNaN(ammoId) && (ammoId > 0)) {
  864.          if (this.hasArmor($dataArmors[ammoId])) {
  865.             var chargeCost = parseInt(skill.equipChargeAmmoCost[ammoId]);
  866.             if (!isNaN(chargeCost)) {
  867.                var nbOwned = this.getAmmoCurrentCharges($dataArmors[ammoId]);
  868.                if (chargeCost <= nbOwned) {
  869.                   return true;
  870.                } else retVal = false;    
  871.             } else retVal = false;
  872.          } else retVal = false;
  873.       }
  874.    }
  875.    return retVal;
  876. };
  877.  
  878. Game_BattlerBase.prototype.canPaySkillWeaponChargeAmmoCost = function(skill) {
  879.    var retVal = true;
  880.    for (var ammoId in skill.weaponChargeAmmoCost) {
  881.       ammoId = parseInt(ammoId);
  882.       if (!isNaN(ammoId) && (ammoId > 0)) {
  883.          if (this.hasWeapon($dataWeapons[ammoId])) {
  884.             var chargeCost = parseInt(skill.weaponChargeAmmoCost[ammoId]);
  885.             if (!isNaN(chargeCost)) {
  886.                var nbOwned = this.getAmmoCurrentCharges($dataWeapons[ammoId]);
  887.                if (chargeCost <= nbOwned) {
  888.                   return true;
  889.                } else retVal = false;    
  890.             } else retVal = false;
  891.          } else retVal = false;
  892.       }
  893.    }
  894.    return retVal;
  895. };
  896.  
  897. Unco.AS.Game_BattlerBase_paySkillCost = Game_BattlerBase.prototype.paySkillCost;
  898. Game_BattlerBase.prototype.paySkillCost = function(skill) {
  899.     Unco.AS.Game_BattlerBase_paySkillCost.call(this, skill);
  900.     if (this.constructor.name === 'Game_Actor') this.paySkillAmmoCost(skill);
  901. };
  902.  
  903. Game_BattlerBase.prototype.paySkillAmmoCost = function(skill) {
  904.    if (skill.id === this.attackSkillId()) {
  905.       if (typeof this._equips !== 'undefined') {
  906.          if (this._equips[0]._itemId > 0) {
  907.             if ( !Unco.AS.hasAmmoCost(skill) ) {
  908.                 skill = $dataWeapons[ ( (typeof $dataWeapons[this._equips[0]._itemId].baseItemId === 'undefined') ? this._equips[0]._itemId : $dataWeapons[this._equips[0]._itemId].baseItemId ) ];
  909.             }            
  910.          }
  911.       }
  912.    }
  913.    this.reloadAmmo(skill);
  914.    this.paySkillItemAmmoCost(skill);
  915.    this.paySkillEquipAmmoCost(skill);
  916.    this.paySkillEquipChargeAmmoCost(skill);
  917. };
  918.  
  919. Game_BattlerBase.prototype.reloadAmmo = function(skill) {
  920.    if ((typeof skill.ammoLoadIndex === 'number') && (typeof skill.ammoLoadSlot === 'number')) {
  921.       var loadSlot = skill.ammoLoadSlot;
  922.       var legitLoadSlots = this.equippableSlotsFor($dataArmors[skill.ammoLoadIndex]);
  923.       if (legitLoadSlots.contains(loadSlot) === false) {
  924.          loadSlot = legitLoadSlots[0];
  925.       }
  926.       this.changeEquipById(loadSlot,skill.ammoLoadIndex);
  927.    }
  928. };
  929.  
  930. Game_BattlerBase.prototype.paySkillItemAmmoCost = function(skill) {
  931.    if (typeof skill.goldCost === 'number') {
  932.       $gameParty.loseGold(skill.goldCost);
  933.    }
  934.    for (var ammoId in skill.itemAmmoCost) {
  935.       ammoId = parseInt(ammoId);
  936.       if (!isNaN(ammoId) && (ammoId > 0)) {
  937.          $gameParty.gainItem($dataItems[ammoId],-skill.itemAmmoCost[ammoId]);
  938.       }
  939.    }
  940. };
  941.  
  942. Game_BattlerBase.prototype.paySkillEquipAmmoCost = function(skill) {
  943.    for (var ammoId in skill.equipAmmoCost) {
  944.       ammoId = parseInt(ammoId);
  945.       if (!isNaN(ammoId) && (ammoId > 0)) {
  946.          skill.equipAmmoCost[ammoId] = parseInt(skill.equipAmmoCost[ammoId]);
  947.          if (this.hasArmor($dataArmors[ammoId]) && !isNaN(skill.equipAmmoCost[ammoId]) && (skill.equipAmmoCost[ammoId] > 0)) {
  948.             this._markForEquipDiscard = ammoId;
  949.             if ($gameParty.getItemAmount($dataArmors[ammoId]) > 0) {
  950.                $gameParty.gainItem($dataArmors[ammoId],-Math.max(skill.equipAmmoCost[ammoId]-1,0));
  951.             }
  952.          }
  953.       }
  954.    }
  955.    for (var ammoId in skill.weaponAmmoCost) {
  956.       ammoId = parseInt(ammoId);
  957.       if (!isNaN(ammoId) && (ammoId > 0)) {
  958.          skill.weaponAmmoCost[ammoId] = parseInt(skill.weaponAmmoCost[ammoId]);
  959.          if (this.hasWeapon($dataWeapons[ammoId]) && !isNaN(skill.weaponAmmoCost[ammoId]) && (skill.weaponAmmoCost[ammoId] > 0)) {
  960.             this._markForWeaponDiscard = ammoId;
  961.             if ($gameParty.getItemAmount($dataWeapons[ammoId]) > 0) {
  962.                $gameParty.gainItem($dataWeapons[ammoId],-Math.max(skill.weaponAmmoCost[ammoId]-1,0));
  963.             }
  964.          }
  965.       }
  966.    }
  967. };
  968.  
  969. Game_BattlerBase.prototype.paySkillEquipChargeAmmoCost = function(skill) {
  970.    for (var ammoId in skill.equipChargeAmmoCost) {
  971.       ammoId = parseInt(ammoId);
  972.       if (!isNaN(ammoId) && (ammoId > 0)) {
  973.          var chargeCost = parseInt(skill.equipChargeAmmoCost[ammoId]);
  974.          if (this.hasArmor($dataArmors[ammoId]) && !isNaN(chargeCost) && (chargeCost > 0)) {
  975.             this.addAmmoCurrentCharges($dataArmors[ammoId], -chargeCost);
  976.             if (this.getAmmoCurrentCharges($dataArmors[ammoId]) <= 0) {
  977.                this._markForEquipDiscard = ammoId;
  978.             }
  979.          }
  980.       }
  981.    }
  982.    for (var ammoId in skill.weaponChargeAmmoCost) {
  983.       ammoId = parseInt(ammoId);
  984.       if (!isNaN(ammoId) && (ammoId > 0)) {
  985.          var chargeCost = parseInt(skill.weaponChargeAmmoCost[ammoId]);
  986.          if (this.hasWeapon($dataWeapons[ammoId]) && !isNaN(chargeCost ) && (chargeCost  > 0)) {
  987.             this.addAmmoCurrentCharges($dataWeapons[ammoId], -chargeCost);
  988.             if (this.getAmmoCurrentCharges($dataWeapons[ammoId]) <= 0) {
  989.                this._markForWeaponDiscard = ammoId;
  990.             }
  991.          }
  992.       }
  993.    }
  994. };
  995.  
  996.  
  997. //=============================================================================
  998. // BattleManager
  999. //=============================================================================
  1000. //
  1001. // Management of post-action skill cost application:
  1002. // - un-equip current ammo,
  1003. // - re-equip one if available in inventory.
  1004. //
  1005.  
  1006. Unco.AS.BattleManager_invokeNormalAction = BattleManager.invokeNormalAction;
  1007. BattleManager.invokeNormalAction = function(subject, target) {
  1008.    Unco.AS.BattleManager_invokeNormalAction.call(this,subject,target);
  1009.    if (typeof this._subject._markForEquipDiscard !== 'undefined') {
  1010.       for (var i in this._subject.equips()) {
  1011.          if ((typeof this._subject.equips()[i] !== 'undefined') && (this._subject.equips()[i] !== null)) {
  1012.             if (typeof this._subject.equips()[i].baseItemId !== 'undefined') {
  1013.                if (this._subject.equips()[i].baseItemId === this._subject._markForEquipDiscard) {
  1014.                   this._subject._markForEquipDiscard = this._subject.equips()[i].id;
  1015.                }
  1016.             }        
  1017.          }
  1018.       }
  1019.       if ( (typeof $dataArmors[this._subject._markForEquipDiscard].ammoCurrentCharges === 'number')
  1020.         && ($dataArmors[this._subject._markForEquipDiscard].ammoCurrentCharges === 0)
  1021.         && (typeof $dataArmors[this._subject._markForEquipDiscard].ammoMorphIfEmpty === 'number')  )
  1022.       {
  1023.          $gameParty.gainItem($dataItems[ $dataArmors[this._subject._markForEquipDiscard].ammoMorphIfEmpty ] , 1);
  1024.       }
  1025.       this._subject.discardEquip($dataArmors[this._subject._markForEquipDiscard]);  
  1026.       if (($gameParty.getItemAmount($dataArmors[ this._subject._markForEquipDiscard ]) > 0) && (!$dataArmors[ this._subject._markForEquipDiscard ].ammoCharges)) {
  1027.          var loadSlot = this._subject.equippableSlotsFor($dataArmors[ this._subject._markForEquipDiscard ])[0];
  1028.          var ammoId = ($dataArmors[ this._subject._markForEquipDiscard ].baseItemId) ? ($dataArmors[ this._subject._markForEquipDiscard ].baseItemId) : this._subject._markForEquipDiscard;
  1029.          this._subject.changeEquipById(loadSlot,ammoId);
  1030.       }    
  1031.       delete this._subject._markForEquipDiscard;
  1032.    }
  1033.    if (typeof this._subject._markForWeaponDiscard !== 'undefined') {
  1034.       for (var i in this._subject.equips()) {
  1035.          if ((typeof this._subject.equips()[i] !== 'undefined') && (this._subject.equips()[i] !== null)) {
  1036.             if (typeof this._subject.equips()[i].baseItemId !== 'undefined') {
  1037.                if (this._subject.equips()[i].baseItemId === this._subject._markForWeaponDiscard) {
  1038.                   this._subject._markForWeaponDiscard = this._subject.equips()[i].id;
  1039.                }
  1040.             }        
  1041.          }
  1042.       }
  1043.       if ( (typeof $dataWeapons[this._subject._markForWeaponDiscard].ammoCurrentCharges === 'number')
  1044.         && ($dataWeapons[this._subject._markForWeaponDiscard].ammoCurrentCharges === 0)
  1045.         && (typeof $dataWeapons[this._subject._markForWeaponDiscard].ammoMorphIfEmpty === 'number')  )
  1046.       {
  1047.          $gameParty.gainItem($dataItems[ $dataWeapons[this._subject._markForWeaponDiscard].ammoMorphIfEmpty ] , 1);
  1048.       }
  1049.       this._subject.discardEquip($dataWeapons[this._subject._markForWeaponDiscard]);  
  1050.       if (($gameParty.getItemAmount($dataWeapons[ this._subject._markForWeaponDiscard ]) > 0) && (!$dataWeapons[ this._subject._markForWeaponDiscard ].ammoCharges)) {
  1051.          var loadSlot = this._subject.equippableSlotsFor($dataWeapons[ this._subject._markForWeaponDiscard ])[0];
  1052.          var ammoId = ($dataWeapons[ this._subject._markForWeaponDiscard ].baseItemId) ? ($dataWeapons[ this._subject._markForWeaponDiscard ].baseItemId) : this._subject._markForWeaponDiscard;
  1053.          this._subject.changeEquipById(loadSlot,ammoId);
  1054.       }        
  1055.       delete this._subject._markForWeaponDiscard;
  1056.    }
  1057. };
  1058.  
  1059. //=============================================================================
  1060. // Window_SkillList
  1061. //=============================================================================
  1062.  
  1063. if ((typeof Imported.YEP_SkillCore === 'undefined') || (Imported.YEP_SkillCore !== true)) {  
  1064.    Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) {
  1065.       var dw = width;
  1066.       if (this._actor.skillTpCost(skill) > 0) {
  1067.          this.changeTextColor(this.tpCostColor());
  1068.          var text = this._actor.skillTpCost(skill);
  1069.          this.drawText(text, x, y, dw, 'right');
  1070.          dw -= this.textWidth(text);
  1071.       }
  1072.       if (dw !== width) {
  1073.          var text = ' ';
  1074.          this.drawText(text, x, y, dw, 'right');
  1075.          dw -= this.textWidth(text);
  1076.       }
  1077.       if (this._actor.skillMpCost(skill) > 0) {
  1078.          this.changeTextColor(this.mpCostColor());
  1079.          var text = this._actor.skillMpCost(skill)
  1080.          this.drawText(text, x, y, dw, 'right');
  1081.          dw -= this.textWidth(text);
  1082.       }
  1083.       return dw;
  1084.    }  
  1085. }
  1086.  
  1087.  
  1088. Unco.AS.Window_SkillList_drawSkillCost = Window_SkillList.prototype.drawSkillCost;  
  1089.    
  1090. Window_SkillList.prototype.drawSkillCost = function(skill, wx, wy, width) {
  1091.    var dw = width;
  1092.    dw = this.drawAllAmmoCosts(skill, wx, wy, dw);
  1093.    return Unco.AS.Window_SkillList_drawSkillCost.call(this,skill, wx, wy, dw);
  1094. };
  1095.    
  1096. Window_SkillList.prototype.drawAmmoCost = function(cost, icon, itemAmountToDisplay, wx, wy, dw) {
  1097.    this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1098.    var text = '';
  1099.    if (Unco.Param.compactCostDisplay === 'false') text = text + 'x';
  1100.    text = text + String(cost);
  1101.    if (Unco.Param.compactCostDisplay === 'false') text = text + ( (itemAmountToDisplay === "") ? "" : (  "/" + itemAmountToDisplay  )  );
  1102.    this.contents.fontSize = Unco.Param.ammoFontSize;
  1103.    if (Unco.Param.compactCostDisplay === 'false') this.drawText(text, wx, wy, dw, 'right');
  1104.    if (Unco.Param.compactCostDisplay === 'false') dw -= this.textWidth(text);
  1105.    if (icon > 0) {
  1106.       var iw = wx + dw - Window_Base._iconWidth;
  1107.       this.drawIcon(icon, iw, wy + 2);
  1108.       if (Unco.Param.compactCostDisplay === 'true') {
  1109.          this.drawText(text, iw, wy, Window_Base._iconWidth, 'center');
  1110.       }
  1111.       dw -= Window_Base._iconWidth + 2;
  1112.    }
  1113.    this.resetFontSettings();
  1114.    return dw;
  1115. }
  1116.  
  1117. Window_SkillList.prototype.drawAllAmmoCosts = function(skill, wx, wy, dw) {
  1118.    //---------------------------------------------------//
  1119.    // - Gold Cost
  1120.    if (typeof skill.goldCost === 'number') {
  1121.       dw = this.drawAmmoCost(skill.goldCost, Unco.Param.goldAmmoIconId, "", wx, wy, dw);
  1122.    }
  1123.    //---------------------------------------------------//
  1124.    // - Item Cost
  1125.    for (var ammoId in skill.itemAmmoCost) {
  1126.       ammoId = parseInt(ammoId);
  1127.       if (!isNaN(ammoId) && (ammoId > 0)) {
  1128.          var ammoCost = skill.itemAmmoCost[ammoId];
  1129.          var icon = $dataItems[ammoId].iconIndex;
  1130.          var amountText = ( (Unco.Param.showAmmoLeft === 'false') ? "" : (  "/" + $gameParty.getItemAmount($dataItems[ammoId])  )  );
  1131.          dw = this.drawAmmoCost(ammoCost, icon, amountText, wx, wy, dw);
  1132.       }
  1133.    }
  1134.    //---------------------------------------------------//
  1135.    // - Armor Cost
  1136.    var zeroArmorAmmo = false;
  1137.    for (var ammoId in skill.equipAmmoCost) {
  1138.       var ammoId = parseInt(ammoId);
  1139.       if (!isNaN(ammoId) && (ammoId > 0)) {
  1140.          if (this._actor.hasArmor($dataArmors[ammoId])) {
  1141.             var ammoCost = skill.equipAmmoCost[ammoId];
  1142.             var icon = $dataArmors[ammoId].iconIndex;
  1143.             var amountText = ( (Unco.Param.showAmmoLeft === 'false') ? "" : (  "/" + ( 1 + $gameParty.getItemAmount($dataArmors[ammoId]) )  )  );
  1144.             dw = this.drawAmmoCost(ammoCost, icon, amountText, wx, wy, dw);
  1145.             zeroArmorAmmo = false;
  1146.             break;
  1147.          } else {
  1148.             zeroArmorAmmo = true;
  1149.             if (typeof smallestCost !== 'Number') {
  1150.                var smallestCost = skill.equipAmmoCost[ammoId];
  1151.             } else {
  1152.                if (skill.equipAmmoCost[ammoId] < smallestCost) smallestCost = skill.equipAmmoCost[ammoId];
  1153.             }
  1154.          }
  1155.       }
  1156.    }
  1157.    if (zeroArmorAmmo === true) {
  1158.       var ammoCost = smallestCost;
  1159.       var icon = ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId );
  1160.       dw = this.drawAmmoCost(ammoCost, icon, "", wx, wy, dw);
  1161.    }
  1162.    //---------------------------------------------------//
  1163.    // - Weapon Cost
  1164.    var zeroWeaponAmmo = false;
  1165.    for (var ammoId in skill.weaponAmmoCost) {
  1166.       var ammoId = parseInt(ammoId);
  1167.       if (!isNaN(ammoId) && (ammoId > 0)) {
  1168.          if (this._actor.hasWeapon($dataWeapons[ammoId])) {
  1169.             var ammoCost = skill.weaponAmmoCost[ammoId];
  1170.             var icon = $dataWeapons[ammoId].iconIndex;
  1171.             var amountText = ( (Unco.Param.showAmmoLeft === 'false') ? "" : (  "/" + ( 1 + $gameParty.getItemAmount($dataWeapons[ammoId]) )  )  );
  1172.             dw = this.drawAmmoCost(ammoCost, icon, amountText, wx, wy, dw);
  1173.             zeroWeaponAmmo = false;
  1174.             break;
  1175.          } else {
  1176.             zeroWeaponAmmo = true;
  1177.             if (typeof smallestCost !== 'Number') {
  1178.                var smallestCost = skill.weaponAmmoCost[ammoId];
  1179.             } else {
  1180.                if (skill.weaponAmmoCost[ammoId] < smallestCost) smallestCost = skill.weaponAmmoCost[ammoId];
  1181.             }
  1182.          }
  1183.       }
  1184.    }
  1185.    if (zeroWeaponAmmo === true) {
  1186.       var ammoCost = smallestCost;
  1187.       var icon = ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId );
  1188.       dw = this.drawAmmoCost(ammoCost, icon, "", wx, wy, dw);
  1189.    }
  1190.    //---------------------------------------------------//
  1191.    // - Charge Armor Cost
  1192.    var zeroChargeArmorAmmo = false;
  1193.    for (var ammoId in skill.equipChargeAmmoCost) {
  1194.       var ammoId = parseInt(ammoId);
  1195.       if (!isNaN(ammoId) && (ammoId > 0)) {
  1196.          if (this._actor.hasArmor($dataArmors[ammoId])) {
  1197.             var ammoCost = skill.equipChargeAmmoCost[ammoId];
  1198.             var icon = $dataArmors[ammoId].iconIndex;
  1199.             var amountText = ( (Unco.Param.showAmmoLeft === 'false') ? "" : (  "/" + this._actor.getAmmoCurrentCharges( $dataArmors[ammoId] )  )  );
  1200.             dw = this.drawAmmoCost(ammoCost, icon, amountText, wx, wy, dw);
  1201.             zeroChargeArmorAmmo = false;
  1202.             break;
  1203.          } else {
  1204.             zeroChargeArmorAmmo = true;
  1205.             if (typeof smallestCost !== 'Number') {
  1206.                var smallestCost = skill.equipChargeAmmoCost[ammoId];
  1207.             } else {
  1208.                if (skill.equipChargeAmmoCost[ammoId] < smallestCost) smallestCost = skill.equipChargeAmmoCost[ammoId];
  1209.             }
  1210.          }
  1211.       }
  1212.    }
  1213.    if (zeroChargeArmorAmmo === true) {
  1214.       var ammoCost = smallestCost;
  1215.       var icon = ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId );
  1216.       dw = this.drawAmmoCost(ammoCost, icon, "", wx, wy, dw);
  1217.    }
  1218.    //---------------------------------------------------//
  1219.    // - Charge Weapon Cost
  1220.    var zeroChargeWeaponAmmo = false;
  1221.    for (var ammoId in skill.weaponChargeAmmoCost) {
  1222.       var ammoId = parseInt(ammoId);
  1223.       if (!isNaN(ammoId) && (ammoId > 0)) {
  1224.          if (this._actor.hasWeapon($dataWeapons[ammoId])) {
  1225.             var ammoCost = skill.weaponChargeAmmoCost[ammoId];
  1226.             var icon = $dataWeapons[ammoId].iconIndex;
  1227.             var amountText = ( (Unco.Param.showAmmoLeft === 'false') ? "" : (  "/" + this._actor.getAmmoCurrentCharges( $dataWeapons[ammoId] )  )  );
  1228.             dw = this.drawAmmoCost(ammoCost, icon, amountText, wx, wy, dw);
  1229.             zeroChargeWeaponAmmo = false;
  1230.             break;
  1231.          } else {
  1232.             zeroChargeWeaponAmmo = true;
  1233.             if (typeof smallestCost !== 'Number') {
  1234.                var smallestCost = skill.weaponChargeAmmoCost[ammoId];
  1235.             } else {
  1236.                if (skill.weaponChargeAmmoCost[ammoId] < smallestCost) smallestCost = skill.weaponChargeAmmoCost[ammoId];
  1237.             }
  1238.          }
  1239.       }
  1240.    }
  1241.    if (zeroChargeWeaponAmmo === true) {
  1242.       var ammoCost = smallestCost;
  1243.       var icon = ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId );
  1244.       dw = this.drawAmmoCost(ammoCost, icon, "", wx, wy, dw);
  1245.    }
  1246.    return dw;
  1247. };
  1248.  
  1249.  
  1250. //=============================================================================
  1251. // Window_Help
  1252. //=============================================================================
  1253.  
  1254. Window_Help.prototype.getAmmoAmountText = function(item) {
  1255.    var text = '';
  1256.    if (typeof item !== 'undefined') {
  1257.       var introText = ( (typeof item.ammoText !== 'undefined') ? item.ammoText : Unco.Param.descAmmoLeftText);
  1258.       if ((DataManager.isSkill(item)) && (Unco.Param.showAmmoLeftInDesc === 'true') && introText !== "") {
  1259.          var skill = item;
  1260.          var withAmmo = false;
  1261.          //---------------------------------------------------//
  1262.          // - Gold Cost
  1263.          if (typeof skill.goldCost === 'number') {
  1264.             text = text + '\\i[' + String(Unco.Param.goldAmmoIconId) + ']';
  1265.             text = text + 'x' + $gameParty.gold();
  1266.             withAmmo = true;
  1267.          }
  1268.          //---------------------------------------------------//
  1269.          // - Item Cost
  1270.          for (var ammoId in skill.itemAmmoCost) {
  1271.             var cost = skill.itemAmmoCost[ammoId];
  1272.             ammoId = parseInt(ammoId);
  1273.             if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(cost)) {
  1274.                var cost = parseInt(cost);
  1275.                var itemOwned = ($gameParty.getItemAmount($dataItems[ammoId]) > 0);
  1276.                text = text + '\\i[' + String($dataItems[ammoId].iconIndex) + ']';
  1277.                text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataItems[ammoId].name + ' ' );
  1278.                text = text + ( ((cost <= 0) && itemOwned) ? '' : ( 'x' + String( $gameParty.getItemAmount($dataItems[ammoId]) ) )  );
  1279.                withAmmo = true;
  1280.             }
  1281.          }
  1282.          //---------------------------------------------------//
  1283.          // - Armor Cost
  1284.          var zeroEquipAmmo = false;
  1285.          for (var ammoId in skill.equipAmmoCost) {
  1286.             var cost = skill.equipAmmoCost[ammoId];
  1287.             var ammoId = parseInt(ammoId);
  1288.             if (!isNaN(ammoId) && (ammoId > 0) && (typeof this._actor !== 'undefined')) {
  1289.                cost = parseInt(cost);
  1290.                withAmmo = true;
  1291.                if (this._actor.hasArmor($dataArmors[ammoId])) {
  1292.                   text = text + '\\i[' + String($dataArmors[ammoId].iconIndex) + ']';
  1293.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataArmors[ammoId].name + ' ' );
  1294.                   text = text + ( (cost <= 0) ? '' : 'x' + String( 1 + $gameParty.getItemAmount($dataArmors[ammoId]) ) );
  1295.                   text = text + ( (typeof $dataArmors[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataArmors[ammoId].ammoDesc + ')' );
  1296.                   zeroEquipAmmo = false;
  1297.                   break;
  1298.                } else {
  1299.                   zeroEquipAmmo = true;
  1300.                }
  1301.             }
  1302.          }
  1303.          if (zeroEquipAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  1304.          //---------------------------------------------------//
  1305.          // - Weapon Cost
  1306.          var zeroWeaponAmmo = false;
  1307.          for (var ammoId in skill.weaponAmmoCost) {
  1308.             var cost = skill.weaponAmmoCost[ammoId];
  1309.             var ammoId = parseInt(ammoId);
  1310.             if (!isNaN(ammoId) && (ammoId > 0) && (typeof this._actor !== 'undefined')) {
  1311.                cost = parseInt(cost);
  1312.                withAmmo = true;
  1313.                if (this._actor.hasWeapon($dataWeapons[ammoId])) {
  1314.                   text = text + '\\i[' + String($dataWeapons[ammoId].iconIndex) + ']';
  1315.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataWeapons[ammoId].name + ' ' );
  1316.                   text = text + ( (cost <= 0) ? '' : 'x' + String( 1 + $gameParty.getItemAmount($dataWeapons[ammoId]) ) );
  1317.                   text = text + ( (typeof $dataWeapons[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataWeapons[ammoId].ammoDesc + ')' );
  1318.                   zeroWeaponAmmo = false;
  1319.                   break;
  1320.                } else {
  1321.                   zeroWeaponAmmo = true;
  1322.                }
  1323.             }
  1324.          }
  1325.          if (zeroWeaponAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  1326.          //---------------------------------------------------//
  1327.          // - Charge Armor Cost
  1328.          var zeroChargeEquipAmmo = false;
  1329.          for (var ammoId in skill.equipChargeAmmoCost) {
  1330.             var cost = skill.equipChargeAmmoCost[ammoId];
  1331.             var ammoId = parseInt(ammoId);
  1332.             if (!isNaN(ammoId) && (ammoId > 0) && (typeof this._actor !== 'undefined')) {
  1333.                cost = parseInt(cost);
  1334.                withAmmo = true;
  1335.                if (this._actor.hasArmor($dataArmors[ammoId])) {
  1336.                   text = text + '\\i[' + String($dataArmors[ammoId].iconIndex) + ']';
  1337.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataArmors[ammoId].name + ' ' );
  1338.                   text = text + ( (cost <= 0) ? '' : 'x' + String( this._actor.getAmmoCurrentCharges($dataArmors[ammoId]) ) );
  1339.                   text = text + ( (typeof $dataArmors[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataArmors[ammoId].ammoDesc + ')' );
  1340.                   zeroChargeEquipAmmo = false;
  1341.                   break;
  1342.                } else {
  1343.                   zeroChargeEquipAmmo = true;
  1344.                }
  1345.             }
  1346.          }
  1347.          if (zeroChargeEquipAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  1348.          //---------------------------------------------------//
  1349.          // - Charge Weapon Cost
  1350.          var zeroChargeWeaponAmmo = false;
  1351.          for (var ammoId in skill.weaponChargeAmmoCost) {
  1352.             var cost = skill.weaponChargeAmmoCost[ammoId];
  1353.             var ammoId = parseInt(ammoId);
  1354.             if (!isNaN(ammoId) && (ammoId > 0) && (typeof this._actor !== 'undefined')) {
  1355.                cost = parseInt(cost);
  1356.                withAmmo = true;
  1357.                if (this._actor.hasWeapon($dataWeapons[ammoId])) {
  1358.                   text = text + '\\i[' + String($dataWeapons[ammoId].iconIndex) + ']';
  1359.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataWeapons[ammoId].name + ' ' );
  1360.                   text = text + ( (cost <= 0) ? '' : 'x' + String( this._actor.getAmmoCurrentCharges($dataWeapons[ammoId]) ) );
  1361.                   text = text + ( (typeof $dataWeapons[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataWeapons[ammoId].ammoDesc + ')' );
  1362.                   zeroWeaponAmmo = false;
  1363.                   break;
  1364.                } else {
  1365.                   zeroWeaponAmmo = true;
  1366.                }
  1367.             }
  1368.          }
  1369.          if (zeroChargeWeaponAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  1370.          //---------------------------------------------------//
  1371.          // - End
  1372.          if (withAmmo === true) text = '\n' + introText + ' : ' + text;
  1373.       }
  1374.    }
  1375.    return text;
  1376. }
  1377.  
  1378. Window_Help.prototype.setItem = function(item) {
  1379.    this.setText(item ? item.description + this.getAmmoAmountText(item) : '');
  1380. };
  1381.  
  1382. Unco.AS.Window_SkillList_setHelpWindowItem = Window_SkillList.prototype.setHelpWindowItem;
  1383. Window_SkillList.prototype.setHelpWindowItem = function(item) {
  1384.    if (this._helpWindow) {
  1385.       this._helpWindow._actor = this._actor;
  1386.    }
  1387.    Unco.AS.Window_SkillList_setHelpWindowItem.call(this,item)
  1388. };
  1389.  
  1390. //=============================================================================
  1391. // Window_ActorCommand
  1392. //=============================================================================
  1393.  
  1394. Window_ActorCommand.prototype.getAmmoText = function(skill) {
  1395.     var ammoStr = '';  
  1396.     if (Unco.Param.showAmmoLeftForAttack === 'true') {
  1397.           //---------------------------------------------------//
  1398.           // - Item Cost
  1399.           for (var ammoId in skill.itemAmmoCost) {
  1400.              var ammoId = parseInt(ammoId);
  1401.              var ammoCost = parseInt(skill.itemAmmoCost[ammoId]);
  1402.              if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(ammoCost) && (ammoCost > 0)) {
  1403.                 if (ammoStr !== '') ammoStr += '|';
  1404.                 ammoStr += String(  $gameParty.getItemAmount($dataItems[ammoId]) );              
  1405.              }
  1406.           }
  1407.           //---------------------------------------------------//
  1408.           // - Armor Cost
  1409.           var zeroAmmo = false;
  1410.           for (var ammoId in skill.equipAmmoCost) {
  1411.              var ammoId = parseInt(ammoId);
  1412.              var ammoCost = parseInt(skill.equipAmmoCost[ammoId]);
  1413.              if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(ammoCost) && (ammoCost > 0)) {
  1414.                 if (this._actor.hasArmor($dataArmors[ammoId])) {
  1415.                    if (ammoStr !== '') ammoStr += '|';
  1416.                    ammoStr += String( 1+$gameParty.getItemAmount($dataArmors[ammoId]) );
  1417.                    zeroAmmo = false;
  1418.                    break;
  1419.                 } else {
  1420.                    zeroAmmo = true;
  1421.                 }
  1422.              }
  1423.           }
  1424.           if (zeroAmmo === true) {
  1425.              if (ammoStr !== '') ammoStr += '|';
  1426.              ammoStr += '0';
  1427.           }
  1428.           //---------------------------------------------------//
  1429.           // - Weapon Cost
  1430.           var zeroWeaponAmmo = false;
  1431.           for (var ammoId in skill.weaponAmmoCost) {
  1432.              var ammoId = parseInt(ammoId);
  1433.              var ammoCost = parseInt(skill.weaponAmmoCost[ammoId]);
  1434.              if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(ammoCost) && (ammoCost > 0)) {
  1435.                 if (this._actor.hasWeapon($dataWeapons[ammoId])) {
  1436.                    if (ammoStr !== '') ammoStr += '|';
  1437.                    ammoStr += String( 1+$gameParty.getItemAmount($dataWeapons[ammoId]) );
  1438.                    zeroWeaponAmmo = false;
  1439.                    break;
  1440.                 } else {
  1441.                    zeroWeaponAmmo = true;
  1442.                 }
  1443.              }
  1444.           }
  1445.           if (zeroWeaponAmmo === true) {
  1446.              if (ammoStr !== '') ammoStr += '|';
  1447.              ammoStr += '0';
  1448.           }
  1449.           //---------------------------------------------------//
  1450.           // - Charge Armor Cost
  1451.           var zeroChargeAmmo = false;
  1452.           for (var ammoId in skill.equipChargeAmmoCost) {
  1453.              var ammoId = parseInt(ammoId);
  1454.              var ammoCost = parseInt(skill.equipChargeAmmoCost[ammoId]);
  1455.              if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(ammoCost) && (ammoCost > 0)) {
  1456.                 if (this._actor.hasArmor($dataArmors[ammoId])) {
  1457.                    if (ammoStr !== '') ammoStr += '|';
  1458.                    ammoStr += String( this._actor.getAmmoCurrentCharges($dataArmors[ammoId]) );
  1459.                    zeroChargeAmmo = false;
  1460.                    break;
  1461.                 } else {
  1462.                    zeroChargeAmmo = true;
  1463.                 }
  1464.              }
  1465.           }
  1466.           if (zeroChargeAmmo === true) {
  1467.              if (ammoStr !== '') ammoStr += '|';
  1468.              ammoStr += '0';
  1469.           }
  1470.           //---------------------------------------------------//
  1471.           // - Charge Weapon Cost
  1472.           var zeroChargeWeaponAmmo = false;
  1473.           for (var ammoId in skill.weaponChargeAmmoCost) {
  1474.              var ammoId = parseInt(ammoId);
  1475.              var ammoCost = parseInt(skill.weaponChargeAmmoCost[ammoId]);
  1476.              if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(ammoCost) && (ammoCost > 0)) {
  1477.                 if (this._actor.hasWeapon($dataWeapons[ammoId])) {
  1478.                    if (ammoStr !== '') ammoStr += '|';
  1479.                    ammoStr += String( this._actor.getAmmoCurrentCharges($dataWeapons[ammoId]) );
  1480.                    zeroChargeWeaponAmmo = false;
  1481.                    break;
  1482.                 } else {
  1483.                    zeroChargeWeaponAmmo = true;
  1484.                 }
  1485.              }
  1486.           }
  1487.           if (zeroChargeWeaponAmmo === true) {
  1488.              if (ammoStr !== '') ammoStr += '|';
  1489.              ammoStr += '0';
  1490.           }
  1491.     }
  1492.     //---------------------------------------------------//
  1493.     // - End
  1494.     if (ammoStr !== '') ammoStr = '[' + ammoStr + ']';
  1495.     return ammoStr;
  1496. };
  1497.  
  1498. Unco.AS.Window_ActorCommand_addCommand = Window_ActorCommand.prototype.addCommand;
  1499. if (Imported.BOB_BattleCommandList === true) {
  1500.    Window_ActorCommand.prototype.addCommand = function(name, symbol, enabled, ext, icon) {
  1501.       if (symbol === 'attack') {
  1502.          var skill = $dataSkills[this._actor.attackSkillId()];
  1503.          if ( Unco.AS.hasAmmoCost(skill) ) {
  1504.             var ammoStr = this.getAmmoText(skill);
  1505.             name = name + ammoStr;
  1506.          } else if ( (this._actor._equips[0]) && (this._actor._equips[0]._itemId) ) {
  1507.             var ammoStr = this.getAmmoText($dataWeapons[this._actor._equips[0]._itemId]);
  1508.             name = name + ammoStr;
  1509.          }
  1510.       }
  1511.       if (symbol === 'customSkill') {
  1512.          var ammoStr = this.getAmmoText(ext);
  1513.          name = name + ammoStr;
  1514.       }
  1515.       Unco.AS.Window_ActorCommand_addCommand.call(this,name, symbol, enabled, ext, icon);
  1516.    };
  1517. } else {
  1518.    if (Imported.YEP_WeaponUnleash) {
  1519.       Window_ActorCommand.prototype.addAttackCommand = function() {
  1520.          Yanfly.WUL.Window_ActorCommand_addAttackCommand.call(this);
  1521.          var index = this.findSymbol('attack');
  1522.          if (index < 0) return;
  1523.          var skill = $dataSkills[this._actor.attackSkillId()];
  1524.          var name = skill.commandAttackText;
  1525.          if ( Unco.AS.hasAmmoCost(skill) ) {
  1526.             var ammoStr = this.getAmmoText(skill);
  1527.             name = name + ammoStr;
  1528.          } else if ((this._actor._equips[0]) && (this._actor._equips[0]._itemId)) {
  1529.             var ammoStr = this.getAmmoText($dataWeapons[this._actor._equips[0]._itemId]);
  1530.             name = name + ammoStr;
  1531.          }
  1532.          this._list[index].name = name;
  1533.       };
  1534.       Window_ActorCommand.prototype.addGuardCommand = function() {
  1535.          Yanfly.WUL.Window_ActorCommand_addGuardCommand.call(this);
  1536.          var index = this.findSymbol('guard');
  1537.          if (index < 0) return;
  1538.          var name = $dataSkills[this._actor.guardSkillId()].commandGuardText;
  1539.          var ammoStr = this.getAmmoText( $dataSkills[this._actor.guardSkillId()] );
  1540.          name = name + ammoStr;
  1541.          this._list[index].name = name;
  1542.       };
  1543.    } else {    
  1544.       Window_ActorCommand.prototype.addCommand = function(name, symbol, enabled, ext) {
  1545.          if (symbol === 'attack') {
  1546.             var skill = $dataSkills[this._actor.attackSkillId()];
  1547.             if ( Unco.AS.hasAmmoCost(skill) ) {
  1548.                var ammoStr = this.getAmmoText(skill);
  1549.                name = name + ammoStr;
  1550.             } else if ( (this._actor._equips[0]) && (this._actor._equips[0]._itemId)) {
  1551.                var ammoStr = this.getAmmoText($dataWeapons[this._actor._equips[0]._itemId]);
  1552.                name = name + ammoStr;
  1553.             }
  1554.          }
  1555.          Unco.AS.Window_ActorCommand_addCommand.call(this,name, symbol, enabled, ext);
  1556.       };
  1557.    }
  1558. }
  1559.  
  1560. Unco.AS.Window_ActorCommand_setHelpWindowItem = Window_ActorCommand.prototype.setHelpWindowItem;
  1561. Window_ActorCommand.prototype.setHelpWindowItem = function(item) {
  1562.    if (this._helpWindow && this._actor) {
  1563.       this._helpWindow._actor = this._actor;
  1564.    }
  1565.    Unco.AS.Window_ActorCommand_setHelpWindowItem.call(this,item)
  1566. };
  1567.  
  1568.  
  1569.  
  1570. if (Imported.YEP_SkillCore === true) {
  1571. //=============================================================================
  1572. // Window_Base
  1573. //=============================================================================
  1574.    Window_Base.prototype.mustDrawActorAmmo = function(actor) {
  1575.       var cond = typeof actor._equips !== 'undefined';
  1576.       if (cond) cond = typeof actor._equips[0] !== 'undefined';
  1577.       if (cond) {
  1578.          if (actor._equips[0]._itemId > 0) {
  1579.             skill = $dataWeapons[actor._equips[0]._itemId];
  1580.             for (var ammoId in skill.itemAmmoCost) {
  1581.                var ammoId = parseInt(ammoId);
  1582.                if (!isNaN(ammoId) && (ammoId > 0)) {                
  1583.                   if (!isNaN(skill.itemAmmoCost[ammoId])) {
  1584.                      return true;
  1585.                   }
  1586.                }
  1587.             }
  1588.             for (var ammoId in skill.equipAmmoCost) {
  1589.                var ammoId = parseInt(ammoId);
  1590.                if (!isNaN(ammoId) && (ammoId > 0)) {                  
  1591.                   if (!isNaN(skill.equipAmmoCost[ammoId])) {
  1592.                      return true;
  1593.                   }
  1594.                }
  1595.             }
  1596.             for (var ammoId in skill.weaponAmmoCost) {
  1597.                var ammoId = parseInt(ammoId);
  1598.                if (!isNaN(ammoId) && (ammoId > 0)) {                  
  1599.                   if (!isNaN(skill.weaponAmmoCost[ammoId])) {
  1600.                      return true;
  1601.                   }
  1602.                }
  1603.             }
  1604.             for (var ammoId in skill.equipChargeAmmoCost) {
  1605.                var ammoId = parseInt(ammoId);
  1606.                if (!isNaN(ammoId) && (ammoId > 0)) {                  
  1607.                   if (!isNaN(skill.equipChargeAmmoCost[ammoId])) {
  1608.                      return true;
  1609.                   }
  1610.                }
  1611.             }
  1612.             for (var ammoId in skill.weaponChargeAmmoCost) {
  1613.                var ammoId = parseInt(ammoId);
  1614.                if (!isNaN(ammoId) && (ammoId > 0)) {                  
  1615.                   if (!isNaN(skill.weaponChargeAmmoCost[ammoId])) {
  1616.                      return true;
  1617.                   }
  1618.                }
  1619.             }
  1620.          }
  1621.       }
  1622.       return false;
  1623.    }
  1624.    Window_Base.prototype.drawActorAmmo = function(actor, x, y, width) {
  1625.       if (typeof actor._equips !== 'undefined') {
  1626.          if (actor._equips[0]._itemId > 0) {
  1627.             skill = $dataWeapons[ ( (typeof $dataWeapons[actor._equips[0]._itemId].baseItemId === 'undefined') ? actor._equips[0]._itemId : $dataWeapons[actor._equips[0]._itemId].baseItemId ) ];
  1628.             var dw = width;
  1629.             //---------------------------------------------------//
  1630.             // - Item Cost
  1631.             for (var ammoId in skill.itemAmmoCost) {
  1632.                var ammoId = parseInt(ammoId);
  1633.                if (!isNaN(ammoId) && (ammoId > 0)) {
  1634.                   var ammoCost = parseInt(skill.itemAmmoCost[ammoId]);              
  1635.                   this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1636.                   var text = (ammoCost <= 0) ? '' : 'x' + String( $gameParty.getItemAmount($dataItems[ammoId]) );
  1637.                   this.contents.fontSize = Unco.Param.ammoFontSize;
  1638.                   this.drawText(text, x, y, dw, 'right');
  1639.                   dw -= this.textWidth(text);
  1640.                   this.resetFontSettings();
  1641.                   if ($dataItems[ammoId].iconIndex > 0) {
  1642.                      var iw = x + dw - Window_Base._iconWidth;
  1643.                      this.drawIcon($dataItems[ammoId].iconIndex, iw, y + 2);
  1644.                      dw -= Window_Base._iconWidth + 2;
  1645.                   }
  1646.                }
  1647.             }
  1648.             //---------------------------------------------------//
  1649.             // - Armor Cost
  1650.             var zeroAmmo = false;
  1651.             for (var ammoId in skill.equipAmmoCost) {
  1652.                var ammoId = parseInt(ammoId);
  1653.                if (!isNaN(ammoId) && (ammoId > 0)) {
  1654.                   var ammoCost = parseInt(skill.equipAmmoCost[ammoId]);  
  1655.                   if (actor.hasArmor($dataArmors[ammoId])) {
  1656.                      this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1657.                      var text = (ammoCost <= 0) ? '' : 'x' + String( 1+$gameParty.getItemAmount($dataArmors[ammoId]) );
  1658.                      this.contents.fontSize = Unco.Param.ammoFontSize;
  1659.                      this.drawText(text, x, y, dw, 'right');
  1660.                      dw -= this.textWidth(text);
  1661.                      this.resetFontSettings();
  1662.                      if ($dataArmors[ammoId].iconIndex > 0) {
  1663.                         var iw = x + dw - Window_Base._iconWidth;
  1664.                         this.drawIcon($dataArmors[ammoId].iconIndex, iw, y + 2);
  1665.                         dw -= Window_Base._iconWidth + 2;
  1666.                      }
  1667.                      zeroAmmo = false;
  1668.                      break;
  1669.                   } else {
  1670.                      zeroAmmo = true;
  1671.                   }
  1672.                }
  1673.             }
  1674.             if (zeroAmmo === true) {
  1675.                this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1676.                var text = 'x0';
  1677.                this.contents.fontSize = Unco.Param.ammoFontSize;
  1678.                this.drawText(text, x, y, dw, 'right');
  1679.                dw -= this.textWidth(text);
  1680.                this.resetFontSettings();
  1681.                var iw = x + dw - Window_Base._iconWidth;
  1682.                this.drawIcon( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) , iw, y + 2);
  1683.                dw -= Window_Base._iconWidth + 2;
  1684.             }
  1685.             //---------------------------------------------------//
  1686.             // - Weapon Cost
  1687.             var zeroWeaponAmmo = false;
  1688.             for (var ammoId in skill.weaponAmmoCost) {
  1689.                var ammoId = parseInt(ammoId);
  1690.                if (!isNaN(ammoId) && (ammoId > 0)) {
  1691.                   var ammoCost = parseInt(skill.weaponAmmoCost[ammoId]);  
  1692.                   if (actor.hasWeapon($dataWeapons[ammoId])) {
  1693.                      this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1694.                      var text = (ammoCost <= 0) ? '' : 'x' + String( 1+$gameParty.getItemAmount($dataWeapons[ammoId]) );
  1695.                      this.contents.fontSize = Unco.Param.ammoFontSize;
  1696.                      this.drawText(text, x, y, dw, 'right');
  1697.                      dw -= this.textWidth(text);
  1698.                      this.resetFontSettings();
  1699.                      if ($dataWeapons[ammoId].iconIndex > 0) {
  1700.                         var iw = x + dw - Window_Base._iconWidth;
  1701.                         this.drawIcon($dataWeapons[ammoId].iconIndex, iw, y + 2);
  1702.                         dw -= Window_Base._iconWidth + 2;
  1703.                      }
  1704.                      zeroWeaponAmmo = false;
  1705.                      break;
  1706.                   } else {
  1707.                      zeroWeaponAmmo = true;
  1708.                   }
  1709.                }
  1710.             }
  1711.             if (zeroWeaponAmmo === true) {
  1712.                this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1713.                var text = 'x0';
  1714.                this.contents.fontSize = Unco.Param.ammoFontSize;
  1715.                this.drawText(text, x, y, dw, 'right');
  1716.                dw -= this.textWidth(text);
  1717.                this.resetFontSettings();
  1718.                var iw = x + dw - Window_Base._iconWidth;
  1719.                this.drawIcon( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) , iw, y + 2);
  1720.                dw -= Window_Base._iconWidth + 2;
  1721.             }
  1722.             //---------------------------------------------------//
  1723.             // - Charge Armor Cost
  1724.             var zeroChargeAmmo = false;
  1725.             for (var ammoId in skill.equipChargeAmmoCost) {
  1726.                var ammoId = parseInt(ammoId);
  1727.                if (!isNaN(ammoId) && (ammoId > 0)) {
  1728.                   var ammoCost = parseInt(skill.equipChargeAmmoCost[ammoId]);  
  1729.                   if (actor.hasArmor($dataArmors[ammoId])) {
  1730.                      this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1731.                      var text = (ammoCost <= 0) ? '' : 'x' + String( actor.getAmmoCurrentCharges($dataArmors[ammoId]) );
  1732.                      this.contents.fontSize = Unco.Param.ammoFontSize;
  1733.                      this.drawText(text, x, y, dw, 'right');
  1734.                      dw -= this.textWidth(text);
  1735.                      this.resetFontSettings();
  1736.                      if ($dataArmors[ammoId].iconIndex > 0) {
  1737.                         var iw = x + dw - Window_Base._iconWidth;
  1738.                         this.drawIcon($dataArmors[ammoId].iconIndex, iw, y + 2);
  1739.                         dw -= Window_Base._iconWidth + 2;
  1740.                      }
  1741.                      zeroChargeAmmo = false;
  1742.                      break;
  1743.                   } else {
  1744.                      zeroChargeAmmo = true;
  1745.                   }
  1746.                }
  1747.             }
  1748.             if (zeroChargeAmmo === true) {
  1749.                this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1750.                var text = 'x0';
  1751.                this.contents.fontSize = Unco.Param.ammoFontSize;
  1752.                this.drawText(text, x, y, dw, 'right');
  1753.                dw -= this.textWidth(text);
  1754.                this.resetFontSettings();
  1755.                var iw = x + dw - Window_Base._iconWidth;
  1756.                this.drawIcon( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) , iw, y + 2);
  1757.                dw -= Window_Base._iconWidth + 2;
  1758.             }
  1759.             //---------------------------------------------------//
  1760.             // - Charge Weapon Cost
  1761.             var zeroChargeWeaponAmmo = false;
  1762.             for (var ammoId in skill.weaponChargeAmmoCost) {
  1763.                var ammoId = parseInt(ammoId);
  1764.                if (!isNaN(ammoId) && (ammoId > 0)) {
  1765.                   var ammoCost = parseInt(skill.weaponChargeAmmoCost[ammoId]);  
  1766.                   if (actor.hasWeapon($dataWeapons[ammoId])) {
  1767.                      this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1768.                      var text = (ammoCost <= 0) ? '' : 'x' + String( actor.getAmmoCurrentCharges($dataWeapons[ammoId]) );
  1769.                      this.contents.fontSize = Unco.Param.ammoFontSize;
  1770.                      this.drawText(text, x, y, dw, 'right');
  1771.                      dw -= this.textWidth(text);
  1772.                      this.resetFontSettings();
  1773.                      if ($dataWeapons[ammoId].iconIndex > 0) {
  1774.                         var iw = x + dw - Window_Base._iconWidth;
  1775.                         this.drawIcon($dataWeapons[ammoId].iconIndex, iw, y + 2);
  1776.                         dw -= Window_Base._iconWidth + 2;
  1777.                      }
  1778.                      zeroChargeWeaponAmmo = false;
  1779.                      break;
  1780.                   } else {
  1781.                      zeroChargeWeaponAmmo = true;
  1782.                   }
  1783.                }
  1784.             }
  1785.             if (zeroChargeWeaponAmmo === true) {
  1786.                this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1787.                var text = 'x0';
  1788.                this.contents.fontSize = Unco.Param.ammoFontSize;
  1789.                this.drawText(text, x, y, dw, 'right');
  1790.                dw -= this.textWidth(text);
  1791.                this.resetFontSettings();
  1792.                var iw = x + dw - Window_Base._iconWidth;
  1793.                this.drawIcon( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) , iw, y + 2);
  1794.                dw -= Window_Base._iconWidth + 2;
  1795.             }
  1796.          }
  1797.       }
  1798.    };
  1799.    
  1800. //=============================================================================
  1801. // DataManager (again)
  1802. //=============================================================================
  1803.    Unco.AS.DataManager_processGSCNotetags1 = DataManager.processGSCNotetags1;
  1804.    DataManager.processGSCNotetags1 = function(group) {
  1805.      Unco.AS.DataManager_processGSCNotetags1.call(this,group);
  1806.      for (var n = 1; n < group.length; n++) {
  1807.        var obj = group[n];
  1808.        var notedata = obj.note.split(/[\r\n]+/);
  1809.  
  1810.        for (var i = 0; i < notedata.length; i++) {
  1811.          var line = notedata[i];
  1812.          if (line.match(/<(?:SWAP GAUGE|gauge)[ ](\d+):[ ](.*)>/i)) {
  1813.            var gauge = parseInt(RegExp.$1);
  1814.            var text = String(RegExp.$2).toUpperCase();
  1815.            if (['AMMO'].contains(text)) {
  1816.              if (gauge === 1) obj.gauge1 = text;
  1817.              if (gauge === 2) obj.gauge2 = text;
  1818.              if (gauge === 3) obj.gauge3 = text;
  1819.            }
  1820.          }
  1821.        }
  1822.      }
  1823.    };
  1824.    Unco.AS.DataManager_processGSCNotetags2 = DataManager.processGSCNotetags2;
  1825.    DataManager.processGSCNotetags2 = function(group) {
  1826.      Unco.AS.DataManager_processGSCNotetags2.call(this,group);
  1827.      for (var n = 1; n < group.length; n++) {
  1828.        var obj = group[n];
  1829.        var notedata = obj.note.split(/[\r\n]+/);
  1830.  
  1831.        for (var i = 0; i < notedata.length; i++) {
  1832.          var line = notedata[i];
  1833.          if (line.match(/<(?:SWAP GAUGE|gauge)[ ](\d+):[ ](.*)>/i)) {
  1834.            var gauge = parseInt(RegExp.$1);
  1835.            var text = String(RegExp.$2).toUpperCase();
  1836.            if (['AMMO'].contains(text)) {
  1837.              if (gauge === 1) obj.gauge1 = text;
  1838.              if (gauge === 2) obj.gauge2 = text;
  1839.              if (gauge === 3) obj.gauge3 = text;
  1840.            }
  1841.          }
  1842.        }
  1843.      }
  1844.    };
  1845.    
  1846.    Unco.AS.Window_Window_Base_drawActorHp = Window_Base.prototype.drawActorHp;
  1847.    Window_Base.prototype.drawActorHp = function(actor, x, y, width) {
  1848.        if ((this.mustDrawActorAmmo(actor)) && (actor.gauge1() === 'AMMO')) {
  1849.        this.drawActorAmmo(actor, x, y, width);
  1850.        } else {
  1851.          Unco.AS.Window_Window_Base_drawActorHp.call(this, actor, x, y, width);
  1852.        }
  1853.    };
  1854.    
  1855.    Unco.AS.Window_Window_Base_drawActorMp = Window_Base.prototype.drawActorMp;
  1856.    Window_Base.prototype.drawActorMp = function(actor, x, y, width) {
  1857.        if ((this.mustDrawActorAmmo(actor)) && (actor.gauge2() === 'AMMO')) {
  1858.          this.drawActorAmmo(actor, x, y, width);
  1859.        } else {
  1860.          Unco.AS.Window_Window_Base_drawActorMp.call(this, actor, x, y, width);
  1861.        }
  1862.    };
  1863.    
  1864.    Unco.AS.Window_Window_Base_drawActorTp = Window_Base.prototype.drawActorTp;
  1865.    Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
  1866.        if ((this.mustDrawActorAmmo(actor)) && (actor.gauge3() === 'AMMO')) {
  1867.        this.drawActorAmmo(actor, x, y, width);
  1868.        } else {
  1869.          Unco.AS.Window_Window_Base_drawActorTp.call(this, actor, x, y, width);
  1870.        }
  1871.    };
  1872. }
  1873.  
  1874. //-----------------------------------------------------------------------------
  1875. // Window_Base
  1876. //
  1877. // Draw item with charges.
  1878.  
  1879. Window_Base.prototype.drawItemName = function(item, x, y, width) {
  1880.    width = width || 312;
  1881.    if (item) {
  1882.       var iconBoxWidth = (Imported.YEP_CoreEngine === true) ? this.lineHeight() : (Window_Base._iconWidth + 4);
  1883.       var padding = (Imported.YEP_CoreEngine === true) ? ( (iconBoxWidth - Window_Base._iconWidth) / 2 ) : 2;
  1884.       this.resetTextColor();
  1885.       this.drawIcon(item.iconIndex, x + padding, y + padding);
  1886.       if (typeof item.ammoCurrentCharges !== 'undefined') {
  1887.          this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1888.          this.contents.fontSize = Unco.Param.ammoFontSize;
  1889.          this.drawText( String( item.ammoCurrentCharges ) , x + padding ,  y + padding , Window_Base._iconWidth , 'center');
  1890.          this.resetTextColor();
  1891.          this.resetFontSettings();
  1892.       }
  1893.       this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
  1894.    }
  1895. };
  1896.  
  1897. //-----------------------------------------------------------------------------
  1898. // Window_Ammo
  1899. //
  1900. // The window for displaying the ammunition amount for attack action.
  1901.  
  1902. function Window_Ammo() {
  1903.     this.initialize.apply(this, arguments);
  1904. }
  1905.  
  1906. Window_Ammo.prototype = Object.create(Window_Base.prototype);
  1907. Window_Ammo.prototype.constructor = Window_Ammo;
  1908.  
  1909. Window_Ammo.prototype.initialize = function(numLines) {
  1910.     var width = Graphics.boxWidth;
  1911.     var height = this.fittingHeight(1);
  1912.     var y = Graphics.height-this.fittingHeight(6);
  1913.     Window_Base.prototype.initialize.call(this, 0, 0, width, height);
  1914.     this._text = '';
  1915. };
  1916.  
  1917. Window_Ammo.prototype.setText = function(text) {
  1918.     if (this._text !== text) {
  1919.         this._text = text;
  1920.         this.refresh();
  1921.     }
  1922. };
  1923.  
  1924. Window_Ammo.prototype.clear = function() {
  1925.     this.setText('');
  1926. };
  1927.  
  1928.  
  1929. Window_Ammo.prototype.setItem = function(actor,item) {
  1930.    var text = '';
  1931.    if (typeof item !== 'undefined') {
  1932.       if ((DataManager.isSkill(item)) && (Unco.Param.showAmmoLeftInDesc === 'true')) {
  1933.          var skill = item;
  1934.          if (skill.id === actor.attackSkillId()) {
  1935.             if ( !Unco.AS.hasAmmoCost(skill) ) {
  1936.                if (typeof actor._equips !== 'undefined') {
  1937.                   if (actor._equips[0]._itemId > 0) {
  1938.                      skill = $dataWeapons[ ( (typeof $dataWeapons[actor._equips[0]._itemId].baseItemId === 'undefined') ? actor._equips[0]._itemId : $dataWeapons[actor._equips[0]._itemId].baseItemId ) ];
  1939.                   }
  1940.                }
  1941.             }
  1942.          }
  1943.          //---------------------------------------------------//
  1944.          // - Item Cost
  1945.          var withAmmo = false;
  1946.          for (var ammoId in skill.itemAmmoCost) {
  1947.             var cost = skill.itemAmmoCost[ammoId];
  1948.             ammoId = parseInt(ammoId);
  1949.             if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(cost)) {
  1950.                var cost = parseInt(cost);
  1951.                var itemOwned = ($gameParty.getItemAmount($dataItems[ammoId]) > 0);
  1952.                text = text + '\\i[' + String($dataItems[ammoId].iconIndex) + ']';
  1953.                text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataItems[ammoId].name + ' ' );
  1954.                text = text + ( ((cost <= 0) && itemOwned) ? '' : ( 'x' + String( $gameParty.getItemAmount($dataItems[ammoId]) ) )  );
  1955.                withAmmo = true;
  1956.             }
  1957.          }
  1958.          //---------------------------------------------------//
  1959.          // - Armor Cost
  1960.          var zeroEquipAmmo = false;
  1961.          for (var ammoId in skill.equipAmmoCost) {
  1962.             var cost = skill.equipAmmoCost[ammoId];
  1963.             var ammoId = parseInt(ammoId);
  1964.             if (!isNaN(ammoId) && (ammoId > 0)) {
  1965.                cost = parseInt(cost);
  1966.                withAmmo = true;
  1967.                if (actor.hasArmor($dataArmors[ammoId])) {
  1968.                   text = text + '\\i[' + String($dataArmors[ammoId].iconIndex) + ']';
  1969.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataArmors[ammoId].name + ' ' );
  1970.                   text = text + ( (cost <= 0) ? '' : 'x' + String( 1 + $gameParty.getItemAmount($dataArmors[ammoId]) )  );
  1971.                   text = text + ( (typeof $dataArmors[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataArmors[ammoId].ammoDesc + ')' );
  1972.                   zeroEquipAmmo = false;
  1973.                   break;
  1974.                } else {
  1975.                   zeroEquipAmmo = true;
  1976.                }
  1977.             }
  1978.          }
  1979.          if (zeroEquipAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  1980.          //---------------------------------------------------//
  1981.          // - Weapon Cost
  1982.          var zeroWeaponAmmo = false;
  1983.          for (var ammoId in skill.weaponAmmoCost) {
  1984.             var cost = skill.weaponAmmoCost[ammoId];
  1985.             var ammoId = parseInt(ammoId);
  1986.             if (!isNaN(ammoId) && (ammoId > 0)) {
  1987.                cost = parseInt(cost);
  1988.                withAmmo = true;
  1989.                if (actor.hasWeapon($dataWeapons[ammoId])) {
  1990.                   text = text + '\\i[' + String($dataWeapons[ammoId].iconIndex) + ']';
  1991.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataWeapons[ammoId].name + ' ' );
  1992.                   text = text + ( (cost <= 0) ? '' : 'x' + String( 1 + $gameParty.getItemAmount($dataWeapons[ammoId]) )  );
  1993.                   text = text + ( (typeof $dataWeapons[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataWeapons[ammoId].ammoDesc + ')' );
  1994.                   zeroWeaponAmmo = false;
  1995.                   break;
  1996.                } else {
  1997.                   zeroWeaponAmmo = true;
  1998.                }
  1999.             }
  2000.          }
  2001.          if (zeroWeaponAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  2002.          //---------------------------------------------------//
  2003.          // - Charge Armor Cost
  2004.          var zeroChargeEquipAmmo = false;
  2005.          for (var ammoId in skill.equipChargeAmmoCost) {
  2006.             var cost = skill.equipChargeAmmoCost[ammoId];
  2007.             var ammoId = parseInt(ammoId);
  2008.             if (!isNaN(ammoId) && (ammoId > 0)) {
  2009.                cost = parseInt(cost);
  2010.                withAmmo = true;
  2011.                if (actor.hasArmor($dataArmors[ammoId])) {
  2012.                   text = text + '\\i[' + String($dataArmors[ammoId].iconIndex) + ']';
  2013.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataArmors[ammoId].name + ' ' );
  2014.                   text = text + ( (cost <= 0) ? '' : 'x' + String( actor.getAmmoCurrentCharges($dataArmors[ammoId]) )  );
  2015.                   text = text + ( (typeof $dataArmors[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataArmors[ammoId].ammoDesc + ')' );
  2016.                   zeroChargeEquipAmmo = false;
  2017.                   break;
  2018.                } else {
  2019.                   zeroChargeEquipAmmo = true;
  2020.                }
  2021.             }
  2022.          }
  2023.          if (zeroChargeEquipAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  2024.          //---------------------------------------------------//
  2025.          // - Charge Weapon Cost
  2026.          var zeroChargeWeaponAmmo = false;
  2027.          for (var ammoId in skill.weaponChargeAmmoCost) {
  2028.             var cost = skill.weaponChargeAmmoCost[ammoId];
  2029.             var ammoId = parseInt(ammoId);
  2030.             if (!isNaN(ammoId) && (ammoId > 0)) {
  2031.                cost = parseInt(cost);
  2032.                withAmmo = true;
  2033.                if (actor.hasWeapon($dataWeapons[ammoId])) {
  2034.                   text = text + '\\i[' + String($dataWeapons[ammoId].iconIndex) + ']';
  2035.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataWeapons[ammoId].name + ' ' );
  2036.                   text = text + ( (cost <= 0) ? '' : 'x' + String( actor.getAmmoCurrentCharges($dataWeapons[ammoId]) )  );
  2037.                   text = text + ( (typeof $dataWeapons[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataWeapons[ammoId].ammoDesc + ')' );
  2038.                   zeroChargeWeaponAmmo = false;
  2039.                   break;
  2040.                } else {
  2041.                   zeroChargeWeaponAmmo = true;
  2042.                }
  2043.             }
  2044.          }
  2045.          if (zeroChargeWeaponAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  2046.          
  2047.          if (withAmmo === true) text = ( (typeof skill.ammoText !== 'undefined') ? skill.ammoText : Unco.Param.descAmmoLeftText) + ' : ' + text;
  2048.       }
  2049.    }
  2050.    if (text !== '') {
  2051.       this.setText(item ? text : '');
  2052.       this.show();
  2053.    }
  2054. };
  2055.  
  2056. Window_Ammo.prototype.refresh = function() {
  2057.     this.contents.clear();
  2058.     this.drawTextEx(this._text, this.textPadding(), 0);
  2059. };
  2060.  
  2061. Unco.AS.Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
  2062. Scene_Battle.prototype.createAllWindows = function() {
  2063.     Unco.AS.Scene_Battle_createAllWindows.call(this);
  2064.     this.createAmmoWindow();
  2065. };
  2066.  
  2067. Scene_Battle.prototype.createAmmoWindow = function() {
  2068.     this._ammoWindow = new Window_Ammo();
  2069.     this._ammoWindow.visible = false;
  2070.     this.addWindow(this._ammoWindow);
  2071. };
  2072.  
  2073. Scene_Battle.prototype.showAmmoWindow = function() {
  2074.   if (Unco.Param.showAmmoLeftActorCommand === 'true') this._ammoWindow.setItem(BattleManager.actor(),$dataSkills[BattleManager.actor().attackSkillId()]);
  2075. };
  2076.  
  2077. Unco.AS.Scene_Battle_onSelectAction = Scene_Battle.prototype.onSelectAction;
  2078. Scene_Battle.prototype.onSelectAction = function() {
  2079.     this._ammoWindow.hide();
  2080.     Unco.AS.Scene_Battle_onSelectAction.call(this);
  2081. };
  2082.  
  2083. Unco.AS.Scene_Battle_commandAttack = Scene_Battle.prototype.commandAttack;
  2084. Scene_Battle.prototype.commandAttack = function() {
  2085.    this._ammoWindow.hide();
  2086.    Unco.AS.Scene_Battle_commandAttack.call(this);
  2087. };
  2088. Unco.AS.Scene_Battle_commandSkill = Scene_Battle.prototype.commandSkill;
  2089. Scene_Battle.prototype.commandSkill = function() {
  2090.    this._ammoWindow.hide();
  2091.    Unco.AS.Scene_Battle_commandSkill.call(this);
  2092. };
  2093. Unco.AS.Scene_Battle_commandGuard = Scene_Battle.prototype.commandGuard;
  2094. Scene_Battle.prototype.commandGuard = function() {
  2095.    this._ammoWindow.hide();
  2096.    Unco.AS.Scene_Battle_commandGuard.call(this);
  2097. };
  2098. Unco.AS.Scene_Battle_commandItem = Scene_Battle.prototype.commandItem;
  2099. Scene_Battle.prototype.commandItem = function() {
  2100.    this._ammoWindow.hide();
  2101.    Unco.AS.Scene_Battle_commandItem.call(this);
  2102. };
  2103. Unco.AS.Scene_Battle_startActorCommandSelection = Scene_Battle.prototype.startActorCommandSelection;
  2104. Scene_Battle.prototype.startActorCommandSelection = function() {
  2105.    this.showAmmoWindow();
  2106.    Unco.AS.Scene_Battle_startActorCommandSelection.call(this);
  2107. };
  2108. Unco.AS.Scene_Battle_onSkillCancel = Scene_Battle.prototype.onSkillCancel;
  2109. Scene_Battle.prototype.onSkillCancel = function() {
  2110.    this.showAmmoWindow();
  2111.    Unco.AS.Scene_Battle_onSkillCancel.call(this);
  2112. };
  2113. Unco.AS.Scene_Battle_onItemCancel = Scene_Battle.prototype.onItemCancel;
  2114. Scene_Battle.prototype.onItemCancel = function() {
  2115.    this.showAmmoWindow();
  2116.    Unco.AS.Scene_Battle_onItemCancel.call(this);
  2117. };
  2118. Unco.AS.Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel;
  2119. Scene_Battle.prototype.onEnemyCancel = function() {
  2120.    if (this._actorCommandWindow.currentSymbol() === 'attack') {
  2121.       this.showAmmoWindow();
  2122.    }
  2123.    Unco.AS.Scene_Battle_onEnemyCancel.call(this);
  2124. };
Advertisement
RAW Paste Data Copied
Advertisement