Advertisement
ZoriaRPG

Modified Alucard Boss HP Gauge for FireSeraphim

Feb 23rd, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.58 KB | None | 0 0
  1. //import "std.zh"
  2. //import "string.zh"
  3.  
  4. //Requires std.zh and string.zh.
  5.  
  6. //1. Set up 5 consecutive tiles in a row in Tile Editor as following:
  7. // 1. Full heart.
  8. // 2. 3/4 heart.
  9. // 3. 1/2 heart.
  10. // 4. 1/4 heart.
  11. // 5. Empty heart.
  12. //2. Note down ID of the first tile in the row (the "Full Heart" one).
  13. // A. Set up the 3 x BACKDROP_NUMROWS tile sheet for backdrop that will be drawn beneath HP gauge. Note down ID of the top left corner tile of the sheet.
  14. //3. Import and compile the script.
  15. //4. In your boss screen, place the invisible FFC, and assign the following arguments:
  16. // D0: ID of the tile you noted down in step 2.
  17. // D1: Slot number of the boss enemy, or his weak spot.
  18. // D2: Hit Points per tile. Larger values means smaller life meter and vise versa.
  19. // D3: Cset used for drawing the life gauge. Setting value exceeding 11 results in health meter flashing trough all csets.
  20. // D4: Setting to 1 results in a boss name being drawn near the health meter. Refer to the "FONT_Y_OFFSET" constant in the script file.
  21. // D5: ID of top-left corner of background drawn beneath HP meter.
  22. // D6: Width of backdrop, in tiles plus one tile to the left and to the right.
  23. //     Set it to -1 for no background.
  24. // D7: Y position of the boss health gauge.
  25. //5. Assign the script to FFC.
  26. //6. Test and enjoy.
  27.  
  28. const int ALUCARD_BOSS_GAUGE_DRAW_LAYER = 6; //THe layer to which all draws occur.
  29.  
  30. const int BOSS_HP_TILE_OFFSET = 8; //Distance between gauge piece positions.
  31. const int BOSS_HP_METER_X_POS = 16; //X position of the leftmost gauge piece.
  32. const int FONT_BOSS_NAME = 0; //Font used for boss name string drawing.
  33. const int SHADOW_COLOR_BOSS_NAME = 1; //Drop shadow Color used for boss name string drawing. Set to -1 for no shadow.
  34. const int COLOR_BOSS_NAME = 0; //Color used for boss name string drawing.
  35. const int BKGCOLOR_BOSS_NAME = -1; //Background color used for boss name string drawing. Change to -1 for transparent.
  36. const int FONT_Y_OFFSET = 8; //Y position of the Boss name string drawing relative to gauge position.
  37. const int BACKDROP_CSET = 6; //Cset used for drawing backdrop beneath boss HP meter.
  38. const int BACKDROP_XOFFSET = -8; //Backdrop position offset.
  39. const int BACKDROP_YOFFSET = -16; //relative to gauge`s coordinates.
  40. const int BACKDROP_TILE_OFFSET = 16; //Distance between backdrop tile positions.
  41. const int BACKDROP_NUMROWS = 3; //Number of tile rows used for composing backdrop.
  42. const int I_STETOSCOPE = 0; //ID of item that is needed to be in Link`s inventory for HP meter to be visible. 0 means always visible
  43.  
  44.  
  45. ffc script BossHPMeter{
  46.     void run (int origtile, int slotnum, int hppertile, int cset, int drawname, int bkgtile, int numbkgsections, int ypos){
  47.         Waitframes(4);
  48.         if (I_STETOSCOPE>0){
  49.             if (!Link->Item[I_STETOSCOPE]) Quit();
  50.         }
  51.         npc boss;
  52.         if (slotnum == 0) boss = Screen->LoadNPC(1);
  53.         else boss = Screen->LoadNPC(slotnum);
  54.         int buffer[256];
  55.         int CSETFLASH[5] = {5,7,8,9,11};
  56.         boss->GetName(buffer);
  57.         int maxhp = boss->HP;
  58.         int curhp = boss->HP;
  59.         int drawhp = curhp;
  60.         while (boss->isValid()){
  61.             if (boss->HP <= 0) break;
  62.             curhp = boss->HP;
  63.             int backdrawx= BOSS_HP_METER_X_POS+BACKDROP_XOFFSET;
  64.             int backdrawy= ypos+BACKDROP_YOFFSET;
  65.             if (numbkgsections>=0) DrawBossMeterBackground(bkgtile, BACKDROP_CSET, BACKDROP_TILE_OFFSET, BACKDROP_NUMROWS, numbkgsections, backdrawx, backdrawy);
  66.             int drawcset;
  67.             drawhp = curhp;
  68.             int drawmaxhp = maxhp;
  69.             int drawxpos = BOSS_HP_METER_X_POS;
  70.             int tiletodraw = origtile;
  71.             if (cset>11) drawcset =CSETFLASH[Rand(4)];
  72.             else drawcset = cset;
  73.             int namey = ypos + FONT_Y_OFFSET;
  74.             if ((drawname > 0)&&(SHADOW_COLOR_BOSS_NAME>=0)) Screen->DrawString(ALUCARD_BOSS_GAUGE_DRAW_LAYER, BOSS_HP_METER_X_POS+1, namey+1, FONT_BOSS_NAME, COLOR_BOSS_NAME, BKGCOLOR_BOSS_NAME,  TF_NORMAL, buffer, OP_OPAQUE);
  75.             if (drawname > 0) Screen->DrawString(ALUCARD_BOSS_GAUGE_DRAW_LAYER, BOSS_HP_METER_X_POS, namey, FONT_BOSS_NAME, SHADOW_COLOR_BOSS_NAME, BKGCOLOR_BOSS_NAME,  TF_NORMAL, buffer, OP_OPAQUE);
  76.             while (drawmaxhp > 0){
  77.                 int tilechooser =   drawhp/hppertile;
  78.                 if (tilechooser >=1) tiletodraw = origtile;
  79.                 else if (tilechooser > 0.75) tiletodraw = origtile;
  80.                 else if (tilechooser> 0.5) tiletodraw = origtile + 1;
  81.                 else if (tilechooser> 0.25) tiletodraw = origtile + 2;
  82.                 else if (tilechooser> 0) tiletodraw = origtile + 3;
  83.                 else tiletodraw = origtile + 4;
  84.                 Screen->FastTile(ALUCARD_BOSS_GAUGE_DRAW_LAYER, drawxpos, ypos, tiletodraw,drawcset, OP_OPAQUE);
  85.                 drawxpos = drawxpos + BOSS_HP_TILE_OFFSET;
  86.                 drawmaxhp -= hppertile;
  87.                 drawhp -= hppertile;
  88.                 }
  89.             Waitframe();
  90.         }
  91.     }
  92. }
  93.  
  94. //Draws n scalable image at (tilex, tiley) with "numrows" height.
  95. //The backdrop image is built with tiles starting at "bkgorigtile" and each subsequent tile is drawn
  96. //after another with offset defined by "tileoffset".
  97. //"bkgcset" controls Cset used for drawing.
  98. void DrawBossMeterBackground(int bkgorigtile, int drawcset, int tileoffset, int numrows, int numsections, int tilex, int tiley){
  99.     int curtilex = tilex;
  100.     int tiletodraw = bkgorigtile;
  101.     for (int i=0; i<numrows; i++){
  102.         curtilex = tilex;
  103.         tiletodraw = bkgorigtile+(i*20);
  104.         Screen->FastTile(ALUCARD_BOSS_GAUGE_DRAW_LAYER, curtilex, tiley, tiletodraw, drawcset, OP_OPAQUE);
  105.         tiletodraw++;
  106.         curtilex += tileoffset;
  107.         for (int i=1; i<numsections; i++){
  108.             Screen->FastTile(ALUCARD_BOSS_GAUGE_DRAW_LAYER, curtilex, tiley, tiletodraw, drawcset, OP_OPAQUE);
  109.             curtilex += tileoffset;
  110.             }
  111.         tiletodraw++;
  112.         Screen->FastTile(ALUCARD_BOSS_GAUGE_DRAW_LAYER, curtilex, tiley, tiletodraw, drawcset, OP_OPAQUE);
  113.         tiley +=16;
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement