Advertisement
Unconnected42

RMMV Plug-in _ Unco_AmmunitionSystem_v0_4_1

Nov 20th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Ammunition System, ver0.4.1
  3. //   by Unconnected42
  4. // UNCO_AmmunitionSystem.js
  5. // Last Updated : 2015/11/17
  6. //=============================================================================
  7.  
  8. var Imported = Imported || {};
  9. Imported.UNCO_AmmunitionSystem = true;
  10.  
  11. var Unco = Unco || {};
  12. Unco.AS = Unco.AS || {};
  13.  
  14.  
  15. //=============================================================================
  16.  /*:
  17.  * @plugindesc  Allows skills to need ammunition.
  18.  * <Unco Ammo>
  19.  * @author Unconnected42
  20.  *
  21.  * @param Show Ammo Left When Actor Command
  22.  * @desc If set as 'true', show how much ammunition is left for main attack at the top of the screen, during actor command selection.
  23.  * @default true
  24.  *
  25.  * @param Show Ammo Left In Help Window
  26.  * @desc  If set as 'true', show how much ammunition is left for a skill in its description.
  27.  * @default true
  28.  *
  29.  * @param Help Window Ammo Text
  30.  * @desc  Default text to be displayed in skill description before ammunition amounts.
  31.  * @default Ammunition left
  32.  *
  33.  * @param Show Ammo Left In Skill Window
  34.  * @desc In skill window, show how much ammunition is left together with the cost if set at 'true'.
  35.  * @default false
  36.  *
  37.  * @param No Ammo Icon
  38.  * @desc  Id of the default icon to be displayed when there is no more ammunition and several types of ammunition are possible.
  39.  * @default 16
  40.  *
  41.  * @param Gold Ammo Icon
  42.  * @desc  Id of the icon to be displayed for gold costs.
  43.  * @default 313
  44.  *
  45.  * @param Ammo Font Size
  46.  * @desc Font size of the ammunition amounts in skill window and gauge.
  47.  * @default 20
  48.  *
  49.  * @param Ammo Font Color
  50.  * @desc Font color of the ammunition amounts in skill window and gauge.
  51.  * @default 6
  52.  *
  53.  * @param Show Ammo Left In Actor Command Window
  54.  * @desc If set at true, will display how much ammo is left just next to the attack command.
  55.  * @default false
  56.  *
  57.  * @param Compact Cost Display
  58.  * @desc If set at true, the amount of needed ammo will be displayed on the icon.
  59.  * @default false
  60.  *
  61.  * @help
  62.  * ============================================
  63.  * Introduction
  64.  * ============================================
  65.  *
  66.  * This plug-in will allow skills or weapons to require the consumption of
  67.  * ammunition, components, etc. in order to work. The cost is  paid each
  68.  * time the skill is used, together with MP/TP costs, or each time the
  69.  * normal attack is used in the case of weapons.
  70.  * The ammunition can be either gold, items or equipments (armours, weapons), or
  71.  * a mix.
  72.  *
  73.  * However, things work differently depending on what type of cost is considered.
  74.  * - items : if several types of items are marked as required as ammunition
  75.  *   for a given skill/weapon, *ALL* of the corresponding prices must be
  76.  *   paid each time the skill/weapon is used.
  77.  * - equipment : the equipment needs to be equipped in order for the skill/weapon
  78.  *   to work. If several types of equipments are marked as required as ammunition
  79.  *   for a given skill/weapon, *ONLY* the cost of the one that is *CURRENTLY
  80.  *   EQUIPPED* will be paid. That means a weapon/skill can be able to use
  81.  *   different interchangeable ammunition types.
  82.  * - Gold cost is straightforward in how it functions.
  83.  *
  84.  * You can also define skills which can change the type of ammunition
  85.  * equipped even during combat, in the case of armour-type ammunition.
  86.  * Then, your hero can use an action to change his/her ammunition type !
  87.  *
  88.  * ============================================
  89.  * Known Compatibility Issues
  90.  * ============================================
  91.  *
  92.  * This plug-in should be placed under all plug-ins that you are using,
  93.  * especially Yanfly's since it actually uses some of their features if
  94.  * they are present.
  95.  * Known exceptions to that rule :
  96.  * - Yanfly's Skill Cooldown
  97.  * - Jay's Dual Techs.
  98.  *   -> Ammunition should be placed above these two plug-ins.
  99.  * This might also be the case for other plug-ins whenever
  100.  * the modification of skill costs is concerned.
  101.  * On the contrary, the following plug-ins MUST be placed above :
  102.  * - Bobstah's BattleCommandList.
  103.  *
  104.  *
  105.  * This plug-in in the present version should be fully compatible
  106.  * with Yanfly's ItemCore Independent Items feature.
  107.  * Therefore, ammunition of any kind can either be independent or
  108.  * not (for the latter case, use a <Not Independent Item> notetag
  109.  * in the ammunition notebox if you are using ItemCore and a max
  110.  * number of items > 0).
  111.  *
  112.  * ============================================
  113.  * Use
  114.  * ============================================
  115.  *
  116.  * Lines to put in either Weapon notebox or Skill notebox for defining costs :
  117.  * <Gold Cost: c>
  118.  * <Ammo i Item: c>  (for items)
  119.  * <Ammo i Equip: c>  (for armors)
  120.  * <Ammo i Weapon: c>  (for weapons)
  121.  * ... where i is the ID of the ammunition item/armor and c is the cost
  122.  * required for one use.
  123.  *
  124.  * To create a skill that will change the type of ammunition equipped:
  125.  * <Ammo i Load: s>
  126.  * ... where i is the ID of the ammunition armor and s is the slot
  127.  * to be equipped. If your actor(s) have for example the following equipment
  128.  * types:
  129.  *     Weapon, Shield, Head, Body, Accessory, Ammunition
  130.  * ... then the slot number would be 6.
  131.  * Note 1: this is meant to be used during battle, when equip menu is not
  132.  * accessible, if you want your actors to be able to switch ammunition.
  133.  * Note 2: it is necessary to define one skill per type of ammunition.
  134.  * Note 3: it is possible to use this tag for equipping any kind of armor, and
  135.  * not just ammunition.
  136.  *
  137.  * Disclaimer concerning weapon-type ammunition: this is a new feature, and
  138.  * in its present state it is intended to be used for weapons that would be
  139.  * their own ammo, like throwing knives, shurikens, etc.
  140.  * In theory, however, it *should* be possible to use as ammo for a weapon
  141.  * a different weapon, provided both of them are equipped, but this possibility
  142.  * has yet to be playtested...
  143.  * Also, the Load feature currently does not work with weapon-type ammo.
  144.  *
  145.  * You can also now have skill availability depend on a game switch status, with
  146.  * the following tag to put in a skill's notebox:
  147.  *   <Game Switch: n>
  148.  * If the game switch number 'n' is set at false, the skill cannot be used.
  149.  *
  150.  * ============================================
  151.  * Displaying Ammunition Amounts & Costs
  152.  * ============================================
  153.  *
  154.  * A given ammunition type is almost always represented by its icon when it
  155.  * is necessary (either to display a cost or a remaining amount).
  156.  * Ammo costs for skills are indicated together with "normal" TP/MP costs.
  157.  *
  158.  * There are several solutions for displaying the remaining ammunition amount
  159.  * so that the player knows where he stands.
  160.  * Most of them are turned on through the plug-in parameters.
  161.  *
  162.  * - For weapons :
  163.  *   + The number of ammunition left can be displayed at the
  164.  *     top of the screen when the actor command menu is active.
  165.  *     This is the default option.
  166.  *   + The number of ammunition left can be displayed in the
  167.  *     command window, just next to the "Attack" option.
  168.  *     No icon in that case.
  169.  *   + If you are using Yanfly's SkillCore plug-in, you can use the following
  170.  *     notetag in the weapon note :
  171.  *         <Swap Gauge n: AMMO>
  172.  *     ...where n is the number of the gauge you want to replace.
  173.  *     Instead of a normal HP/MP/TP gauge, you will then have the amount of
  174.  *     ammunition left for the currently equipped weapon.
  175.  * - For skills :
  176.  *   + The remaining amount for each ammunition type can be showed
  177.  *     together with cost in the skill window.
  178.  *   + It can also be displayed after the skill description, in the help
  179.  *     window. This is the default option.
  180.  *     In that case, you should keep the skill description within one unique
  181.  *     line with no line-break at the end, or else the remaining ammo will
  182.  *     not be visible.
  183.  *
  184.  * The text before ammunition left amounts can be customized with the following
  185.  *   notetag in the skill notebox:
  186.  *   <Ammo Left Text: xxx>
  187.  *   ... with xxx being your custom text.
  188.  * The name of the ammunition type can be displayed along with its icon with
  189.  * the following notetag in the weapon/skill notebox:
  190.  *   <Show Ammo Name>
  191.  *
  192.  * Also, in the case of equipment ammunition, several types of
  193.  * ammunition are possible but only one (the one equipped) will be displayed
  194.  * in any skill/help/etc window (or gauge). When there is no more ammunition,
  195.  * the system normally would not know which icon to use !
  196.  * There is a default icon for that, but you can put the following notetag
  197.  * in skill/weapon notebox to define which icon will be used :
  198.  *   <No Ammo Icon: i>
  199.  *   ... with i being the icon number.
  200.  * It is also possible to add details about the ammunition type currently
  201.  * equipped by adding the following notetag in the ammo notebox :
  202.  *   <Ammo Window Desc: xxx>
  203.  * Where 'xxx' is the description you want to give to your ammo.
  204.  * This description will show up in the skill help window and the ammunition
  205.  * window visible during actor command selection.
  206.  * Please that if you deactivate the ammo window or the display of remaining
  207.  * ammo amount with the corresponding plug-in parameters, you will of course
  208.  * not see any description of ammunition !
  209.  */
  210. //=============================================================================
  211.  
  212. //=============================================================================
  213. // Parameter Variables
  214. //=============================================================================
  215.  
  216. Unco.Parameters = $plugins.filter(function(p) {
  217.         return p.description.contains('<Unco Ammo>');
  218.     })[0].parameters; //Copied from Ellye, who thanks Iavra
  219. Unco.Param = Unco.Param || {};
  220.  
  221. Unco.Param.showAmmoLeftActorCommand = String(Unco.Parameters['Show Ammo Left When Actor Command']).toLowerCase();
  222. Unco.Param.showAmmoLeft = String(Unco.Parameters['Show Ammo Left In Skill Window']).toLowerCase();
  223. Unco.Param.ammoFontSize = Number(Unco.Parameters['Ammo Font Size']);
  224. Unco.Param.ammoFontColor = Number(Unco.Parameters['Ammo Font Color']);
  225. Unco.Param.showAmmoLeftInDesc = String(Unco.Parameters['Show Ammo Left In Help Window']).toLowerCase();
  226. Unco.Param.descAmmoLeftText = String(Unco.Parameters['Help Window Ammo Text']);
  227. Unco.Param.defaultNoAmmoIconId = parseInt(String(Unco.Parameters['No Ammo Icon']));
  228. Unco.Param.goldAmmoIconId = parseInt(String(Unco.Parameters['Gold Ammo Icon']));
  229. Unco.Param.showAmmoLeftForAttack = String(Unco.Parameters['Show Ammo Left In Actor Command Window']).toLowerCase();
  230. Unco.Param.compactCostDisplay = String(Unco.Parameters['Compact Cost Display']).toLowerCase();
  231.  
  232. //=============================================================================
  233. // DataManager
  234. //=============================================================================
  235.  
  236. Unco.AS.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  237. DataManager.isDatabaseLoaded = function() {
  238.     if (!Unco.AS.DataManager_isDatabaseLoaded.call(this)) return false;
  239.     this.processUncoItemAmmoNotetags($dataSkills);
  240.     this.processUncoSwitchNotetags($dataSkills);
  241.     this.processUncoGoldCostNotetags($dataSkills);
  242.     this.processUncoAmmoTextNotetags($dataSkills);
  243.     this.processUncoEquipAmmoNotetags($dataSkills);
  244.     this.processUncoAmmoLoadNotetags($dataSkills);
  245.     this.processUncoAmmoTextNotetags($dataWeapons);
  246.     this.processUncoItemAmmoNotetags($dataWeapons);
  247.     this.processUncoEquipAmmoNotetags($dataWeapons);
  248.     this.processUncoAmmoDescNotetags($dataArmors);
  249.     return true;
  250. };
  251.  
  252. DataManager.processUncoSwitchNotetags = function(group) {
  253.    for (var n = 1; n < group.length; n++) {
  254.       var obj = group[n];
  255.       var notedata = obj.note.split(/[\r\n]+/);
  256.      
  257.       obj.ammoGameSwitch = [];
  258.  
  259.       for (var i = 0; i < notedata.length; i++) {
  260.          var line = notedata[i];
  261.          if (line.match(/<(?:GAME)[ ](?:SWITCH):[ ](\d+)>/i)) {
  262.             var value = parseInt(RegExp.$1);
  263.             if (!isNaN(value)) {
  264.                obj.ammoGameSwitch[value] = true;
  265.             }
  266.          }
  267.       }
  268.    }
  269. }
  270.  
  271. DataManager.processUncoGoldCostNotetags = function(group) {
  272.    for (var n = 1; n < group.length; n++) {
  273.       var obj = group[n];
  274.       var notedata = obj.note.split(/[\r\n]+/);
  275.  
  276.       for (var i = 0; i < notedata.length; i++) {
  277.          var line = notedata[i];
  278.          if (line.match(/<(?:GOLD)[ ](?:COST):[ ](\d+)>/i)) {
  279.             var value = parseInt(RegExp.$1);
  280.             if (!isNaN(value)) {
  281.                obj.goldCost = value;
  282.             }
  283.          }
  284.       }
  285.    }
  286. }
  287.  
  288. DataManager.processUncoItemAmmoNotetags = function(group) {
  289.    for (var n = 1; n < group.length; n++) {
  290.       var obj = group[n];
  291.       var notedata = obj.note.split(/[\r\n]+/);
  292.  
  293.       obj.itemAmmoCost = [];
  294.  
  295.       for (var i = 0; i < notedata.length; i++) {
  296.          var line = notedata[i];
  297.          if (line.match(/<(?:AMMO)[ ](\d+)[ ](?:ITEM):[ ](\d+)>/i)) {
  298.             var index = parseInt(RegExp.$1);
  299.             var value = parseInt(RegExp.$2);
  300.             if ( (!isNaN(index)) && (!isNaN(value)) ) {
  301.                obj.itemAmmoCost[index] = value;
  302.                if (DataManager.isWeapon(obj)) {
  303.                   if (typeof $dataItems[index].isItemAmmoForWeapon === 'undefined') $dataItems[index].isItemAmmoForWeapon = [];
  304.                   $dataItems[index].isItemAmmoForWeapon[obj.id] = value;
  305.                } else {
  306.                   if (typeof $dataItems[index].isItemAmmoForSkill === 'undefined') $dataItems[index].isItemAmmoForSkill = [];
  307.                   $dataItems[index].isItemAmmoForSkill[obj.id] = value;
  308.                }
  309.             }
  310.          }
  311.       }
  312.    }
  313. }
  314.  
  315. DataManager.processUncoEquipAmmoNotetags = function(group) {
  316.    for (var n = 1; n < group.length; n++) {
  317.       var obj = group[n];
  318.       var notedata = obj.note.split(/[\r\n]+/);
  319.  
  320.       obj.equipAmmoCost = [];
  321.       obj.weaponAmmoCost = [];
  322.  
  323.       for (var i = 0; i < notedata.length; i++) {
  324.          var line = notedata[i];
  325.          if (line.match(/<(?:AMMO)[ ](\d+)[ ](?:EQUIP):[ ](\d+)>/i)) {
  326.             var index = parseInt(RegExp.$1);
  327.             var value = parseInt(RegExp.$2);
  328.             if ( (!isNaN(index)) && (!isNaN(value)) ) {
  329.                obj.equipAmmoCost[index] = value;
  330.                if (DataManager.isWeapon(obj)) {
  331.                   if (typeof $dataArmors[index].isEquipAmmoForWeapon === 'undefined') $dataArmors[index].isEquipAmmoForWeapon = [];
  332.                   $dataArmors[index].isEquipAmmoForWeapon[obj.id] = value;
  333.                } else {
  334.                   if (typeof $dataArmors[index].isEquipAmmoForSkill === 'undefined') $dataArmors[index].isEquipAmmoForSkill = [];
  335.                   $dataArmors[index].isEquipAmmoForSkill[obj.id] = value;
  336.                }
  337.             }
  338.          }
  339.          if (line.match(/<(?:AMMO)[ ](\d+)[ ](?:WEAPON):[ ](\d+)>/i)) {
  340.             var index = parseInt(RegExp.$1);
  341.             var value = parseInt(RegExp.$2);
  342.             if ( (!isNaN(index)) && (!isNaN(value)) ) {
  343.                obj.weaponAmmoCost[index] = value;
  344.                if (DataManager.isWeapon(obj)) {
  345.                   if (typeof $dataWeapons[index].isWeaponAmmoForWeapon === 'undefined') $dataWeapons[index].isWeaponAmmoForWeapon = [];
  346.                   $dataWeapons[index].isWeaponAmmoForWeapon[obj.id] = value;
  347.                } else {
  348.                   if (typeof $dataWeapons[index].isWeaponAmmoForSkill === 'undefined') $dataWeapons[index].isWeaponAmmoForSkill = [];
  349.                   $dataWeapons[index].isWeaponAmmoForSkill[obj.id] = value;
  350.                }
  351.             }
  352.          }
  353.       }
  354.    }
  355. }
  356.  
  357. DataManager.isItemAmmo = function(item) {
  358.    return this.isItem(item) && (item.isItemAmmoForWeapon || item.isItemAmmoForSkill);
  359. };
  360. DataManager.isEquipAmmo = function(item) {
  361.    return this.isArmor(item) && (item.isEquipAmmoForWeapon || item.isEquipAmmoForSkill);
  362. };
  363. DataManager.isWeaponAmmo = function(item) {
  364.    return this.isWeapon(item) && (item.isWeaponAmmoForWeapon || item.isWeaponAmmoForSkill);
  365. };
  366. DataManager.isAmmo = function(item) {
  367.    return (this.isItemAmmo(item) || this.isEquipAmmo(item) || this.isWeaponAmmo(item));
  368. };
  369.  
  370. DataManager.processUncoAmmoTextNotetags = function(group) {
  371.    for (var n = 1; n < group.length; n++) {
  372.       var obj = group[n];
  373.       var notedata = obj.note.split(/[\r\n]+/);
  374.       for (var i = 0; i < notedata.length; i++) {
  375.          var line = notedata[i];
  376.          if (line.match(/<(?:AMMO)[ ](?:LEFT)[ ](?:TEXT):[ ](.*)>/i)) {
  377.             obj.ammoText = String(RegExp.$1);
  378.          }
  379.          if (line.match(/<(?:NO)[ ](?:AMMO)[ ](?:ICON):[ ](\d+)>/i)) {
  380.             obj.noAmmoIconId = parseInt(RegExp.$1);
  381.          }
  382.          if (line.match(/<(?:SHOW)[ ](?:AMMO)[ ](?:NAME)>/i)) {
  383.             obj.showAmmoName = true;
  384.          }
  385.       }
  386.    }
  387. };
  388.  
  389. DataManager.processUncoAmmoLoadNotetags = function(group) {
  390.    for (var n = 1; n < group.length; n++) {
  391.       var obj = group[n];
  392.       var notedata = obj.note.split(/[\r\n]+/);
  393.       for (var i = 0; i < notedata.length; i++) {
  394.          var line = notedata[i];
  395.          if (line.match(/<(?:AMMO)[ ](\d+)[ ](?:LOAD):[ ](\d+)>/i)) {
  396.             var index = parseInt(RegExp.$1);
  397.             var equid = parseInt(RegExp.$2);
  398.             if ( (!isNaN(index)) && (!isNaN(equid)) ) {
  399.                obj.ammoLoadIndex = index;
  400.                obj.ammoLoadSlot = equid;
  401.             }
  402.          }
  403.       }
  404.    }
  405. };
  406.  
  407. DataManager.processUncoAmmoDescNotetags = function(group) {
  408.    for (var n = 1; n < group.length; n++) {
  409.       var obj = group[n];
  410.       var notedata = obj.note.split(/[\r\n]+/);
  411.       for (var i = 0; i < notedata.length; i++) {
  412.          var line = notedata[i];
  413.          if (line.match(/<(?:AMMO)[ ](?:WINDOW)[ ](?:DESC):[ ](.*)>/i)) {
  414.             obj.ammoDesc = String(RegExp.$1);
  415.          }
  416.       }
  417.    }
  418. };
  419.  
  420. //=============================================================================
  421. // Game_BattlerBase
  422. //=============================================================================
  423.  
  424. Unco.AS.Game_BattlerBase_canEquipArmor = Game_BattlerBase.prototype.canEquipArmor;
  425. Game_BattlerBase.prototype.canEquipArmor = function(item) {
  426.    if (typeof $dataArmors[item.id].isEquipAmmoForWeapon !== 'undefined') {
  427.       var ok = false;
  428.       if (this._equips[0].itemId() > 0) {
  429.          var EquippedWeaponId = ( (typeof $dataWeapons[this._equips[0].itemId()].baseItemId === 'undefined') ? this._equips[0].itemId() : $dataWeapons[this._equips[0].itemId()].baseItemId );
  430.          for (var weaponId in $dataArmors[item.id].isEquipAmmoForWeapon) {
  431.             weaponId = parseInt(weaponId);
  432.             if (weaponId === EquippedWeaponId) {
  433.                ok = true;
  434.                break;
  435.             }
  436.          }
  437.       }
  438.       if (ok === false) return false;
  439.    }
  440.    return Unco.AS.Game_BattlerBase_canEquipArmor.call(this,item);
  441. };
  442.  
  443. Unco.AS.Game_BattlerBase_canEquipWeapon = Game_BattlerBase.prototype.canEquipWeapon;
  444. Game_BattlerBase.prototype.canEquipWeapon = function(item) {
  445.    if (typeof $dataWeapons[item.id].isWeaponAmmoForWeapon !== 'undefined') {
  446.       var ok = false;
  447.       var wantedWeaponId = ( (typeof $dataWeapons[item.id].baseItemId === 'undefined') ? item.id : $dataWeapons[item.id].baseItemId );
  448.       var EquippedWeaponId = 0;
  449.       if (this._equips[0].itemId() > 0) {
  450.          EquippedWeaponId = ( (typeof $dataWeapons[this._equips[0].itemId()].baseItemId === 'undefined') ? this._equips[0].itemId() : $dataWeapons[this._equips[0].itemId()].baseItemId );
  451.       }
  452.       for (var weaponId in $dataWeapons[item.id].isWeaponAmmoForWeapon) {
  453.          weaponId = parseInt(weaponId);
  454.          if (this._equips[0].itemId() > 0) {
  455.             if (weaponId === EquippedWeaponId) {
  456.                ok = true;
  457.                break;
  458.             }
  459.          }
  460.          if (weaponId === wantedWeaponId) {
  461.             ok = true;
  462.             break;
  463.          }
  464.       }
  465.       if (ok === false) return false;
  466.    }
  467.    return Unco.AS.Game_BattlerBase_canEquipWeapon.call(this,item);
  468. };
  469.  
  470. Game_Party.prototype.getItemAmount = function(baseItem) {
  471.    if (!baseItem) return 0;
  472.    var amount = 0;
  473.    if (Imported.YEP_ItemCore) {
  474.       var maxItems = 0;
  475.       if (DataManager.isItem(baseItem)) {
  476.          maxItems = Yanfly.Param.ItemMaxItems;
  477.       }
  478.       if (DataManager.isWeapon(baseItem))  {
  479.          maxItems = Yanfly.Param.ItemMaxWeapons;
  480.       }
  481.       if (DataManager.isArmor(baseItem))  {
  482.          maxItems = Yanfly.Param.ItemMaxArmors;
  483.       }        
  484.       if (maxItems > 0) {
  485.          if (baseItem.nonIndepdent === false) {
  486.             if (DataManager.isItem(baseItem)) {
  487.                baseItem = ( baseItem.baseItemId ? $dataItems[baseItem.baseItemId] : baseItem );
  488.                var group = this.items();
  489.             }
  490.             if (DataManager.isWeapon(baseItem))  {
  491.                baseItem = ( baseItem.baseItemId ? $dataWeapons[baseItem.baseItemId] : baseItem );
  492.                var group = this.weapons();
  493.             }
  494.             if (DataManager.isArmor(baseItem))  {
  495.                baseItem = ( baseItem.baseItemId ? $dataArmors[baseItem.baseItemId] : baseItem );
  496.                var group = this.armors();
  497.             }        
  498.             var baseItemId = baseItem.id;
  499.             for (var i = 0; i < group.length; ++i) {
  500.                var item = group[i];
  501.                if (!item) continue;
  502.                if (!item.baseItemId) continue;
  503.                if (item.baseItemId !== baseItemId) continue;
  504.                amount += 1;
  505.             }
  506.             return amount;
  507.          }
  508.       }
  509.    }
  510.    if ( DataManager.isItem(baseItem) && $gameParty._items[baseItem.id]) amount = $gameParty._items[baseItem.id];
  511.    if ( DataManager.isArmor(baseItem) && $gameParty._armors[baseItem.id]) amount = $gameParty._armors[baseItem.id];
  512.    if ( DataManager.isWeapon(baseItem) && $gameParty._weapons[baseItem.id]) amount = $gameParty._weapons[baseItem.id];
  513.    return amount;
  514. }
  515.  
  516. Unco.AS.Game_BattlerBase_canPaySkillCost =
  517.    Game_BattlerBase.prototype.canPaySkillCost;
  518. Game_BattlerBase.prototype.canPaySkillCost = function(skill) {
  519.    if (!this.canPaySkillAmmoCost(skill)) return false;
  520.    return Unco.AS.Game_BattlerBase_canPaySkillCost.call(this, skill);
  521. };
  522.  
  523. Game_BattlerBase.prototype.canPaySkillAmmoCost = function(skill) {
  524.    if (skill.id === this.attackSkillId()) {
  525.       if (typeof this._equips !== 'undefined') {
  526.          if (this._equips[0]._itemId > 0) {
  527.             skill = $dataWeapons[ ( (typeof $dataWeapons[this._equips[0]._itemId].baseItemId === 'undefined') ? this._equips[0]._itemId : $dataWeapons[this._equips[0]._itemId].baseItemId ) ];
  528.          }
  529.       }
  530.    }
  531.    for (var switchId in skill.ammoGameSwitch) {
  532.       switchId = parseInt(switchId);
  533.       if (!isNaN(switchId) && (switchId > 0)) {
  534.          if ($gameSwitches.value(switchId) === false) {
  535.             return false;
  536.          }
  537.       }
  538.    }
  539.    if (!this.canPaySkillReloadAmmoCost(skill)) return false;
  540.    if (!this.canPaySkillItemAmmoCost(skill)) return false;
  541.    if (!this.canPaySkillEquipAmmoCost(skill)) return false;
  542.    return true;
  543. };
  544.  
  545. Game_BattlerBase.prototype.canPaySkillReloadAmmoCost = function(skill) {
  546.    if ((typeof skill.ammoLoadIndex === 'number') && (typeof skill.ammoLoadSlot === 'number')) {
  547.       if (this.hasArmor($dataArmors[skill.ammoLoadIndex]) || ($gameParty.getItemAmount($dataArmors[skill.ammoLoadIndex]) < 1)) {
  548.          return false;
  549.       }
  550.    }
  551.    return true;
  552. };
  553.  
  554. Game_BattlerBase.prototype.canPaySkillItemAmmoCost = function(skill) {
  555.    if (typeof skill.goldCost === 'number') {
  556.       if (skill.goldCost > $gameParty.gold()) {
  557.          return false;
  558.       }
  559.    }
  560.    for (var ammoId in skill.itemAmmoCost) {
  561.       ammoId = parseInt(ammoId);
  562.       if (!isNaN(ammoId) && (ammoId > 0)) {
  563.          var nbOwned = $gameParty.getItemAmount($dataItems[ammoId]);
  564.          if (skill.itemAmmoCost[ammoId] > nbOwned) {
  565.             return false;
  566.          }
  567.       }
  568.    }
  569.    return true;
  570. };
  571.  
  572.  
  573. Game_BattlerBase.prototype.canPaySkillEquipAmmoCost = function(skill) {
  574.    if (!this.canPaySkillArmorAmmoCost(skill)) return false;
  575.    if (!this.canPaySkillWeaponAmmoCost(skill)) return false;
  576.    return true;
  577. };
  578.  
  579. Game_BattlerBase.prototype.canPaySkillArmorAmmoCost = function(skill) {
  580.    var retVal = true;
  581.    for (var ammoId in skill.equipAmmoCost) {
  582.       ammoId = parseInt(ammoId);
  583.       if (!isNaN(ammoId) && (ammoId > 0)) {
  584.          if (this.hasArmor($dataArmors[ammoId])) {
  585.             skill.equipAmmoCost[ammoId] = parseInt(skill.equipAmmoCost[ammoId]);
  586.             if (!isNaN(skill.equipAmmoCost[ammoId])) {
  587.                var nbOwned = 1+$gameParty.getItemAmount($dataArmors[ammoId]);
  588.                if (skill.equipAmmoCost[ammoId] <= nbOwned) {
  589.                   return true;
  590.                }        
  591.             } else retVal = false;
  592.          } else retVal = false;
  593.       }
  594.    }
  595.    return retVal;
  596. };
  597.  
  598. Game_BattlerBase.prototype.canPaySkillWeaponAmmoCost = function(skill) {
  599.    var retVal = true;
  600.    for (var ammoId in skill.weaponAmmoCost) {
  601.       ammoId = parseInt(ammoId);
  602.       if (!isNaN(ammoId) && (ammoId > 0)) {
  603.          if (this.hasWeapon($dataWeapons[ammoId])) {
  604.             skill.weaponAmmoCost[ammoId] = parseInt(skill.weaponAmmoCost[ammoId]);
  605.             if (!isNaN(skill.weaponAmmoCost[ammoId])) {
  606.                var nbOwned = 1+$gameParty.getItemAmount($dataWeapons[ammoId]);
  607.                if (skill.weaponAmmoCost[ammoId] <= nbOwned) {
  608.                   return true;
  609.                }        
  610.             } else retVal = false;
  611.          } else retVal = false;
  612.       }
  613.    }
  614.    return retVal;
  615. };
  616.  
  617. Unco.AS.Game_BattlerBase_paySkillCost = Game_BattlerBase.prototype.paySkillCost;
  618. Game_BattlerBase.prototype.paySkillCost = function(skill) {
  619.     Unco.AS.Game_BattlerBase_paySkillCost.call(this, skill);
  620.     this.paySkillAmmoCost(skill);
  621. };
  622.  
  623. Game_BattlerBase.prototype.paySkillAmmoCost = function(skill) {
  624.    if (skill.id === this.attackSkillId()) {
  625.       if (typeof this._equips !== 'undefined') {
  626.          if (this._equips[0]._itemId > 0) {
  627.             skill = $dataWeapons[ ( (typeof $dataWeapons[this._equips[0]._itemId].baseItemId === 'undefined') ? this._equips[0]._itemId : $dataWeapons[this._equips[0]._itemId].baseItemId ) ];
  628.          }
  629.       }
  630.    }
  631.    this.reloadAmmo(skill);
  632.    this.paySkillItemAmmoCost(skill);
  633.    this.paySkillEquipAmmoCost(skill);
  634. };
  635.  
  636. Game_BattlerBase.prototype.reloadAmmo = function(skill) {
  637.    if ((typeof skill.ammoLoadIndex === 'number') && (typeof skill.ammoLoadSlot === 'number')) {
  638.       this.changeEquipById(skill.ammoLoadSlot,skill.ammoLoadIndex);
  639.    }
  640. };
  641.  
  642. Game_BattlerBase.prototype.paySkillItemAmmoCost = function(skill) {
  643.    if (typeof skill.goldCost === 'number') {
  644.       $gameParty.loseGold(skill.goldCost);
  645.    }
  646.    for (var ammoId in skill.itemAmmoCost) {
  647.       ammoId = parseInt(ammoId);
  648.       if (!isNaN(ammoId) && (ammoId > 0)) {
  649.          $gameParty.gainItem($dataItems[ammoId],-skill.itemAmmoCost[ammoId]);
  650.       }
  651.    }
  652. };
  653.  
  654. Game_BattlerBase.prototype.paySkillEquipAmmoCost = function(skill) {
  655.    for (var ammoId in skill.equipAmmoCost) {
  656.       ammoId = parseInt(ammoId);
  657.       if (!isNaN(ammoId) && (ammoId > 0)) {
  658.          skill.equipAmmoCost[ammoId] = parseInt(skill.equipAmmoCost[ammoId]);
  659.          if (this.hasArmor($dataArmors[ammoId]) && !isNaN(skill.equipAmmoCost[ammoId]) && (skill.equipAmmoCost[ammoId] > 0)) {
  660.             if ($gameParty.getItemAmount($dataArmors[ammoId]) > 0) {
  661.                $gameParty.gainItem($dataArmors[ammoId],-Math.max(skill.equipAmmoCost[ammoId]-1,0));
  662.             }
  663.             if (  $gameParty.getItemAmount($dataArmors[ammoId]) === 0  ) {
  664.                this._markForEquipDiscard = ammoId;
  665.             } else {
  666.                $gameParty.gainItem($dataArmors[ammoId],-1);
  667.             }
  668.          }
  669.       }
  670.    }
  671.    for (var ammoId in skill.weaponAmmoCost) {
  672.       ammoId = parseInt(ammoId);
  673.       if (!isNaN(ammoId) && (ammoId > 0)) {
  674.          skill.weaponAmmoCost[ammoId] = parseInt(skill.weaponAmmoCost[ammoId]);
  675.          if (this.hasWeapon($dataWeapons[ammoId]) && !isNaN(skill.weaponAmmoCost[ammoId]) && (skill.weaponAmmoCost[ammoId] > 0)) {
  676.             if ($gameParty.getItemAmount($dataWeapons[ammoId]) > 0) {
  677.                $gameParty.gainItem($dataWeapons[ammoId],-Math.max(skill.weaponAmmoCost[ammoId]-1,0));
  678.             }
  679.             if (  $gameParty.getItemAmount($dataWeapons[ammoId]) === 0  ) {
  680.                this._markForWeaponDiscard = ammoId;
  681.             } else {
  682.                $gameParty.gainItem($dataWeapons[ammoId],-1);
  683.             }
  684.          }
  685.       }
  686.    }
  687. };
  688.  
  689.  
  690. //=============================================================================
  691. // BattleManager
  692. //=============================================================================
  693. Unco.AS.BattleManager_endAction = BattleManager.endAction;
  694. BattleManager.endAction = function() {
  695.    Unco.AS.BattleManager_endAction.call(this);
  696.    if (typeof this._subject._markForEquipDiscard !== 'undefined') {
  697.       for (var i in this._subject.equips()) {
  698.          if ((typeof this._subject.equips()[i] !== 'undefined') && (this._subject.equips()[i] !== null)) {
  699.             if (typeof this._subject.equips()[i].baseItemId !== 'undefined') {
  700.                if (this._subject.equips()[i].baseItemId === this._subject._markForEquipDiscard) {
  701.                   this._subject._markForEquipDiscard = this._subject.equips()[i].id;
  702.                }
  703.             }        
  704.          }
  705.       }
  706.       this._subject.discardEquip($dataArmors[this._subject._markForEquipDiscard]);      
  707.       delete this._subject._markForEquipDiscard;
  708.    }
  709.    if (typeof this._subject._markForWeaponDiscard !== 'undefined') {
  710.       for (var i in this._subject.equips()) {
  711.          if ((typeof this._subject.equips()[i] !== 'undefined') && (this._subject.equips()[i] !== null)) {
  712.             if (typeof this._subject.equips()[i].baseItemId !== 'undefined') {
  713.                if (this._subject.equips()[i].baseItemId === this._subject._markForWeaponDiscard) {
  714.                   this._subject._markForWeaponDiscard = this._subject.equips()[i].id;
  715.                }
  716.             }        
  717.          }
  718.       }
  719.       this._subject.discardEquip($dataWeapons[this._subject._markForWeaponDiscard]);      
  720.       delete this._subject._markForWeaponDiscard;
  721.    }
  722. };
  723.  
  724. //=============================================================================
  725. // Window_SkillList
  726. //=============================================================================
  727.  
  728. if ((typeof Imported.YEP_SkillCore === 'undefined') || (Imported.YEP_SkillCore !== true)) {  
  729.    Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) {
  730.       var dw = width;
  731.       if (this._actor.skillTpCost(skill) > 0) {
  732.          this.changeTextColor(this.tpCostColor());
  733.          var text = this._actor.skillTpCost(skill);
  734.          this.drawText(text, x, y, dw, 'right');
  735.          dw -= this.textWidth(text);
  736.       }
  737.       if (dw !== width) {
  738.          var text = ' ';
  739.          this.drawText(text, x, y, dw, 'right');
  740.          dw -= this.textWidth(text);
  741.       }
  742.       if (this._actor.skillMpCost(skill) > 0) {
  743.          this.changeTextColor(this.mpCostColor());
  744.          var text = this._actor.skillMpCost(skill)
  745.          this.drawText(text, x, y, dw, 'right');
  746.          dw -= this.textWidth(text);
  747.       }
  748.       return dw;
  749.    }  
  750. }
  751.  
  752.  
  753. Unco.AS.Window_SkillList_drawSkillCost = Window_SkillList.prototype.drawSkillCost;  
  754.    
  755. Window_SkillList.prototype.drawSkillCost = function(skill, wx, wy, width) {
  756.    var dw = width;
  757.    dw = this.drawAmmoCost(skill, wx, wy, dw);
  758.    return Unco.AS.Window_SkillList_drawSkillCost.call(this,skill, wx, wy, dw);
  759. };
  760.    
  761.  
  762. Window_SkillList.prototype.drawAmmoCost = function(skill, wx, wy, dw) {
  763.    if (typeof skill.goldCost === 'number') {      
  764.       this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  765.       var text = '';
  766.       if (Unco.Param.compactCostDisplay === 'false') text = text + 'x';
  767.       text = text + String(skill.goldCost);
  768.       this.contents.fontSize = Unco.Param.ammoFontSize;
  769.       if (Unco.Param.compactCostDisplay === 'false') this.drawText(text, wx, wy, dw, 'right');
  770.       if (Unco.Param.compactCostDisplay === 'false') dw -= this.textWidth(text);
  771.       if (Unco.Param.goldAmmoIconId > 0) {
  772.          var iw = wx + dw - Window_Base._iconWidth;
  773.          this.drawIcon(Unco.Param.goldAmmoIconId, iw, wy + 2);
  774.          if (Unco.Param.compactCostDisplay === 'true') {
  775.             this.drawText(text, iw, wy, Window_Base._iconWidth, 'center');
  776.          }
  777.          dw -= Window_Base._iconWidth + 2;
  778.       }
  779.       this.resetFontSettings();
  780.    }
  781.    for (var ammoId in skill.itemAmmoCost) {
  782.       ammoId = parseInt(ammoId);
  783.       if (!isNaN(ammoId) && (ammoId > 0)) {
  784.          this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  785.          var text = '';
  786.          if (Unco.Param.compactCostDisplay === 'false') text = text + 'x';
  787.          text = text + String(skill.itemAmmoCost[ammoId]);
  788.          if (Unco.Param.compactCostDisplay === 'false') text = text + ( (Unco.Param.showAmmoLeft === 'false') ? "" : (  "/" + $gameParty.getItemAmount($dataItems[ammoId])  )  );
  789.          this.contents.fontSize = Unco.Param.ammoFontSize;
  790.          if (Unco.Param.compactCostDisplay === 'false') this.drawText(text, wx, wy, dw, 'right');
  791.          if (Unco.Param.compactCostDisplay === 'false') dw -= this.textWidth(text);
  792.          if ($dataItems[ammoId].iconIndex > 0) {
  793.             var iw = wx + dw - Window_Base._iconWidth;
  794.             this.drawIcon($dataItems[ammoId].iconIndex, iw, wy + 2);
  795.             if (Unco.Param.compactCostDisplay === 'true') {
  796.                this.drawText(text, iw, wy, Window_Base._iconWidth, 'center');
  797.             }
  798.             dw -= Window_Base._iconWidth + 2;
  799.          }
  800.          this.resetFontSettings();
  801.       }
  802.    }
  803.    var zeroArmorAmmo = false;
  804.    for (var ammoId in skill.equipAmmoCost) {
  805.       var ammoId = parseInt(ammoId);
  806.       if (!isNaN(ammoId) && (ammoId > 0)) {
  807.          if (this._actor.hasArmor($dataArmors[ammoId])) {
  808.             this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  809.             var text = '';
  810.             if (Unco.Param.compactCostDisplay === 'false') text = text + 'x';
  811.             text = text + String(skill.equipAmmoCost[ammoId])
  812.             if (Unco.Param.compactCostDisplay === 'false') text = text + ( (Unco.Param.showAmmoLeft === 'false') ? "" : (  "/" + ( 1 + $gameParty.getItemAmount($dataArmors[ammoId]) )  )  );
  813.             this.contents.fontSize = Unco.Param.ammoFontSize;
  814.             if (Unco.Param.compactCostDisplay === 'false') this.drawText(text, wx, wy, dw, 'right');
  815.             if (Unco.Param.compactCostDisplay === 'false') dw -= this.textWidth(text);
  816.             this.resetFontSettings();
  817.             if ($dataArmors[ammoId].iconIndex > 0) {
  818.                var iw = wx + dw - Window_Base._iconWidth;
  819.                this.drawIcon($dataArmors[ammoId].iconIndex, iw, wy + 2);
  820.                if (Unco.Param.compactCostDisplay === 'true') {
  821.                   this.drawText(text, iw, wy, Window_Base._iconWidth, 'center');
  822.                }
  823.                dw -= Window_Base._iconWidth + 2;
  824.             }
  825.             zeroArmorAmmo = false;
  826.             break;
  827.          } else {
  828.             zeroArmorAmmo = true;
  829.             if (typeof smallestCost !== 'Number') {
  830.                var smallestCost = skill.equipAmmoCost[ammoId];
  831.             } else {
  832.                if (skill.equipAmmoCost[ammoId] < smallestCost) smallestCost = skill.equipAmmoCost[ammoId];
  833.             }
  834.          }
  835.       }
  836.    }
  837.    if (zeroArmorAmmo === true) {
  838.        this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  839.        var text = '';
  840.        if (Unco.Param.compactCostDisplay === 'false') text = text + 'x';
  841.        text = text + String(smallestCost);
  842.        this.contents.fontSize = Unco.Param.ammoFontSize;
  843.        if (Unco.Param.compactCostDisplay === 'false') this.drawText(text, wx, wy, dw, 'right');
  844.        if (Unco.Param.compactCostDisplay === 'false') dw -= this.textWidth(text);
  845.        var iw = wx + dw - Window_Base._iconWidth;
  846.        this.drawIcon( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) , iw, wy + 2);
  847.        if (Unco.Param.compactCostDisplay === 'true') this.drawText(text, iw, wy, Window_Base._iconWidth, 'center');
  848.        dw -= Window_Base._iconWidth + 2;
  849.        this.resetFontSettings();
  850.    }
  851.    var zeroWeaponAmmo = false;
  852.    for (var ammoId in skill.weaponAmmoCost) {
  853.       var ammoId = parseInt(ammoId);
  854.       if (!isNaN(ammoId) && (ammoId > 0)) {
  855.          if (this._actor.hasWeapon($dataWeapons[ammoId])) {
  856.             this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  857.             var text = '';
  858.             if (Unco.Param.compactCostDisplay === 'false') text = text + 'x';
  859.             text = text + String(skill.weaponAmmoCost[ammoId])
  860.             if (Unco.Param.compactCostDisplay === 'false') text = text + ( (Unco.Param.showAmmoLeft === 'false') ? "" : (  "/" + ( 1 + $gameParty.getItemAmount($dataWeapons[ammoId]) )  )  );
  861.             this.contents.fontSize = Unco.Param.ammoFontSize;
  862.             if (Unco.Param.compactCostDisplay === 'false') this.drawText(text, wx, wy, dw, 'right');
  863.             if (Unco.Param.compactCostDisplay === 'false') dw -= this.textWidth(text);
  864.             this.resetFontSettings();
  865.             if ($dataWeapons[ammoId].iconIndex > 0) {
  866.                var iw = wx + dw - Window_Base._iconWidth;
  867.                this.drawIcon($dataWeapons[ammoId].iconIndex, iw, wy + 2);
  868.                if (Unco.Param.compactCostDisplay === 'true') {
  869.                   this.drawText(text, iw, wy, Window_Base._iconWidth, 'center');
  870.                }
  871.                dw -= Window_Base._iconWidth + 2;
  872.             }
  873.             zeroWeaponAmmo = false;
  874.             break;
  875.          } else {
  876.             zeroWeaponAmmo = true;
  877.             if (typeof smallestCost !== 'Number') {
  878.                var smallestCost = skill.weaponAmmoCost[ammoId];
  879.             } else {
  880.                if (skill.weaponAmmoCost[ammoId] < smallestCost) smallestCost = skill.weaponAmmoCost[ammoId];
  881.             }
  882.          }
  883.       }
  884.    }
  885.    if (zeroWeaponAmmo === true) {
  886.        this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  887.        var text = '';
  888.        if (Unco.Param.compactCostDisplay === 'false') text = text + 'x';
  889.        text = text + String(smallestCost);
  890.        this.contents.fontSize = Unco.Param.ammoFontSize;
  891.        if (Unco.Param.compactCostDisplay === 'false') this.drawText(text, wx, wy, dw, 'right');
  892.        if (Unco.Param.compactCostDisplay === 'false') dw -= this.textWidth(text);
  893.        var iw = wx + dw - Window_Base._iconWidth;
  894.        this.drawIcon( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) , iw, wy + 2);
  895.        if (Unco.Param.compactCostDisplay === 'true') this.drawText(text, iw, wy, Window_Base._iconWidth, 'center');
  896.        dw -= Window_Base._iconWidth + 2;
  897.        this.resetFontSettings();
  898.    }
  899.    return dw;
  900. };
  901.  
  902.  
  903. //=============================================================================
  904. // Window_Help
  905. //=============================================================================
  906.  
  907. Window_Help.prototype.getAmmoAmountText = function(item) {
  908.    var text = '';
  909.    if (typeof item !== 'undefined') {
  910.       var introText = ( (typeof item.ammoText !== 'undefined') ? item.ammoText : Unco.Param.descAmmoLeftText);
  911.       if ((DataManager.isSkill(item)) && (Unco.Param.showAmmoLeftInDesc === 'true') && introText !== "") {
  912.          var skill = item;
  913.          var withAmmo = false;
  914.          if (typeof skill.goldCost === 'number') {
  915.             text = text + '\\i[' + String(Unco.Param.goldAmmoIconId) + ']';
  916.             text = text + 'x' + $gameParty.gold();
  917.             withAmmo = true;
  918.          }
  919.          for (var ammoId in skill.itemAmmoCost) {
  920.             var cost = skill.itemAmmoCost[ammoId];
  921.             ammoId = parseInt(ammoId);
  922.             if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(cost)) {
  923.                var cost = parseInt(cost);
  924.                var itemOwned = ($gameParty.getItemAmount($dataItems[ammoId]) > 0);
  925.                text = text + '\\i[' + String($dataItems[ammoId].iconIndex) + ']';
  926.                text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataItems[ammoId].name + ' ' );
  927.                text = text + ( ((cost <= 0) && itemOwned) ? '' : ( 'x' + String( $gameParty.getItemAmount($dataItems[ammoId]) ) )  );
  928.                withAmmo = true;
  929.             }
  930.          }
  931.          var zeroEquipAmmo = false;
  932.          for (var ammoId in skill.equipAmmoCost) {
  933.             var cost = skill.equipAmmoCost[ammoId];
  934.             var ammoId = parseInt(ammoId);
  935.             if (!isNaN(ammoId) && (ammoId > 0) && (typeof this._actor !== 'undefined')) {
  936.                cost = parseInt(cost);
  937.                withAmmo = true;
  938.                if (this._actor.hasArmor($dataArmors[ammoId])) {
  939.                   text = text + '\\i[' + String($dataArmors[ammoId].iconIndex) + ']';
  940.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataArmors[ammoId].name + ' ' );
  941.                   text = text + ( (cost <= 0) ? '' : 'x' + String( 1 + $gameParty.getItemAmount($dataArmors[ammoId]) ) );
  942.                   text = text + ( (typeof $dataArmors[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataArmors[ammoId].ammoDesc + ')' );
  943.                   zeroEquipAmmo = false;
  944.                   break;
  945.                } else {
  946.                   zeroEquipAmmo = true;
  947.                }
  948.             }
  949.          }
  950.          if (zeroEquipAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  951.          var zeroWeaponAmmo = false;
  952.          for (var ammoId in skill.weaponAmmoCost) {
  953.             var cost = skill.weaponAmmoCost[ammoId];
  954.             var ammoId = parseInt(ammoId);
  955.             if (!isNaN(ammoId) && (ammoId > 0) && (typeof this._actor !== 'undefined')) {
  956.                cost = parseInt(cost);
  957.                withAmmo = true;
  958.                if (this._actor.hasWeapon($dataWeapons[ammoId])) {
  959.                   text = text + '\\i[' + String($dataWeapons[ammoId].iconIndex) + ']';
  960.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataWeapons[ammoId].name + ' ' );
  961.                   text = text + ( (cost <= 0) ? '' : 'x' + String( 1 + $gameParty.getItemAmount($dataWeapons[ammoId]) ) );
  962.                   text = text + ( (typeof $dataWeapons[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataWeapons[ammoId].ammoDesc + ')' );
  963.                   zeroWeaponAmmo = false;
  964.                   break;
  965.                } else {
  966.                   zeroWeaponAmmo = true;
  967.                }
  968.             }
  969.          }
  970.          if (zeroWeaponAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  971.          if (withAmmo === true) text = '\n' + introText + ' : ' + text;
  972.       }
  973.    }
  974.    return text;
  975. }
  976.  
  977. Window_Help.prototype.setItem = function(item) {
  978.    this.setText(item ? item.description + this.getAmmoAmountText(item) : '');
  979. };
  980.  
  981. Unco.AS.Window_SkillList_setHelpWindowItem = Window_SkillList.prototype.setHelpWindowItem;
  982. Window_SkillList.prototype.setHelpWindowItem = function(item) {
  983.    if (this._helpWindow) {
  984.       this._helpWindow._actor = this._actor;
  985.    }
  986.    Unco.AS.Window_SkillList_setHelpWindowItem.call(this,item)
  987. };
  988.  
  989. //=============================================================================
  990. // Window_ActorCommand
  991. //=============================================================================
  992.  
  993. Window_ActorCommand.prototype.getAmmoText = function(skill) {
  994.     var ammoStr = '';  
  995.     if (Unco.Param.showAmmoLeftForAttack === 'true') {
  996.           for (var ammoId in skill.itemAmmoCost) {
  997.              var ammoId = parseInt(ammoId);
  998.              var ammoCost = parseInt(skill.itemAmmoCost[ammoId]);
  999.              if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(ammoCost) && (ammoCost > 0)) {
  1000.                 if (ammoStr !== '') ammoStr += '|';
  1001.                 ammoStr += String(  $gameParty.getItemAmount($dataItems[ammoId]) );              
  1002.              }
  1003.           }
  1004.           var zeroAmmo = false;
  1005.           for (var ammoId in skill.equipAmmoCost) {
  1006.              var ammoId = parseInt(ammoId);
  1007.              var ammoCost = parseInt(skill.equipAmmoCost[ammoId]);
  1008.              if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(ammoCost) && (ammoCost > 0)) {
  1009.                 if (this._actor.hasArmor($dataArmors[ammoId])) {
  1010.                    if (ammoStr !== '') ammoStr += '|';
  1011.                    ammoStr += String( 1+$gameParty.getItemAmount($dataArmors[ammoId]) );
  1012.                    zeroAmmo = false;
  1013.                    break;
  1014.                 } else {
  1015.                    zeroAmmo = true;
  1016.                 }
  1017.              }
  1018.           }
  1019.           if (zeroAmmo === true) {
  1020.              if (ammoStr !== '') ammoStr += '|';
  1021.              ammoStr += '0';
  1022.           }
  1023.           var zeroWeaponAmmo = false;
  1024.           for (var ammoId in skill.weaponAmmoCost) {
  1025.              var ammoId = parseInt(ammoId);
  1026.              var ammoCost = parseInt(skill.weaponAmmoCost[ammoId]);
  1027.              if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(ammoCost) && (ammoCost > 0)) {
  1028.                 if (this._actor.hasWeapon($dataWeapons[ammoId])) {
  1029.                    if (ammoStr !== '') ammoStr += '|';
  1030.                    ammoStr += String( 1+$gameParty.getItemAmount($dataWeapons[ammoId]) );
  1031.                    zeroWeaponAmmo = false;
  1032.                    break;
  1033.                 } else {
  1034.                    zeroWeaponAmmo = true;
  1035.                 }
  1036.              }
  1037.           }
  1038.           if (zeroWeaponAmmo === true) {
  1039.              if (ammoStr !== '') ammoStr += '|';
  1040.              ammoStr += '0';
  1041.           }
  1042.     }
  1043.     if (ammoStr !== '') ammoStr = '[' + ammoStr + ']';
  1044.     return ammoStr;
  1045. };
  1046.  
  1047. Unco.AS.Window_ActorCommand_addCommand = Window_ActorCommand.prototype.addCommand;
  1048. if (Imported.BOB_BattleCommandList === true) {
  1049.    Window_ActorCommand.prototype.addCommand = function(name, symbol, enabled, ext, icon) {
  1050.       if ((symbol === 'attack') && (this._actor._equips[0]) && (this._actor._equips[0]._itemId)) {
  1051.          var ammoStr = this.getAmmoText($dataWeapons[this._actor._equips[0]._itemId]);
  1052.          name = name + ammoStr;
  1053.       }
  1054.       if (symbol === 'customSkill') {
  1055.          var ammoStr = this.getAmmoText(ext);
  1056.          name = name + ammoStr;
  1057.       }
  1058.       Unco.AS.Window_ActorCommand_addCommand.call(this,name, symbol, enabled, ext, icon);
  1059.    };
  1060. } else {
  1061.    Window_ActorCommand.prototype.addCommand = function(name, symbol, enabled, ext) {
  1062.       if ((symbol === 'attack') && (this._actor._equips[0]) && (this._actor._equips[0]._itemId)) {
  1063.          var ammoStr = this.getAmmoText($dataWeapons[this._actor._equips[0]._itemId]);
  1064.          name = name + ammoStr;
  1065.       }
  1066.       Unco.AS.Window_ActorCommand_addCommand.call(this,name, symbol, enabled, ext);
  1067.    };
  1068. }
  1069.  
  1070. Unco.AS.Window_ActorCommand_setHelpWindowItem = Window_ActorCommand.prototype.setHelpWindowItem;
  1071. Window_ActorCommand.prototype.setHelpWindowItem = function(item) {
  1072.    if (this._helpWindow && this._actor) {
  1073.       this._helpWindow._actor = this._actor;
  1074.    }
  1075.    Unco.AS.Window_ActorCommand_setHelpWindowItem.call(this,item)
  1076. };
  1077.  
  1078.  
  1079.  
  1080. if (Imported.YEP_SkillCore === true) {
  1081. //=============================================================================
  1082. // Window_Base
  1083. //=============================================================================
  1084.    Window_Base.prototype.mustDrawActorAmmo = function(actor) {
  1085.       if (typeof actor._equips !== 'undefined') {
  1086.          if (actor._equips[0]._itemId > 0) {
  1087.             skill = $dataWeapons[actor._equips[0]._itemId];
  1088.             for (var ammoId in skill.itemAmmoCost) {
  1089.                var ammoId = parseInt(ammoId);
  1090.                if (!isNaN(ammoId) && (ammoId > 0)) {                
  1091.                   if (!isNaN(skill.itemAmmoCost[ammoId])) {
  1092.                      return true;
  1093.                   }
  1094.                }
  1095.             }
  1096.             for (var ammoId in skill.equipAmmoCost) {
  1097.                var ammoId = parseInt(ammoId);
  1098.                if (!isNaN(ammoId) && (ammoId > 0)) {                  
  1099.                   if (!isNaN(skill.equipAmmoCost[ammoId])) {
  1100.                      return true;
  1101.                   }
  1102.                }
  1103.             }
  1104.             for (var ammoId in skill.weaponAmmoCost) {
  1105.                var ammoId = parseInt(ammoId);
  1106.                if (!isNaN(ammoId) && (ammoId > 0)) {                  
  1107.                   if (!isNaN(skill.weaponAmmoCost[ammoId])) {
  1108.                      return true;
  1109.                   }
  1110.                }
  1111.             }
  1112.          }
  1113.       }
  1114.       return false;
  1115.    }
  1116.    Window_Base.prototype.drawActorAmmo = function(actor, x, y, width) {
  1117.       if (typeof actor._equips !== 'undefined') {
  1118.          if (actor._equips[0]._itemId > 0) {
  1119.             skill = $dataWeapons[ ( (typeof $dataWeapons[actor._equips[0]._itemId].baseItemId === 'undefined') ? actor._equips[0]._itemId : $dataWeapons[actor._equips[0]._itemId].baseItemId ) ];
  1120.             var dw = width;
  1121.             for (var ammoId in skill.itemAmmoCost) {
  1122.                var ammoId = parseInt(ammoId);
  1123.                if (!isNaN(ammoId) && (ammoId > 0)) {
  1124.                   var ammoCost = parseInt(skill.itemAmmoCost[ammoId]);              
  1125.                   this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1126.                   var text = (ammoCost <= 0) ? '' : 'x' + String( $gameParty.getItemAmount($dataItems[ammoId]) );
  1127.                   this.contents.fontSize = Unco.Param.ammoFontSize;
  1128.                   this.drawText(text, x, y, dw, 'right');
  1129.                   dw -= this.textWidth(text);
  1130.                   this.resetFontSettings();
  1131.                   if ($dataItems[ammoId].iconIndex > 0) {
  1132.                      var iw = x + dw - Window_Base._iconWidth;
  1133.                      this.drawIcon($dataItems[ammoId].iconIndex, iw, y + 2);
  1134.                      dw -= Window_Base._iconWidth + 2;
  1135.                   }
  1136.                }
  1137.             }
  1138.             var zeroAmmo = false;
  1139.             for (var ammoId in skill.equipAmmoCost) {
  1140.                var ammoId = parseInt(ammoId);
  1141.                if (!isNaN(ammoId) && (ammoId > 0)) {
  1142.                   var ammoCost = parseInt(skill.equipAmmoCost[ammoId]);  
  1143.                   if (actor.hasArmor($dataArmors[ammoId])) {
  1144.                      this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1145.                      var text = (ammoCost <= 0) ? '' : 'x' + String( 1+$gameParty.getItemAmount($dataArmors[ammoId]) );
  1146.                      this.contents.fontSize = Unco.Param.ammoFontSize;
  1147.                      this.drawText(text, x, y, dw, 'right');
  1148.                      dw -= this.textWidth(text);
  1149.                      this.resetFontSettings();
  1150.                      if ($dataArmors[ammoId].iconIndex > 0) {
  1151.                         var iw = x + dw - Window_Base._iconWidth;
  1152.                         this.drawIcon($dataArmors[ammoId].iconIndex, iw, y + 2);
  1153.                         dw -= Window_Base._iconWidth + 2;
  1154.                      }
  1155.                      zeroAmmo = false;
  1156.                      break;
  1157.                   } else {
  1158.                      zeroAmmo = true;
  1159.                   }
  1160.                }
  1161.             }
  1162.             if (zeroAmmo === true) {
  1163.                this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1164.                var text = 'x0';
  1165.                this.contents.fontSize = Unco.Param.ammoFontSize;
  1166.                this.drawText(text, x, y, dw, 'right');
  1167.                dw -= this.textWidth(text);
  1168.                this.resetFontSettings();
  1169.                var iw = x + dw - Window_Base._iconWidth;
  1170.                this.drawIcon( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) , iw, y + 2);
  1171.                dw -= Window_Base._iconWidth + 2;
  1172.             }
  1173.             var zeroWeaponAmmo = false;
  1174.             for (var ammoId in skill.weaponAmmoCost) {
  1175.                var ammoId = parseInt(ammoId);
  1176.                if (!isNaN(ammoId) && (ammoId > 0)) {
  1177.                   var ammoCost = parseInt(skill.weaponAmmoCost[ammoId]);  
  1178.                   if (actor.hasWeapon($dataWeapons[ammoId])) {
  1179.                      this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1180.                      var text = (ammoCost <= 0) ? '' : 'x' + String( 1+$gameParty.getItemAmount($dataWeapons[ammoId]) );
  1181.                      this.contents.fontSize = Unco.Param.ammoFontSize;
  1182.                      this.drawText(text, x, y, dw, 'right');
  1183.                      dw -= this.textWidth(text);
  1184.                      this.resetFontSettings();
  1185.                      if ($dataWeapons[ammoId].iconIndex > 0) {
  1186.                         var iw = x + dw - Window_Base._iconWidth;
  1187.                         this.drawIcon($dataWeapons[ammoId].iconIndex, iw, y + 2);
  1188.                         dw -= Window_Base._iconWidth + 2;
  1189.                      }
  1190.                      zeroWeaponAmmo = false;
  1191.                      break;
  1192.                   } else {
  1193.                      zeroWeaponAmmo = true;
  1194.                   }
  1195.                }
  1196.             }
  1197.             if (zeroWeaponAmmo === true) {
  1198.                this.changeTextColor(this.textColor(Unco.Param.ammoFontColor));
  1199.                var text = 'x0';
  1200.                this.contents.fontSize = Unco.Param.ammoFontSize;
  1201.                this.drawText(text, x, y, dw, 'right');
  1202.                dw -= this.textWidth(text);
  1203.                this.resetFontSettings();
  1204.                var iw = x + dw - Window_Base._iconWidth;
  1205.                this.drawIcon( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) , iw, y + 2);
  1206.                dw -= Window_Base._iconWidth + 2;
  1207.             }
  1208.          }
  1209.       }
  1210.    };
  1211.    
  1212. //=============================================================================
  1213. // DataManager (again)
  1214. //=============================================================================
  1215.    Unco.AS.DataManager_processGSCNotetags1 = DataManager.processGSCNotetags1;
  1216.    DataManager.processGSCNotetags1 = function(group) {
  1217.      Unco.AS.DataManager_processGSCNotetags1.call(this,group);
  1218.      for (var n = 1; n < group.length; n++) {
  1219.        var obj = group[n];
  1220.        var notedata = obj.note.split(/[\r\n]+/);
  1221.  
  1222.        for (var i = 0; i < notedata.length; i++) {
  1223.          var line = notedata[i];
  1224.          if (line.match(/<(?:SWAP GAUGE|gauge)[ ](\d+):[ ](.*)>/i)) {
  1225.            var gauge = parseInt(RegExp.$1);
  1226.            var text = String(RegExp.$2).toUpperCase();
  1227.            if (['AMMO'].contains(text)) {
  1228.              if (gauge === 1) obj.gauge1 = text;
  1229.              if (gauge === 2) obj.gauge2 = text;
  1230.              if (gauge === 3) obj.gauge3 = text;
  1231.            }
  1232.          }
  1233.        }
  1234.      }
  1235.    };
  1236.    Unco.AS.DataManager_processGSCNotetags2 = DataManager.processGSCNotetags2;
  1237.    DataManager.processGSCNotetags2 = function(group) {
  1238.      Unco.AS.DataManager_processGSCNotetags2.call(this,group);
  1239.      for (var n = 1; n < group.length; n++) {
  1240.        var obj = group[n];
  1241.        var notedata = obj.note.split(/[\r\n]+/);
  1242.  
  1243.        for (var i = 0; i < notedata.length; i++) {
  1244.          var line = notedata[i];
  1245.          if (line.match(/<(?:SWAP GAUGE|gauge)[ ](\d+):[ ](.*)>/i)) {
  1246.            var gauge = parseInt(RegExp.$1);
  1247.            var text = String(RegExp.$2).toUpperCase();
  1248.            if (['AMMO'].contains(text)) {
  1249.              if (gauge === 1) obj.gauge1 = text;
  1250.              if (gauge === 2) obj.gauge2 = text;
  1251.              if (gauge === 3) obj.gauge3 = text;
  1252.            }
  1253.          }
  1254.        }
  1255.      }
  1256.    };
  1257.    
  1258.    Unco.AS.Window_Window_Base_drawActorHp = Window_Base.prototype.drawActorHp;
  1259.    Window_Base.prototype.drawActorHp = function(actor, x, y, width) {
  1260.        if ((this.mustDrawActorAmmo(actor)) && (actor.gauge1() === 'AMMO')) {
  1261.        this.drawActorAmmo(actor, x, y, width);
  1262.        } else {
  1263.          Unco.AS.Window_Window_Base_drawActorHp.call(this, actor, x, y, width);
  1264.        }
  1265.    };
  1266.    
  1267.    Unco.AS.Window_Window_Base_drawActorMp = Window_Base.prototype.drawActorMp;
  1268.    Window_Base.prototype.drawActorMp = function(actor, x, y, width) {
  1269.        if ((this.mustDrawActorAmmo(actor)) && (actor.gauge2() === 'AMMO')) {
  1270.          this.drawActorAmmo(actor, x, y, width);
  1271.        } else {
  1272.          Unco.AS.Window_Window_Base_drawActorMp.call(this, actor, x, y, width);
  1273.        }
  1274.    };
  1275.    
  1276.    Unco.AS.Window_Window_Base_drawActorTp = Window_Base.prototype.drawActorTp;
  1277.    Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
  1278.        if ((this.mustDrawActorAmmo(actor)) && (actor.gauge3() === 'AMMO')) {
  1279.        this.drawActorAmmo(actor, x, y, width);
  1280.        } else {
  1281.          Unco.AS.Window_Window_Base_drawActorTp.call(this, actor, x, y, width);
  1282.        }
  1283.    };
  1284. }
  1285.  
  1286.  
  1287. //-----------------------------------------------------------------------------
  1288. // Window_Ammo
  1289. //
  1290. // The window for displaying the ammunition amount for attack action.
  1291.  
  1292. function Window_Ammo() {
  1293.     this.initialize.apply(this, arguments);
  1294. }
  1295.  
  1296. Window_Ammo.prototype = Object.create(Window_Base.prototype);
  1297. Window_Ammo.prototype.constructor = Window_Ammo;
  1298.  
  1299. Window_Ammo.prototype.initialize = function(numLines) {
  1300.     var width = Graphics.boxWidth;
  1301.     var height = this.fittingHeight(1);
  1302.     var y = Graphics.height-this.fittingHeight(6);
  1303.     Window_Base.prototype.initialize.call(this, 0, 0, width, height);
  1304.     this._text = '';
  1305. };
  1306.  
  1307. Window_Ammo.prototype.setText = function(text) {
  1308.     if (this._text !== text) {
  1309.         this._text = text;
  1310.         this.refresh();
  1311.     }
  1312. };
  1313.  
  1314. Window_Ammo.prototype.clear = function() {
  1315.     this.setText('');
  1316. };
  1317.  
  1318.  
  1319. Window_Ammo.prototype.setItem = function(actor,item) {
  1320.    var text = '';
  1321.    if (typeof item !== 'undefined') {
  1322.       if ((DataManager.isSkill(item)) && (Unco.Param.showAmmoLeftInDesc === 'true')) {
  1323.          var skill = item;
  1324.          if (skill.id === actor.attackSkillId()) {
  1325.             if (typeof actor._equips !== 'undefined') {
  1326.                if (actor._equips[0]._itemId > 0) {
  1327.                   skill = $dataWeapons[ ( (typeof $dataWeapons[actor._equips[0]._itemId].baseItemId === 'undefined') ? actor._equips[0]._itemId : $dataWeapons[actor._equips[0]._itemId].baseItemId ) ];
  1328.                }
  1329.             }
  1330.          }
  1331.          var withAmmo = false;
  1332.  
  1333.          for (var ammoId in skill.itemAmmoCost) {
  1334.             var cost = skill.itemAmmoCost[ammoId];
  1335.             ammoId = parseInt(ammoId);
  1336.             if (!isNaN(ammoId) && (ammoId > 0) && !isNaN(cost)) {
  1337.                var cost = parseInt(cost);
  1338.                var itemOwned = ($gameParty.getItemAmount($dataItems[ammoId]) > 0);
  1339.                text = text + '\\i[' + String($dataItems[ammoId].iconIndex) + ']';
  1340.                text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataItems[ammoId].name + ' ' );
  1341.                text = text + ( ((cost <= 0) && itemOwned) ? '' : ( 'x' + String( $gameParty.getItemAmount($dataItems[ammoId]) ) )  );
  1342.                withAmmo = true;
  1343.             }
  1344.          }
  1345.          var zeroEquipAmmo = false;
  1346.          for (var ammoId in skill.equipAmmoCost) {
  1347.             var cost = skill.equipAmmoCost[ammoId];
  1348.             var ammoId = parseInt(ammoId);
  1349.             if (!isNaN(ammoId) && (ammoId > 0)) {
  1350.                cost = parseInt(cost);
  1351.                withAmmo = true;
  1352.                if (actor.hasArmor($dataArmors[ammoId])) {
  1353.                   text = text + '\\i[' + String($dataArmors[ammoId].iconIndex) + ']';
  1354.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataArmors[ammoId].name + ' ' );
  1355.                   text = text + ( (cost <= 0) ? '' : 'x' + String( 1 + $gameParty.getItemAmount($dataArmors[ammoId]) )  );
  1356.                   text = text + ( (typeof $dataArmors[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataArmors[ammoId].ammoDesc + ')' );
  1357.                   zeroEquipAmmo = false;
  1358.                   break;
  1359.                } else {
  1360.                   zeroEquipAmmo = true;
  1361.                }
  1362.             }
  1363.          }
  1364.          if (zeroEquipAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  1365.          var zeroWeaponAmmo = false;
  1366.          for (var ammoId in skill.weaponAmmoCost) {
  1367.             var cost = skill.weaponAmmoCost[ammoId];
  1368.             var ammoId = parseInt(ammoId);
  1369.             if (!isNaN(ammoId) && (ammoId > 0)) {
  1370.                cost = parseInt(cost);
  1371.                withAmmo = true;
  1372.                if (actor.hasWeapon($dataWeapons[ammoId])) {
  1373.                   text = text + '\\i[' + String($dataWeapons[ammoId].iconIndex) + ']';
  1374.                   text = text + ( (typeof skill.showAmmoName === 'undefined') ? '' : $dataWeapons[ammoId].name + ' ' );
  1375.                   text = text + ( (cost <= 0) ? '' : 'x' + String( 1 + $gameParty.getItemAmount($dataWeapons[ammoId]) )  );
  1376.                   text = text + ( (typeof $dataWeapons[ammoId].ammoDesc === 'undefined') ? '' : '(' + $dataWeapons[ammoId].ammoDesc + ')' );
  1377.                   zeroWeaponAmmo = false;
  1378.                   break;
  1379.                } else {
  1380.                   zeroWeaponAmmo = true;
  1381.                }
  1382.             }
  1383.          }
  1384.          if (zeroWeaponAmmo === true) text = text + '\\i[' + String( ( (skill.noAmmoIconId) ? skill.noAmmoIconId : Unco.Param.defaultNoAmmoIconId ) ) + ']x0';
  1385.          
  1386.          if (withAmmo === true) text = ( (typeof skill.ammoText !== 'undefined') ? skill.ammoText : Unco.Param.descAmmoLeftText) + ' : ' + text;
  1387.       }
  1388.    }
  1389.    if (text !== '') {
  1390.       this.setText(item ? text : '');
  1391.       this.show();
  1392.    }
  1393. };
  1394.  
  1395. Window_Ammo.prototype.refresh = function() {
  1396.     this.contents.clear();
  1397.     this.drawTextEx(this._text, this.textPadding(), 0);
  1398. };
  1399.  
  1400. Unco.AS.Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
  1401. Scene_Battle.prototype.createAllWindows = function() {
  1402.     Unco.AS.Scene_Battle_createAllWindows.call(this);
  1403.     this.createAmmoWindow();
  1404. };
  1405.  
  1406. Scene_Battle.prototype.createAmmoWindow = function() {
  1407.     this._ammoWindow = new Window_Ammo();
  1408.     this._ammoWindow.visible = false;
  1409.     this.addWindow(this._ammoWindow);
  1410. };
  1411.  
  1412. Scene_Battle.prototype.showAmmoWindow = function() {
  1413.   if (Unco.Param.showAmmoLeftActorCommand === 'true') this._ammoWindow.setItem(BattleManager.actor(),$dataSkills[BattleManager.actor().attackSkillId()]);
  1414. };
  1415.  
  1416. Unco.AS.Scene_Battle_onSelectAction = Scene_Battle.prototype.onSelectAction;
  1417. Scene_Battle.prototype.onSelectAction = function() {
  1418.     this._ammoWindow.hide();
  1419.     Unco.AS.Scene_Battle_onSelectAction.call(this);
  1420. };
  1421.  
  1422. Unco.AS.Scene_Battle_commandAttack = Scene_Battle.prototype.commandAttack;
  1423. Scene_Battle.prototype.commandAttack = function() {
  1424.    this._ammoWindow.hide();
  1425.    Unco.AS.Scene_Battle_commandAttack.call(this);
  1426. };
  1427. Unco.AS.Scene_Battle_commandSkill = Scene_Battle.prototype.commandSkill;
  1428. Scene_Battle.prototype.commandSkill = function() {
  1429.    this._ammoWindow.hide();
  1430.    Unco.AS.Scene_Battle_commandSkill.call(this);
  1431. };
  1432. Unco.AS.Scene_Battle_commandGuard = Scene_Battle.prototype.commandGuard;
  1433. Scene_Battle.prototype.commandGuard = function() {
  1434.    this._ammoWindow.hide();
  1435.    Unco.AS.Scene_Battle_commandGuard.call(this);
  1436. };
  1437. Unco.AS.Scene_Battle_commandItem = Scene_Battle.prototype.commandItem;
  1438. Scene_Battle.prototype.commandItem = function() {
  1439.    this._ammoWindow.hide();
  1440.    Unco.AS.Scene_Battle_commandItem.call(this);
  1441. };
  1442. Unco.AS.Scene_Battle_startActorCommandSelection = Scene_Battle.prototype.startActorCommandSelection;
  1443. Scene_Battle.prototype.startActorCommandSelection = function() {
  1444.    this.showAmmoWindow();
  1445.    Unco.AS.Scene_Battle_startActorCommandSelection.call(this);
  1446. };
  1447. Unco.AS.Scene_Battle_onSkillCancel = Scene_Battle.prototype.onSkillCancel;
  1448. Scene_Battle.prototype.onSkillCancel = function() {
  1449.    this.showAmmoWindow();
  1450.    Unco.AS.Scene_Battle_onSkillCancel.call(this);
  1451. };
  1452. Unco.AS.Scene_Battle_onItemCancel = Scene_Battle.prototype.onItemCancel;
  1453. Scene_Battle.prototype.onItemCancel = function() {
  1454.    this.showAmmoWindow();
  1455.    Unco.AS.Scene_Battle_onItemCancel.call(this);
  1456. };
  1457. Unco.AS.Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel;
  1458. Scene_Battle.prototype.onEnemyCancel = function() {
  1459.    if (this._actorCommandWindow.currentSymbol() === 'attack') {
  1460.       this.showAmmoWindow();
  1461.    }
  1462.    Unco.AS.Scene_Battle_onEnemyCancel.call(this);
  1463. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement