heroofhyla

skillsOnlyBattleWindow.js - streamlined!

Dec 28th, 2016
125
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 showSkillIcon
  6.  * @desc if "1" then icons are shown next to skills
  7.  * @default 1
  8.  * @param itemCommandSkill
  9.  * @desc Create a placeholder skill for the item command and set its ID here.
  10.  * @default 3
  11.  * @
  12.  * No warranty, express or implied. I can't guarantee that it will
  13.  * work at all. If it's useful to you, credit is appreciated.
  14.  * You may redistribute, but do not remove any of the above.
  15.  * @help
  16.  * Seal skill 1 to remove the attack command from a character.
  17.  * Seal skill 2 to remove the guard command.
  18.  * Seal the skill specified by "itemCommandSkill" to remove the item command.
  19.  */
  20.  
  21. (function(){
  22.     var parameters = PluginManager.parameters('skillsOnlyBattleWindow');
  23.     var showAttackCommand = Number(parameters['showAttackCommand'] || 0);
  24.     var showItemCommand = Number(parameters['showItemCommand'] || 0);
  25.     var showGuardCommand = Number(parameters['showGuardCommand'] || 0);
  26.     var showSkillIcon = Number(parameters['showSkillIcon'] || 0);
  27.     var itemCommandSkill = Number(parameters['itemCommandSkill'] || 3);
  28.     this.icons = [];
  29.     Window_ActorCommand.prototype.makeCommandList = function() {
  30.         if (this._actor) {
  31.             this.icons = [];
  32.             this.addEachSkillCommand();
  33.         }
  34.     };
  35.    
  36.     Window_ActorCommand.prototype.addEachSkillCommand = function() {
  37.         var skills = this._actor.usableSkills();        
  38.         if (!this._actor.isSkillSealed(1)){
  39.             this.addAttackCommand();
  40.             this.icons.push($dataSkills[1].iconIndex);
  41.         }
  42.         skills.forEach(function(skill) {
  43.             var name = skill.name;
  44.             this.addCommand(name, 'singleSkill', true, skill);
  45.             this.icons.push(skill.iconIndex);
  46.         }, this);
  47.        
  48.         if (!this._actor.isSkillSealed(2)){
  49.             this.addGuardCommand();
  50.             this.icons.push($dataSkills[2].iconIndex);
  51.         }
  52.        
  53.         if (!this._actor.isSkillSealed(itemCommandSkill)){
  54.                 this.addItemCommand();
  55.                 this.icons.push($dataSkills[itemCommandSkill].iconIndex);
  56.         }
  57.     };
  58.    
  59.     Window_ActorCommand.prototype.drawItem = function(index){
  60.         var rect = this.itemRectForText(index);
  61.         var align = this.itemTextAlign();
  62.         this.resetTextColor();
  63.         this.changePaintOpacity(this.isCommandEnabled(index));
  64.         var x = rect.x;
  65.         if (showSkillIcon){
  66.             this.drawIcon(this.icons[index], rect.x, rect.y);
  67.             x += Window_Base._iconWidth;
  68.             this.drawText(this.commandName(index), x, rect.y, rect.width-Window_Base._iconWidth, align);
  69.         }else{
  70.             this.drawText(this.commandName(index), x, rect.y, rect.width, align);
  71.         }
  72.        
  73.     }
  74.     Scene_Battle.prototype.commandSingleSkill = function() {
  75.         var skill = this._actorCommandWindow.currentExt();
  76.         var action = BattleManager.inputtingAction();
  77.         action.setSkill(skill.id);
  78.         BattleManager.actor().setLastBattleSkill(skill);
  79.         this.onSelectAction();
  80.     };
  81.    
  82.     Scene_Battle.prototype.createActorCommandWindow = function() {
  83.         this._actorCommandWindow = new Window_ActorCommand();
  84.         this._actorCommandWindow.setHandler('cancel', this.selectPreviousCommand.bind(this));
  85.         this._actorCommandWindow.setHandler('singleSkill', this.commandSingleSkill.bind(this));
  86.         this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));
  87.         this._actorCommandWindow.setHandler('guard', this.commandGuard.bind(this));
  88.         this._actorCommandWindow.setHandler('item', this.commandItem.bind(this));
  89.         this.addWindow(this._actorCommandWindow);
  90.     };
  91. })();
Add Comment
Please, Sign In to add comment