Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // BossBar.js
  3. //=============================================================================
  4. //v2.0
  5. /*:
  6.  * @plugindesc Makes boss hp bar appear in battle if you have note tag on the boss.
  7.  * @author Jeremy Cannady
  8.  *
  9.  * @param Boss Border X
  10.  * @desc Select x position adjust.Positive to go right, negative to go left.
  11.  * @default 50
  12.  *
  13.  * @param Boss Border Y
  14.  * @desc Select the y position adjust. Poistive to go down, negative to go up.
  15.  * @default 350
  16.  *
  17.  * @param Boss Bar X
  18.  * @desc Select x position adjust.Positive to go right, negative to go left.
  19.  * @default 202
  20.  *
  21.  * @param Boss Bar Y
  22.  * @desc Select the y position adjust. Poistive to go down, negative to go up.
  23.  * @default 400
  24.  *
  25.  * @param Turn Opacity
  26.  * @desc Opacity of the bars when you are attacking, etc. 255 is visible 0 is invisible.
  27.  * @default 255
  28.  *
  29.  * @param Input Opacity
  30.  * @desc Opacity of the bars when you are selcting actions to do. 255 is visible 0 is invisible.
  31.  * @default 100
  32.  *
  33.  * @param Scale
  34.  * @desc Scales both of the images. 1.2 is 20% increase. 0.8 is 80% of original. 1 is no scale.
  35.  * @default 1
  36.  *
  37.  * @help
  38.  * Put <Boss:1> in the enemy note tag to activate. No Spaces.
  39.  *This will get the image BossBar1.png and BossFill1.png from the img/pictures
  40.  *and display this during battle.Please note if you scale the image you need to adjust the x and y values.
  41.  *
  42. */
  43.  
  44. (function(){
  45. //=============================================================================
  46. // Create variables.
  47. //=============================================================================
  48.     var parameters = PluginManager.parameters('BossBar');
  49.     var bossbx = Number(parameters['Boss Border X'] || 50);
  50.     var bossby = Number(parameters['Boss Border Y'] || 350);
  51.     var bossbgx = Number(parameters['Boss Bar X'] || 202);
  52.     var bossbgy = Number(parameters['Boss Bar Y'] || 400);
  53.     var inputOpacity = Number(parameters['Input Opacity'] || 255);
  54.     var turnOpacity = Number(parameters['Turn Opacity'] || 255);
  55.     var scale = Number(parameters['Scale'] || 1);
  56.     Game_Troop.prototype.currentBossID = 0;
  57.     Game_Troop.prototype.currentBossTroopID = 0;
  58.     Game_Troop.prototype.currentBossMetaID = 0;
  59.     Game_Troop.prototype.haveBoss = false;
  60. //=============================================================================
  61. // Create sprite layer to display boss gauge.
  62. //=============================================================================
  63.     var alias_BossGauge_createLowerLayer = Spriteset_Battle.prototype.createLowerLayer
  64.     Spriteset_Battle.prototype.createLowerLayer = function() {
  65.         alias_BossGauge_createLowerLayer.call(this);
  66.         var haveBoss = 0;
  67.         for(var i = 0; i < $gameTroop._enemies.length; i++){
  68.             if ($dataEnemies[$gameTroop._enemies[i]._enemyId].meta.Boss){
  69.                 $gameTroop.currentBossTroopID = i;
  70.                 $gameTroop.currentBossID = $gameTroop._enemies[i]._enemyId;
  71.                 $gameTroop.currentBossMetaID = $dataEnemies[$gameTroop.currentBossID].meta.Boss;
  72.                 $gameTroop.haveBoss = true;
  73.                 haveBoss += 1;
  74.             };
  75.             if(haveBoss === 0){
  76.                 $gameTroop.haveBoss = false;       
  77.             }
  78.         };
  79.         if($gameTroop.haveBoss){
  80.             this.createBossGauge();
  81.         };
  82.     }
  83. //=============================================================================
  84. // Create update function to update the gauge.
  85. //=============================================================================
  86.     var alias_SSB_update = Spriteset_Battle.prototype.update
  87.     Spriteset_Battle.prototype.update = function() {
  88.         alias_SSB_update.call(this);
  89.         if($gameTroop.haveBoss){
  90.             this.updateBossGauge();
  91.         };
  92.     }
  93. //=============================================================================
  94. // Create the bitmaps and add them.
  95. //=============================================================================
  96.     Spriteset_Battle.prototype.createBossGauge = function() {
  97.         this.bitmap1 = new Sprite(ImageManager.loadPicture("BossBar"+$dataEnemies[$gameTroop.currentBossID].meta.Boss));
  98.         this.bitmap2 = new Sprite(ImageManager.loadPicture("BossBarFill"+$dataEnemies[$gameTroop.currentBossID].meta.Boss));
  99.         this.bitmap1.x = bossbx;
  100.         this.bitmap1.scale.x = scale;
  101.         this.bitmap1.y = bossby;
  102.         this.bitmap1.scale.y = scale;
  103.         this.bitmap2.x = bossbgx;
  104.         this.bitmap2.scale.x = scale;
  105.         this.bitmap2.y = bossbgy
  106.         this.bitmap2.scale.y = scale;
  107.         this.addChild(this.bitmap1);
  108.         this.addChild(this.bitmap2);   
  109.     };
  110. //=============================================================================
  111. // Update the gauge based on boss HP.
  112. //=============================================================================
  113.     Spriteset_Battle.prototype.updateBossGauge = function() {
  114.         if(BattleManager._phase == 'input'){
  115.             this.bitmap1.opacity = inputOpacity;
  116.             this.bitmap2.opacity = inputOpacity;
  117.         }else{
  118.             this.bitmap1.opacity = turnOpacity;
  119.             this.bitmap2.opacity = turnOpacity;
  120.         };
  121.        
  122.         var rate = $gameTroop._enemies[$gameTroop.currentBossTroopID]._hp/$dataEnemies[$gameTroop.currentBossID].params[0];
  123.         if(rate > 1){rate = 1};
  124.        
  125.         this.bitmap2.setFrame(0, 0, this.bitmap2.bitmap.width * rate, this.bitmap2.height);
  126.         if ($gameTroop._enemies[$gameTroop.currentBossTroopID]._hp == 0 ){
  127.             this.bitmap1.opacity = 0;
  128.             this.bitmap2.opacity = 0;
  129.         };
  130.     };
  131. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement