PDA

View Full Version : script help needed!!!



Master Maniac
04-30-2008, 10:45 PM
also posted at pure.
im making a cutscene script.
however, it doesent run properly. imi pretty confident it has something to do with my loops and such, but the syntax of everything is checked. the scope is kinda messed up, however, because i did a lot of editing and backtracking.

the script does everything up to disabling the movement. after that no part of the script runs.


import "std.zh"

ffc script elzo_cutscene{
void run(int s,int c1,int c2,int tiles){

int t;

while(t<4)

if(Link->Item[255]){

int combo = Screen->ComboT[ComboAt(Link->X,Link->Y)];
Screen->ComboT[ComboAt(Link->X,Link->Y)] = c1;
Waitframes(3);
Screen->ComboT[ComboAt(Link->X,Link->Y)] = combo;
}

else{

ffc octo1=Screen->LoadFFC(2);
ffc octo2=Screen->LoadFFC(3);
ffc rock=Screen->LoadFFC(4);
ffc fairy=Screen->LoadFFC(1);

if(rock->X==(fairy->X+4)){

rock->X=octo2->X;
octo2->Data+=2;
rock->Vx*=-1;
t+=1;
}

if(rock->X==(fairy->X+12)){

rock->X=octo1->X;
octo1->Data+=2;
rock->Vx*=-1;
t++;
}

if(t<4){

Link->InputLeft=false;
Link->InputRight=false;
Link->InputUp=false;
Link->InputDown=false;
Link->InputB=false;

}

if(t==4){

Screen->Message(s);
}
if(Link->X==(tiles*16)){

int combo2 = Screen->ComboT[ComboAt(Link->X,Link->Y)];
Screen->ComboT[ComboAt(Link->X,Link->Y)] = c2;
Waitframes(3);
Screen->ComboT[ComboAt(Link->X,Link->Y)] = combo2;
Link->Item[255]=true;
octo1->Data=0;
octo2->Data=0;
}
}
Waitframe();
}
}
}
}

i just don't understand what's wrong with it.

the effect i'm trying to create:

2 ffc's push 1 ffc at an ffc, taking turns at it. (coordinates get re-set when the projectile is lined up with the ffc being "attacked")

then, after the victim ffc is hit 4 times, it plays a message.

then it warps to another screen and gives link a dummy item, which stops makes a seperate outcome.

Master Maniac
05-03-2008, 11:26 AM
*bump*

i really need help here, guys...

EDIT: also, i have determined that my problems in this script have nothing to do with Abs()

(as far as i know...)

ScaryBinary
05-03-2008, 02:49 PM
I haven't found anything glaringly incorrect in the script, but here are a few general comments/tips that might help (or might not :D), along with some things I noticed in your script that may or may not be any big deal.

If you can post the paramters you're using for the FFCs (their starting X positions and velocities) I'll try to recreate the scene and see what happens.

What's up with that while loop?
I'm not sure if this is just a cut and paste error for the post or what, but there's no opening curley brace for your while loop. It should be
while(t<4) {. Also you might have an extra closing curley brace at the end of your script.

Initalize your variables
From your script:
int t;

while(t<4)
You declare a variable, then immediately check it's value in the while loop. But what value does "t" have at this point? You haven't set it to anything yet. Chances are it's 0, but that's generally not guaranteed. It's best to do something like
int t=0; just to be sure. I doubt this is a real problem with your script.

Trace() is your friend!
Use the Trace() function to write numbers to the allegro.log file. This will give you insight into how your scripts are running. For instance, you could write the value of your "t" variable to the log file each time the while loop executes. You may find that "t" never gets larger than 3 (or maybe it goes from 2 to 6), for example, and so the "if(t==4)" if statement is never true.

Sprinkle the Trace() calls throughout your loops or other areas where you think you might have problems to see what's getting executed. For instance, put a "Trace(1.0);" inside your first if statement. If you see that in the log file, you know that if statement gets executed. Put a "Trace(2.0);" in your second if statement...and so on.

Master Maniac
05-03-2008, 11:09 PM
ah thank you. actually the while loop problem was just a small error i made. i just forgot to put the brace when i went back and edited it.

i will try the trace thing. maybe it will work, but then again i already know where the script stops functioning.

i can tell you, as far as parameters go, the FFCs Y coordinates are all the same. ffc 1's X is 120. one of the next two is around 3-3.5 tiles away from it on each side. the rock is under the ffc on the left.

Vx for the rock is 2 i think and nothing else moves.

ScaryBinary
05-04-2008, 11:40 AM
I think I know part of the issue, but I haven't quite figured out how to fix it yet. It depends on where Link starts when your script is running.

First, I got it to display the message without any modifications to your script (other then fixing the while loop braces). So I'm not sure why you're not seeing that, unless you're passing in an invalid string number from the FFC editor or something of that nature.

Remember that your message gets displayed when t==4, and that Link can't move until t >= 4. So if Link's X position is not equal to (tiles * 16) at the start of the script, Link cannot ever meet this requirement until t==4.

So what that means is that even if Link gets Item 255 at the end of the while loop, at this point t==4, so you will exit the while loop (which only loops if t < 4). Meaning that the portion of the code at the top of the while loop that checks if Link has Item 255 is never executed.

Again, this depends on Link's starting X position. I'm not quite sure what the intent of that portion of the script is (does Link start at the left side of the screen, and then he walks to the right after the octoroks are done attacking the fairy?) so I could be completely off the mark here. But take a look how the value of "t" fits in with when Link can move.

I'll play around with the script more when I get another chance.

ScaryBinary
05-04-2008, 04:54 PM
Forgive the double-post.

I think I have it working. I verified that all of the code is executed at least. Here's the modified file. See if it works per your requirements.

I made a few changes.

I modified the while loop to be t<=4.
When t==4, in addition to displaying the message, I "deleted" the rock FFC by setting its velocity to 0, then setting its Data to 0. I'm not quite sure how yet, but I think the rock was what was messing things up.
Added a "t++" to the "if(Link->Item[255])" block. This will kick you out of the while loop.


import "std.zh"

ffc script elzo_cutscene{
void run(int s,int c1,int c2,int tiles){

int t = 0;

while(t<=4) {

if(Link->Item[255]){
int combo = Screen->ComboT[ComboAt(Link->X,Link->Y)];
Screen->ComboT[ComboAt(Link->X,Link->Y)] = c1;
Waitframes(3);
Screen->ComboT[ComboAt(Link->X,Link->Y)] = combo;
t++;
}
else{

ffc octo1=Screen->LoadFFC(2);
ffc octo2=Screen->LoadFFC(3);
ffc rock=Screen->LoadFFC(4);
ffc fairy=Screen->LoadFFC(1);

if(rock->X==(fairy->X+4)){
rock->X=octo2->X;
octo2->Data+=2;
rock->Vx*=-1;
t+=1;
}

if(rock->X==(fairy->X+12)){

rock->X=octo1->X;
octo1->Data+=2;
rock->Vx*=-1;
t++;
}

if(t<4){
Link->InputLeft=false;
Link->InputRight=false;
Link->InputUp=false;
Link->InputDown=false;
Link->InputB=false;
}

if(t==4){
Screen->Message(s);
rock->Vx = 0;
rock->X = 0;
rock->Data = 0;
}

if(Link->X <= (tiles * 16) ){
int combo2 = Screen->ComboT[ComboAt(Link->X,Link->Y)];
Screen->ComboT[ComboAt(Link->X,Link->Y)] = c2;
Waitframes(3);
Screen->ComboT[ComboAt(Link->X,Link->Y)] = combo2;
Link->Item[255]=true;
octo1->Data = 0;
octo2->Data = 0;
}
}
Waitframe();
}
}
}

Master Maniac
05-04-2008, 06:23 PM
i haven't tested it yet, but i knew the rock was the problem. it never reset its coordinates after the parameters were set in the if() statements. every time it collided with the "fairy" it was supposed to move to the other "octo" and switch its velocity along the X-axis. however, it never did that. when it would collide with the fairy, it would just keep going. i dont know why, but im pretty sure that was my main problem. i will try this one, though. i appreciate you not making any major modifications to it as well. thank you for the help.

ScaryBinary
05-05-2008, 07:33 AM
One more change I forgot to mention (I just remembered it while driving to work this morning....): I changed the logic in the last if statement to execute if Link's X position is is less than tiles * 16...
if(Link->X <= (tiles * 16) ){
int combo2 = Screen->ComboT[ComboAt(Link->X,Link->Y)];
Screen->ComboT[ComboAt(Link->X,Link->Y)] = c2;
Waitframes(3);
Screen->ComboT[ComboAt(Link->X,Link->Y)] = combo2;
Link->Item[255]=true;
octo1->Data = 0;
octo2->Data = 0;
}
I did this becuase in my test, Link started out in the middle of the screen. If You want Link to start out on the left side of the screen, then change this if statement back to what you had, or to Link->X >= (tiles * 16).

Master Maniac
05-05-2008, 06:08 PM
actually i'm going to have to edit quite a few things. this was actually a request, so yeah. link is supposed to enter from the top of the screen.

but the way i need it, he enters from the right side, so i will probably have to add some notes in this as to how to make it work for link entering from all sides.

thanks for your help!