PDA

View Full Version : "Normal" Boss Battle script



Schwa
04-14-2008, 12:53 AM
First off: This is my first script. I had another one once, but pikaguy900 wrote 95% of it for me... This one I figured out mostly on my own, but pikaguy900 taught me about Global Variables, and Gleeok showed me how to create Arrays and gave me the code to kill all enemies on the screen. :D

Now then... This script allows for boss fights with regular enemies rather than custom ones... by drawing a HP gauge for any enemy you choose... and then some. Read the comment tags at the top of the script and see what it does! :D


//***"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();
}
}
Test it out and tell me what you think! Not bad for my first script, eh? ...Eventually I'll need a way to combine this with C-Dawg's Ghosting Script, but that shouldn't be too hard at all, unless there are certain factors I'm overlooking.

Thanks to everyone who helped me out, and everyone who enjoys my first script! Cheers! :D :D

P.S. Yes, this code uses an Array... and to my knowledge it's one of the first scripts to do so. Someone will need to add some info to the Wiki soon, methinks.

Gleeok
04-14-2008, 01:05 AM
Hey good job and congrats on your first script. :)

One suggestion though; Since this script could be used in conjuction with another boss script, Maybe people might like an alternate version of the bossmeter script using LoadNPC.

Joe123
04-14-2008, 03:04 AM
Wow, very flash.

I think my first script was

ffc script{
void run(){
while(true){
Link->InputL = false;
Waitframe();
}
}
}

>_<



Anyway, well done ^_^

Schwa
04-14-2008, 03:45 AM
Thanks guys. ^_^


One suggestion though; Since this script could be used in conjuction with another boss script, Maybe people might like an alternate version of the bossmeter script using LoadNPC.
This was my original intent, so I could get it to work with Ring Leaders and Enemies holding Items... LoadNPC was fritzing out on me though. It wouldn't recognize anything when I tried putting "1" as the NPC to load, so I assumed that Enemy ID values were calculated in weird orders, which I wasn't really able to decipher.

Also at some point I want to make an alternate version of this script where the bar is a parallelagram instead of a rectangle. ;)