Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

newww questions

89 replies · 17,160 views · Started 03 February 2008

ffc script eyesore{
void run( int foo,int bar,int barieo){ // There's no need to use names for fake integers for your real integers, you could give them names that actually describe what they do.
combo1 = ComboD[foo]; //What is this doing? It makes no sense.
combo2 = ComboD[bar]; //Same with this.

int x; int y;
int speed = 2;

npc ghosted_hp_enemy1 = Screen->CreateNPC(barieo); //These lines are fine
npc ghosted_hp_enemy2 = Screen->CreateNPC(barieo);
npc ghosted_hp_enemy3 = Screen->CreateNPC(barieo);
npc ghosted_hp_enemy4 = Screen->CreateNPC(barieo);
ffc eye1 = Screen->LoadFFC(1); //And this one, although, if the script is on ffc1, there's no need to declare it within the script.
//The script references it's own ffc as 'this->'.
while(true){
eye1->Vx = speed; //Probably best not to throw too many extra space around, although I think it should compile OK anyway
eye1->Vy = speed;
ghosted_hp_enemy1->X = eye1->X;
ghosted_hp_enemy1->Y = eye1->Y;
ghosted_hp_enemy1->HP = 20; //Forgot the ';' at the end of this line

if(Abs(eye1->Y - combo1->Y)<18){ //Scope scope scope!
eye1->Vy *= -1; //I assume this line is meant to mean 'multiply eye1's speed by -1'.
//You can't just do it the way you did, you need the equals sign.
//Check this on assignment: http://www.shardstorm.com/ZCwiki/ZScript_Concepts
}

if(Abs(eye1->X - combo1->X)<18){ //Same as the last one
eye1->Vx *= -1; // You had a ':' here instead of a ';'
}

if(Abs(eye1->Y - combo2->Y)<18){
eye1-> Vy *= -1;
}

if(Abs(eye1->X - combo2->X)<18){
eye1-> Vx *= -1;
}

if( ghosted_hp_enemy1->HP == 0){ //No need to take 'Abs' here, the NPC's HP will never be less than 0.
eye1->Data = 0; //Make sure to end the line with a ';'
}

Waitframe(); //';' again.
}
}
}
//Right, I've just removed the rest of the script, because it won't function.
//If you declare 'while(true)', then only that part of the script will run and no other parts.
//At all.
//You need to compile it all into one while loop.

Scope:

		}else{
if(!upcheck){
this->Vy = 0;
link2->Vy = 0;
water->Vy = 0;
}
}

In this code, the scope is wrong.

		}else{
if(!upcheck){
this->Vy = 0;
link2->Vy = 0;
water->Vy = 0;
}
}

In this code, the scope is correct.

You can see the difference, yes?

What you have is two scopes.
The first is the 'else' requirement, and the second is the 'if' requirement.

The else is declared at two indentations.
All functions within the else are then placed at three indentations, so this includes only the if.
The if is declared at three indentations, so the functions within it are placed at four indentations.
This means that the if is closed at three indentations, not four, and the else is closed at two indentations, not three.

It is essential that you get your scope correct, otherwise reading your scripts will be a nightmare.

That spiel on scope isn't relevant to your script; it's a copy-paste from someone else's thread.
It's still very relevant however.

ah ok... yeah i tried testing it and it pointed out all my errors and stuff like syntax and everything. my braces didnt really bother it at all. but i guess the Combo1 and Combo2 variables made it hate me... see the ComboD[] is where you declare your combos for it to bounce off of. i just renamed it to make things easier on me instead of saying ComboD[foo] every time i needed it.

so ive fixed everything ecxept the while loop and those variables. can you tell me how to declare combos using foo and stuff like that since thats apparently wrong? thats the only thing makin ZQ mad at me at the moment.

it says in the wiki that ComboD[] is used to declare a certain combo that you want to use in a variable... but i guess thats wrong.

and thanks very much for helping lol ill make sure you guys get credit for it in my quest

The scope errors won't make any difference to how the script compiles, they just show that you don't understand how it works. And make it hard to read.

The wiki isn't wrong; your understanding of how it's meant to work is wrong.
You don't 'declare' combos, the things that you declare are one of 'Integers, Booleans, Floats, NPCs, Items and FFCs'.
Combos are not something you declare.

Why are you doing that?
Explain what it's meant to do, and I'll tell you how you should do it.

ahh... i figured the wiki was wrong... *sadness*...

ok basically what the combo stuff does is you set the combo IDs in the first 2 argument tabs and those are the ones that the eyes "bounce" off of.

and thanks again lol i kno im kinda hopeless...

😱

You think you can just do that and then the script will work it all out for you?!
Oh dear =P

Your script won't function like that at all, sorry.

oh no... *more sadness*... well then i guess im going with gleeok's original idea to just make it bounce off solid walls then.

Oh wait, I wasn't thinking straight earlier.
You could do a check for the combo at certain distances from the ffc depending on it's current (Vx, Vy), and then if it's that combotype, reverse one of it's speeds.

Wouldn't be fun though.

ok... better idea. how about, instead of making it bounce off combos, i make it bounce off a flag that does absolutely nothing? [i need help fiuring this out of course but i dont think it would be as difficult as what youre saying]

and thanks for the idea C-dawg

The difference between telling it to bounce off a combo and a flag is the difference between putting:

if(Screen->ComboT[ComboAt(x,y)] == combotype){

and putting:
if(Screen->ComboF[ComboAt(x,y)] == flag){

One letter's difference.
Neglible.

ok... this doesent seem that difficult actually...

but then again im just looking at it too...

so... i haves a question. how do i pick which flag it bounces off of?

do i put the # of the flag in the spot after the == sign? or is it slightly more complex?

No, that's it.

You need to specify the correct (x,y) coordinates though, referencing the ffc's coordinates.

lol im sorry i fail to understand this...

so i take the coordinates... and those are where the flag is so if theres a flag at those coordinates then...? im is so confused...

ah...Ahhh i get it now...

ok so it tells when the FFC becomes adjacent to the flag? but how do you know which flag to use?

Oh, well what I'd written wouldn't actually compile.
I've used an integer called 'flag', although I haven't declared it, because what I put was just an example.

Replace 'flag' with the flag number you want to use, or actually declare 'flag' and set it to that value.

ahhhh thank you so much man! ok i get it now.

oh and also, will it work with any flag? as in the ones labeled <unused> and stuff too?

ok, joe. you might be proud finally XD.

i have,

deleted a bunch of extra spaces (for organization)

checked my punctuation (either ; { or } at the end of every line

completely removed the whole combo thing (replaced with flags)

shortened the script considerably

added a new argument (the enemy's hp)

compiled everything into one while () loop

and checked my scope.

now, here's my monstrosity.

import "std.zh"
ffc script eyesore{
void run(int barieo, int bar){

int x; int y;
int speed = 2;

npc ghosted_hp_enemy1 = Screen->CreateNPC(barieo);
npc ghosted_hp_enemy2 = Screen->CreateNPC(barieo);
npc ghosted_hp_enemy3 = Screen->CreateNPC(barieo);
npc ghosted_hp_enemy4 = Screen->CreateNPC(barieo);
ffc eye1 = Screen->LoadFFC(1);
ffc eye2 = Screen->LoadFFC(2);
ffc eye3 = Screen->LoadFFC(3);
ffc eye4 = Screen->LoadFFC(4);
ffc center = Screen->LoadFFC(5);

while (true){

eye1-> Vx = speed;
eye1-> Vy = speed;
ghosted_hp_enemy1->X = eye1-> X;
ghosted_hp_enemy1->Y = eye1-> Y;
ghosted_hp_enemy1->HP = bar;

if(Screen->ComboF[ComboAt(eye1->Y)] == flag){
eye1->Vy *= -1;

}

if(Screen->ComboF[ComboAt(eye1->X)] == flag){
eye1-> Vx *= -1;

}

if((ghosted_hp_enemy1->HP)==0){
eye1->Data = 0;

}

eye2-> Vx = speed;
eye2-> Vy = speed;
ghosted_hp_enemy2->X = eye2-> X;
ghosted_hp_enemy2->Y = eye2-> Y;
ghosted_hp_enemy2->HP = bar;

if(Screen->ComboF[ComboAt(eye2->Y)] == flag){
eye2-> Vy *= -1;

}

if(Screen->ComboF[ComboAt(eye2->X)] == flag){
eye2-> Vx *= -1;

}

if((ghosted_hp_enemy2->HP)==0){
eye2->Data = 0;

}

eye3-> Vx = speed;
eye3-> Vy = speed;
ghosted_hp_enemy3->X = eye3-> X;
ghosted_hp_enemy3->Y = eye3-> Y;
ghosted_hp_enemy3->HP = bar;

if(Screen->ComboF[ComboAt(eye3->Y)] == flag){
eye3-> Vy *= -1;
}

if(Screen->ComboF[ComboAt(eye3->X)] == flag){
eye3-> Vx *= -1;

}

if((ghosted_hp_enemy3->HP)==0){
eye3->Data = 0;

}

eye4-> Vx = speed;
eye4-> Vy = speed;
ghosted_hp_enemy4->X = eye4-> X;
ghosted_hp_enemy4->Y = eye4-> Y;
ghosted_hp_enemy4->HP = bar;

if(Screen->ComboF[ComboAt(eye4->Y)] == flag){
eye4-> Vy *= -1;

}

if(Screen->ComboF[ComboAt(eye4->X)] == flag){
eye4-> Vx *= -1;

}

if((ghosted_hp_enemy4->HP)==0){
eye4->Data = 0;

}

if(eye1->Data == 0 && eye2->Data == 0 && eye3->Data == 0 && eye4->Data == 0){
center->Data = 0;

}

Waitframe();
}
}

am i ok now? except for attacking, i see nothing else to add. but there are things ive left out too.

like the flag #. i need to boot up ZQ and find one that would be useful. but that can wait.

and thats about it as far as i can tell. did i fix everything?

This is indeed much improved.

Problems:
You're setting the HP of each enemy every frame.
You need to do that before the while loop.
Once an ffc's data becomes 0, it is dereferenced (I think), therefore you can't check whether other ffc's datas are 0 before doing things.

98 is the first script-only flag.

uh-oh... big trouble then...

ok ive re-wired things and now im checking if the enemy's HP reaches 0 instead of the ffc's data. does an enemy become derefrenced in the same way as an ffc?

if not, ive got everything right.

and if so, ill just have to bool. shouldnt be too hard, right?

umm... well i kinda got everything set up for it to check the HP already... i just changed it from checking the ffc's data to checking the enemies HP...

i could change it to bool but it seems pointless to me.

would you like to see it now?

ok then XD

im sure that its done now too... except for attacking.

import "std.zh"
ffc script eyesore{
void run(int barieo, int bar){

int x; int y;
int speed = 2;

npc ghosted_hp_enemy1 = Screen->CreateNPC(barieo);
npc ghosted_hp_enemy2 = Screen->CreateNPC(barieo);
npc ghosted_hp_enemy3 = Screen->CreateNPC(barieo);
npc ghosted_hp_enemy4 = Screen->CreateNPC(barieo);
ffc eye1 = Screen->LoadFFC(1);
ffc eye2 = Screen->LoadFFC(2);
ffc eye3 = Screen->LoadFFC(3);
ffc eye4 = Screen->LoadFFC(4);
ffc center = Screen->LoadFFC(5);
ghosted_hp_enemy1->HP = bar;
ghosted_hp_enemy2->HP = bar;
ghosted_hp_enemy3->HP = bar;
ghosted_hp_enemy4->HP = bar;

while (true){

eye1-> Vx = speed;
eye1-> Vy = speed;
ghosted_hp_enemy1->X = eye1-> X;
ghosted_hp_enemy1->Y = eye1-> Y;

if(Screen->ComboF[ComboAt(eye1->Y)] == 98){
eye1->Vy *= -1;

}

if(Screen->ComboF[ComboAt(eye1->X)] == 98){
eye1-> Vx *= -1;

}

if((ghosted_hp_enemy1->HP)==0){
eye1->Data = 0;

}

eye2-> Vx = speed;
eye2-> Vy = speed;
ghosted_hp_enemy2->X = eye2-> X;
ghosted_hp_enemy2->Y = eye2-> Y;

if(Screen->ComboF[ComboAt(eye2->Y)] == 98){
eye2-> Vy *= -1;

}

if(Screen->ComboF[ComboAt(eye2->X)] == 98){
eye2-> Vx *= -1;

}

if((ghosted_hp_enemy2->HP)==0){
eye2->Data = 0;

}

eye3-> Vx = speed;
eye3-> Vy = speed;
ghosted_hp_enemy3->X = eye3-> X;
ghosted_hp_enemy3->Y = eye3-> Y;

if(Screen->ComboF[ComboAt(eye3->Y)] == 98){
eye3-> Vy *= -1;
}

if(Screen->ComboF[ComboAt(eye3->X)] == 98){
eye3-> Vx *= -1;

}

if((ghosted_hp_enemy3->HP)==0){
eye3->Data = 0;

}

eye4-> Vx = speed;
eye4-> Vy = speed;
ghosted_hp_enemy4->X = eye4-> X;
ghosted_hp_enemy4->Y = eye4-> Y;

if(Screen->ComboF[ComboAt(eye4->Y)] == 98){
eye4-> Vy *= -1;

}

if(Screen->ComboF[ComboAt(eye4->X)] == 98){
eye4-> Vx *= -1;

}

if((ghosted_hp_enemy4->HP)==0){
eye4->Data = 0;

}

if(ghosted_hp_enemy1->HP ==0 && ghosted_hp_enemy2->HP == 0 && ghosted_hp_enemy3->HP == 0 && ghosted_hp_enemy4->hp == 0){
center->Data = 0;

}

Waitframe();
}
}

however, i would like to know how the best way to bool it is tho.

would it be like this:

if(Bool(ghosted_hp_enemy1 && ghosted_hp_enemy2 && ghosted_hp_enemy3 && ghosted_hp_enemy4 == false)){

or like this:

if(Bool(ghosted_hp_enemy1 == false) && Bool(ghosted_hp_enemy2 == false) && Bool(ghosted_hp_enemy3 == false) && Bool(ghosted_hp_enemy4 == false)){

also, would i use one equal sign or 2? i understand that = means "is set to" and == means "is equal to" but im not sure which i would use with bool. and bool does need to be capitalized, too right?

'ComboAt(x,y)' takes two parameters.
You can't put 'ComboAt(x)', because coordinates have two parts to them.

You've done that a lot.

And I don't know what you think you're doing with booleans, but it shouldn't be anything like that...

A bool is just a variable with two states.
So you do it like this:

	void run(){
bool eye1check;
bool eye2check;
//etc...

//......
while(true){
//....

if(!eye1->IsValid) eye1check = true;
if(!eye2->IsValid) eye1check = true;
//etc...

if(eye1check && eye2check && etc){
//do stuff
}

			if(!eye1->IsValid) eye1check = true;
if(!eye2->IsValid) eye1check = true;

this part. you said ! meant "not" right? then this says "if not eye1 is valid..."

does this mean that "if anything other than eye1 exists"? of does it check near eye1 for anything out of the ordinary like flags?

isValid is a bool already. It can either mean true or false.

So;

if(!eye1->IsValid) eye1check = true;

Translation:

if eye1 is not found, (it died), eye1check becomes true.