PDA

View Full Version : newww questions



Master Maniac
02-02-2008, 10:55 PM
ok i kno i seem a little... beggy [for lack of a better word] but im in the process of finding these things on my own.

ok so im looking at the variables and functions list on the wiki. the only problem is that it doesent seem like all of them are there. is this all of the variables and functions one could possibly need to put things in a script?

im going to write the script on my own i just need to translate all i need to CPU language first. Thanks

pkmnfrk
02-02-2008, 11:08 PM
No, this is not all we might need. However, that's all there is for now.

That said, many things are possible. We can help you figure out what you need if it's not obvious.

Master Maniac
02-02-2008, 11:21 PM
lol im kinda trying to stop bugging everyone here and finally do something myself for once. actually all i really need to do so is an accurate list of variables and functions and i would be set. then i could write my own scripts and stop begging others to do so for me XD

i already understand how to set up a script. i get the layout, and the use tab instead of randomly placed space bar strikes and i understand simple things like an if() function. I understand also, that the scripts have to be set up PRECISELY to work perfectly right, which means no gaps, no flaws, no holes, no errors.

so basically all i need is to write one. the tutorials help, but they dont give variable and function lists so its not the best...

thanks for the help XD and sorry for bugging everyone so much.

and i agree with joe.
:D looks reeeally creepy. like its hiding something. or it could be the look someone gives after farting in an elevator. either way works.

Joe123
02-03-2008, 06:00 AM
You agree with me about what? :confused:
I haven't posted here...


Don't worry about bugging if you're asking for help, you'll never learn if you don't ask.
I had to bug for weeks before I could do anything.

What specific things do you need to know about this time?

Learning by reading other scripts and copying other syntax/functions is how I did it.

ScaryBinary
02-03-2008, 11:19 AM
ZScript gives you some built in variables and functions, but you can also create your own.

Some of the built-in things you can mess around with include enemies, Link, Freeform Combos, various Screen settings, etc. Keep in mind that scripting doesn't give you full control of every aspect of the game, so you might be expecting more than there really is as far as functions and so on.

The Script Showcase is a good spot to look around, but admittedly some of the scripts are confusing if you don't know what the scripts are trying to do in the first place.

The Wiki is a good starting point, but yes, there probably are some things missing here and there. I've tried to update it, but in some cases I lack the time to do a decent job, and in other cases I lack the knowledge...:D...the more questions we ask here, the more answers we'll get, and it will allow us to improve the Wiki. So ask away!

PS: For the record, I prefer spaces over tabs when indenting. I've been bitten by tabs too often....:tongue:

Joe123
02-03-2008, 02:10 PM
Nooo, space bar is evil.
Tab does nice sized indents.

Master Maniac
02-03-2008, 03:21 PM
lol i kno it wasnt a post here but i remember reading a post where you said the :D guy looks creepy and i agree so i figured id say something about it XD

ok... so basically what i need... for now... is variables to describe an FFc movement, to check link's position on the screen, and some to describe the ffc taking damage like flashing and being knocked back when the ghosted enemy is hit.

then im not sure how i would set it up but i need to make the ffc pullable via hookshot. but idk the slightest thing about bringing items into ffc scripts so... yea...

ill check out the script showcase and see if they help though. thanks!

Joe123
02-03-2008, 03:58 PM
That was Matthew, not me...

Right, well.
Checking Link's position on the screen is as easy as:

Link->X
Link->Y
Putting that command returns the value of the top-left pixel of Link's current location, as an integer that you can use for whatever purpose.
You can also set it to move Link.

FFC movement:
You can either:

this->X
this->Y
Acces the ffc's coordinates directly the same way as you did with Link's, or:

this->Vx = whatever;
this->Vy = googol;
Set the vertical and horizontal component's of the ffc's velocity, a bit like that.
A googol is probably a bad idea though.

Please note that there is an important discretion between:

this->Vx = 20;
this->Vx == 20
Note how I finished the first line with a semi colon, but not the second.
'=' means 'is set to'
'==' means 'is equal to'
All functions finish with a semi-colon, so the first line is a function, setting the Vx to 20.
The second line you would use as the requirements for an if or while, to check whether the ffc the script is attached to's horizontal velocity is equal to 20.

Aswell as the discretion between:

this->Vy = foo;
foo = this->Vy;
The first will set foo to the script's ffcs speed, while the second will set the ffc's speed to foo.
That's probably obvious, but important to note nonetheless.


On a(further)n aside, declaration and manipulation of different ffcs:
If you just put 'this', it's pointer is already loaded as the ffc the script is attached to, but if you want to reference another ffc, you must load it like this:

ffc foo = Screen->LoadFFC(5);
Then you can reference foo and tell it what to do:

foo->Vx = 5;
this->Vx = 98.7
In the same way as you can set the ffc that the script is attached to's info.

To change the ffc to make it flash, you want:

this->Data = ????;
Which will set the combo attacked to the ffc to the combo ID you give it.

Anything you don't understand, feel free to ask away to your heart's content.

Master Maniac
02-03-2008, 04:20 PM
ok i understand most of this... just a few questions

so i get the check link position variables.
and to make the FFC check link's position, wait, then move i would...


Link->X(Waitframe(30))->this->X
Link->Y(Waitframe(30))->this->Y

right?... but no... it would be un-organized as that and move toward the X before the Y... so this is the wrong way to do it i would guess. they just need to be seperated and re-organized... would it be better as


(waitframe(30))this->X==Link->X

and then do the same for the Y?this seems to make a slight bit more sense to me, but it would wait, then go to the link position after 30 frames... so the link would be directly targeted instead of his position targeted and then sent to that... ugh this is confusing.

also, how would i set the velocity of the movement to the checked position? would i set the velovity variables at the end using parentheses?

Joe123
02-03-2008, 04:46 PM
*sigh*
If only it were that simple.

What you just put makes absolutely no scripting sense whatsoever.
I can see what you're getting at, but it won't work.


so i get the check link position variables.
and to make the FFC check link's position, wait, then move i would...


Link->X(Waitframe(30))->this->X
Link->Y(Waitframe(30))->this->Y

right?
Wrong.

What you'd do is:

int x; int y; // declare some integers to store coordinates in
int xdistance; int ydistance; // declare some integers to store distances in
int time = 10; // this is the number of pixels per frame your ffc will move at (I think)
x = Link->X; // set them to Link's current coordinates
y = Link->Y;
Waitframes(30); //Wait for 30 frames (although I don't advise doing it like this, then your script will stop all other functions for 30 frames)
xdistance = Abs(this->X - x); //set the distance between the values you took and the ffc's coordinates.
//Abs takes the absolute value of the parameter, so if the value is negative it will be set positive
ydistance = Abs(this->Y - y);

//Speed == distance / time, so:
this->Vx = (xdistance / time); // set the vertical and horizontal speeds of the ffc by dividing their distances from x and y
this->Vy = (ydistance / time); // by a time constant.


And you'd have that within a loop, and with probably some sort of:

if(this->X == x && this->Y == y){whatever}
at the end.

Master Maniac
02-03-2008, 05:08 PM
so i shouldnt use waitframes becauseit halts ALL functions in the script even if its in a seperate level? like:


//blah blah variables and stuff
{//more variables
{waitframes(30)//tada!! magic variable...
}//whatever function
}

where as i would see, it would halt only the things in that level of brackets, instead of the whole script altogether.

ok these are the variables i need obviously but i also need to know how to set it to "bounce" off un-walkable combos and specific combos you set. which would be the D: things.i need to know how to set those up altogether actually...

and so i have to have this in an if function, so that means


if(this->X == x && this->Y == y){whatever}

the way im reading this it says that if the ffc is at these coordinates, then it does whatever is in the code in the brackets, right? and whats the difference between capital and lowercase X and Y variables?

DarkDragon
02-03-2008, 05:21 PM
this->X is a built-in variable; it always is equal to whatever the FFC's X coordinate is, and if you write to it, the FFC automatically moves there.
x is a home-made variable Joe created. These ordinary variables don't do anything special when read or written to, but are used to temporarily store information. For instance,


ffc script foo
{
void run()
{
while(true)
{
int x = Link->X;
int y = Link->Y;
Waitframes(30);
this->X = x;
this->Y = y;
}
}
}

will cause the FFC to remember Link's X and Y position, wait 30 frames, then teleport to that position.

Master Maniac
02-03-2008, 05:34 PM
oooh ok this makes sense. so then basically that is what i was trying to make them do except that makes them teleport whereas i need them to have a specific speed to move to there. I understand... ok so,


ffc script foo
{
void run()
{
while(true)//this means while the ffc exists
{
int x = Link->X; //this means to store links X coordinates in x
int y = Link->Y; //this is the same thing but using Y
Waitframes(30); //wait 30 frames
this->X = x; //ffc goes directly to the stored x
this->Y = y; //directly to the stored y
}
}
}

ok... i understand... so how would i plug velocity into this so it doesent look quite so jumpy in the quest? do you have to set the velocity for movement before you set any special actions involving movement? this wouldnt make sense... to do that you would have to set the velocity for regular movement, then for special movement, then plug in the variables for special movement in the "attack" function in the script...

would you do this at the beginning and use homemade variables like joes to refrence them?

Joe123
02-03-2008, 05:36 PM
I think I assumed you had a little more knowledge of this than you actually do, apologies if I did (/you do and I'm now being patronising).

Let's start with the discretion between variables and functions.
Variables are numbers that you can manipulate, and they come in 3 tasty methods:
Integers (declared with 'int')
Booleans (declared with 'bool')
Floats (declared with 'float')

Booleans can only have two values, '0' and '1'.
In script, they are given 'true' and 'false', and are great for switches and the like.
Integers and Floats are a little misleading.
ZScript makes no discretion between int and float, all integers and all floats are numbers with up to 4 decimal places (so there are no real integers).

You declare vairables like this:

bool fooieo;
bool foo = true;
int bar;
int barieo = 15;
I've never used floats personally.

And to use a variable you must first declare it, or the script will not compile properly.

The first line declares the boolean 'fooeio', and sets it to 'false'
The second line declares the boolean 'foo', and sets it to 'true'
The third line declares the integer 'bar', and sets it to '0'
The fourth line declares the integer 'barieo', and sets it to '15'.


You can then access your variables at other points during the script just by putting in their names.
Don't put the declaration word before them again, because you can't declare two variables with the same name in the same scope.


Functions are what you'll find in ZScript.txt, and are all (well, most of them are) accessed with pointers.
Let's take the function 'GetCurDmapScreen()'.
This function returns the value of Link's screen in the current DMap.

Referring to ZScript.txt, it is in the 'Game' section, so to access it, we use the 'Game->' pointer.
Like so:

Game->GetCurDmapScreen()

So, this function returns an integer, but at the moment we aren't doing anything with it, so let's combine it with an integer we declared earlier, and an if command:

int foo;
foo = Game->GetCurDmapScreen();

if(foo == 10){//do something nice}
So we declared the integer foo, then we set it to the current Dmap Screen.
Notice that this line ends in a semi colon, as is the way with functions.

Then we checked whether foo was equal to 10, then if it was, we did something nice. (well, don't just put notes and then write out what you want the script to do, it won't work very well =P).


http://www.purezc.com/forums/index.php?showtopic=25946
This thread is great for understanding integers.

I haven't covered everything you asked, but it's quite important that you understand that much.
I'll go over the other bits, and post a bit of example script of how to do what you're asking after you get this much.

EDIT: Don't you just hate it when two people've posted by the time you've finished writing what you're saying =P

Master Maniac
02-03-2008, 06:09 PM
ok... yea i think i kno a little less than i thought too...

but i understand that:

1-variables can describe things in 2 ways.
a-true/false
b-as a number value, like a Dmap # or if you have a certain piece of triforce.
also, that in Zscript, it wont tell the difference between int and float, so they are basically the same thing.[maybe?]
and another also, you can set variables and refrence them any time in the script, but inly using the variable name without the bool or int tags. like saying int foo in the beginning and just saying plain foo in later parts.

2 functions are arrangements of variables to preform specific actions. pretty simple...almost...

which means i also have questions lol

so if you set some variable like foo in the beginning, and refrence it later, it will be whatever you made it when you refrence it. meaning if you refrence after you made foo's value = 10, then basically youre refrencing the value. but what about the next time you refrence it? will it still be the same amount or will it reset?

and why did you add "ieo" to foo and bar? was that just another name for a homemade variable or does it have something to do with the variables themselves?

Joe123
02-03-2008, 06:25 PM
Yes, that's better :)

Functions can be other things aswell as arrangements of variables too though.

Game->PlaySound(message);
Obviously uses a vairable, but it is input only (you couldn't it in an if requirement), playing the sfx that the integer 'message' is set to.

The ieo was just to make them into different names; you can't declare two variables with the same name in the same scope.
There are some other names for dummy variables, but they didn't come to mind at the time.

I'll write up a bit of example code for how I'd do what you're asking in a bit.

Master Maniac
02-03-2008, 06:35 PM
ok thanks XD i understand slightly better now, even though i know theres more to get, i think it would be easier to write a script knowing these things lol

but now i have new questions. 2 of them. lol and one is slightly off-topic. [only slightly]

so ill start with that one. its just out of curiosity.

if you have an ffc and the combo its set to is a center statue combo, and the screen flag statues shoot fire is on, will it give the ffc the effect of shooting fireballs? it seems to make sense, but it might not work since it makes it a different kind of combo.

and the other,

ive seen other game making programs where you have to set up EVERYTHING. HP movement buttons actions items enemies EVERYTHING. one of the commands in that is to destroy an object. as in to give the effect of killing a boss, it makes the object disappear. is this possible to do with ffcs? after you kill the ghosted enemy, you could link the existence of the FFC to the health of the enemy, but that seems more complex. is there just a command to "destroy" an ffc after a certain objective in the script is reached?

The_Amaster
02-03-2008, 06:36 PM
...

ha

HA!

HA HA!
This is it! This is what I need for my Doppelganger Replicator. Yes!

*goes off to code*

EDIT: Question from me now. I need a way to make an FFC invisible and visible.

Master Maniac
02-03-2008, 06:39 PM
is amaster ok? it seems he just had a brain fart... [my word for insanely obvious idea]

DarkDragon
02-03-2008, 06:42 PM
ok thanks XD i understand slightly better now, even though i know theres more to get, i think it would be easier to write a script knowing these things lol

but now i have new questions. 2 of them. lol and one is slightly off-topic. [only slightly]

so ill start with that one. its just out of curiosity.

if you have an ffc and the combo its set to is a center statue combo, and the screen flag statues shoot fire is on, will it give the ffc the effect of shooting fireballs? it seems to make sense, but it might not work since it makes it a different kind of combo.

I don't think so, but I'm not sure; try it ;)


and the other,

ive seen other game making programs where you have to set up EVERYTHING. HP movement buttons actions items enemies EVERYTHING. one of the commands in that is to destroy an object. as in to give the effect of killing a boss, it makes the object disappear. is this possible to do with ffcs? after you kill the ghosted enemy, you could link the existence of the FFC to the health of the enemy, but that seems more complex. is there just a command to "destroy" an ffc after a certain objective in the script is reached?

Setting an FFC's data to 0 or moving it far off screen (-100,-100 should do nicely) both kill FFCs.



EDIT: Question from me now. I need a way yo make an FFC invisible and visible.

Set its datato a non-0 combo with a fully transparent tile.

The_Amaster
02-03-2008, 06:43 PM
Kinda yeah. For some weird reason, it hadn't occured to me to use

this->X = x;

Joe123
02-03-2008, 06:44 PM
but now i have new questions. 2 of them. lol and one is slightly off-topic. [only slightly]
It's your topic =P


if you have an ffc and the combo its set to is a center statue combo, and the screen flag statues shoot fire is on, will it give the ffc the effect of shooting fireballs? it seems to make sense, but it might not work since it makes it a different kind of combo.
I don't think that would work, _L_ said that centre statue combos work by spawning fireshooter enemies when the screen is loaded, so in that case it wouldn't work.
What you'd do for that is take C-'s or Gleeok's enemy ghost scripts, then attach a fireshooter enemy to the ffc with them.
I've done it many a time and it works nicely.


ive seen other game making programs where you have to set up EVERYTHING. HP movement buttons actions items enemies EVERYTHING. one of the commands in that is to destroy an object. as in to give the effect of killing a boss, it makes the object disappear. is this possible to do with ffcs? after you kill the ghosted enemy, you could link the existence of the FFC to the health of the enemy, but that seems more complex. is there just a command to "destroy" an ffc after a certain objective in the script is reached?
Yeah, if you set an ffc's data to '0', it dissapears and any scripts it is running stop.



Question from me now. I need a way to make an FFC invisible and visible.
There is a flag called 'Only visible to lens of truth' in the ffc.
You can access that with:

this->Flags[thatflag] = true;
Although I can't remember what number flag it was; check std.zh for that.
Obviously that'll only work if you're not using the lens, but who really does?

I've written that example script now MM, just noting up.

Master Maniac
02-03-2008, 06:51 PM
ah ok it makes sense. ill just make the enemies attached to the ffc's be shooters then.

and then when they die, they will set the data to 0. easy enough to understand.

thanks for all your help btw lol

Joe123
02-03-2008, 07:01 PM
ffc script movetolink{ // start the ffc script
void run(int time, int foo){ // Start the void run command, which all script must begin with.
// Also, at this point, the integer 'time' is declared.
// This integer is set via 'D0' of the ffc in ZQuest.
// Integer 'foo' is set to D1, just as an example of the syntax.

int x; int y; // Declare the coordinate storage variables
int xd; int yd; // Declare the distance storage variables
int xs; int ys; // Declare the speed storage variables
// You could write the script without storing the speed or distance variables, but I'm just
// using them to tidy it up a bit, and make it more explanitory what I'm doing really.

if(time == 0) time = 10; // A little 'defaulting' if.
// Just means that if you leave 'time' to be 0 in D0, it'll be set to 10.
// Division by 0 is not allowed.

while(true){ // The 'while' loop.
// It'll keep looping 'while' the conditions within the parenthesis are true.
// 'While(true)' will loop forever.

x = Link->X; // Set the coordinate storage variables to Link's position
y = Link->Y;

Waitframes(30); // Seeing as this script only deals with this one function, we're going to wait
// for 30 frames within it, usually I wouldn't do that.

xd = Abs(this->X - x); // Set the absolute value of the distance between the ffc's current position
yd = Abs(this->Y - y); // and the stored coordinates into the distance variables.

xs = xd/time; // Set the speed variables to be the distance divided by the time
ys = yd/time; // This isn't necessary, but it's more explanitory.

this->Vx = xs; // Set the vertical and horizontal components of the ffc's velocity to their
this->Vy = ys; // repective speeds.

while(Abs(this->X - x) > 4) || Abs(this->Y-y) > 4){ // Another while loop, this time much more complex.
// I'll explain this outside the code box.
Waitframe();

} // End this while loop

this->Vx = 0; // Stop the ffc from moving once it gets there.
this->Vy = 0; // It'll now wait and repeat the process after 30 (well, 31) frames.

Waitframe(); // Wait for a frame, then re-loop the while(true) loop
}

} // End the void run
} //End the script

What the second while loop does is to keep the script waiting until the ffc reaches (near to) the stored coordinates, before letting the script loop round, and the ffc go again.

How it works is:

while(Abs(this->X - x) > 4) || Abs(this->Y-y) > 4){
It checks if either the ffc's X coordinate is within 4 pixels of the stored x, or the same for the Y.

Abs(this->X - x) > 4
Returns the absolute paramater of the distance between the ffc and the stored coordinate, and if it's greater than 4, lets the loop continue.

||
Or

Abs(this->Y-y) > 4)
Then does the same for the y coordinates.

If either of them are not within four pixels of the stored coordinates, the while loop will continue looping 'Waitframe();'.
This means that the rest of the script will not continue.

Note that while loops with no waitframe in them are usually bad, because they stop the system from running.
Especially if they are while(true) loops.

EDIT: That's ok, I have little better to do apparently.

Master Maniac
02-03-2008, 07:12 PM
lol strangely this makes sense to me. so if i want it to "attack" after it reaches a certain coordinate i would use something like,


while(Abs(this->X - x) > 4) || Abs(this->Y-y) > 4){(this->X=x)&&(this->Y=y)
}

right? or would that disregard the velocity and distance variables and just teleport it to there instantly?

Joe123
02-03-2008, 07:18 PM
I've made a slight update to the script, because I missed a bit out.

Have another look, I think you're confused.
What the script does is:
Set the ffc's Vx and Vy so that it should move to that point, idles while it moves (this is what the while loop does), then stops when it gets there and repeats (the bit I added was it stopping).

The idea was that 'It attacking' was the movement to the point where Link was standing.

And I'm going to have a big spiel about conditions and functions syntax in a minute, but we'll wait till you understand how it works first.

Master Maniac
02-03-2008, 07:29 PM
oh...OH! i get it. this is the part itself where it moves to the stored link position. which means, that the Vx and Vy that you set in the beginning IS the velocity for when the ffc moves to the link position.hah!

ok now that i get that, the ending part. it looks like it makes the ffc stop for a half secondand then return to normal movement. so after this bit, i could, instead of making it stop, i could make it move to a specific coordinate and then continue normal movement?... no... no id have to repeat the process, except make it return to a specific coordinate instead of a tracked one and then repeat it.[BRAIN FART!!]

or i could make it track to another ffc's coordinates and move to there and then return to the normal movement.

anyway back to the script, it also looks like foo isnt used. why did you define it if it serves no purpose? unless its to be refrenced later?

Joe123
02-03-2008, 07:36 PM
oh...OH! i get it. this is the part itself where it moves to the stored link position. which means, that the Vx and Vy that you set in the beginning IS the velocity for when the ffc moves to the link position.hah!
Precisely.


ok now that i get that, the ending part. it looks like it makes the ffc stop for a half secondand then return to normal movement.
No, it stops for half a second, then repeats again.
And again.
And again.
Forever.

There is no 'Normal Movement'.
There is 'this movement', which is:
ffc stops for 30 frames.
ffc moves to point where Link was 30 frames ago.
repeat.


so after this bit, i could, instead of making it stop, i could make it move to a specific coordinate and then continue normal movement?
Yes, that's not hard, but there is still no normal movement.


... no... no id have to repeat the process, except make it return to a specific coordinate instead of a tracked one and then repeat it.
Well the point is that the script then tracks a new coordinate...


or i could make it track to another ffc's coordinates and move to there and then return to the normal movement.

//Integer 'foo' is set to D1, just as an example of the syntax.
I said.
It's there to show you that to access D1-D8, you put a comma between each integer declaration.

Master Maniac
02-03-2008, 07:44 PM
oh ok so basically, this script makes it "attack" over and over until it dies. i get it.

and since there is no "normal movement" theres nothing to return to. i would have to define that myself.so is it possible to make it do this periodically, and between attacks have some sort of movement pattern?... never mind that... i could probably figure that out myself. anythings possible with scripting almost lol

and also when setting the Vx and Vy variables, are they set in pixels per frame?

Joe123
02-03-2008, 07:52 PM
Yes, having it periodically move between patterns isn't too hard.
This is exactly what I did with my first script boss actually, what a coincidence.
However, you won't be able to use the script as it is to do that.
Find another movement pattern, and I'll give you a hand to patch them together.

And yes, I think they are.


Right, syntax lecture:


while(Abs(this->X - x) > 4) || Abs(this->Y-y) > 4){(this->X=x)&&(this->Y=y)
}
This is very bad.

while(Abs(this->X - x) > 4) || Abs(this->Y-y) > 4){
this->X = x;
this->Y = y;
Waitframe();
}
What it should be (well, not in that specific script, but for the correct syntax) is this.

Syntax/commands for within requirements:
&& - And
|| - Or
! - Not
== - Equal to
!= - Not Equal to
< - Less than
<= - Less than or equal to
> - More than
>= - More than or equal to
() - Used for grouping functions together


Syntax/commands for normal function lines:
= - Is set to
; - Ends a function line. Always, with no shadow of a doubt


Don't try to use them interchangeably, '(this->X=x)&&(this->Y=y)' is not some kind of a function, you're trying to make requirements into functions.

Master Maniac
02-03-2008, 08:14 PM
ok so basically,




while(Abs(this->X - x) > 4) || Abs(this->Y-y) > 4){(this->X=x)&&(this->Y=y)
}

is bad because it is out of order and also more complex than it needs to be. so i need to take out the ()'s because they arent grouping functions together and that would cause an error.

then they need to be seperated which would do the same thing as the &&. and then i need the ; and waitframes() at the end to make it work perfectly like i wanted it to. i get it.

so now, about the movement switching.

im planning on having 5 ffcs. the first is the beast that "controls" the eyes. its basically a blank ffc that will die after all of the eyes are destroyed. so, i need the other 4 to be the ones moving. the big one just kinda sits there.

the other 4 move around ONLY on the top half of the screen. they move around pretty randomly. they bounce off of certain combos, which should be set via a D: number because if its set to bounce off unwalkable combos, then it wont move seeing as to how the whole top half of the screen is un-walkable damage combos. I think i only need it to bounce from 2 combos though.

and at some point, i need the eyes to be able to be pulled toward you via hookshot.

so, the main one is a non moving ffc that is linked to the minion eyes existence.

the other 4 ffcs are the minion eyes. they float randomly.

Joe123
02-03-2008, 08:40 PM
ok so basically,

while(Abs(this->X - x) > 4) || Abs(this->Y-y) > 4){(this->X=x)&&(this->Y=y)
}

is bad because it is out of order and also more complex than it needs to be.

No!
It's bad because you are using punctuation that should go in the if requirements to try and use functions!
Go back and read the syntax thing again.


so i need to take out the ()'s because they arent grouping functions together and that would cause an error.
They would, as well as the fact that:
Your functions do not end in a semi colon.
All functions must end in semi colons

this->X = x
Is bad

this->X = x;
Is good.


then they need to be seperated which would do the same thing as the &&.
No it would not do the same thing as &&.
In the if requirements, that means 'if(this AND this)'
In a set of functions, you put one function, end with a semi colon, then just put the next.
Often on the next line, but it doesn't have to be.


and then i need the ; and waitframes()
Yes, finish functions with ;
And Waitframe(); is what you want, not Waitframes();
The second is for waiting more than one frame, and what happens is that the loop repeats, and will keep looping the single waitframe for the number of frames necessary.

BUT!
This part is just an excersize in syntax, not anything to do with what you need to put in that loop, because all that was necessary was one waitframe.

Also, I'm not sure that you understand scope properly:

//global
script{
// a
void run(){
int foo;
// b
while(true){
// c
if(1){
//d
}
//c
if(2){
//d
if(3){
//e
}
//d
}
//c
Waitframe();
}
//b
}
//a
}
The Global scope contains everything in your script file
Scope A contains everything within the script
Scope B contains everything within the void run
Scope C contains everything within the while loop
Scope D could be at the level of both if(1) and if(2)
Scope E contains evething within if(3)

So the while loop is within scope b, but things in the while loop are at scope c.
Different numbers of indentations show different scopes, so scope a is at one indentation, whereas scope d is at 4, within both ifs.

I always put my Waitframe() on the same scope as the while, even though it should technically be at scope c, and I always declare all integers on the same scope as the void run(), although they should tecnically be at scope b.
This is all theoretical, because you could write your script out on one line if you wanted, but it makes it a lot easier to read if you get your scope correct.



im planning on having 5 ffcs. the first is the beast that "controls" the eyes. its basically a blank ffc that will die after all of the eyes are destroyed. so, i need the other 4 to be the ones moving. the big one just kinda sits there.
Interesting, if a little complex.


the other 4 move around ONLY on the top half of the screen. they move around pretty randomly. they bounce off of certain combos, which should be set via a D: number because if its set to bounce off unwalkable combos, then it wont move seeing as to how the whole top half of the screen is un-walkable damage combos. I think i only need it to bounce from 2 combos though.
Yeah that's not too hard, I've been scripting random motion quite a bit recently anyway, check the script showcase, I have a random motion script you might find interesting in it.


and at some point, i need the eyes to be able to be pulled toward you via hookshot.
I don't think this is feasable, but other people have said it is.

Master Maniac
02-03-2008, 08:52 PM
ah ok i understand a slight bit better now. so the part thats wrong is the type of punctuation im using. i should use ; because im editing the variables there, not the function. ok.

so im in the process of writing this now. this is how far i am.


import "std.zh"

ffc script eyesore;

void run(){

load ffc(1){

int x = 0;

int y = 0;

int Vx = 6;

int Vy = 6;

however i think this might not be right already. ffc 1 is an eye. so it eill be moving. i need to set the combos to "bounce" off of if it hits them.

so... is there a variable to reflect motion over an axis? i want it to just basically set the speed on its axis multiplied by -1 so it reverses direction when it collides with certain combos.

Joe123
02-03-2008, 09:08 PM
import "std.zh"

ffc script eyesore;

void run(){

load ffc(1){

int x = 0;

int y = 0;

int Vx = 6;

int Vy = 6;
Some bad punctuation still.
Opening scopes starts with '{', not ';', and the script is a scope, so:

ffc script eyesore{
Void run is in that scope, so:

ffc script eyesore{
void run(){
To use functions, you need pointers.
The function is 'LoadFFC(number);' for a start, not 'load ffc(number){'
The pointer for this function is 'Screen->'
Loading an ffc is not a scope, it is a new pointer, so the function ends in ';', not '{'.
So what you need is:

ffc whatever = Screen->LoadFFC(1);
When you declare integers, please declare them at the void run scope.
It's not essential, but it's easier to read.
Also, when you declare an integer, if you declare it with nothing after the declaration it is automatically set to 0 (I was getting at this earlier with the fooeios bit you didn't pick up on it obviously).
It'll be confusing is you use 'Vx' as an integer like that, because 'this->Vx' is a function already.
I'd go for 'xs' (xspeed) or something personaly.
And finally, 6 pix/frm is very very fast.

so:

ffc script eyesore{
void run(){
int x; int y;
int xs = 2;
int ys = 2;
ffc eye1 = Screen->LoadFFC(1);
while(true) // I've put this, you'll probably want it, but you didn't get that far yours



so... is there a variable to reflect motion over an axis? i want it to just basically set the speed on its axis multiplied by -1 so it reverses direction when it collides with certain combos.

Variable:
10. Mathematics, Computers.
a. a quantity or function that may assume any given value or set of values.

Variables do not reflect motion over axis.
Variables store the magnitude of your motion, and functions reflect it.

If you say:

int speed = 15;
this->Vx = -speed;
it will reflect your speed.

You could also put:

int speed = 15;
speed *= -1;
this->Vx = speed;

The '*=' operator means 'Take the value of the integer on the left, and multiply it by the value on the right, then set it to what you get.

Master Maniac
02-03-2008, 09:25 PM
hmkay... question. in


ffc script eyesore{
void run(){
int x; int y;
int xs = 2;
int ys = 2;
ffc eye1 = Screen->LoadFFC(1);
while(true)

why did you move the screen->loadffc(1); to after the variables describing it?

also, i understand that putting variables in the () after the void run sets them to the D: slots. how would i set them to describe a combo to set it to? i need 2 of them, but both set combo IDs.

and also how do i say "if ffc eye1 collides with (variable for the combo to bounce off of)"?

Master Maniac
02-03-2008, 09:38 PM
sorry for the double-post. my computer is acting up.

so ive fixed what little i have and addes a few things.


import "std.zh"

ffc script eyesore{

void run( int foo,int bar){

int bar = combo();

int foo = combo();

int x; int y;

int xs = 2;

int ys = 2;

ffc eye1 = screen-> load ffc(1);

while (true){

the problem is that i probably have the combo variables wrong. should they be set to


combo(int foo);
combo(int bar);

instead? or is it completely wrong either way?

Gleeok
02-04-2008, 02:46 AM
import "std.zh"

ffc script eyesore{

void run( int foo,int bar){

int bar = combo(); //combo is undeclared!

int foo = combo(); //you have to use data for a combo, it's just a number after all

int bar = 123; //or...
int combo = 123;
int bar = combo;

int x; int y;

int xs = 2;

int ys = 2;

ffc eye1 = screen-> load ffc(1); //load ffc(1) isn't right. you want :
ffc eye1 = Screen->LoadFFC(1); //look in z.script.text and std.zh for these

while (true){



Maybe start off writing some simple little scripts to get the hang of it, then tackle a scripted hookshot and boss. For example you could write the bits of info that those scripts would contain into their own mini scripts, then combine them when you get more proficient with them.

Like movement;
eye1->Vx = 123;
eye1->Vy = 123;
Boss movement;
this->Vx.
other stuff;
if(Link->X>0){//do things
if(Link->HP<32){//other things
etc...

Joe123
02-04-2008, 12:34 PM
Gleeok already said it, but I'm going to re-stress that you cannot just make up functions.

There is a definitive list of ZScript functions, and it can be found here:
http://www.shardstorm.com/ZCwiki/ZScript_Language_Reference

Any other functions will not work
The functions are case and exact punctuation sensitive, so you can't just write them however you like.

ffc eye1 = screen-> load ffc(1);
This is wrong, because you have not used the correct case for some of the letters, and you have left spaces when you should not have.

If you want to load an ffc, you must do it like this:

ffc eye1 = Screen->LoadFFC(1);


why did you move the screen->loadffc(1); to after the variables describing it?
Because those variables that ypu declared did not have anything to do with the ffc that you declared.
I can see why you thought that they did, due to you writing the ffc as a scope originally, but where you put 'int Vx = 6;', it did not have any relation to the ffc's speed.
What you did was declare a variable and set it to 6.
Nothing to do with ffc speed.

What you wanted was:

ffc eye1 = Screen->LoadFFC(1);
eye1->Vx = 6;
Once you have declared the ffc like so, it is then referenced via a pointer, like that.

Master Maniac
02-04-2008, 06:45 PM
oh ok... so basically the way i was doing it, it wasnt right because of my spaces and capitalization... ok i understand.

but what about the combo variables? i want them to be stated by the foo and bar intergers, which i have set to the D:0 and D:1 slots. is there no way to tell the script that "hey bar/foo is a combo ID"?

and thanks gleeok, but ive never been good at starting small.it seems easier for me to learn more complex things and ask lots of questions, instead of learning a little and asking nothing.

Joe123
02-04-2008, 07:17 PM
Foo and Bar are words used in C to signify dummy variables, so that's why I used them for the purpose of showing you how to do things.
When you actually script, it's usual to use words that actually signifiy what you're using the variables for.

And you don't tell the script that a variable is a combo ID, a variable is just a value and nothing else
How you tell it that you're using it to be a combo ID is like this:

this->Data = comboID;
'this' references the ffc you have the script attached to, '->' is a pointer, which is saying that you want to reference this ffc's data, and then you set that value with the assignment operator, '=', to the integer, 'comboID'.

Scary Binary's covered a lot of this stuff in the ZC wiki, go and have a read of that and see if it helps.

Gleeok
02-04-2008, 07:20 PM
but what about the combo variables? i want them to be stated by the foo and bar intergers, which i have set to the D:0 and D:1 slots. is there no way to tell the script that "hey bar/foo is a combo ID"?


But you already declared them!



void run( int foo,int bar){

foo is whatever you set D0 to, and the same with bar. If you want, say, combo ID 6700, then set D0 to 6700.

You can then access that by:


ffc eye1 = Screen->LoadFFC(1);
eye1->Data = foo;

That will set ffc 1 graphics to use combo 6700, or whatever you input for D[0].

Joe123
02-04-2008, 07:24 PM
Becha to it ^_^

Also I just noticed, in your title

bool reality = false;
Is unnecessay, because if you declare a boolean it's set to false by default.
Hehehe

Gleeok
02-04-2008, 07:34 PM
Sure, but it loses a little something like that....Howabout now. :p

Master Maniac
02-04-2008, 07:35 PM
but thats not what i want to happen. i want to say that setting the variables for foo and bar (which are covered in D: slots) would set the combo ID. meaning, defining the value for foo, defines the value for comboID.

and then later i would refrence the variables not foo, but combo in order to acknowledge that something has to happen to do with this combo. I dont want the ffc to recognize them just yet.

but anyway, i dont think there is an actual combo ID variable (or if so it doesent seem to be on the list) so im thinking something like this



[edit] int ComboD[]
The combo ID of the ith combo on the screen, where i is the index used to access this array. Combos are counted left to right, top to bottom.

but that would be a pain in the butt to do, since you would have to count up the combos on the screen to figure this out. and also im not sure if it counts toward all combos of the same ID or just that one that you select.

and also i have some slightly more complex questions. then you aet a coordinate for an ffc, are you setting the coordinate for the top left pixel of the combo? or does it recognize it as a whole?

and also, as i dont see this on the list either, how would i say "when the ffc comes within (# of pixels) of this combo"?

Master Maniac
02-04-2008, 07:40 PM
and also with the combo thing, im not making it the graphics for the enemy itself. those will be the combos it "bounces" off of.

sorry double post, computer is acting up.

Gleeok
02-04-2008, 07:42 PM
Yes, top-left corner. and


if(Abs(x,y)<z){

for proximity.

Master Maniac
02-04-2008, 07:49 PM
ahh ok thank you gleeok lol this helps a lot XD

Joe123
02-04-2008, 07:57 PM
If you have something that references combos by counting along, what you do is this:

Screen->ComboD[ComboAt(x,y)] = whatever;
ComboAt(x,y) converts a single reference to coordinates.

Gleeok
02-04-2008, 07:59 PM
Ok, so get started then. ;)

Here's the basic archtype you can use:


ffc script makeit{

void run (){ // D[] vars go here

//===================================
// DECLARED STUFF GOES HERE
//===================================

while(true){

Waitframe();

//===================================
// SCRIPT STUFF GOES HERE
//===================================

} // end of true
}
} // end of script

Master Maniac
02-04-2008, 08:15 PM
ok i understand.

and im sorry for being so frustrating lol it takes me a little bit to fully grasp a concept.

so with the


if(Abs(x,y)<z){

i have to state the X and Y coordinates first, and what is using these coordinates. so to start.


if(Abs(eye1->Y)<18)

im only stating the Y coordinates because basically what i mean is "when the Y coordinate comes within 18 pixels of". so i could, theoretically remove X from this altogether.

the part about this that confuses me here is this. i have to have a dummy variable(foo) that identifies a number when set in the D: settings. this number is later identified as a combo ID later in the script. this should refrence that combo ID set by foo. however im not quite sure how to set it up.i dont want it to make the graphics become the combo or anything like that, i just need it to recognize that foo sets the combo ID for another variable. so would


combo1 = ComboD[int. foo];

work? and then i plug it in here :


if(Abs(eye1->Y)<18(combo1->Y))

which as i see it says "when eye1's Y coordinates come within 18 pixels of combo1's Y coordinates"

but this all depends on if i set up the combo1 = ComboD[int. foo]; stuff is set up correctly. and as i see it, that should work, saying that the ID of the combo is described by the number (foo) which is defined via D: slot.

my main question: is this right? lol

Joe123
02-04-2008, 08:31 PM
if(Abs(x,y)<z){
This is infact wrong, so don't get confused with that ¬_¬

What Gleeok meant is this:

if(Abs(x - y) < z){
With a minus sign, not a comma.
Makes all the difference.



if(Abs(eye1->Y)<18)
This will function, but what it says is:
'If the absolute parameter of eye1's Y coordinate is less than 18, run this scope'.
So basically, that part is the same as:


if(eye1->Y < 18)
Which isn't what you want.

You're trying to work out whether the distance between two points is less than 18, but you're only put one point into the mix.
Which obviously isn't going to work.

What you mean is:


if(Abs(eye1->Y - combo1Y) < 18)
That should work better.



combo1 = ComboD[int. foo];
What is this?
Declare all your variables after the void run command, and don't declare them with a full stop after 'int'.


Right, on a side(ish) note, you need to understand independance of vertical and horizontal motion.
It's simple really, if you're referencing coordinates or speeds, X and Y components are always treated seperately.


What you want is to firstly just find the (x,y) coordinate that you want your ffc to bounce of in ZQuest, then this:
[code]if(Abs(eye1->Y - y) < 18) && Abs(eye1->X - x < 18)){//proceed}

Gleeok
02-04-2008, 08:37 PM
Yeah, a minus...

....

...<_< oops

Master Maniac
02-04-2008, 08:44 PM
you might be proud of me then XD i recognized this because the bouncing depends on the difference and independance of the X and Y motion. if both Vx and Vy are set to 2 then it moves diagonally to the lower right at 2 pixels per frame. or it appears to. in reality it moves down 2 pixels and right 2 pixels.

right so knowing that i dont have to re-state the int. part, this is what my script looks like thus far.


import "std.zh"

ffc script eyesore{

void run( int foo,int bar,int barieo){//ok declares D: setting variables

combo1 = comboD(foo);//made sure to remove the int's

combo2 = comboD(bar);

int x; int y;

int speed = 2;

npc ghosted_hp_enemy1 = screem->createNPC(barieo);

ffc eye1 = Screen->LoadFFC(1);

while (true){

eye1-> Vx = speed;//sets the velocity up as diagonal movement

eye1-> Vy = speed;

eye1-> X = // need to find the X coordinate for "the center of the screen"

eye1-> Y = 19;

ghosted_hp_enemy1->X = eye1-> X;//attaches my enemy

ghosted_hp_enemy1->Y = eye1-> Y;

ghosted_hp_enemy1->HP = 20

if(Abs(eye1->Y)<18(combo1->Y)){//this does the "bounce" effect

eye1-> Vy*-1;

}

if(Abs(eye1->X)<18(combo1->X)){

eye1-> Vx*-1:

}

if(Abs(eye1->Y)<18(combo2->Y)){

eye1-> Vy*-1;

}

if(Abs(eye1->X)<18(Combo2->X)){

eye1-> Vx*-1;

}

if(Abs(ghosted_hp_enemy1->HP)==0){

eye1-> X = -100;

eye1-> Y = -100;

Master Maniac
02-04-2008, 09:03 PM
ok, now.i fixed some of my wrong spots. sorry for the double post. im hating my computer right now and it seems to return the favor.


import "std.zh"

ffc script eyesore{

void run( int foo,int bar,int barieo){

combo1 = ComboD[foo];

combo2 = ComboD[bar];

int x; int y;

int speed = 2;

npc ghosted_hp_enemy1 = screem->createNPC(barieo);

ffc eye1 = Screen->LoadFFC(1);

while (true){

eye1-> Vx = speed;

eye1-> Vy = speed;

eye1-> X = // need to find the X coordinate for "the center of the screen"

eye1-> Y = 19;

ghosted_hp_enemy1->X = eye1-> X;

ghosted_hp_enemy1->Y = eye1-> Y;

ghosted_hp_enemy1->HP = 20

if(Abs(eye1->Y - combo1->Y)<18){

eye1-> Vy*-1;

}

if(Abs(eye1->X - combo1->X)<18){

eye1-> Vx*-1:

}

if(Abs(eye1->Y - combo2->Y)<18){

eye1-> Vy*-1;

}

if(Abs(eye1->X - combo2->X)<18){

eye1-> Vx*-1;

}

if(Abs(ghosted_hp_enemy1->HP)==0){

eye1->Data = 0

}

Waitframe()

}

this would be my script. now i just have ot repeat it 3 more times and link it tp a 5th ffc to make it my custom boss XD

Gleeok
02-04-2008, 09:11 PM
Question: Do want the eyeballs to bounce off of any/all solid combos/walls? Because I already have that code...unless you want to make it yourself.

and..

eye1-> Vx = speed; //right

eye1-> Vy = speed; //down


//eye1-> X = ..

//eye1-> Y = 19;
the last ones will overwrite the first ones. You cant have velocity if the ffc is fixed at a point every frame.

Master Maniac
02-04-2008, 09:15 PM
ahh yes i would love to make them bounce from solid combos if you dont mind XD

and also, i guess i took an extra step there. i was trying to create a "spawn point" per se. it will just have to be something edited in the ffc traits itself.

and gleeok, when this is completely finished, it should be your kind of enemy. im making it tackle link AND shoot fireballs [eventually] to cause mass destruction lol.

Gleeok
02-04-2008, 10:17 PM
Alright well here's an old version. (works fine) ;) I added it to yours for you. Now "eye1 will perpetually bounce off walls.



import "std.zh"

ffc script eyesore{

void run( int foo,int bar,int barieo){

combo1 = ComboD[foo];

combo2 = ComboD[bar];

int x; int y;

int speed = 2;

npc ghosted_hp_enemy1 = screem->createNPC(barieo);

ffc eye1 = Screen->LoadFFC(1);

while (true){

Waitframe();


eye1-> Vx = speed;

eye1-> Vy = speed;

ghosted_hp_enemy1->X = eye1-> X;

ghosted_hp_enemy1->Y = eye1-> Y;

ghosted_hp_enemy1->HP = 20

if(Abs(eye1->Y - combo1->Y)<18){

eye1-> Vy*-1;

}

if(Abs(eye1->X - combo1->X)<18){

eye1-> Vx*-1:

}

if(Abs(eye1->Y - combo2->Y)<18){

eye1-> Vy*-1;

}

if(Abs(eye1->X - combo2->X)<18){

eye1-> Vx*-1;

}

if(Abs(ghosted_hp_enemy1->HP)==0){

eye1->Data = 0

}
//-----------------------eye1 bounce code-----------

if ( (eye1->Vx > 0) && (!canMove(eye1->X+17,eye1->Y))){
eye1->Vx = -eye1->Vx; }
else{
if ( (eye1->Vx < 0) && (!canMove(eye1->X-1,eye1->Y))){
eye1->Vx = -eye1->Vx; }
else{
if ( (eye1->Vy > 0) && (!canMove(eye1->X,eye1->Y+17))){
eye1->Vy = -eye1->Vy; }
else{
if ( (eye1->Vy < 0) && (!canMove(eye1->X,eye1->Y-1))){
eye1->Vy = -eye1->Vy; }
}
}
}

if(eye1->X > 232) { eye1->Vx = -1; eye1->X--;}
if(eye1->X < 8) { eye1->Vx = 1; eye1->X++;}
if(eye1->Y > 152) { eye1->Vy = -1; eye1->Y--;}
if(eye1->Y < 8) { eye1->Vy = 1; eye1->Y++;}

}
}
bool canMove(int x, int y){

// x=23, y=130
// Obviously in range...
if(x<0 || x>255 || y<0 || y>175)
return false;
int mask=1111b;

// x % 16 = 7, so
// mask = 1111 & 0011 = 0011
if(x%16<8)
mask&=0011b;
else
mask&=1100b;

// y % 16 = 2, so
// mask = 0011 & 0101 = 0001
if(y%16<8)
mask&=0101b;
else
mask&=1010b;

// All but the top-right quarter of the combo is solid, so ComboS = 1011
// mask & ComboS = 0001 & 1011 = 0001
// The result wasn't 0, so return false
return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);
}// end of canMove

} //

Master Maniac
02-04-2008, 10:30 PM
oh... wow... ok that was scary... lots of big numbers...

but so basically it bounces off of un-walkable combos now?

oh shit... you can hate me now...

the whole reason i didnt try this before, therefore the reason i wanted to set combos is because where i would use it, it would be staying over un-walkable combos. actually that was matthew's script with the lava swimmer thing. but my point being, this wouldnt work for me if its above those lava combos because they are all un-walkable.

I will however keep this together with the script, so that i when i post it in the showcase, other people could use it and have it bounce off walls and all unwalkable combos. maybe ill use it twice so your efforts werent completely in vain.

actually, ill probably turn this into 2 seperate scripts. (i know what im doing)

oh and speaking of, everyone who has helped me is gonna get the credit for it in my quest that im putting this in, since it wouldnt be possible without all your help.

C-Dawg
02-06-2008, 07:57 PM
Oh for pete's sake.

Just rewrite the script so that it bounces when it's adjacent to a particular flag (use one of the script flags). Then you can draw your own boundaries on the screen.

Master Maniac
02-23-2008, 03:37 PM
hey joe... i have a request now. im going to test this one soon, being my first one and all, and i havent really worked on it much, but i think its done with the basic movement for now. and im pretty sure ive set it up right too, lol wouldnt you be proud XD youre a good teacher lol. so here it is.


import "std.zh"

ffc script eyesore{

void run( int foo,int bar,int barieo){

combo1 = ComboD[foo];

combo2 = ComboD[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);

while (true){

eye1-> Vx = speed;

eye1-> Vy = speed;

ghosted_hp_enemy1->X = eye1-> X;

ghosted_hp_enemy1->Y = eye1-> Y;

ghosted_hp_enemy1->HP = 20

if(Abs(eye1->Y - combo1->Y)<18){

eye1-> Vy*-1;

}

if(Abs(eye1->X - combo1->X)<18){

eye1-> Vx*-1:

}

if(Abs(eye1->Y - combo2->Y)<18){

eye1-> Vy*-1;

}

if(Abs(eye1->X - combo2->X)<18){

eye1-> Vx*-1;

}

if(Abs(ghosted_hp_enemy1->HP)==0){

eye1->Data = 0

}

Waitframe()

}


ffc eye2 = Screen->LoadFFC(2);

while (true){

eye2-> Vx = speed;

eye2-> Vy = speed;

ghosted_hp_enemy2->X = eye2-> X;

ghosted_hp_enemy2->Y = eye2-> Y;

ghosted_hp_enemy2->HP = 20

if(Abs(eye2->Y - combo1->Y)<18){

eye2-> Vy*-1;

}

if(Abs(eye2->X - combo1->X)<18){

eye2-> Vx*-1:

}

if(Abs(eye2->Y - combo2->Y)<18){

eye2-> Vy*-1;

}

if(Abs(eye2->X - combo2->X)<18){

eye2-> Vx*-1;

}

if(Abs(ghosted_hp_enemy2->HP)==0){

eye2->Data = 0

}

Waitframe()

}

ffc eye3 = Screen->LoadFFC(3);

while (true){

eye3-> Vx = speed;

eye3-> Vy = speed;

ghosted_hp_enemy3->X = eye3-> X;

ghosted_hp_enemy3->Y = eye3-> Y;

ghosted_hp_enemy3->HP = 20

if(Abs(eye3->Y - combo1->Y)<18){

eye3-> Vy*-1;

}

if(Abs(eye3->X - combo1->X)<18){

eye3-> Vx*-1:

}

if(Abs(eye3->Y - combo2->Y)<18){

eye3-> Vy*-1;

}

if(Abs(eye3->X - combo2->X)<18){

eye3-> Vx*-1;

}

if(Abs(ghosted_hp_enemy3->HP)==0){

eye3->Data = 0

}

Waitframe()

}

ffc eye4 = Screen->LoadFFC(4);

eye4-> Vx = speed;

eye4-> Vy = speed;

ghosted_hp_enemy4->X = eye4-> X;

ghosted_hp_enemy4->Y = eye4-> Y;

ghosted_hp_enemy4->HP = 20

if(Abs(eye4->Y - combo1->Y)<18){

eye4-> Vy*-1;

}

if(Abs(eye4->X - combo1->X)<18){

eye4-> Vx*-1:

}

if(Abs(eye4->Y - combo2->Y)<18){

eye4-> Vy*-1;

}

if(Abs(eye4->X - combo2->X)<18){

eye4-> Vx*-1;

}

if(Abs(ghosted_hp_enemy4->HP)==0){

eye4->Data = 0

}

Waitframe()

}

ffc center = Screen->LoadFFC(5);

while (true){

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

center->Data = 0}

Waitframe()

}

}

could you make a patch for the "attacking" part like we talked about in the beginning of this thread? please? if you dont want to its fine. ill find a way lol.

and also, this is set up right isnt it?

Joe123
02-23-2008, 04:18 PM
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.

Master Maniac
02-23-2008, 04:58 PM
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

Joe123
02-23-2008, 07:55 PM
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.

Master Maniac
02-24-2008, 12:44 PM
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...

Joe123
02-24-2008, 12:51 PM
:eek:

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.

Master Maniac
02-24-2008, 02:37 PM
oh no... *more sadness*... well then i guess im going with gleeok's original idea to just make it bounce off solid walls then.

Joe123
02-24-2008, 02:53 PM
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.

Master Maniac
02-24-2008, 03:12 PM
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

Joe123
02-24-2008, 03:15 PM
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.

Master Maniac
02-24-2008, 03:45 PM
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?

Joe123
02-24-2008, 03:49 PM
No, that's it.

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

Master Maniac
02-24-2008, 04:00 PM
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...

Joe123
02-24-2008, 04:02 PM
>_<

if(Screen->ComboF[ComboAt(eye1->X, eye1->Y)] == flag){

Bit like that.

Master Maniac
02-24-2008, 04:44 PM
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?

Joe123
02-24-2008, 06:29 PM
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.

Master Maniac
02-24-2008, 08:41 PM
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?

Joe123
02-24-2008, 09:04 PM
Yes, although the ones labelled 'Script Only' or whatever are probably best.
98+.

Master Maniac
02-24-2008, 09:24 PM
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?

Joe123
02-24-2008, 09:40 PM
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.

Master Maniac
02-24-2008, 09:49 PM
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?

Joe123
02-25-2008, 12:43 PM
No I don't think they do.

I'd bool personally though.

Master Maniac
02-25-2008, 11:47 PM
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?

Joe123
02-26-2008, 03:40 AM
If you want to show it to me :shrug:

Master Maniac
02-26-2008, 06:52 PM
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?

Joe123
02-26-2008, 06:59 PM
'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
}

Master Maniac
02-27-2008, 09:41 PM
...?

this confuses me...

i thought ! meant "not"?

Joe123
02-28-2008, 03:34 AM
It does, what's confusing?

Master Maniac
02-28-2008, 10:40 PM
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?

Gleeok
02-29-2008, 01:32 AM
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.

Master Maniac
03-01-2008, 11:04 AM
ahh i understand now lol

thank you gleeok =)