PDA

View Full Version : Gameboy-Zelda Style Bottomless Pits/Lava Script



Joe123
01-11-2008, 02:46 PM
const int linkfalling = 0; // set here the first tile of your 5 tile Link Falling animation
const int linklava = 0; // set here the first tile of your 5 tile Link Drowning animation
const int fallingsfx = 0; // set here the SFX that plays when Link falls
const int lavasfx = 0; // set here the SFX that plays when Link drowns in lava
const int invis = 0; // set here the item ID of an item with Link Tile Modifier to make Link completely invisible

ffc script hole{
void run(int lava, int warpx, int warpy, int combotype, int tile){
int sfx = fallingsfx;
if(warpx == 0 && warpy == 0){Waitframes(5); warpx = Link->X; warpy = Link->Y;}
if(tile == 0){tile = linkfalling;}
if(combotype == 0){combotype = 35;}
if(lava != 0){if(tile == linkfalling){tile = linklava;}sfx = lavasfx;}
int timer; bool switch;
int x; int y; bool falling;

while(true){
if(Screen->ComboT[ComboAt(Link->X+8, Link->Y+8)] == combotype && Link->Z == 0){
if(Link->Action != LA_FROZEN && !falling){
falling = true;
}
while(falling && Screen->ComboT[ComboAt(Link->X+8, Link->Y+8)] == combotype && Link->Z == 0 && timer < 5){
timer++;
Waitframe();
}
for(timer = 0; timer < 40; timer++){
if(!switch){Game->PlaySound(sfx); switch = true; x = Link->X; y = Link->Y;}
Link->Item[invis] = true;
Link->Action = LA_FROZEN;
if(lava == 0) Screen->DrawTile(2, x, y, tile+Floor(timer/8), 1, 1, 6, 1, 0, 0, 0, 0, true, 128);
else Screen->DrawTile(2, x, y, tile+Floor(timer/8), 1, 1, 6, 1, 0, 0, 0, 0, true, 128);
Waitframe();
}
switch = false;
Link->Item[invis] = false;
Link->X = warpx; Link->Y = warpy;
Link->Action = 0;
Link->HP -= 8;
Game->PlaySound(19);
}
Waitframe();
}
}
}

Make sure to set the Constant Integers at the beginning, and also to include them into the script file.

Arguments:
D0: If D0 is equal to '0', the script makes pits. If D0 is not equal to '0', the script makes lava.
D1 && 2: D1 && 2 are the coordinates to have Link re-spawn at after falling into a pit. If left at 0, he will respawn where he entered the screen.
D3: The combotype for 'Pit' combos. If left at '0', they will be 'centre statue' combos, by default.
D4: The tile to be used for the 'Link Falling' animation. If left at '0', the ones set in the integers are the beginning will be used.

Russ
01-11-2008, 03:32 PM
Awesome! Joe, you are an amazing scripter!

Joe123
01-11-2008, 03:56 PM
Thanks :)

If you wanted a demonstration of this script in action, The Legend of Zelda: The Fort Knights (http://www.armageddongames.net/forums/showthread.php?t=100735) is a good way of finding out how it works :)

Beta Link
01-11-2008, 07:30 PM
Hmm... Well, depending on how well it works, I might use it! Way to go on this! :)

_L_
01-16-2008, 12:36 AM
Instead of manually moving Link and changing his HP, you could just set his Action to LA_DROWNING. It's like I said in build 643:
If you set it to LA_DROWNING, and Link isn't on a water tile, then he will 'drown', but his sprite won't be drawn at all.

Jigglysaint
01-16-2008, 01:00 AM
Cool. If I ever get this quest off the ground, I might use it.

Joe123
01-16-2008, 03:52 AM
Do I not need to worry about the invisible LTM then?

Beta Link
01-16-2008, 09:00 PM
Hey! I tried compiling it in Zquest, and I got multiple errors. This is in b718, btw...

Line 10- Function waitframes is undeclared
Line 18- Function comboat is undeclared
Line 19- Variable LA_Frozen is undeclared
Line 22- Function comboat is undeclared
Line 29- Variable LA_Frozen is undeclared
Line 30- Function floor is undeclared
Line 31- Function floor is undeclared

So I guess the problems are "waitframes", "comboat", "LA_Frozen", and "floor". Waitframes is supposed to be "waitframe", isn't it? That's the only thing I could make out. :tongue:

Joe123
01-16-2008, 09:04 PM
*sigh*

Don't go and change all the 'Waitframes();' to 'Waitframe();', that won't do you any good.

How many scripts are you using?

It it's more than one, make sure they're all in the same .z file.
Also, it'd probably be a good idea for you to put

import "std.zh" on the first line of the file ;)

The things that aren't compiling were declared within std.zh, and you haven't told ZScript to load it, therefore it doesn't know what they are.

What I don't understand is why they're not just loaded by default.

Beta Link
01-16-2008, 09:43 PM
ah, so that's the problem. Thanks!


Don't go and change all the 'Waitframes();' to 'Waitframe();', that won't do you any good.
Yeah, I thought so.

Edit: Ugh, what now? The script compiled fine, but it's not working! At all! Someone must really not want me to use scripts in my quest. :tongue:

The_Amaster
01-16-2008, 10:00 PM
Okay, this just prompted me to make an all-new favorites folder for organizing scripts I intend to use, because there are just too many awesome ones out there.

Way to go Joe!

Joe123
01-17-2008, 03:32 AM
Did you:
Make all out your pit combos walkable, Centre State combos?
Make sure that the FFC that it's applied to has a non-zero combo

Beta Link
01-17-2008, 05:51 PM
Ok, well I had already made the pit combos walkable center statues. And they have to be applied to the FFC? I could have sworn I did that already, but I'll try again just in case. I saw a thread in the bug forum about FFCs not working in builds 704-718, so maybe that's the issue... Can't be sure yet though.

Edit: Nope, didn't work. It must be a bug.

Joe123
01-17-2008, 06:07 PM
What?

No, don't make the combos into the ffc's combo...

Right:
1) Compile the script
2) Set the script to a slot
3) Go to 'ffc 1' for the room you want the pits in
4) Set that script to the ffc, and set it's combo to a transparent combo that is not combo 0
5) Make all your pit combos into walkable centre statue combos
6) Place them on the screen
7) Open in Zelda Classic and play.

Beta Link
01-18-2008, 07:48 PM
Ok, well that helps. I'll try that. :)

Edit: Finally! I didn't know what I was doing wrong before, but it's definately working now! Thankyou so much, I know I've been a pain.

The_Amaster
01-19-2008, 05:13 PM
Okay, slight problem. I set it up right? Assign script to FFC, set arguments, draw combos, etc. Then I go to test it. Run ZC, and nothing happens when I step on the combos. So I open up ZQ and lo and behold, the FFC has reset itself to blank. Any ideas? I have other FFC's running on the same screen, so it's something specific.

Russ
01-19-2008, 06:25 PM
Okay, slight problem. I set it up right? Assign script to FFC, set arguments, draw combos, etc. Then I go to test it. Run ZC, and nothing happens when I step on the combos. So I open up ZQ and lo and behold, the FFC has reset itself to blank. Any ideas? I have other FFC's running on the same screen, so it's something specific.
You have to set the freeform combo to a combo that is not combo number zero. I you don't set a combo for the FFC, it will reset.

The_Amaster
01-19-2008, 06:46 PM
Hmmmm....I thought I did, but I'll check.

Joe123
01-19-2008, 08:28 PM
Edit: Finally! I didn't know what I was doing wrong before, but it's definately working now! Thankyou so much, I know I've been a pain.

That's alright, don't worry about being a pain, I appear to have to have limitless amounts of time to devote to helping around here :shrug:


And if that's what happened, Amaster, I'd be willing to put quite a lot of money on that you haven't assinged the ffc to a non-zero combo.

The_Amaster
01-20-2008, 11:05 PM
Nope. Definitely a non-zero transparent combo. I'm stumped.

Pineconn
01-21-2008, 03:04 AM
I guess I encountered some odd bug with this script in The Fort Knights. Somehow I died while Link disappeared after I fell down a pit but before Link reappeared on the surface. The result? When Link resurfaced, he was invisible. The only way to remedy this was to fall down the pit again.


Do I not need to work about the invisible LTM then?

I hope this isn't what I was talking about, and therefore I would look like an idiot... ;)

Joe123
01-21-2008, 03:57 AM
Nope. Definitely a non-zero transparent combo. I'm stumped.

Well, I made a few minor changes to the script between last using it and posting it up, so I'll go and check it again but I don't think I could've broken it.



I guess I encountered some odd bug with this script in The Fort Knights. Somehow I died while Link disappeared after I fell down a pit but before Link reappeared on the surface. The result? When Link resurfaced, he was invisible. The only way to remedy this was to fall down the pit again.

Oh yeah, I've fixed that one.



Do I not need to work about the invisible LTM then?
I hope this isn't what I was talking about, and therefore I would look like an idiot...

Funny, I meant to put 'worry' there, not 'work'.

Anyway, at the moment the script requires making Link invisible via LTM, but _L_ was suggesting another method.

He didn't reply though, so at the moment, LTM still.

The_Amaster
01-21-2008, 02:47 PM
Well, step by step heres what I do:

1.)Open Scripts.z
2.)Set the 5 variables at the top of the script.
3.)Save and Quit
4.)Open up ZC and my quest.
5.)Go to "Import ZScript"
6.) Import and Compile
7.) Assign to slot 4.
8.)Go to FFC 5.
9.)Set the combo ot a non-zero blank.
10.) Assign it script 4
11.) Set the arguments.(For the record, the only one I set is the combo number)
12.)Save and quit
13.) Open ZC and my quest.
14.) Walk on the combos. Nothing happens.
15.) Open ZC. The FFC is blank. WTH?

If it matters, my pit combo is entirely blank property wise.

Joe123
01-21-2008, 03:18 PM
You set the combo number?
And what number are you setting there?

The Combo ID number of a combo that looks like a pit?

Don't be doing that.

What you want to do is make all of your pits have the combo type number (so, 35 for centre statue) that is set in that box.
Centre Statue is default.

So don't make your pit combos blank propertywise, and don't set an absurdly high value in that box, because it ain't a combo ID.

That doesn't solve the dissapearing FFC problem though.
Hrm.

The_Amaster
01-21-2008, 05:02 PM
Ohhhhhhhhh...
I get it now. That makes sense. I had the two confused. Off to test.

EDIT: She works! As for the reseting, well I had to similar test screens set up, and on only one had I set it to a non-zero. There's the problem.

Joe123
05-18-2008, 04:41 AM
And now Mark 2:

const int linkfalling = 0; // set here the first tile of your 5 tile Link Falling animation
const int linklava = 0; // set here the first tile of your 5 tile Link Drowning animation
const int fallingsfx = 0; // set here the SFX that plays when Link falls
const int lavasfx = 0; // set here the SFX that plays when Link drowns in lava

ffc script hole{
void run(int lava, int warpx, int warpy, int combotype, int tile){
int sfx = fallingsfx;
if(warpx == 0 && warpy == 0){Waitframes(5); warpx = Link->X; warpy = Link->Y;}
if(tile == 0){tile = linkfalling;}
if(combotype == 0){combotype = 35;}
if(lava != 0){if(tile == linkfalling){tile = linklava;}sfx = lavasfx;}
int i; int x; int y; bool falling;

while(true){
falling = false;
while(Screen->ComboT[ComboAt(Link->X+8, Link->Y+8)] != combotype || Link->Z > 0 || Link->Action == LA_FROZEN) Waitframe();

i = 0;
while(Screen->ComboT[ComboAt(Link->X+8, Link->Y+8)] == combotype && Link->Z == 0 && Link->Action != LA_FROZEN && i < 5){
i++;
if(i==5) falling = true;
Waitframe();
}

if(falling){
Screen->ClearSprites(3);
Game->PlaySound(sfx);
x = Link->X; y = Link->Y;
for(i=0;i<40;i++){
Waitframe();
Link->Action = LA_DROWNING;
if(lava == 0) Screen->DrawTile(2, x, y, tile+Floor(i/8), 1, 1, 6, 1, 0, 0, 0, 0, true, 128);
else Screen->DrawTile(2, x, y, tile+Floor(i/8), 1, 1, 6, 1, 0, 0, 0, 0, true, 128);
}
Link->X = warpx; Link->Y = warpy;
Link->Action = 0;
Link->HP -= 8;
Game->PlaySound(19);
}
}
}
}

No need for silly Link Tile Modifiers anymore!
All other set up is the same though.

KCJV
12-27-2015, 06:31 PM
I got the error "Line 204, error T21: Couldn't match type signature Drawtile(Screen, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Bool, Float)

Gleeok
12-27-2015, 07:34 PM
The script is old so there's an updated script at pzc I believe.

Otherwise DrawTile needs a corresponding y_scale argument:


Screen->DrawTile(2, x, y, tile+Floor(i/8), 1, 1, 6, 1, 1 // <------here
, 0, 0, 0, 0, true, 128);

KCJV
12-28-2015, 07:31 AM
I did this, it now works fine :D thanks

ZoriaRPG
12-28-2015, 11:10 AM
Oh my, we're using 2.11-era code files?...

Actually, I think this was one of the things I had to fix in the Starshooter script to get Starshooter to work, and not crash, on a release build of 2.5. I know it was some series of drawing functions that had been revised, with more args in newer ZC versions.
Tamamo maintains the update of the holes script though, so it might be good to post the latest version here.