Advertisement
Unconnected42

RMMV Plug-in _ Unco_AmmunitionSystem1_1_7_UpToDate

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