Jump to content

Photo

WW style swimming.


  • Please log in to reply
17 replies to this topic

#1 Geoffrey

Geoffrey

    Chosen One

  • Members

Posted 16 December 2008 - 10:31 AM

So, what I was thinking was that it should work just like the 'Bottomless Pits and Lava' script, except it will allow you to swim for 15 seconds before you drown and would be for 'water' combos instead of 'centre statues'.

Who is talented enough in the ways of the script to take on my amazing challenge?

No, but seriously. It would probably be a really simple edit.

#2 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 16 December 2008 - 06:37 PM

Sounds pretty easy.

I'll script it once I finish my World History Review.

EDIT: I have it. It should work.
It warps you to the last place you were at before swimming.
I designed it for use with global scripts
CODE
const int DROWNTIME = 900; //that does 15 seconds
const int DROWNSFX = 0; //set the drowning sfx here
const int DROWNDMG = 4; //that's a quarter heart
const int WARPSFX = 0;  //set the warping out sfx here

//put this before the loop of your global script slot 2
int laststate = Link->Action;
int warpx = Link->X;
int warpy = Link->Y;
int warpdmap = Game->GetCurDMap();
int warpdscreen = Game->GetCurDMapScreen();
int drowncounter = 0;

//put this in the middle of the global script
if(Link->Action == LA_SWIMMING) {
    drowncounter ++;
    if(drowncounter == DROWNTIME) {
        Game->PlaySound(DROWNSFX);
        for(int i=0; i<40; i++) {
            Waitframe();
            Link->Action = LA_DROWNING;
        }
        Link->Warp(warpdmap, warpdscreen);
        Link->X = warpx; Link->Y = warpy;
        Link->Action = 0;
        Link->HP -= DROWNDMG;
        Game->PlaySound(WARPSFX);
    }
} else {
    warpx = Link->X;
    warpy = Link->Y;
    warpdmap = Game->GetCurDMap();
    warpdscreen = Game->GetCurDMapScreen();

    if(laststate == LA_SWIMMING)
        drowncounter = 0;
}

//put this right before the waitframe in your global script slot 2

laststate = Link->Action;

It's just a quick fix. It's not really complete yet, but it should work.
PUT IT IN YOUR GLOBAL SCRIPT!!!!

Edited by Beefster, 17 December 2008 - 04:59 PM.


#3 Geoffrey

Geoffrey

    Chosen One

  • Members

Posted 16 December 2008 - 10:51 PM

Sweet, I'll try it out right now. icon_smile.gif

QUOTE
LINE 16: SYNTAX ERROR, UNEXPECTED IF, EXPECTING
$END, ON TOKEN IF


Doesn't seem to be working...and I'm no scripter. icon_razz.gif
But you said it wasn't really complete, so it's cool.

Edited by Molten Onyx, 16 December 2008 - 10:57 PM.


#4 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 16 December 2008 - 11:12 PM

It means he forgot to close the 'if' expression. Can you organize this a little bit beefster09? It'll be useful if you can let the user(that doesnt have knowledge with zscript) know what you're trying to do?

#5 Joe123

Joe123

    Retired

  • Members

Posted 17 December 2008 - 04:32 AM

No, it means he hasn't actually put that code chunk inside the global script.

You can't just use that code as it is MO, you need to put it inside the global script.
CODE
global script Slot2{
     void run(){
          while(true){
          //code goes here

     Waitframe();
     }
}


#6 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 17 December 2008 - 04:58 AM

There is also a waitrame() with no semicolon in there. Unless you insert the semicolon after the waitframe , it wont compile.

#7 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 17 December 2008 - 04:59 PM

You're right. there is. I've been using ika for a while, so I'm still in Python mode. Python doesn't use semicolons for ending statements. I'll just fix that.

#8 Geoffrey

Geoffrey

    Chosen One

  • Members

Posted 19 December 2008 - 08:15 PM

CODE
import "std.zh"
const int DROWNTIME = 900; //that does 15 seconds
const int DROWNSFX = 0; //set the drowning sfx here
const int DROWNDMG = 4; //that's a quarter heart
const int WARPSFX = 0;  //set the warping out sfx here
global script slot2{
    void run(){
        while(true){
        int laststate = Link->Action;
        int warpx = Link->X;
        int warpy = Link->Y;
        int warpdmap = Game->GetCurDMap();
        int warpdscreen = Game->GetCurDMapScreen();
        int drowncounter = 0;
            if(Link->Action == LA_SWIMMING) {
                drowncounter ++;
                if(drowncounter == DROWNTIME) {
                    Game->PlaySound(DROWNSFX);
                    for(int i=0; i<40; i++) {
                        Waitframe();
                        Link->Action = LA_DROWNING;
                    }
                    Link->Warp(warpdmap, warpdscreen);
                    Link->X = warpx; Link->Y = warpy;
                    Link->Action = 0;
                    Link->HP -= DROWNDMG;
                    Game->PlaySound(WARPSFX);
                }
            } else {
                warpx = Link->X;
                warpy = Link->Y;
                warpdmap = Game->GetCurDMap();
                warpdscreen = Game->GetCurDMapScreen();

                if(laststate == LA_SWIMMING)
                    drowncounter = 0;
            }
    laststate = Link->Action;
    Waitframe();
    }
}

I have it set up like that right now, but when I compile it, it tells me there is an error on line 42. There is no line 42.
Also, sorry for not putting it together before, I have a bad habit of quickly looking over things without actually reading them.

EDIT: I gots 200 posts now. icon_awesome.gif

Edited by Molten Onyx, 19 December 2008 - 08:28 PM.


#9 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 19 December 2008 - 08:31 PM

You're missing a close-bracket.

Here's what it should look like:
CODE
import "std.zh"

const int DROWNTIME = 900; //that does 15 seconds
const int DROWNSFX = 0; //set the drowning sfx here
const int DROWNDMG = 4; //that's a quarter heart
const int WARPSFX = 0;  //set the warping out sfx here

global script slot2{
    void run(){
    
        int laststate = Link->Action;
        int warpx = Link->X;
        int warpy = Link->Y;
        int warpdmap = Game->GetCurDMap();
        int warpdscreen = Game->GetCurDMapScreen();
        int drowncounter = 0;
        //Don't put declarations in while loops. THAT'S BAD.
    
        while(true){
            
            if(Link->Action == LA_SWIMMING) {
                drowncounter ++;
                if(drowncounter == DROWNTIME) {
                    Game->PlaySound(DROWNSFX);
                    for(int i=0; i<40; i++) {
                        Waitframe();
                        Link->Action = LA_DROWNING;
                    }
                    Link->Warp(warpdmap, warpdscreen);
                    Waitframe();
                    Link->X = warpx; Link->Y = warpy;
                    Link->Action = 0;
                    Link->HP -= DROWNDMG;
                    Game->PlaySound(WARPSFX);
                }
            } else {
                warpx = Link->X;
                warpy = Link->Y;
                warpdmap = Game->GetCurDMap();
                warpdscreen = Game->GetCurDMapScreen();

                if(laststate == LA_SWIMMING)
                    drowncounter = 0;
            }
            
            laststate = Link->Action;
            Waitframe();
        }
    }
}

Edited by Beefster, 10 January 2009 - 05:37 PM.


#10 Geoffrey

Geoffrey

    Chosen One

  • Members

Posted 19 December 2008 - 08:40 PM

Okay, thanks. I re-organized mine to look like that and now it works.

Sorry if I'm just being annoying. icon_lol.gif

#11 Geoffrey

Geoffrey

    Chosen One

  • Members

Posted 22 December 2008 - 01:14 PM

The script doesn't warp you to where you last were before entering the water, instead when you drown it warps you to the warp location thingy (blue square).

If you could fix this it would be great.


#12 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 22 December 2008 - 04:29 PM

That's odd. The script should drop him off at the last coordinates Link was at before swimming. I'll take a look at it later.

Edited by Beefster, 22 December 2008 - 04:31 PM.


#13 Geoffrey

Geoffrey

    Chosen One

  • Members

Posted 10 January 2009 - 01:35 PM

Hey, are you still gonna' look at it or what?

It's okay if you don't, but it would be awesome if you would.

#14 Professor Snugglesworth

Professor Snugglesworth

    Initiate

  • Members

Posted 10 January 2009 - 02:21 PM

I'd say try adding the line "Waitframe();" in between the two lines:

CODE
                    Link->Warp(warpdmap, warpdscreen);
                    Link->X = warpx; Link->Y = warpy;


I think I've run into this before, that if you try to change Link's X and Y positions during the same frame that he warps, it puts him at the blue box at the end of the frame anyway.

#15 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 10 January 2009 - 05:36 PM

Ah. Okay. I'll edit my earlier post. See if that works MO.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users