Advertisement
Unconnected42

RMMV Plug-in _ Unco_AmmunitionSystem1_1_2 TEST

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