Advertisement
heroofhyla

skillsOnlyBattleWindow.js - now with icons!

Dec 28th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2.  * @plugindesc Shows only a listing of all an actor's skills in the
  3.  * actor command window
  4.  * @author Michael Stroud
  5.  * @param showAttackCommand
  6.  * @desc if "1" and if the attack skill is not sealed, show the "Attack" command.
  7.  * @default 0
  8.  * @param showItemCommand
  9.  * @desc if "1", show the "Item" command
  10.  * @default 0
  11.  * @param itemIconID
  12.  * @desc If showSkillIcon and showItemCommand are both "1", the value here will be
  13.  * drawn as the icon for the "Item" command.
  14.  * @default 209
  15.  * @param showGuardCommand
  16.  * @desc if "1" and if the guard skill is not sealed, show the "Guard" command
  17.  * @default 0
  18.  * @param showSkillIcon
  19.  * @desc if "1" then icons are shown next to skills
  20.  * @default 1
  21.  * No warranty, express or implied. I can't guarantee that it will
  22.  * work at all. If it's useful to you, credit is appreciated.
  23.  * You may redistribute, but do not remove any of the above.
  24.  *
  25.  */
  26.  
  27. (function(){
  28.     var parameters = PluginManager.parameters('skillsOnlyBattleWindow');
  29.     var showAttackCommand = Number(parameters['showAttackCommand'] || 0);
  30.     var showItemCommand = Number(parameters['showItemCommand'] || 0);
  31.     var showGuardCommand = Number(parameters['showGuardCommand'] || 0);
  32.     var showSkillIcon = Number(parameters['showSkillIcon'] || 1);
  33.     var itemIconID = Number(parameters['itemIconID'] || 209);
  34.     this.icons = [];
  35.     Window_ActorCommand.prototype.makeCommandList = function() {
  36.         if (this._actor) {
  37.             this.icons = [];
  38.             this.addEachSkillCommand();
  39.         }
  40.     };
  41.    
  42.     Window_ActorCommand.prototype.addEachSkillCommand = function() {
  43.         var skills = this._actor.usableSkills();
  44.         if (showAttackCommand && !this._actor.isSkillSealed(1)){
  45.             this.addAttackCommand();
  46.             this.icons.push($dataSkills[1].iconIndex);
  47.         }
  48.         skills.forEach(function(skill) {
  49.             var name = skill.name;
  50.             this.addCommand(name, 'singleSkill', true, skill);
  51.             this.icons.push(skill.iconIndex);
  52.         }, this);
  53.         if (showGuardCommand && !this._actor.isSkillSealed(2)){
  54.             this.addGuardCommand();
  55.             this.icons.push($dataSkills[2].iconIndex);
  56.         }
  57.         if (showItemCommand){
  58.             this.addItemCommand();
  59.             this.icons.push(itemIconID);
  60.         }
  61.     };
  62.    
  63.     Window_ActorCommand.prototype.drawItem = function(index){
  64.         var rect = this.itemRectForText(index);
  65.         var align = this.itemTextAlign();
  66.         this.resetTextColor();
  67.         this.changePaintOpacity(this.isCommandEnabled(index));
  68.         var x = rect.x;
  69.         if (showSkillIcon){
  70.             this.drawIcon(this.icons[index], rect.x, rect.y);
  71.             x += Window_Base._iconWidth;
  72.             this.drawText(this.commandName(index), x, rect.y, rect.width-Window_Base._iconWidth, align);
  73.         }else{
  74.             this.drawText(this.commandName(index), x, rect.y, rect.width, align);
  75.         }
  76.        
  77.     }
  78.     Scene_Battle.prototype.commandSingleSkill = function() {
  79.         var skill = this._actorCommandWindow.currentExt();
  80.         var action = BattleManager.inputtingAction();
  81.         action.setSkill(skill.id);
  82.         BattleManager.actor().setLastBattleSkill(skill);
  83.         this.onSelectAction();
  84.     };
  85.    
  86.     Scene_Battle.prototype.createActorCommandWindow = function() {
  87.         this._actorCommandWindow = new Window_ActorCommand();
  88.         this._actorCommandWindow.setHandler('cancel', this.selectPreviousCommand.bind(this));
  89.         this._actorCommandWindow.setHandler('singleSkill', this.commandSingleSkill.bind(this));
  90.         this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));
  91.         this._actorCommandWindow.setHandler('guard', this.commandGuard.bind(this));
  92.         this._actorCommandWindow.setHandler('item', this.commandItem.bind(this));
  93.         this.addWindow(this._actorCommandWindow);
  94.     };
  95. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement