Guest User

Untitled

a guest
Jul 29th, 2016
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // YEP_WeakResist.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc Add-on to YEP Battle Engine that shows Weak/Resist popups.
  7.  * @author KockaAdmiralac
  8.  *
  9.  * @help
  10.  * This is not really finished yet...
  11.  *
  12.  * @param Weak
  13.  * @desc If element rate is bigger than this parameter, "Weak" will be displayed
  14.  * @default 1.2
  15.  *
  16.  * @param Resist
  17.  * @desc If element rate is smaller than this parameter, "Resist" will be
  18.  * displayed
  19.  * @default 0.8
  20.  *
  21.  * @param Weak Jump
  22.  * @desc Because this is just a temporary version, I had to make
  23.  * Weakpoint text to jump. This is where you configure how high.
  24.  * @default 30
  25.  *
  26.  * @param Resist Jump
  27.  * @desc Because this is just a temporary version, I had to make
  28.  * Resist text to jump. This is where you configure how high.
  29.  * @default 30
  30.  */
  31.  
  32. (function(){
  33.  
  34.  
  35.  
  36. // Aliases
  37. var _kocka_random_alias_clear_4b8L2M99 = Game_ActionResult.prototype.clear;
  38. var _kocka_random_alias_apply_h7G3Bp1m = Game_Action.prototype.apply;
  39. var _kocka_random_alias_setup_3BfM6fH4 = Sprite_Damage.prototype.setup;
  40. var _kocka_random_alias_initialize_3Bjd9R7x = Sprite_Damage.prototype.initialize;
  41.  
  42.  
  43.  
  44. // Parameters
  45. var _pluginParams = PluginManager.parameters("YEP_WeakResist");
  46. var weakResult = _pluginParams["Weak"];
  47. var resistResult = _pluginParams["Resist"];
  48. var weakJump = Number(_pluginParams["Weak Jump"]);
  49. var resistJump = Number(_pluginParams["Resist Jump"]);
  50.  
  51.  
  52.  
  53. //-----------------------------------------------------------------------------
  54. // Game_ActionResult
  55. //
  56. // The game object class for a result of a battle action. For convinience, all
  57. // member variables in this class are public.
  58.  
  59. Game_ActionResult.prototype.clear = function()
  60. {
  61.     _kocka_random_alias_clear_4b8L2M99.apply(this, arguments);
  62.     this.elementId = -1;
  63. }
  64.  
  65.  
  66.  
  67. //-----------------------------------------------------------------------------
  68. // Game_Action
  69. //
  70. // The game object class for a battle action.
  71.  
  72. Game_Action.prototype.apply = function(target)
  73. {
  74.     _kocka_random_alias_apply_h7G3Bp1m.apply(this, arguments);
  75.     result = target.result();
  76.     if(result.isHit()) result.elementId = this.item().damage.elementId;
  77.     result.weakPopupNeeded = false;
  78.     result.resistPopupNeeded = false;
  79.     var rateResult = this.calcElementRate(target);
  80.     if (rateResult > weakResult)
  81.     {
  82.         result.weakPopupNeeded = true;
  83.     }
  84.     if (rateResult < resistResult)
  85.     {
  86.         result.resistPopupNeeded = true;
  87.     }
  88. }
  89.  
  90.  
  91.  
  92. //-----------------------------------------------------------------------------542
  93. // Game_Battler
  94. //
  95. // The superclass of Game_Actor and Game_Enemy. It contains methods for sprites
  96. // and actions.
  97.  
  98. Game_Battler.prototype.resultWeak = function()
  99. {
  100.     return this._result.weakPopupNeeded;
  101. }
  102.  
  103. Game_Battler.prototype.resultResist = function()
  104. {
  105.     return this._result.resistPopupNeeded;
  106. }
  107.  
  108.  
  109.  
  110. //-----------------------------------------------------------------------------
  111. // Sprite_Battler
  112. //
  113. // The superclass of Sprite_Actor and Sprite_Enemy.
  114.  
  115. Sprite_Battler.prototype.setupDamagePopup = function()
  116. {
  117.     if (this._battler.isDamagePopupRequested())
  118.     {
  119.         if (this._battler.isSpriteVisible())
  120.         {
  121.             var sprite = new Sprite_Damage();
  122.             sprite.x = this.x + this.damageOffsetX();
  123.             sprite.y = this.y + this.damageOffsetY();
  124.             console.log(this._battler._result);
  125.             if(this._battler.resultWeak())
  126.             {
  127.                 sprite.setWeak();
  128.             }
  129.             else if(this._battler.resultResist())
  130.             {
  131.                 sprite.setResist();
  132.             }
  133.             sprite.setup(this._battler);
  134.             this.pushDamageSprite(sprite);
  135.             BattleManager._spriteset.addChild(sprite)
  136.         }
  137.     }
  138.     else
  139.     {
  140.       this._battler.clearDamagePopup();
  141.       this._battler.clearResult();
  142.     }
  143. };
  144.  
  145.  
  146.  
  147. //-----------------------------------------------------------------------------
  148. // Sprite_Damage
  149. //
  150. // The sprite for displaying a popup damage.
  151.  
  152. Sprite_Damage.prototype.intialize = function()
  153. {
  154.     _kocka_random_alias_initialize_3Bjd9R7x.apply(this, arguments);
  155.     this._weak = false;
  156.     this._resist = false;
  157. }
  158. Sprite_Damage.prototype.setWeak = function() { this._weak = true; };
  159. Sprite_Damage.prototype.setResist = function() { this._resist = true; };
  160. Sprite_Damage.prototype.digitHeight = function() { return this._damageBitmap ? this._damageBitmap.height / 7 : 0; };
  161. Sprite_Damage.prototype.setup = function(target)
  162. {
  163.     _kocka_random_alias_setup_3BfM6fH4.apply(this, arguments);
  164.     if(this._weak)this.createWeak();
  165.     if(this._resist)this.createResist();
  166. }
  167.  
  168. Sprite_Damage.prototype.createWeak = function()
  169. {
  170.     var w = this.digitWidth();
  171.     var h = this.digitHeight();
  172.     var sprite = this.createChildSprite();
  173.     sprite.setFrame(0, 5 * h, 6.5 * w, h);
  174.     sprite.y = -80;
  175.     sprite.ry = sprite.y;
  176.     sprite.talBaseY = -40
  177.     sprite.dy = weakJump;
  178. }
  179.  
  180. Sprite_Damage.prototype.createResist = function()
  181. {
  182.     var w = this.digitWidth();
  183.     var h = this.digitHeight();
  184.     var sprite = this.createChildSprite();
  185.     sprite.setFrame(0, 6 * h, 6 * w, h);
  186.     sprite.y = -80;
  187.     sprite.ry = sprite.y;
  188.     sprite.talBaseY = -40
  189.     sprite.dy = resistJump;
  190. }
  191.  
  192. Sprite_Damage.prototype.updateChild = function(sprite) {
  193.     if (sprite.talBaseY == null)
  194.     sprite.talBaseY = 0;
  195.     sprite.dy += 0.5;
  196.     sprite.ry += sprite.dy;
  197.     if (sprite.ry >= sprite.talBaseY) {
  198.         sprite.ry = sprite.talBaseY;
  199.         sprite.dy *= -0.6;
  200.     }
  201.     sprite.y = Math.round(sprite.ry);
  202.     sprite.setBlendColor(this._flashColor);
  203. };
  204.  
  205. })();
Advertisement
Add Comment
Please, Sign In to add comment