Guest User

Untitled

a guest
Aug 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. /*:
  2. @plugindesc Show equipment skills on equip menu
  3. @author armornick
  4.  
  5. @param Equipment Skills Text
  6. @desc The label to show above the equipment skills list.
  7. @default Equipment Skills
  8.  
  9. @help
  10.  
  11. This plugin shows the changes in skills via equipment.
  12.  
  13. === License ====
  14.  
  15. Permission is hereby granted, free of charge, to any person obtaining a copy
  16. of this software and associated documentation files (the "Software"), to deal
  17. in the Software without restriction, including without limitation the rights
  18. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  19. of the Software, and to permit persons to whom the Software is furnished to do so.
  20.  
  21. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  22. INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  23. PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  24. FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  25. OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  26. DEALINGS IN THE SOFTWARE.
  27.  
  28. */
  29.  
  30. var Imported = Imported || {};
  31. Imported.NIA_EquipSkillCommands = 1;
  32.  
  33. (function () {
  34.  
  35. var params = PluginManager.parameters('NIA_EquipSkillCommands');
  36. var EQUIP_SKILLS_TEXT = params['Equipment Skills Text'] || "Equipment Skills";
  37.  
  38. //-----------------------------------------------------------------------------
  39. // Window_EquipStatus
  40.  
  41. Window_EquipStatus.prototype.initialize = function(x, y, height) {
  42. var width = this.windowWidth();
  43. Window_Base.prototype.initialize.call(this, x, y, width, height);
  44. this._actor = null;
  45. this._tempActor = null;
  46. this.refresh();
  47. };
  48.  
  49. /*
  50. Gets the "diff value" for the given skill and new and old trait lists.
  51.  
  52. Returns -1 if the given skill is removed after the equipment change,
  53. +1 if the skill is added after equipment change, or 0 if there is
  54. no change in the given skill.
  55. */
  56. function getEquipSkillDiff (trait, oldList, newList) {
  57. var result = 0, skillId = trait.dataId;
  58. // if the newList is null, this means we show the current state
  59. if (newList == null) {
  60. return result;
  61. }
  62. for (let oldItem of oldList) {
  63. if (oldItem.dataId === skillId) {
  64. result--; break;
  65. }
  66. }
  67. for (let newItem of newList) {
  68. if (newItem.dataId === skillId) {
  69. result++; break;
  70. }
  71. }
  72. return result;
  73. }
  74.  
  75. var NIA_EquipSkillCommands_WindowEquipStatus_refresh = Window_EquipStatus.prototype.refresh;
  76. Window_EquipStatus.prototype.refresh = function() {
  77. NIA_EquipSkillCommands_WindowEquipStatus_refresh.call(this);
  78.  
  79. if (this._actor) {
  80. var i = this.numVisibleRows(); // take the next row to draw at
  81. var oldEquipSkills = this._actor.traits(Game_Action.EFFECT_LEARN_SKILL),
  82. allEquipSkills = oldEquipSkills;
  83.  
  84. var newEquipSkills = null;
  85. if (this._tempActor) {
  86. newEquipSkills = this._tempActor.traits(Game_Action.EFFECT_LEARN_SKILL);
  87. allEquipSkills = oldEquipSkills.concat(newEquipSkills);
  88. }
  89.  
  90. this.resetTextColor();
  91. this.drawText(EQUIP_SKILLS_TEXT, 0, this.lineHeight() * (1 + i++), 120);
  92.  
  93. for (let equipSkill of allEquipSkills) {
  94. var skill = $dataSkills[equipSkill.dataId];
  95. this.drawEquipSkill(skill, 0, this.lineHeight() * (1 + i++), 120,
  96. getEquipSkillDiff(equipSkill, oldEquipSkills, newEquipSkills));
  97. }
  98. }
  99. }
  100.  
  101. Window_EquipStatus.prototype.drawEquipSkill = function(item, x, y, width, diffvalue) {
  102. if (item) {
  103. var iconBoxWidth = Window_Base._iconWidth + 4;
  104. this.changeTextColor(this.paramchangeTextColor(diffvalue));
  105. this.drawIcon(item.iconIndex, x + 2, y + 2);
  106. this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
  107. }
  108. }
  109.  
  110.  
  111.  
  112. //-----------------------------------------------------------------------------
  113. // Window_EquipItem
  114.  
  115. Window_EquipItem.prototype.maxCols = function() {
  116. return 1;
  117. };
  118.  
  119. //-----------------------------------------------------------------------------
  120. // Window_EquipSlot
  121.  
  122. Window_EquipSlot.prototype.initialize = function(x, y, width) {
  123. var height = this.windowHeight();
  124. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  125. this._actor = null;
  126. this.refresh();
  127. };
  128.  
  129. Window_EquipSlot.prototype.windowHeight = function() {
  130. return this.fittingHeight(this.guessEquipSlotsCount());
  131. };
  132.  
  133. Window_EquipSlot.prototype.guessEquipSlotsCount = function () {
  134. return $gameActors.actor(1).equipSlots().length;
  135. };
  136.  
  137. //-----------------------------------------------------------------------------
  138. // Scene_Equip
  139.  
  140. Scene_Equip.prototype.createStatusWindow = function() {
  141. var wh = Graphics.boxHeight - this._helpWindow.height;
  142. this._statusWindow = new Window_EquipStatus(0, this._helpWindow.height, wh);
  143. this.addWindow(this._statusWindow);
  144. };
  145.  
  146. Scene_Equip.prototype.createSlotWindow = function() {
  147. var wx = this._statusWindow.width;
  148. var wy = this._commandWindow.y + this._commandWindow.height;
  149. var ww = Graphics.boxWidth - this._statusWindow.width;
  150. var wh = this._statusWindow.height - this._commandWindow.height;
  151. this._slotWindow = new Window_EquipSlot(wx, wy, ww, wh);
  152. this._slotWindow.setHelpWindow(this._helpWindow);
  153. this._slotWindow.setStatusWindow(this._statusWindow);
  154. this._slotWindow.setHandler('ok', this.onSlotOk.bind(this));
  155. this._slotWindow.setHandler('cancel', this.onSlotCancel.bind(this));
  156. this.addWindow(this._slotWindow);
  157. };
  158.  
  159. Scene_Equip.prototype.createItemWindow = function() {
  160. var wx = this._statusWindow.width;
  161. var wy = this._slotWindow.y + this._slotWindow.height;
  162. var ww = Graphics.boxWidth;
  163. var wh = Graphics.boxHeight - wy;
  164. this._itemWindow = new Window_EquipItem(wx, wy, ww, wh);
  165. this._itemWindow.setHelpWindow(this._helpWindow);
  166. this._itemWindow.setStatusWindow(this._statusWindow);
  167. this._itemWindow.setHandler('ok', this.onItemOk.bind(this));
  168. this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
  169. this._slotWindow.setItemWindow(this._itemWindow);
  170. this.addWindow(this._itemWindow);
  171. };
  172.  
  173. }())
Add Comment
Please, Sign In to add comment