Astfgl

QTEAddonSPW R1

Nov 14th, 2016
9,204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // QTE Addon: Skill possibilities window
  3. // by Astfgl
  4. // Date: 09/11/2016
  5. // Revision: 11/11/2016
  6. // Added help and TOU info.
  7. // Made to work with the QTEWindow plugin by Astfgl.
  8. // Please refer to that plugin for the terms of use.
  9. // If you credit me for the QTE window I don't require additional credit for the
  10. // use of this plugin.
  11. //=============================================================================
  12.  
  13.  
  14. /*:
  15.  * @plugindesc v1.0; Creates a window to display the skill possibilities and their sequence, to use with the QTEWindow plugin.
  16.  * @author Astfgl
  17.  *
  18.  * @param x
  19.  * @desc The default x coordinate of the window
  20.  * @default 0  
  21.  *
  22.  * @param y
  23.  * @desc the default y coordinate of the window
  24.  * @default 0
  25.  *
  26.  * @param width
  27.  * @desc The default width of the window in pixels
  28.  * @default 300
  29.  *
  30.  * @param height
  31.  * @desc The default height of the window in lines
  32.  * @default 5
  33.  *
  34.  * @param textWidth
  35.  * @desc The width of the text area in pixels
  36.  * @default 100
  37.  *
  38.  * @param iconWidth
  39.  * @desc The width of the icon area in pixels
  40.  * @default 200
  41.  *
  42.  * @param maxInputs
  43.  * @desc The default number of max Inputs
  44.  * @default 5
  45.  *
  46.  * @param minInputs
  47.  * @desc The default number of minimum inputs
  48.  * @default 1
  49.  *
  50.  * @help
  51.  * =========================================
  52.  * Skill possibilities Window
  53.  * =========================================
  54.  * REQUIREMENTS:
  55.  * This plugins requires that the QTEWindow plugin is installed and
  56.  * placed above it in the plugin list.
  57.  * SETUP:
  58.  * Setup each parameter to your liking, alhtough none is required.
  59.  *
  60.  * USAGE:
  61.  * This window will display the skill possibilities of an actor
  62.  * for a free input QTE based on three parameters:
  63.  * - The actor Id
  64.  * - The minimum number of input
  65.  * - The maximum number of input
  66.  * If an actor has five skills but only three of them have a <qteSeq:>
  67.  * notetag, skillA 3 inputs, skillB 4 inputs, skillC 5 inputs.
  68.  * minInputs = 5, will display only skillC
  69.  * maxInputs = 3, will display only skillA
  70.  * maxInputs = minInputs = 4, will display only skill B
  71.  *
  72.  * Creating a SPW:
  73.  * $gameMap.createSPW(actorId,maxInputs,minInputs)
  74.  *
  75.  * You can then set the window parameters using the following:
  76.  * Window coordinates:
  77.  *  - $gameMap.setSPWCoord(x,y)
  78.  *
  79.  * Window size :
  80.  * - $gameMap.setSPWSize(width,height)
  81.  *
  82.  * Text and Icon area repartition:
  83.  * - $gameMap.setSPWText(textAreaWidth,iconAreaWidth)
  84.  *
  85.  * Remove SPW window:
  86.  * - $gameMap.removeSPW()
  87.  *
  88.  */
  89.  
  90. function Window_SPW() {
  91.     this.initialize.apply(this, arguments);
  92. }
  93.  
  94. Window_SPW.prototype = Object.create(Window_Base.prototype);
  95. Window_SPW.prototype.constructor = Window_SPW;
  96.  
  97. Window_SPW.prototype.initialize = function() {
  98.     Window_Base.prototype.initialize.call(this,0,0,1000,1000);
  99.     var parameters = PluginManager.parameters('QTEAddonSPW');
  100.     this.x = eval(parameters.x);
  101.     this.y = eval(parameters.y);
  102.     this.width = eval(parameters.width);
  103.     this.height = eval(parameters.height) * this.lineHeight();
  104.     this._txtWidth = eval(parameters.textWidth);
  105.     this._iconWidth = eval(parameters.iconWidth);
  106.     this._maxInputs = eval(parameters.maxInputs);
  107.     this._minInputs = eval(parameters.minInputs);
  108.     this._actor = $gameActors.actor(1);
  109.     this._lineHeight = this.lineHeight();
  110.     this.update();
  111. }
  112.  
  113. Window_SPW.prototype.update = function() {
  114.     this.contents.clear();
  115.     if (this._actor !== 0) {
  116.         var list = this.createSkillList();
  117.         var i, ii, index, txt
  118.         for (i = 0; i < list.length; i++) {
  119.             txt = "";
  120.             txt+= list[i].name;
  121.             txt+= ":";
  122.             this.drawText(txt, 0, this._lineHeight * i, this._txtWidth, "left");
  123.             for (ii = 0; ii < eval(list[i].meta.qteSeq).length; ii++) {
  124.                 index = SceneManager._scene._QTEWindow.getIconIndex(eval(list[i].meta.qteSeq)[ii])
  125.                 this.drawIcon(index, this._txtWidth + 36 * ii, this._lineHeight * i)
  126.             }
  127.         }
  128.     }
  129. }
  130.  
  131. Window_SPW.prototype.clear = function() {
  132.     this.initialize();
  133. }
  134.  
  135. Window_SPW.prototype.createSkillList = function() {
  136.     var list = []
  137.     if (this._actor !== 0) {
  138.         var skills = this._actor.skills();
  139.         for (var i = 0; i < skills.length; i++) {
  140.             if (skills[i].meta.qteSeq) {
  141.                 if (eval(skills[i].meta.qteSeq).length <= this._maxInputs && eval(skills[i].meta.qteSeq).length >= this._minInputs) {
  142.                     list.push(skills[i]);
  143.                 }
  144.             }
  145.         }
  146.     }
  147.     return list
  148. }
  149.  
  150. Game_Map.prototype.createSPW = function(actorId, maxInputs, minInputs) {
  151.     var scene = SceneManager._scene
  152.     var win = new Window_SPW
  153.     scene._SPWindow = win
  154.     scene._SPWindow._actor = $gameActors.actor(actorId);
  155.     if (maxInputs) {scene._SPWindow._maxInputs = maxInputs};
  156.     if (minInputs) {scene._SPWindow._minInputs}
  157.     scene.addChild(scene._SPWindow);
  158.     scene._SPWindow.show();
  159. }
  160.  
  161. Game_Map.prototype.removeSPW = function() {
  162.     SceneManager._scene.removeChild(SceneManager._scene._SPWindow);
  163.     SceneManager._scene._SPWindow.clear()
  164. }
  165.  
  166. Game_Map.prototype.setSPWCoord = function(x,y) {
  167.     SceneManager._scene._SPWindow.x = x;
  168.     SceneManager._scene._SPWindow.y = y;
  169. }
  170.  
  171. Game_Map.prototype.setSPWSize = function(x,y) {
  172.     SceneManager._scene._SPWindow.width = x;
  173.     SceneManager._scene._SPWindow.height = (y+1) * SceneManager._scene._SPWindow._lineHeight;
  174. }
  175.  
  176. Game_Map.prototype.setSPWText = function(x,y) {
  177.     SceneManager._scene._SPWindow._txtWidth = x;
  178.     SceneManager._scene._SPWindow._iconWidth = y;
  179. }
Add Comment
Please, Sign In to add comment