Advertisement
Quickdraws24

State Overlay Control

Oct 29th, 2015
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Quickdraws Plugin - State Overlay Control
  3. // StateOverlayControl.js
  4. // Version: 1.00
  5. //=============================================================================
  6.  
  7. var Imported = Imported || {};
  8. Imported.StateOverlayControl = true;
  9.  
  10. var Quickdraws = Quickdraws || {};
  11. Quickdraws.control = Quickdraws.control || {};
  12.  
  13. //=============================================================================
  14. /*:
  15.  * @plugindesc Breaks the limit of state overlays by using note tags to reference index. Options to change some properties.
  16.  * @author Quickdraws
  17.  *
  18.  * @param State Overlay Width
  19.  * @desc This is the width of a single cell in the overlay.
  20.  * Default: 96
  21.  * @default 96
  22.  *
  23.  * @param State Overlay Height
  24.  * @desc This is the height of a single cell in the overlay.
  25.  * Default: 96
  26.  * @default 96
  27.  *
  28.  * @param Animation Frames
  29.  * @desc Adjust how many frames of animation there are.
  30.  * Default: 8
  31.  * @default 8
  32.  *
  33.  * @param Anchor X
  34.  * @desc Adjust where the animations are anchored X axis.
  35.  * Default: 0.5
  36.  * @default 0.5
  37.  *
  38.  * @param Anchor Y
  39.  * @desc Adjust where the animations are anchored Y axis.
  40.  * Default: 1
  41.  * @default 1
  42.  *
  43.  * @param Wait Frames
  44.  * @desc Adjust the wait time between animation frames.
  45.  * Default: 8
  46.  * @default 8
  47.  *
  48.  * @help
  49.  * ============================================================================
  50.  * Overview
  51.  * ============================================================================
  52.  * This plugin breaks the default state overlay limit and provides some property
  53.  * modifications.
  54.  *
  55.  * ============================================================================
  56.  * Notetags
  57.  * ============================================================================
  58.  * <OVERLAY INDEX: x>
  59.  *
  60.  * Then use <OVERLAY INDEX: x> in the note of a state and replace the 'x'
  61.  * by the line number of your new overlay.
  62.  *
  63.  * Example:
  64.  * <STATE OVERLAY: 27>
  65.  *
  66.  * this will choose the 27nth line based on your width and height settings of your
  67.  * States.png
  68.  *
  69.  * ============================================================================
  70.  * Misc
  71.  * ============================================================================
  72.  * The default animation for state overlays is made of 8 frames of 96x96.
  73.  *
  74.  * Always be mindful of the line format in order based on your desire frame width
  75.  * and height to make thing line up and show properly.
  76.  *
  77.  * ============================================================================
  78.  * Terms
  79.  * ============================================================================
  80.  * Free to use commercial or non commercial just credit the author as
  81.  * Quickdraws.
  82.  * ============================================================================
  83.  * Changelog
  84.  * ============================================================================
  85.  * Version 1.00
  86.  * - Initial release.
  87.  */
  88. //=============================================================================
  89.  
  90. //=============================================================================
  91. // Parameter Variables
  92. //=============================================================================
  93.  
  94.   Quickdraws.Parameters = PluginManager.parameters('StateOverlayControl');
  95.   Quickdraws.Param = Quickdraws.Param || {};
  96.  
  97.   Quickdraws.Param.SOWidth = Number(Quickdraws.Parameters['State Overlay Width']);
  98.   Quickdraws.Param.SOHeight = Number(Quickdraws.Parameters['State Overlay Height']);
  99.   Quickdraws.Param.SOFrames = Number(Quickdraws.Parameters['Animation Frames']);
  100.  
  101.   Quickdraws.Param.AnchorX = Number(Quickdraws.Parameters['Anchor X']);
  102.   Quickdraws.Param.AnchorY = Number(Quickdraws.Parameters['Anchor Y']);
  103.   Quickdraws.Param.WaitFrames = Number(Quickdraws.Parameters['Wait Frames']);
  104. //=============================================================================
  105. // DataManager
  106. //=============================================================================
  107.  
  108. Quickdraws.control.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  109. DataManager.isDatabaseLoaded = function() {
  110.     if (!Quickdraws.control.DataManager_isDatabaseLoaded.call(this)) return false;
  111.     DataManager.processControlTags1($dataStates);
  112.         return true;
  113. };
  114.  
  115.   DataManager.processControlTags1 = function(group) {
  116.     var note1 = /<(?:OVERLAY INDEX):[ ]*(\d+)>/i;
  117.     var note2 = /<(?:OVERLAY ANCHOR X):[ ]*(\d+)>/i;
  118.     var note3 = /<(?:OVERLAY ANCHOR Y):[ ]*(\d+)>/i;
  119.    
  120.     for (var n = 1; n < group.length; n++) {
  121.         var obj = group[n];
  122.         var notedata = obj.note.split(/[\r\n]+/);
  123.    
  124.     // obj.anchorx = [];
  125.     // obj.anchory = [];
  126.    
  127.         for (var i = 0; i < notedata.length; i++) {
  128.             var line = notedata[i];
  129.             if (line.match(note1)) {
  130.                 obj.overlay = parseInt(RegExp.$1);
  131.             } else if (line.match(note2)) {
  132.                 obj.anchorx = parseInt(RegExp.$1);
  133.             } else if (line.match(note3)) {    
  134.                  obj.anchory = parseInt(RegExp.$1);
  135.             }
  136.             }
  137.       }
  138. };
  139.  
  140.   Sprite_StateOverlay.prototype.initMembers = function() {
  141.     this._battler = null;
  142.     this._overlayIndex = 0;
  143.     this._animationCount = 0;
  144.     this._pattern = 0;
  145.     this.anchor.x = Quickdraws.Param.AnchorX;
  146.     this.anchor.y = Quickdraws.Param.AnchorY;
  147. };
  148.                            
  149.     Sprite_StateOverlay.prototype.animationWait = function() {
  150.         return Quickdraws.Param.WaitFrames;
  151. };
  152.            
  153.   Sprite_StateOverlay.prototype.updatePattern = function() {
  154.     this._pattern++;
  155.     this._pattern %= Quickdraws.Param.SOFrames;
  156.     if (this._battler) {
  157.         this._overlayIndex = this._battler.stateOverlayIndex();
  158.     }
  159. };
  160.  
  161.   Sprite_StateOverlay.prototype.updateFrame = function() {
  162.  
  163.     if (this._overlayIndex > 0) {
  164.         var w = Quickdraws.Param.SOWidth;
  165.         var h = Quickdraws.Param.SOHeight;
  166.         var sx = this._pattern * w;
  167.         var sy = (this._overlayIndex - 1) * h;
  168.         this.setFrame(sx, sy, w, h);
  169.     } else {
  170.         this.setFrame(0,0,0,0);
  171.     }
  172.   };
  173.  
  174.  
  175.         // var monkey = this._battler.bump();
  176.  
  177.     // Game_BattlerBase.prototype.bump = function(stateId) {
  178.    
  179.      // var testing = $dataStates[this._stateId].anchorx;
  180.    
  181.     // return testing;
  182. // };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement