PDA

View Full Version : Enemy Booster



C-Dawg
12-19-2006, 01:06 PM
This is a script for an enemy boosting FFC, but it has applications outside of that. Have it rotate around Link, and set it to decrease enemy HP instead of increase it, and you've made an offensive weapon, for example.



// ================================================== ====
// ENEMY_BOOSTER - This FFC will boost the attributes of any npc that
// comes within 16 pixels of it. After triggering, the FFC will switch to the next
// combo and deactivate for a certain period of time. If you don't want the booster
// to boost all attributes, leave those variables set to 0.
// Most variables can be negative, making this into an enemy weakener.
// D0 - The amount by which the enemy's hit points will be boosted.
// D1 - The amount by which the enemy's damage will be boosted.
// D2 - The amount by which the enemy's movement rate will be boosted.
// D3 - The new Cset that will be assigned to the enemy once it has been boosted.
// D4 - The number of tics that the booster will remain deactivated after activating.
// ================================================== ==============


ffc script enemy_booster{

void run( int hitpoint_boost; int damage_boost; int speed_boost; int cset_boost; int delay){

int enemy_num = 0; // Used to check how many enemies there are
// on a screen each tic.
int counter = 1; // Used to check location of each enemy in turn.

npc current_enemy; // Used to load up each enemy in turn.

int state = 1; // Prevents pumping up enemy too much by turning off
// for a few tics once an enemy triggers it.
// 0 = Active
// 1+ = Inactive

while(true){

counter = 1;
enemy_num = Screen->NumNPCs();


// Check each npc on the screen's location. If it is within 16 tiles of this FFC, apply the
// boosts to that npc and then deactivate.

while ( (counter <= enemy_num) && state = 0){
current_enemy = Screen->LoadNPC(counter);
if ( (current_enemy->X < this->X + 16) && (current_enemy->X > this->X - 16) &&
(current_enemy->Y < this->Y + 16) && (current_enemy->Y > this->Y - 16) ){

this->HP = this->HP + hitpoint_boost;
this->Damage = this->Damage + damage_boost;
this->Rate = this->Rate + speed_boost;

state = 1;
this->Data++;

if (cset_boost !=0){ this->Cset = cset_boost; }

} // end if
counter++;
} // end of internal while

// Deactive once an enemy has been boosted. Stay deactivated for delay tics.

if ( state != 0 ){
if (state = delay) { state = 0; this->Data--; }
else ( state++ }
} // end if

Waitframe();

} // end of while

} // end of void run

} // end of script

_L_
12-20-2006, 10:04 AM
If this works fine, shouldn't it be in the Showcase forum?

ShadowTiger
12-20-2006, 11:55 AM
I get an error when I try to import this and compile it in ZQuest:

Pass 1: Parsing
Line 17: Syntax Error, Unexpected Semicolon, Expecting RPAREN, On Token ;
Fatal Error P00: Can't Open or Parse Input File!

-- Press A Key --


void run( int hitpoint_boost; int damage_boost; int speed_boost; int cset_boost; int
delay){ This seems to be the line causing it. I think. ._o' There's probably a word wrap issue on my end, come to think of it. I'll try it all one one line.

How space-sensitive is C/ZScript, anyway? If the proper usage of semicolons separating the int types being introduced is preserved, and all spaces removed, does it retain its meaning?

C-Dawg
12-20-2006, 12:38 PM
It doesnt' work fine yet, thats why it's here instead of script showcase. I have a bad habit of coding during downtime at work. I cannot, therefore, test them in advance.

I bet the problem is that you use , instead of ; in the void() function.

Also, white space is typically ignored by the compiler.

Master_of_Power
12-20-2006, 05:44 PM
// ================================================== ====
// ENEMY_BOOSTER - This FFC will boost the attributes of any npc that
// comes within 16 pixels of it. After triggering, the FFC will switch to the next
// combo and deactivate for a certain period of time. If you don't want the booster
// to boost all attributes, leave those variables set to 0.
// Most variables can be negative, making this into an enemy weakener.
// D0 - The amount by which the enemy's hit points will be boosted.
// D1 - The amount by which the enemy's damage will be boosted.
// D2 - The amount by which the enemy's movement rate will be boosted.
// D3 - The new Cset that will be assigned to the enemy once it has been boosted.
// D4 - The number of tics that the booster will remain deactivated after activating.
// ================================================== ==============


ffc script enemy_booster{

void run()
{
int hitpoint_boost = D0; //Problem solved up here, it seems...
int damage_boos = D1;
int speed_boost =D2;
int cset_boost=D3;
int delay=D4;

int enemy_num = 0; // Used to check how many enemies there are
// on a screen each tic.
int counter = 1; // Used to check location of each enemy in turn.

npc current_enemy; // Used to load up each enemy in turn.

int state = 1; // Prevents pumping up enemy too much by turning off
// for a few tics once an enemy triggers it.
// 0 = Active
// 1+ = Inactive

while(true){

counter = 1;
enemy_num = Screen->NumNPCs();


// Check each npc on the screen's location. If it is within 16 tiles of this FFC, apply the
// boosts to that npc and then deactivate.

while ( (counter < = enemy_num) && state = 0){ //Seems to be a problem here, but I can't put my finger on it
current_enemy = Screen->LoadNPC(counter);
if ( (current_enemy->X < this->X + 16) && (current_enemy->X > this->X - 16) &&
(current_enemy->Y < this->Y + 16) && (current_enemy->Y > this->Y - 16) ){

this->HP = this->HP + hitpoint_boost;
this->Damage = this->Damage + damage_boost;
this->Rate = this->Rate + speed_boost;

state = 1;
this->Data++;

if (cset_boost !=0){ this->Cset = cset_boost; }

} // end if
counter++;
} // end of internal while

// Deactive once an enemy has been boosted. Stay deactivated for delay tics.

if ( state != 0 ){
if (state = delay) { state = 0; this->Data--; }
else ( state++ }
} // end if

Waitframe();

} // end of while

} // end of void run

} // end of script

Apparently Line 43 is acting up with the following error message

Line 43: Syntax Error, Unexpected Assign, Expecting RPAREN or OR, on token =
Fatal Error P00


I get an error when I try to import this and compile it in ZQuest:

Pass 1: Parsing
Line 17: Syntax Error, Unexpected Semicolon, Expecting RPAREN, On Token ;
Fatal Error P00: Can't Open or Parse Input File!

I'm unable to figure whether or not the problem is solved here, but I'm not getting any errors from that line now.

DarkDragon
12-21-2006, 10:47 AM
??? That shouldn't compile at all, since D0 is not a declared variable...
C-Dawg's fix of replacing the semicolons with commas is correct.

Whitespaces are ignored by the compiler, with the exception that at least one whitespace must separate two consecutive tokens which are keywords, numeric constants, or identifiers.

Saffith
12-21-2006, 05:33 PM
??? That shouldn't compile at all, since D0 is not a declared variable...
It doesn't. It's just that it finds the <=/== problem before it notices the undeclared variables.

bigjoe
04-13-2007, 11:33 AM
This script would be useful in reducing the amount of enemies you need to create in the enemy editor, thus freeing space for more enemies to be created. I would like to see it completed.

Also, a version that boosts enemies at their spawn time rather than when they step on a combo would be ideal.

C-Dawg
04-14-2007, 08:25 PM
This script would be useful in reducing the amount of enemies you need to create in the enemy editor, thus freeing space for more enemies to be created. I would like to see it completed.

Also, a version that boosts enemies at their spawn time rather than when they step on a combo would be ideal.

I think this was completed; isn't it in Script Showcase too? Anyway, a working version can be found in my SideQuest.qst, which you can download in a thread in ZC Design Exchange.

I think the version I used there actually spawned them using a script and set health accordingly, too. I used it to make a Ghoma-1 with 50 hit points.

-C