Advertisement
Unconnected42

RPG Maker Plug-in - Ammunition System v. 1.1.4

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