PDA

View Full Version : The Crab_boss script (yes "The"; 'cause as we all know there's lots of crab scripts.)



Gleeok
11-02-2007, 03:01 AM
Do you need and endless supply of ffc's being hurled at Link from a Giant Crab-like monster? If so then look no further. Because i've got crabs, and now you can have crabs too. :p

http://i233.photobucket.com/albums/ee49/Gleeok9/zelda025.png


This is my first fully completed boss script, but not to be the last! ..Anyway most of you will have no use for this script because, well...It's designed to kill you. :eyebrow: But that's why there's variables I guess. So you can set 'em up however you like. Although I guess you could give Link more equipment too...I'm mostly posting this for simplicity and learning purposes for future scripters. But if anyone actually uses it then that's great too. :D




//================================================== =========================
// ***FFC SCRIPT CRAB BOSS***
// Link FFC's to this ffc to make it any way you like. :D
// this ffc expects to be in the upper part of the screen. It will move left and right
// and fire projectiles at downward angles.
//D0 the number of this ffc
//D1 enemy HP
//D2 enemy speed
//D3 bubble speed
//D4 the combos to be used as bubble projectiles
//D5 the cset of the bubble projectiles
//D6 0=constant movement, 1=randomly stops for a short time
//================================================== =========================

ffc script Crab_boss{

void run(int this_ffc_number, int enemyHP, int crabspeed, int bubblespeed, int bubble_combo, int cset, int constant){

ffc this_ffc = Screen->LoadFFC(this_ffc_number);
if(this_ffc_number == 0){ this_ffc_number = 1; }
if(enemyHP == 0){ enemyHP = 100; }
if(bubblespeed == 0){ bubblespeed = 1; }
int delay = 0;
int attack_state = 0; // 0=moving, 1=standing still
int movement_state = 0; // 0=right, 1=left
int switch_state = 0;
int bubble_ffc = 10;
int crab_stopped = 0;
int RandNum;
int screen_enemy_number = Screen->NumNPCs();

ffc bubble;

Waitframes(4);

npc crablife = Screen->LoadNPC(1);
crablife->HP = enemyHP;

while(true){

if((delay == 60) && (crablife->HP > enemyHP*0.8)){ delay = 0;}
if((delay == 150)&&(crablife->HP <= enemyHP*0.8)&&(crablife->HP > enemyHP*0.35)){ delay = 0;}
if((delay == 200) && (crablife->HP <= enemyHP*0.35)){ delay = 0;}
delay++;

if(bubble_ffc >= 23){ bubble_ffc = 10;}

crablife->X = this->X; crablife->Y = this->Y;

if(this_ffc->X <= 64){ movement_state = 0;}
if(this_ffc->X >= 180){ movement_state = 1;}


//===========================
//ENEMY MOVEMENT
//===========================

if(crab_stopped > 0){ crab_stopped--;}
if(crab_stopped == 0){ attack_state = 0;}

if(movement_state == 0 && attack_state == 0){this_ffc->Vx = crabspeed;}
if(movement_state == 1 && attack_state == 0){this_ffc->Vx = -crabspeed;}
if(movement_state == 0 && attack_state == 1){this_ffc->Vx = 0;}
if(movement_state == 1 && attack_state == 1){this_ffc->Vx = 0;}

if((constant == 1)&&(switch_state == 0)){RandNum = Rand(180);switch_state = 1;}
if((constant == 1)&&(switch_state == 1)){
RandNum++;
if(RandNum == 180){
attack_state = 1; switch_state = 0; crab_stopped = 30;
}
}
if((this_ffc->X > Link->X)&&(this_ffc->Y >= Link->Y-8)){ this_ffc->Vx = -crabspeed-0.2; crab_stopped = 0; movement_state = 1;}
if((this_ffc->X < Link->X)&&(this_ffc->Y >= Link->Y-8)){ this_ffc->Vx = crabspeed+0.2; crab_stopped = 0; movement_state = 0;}


//===========================
//ENEMY FIRE
//===========================

if(crablife->HP > enemyHP*0.8){

if((delay == 15)||(delay == 45)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble_ffc++; }
if(delay == 30){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = bubblespeed*0.8;
bubble_ffc++;}
if(delay == 60){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = -bubblespeed*0.8;
bubble_ffc++;}
}
if((crablife->HP <= enemyHP*0.8)&&(crablife->HP > enemyHP*0.35)){

if((delay == 10)||(delay == 50 )||(delay == 90)||(delay == 130)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = 0;
bubble_ffc++; }
if((delay == 20)||(delay == 40 )||(delay == 100)||(delay == 120)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = bubblespeed*0.6;
bubble_ffc++; }
if((delay == 30)||(delay == 110 )){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed*0.8;
bubble->Vx = bubblespeed;
bubble_ffc++; }
if((delay == 60)||(delay == 80 )||(delay == 140)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = -bubblespeed*0.6;
bubble_ffc++; }
if((delay == 70)||(delay == 150 )){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed*0.8;
bubble->Vx = -bubblespeed;
bubble_ffc++; }
}
if(crablife->HP <= enemyHP*0.35){

if((delay == 7)||(delay == 49 )||(delay == 91)||(delay == 133)||(delay == 175)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = 0;
bubble_ffc++; }

if((delay == 14)||(delay == 42 )||(delay == 98)||(delay == 126)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = bubblespeed*0.4;
bubble_ffc++; }
if((delay == 21)||(delay == 35 )||(delay == 105)||(delay == 119)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = bubblespeed*0.8;
bubble_ffc++; }
if((delay == 28)||(delay == 112)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed*0.9;
bubble->Vx = bubblespeed*1.2;
bubble_ffc++; }
if((delay == 56)||(delay == 84 )||(delay == 140)||(delay == 168)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = -bubblespeed*0.4;
bubble_ffc++; }
if((delay == 63)||(delay == 77 )||(delay == 147)||(delay == 161)){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed;
bubble->Vx = -bubblespeed*0.8;
bubble_ffc++; }

if((delay == 70)||(delay == 154 )){
bubble = Screen->LoadFFC(bubble_ffc);
bubble->Data = bubble_combo;
bubble->CSet = cset;
bubble->X = this->X;
bubble->Y = this->Y + 8;
bubble->Vy = bubblespeed*0.9;
bubble->Vx = -bubblespeed*1.2;
bubble_ffc++; }
}

Waitframe();
}
}
}


=================***READ***==================

I do some things a little different than you may be used to. First is this script does not create an enemy. It assumes you have a screen enemy set and enemies->secrets is probably enabled. It then uses this enemy for fuel, increasing it's HP and such. DO NOT USE "ENTER FROM SIDES'.

Next: Do NOT use FFC's 10-23 for anything! don't even set anything on them. The script does all the work and will use these for it's own twisted scheme.

-Variables-

//D0 the number of this ffc : You can blame C- for this. ;) I got used to reading through his stuff a while back, so I'll accidentally type this_ffc instead of this, and then it won't compile, so now I just add this by default.

//D1 enemy HP
//D2 enemy speed
//D3 bubble speed : I'd test this at 1 before you set it any higher than that.
//D4 the combos to be used as bubble projectiles
//D5 the cset of the bubble projectiles
//D6 0=constant movement, 1=randomly stops for a short time

Others self explanitory.

-Oh, and if anyone is wondering why there's no demo it's because there's a bug with damage combo's in 635. *hint* devs fix pwease...

Have fun.

C-Dawg
11-02-2007, 10:02 AM
There is at least ONE other crab boss script out there, you know. ;)

As for using this_ffc: If it's fixed, great, but I tried it a few builds back when DarkDragon said it was fixed, and it wasn't. For now, I've been able to avoid using up all seven Data fields, so I still use this_ffc_number.

Good job, Gleeok!



Oh, and if anyone is wondering why there's no demo it's because there's a bug with damage combo's in 635. *hint* devs fix pwease...

Have fun.

Wait what?

Majora
11-02-2007, 10:30 AM
WTF

NEEDS MOAR DIABABA


Joking aside, this is pretty bad-ass. Nicely done! Maybe I'll use it in my quest.

Russ
11-02-2007, 11:12 AM
Looks good. But what do you mean by D0 equals the number of the freeform combo?

C-Dawg
11-02-2007, 11:30 AM
Looks good. But what do you mean by D0 equals the number of the freeform combo?

D0, D1, D2, D3, D4, D5, D6, D7 are the "arguments" you can enter in the FFC when you set it up in ZQuest. This lets you re-use the same script on multiple FFCs and modify it. For example, this crab boss could occur several times in the quest, with more health and speed each time. Just change the arguments when you attach the script to an FFC.

My habit, that Gleeok has adopted, is to copy the Number of the FFC (they are numbered 1 through 32) into the D0 argument. Then the script knows exactly what FFC to load up and move around pursuant to the script. If the "this" function is now properly implemented, you don't really need to do this anymore.

Using "this_ffc" instead of "this," which is short hand for passing the number of the FFC explicitly in D0, has some other flexibility. You could, if you wanted, put the script on one FFC and then tell the script it is acting on ANOTHER FFC. This might be useful if you want two scripts running on the same FFC at once. So you could have one script making an FFC move around, another making it ghost an enemy, and a third shooting other FFCs, for instance. (I plan on making use of this in the Megaman toolbox Gleeok and I are tinkering with. This is the only way I know of to easily make custom bosses modular for people who don't want to bother with ZScripting.)

Russ
11-02-2007, 02:18 PM
I know what the augments are. I just was confused about what the first augment of this script does.

Joe123
11-02-2007, 05:13 PM
I got caught by that 'this_ffc' of yours too C :P
Managed to escape to 'this' after not too long though :D

Gleeok
11-02-2007, 06:02 PM
Yeah, it comes in handy. I'm working on some new scripts that have this_ffc, other_ffc, and i'm tinkering with an additional third_ffc and fourth_ff. :D To anyone wondering as to why, let me explain:

What this will do is allow you to set these;
A) to any ffc slot you want,
B) to have each ffc able to read and change data from other ffc's,
C) be able to coordinate simple and complex tasks between them


For an example of this think Portal script or Mothula script.;)


Megaman toolbox

That reminds me I need to add all the 2x2 enemies, which is basically All the bosses from 1-4(8 combos of 2x2 large ffc's, [standing, moving, jumping, firing] for left and right) and weapon animation, and some other enemies. I have all the sprites, I've just need to rip them.