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

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

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.

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.
😃 looks reeeally creepy. like its hiding something. or it could be the look someone gives after farting in an elevator. either way works.

You agree with me about what? 😕
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.

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...😃...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:

lol i kno it wasnt a post here but i remember reading a post where you said the 😃 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!

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.

[EDIT:] 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.
[/EDIT]

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.

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?

*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.

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?

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.

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?

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

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?

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.

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?

...

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 wrote: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.

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.

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

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.

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?

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.

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?

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.

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?

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.