Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //import "std.zh"
- //import "string.zh"
- //Requires std.zh and string.zh.
- //1. Set up 5 consecutive tiles in a row in Tile Editor as following:
- // 1. Full heart.
- // 2. 3/4 heart.
- // 3. 1/2 heart.
- // 4. 1/4 heart.
- // 5. Empty heart.
- //2. Note down ID of the first tile in the row (the "Full Heart" one).
- // 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.
- //3. Import and compile the script.
- //4. In your boss screen, place the invisible FFC, and assign the following arguments:
- // D0: ID of the tile you noted down in step 2.
- // D1: Slot number of the boss enemy, or his weak spot.
- // D2: Hit Points per tile. Larger values means smaller life meter and vise versa.
- // D3: Cset used for drawing the life gauge. Setting value exceeding 11 results in health meter flashing trough all csets.
- // 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.
- // D5: ID of top-left corner of background drawn beneath HP meter.
- // D6: Width of backdrop, in tiles plus one tile to the left and to the right.
- // Set it to -1 for no background.
- // D7: Y position of the boss health gauge.
- //5. Assign the script to FFC.
- //6. Test and enjoy.
- const int ALUCARD_BOSS_GAUGE_DRAW_LAYER = 6; //THe layer to which all draws occur.
- const int BOSS_HP_TILE_OFFSET = 8; //Distance between gauge piece positions.
- const int BOSS_HP_METER_X_POS = 16; //X position of the leftmost gauge piece.
- const int FONT_BOSS_NAME = 0; //Font used for boss name string drawing.
- const int SHADOW_COLOR_BOSS_NAME = 1; //Drop shadow Color used for boss name string drawing. Set to -1 for no shadow.
- const int COLOR_BOSS_NAME = 0; //Color used for boss name string drawing.
- const int BKGCOLOR_BOSS_NAME = -1; //Background color used for boss name string drawing. Change to -1 for transparent.
- const int FONT_Y_OFFSET = 8; //Y position of the Boss name string drawing relative to gauge position.
- const int BACKDROP_CSET = 6; //Cset used for drawing backdrop beneath boss HP meter.
- const int BACKDROP_XOFFSET = -8; //Backdrop position offset.
- const int BACKDROP_YOFFSET = -16; //relative to gauge`s coordinates.
- const int BACKDROP_TILE_OFFSET = 16; //Distance between backdrop tile positions.
- const int BACKDROP_NUMROWS = 3; //Number of tile rows used for composing backdrop.
- 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
- ffc script BossHPMeter{
- void run (int origtile, int slotnum, int hppertile, int cset, int drawname, int bkgtile, int numbkgsections, int ypos){
- Waitframes(4);
- if (I_STETOSCOPE>0){
- if (!Link->Item[I_STETOSCOPE]) Quit();
- }
- npc boss;
- if (slotnum == 0) boss = Screen->LoadNPC(1);
- else boss = Screen->LoadNPC(slotnum);
- int buffer[256];
- int CSETFLASH[5] = {5,7,8,9,11};
- boss->GetName(buffer);
- int maxhp = boss->HP;
- int curhp = boss->HP;
- int drawhp = curhp;
- while (boss->isValid()){
- if (boss->HP <= 0) break;
- curhp = boss->HP;
- int backdrawx= BOSS_HP_METER_X_POS+BACKDROP_XOFFSET;
- int backdrawy= ypos+BACKDROP_YOFFSET;
- if (numbkgsections>=0) DrawBossMeterBackground(bkgtile, BACKDROP_CSET, BACKDROP_TILE_OFFSET, BACKDROP_NUMROWS, numbkgsections, backdrawx, backdrawy);
- int drawcset;
- drawhp = curhp;
- int drawmaxhp = maxhp;
- int drawxpos = BOSS_HP_METER_X_POS;
- int tiletodraw = origtile;
- if (cset>11) drawcset =CSETFLASH[Rand(4)];
- else drawcset = cset;
- int namey = ypos + FONT_Y_OFFSET;
- 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);
- 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);
- while (drawmaxhp > 0){
- int tilechooser = drawhp/hppertile;
- if (tilechooser >=1) tiletodraw = origtile;
- else if (tilechooser > 0.75) tiletodraw = origtile;
- else if (tilechooser> 0.5) tiletodraw = origtile + 1;
- else if (tilechooser> 0.25) tiletodraw = origtile + 2;
- else if (tilechooser> 0) tiletodraw = origtile + 3;
- else tiletodraw = origtile + 4;
- Screen->FastTile(ALUCARD_BOSS_GAUGE_DRAW_LAYER, drawxpos, ypos, tiletodraw,drawcset, OP_OPAQUE);
- drawxpos = drawxpos + BOSS_HP_TILE_OFFSET;
- drawmaxhp -= hppertile;
- drawhp -= hppertile;
- }
- Waitframe();
- }
- }
- }
- //Draws n scalable image at (tilex, tiley) with "numrows" height.
- //The backdrop image is built with tiles starting at "bkgorigtile" and each subsequent tile is drawn
- //after another with offset defined by "tileoffset".
- //"bkgcset" controls Cset used for drawing.
- void DrawBossMeterBackground(int bkgorigtile, int drawcset, int tileoffset, int numrows, int numsections, int tilex, int tiley){
- int curtilex = tilex;
- int tiletodraw = bkgorigtile;
- for (int i=0; i<numrows; i++){
- curtilex = tilex;
- tiletodraw = bkgorigtile+(i*20);
- Screen->FastTile(ALUCARD_BOSS_GAUGE_DRAW_LAYER, curtilex, tiley, tiletodraw, drawcset, OP_OPAQUE);
- tiletodraw++;
- curtilex += tileoffset;
- for (int i=1; i<numsections; i++){
- Screen->FastTile(ALUCARD_BOSS_GAUGE_DRAW_LAYER, curtilex, tiley, tiletodraw, drawcset, OP_OPAQUE);
- curtilex += tileoffset;
- }
- tiletodraw++;
- Screen->FastTile(ALUCARD_BOSS_GAUGE_DRAW_LAYER, curtilex, tiley, tiletodraw, drawcset, OP_OPAQUE);
- tiley +=16;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement