Jump to content

Photo

Boss Meter


  • Please log in to reply
18 replies to this topic

#1 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 11 April 2008 - 01:20 PM

I just thought of a cool idea.

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. icon_biggrin.gif

How hard would this be?

#2 Joe123

Joe123

    Retired

  • Members

Posted 11 April 2008 - 01:55 PM

It'd be really easy, but I wouldn't do it using primitives.

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 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 11 April 2008 - 05:54 PM

I don't like that way of doing it. It's too much like traditional custom boss meters. >_<

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 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 11 April 2008 - 06:51 PM

The way I'm doing it is there is a horizontal bar at the top of the screen that runs the length of the screen. Of course this isn't exactly practical for zelda type quests because I give bosses *tons* of HP. In fact the lv1 boss has 800 hit points.

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 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 12 April 2008 - 02:32 AM

Well, one nice thing about the Rectangle bar is that, in your case when you give your bosses super high HP like 800, you can just make the Rectange 1 pixel wide per HP unit, rather than 4... giving you more room.

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 icon_cry.gif ). 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. icon_blah.gif I'll keep you updated when I either succeed or run into a snag. ^_^

#6 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 12 April 2008 - 04:36 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.

The simplest method off the top of my head is easily:

..well lets see:

CODE

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 Joe123

Joe123

    Retired

  • Members

Posted 12 April 2008 - 04:56 AM

QUOTE(Schwa @ Apr 11 2008, 11:54 PM) View Post

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 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 12 April 2008 - 08:14 AM

Well, I hope you guys are proud of me. I just created my first working script all on my own. icon_biggrin.gif

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 Joe123

Joe123

    Retired

  • Members

Posted 12 April 2008 - 08:24 AM

Oh wait, so your script gauges the rectangle by the size of the boss's health?

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 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 13 April 2008 - 04:54 PM

QUOTE(Joe123 @ Apr 12 2008, 06:24 AM) View Post
Oh wait, so your script gauges the rectangle by the size of the boss's health?

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.

QUOTE(Joe123 @ Apr 12 2008, 06:24 AM) View Post
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.

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 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 13 April 2008 - 07:10 PM

QUOTE(Schwa @ Apr 13 2008, 02:54 PM) View Post

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 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 14 April 2008 - 08:02 AM

Well, I finished this several hours ago, but I'll post it here; I only posted it at AGN so far.

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. icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif

CODE
//***"Normal" Boss Battle Script***
//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! icon_biggrin.gif

#13 C-Dawg

C-Dawg

    Magus

  • Members

Posted 05 May 2008 - 10:27 AM

QUOTE(Gleeok @ Apr 12 2008, 03:36 AM) View Post

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 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 May 2008 - 09:49 PM

QUOTE(C-Dawg @ May 5 2008, 08:27 AM) View Post

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 Joe123

Joe123

    Retired

  • Members

Posted 06 May 2008 - 01:16 AM

You're not using that integer I wrote for you then?
He he he =P


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users