khanhdu

Gilgamar - ButtonCast

Nov 6th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*=============================================================================
  2. * Gilgamar - ButtonCast
  3. * By Gilgamar
  4. * G_ButtonCast.js
  5. * Version: 1
  6. * Free for commercial and non commercial use.
  7. *=============================================================================*/
  8. /*:
  9. * @plugindesc v1.0 Adds ability to instantly cast skills with button.
  10. * @author Gilgamar
  11. *
  12. * @param Skill 1
  13. * @desc ID of skill to bind to key 1
  14. * Default: 1
  15. * @default 1
  16. */
  17.  
  18. var parameters = PluginManager.parameters('G_ButtonCast');
  19. // console.log(parameters)
  20. var ButtonCast = {};
  21. ButtonCast.battler = 2 // Pick battler here
  22. ButtonCast.skill1 = Number(parameters['Skill 1']);
  23.  
  24. var skillKeys = [1,2,3,4,5,6,7,8,9];
  25. // Make sure game can poll keys 1-9
  26. Input.keyMapper[49] = '1';
  27. Input.keyMapper[50] = '2';
  28. Input.keyMapper[51] = '3';
  29. Input.keyMapper[52] = '4';
  30. Input.keyMapper[53] = '5';
  31. Input.keyMapper[54] = '6';
  32. Input.keyMapper[55] = '7';
  33. Input.keyMapper[56] = '8';
  34. Input.keyMapper[57] = '9';
  35.  
  36. var aliasPluginCommand = Game_Interpreter.prototype.pluginCommand;
  37.  
  38. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  39. aliasPluginCommand.call(this, command, args);
  40. if (command == 'ButtonCast') {
  41. switch (args[0]) {
  42. case 'init':
  43. break;
  44. }
  45. }
  46. }
  47.  
  48. function checkInput() {
  49. for (var i = 0; i < skillKeys.length; i++){
  50. k = skillKeys;
  51. if (Input.isPressed(String(k))) return k;
  52. }
  53. return null;
  54. }
  55.  
  56. function runSkill(k, battleManager) {
  57. var battler = $gameParty.battleMembers()[ButtonCast.battler];
  58. action = new Game_Action(battler);
  59. action.setSkill(9);
  60. battler._actions.push(action);
  61. // battleManager.startATBInput(battler); // Use this to select an action in battle
  62. battleManager.startATBAction(battler);
  63. }
  64.  
  65. //----------------------------------------------------------------------------//
  66. // YANFLY OVERRIDES
  67.  
  68. BattleManager.updateATBTicks = function() {
  69. k = checkInput();
  70. if (k) runSkill(k, this);
  71.  
  72. this._atbTicks += 1 * this.tickRate();
  73. if (this._atbTicks < this._atbFullTurn) return;
  74. $gameTroop.increaseTurn();
  75. this._atbTicks = 0;
  76. if (this.isTurnBased()) {
  77. this.endTurn();
  78. } else {
  79. this.endTurn();
  80. }
  81. };
Advertisement
Add Comment
Please, Sign In to add comment