Advertisement
modern_algebra

ActorSpriteOptions

Oct 30th, 2015
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. //  Actor Sprite Options
  3. //  Version: 1.0.1
  4. //  Date: 31 October 2015
  5. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  6. /*:
  7.  * @author Modern Algebra (rmrk.net)
  8.  *
  9.  * @plugindesc Set the step animation, move animation, and blend type for each actor individually
  10.  *
  11.  * @help With this plugin, you can set the blend type, walk animation, and step
  12.  * animation for actors. If one of your actors is a flying creature like an
  13.  * angel, for instance, this script lets you set it so that he or she is still
  14.  * beating his or her wings while the player is stationary.
  15.  *
  16.  * The plugin is set up by writing the following codes in an actor's notebox.
  17.  *
  18.  * To make it so that an actor is animating even when stationary, write:
  19.  *      \step
  20.  *
  21.  * To make it so that an actor is not animating even when moving, write:
  22.  *      \immobile
  23.  *
  24.  * To change the blend type of an actor to something else, write:
  25.  *      \blend[x]
  26.  *
  27.  * Replace x with an integer, where the integers mean the following:
  28.  *      0  : Normal
  29.  *      1  : Additive
  30.  *      2  : Multiply
  31.  *      3  : Screen
  32.  */
  33. //=============================================================================
  34.  
  35. (function() {
  36.    
  37.     // mafsoBlendMode - Lazy Instantiation, default of 0
  38.     Game_Actor.prototype.mafsoBlendMode = function() {
  39.         if (!this._mafsoBlendMode) {
  40.             var actor = this.actor();
  41.             if (actor) {
  42.                 var rmatch = actor.note.match(/\\BLEND\s*\[\s*(\d+)\s*\]/i); // \blend[x]
  43.                 this._mafsoBlendMode = rmatch ? +rmatch[1] : 0;
  44.             }
  45.         }
  46.         return this._mafsoBlendMode || 0;
  47.     }
  48.    
  49.     // mafsoWalkAnime - Lazy Instantiation, default of true
  50.     Game_Actor.prototype.mafsoWalkAnime = function() {
  51.         if (!this._mafsoWalkAnime) {
  52.             var actor = this.actor();
  53.             if (actor) { this._mafsoWalkAnime = !(/\\IMMOBILE/i).test(actor.note); } // \immobile
  54.         }
  55.         return this._mafsoWalkAnime || true;
  56.     }
  57.    
  58.     // mafsoStepAnime - Lazy Instantiation, default of false
  59.     Game_Actor.prototype.mafsoStepAnime = function() {
  60.         if (!this._mafsoStepAnime) {
  61.             var actor = this.actor();
  62.             if (actor) { this._mafsoStepAnime = (/\\STEP/i).test(actor.note); } // \step
  63.         }
  64.         return this._mafsoStepAnime || false;
  65.     }
  66.    
  67.     // Set Sprite Options based on actor
  68.     Game_Character.prototype.mafsoSetActorSpriteOptions = function(actor) {
  69.         this.setBlendMode(actor.mafsoBlendMode());
  70.         this.setWalkAnime(actor.mafsoWalkAnime());
  71.         this.setStepAnime(actor.mafsoStepAnime());
  72.     }; 
  73.    
  74.     // Refresh
  75.     var mafso_Game_Player_refresh =
  76.             Game_Player.prototype.refresh;
  77.     Game_Player.prototype.refresh = function() {
  78.         mafso_Game_Player_refresh.apply(this, arguments); // Call original method
  79.         var actor = $gameParty.leader();
  80.         // Set options based on lead actor
  81.         if (actor) { this.mafsoSetActorSpriteOptions(actor); }
  82.     };
  83.    
  84.     // Game_Follower - Update
  85.     var _mafso_Game_Follower_update =
  86.             Game_Follower.prototype.update;
  87.     Game_Follower.prototype.update = function() {
  88.         _mafso_Game_Follower_update.apply(this, arguments); // Call original method
  89.         var actor = this.actor()
  90.         // Set options based on actor in this position
  91.         if (actor) { this.mafsoSetActorSpriteOptions(actor); }
  92.     };
  93.    
  94. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement