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

Sidescroll Ladder Script

61 replies · 10,990 views · Started 13 December 2007

You'd do it this way:


global script Slot_2{
void run(){
while(true){
//call the ladder function
ladder(98);
Waitframe();
}
}
}

global variablies and constants goes on top of the global script file, each variable ending in a semi-colon.

you can also change the variable 98 to any other flag number of your choice. you can only use flags 98 - 102 for now though.

Doing the work for you:

import "std.zh"

//global variables go here
bool has_hover = false;
bool on_ladder = false;

global script onstart {
void run() {

//one time things go here

while(true) {

//function calls go here
ladder(98);

Waitframe();
}
}

//functions go here
//Courtesy of Saffith/beefster09
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);

}

void ladder(int f) {
int lc;

lc = ComboAt(Link->X+8, Link->Y+15); //for speed

if(Screen->ComboF[lc] == f || Screen->ComboI[lc] == f) {
if(!on_ladder) {
on_ladder = true;
has_hover = Link->Item[I_HOVERBOOTS];
Link->Item[I_HOVERBOOTS] = false;
}
Link->Jump = 0;
Link->Z = 0;
Link->Dir = DIR_UP;

if(Link->InputDown) {
Link->InputDown = false;
Link->Action = LA_WALKING;
if(!isSolid(Link->X, Link->Y + 16)) Link->Y += 1;
}
if(Link->InputUp) {
Link->InputUp = false;
Link->Action = LA_WALKING;
if(!isSolid(Link->X, Link->Y - 1)) Link->Y -= 1;
}
if(Link->InputLeft) {
Link->InputLeft = false;
Link->Action = LA_WALKING;
if(!isSolid(Link->X - 1 , Link->Y)) Link->X -= 1;
}
if(Link->InputRight) {
Link->InputRight = false;
Link->Action = LA_WALKING;
if(!isSolid(Link->X + 16, Link->Y)) Link->X += 1;
}
} else {
if(on_ladder) {
Link->Item[I_HOVERBOOTS] = has_hover;
on_ladder = false;
}
}
}

}