Advertisement
Jragyn

[MV] J_QABS_EquipSkills

Dec 9th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* -------------------------------------------------------------------------- */
  2. // J_QABS_EquipSkills
  3. // V: 1.0
  4.  
  5. /*:@plugindesc Enables skills for use via hotkeybar.
  6. @author J
  7.  
  8. @help This plugin implements a hard-coded variant to enable skills attached to
  9. non-weapons for the skillbar.
  10.  
  11. This needs to be placed beneath QABS itself.
  12. This is designed to work in tandem with the rest of the QABS system.
  13. This was written for me, but I'm uploading it incase others wanted to expand it.
  14. */
  15. /* -------------------------------------------------------------------------- */
  16.  
  17. var j_Game_System_initialize = Game_System.prototype.initialize;
  18. Game_System.prototype.initialize = function() {
  19.   j_Game_System_initialize.call(this);
  20.   this._absEquipKeys = {};
  21. };
  22.  
  23. var j_Game_Actor_initEquips = Game_Actor.prototype.initEquips;
  24. Game_Actor.prototype.initEquips = function(equips) {
  25.   j_Game_Actor_initEquips.call(this, equips);
  26.   if (this === $gameParty.leader()) {
  27.     this.updateEquipSkills();
  28.   }
  29. };
  30.  
  31. // (modified method)
  32. var j_Game_Actor_changeEquip = Game_Actor.prototype.changeEquip;
  33. Game_Actor.prototype.changeEquip = function(slotId, item) {
  34.   j_Game_Actor_changeEquip.call(this, slotId, item);
  35.   this.updateEquipSkills();
  36. };
  37.  
  38. // (new method)
  39. Game_Actor.prototype.updateEquipSkills = function() {
  40.   if (this !== $gameParty.leader()) return;
  41.   var skillSet = {}; var count = 0;
  42.   var skillKeys = { "#k":1, "#l":2, "#u":3, "#i":4, "#o":5, "#p":6 };
  43.   var e = $gameParty.leader()._equips;
  44.   e.forEach(function(value, index) { //console.log(value.object());
  45.     if (!value.object()) { return; }
  46.     try {
  47.       if (value.isWeapon()) {
  48.         var sDetails = $dataWeapons[value.object().id].qmeta.skillKeys || $dataWeapons[value.object().item.id].qmeta.absSkills;
  49.         if (!sDetails) return;
  50.         var wSkill = QABS.stringToSkillKeyObj(sDetails);//QABS.stringToSkillKeyObj(item.id);
  51.         skillSet[skillKeys[wSkill[Object.keys(wSkill)[0]].input[0]]] = (wSkill[Object.keys(wSkill)[0]]);
  52.       }
  53.       else if (value.isArmor()) {
  54.         var sDetails = $dataArmors[value.object().id].qmeta.skillKeys || $dataArmors[value.object().id].qmeta.absSkills;
  55.         if (!sDetails) return;
  56.         var aSkill = QABS.stringToSkillKeyObj(sDetails);
  57.         skillSet[skillKeys[aSkill[Object.keys(aSkill)[0]].input[0]]] = (aSkill[Object.keys(aSkill)[0]]);
  58.       }
  59.     } catch (error) { console.log(error); }
  60.   }, this); // end forEach of equips.
  61.   console.log("the skillset currently:");
  62.   console.log(skillSet);
  63.   $gameSystem.changeABSequipSkills(skillSet);
  64. };
  65.  
  66. // (modified method)
  67. var j_QABS_setupBattler = Game_Player.prototype.setupBattler;
  68. Game_Player.prototype.setupBattler = function() {
  69.   j_QABS_setupBattler.call(this);
  70.   $gameSystem.changeABSequipSkills({});
  71.   this.battler().updateEquipSkills();
  72. };
  73.  
  74.   // can i make armor skills? (new method)
  75. // this is the last step, it assigns the skillset to the keys and refreshes.
  76. Game_System.prototype.changeABSequipSkills = function(skillSet) {
  77.   this._absEquipKeys = skillSet;
  78.   this.resetABSKeys();
  79. };
  80.  
  81. // (modified new method)
  82. Game_System.prototype.resetABSKeys = function() {
  83.   this._absKeys = QABS.getDefaultSkillKeys();
  84.   for (var key in this._absKeys) {
  85.     Object.assign(
  86.       this._absKeys[key],
  87.       this._absClassKeys[key] || {},
  88.       this._absWeaponKeys[key] || {},
  89.       this._absEquipKeys[key] || {},
  90.       this._absOverrideKeys[key] || {}
  91.     );
  92.   }
  93.   this.preloadAllSkills();
  94.   this.checkAbsMouse();
  95. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement