Boss Meter
#1
Posted 11 April 2008 - 01:20 PM
Wouldn't it be possible to use the Rectangle Drawing command to draw an HP bar for an Enemy on the screen? The script would check the enemy in Slot 1's current HP every frame, then draw the Rectangle that starts at the FFC's x position and spans 4 pixels to the right for every unit of HP the enemy has. (Some simple math formulas would do the trick.)
After all, normal boss enemies should have HP meters too, not just custom ones.
How hard would this be?
#2
Posted 11 April 2008 - 01:55 PM
What would be a better way of doing it would be to use an ffc's graphic.
Set the script to divide the enemy's HP into quarters (or more divisions if you like), and then change the ffc's graphic to something different as its health goes down.
#3
Posted 11 April 2008 - 05:54 PM
Unless the meter could draw one 8x8 tile for every HP the boss has... but even so, I think my idea would be the way to go, 'cause it's more exact.
#4
Posted 11 April 2008 - 06:51 PM
You want DrawTile for boss HP "blocks", or Rectangle for a bar. However if you draw a custom life bar in the tile page you can use that too. Might look slightly better than just a Rectangle.
#5
Posted 12 April 2008 - 02:32 AM
But the blocks can work pretty nice too, 'cause you can have "notches" like the Megaman HP meters... which would be totally awesome IMO, but probably quite more difficult to code (except for you, Gleeok, 'cause you're PZC's Scripting God as far as I'm concerned).
I'm very new to scripting... but I've coded in SNES ASM before, while I was on the Super Mario World Rom Hacking scene, and I learned it pretty fast, so with a little practice I may be able to pick up ZScript pretty fast too. If I make the Boss Meter on my own, it'll be my first script (well, second actually, but my first script is A) gone from my hard drive and B) mostly done for me by someone else ). Doesn't hurt to give it a try though, I suppose. But Gleeok and Joe, you guys have to bail me out if I eff this one up. I'll keep you updated when I either succeed or run into a snag. ^_^
#6
Posted 12 April 2008 - 04:36 AM
The simplest method off the top of my head is easily:
..well lets see:
ffc script test_lifebar{
void run(){
Waitframes(4); int result; int p;
npc enemy = Screen->LoadNPC(1);
int maxHP = enemy->HP;
while(true){
Waitframe(); p=0;
for(float i=100;i>0;i-=5){
if(enemy->HP>maxHP*(i/100){result=p;i=0;}p++;
}
Screen->DrawTile(6,x,y,starting_tile+result,1,tile_height,cset,1,0,0,0,0,true,128);
}
}
}
untested but just fill in the DrawTile slots with the correct data and it should work....assuming the tiles are arranged in a group of 20 like I mentioned from left to right; full life----->dead.
#7
Posted 12 April 2008 - 04:56 AM
Unless the meter could draw one 8x8 tile for every HP the boss has... but even so, I think my idea would be the way to go, 'cause it's more exact.
How is not exact?
You can make the meter look like anything you like cause you just draw from the tiles instead of having to set up complex primitive routines.
It's far superior...
#8
Posted 12 April 2008 - 08:14 AM
It creates any enemy you choose, and gauges it's HP in the form of a rectangle bar (actually two rectangles-- trust me, it looks nicer).
What I want to do instead though is get the script to gauge the first Screen Enemy on the list, rather than create a brand new enemy and gauge that one. This is so I can get Ring Leader rooms to work properly and also so the boss enemy doesn't return every time you come back to the room.
I'll work on it a little more... Any tips you can give me? Last time I seemed to have trouble getting the script to recognize the ID of the first Screen Enemy on the list... It wouldn't be recognized and instead just wrote an error to Allegro, even though I tested both ID values 0 and 1. I assume now it's more complicated than that.
#9
Posted 12 April 2008 - 08:24 AM
That is pretty clever actually, better than my method.
I thought you were going to draw lots of rectangular blocks.
To load the enemy on the screen, put 'Waitframes(4);' before 'Screen->LoadNPC(1)', because the system has to wait for 4 frames before it recognises the enemy.
#10
Posted 13 April 2008 - 04:54 PM
That is pretty clever actually, better than my method.
I thought you were going to draw lots of rectangular blocks.
Ah, no no... That method would've been a bit tedious and unconventional. Thanks for the compliment. ^_^ Once I got this script perfect, I'll make a second version that draws a bar that looks like a parallelagram instead of a rectangle. Then I'll post both versions.
SH1T! It would've been nice to know this earlier... This is SO helpful! Thanks so much!
I decided to give something else a try though... My new goal is to make the script spawn the boss enemy on the screen and gauge IT'S health. Right now it works, but if you kill it, it always comes back when you leave the screen and come back. I want it to not do this. And the way I thought to fix this problem would be to set up a Custom Array, indexed by the current Screen and Map number.
My problem: I have NO idea how the code for a custom Array is supposed to look. And the description on the Shardstorm updates website only confused the hell out of me.
If someone could help me with that, I would be grateful.
What I do know about custom Arrays is that they can either be one or two dimensional... but that's about it.
#11
Posted 13 April 2008 - 07:10 PM
SH1T! It would've been nice to know this earlier... This is SO helpful! Thanks so much!
Ahem* See post number 6.
And the array:
http://www.armageddo...threadid=102190
#12
Posted 14 April 2008 - 08:02 AM
Thanks to Matthew, Gleeok and Joe123 for the advice I needed to pull this off.
And AWESOME, this is one of the first Array-using scripts.
//By: Schwa
//- - - - - - - -
//What this does:
//This script spawns an enemy of your choice to any X Y screen location you want. As long
//as this enemy is alive, the enemy's HP will be gauged in the form of a bar at the top
//of the screen. When the enemy dies, the bar will vanish, and every other enemy on the
//screen will die on the spot. The killed "boss" enemy will NEVER reappear.
//- - - - - - - -
//Customizability:
//*Set D0 to decide which enemy is being spawned. Use the constants in std.zh to help.
//*Set D1 and D2 to choose the X and Y position of the spawned enemy, respectively. This
// is important because enemies like Aquamentus need to start at certain screen positions
// and due to the nature of the script, this must be done manually.
//*Set D3 to set the "Fight ID" of the fight. This is what makes the enemy never reappear
// when you kill it. No two instances of this script should ever have the same Fight ID,
// or else killing one boss will kill any bosses of the same Fight ID. It can be any
// value from 0 to 255. If you need more room, change "int garr_bosskill[255]" to some
// higher value.
//- - - - - - - -
//Limitations:
//This script won't work so well with Gleeok, Patra and probably Manhandla. It's meant for
//you to make your own enemies in the Enemy Editor, such as stronger versions of existing
//basic enemies, and use them as bosses. It might be possible to combine this script with
//C-Dawg's Ghosting Script for more possibilities... We'll see what happens.
//- - - - - - - -
int garr_bosskill[255];
import "std.zh"
ffc script scr_bossmeter
{
void run(int enemy_id, int enemy_x, int enemy_y, int fight_id)
{
this->X = 0;
this->Y = 0;
if (garr_bosskill[fight_id] == 0)
{
npc var_enemynum = Screen->CreateNPC(enemy_id);
int var_maxhp = var_enemynum->HP;
var_enemynum->X = enemy_x;
var_enemynum->Y = enemy_y;
while(var_enemynum->isValid() && var_enemynum->HP > 0)
{
Screen->Rectangle(6, (this->X + 32), this->Y, (this->X + 32 + (var_enemynum->HP * 2)), (this->Y + 8), 82, 1, 0, 0, 0, true, 128);
Screen->Rectangle(6, (this->X + 32), this->Y, (this->X + 32 + (var_maxhp * 2)), (this->Y + 8), 81, 1, 0, 0, 0, false, 128);
Waitframe();
}
int e = Screen->NumNPCs();
int i;
while(i++ < e)
{
npc autokill = Screen->LoadNPC(i);
autokill->HP = 0;
}
}
garr_bosskill[fight_id] = 1;
this->Y -= 128;
Quit();
}
}
My future goals with this are to figure out how to combine it with a Ghosting Script, and to make an alternate version of this with a parallelagram bar instead of a rectangle bar.
Let me know what you guys think of my first script in Zelda Classic!
#13
Posted 05 May 2008 - 10:27 AM
Actually the "notches" would be the easiest way of doing it imo. You could have each notch represent 5% of the bosses hp, so you could easily draw a bar in the tiles page 1 tile wide X tiles tall, then copy/ paste it 19 times and fill in the hp portion of it. Walla, instant MegaMan life bar. No need to combo it either.
Parallel evolution or failure to cite consulting authority? You decide!
Not that I mind. Spread the knowledge.
#14
Posted 05 May 2008 - 09:49 PM
Parallel evolution or failure to cite consulting authority? You decide!
Not that I mind. Spread the knowledge.
...heh. I feel bad now that you posted that. I honestly haven't looked at how you were doing it in Zodiac (I'm ashamed)....I thought for some reason you were using a Rectangle to make the boss meter.
On the subject of paralell evolution; It seems there's only a few 'good' ways to go about scripting complex manuevers, but a lot of bad ways. It doesn't suprise me in the least that occaisionally I will write something strikingly familiar to you. You know what they say; Great minds think alike. Hahaha... Yeah, I'll have to look through a newer version of Zodiac and see what you've been up to. BTW; Even though all the code and graphics i'm using are 100% original, You are the first non-dev to make the credits in this quest...That's something right?
#15
Posted 06 May 2008 - 01:16 AM
He he he =P
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users