PDA

View Full Version : Sideview "ladderscript" bug



TwilightKnight
09-01-2008, 06:51 AM
So, I got a ladderscript for my quest which makes an functional ladder in sideview gravity. Now this works very fine, but Link's animation is screwed up when he goes over the ladder.

Here is the script:

import "std.zh"

//Courtesy of Saffith, beefster09, and pkmnfrk
bool isSolid(int x, int y) {

if(x<0 || x>255 || y<0 || y>175) return false;
int mask=1111b;

if(x % 16 < 8)
mask &= 0011b;
else
mask &= 1100b;

if(y % 16 < 8)
mask &= 0101b;
else
mask &= 1010b;

int ret = Screen->ComboS[ComboAt(x, y)] & mask;
return (ret!=0);

}

ffc script ladder {
void run(int f) {
if(f == 0) f = 98;

while(true) {
if(Screen->ComboF[ComboAt(Link->X+8, Link->Y)] == f) {
if(Link->Jump < 0) Link->Jump = 0;

if(Link->InputDown) {
if(!isSolid(Link->X, Link->Y + 1)) Link->Y += 1;
}
if(Link->InputUp) {
if(!isSolid(Link->X, Link->Y - 1)) Link->Y -= 1;
}
}
Waitframe();
}
}
}

Here is a simple test demo, to confirm the bug:
Quest File (http://www.freewebs.com/bbflashsite/ladder.qst)(Ignore the enemies, as they will be for another bug I'll post here too)

Bug is found in Build 846.

Edit: Someone also checked for me if the script doesn't change animation, it doesn't so that's why this belongs here.

Gleeok
09-01-2008, 05:17 PM
These would be the only lines that would change links behavior.

It's not changing the animation, only changing his coordinates.




if(Screen->ComboF[ComboAt(Link->X+8, Link->Y)] == f) {
if(Link->Jump < 0) Link->Jump = 0;

if(Link->InputDown) {
if(!isSolid(Link->X, Link->Y + 1)) Link->Y += 1;

pkmnfrk
09-01-2008, 05:50 PM
1. This is my script, but
2. I don't know how to fix the animation problem.

I know what's causing it (Game says "Link's not standing on a solid combo, he should fall!", and I'm saying "Link isn't falling, he's just standing there")

What we need is a built in ladder combo. Or, failing that, a way to change gravity via scripting.

Gleeok
09-01-2008, 07:31 PM
What about:
1; using a waitdraw(); or,
2; "locking in" Links x,y every frame with said waitdraw()
as a workaround? ..making sure that the screen doesn't re-render him a pixel off from where you want him to be.

Joe123
09-01-2008, 08:35 PM
Just to clarify to TwilightKnight, this is how the script works, it's not a bug with ZC itself.

Beta Link
09-01-2008, 09:20 PM
You know, to fix this 'bug', I just use Joe123s 'climbing' script (http://www.armageddongames.net/forums/showthread.php?t=99828) along with it. I find it works very well. ;)

_L_
09-02-2008, 12:11 AM
Here is what the problem is!

if(Link->Jump < 0) Link->Jump = 0;You might think this is sufficient to stabilise Link in midair. Not quite! In fact, every frame that Link spends off the ground, the Gravity constant in Init Data is subtracted from his Jump. This is how gravity works!

So, to negate this effect during every frame, you must do this!



const int GRAVITY = 0.16; // Must equal your Gravity constant in Init Data.
...
if(Link->Jump <= 0) Link->Jump = GRAVITY;

That being said, I could conceivably add a fix that stops Link's gravity during the single frame after a script sets Link->Jump, if you fellows think it makes the most sense. But this might throw off a few people who have already written scripts that use the current behaviour.

pkmnfrk
09-02-2008, 11:46 AM
Or, like, let us change gravity, which would have more use overall.

_L_
09-03-2008, 01:01 AM
How would changing Gravity be useful? If you set it to 0, then the enemies, items and weapons wouldn't fall down either.

pkmnfrk
09-05-2008, 02:57 PM
Well, it's entirely possible that I didn't think of that.

Be that as it may, changing gravity would be useful in circumstances other than this. Like, LINK IN SPACE! Or something.

Nicholas Steel
09-05-2008, 10:20 PM
reversing gravity and stuff would also be possible then, too :)