Jump to content

Photo

Sail Boat Script


  • Please log in to reply
84 replies to this topic

#1 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 26 January 2008 - 01:48 PM

This is what I gat so far:
CODE
int level = 0;
bool boatjump = false;

ffc script boat
{
    void run()
    {
    ffc boat = Screen->LoadFFC(1);
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
    ffc barrel
    ffc ball = Screen->LoadFFC(7);

    while(true)
        {
        Link->Action = LA_FROZEN;
        if(Link->InputUp){
            boat->Vy = 1;
            link2->Vy = 1;
            water->Vy = 1;
            }
        if(Link->InputDown){
            boat->Vy = -1;
            link2->Vy = -1;
            water->Vy = -1;
            }
        int choice = Rand(3);
        int choicey = Rand(9);
        if (choice == 1) {barrel = Screen->LoadFFC(4);}
        if (choice == 2) {barrel = Screen->LoadFFC(5);}
        if (choice == 3) {barrel = Screen->LoadFFC(6);}
        if (choicey == 1)
            {
            barrel->Y = 16;
            barrel->Vx = -1;
            }
        if (choicey == 2)
            {
            barrel->Y = 32;
            barrel->Vx = -1;
            }
        if (choicey == 3)
            {
            barrel->Y = 48;
            barrel->Vx = -1;
            }
        if (choicey == 4)
            {
            barrel->Y = 64;
            barrel->Vx = -1;
            }
        if (choicey == 5)
            {
            barrel->Y = 80;
            barrel->Vx = -1;
            }
        if (choicey == 6)
            {
            barrel->Y = 96;
            barrel->Vx = -1;
            }
        if (choicey == 7)
            {
            barrel->Y = 112;
            barrel->Vx = -1;
            }
        if (choicey == 8)
            {
            barrel->Y = 128;
            barrel->Vx = -1;
            }
        if (choicey == 9)
            {
            barrel->Y = 144;
            barrel->Vx = -1;
            }
        }
    }
}


This is want it needs to do:
QUOTE
There are 3 ffcs on the screen right now. Link is frozen and invisible.

FFC#1 is the boat and sail.
FFC#2 is "Link".
FFC#3 is the water behind the boat.

When up is pressed, ffcs 1 and 2 move up.

When down is pressed, ffcs 1 and 2 move down.

When left or right is pressed, nothing happens.

If A is pressed, the ffcs 1 and 2 jump.

3 types of obstacles will "move" to the left from a random position off the right side.

If one hits FFC#2, Link loses a heart.

FFC#4 will be used for the barrel/ice.
FFC#5 will be used for the whirlpool.
FFC#6 will be used for the cyclone.

Also, if Link has a cannon, the obstacles will appear less often and zoras will appear and shoot fireballs at FFC#2.
If B is pressed, the cannon fires.

FFC#7 will be used for the cannon ball.

After a few min. Link will warp to Dmap, screen.

The difficultly level increases as the game goes on.


It doesn't do anything. icon_frown.gif
I will owe whoever helps me with this a big favor.

Edited by Mega Link, 26 January 2008 - 01:51 PM.


#2 Eddard McHorn Van-Schnuder

Eddard McHorn Van-Schnuder

    smash the bye button

  • Members
  • Real Name:Ronny Wiltersen

Posted 27 January 2008 - 06:41 AM

I don't know much about scripting... infact, I don't know anything at all...
BUT I know that... or I THINK you can just edit the Epna script to work like a boat...am I right?

#3 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 27 January 2008 - 10:30 AM

Looks like you forgot to put a Waitframe(); in. Without delays, you're just gonna crash ZC. Try it with some frame delays. Like Waitframes(16);

I can also see exactly what you are trying to do. It's supposed to be a dodging game, right? You might want to incorporate more than 3 objects because they will continuously "respawn" on the edge of the screen before they have a chance to reach the boat. The better way is to have 4 types of objects each with their own combo sprites, and the fourth is blank and appears roughly half of the time. Then you just cycle between your 16 ffcs.

You also might want to optimize your choicey code with the following code instead of all the if statements:
CODE
barrel->X = choicey*16+16;
barrel->Vx = -1;

the +16 is actually necessary because Rand(i) generates a random number between 0 and one less than i.

Edited by Beefster, 27 January 2008 - 10:49 AM.


#4 Joe123

Joe123

    Retired

  • Members

Posted 27 January 2008 - 11:36 AM

QUOTE(Migokalle @ Jan 27 2008, 11:41 AM) View Post

I don't know much about scripting... infact, I don't know anything at all...
BUT I know that... or I THINK you can just edit the Epna script to work like a boat...am I right?


No, you're not.

#5 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 27 January 2008 - 01:19 PM

QUOTE(Beefster)
I can also see exactly what you are trying to do. It's supposed to be a dodging game, right?

YES!

I put a waitframe in but nothing happens. icon_cry.gif
CODE
ffc script boat
{
    void run()
    {
    ffc boat = Screen->LoadFFC(1);
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
    ffc barrel;
    ffc ball = Screen->LoadFFC(7);
    while(true)
        {
        //Link->Action = LA_FROZEN;
        if(Link->InputUp){
            boat->Vy = 1;
            link2->Vy = 1;
            water->Vy = 1;
            }
        if(Link->InputDown){
            boat->Vy = -1;
            link2->Vy = -1;
            water->Vy = -1;
            }
        waitframe();
        int choice = Rand(3);
        int choicey = Rand(9);
        if (choice == 1) {barrel = Screen->LoadFFC(4);}
        if (choice == 2) {barrel = Screen->LoadFFC(5);}
        if (choice == 3) {barrel = Screen->LoadFFC(6);}
        barrel->Y = choicey*16+16;
        barrel->Vx = -1;
        }
    }
}

The boat won't budge.

QUOTE(Beefster)
The better way is to have 4 types of objects each with their own combo sprites, and the fourth is blank and appears roughly half of the time. Then you just cycle between your 16 ffcs.

16 FFCs?


#6 Joe123

Joe123

    Retired

  • Members

Posted 27 January 2008 - 01:33 PM

CODE
ffc script boat{
    void run(){
    ffc boat = Screen->LoadFFC(1);
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
    ffc barrel;
    ffc ball = Screen->LoadFFC(7);
    int choice; int choicey;
        while(true){
            Link->Action = LA_FROZEN; //Why was this line noted? It makes Link invicible, aswell as stopping him from moving.
                    //exactly what you want, surely?
            if(Link->InputUp){
                boat->Vy = 1;
                link2->Vy = 1;
                water->Vy = 1;
            }
            if(Link->InputDown){
                boat->Vy = -1;
                link2->Vy = -1;
                water->Vy = -1;
            }
            if(link2->Y > 152){boat->Vy = 0; link2->Vy = 0; water->Vy = 0; //just a couple of edgeguard functions,
            if(link2->Y < 16){boat->Vy = 0; link2->Vy = 0; water->Vy = 0;  // we don't want Link leaving the screen.


            //choice = Rand(3);
            //choicey = Rand(9);
            //if(choice == 1) barrel = Screen->LoadFFC(4);
            //if(choice == 2) barrel = Screen->LoadFFC(5);
            //if(choice == 3) barrel = Screen->LoadFFC(6);
            //barrel->Y = choicey*16+16;
            //barrel->Vx = -1;
            //I've noted out this section basically because it won't work. I don't really get how you're trying to
            //make the barrels like this, this section of the script repeats every single frame, so what you have is
            //one ffc declared, which is then being told that it's one of 3 random ffcs every frame. That does not
            //equate to having three barrels, sorry.
        Waitframe(); //Waitframe has to have a capital W or it won't compile.
        }
    }
}

Tabs instead of spacebars is wonderful for scripting.

Edited by Joe123, 27 January 2008 - 01:34 PM.


#7 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 27 January 2008 - 01:40 PM

QUOTE(Joe123 @ Jan 27 2008, 12:33 PM) View Post

Tabs instead of spacebars is wonderful for scripting.

I am using tabs!

When I post it, it changes the tabs into spaces!

#8 Joe123

Joe123

    Retired

  • Members

Posted 27 January 2008 - 01:48 PM

Oh, sorry.

#9 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 27 January 2008 - 02:27 PM

It won't compile!

It says:
QUOTE(Stupid Zquest!)
LINE115: SYNTAX ERROR, UNEXPECTED SCRIPT, EXPECTING IDENTIFIER, ON TOKEN SCRIPT
FATAL ERROR P00: CAN'T OPEN OR PARSE INPUT FILE!


Here is lakelon.z

#10 Joe123

Joe123

    Retired

  • Members

Posted 27 January 2008 - 06:09 PM

CODE
import "std.zh"

//-----------------------------------//
//            Global Variables       //
//-----------------------------------//

bool guy1 = false;
bool guy2 = false;
bool guy3 = false;
bool guy4 = false;
int level = 0;
bool boatjump = false;

//-----------------------------------//
//               Global Scipts       //
//-----------------------------------//


//-----------------------------------//
//                FFC Scipts         //
//-----------------------------------//

ffc script bguys{
    void run(int guy){
        if(guy == 1 && !guy1){
            Screen->Message(5);
            guy1 = true;
        }
        if(guy == 2 && !guy2){
        Screen->Message(9);
            guy2 = true;
        }
        if(guy == 1 && guy2 && !guy3){
            Screen->Message(10);
            guy3 = true;
        }
        if(guy == 4 && !guy4){
            Screen->Message(11);
            guy4 = true;
        }
    }
}

ffc script mapmark{
    void run(){
        if(guy1) Link->Item[22] = true;
    }
}

ffc script boat{
    void run(){
    ffc boat = Screen->LoadFFC(1);
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
    ffc barrel;
    ffc ball = Screen->LoadFFC(7);
    int choice; int choicey;
        while(true){
            Link->Action = LA_FROZEN; //Why was this line noted? It makes Link invicible, aswell as stopping him from moving.
                    //exactly what you want, surely?
            if(Link->InputUp){
                boat->Vy = 1;
                link2->Vy = 1;
                water->Vy = 1;
            }
            if(Link->InputDown){
                boat->Vy = -1;
                link2->Vy = -1;
                water->Vy = -1;
            }
            if(link2->Y > 152){boat->Vy = 0; link2->Vy = 0; water->Vy = 0;} //just a couple of edgeguard functions,
            if(link2->Y < 16){boat->Vy = 0; link2->Vy = 0; water->Vy = 0;}  // we don't want Link leaving the screen.


            //choice = Rand(3);
            //choicey = Rand(9);
            //if(choice == 1) barrel = Screen->LoadFFC(4);
            //if(choice == 2) barrel = Screen->LoadFFC(5);
            //if(choice == 3) barrel = Screen->LoadFFC(6);
            //barrel->Y = choicey*16+16;
            //barrel->Vx = -1;
            //I've noted out this section basically because it won't work. I don't really get how you're trying to
            //make the barrels like this, this section of the script repeats every single frame, so what you have is
            //one ffc declared, which is then being told that it's one of 3 random ffcs every frame. That does not
            //equate to having three barrels, sorry.
        Waitframe(); //Waitframe has to have a capital W or it won't compile.
        }
    }
}


//-----------------------------------//
//                Item Scipts        //
//-----------------------------------//

//this script plays a message string upon
//obtaining the item. Once you attatch
//this script to an item, just place the
//string # into the D0 box in Arguments.

item script itemmessage{
    void run(int msgID){
        Screen->Message(msgID);
    }
}

item script levelincrease{
    void run(){
        level += 1;
    }
}


My bad, missed some right braces.

Also, if you want to check whether a boolean is true, you can do this:
CODE
bool checker;
if(checker){}

and you don't have to do this:
CODE
bool checker;
if(checker == true){}


Just takes less effort to write.
If you want to check if it's false, put an exclamation mark before it.
! means 'not'.

I changed the script around to do it like that because I'm bored and have nothing better to do.

#11 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 27 January 2008 - 07:30 PM

Thanks.

QUOTE(Joe123)
I changed the script around to do it like that because I'm bored and have nothing better to do.


In that case, could you finish the script?

...

Please? icon_cry.gif

#12 Joe123

Joe123

    Retired

  • Members

Posted 28 January 2008 - 02:58 AM

Oh, I meant that I changed that ffc one that plays message strings to check for booleans in the quicker method.

And if you try and do it yourself, I'll fix it when it doesn't work.

I don't have the time to do it completely myself.


How's it going now anyway?
Does it compile/work?

#13 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 28 January 2008 - 08:01 PM

QUOTE(Joe123 @ Jan 28 2008, 01:58 AM) View Post

How's it going now anyway?
Does it compile/work?


Nope. The Boat still won't budge.

...


Why!?

QUOTE(Joe123 @ Jan 28 2008, 01:58 AM) View Post

Oh, I meant that I changed that ffc one that plays message strings to check for booleans in the quicker method.


Guess what that script is supposed to do.



#14 Joe123

Joe123

    Retired

  • Members

Posted 29 January 2008 - 02:41 AM

I'll test it myself in a bit and see perhaps.


And I don't really know, NPCs that play different string?

#15 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 29 January 2008 - 08:18 AM

QUOTE(Joe123 @ Jan 29 2008, 01:41 AM) View Post
I'll test it myself in a bit and see perhaps.


Ok.

QUOTE(Joe123 @ Jan 29 2008, 01:41 AM) View Post
And I don't really know, NPCs that play different string?


You know how in the new Zelda games that at the beginning, you talk to people and eventually get the item(s) needed to continue? That's what that script does.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users