Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Sideview "ladderscript" bug

10 replies · 3,479 views · Started 01 September 2008

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(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.

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;

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.

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.

Just to clarify to TwilightKnight, this is how the script works, it's not a bug with ZC itself.

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.

How would changing Gravity be useful? If you set it to 0, then the enemies, items and weapons wouldn't fall down either.

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.