Would it be easy to have a script that shows a little red bar above the enemy when you attack it showing its health? Turns to black when damage is done.
Enemy Health Bar
#1
Posted 07 January 2017 - 12:38 PM
#2
Posted 08 January 2017 - 03:55 AM
You are welcome to try this...
////////////////////// /// Display NPC HP /// /// v0.2 /// /// 8th Jan, 2017 /// /// By: ZoriaRPG /// ////////////////////// //Base Settings. const int NPC_HP_DISPLAY_BAR = 1; //Set to 1 to draw graph bars, 0 to disable. const int NPC_HP_DISPLAY_NUMERALS = 1; //Set to 1 to draw the HP as numerals, 0 to disable. //Numeral Drawing Settings const int NPC_DRAW_HP_LAYER = 2; const int NPC_DRAW_HP_X_OFFSET = -4; //Distance from NPC on X axis. const int NPC_DRAW_HP_Y_OFFSET = -4; //Distance from enemy on Y axis. const int NPC_DRAW_HP_SHADOW_OFFSET = 1; //Distance of the drop shadow fromt he foreground text. const int NPC_DRAW_HP_FONT = 2; //z3 small const int NPC_DRAW_HP_FONT_SIZE = 16; const int NPC_DRAW_HP_BG_COLOUR = 0x0F; //bacgkround, black const int NPC_DRAW_HP_FG_COLOUR = 0x01; //foreground, white //Avoid using CSets 2, 3, 4 and 6 in your colour choices. const int NPC_DRAW_HP_OPACITY = 128; //128 opaque, 64 translucent. //Graph Bar Drawing Settings const int NPC_DRAW_HP_RECT_HEIGHT = 2; const int NPC_DRAW_HP_RECT_BG_COLOUR = 0x0F; //Black, background colour. //If 0x0F is not black, set it to black in your palette. const int NPC_DRAW_HP_RECT_FG_COLOUR = 0x01; //0x01 is typically white. Set to red in your palette. //Do not use CSet 6, and avoid CSet 2, 3, and 4. const int NPC_DRAW_HP_RECT_LAYER = 2; const int NPC_DRAW_HP_RECT_X_OFFSET = 0; //X Distance from n->X const int NPC_DRAW_HP_RECT_Y_OFFSET = -3; //Y distance from n->Y const int NPC_DRAW_HP_RECT_SHADOW_X_OFFSET = 1; const int NPC_DRAW_HP_RECT_SHADOW_Y_OFFSET = 1; const int NPC_DRAW_HP_RECT_SCALE = -1; //Might need to be 100. const int NPC_DRAW_HP_RECT_RX = 0; const int NPC_DRAW_HP_RECT_RY = 0; const int NPC_DRAW_HP_RECT_RANGLE = 0; const int NPC_DRAW_HP_RECT_BG_OPACITY = 128; //background; 64 trans, 128 opaque. const int NPC_DRAW_HP_RECT_FG_OPACITY = 128; //foreground; 64 trans, 128 opaque. //Call in the global active script, while loop, prior to Waitdraw(); void DrawEnemyHP(){ for ( int q = Screen->NumNPCs(); q > 0; q-- ) { npc n = Screen->LoadNPC(q); if ( n->Type != NPCT_GUY && n->Type != NPCT_FAIRY && n->Type != NPCT_LANMOLA && n->Type != NPCT_MOLDORM && n->Type != NPCT_GLEEOK && n->Type != NPCT_PATRA && n->Type != NPCT_DODONGO && n->Type != NPCT_ROCK && n->ID != NPC_GANON ) { if ( NPC_HP_DISPLAY_BAR ) { //Black background Screen->Rectangle( NPC_DRAW_HP_RECT_LAYER, n->X+NPC_DRAW_HP_RECT_X_OFFSET+NPC_DRAW_HP_RECT_SHADOW_X_OFFSET, n->Y+NPC_DRAW_HP_RECT_Y_OFFSET+NPC_DRAW_HP_RECT_SHADOW_Y_OFFSET-NPC_DRAW_HP_RECT_HEIGHT, n->X+NPC_DRAW_HP_RECT_X_OFFSET+NPC_DRAW_HP_RECT_SHADOW_X_OFFSET+n->HP, n->Y+NPC_DRAW_HP_RECT_Y_OFFSET+NPC_DRAW_HP_RECT_SHADOW_Y_OFFSET, NPC_DRAW_HP_RECT_BG_COLOUR, NPC_DRAW_HP_RECT_SCALE, NPC_DRAW_HP_RECT_RX, NPC_DRAW_HP_RECT_RY, NPC_DRAW_HP_RECT_RANGLE, true, NPC_DRAW_HP_RECT_BG_OPACITY); //Red foreground Screen->Rectangle( NPC_DRAW_HP_RECT_LAYER, n->X+NPC_DRAW_HP_RECT_X_OFFSET, n->Y+NPC_DRAW_HP_RECT_Y_OFFSET-NPC_DRAW_HP_RECT_HEIGHT, n->X+NPC_DRAW_HP_RECT_X_OFFSET+n->HP, n->Y+NPC_DRAW_HP_RECT_Y_OFFSET, NPC_DRAW_HP_RECT_FG_COLOUR, NPC_DRAW_HP_RECT_SCALE, NPC_DRAW_HP_RECT_RX, NPC_DRAW_HP_RECT_RY, NPC_DRAW_HP_RECT_RANGLE, true, NPC_DRAW_HP_RECT_FG_OPACITY); } if ( NPC_HP_DISPLAY_NUMERALS ) { //Shadow Screen->DrawInteger(NPC_DRAW_HP_LAYER, n->X+NPC_DRAW_HP_X_OFFSET+NPC_DRAW_HP_SHADOW_OFFSET, n->Y+,NPC_DRAW_HP_Y_OFFSET+NPC_DRAW_HP_SHADOW_OFFSET, NPC_DRAW_HP_FONT, NPC_DRAW_HP_BG_COLOUR, -1, NPC_DRAW_HP_FONT_SIZE, NPC_DRAW_HP_FONT_SIZE, n->HP, 0, NPC_DRAW_HP_OPACITY); //Foreground Screen->DrawInteger(NPC_DRAW_HP_LAYER, n->X+NPC_DRAW_HP_X_OFFSET, n->Y+,NPC_DRAW_HP_Y_OFFSET, NPC_DRAW_HP_FONT, NPC_DRAW_HP_FG_COLOUR, -1, NPC_DRAW_HP_FONT_SIZE, NPC_DRAW_HP_FONT_SIZE, n->HP, 0, NPC_DRAW_HP_OPACITY); } } } } global script draw_npc_hp_example{ void run(){ while(true){ DrawEnemyHP(); Waitdraw(); Waitframe(); } } }
I added in drawing boxes, either with, or instead of the numerals. This should draw a box with a shadow a number of pixels equal to the present HP of the NPC.
- ShadowTiger likes this
#3
Posted 08 January 2017 - 01:02 PM
Now if I were to add that with this...
import "std.zh" global script GlobalScript { void run() { while(true) { EnemyDamage(); Waitframe(); } } } // Set this to the font colour you want. It is set to 1 (white) by default. const int DMG_FONTCOL=1; // Set this to three different unused slots for the npc->Misc[] values. If you don't have any other script using those, the default values are fine. const int DMG_MISC1=1; const int DMG_MISC2=2; const int DMG_MISC3=3; void EnemyDamage(){ int offset; for(int i=1;i<=Screen->NumNPCs();i++){ npc enem=Screen->LoadNPC(i); if(enem->Misc[DMG_MISC1]==0){ enem->Misc[DMG_MISC1]=1; enem->Misc[DMG_MISC2]=enem->HP; enem->Misc[DMG_MISC3]=0; } if(enem->Misc[DMG_MISC1]!=0&&enem->HP<enem->Misc[DMG_MISC2]){ enem->Misc[DMG_MISC1]=45; enem->Misc[DMG_MISC3]=enem->Misc[DMG_MISC2]-enem->HP; enem->Misc[DMG_MISC2]=enem->HP; } if(enem->Misc[DMG_MISC1]>1){ if(enem->Misc[DMG_MISC3]>9){offset=0;} else{offset=4;} if(enem->Misc[DMG_MISC1]%3!=0)Screen->DrawInteger(6, enem->X+offset, enem->Y-18+(enem->Misc[DMG_MISC1]/5), FONT_Z1, DMG_FONTCOL, -1, -1, -1, enem->Misc[DMG_MISC3], 0, 128); enem->Misc[DMG_MISC1]--; } } } ffc script showBossHealth{ void run(){ npc boss; int theboss = 0; int highest = 0; int numNPCs = 0; int red = 108; //value can be modified depending on tileset palette int white = 17; //value can be modified depending on tileset palette int xoffset = 3; //initial x offset for top left rectangle int yoffset = 20; //initial y offset for top left rectangle while(Link->Action == LA_SCROLLING){ Waitframe(); } Waitframe(); //necessary to let ZC load everything on the screen before checking for a boss Waitframe(); numNPCs = Screen->NumNPCs(); //check all NPCs on the screen and define the boss as the one with the most HP if(numNPCs > 0){ for(int i = 1; i<=numNPCs; i++){ boss = Screen->LoadNPC(i); if(boss->isValid() && boss->HP > highest){ highest = boss->HP; theboss = i; } } } boss = Screen->LoadNPC(theboss); //display boss health meter whilst the boss is alive while(boss->isValid()){ float bossHealth = (boss->HP/highest) * 8; int shaded = Ceiling(bossHealth); int colour; for(int i=0; i<8; i++){ if(8-i > shaded) colour = white; else colour = red; Screen->Rectangle(0, xoffset, yoffset+8*i, xoffset+8, yoffset+8*i+5, colour, 1, 0, 0, 0, true, 128); } Waitframe(); } } } item script Message{ void run(int m){ Screen->Message(m); } }
How would I go about that?
#4
Posted 08 January 2017 - 01:07 PM
edited
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#5
Posted 08 January 2017 - 01:11 PM
Okay, I tried the script by itself, and this is what I got:
PASS 1: PARSING
LINE 76: SYNTAX ERROR, UNEXPECTED COMMA, ON TOKEN ,
FATAL ERROR P00: CAN'T OPEN OR PARSE INPUT FILE!
I tired that new one and A different error popped up.
PASS 1: PARSING
LINE 174: SYNTAX ERROR, UNEXPECTED COMMA, ON TOKEN ,
FATAL ERROR P00: CAN'T OPEN OR PARSE INPUT FILE!
Edited by Mibbitable, 08 January 2017 - 01:13 PM.
#6
Posted 08 January 2017 - 02:15 PM
You can even take out the boss health script if that will cause some problems with the enemy health.
#7
Posted 08 January 2017 - 02:24 PM
////////////////////// /// Display NPC HP /// /// v0.2 /// /// 8th Jan, 2017 /// /// By: ZoriaRPG /// ////////////////////// //Base Settings. const int NPC_HP_DISPLAY_BAR = 1; //Set to 1 to draw graph bars, 0 to disable. const int NPC_HP_DISPLAY_NUMERALS = 1; //Set to 1 to draw the HP as numerals, 0 to disable. //Numeral Drawing Settings const int NPC_DRAW_HP_LAYER = 2; const int NPC_DRAW_HP_X_OFFSET = -4; //Distance from NPC on X axis. const int NPC_DRAW_HP_Y_OFFSET = -4; //Distance from enemy on Y axis. const int NPC_DRAW_HP_SHADOW_OFFSET = 1; //Distance of the drop shadow fromt he foreground text. const int NPC_DRAW_HP_FONT = 2; //z3 small const int NPC_DRAW_HP_FONT_SIZE = 16; const int NPC_DRAW_HP_BG_COLOUR = 0x0F; //bacgkround, black const int NPC_DRAW_HP_FG_COLOUR = 0x01; //foreground, white //Avoid using CSets 2, 3, 4 and 6 in your colour choices. const int NPC_DRAW_HP_OPACITY = 128; //128 opaque, 64 translucent. //Graph Bar Drawing Settings const int NPC_DRAW_HP_RECT_HEIGHT = 2; const int NPC_DRAW_HP_RECT_BG_COLOUR = 0x0F; //Black, background colour. //If 0x0F is not black, set it to black in your palette. const int NPC_DRAW_HP_RECT_FG_COLOUR = 0x01; //0x01 is typically white. Set to red in your palette. //Do not use CSet 6, and avoid CSet 2, 3, and 4. const int NPC_DRAW_HP_RECT_LAYER = 2; const int NPC_DRAW_HP_RECT_X_OFFSET = 0; //X Distance from n->X const int NPC_DRAW_HP_RECT_Y_OFFSET = -3; //Y distance from n->Y const int NPC_DRAW_HP_RECT_SHADOW_X_OFFSET = 1; const int NPC_DRAW_HP_RECT_SHADOW_Y_OFFSET = 1; const int NPC_DRAW_HP_RECT_SCALE = -1; //Might need to be 100. const int NPC_DRAW_HP_RECT_RX = 0; const int NPC_DRAW_HP_RECT_RY = 0; const int NPC_DRAW_HP_RECT_RANGLE = 0; const int NPC_DRAW_HP_RECT_BG_OPACITY = 128; //background; 64 trans, 128 opaque. const int NPC_DRAW_HP_RECT_FG_OPACITY = 128; //foreground; 64 trans, 128 opaque. //Call in the global active script, while loop, prior to Waitdraw(); void DrawEnemyHP(){ for ( int q = Screen->NumNPCs(); q > 0; q-- ) { npc n = Screen->LoadNPC(q); if ( n->Type != NPCT_GUY && n->Type != NPCT_FAIRY && n->Type != NPCT_LANMOLA && n->Type != NPCT_MOLDORM && n->Type != NPCT_GLEEOK && n->Type != NPCT_PATRA && n->Type != NPCT_DODONGO && n->Type != NPCT_ROCK && n->ID != NPC_GANON ) { if ( NPC_HP_DISPLAY_BAR && n->HP > 0 ) { //Black background Screen->Rectangle( NPC_DRAW_HP_RECT_LAYER, n->X+NPC_DRAW_HP_RECT_X_OFFSET+NPC_DRAW_HP_RECT_SHADOW_X_OFFSET, n->Y+NPC_DRAW_HP_RECT_Y_OFFSET+NPC_DRAW_HP_RECT_SHADOW_Y_OFFSET-NPC_DRAW_HP_RECT_HEIGHT, n->X+NPC_DRAW_HP_RECT_X_OFFSET+NPC_DRAW_HP_RECT_SHADOW_X_OFFSET+n->HP, n->Y+NPC_DRAW_HP_RECT_Y_OFFSET+NPC_DRAW_HP_RECT_SHADOW_Y_OFFSET, NPC_DRAW_HP_RECT_BG_COLOUR, NPC_DRAW_HP_RECT_SCALE, NPC_DRAW_HP_RECT_RX, NPC_DRAW_HP_RECT_RY, NPC_DRAW_HP_RECT_RANGLE, true, NPC_DRAW_HP_RECT_BG_OPACITY); //Red foreground Screen->Rectangle( NPC_DRAW_HP_RECT_LAYER, n->X+NPC_DRAW_HP_RECT_X_OFFSET, n->Y+NPC_DRAW_HP_RECT_Y_OFFSET-NPC_DRAW_HP_RECT_HEIGHT, n->X+NPC_DRAW_HP_RECT_X_OFFSET+n->HP, n->Y+NPC_DRAW_HP_RECT_Y_OFFSET, NPC_DRAW_HP_RECT_FG_COLOUR, NPC_DRAW_HP_RECT_SCALE, NPC_DRAW_HP_RECT_RX, NPC_DRAW_HP_RECT_RY, NPC_DRAW_HP_RECT_RANGLE, true, NPC_DRAW_HP_RECT_FG_OPACITY); } if ( NPC_HP_DISPLAY_NUMERALS && n->HP > 0 ) { //Shadow Screen->DrawInteger(NPC_DRAW_HP_LAYER, n->X+NPC_DRAW_HP_X_OFFSET+NPC_DRAW_HP_SHADOW_OFFSET, n->Y+NPC_DRAW_HP_Y_OFFSET+NPC_DRAW_HP_SHADOW_OFFSET, NPC_DRAW_HP_FONT, NPC_DRAW_HP_BG_COLOUR, -1, NPC_DRAW_HP_FONT_SIZE, NPC_DRAW_HP_FONT_SIZE, n->HP, 0, NPC_DRAW_HP_OPACITY); //Foreground Screen->DrawInteger(NPC_DRAW_HP_LAYER, n->X+NPC_DRAW_HP_X_OFFSET, n->Y+NPC_DRAW_HP_Y_OFFSET, NPC_DRAW_HP_FONT, NPC_DRAW_HP_FG_COLOUR, -1, NPC_DRAW_HP_FONT_SIZE, NPC_DRAW_HP_FONT_SIZE, n->HP, 0, NPC_DRAW_HP_OPACITY); } } } } global script draw_npc_hp_example{ void run(){ while(true){ DrawEnemyHP(); Waitdraw(); Waitframe(); } } }
Edited by ZoriaRPG, 08 January 2017 - 02:53 PM.
- Mibbitable likes this
#8
Posted 08 January 2017 - 02:34 PM
Everything compiled okay, but nothing appears in any of the "Assign Compiled Script" tab.
Am I doing something wrong?
#9
Posted 08 January 2017 - 02:53 PM
I edited the above post with it uncommented, for reference.
#10
Posted 08 January 2017 - 04:39 PM
Works perfectly! <3
Now how can I add that to my other scripts?
#11
Posted 08 January 2017 - 06:27 PM
And I have a little issue, some of my enemy's have extraordinary health, is there a way to have the bar not grow and just stay one size? Or will that be too much of a issue? I can work around it if so.
#12
Posted 10 January 2017 - 09:35 PM
I'm picturing a wind waker style.
#13
Posted 10 January 2017 - 11:23 PM
I could vbound it so that it is never larger than N, easily enough.
My apologies for the lack of script support. I thought that someone else might explain it, as I'm rather bus, even now, and it will be a day, or two, before I can provide anything further. It seems that you have configured it.
- Mibbitable likes this
#14
Posted 11 January 2017 - 11:50 AM
Take all the time you need! No rush!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users