Pegasus Boots, or rather a Dash script...
Code:
import "std.zh"
// ==========================================
// Dash - This script handles the dash boots.
// ==========================================
ffc script Dash{
int dashforce_maximum; // The maximum force of the player's Dash.
int dashforce_current = 0; // The current force
int i = 0; // This counter slows the rate at which
// dashforce decays, to smooth the dash.
int dash_pause = 0; // This counter prevents the player from
// holding down R for continuous dashing.
void run(){
int savedLinkX;
int savedLinkY;
while(true){
if(Link->Dir==DIR_RIGHT || Link->Dir==DIR_LEFT || Link->Dir==DIR_UP || Link->Dir==DIR_DOWN){
dashforce_maximum = 7;
}
else{
dashforce_maximum = 0;
}
if( (Link->InputR) && (dash_pause == 0) &&
(!canMove(Link->Y+17, Link->X+16)) ||
(!canMove(Link->Y+17, Link->X)) ||
(!canMove(Link->Y+17, Link->X+8)));
{
dashforce_current = dashforce_maximum;
dash_pause = 20;
}
if(Link->Dir==DIR_LEFT){
if(dashforce_current > 0){
if( (!canMove(Link->X+4, Link->Y+7)) ||
(!canMove(Link->X+8, Link->Y-7)) ||
(!canMove(Link->X+16, Link->Y))) {
dashforce_current = 0;
}
else {
Link->X = Link->X - dashforce_current;
savedLinkX = Link->X;
if(i == 2){
i = 0;
}
else{
dashforce_current--;
i++;
}
}
}
}
if(Link->Dir==DIR_UP){
if(dashforce_current > 0){
if( (!canMove(Link->X, Link->Y+7)) ||
(!canMove(Link->X+4, Link->Y+16)) ||
(!canMove(Link->X-4, Link->Y+16)) ||
(!canMove(Link->X+7, Link->Y+16)) ||
(!canMove(Link->X-7, Link->Y+16))) {
dashforce_current = 0;
}
else {
Link->Y = Link->Y - dashforce_current;
savedLinkY = Link->Y;
if(i == 2){
i = 0;
}
else{
dashforce_current--;
i++;
}
}
}
}
if(Link->Dir==DIR_RIGHT){
if(dashforce_current > 0){
if( (!canMove(Link->X+4, Link->Y+7)) ||
(!canMove(Link->X+8, Link->Y-7)) ||
(!canMove(Link->X+12, Link->Y+4)) ||
(!canMove(Link->X+16, Link->Y-4))) {
dashforce_current = 0;
}
else {
Link->X = Link->X + dashforce_current;
savedLinkX = Link->X;
if(i == 2){
i = 0;
}
else{
dashforce_current--;
i++;
}
}
}
}
if(Link->Dir==DIR_DOWN){
if(dashforce_current > 0){
if( (!canMove(Link->X, Link->Y+7)) ||
(!canMove(Link->X+4, Link->Y+16)) ||
(!canMove(Link->X-4, Link->Y+16)) ||
(!canMove(Link->X+7, Link->Y+16)) ||
(!canMove(Link->X-7, Link->Y+16))) {
dashforce_current = 0;
}
else {
Link->Y = Link->Y + dashforce_current;
savedLinkY = Link->Y;
if(i == 2){
i = 0;
}
else{
dashforce_current--;
i++;
}
}
}
}
Link->InputR = false; // This is necessary to stop R from
// flipping your selected item.
// Decrement dash_pause as long as you're on the ground.
dash_pause--;
if (dash_pause < 1) { dash_pause = 0; }
Waitframe();
} // end of while loop
} // end of void run
// ===================================
// Collision detection function
// ===================================
bool canMove(int x, int y){
if(Link->InputR){
// x=23, y=130
// Obviously in range...
if(x<0 || x>255 || y<0 || y>175)
return false;
int mask=1111b;
// x % 16 = 7, so
// mask = 1111 & 0011 = 0011
if(x%16<8)
mask&=0011b;
else
mask&=1100b;
// y % 16 = 2, so
// mask = 0011 & 0101 = 0001
if(y%16<8)
mask&=0101b;
else
mask&=1010b;
// All but the top-right quarter of the combo is solid, so ComboS = 1011
// mask & ComboS = 0001 & 1011 = 0001
// The result wasn't 0, so return false
return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);
}
}// end of canMove
}// end of ffc script
This script will make your player dash across the screen as long as 'R' is held. If they hit a wall, they will move inside of the unwalkable combo slightly (Some !canMove errors I can't repair, shouldn't cause any problems though.) If stuck in a wall, simply move in the opposite direction to get out.
If you put the walls of your rooms over Link's head (With a layer), he could look like he's stuck there on purpose (Smash!). Other than that, enjoy.
I'm sure there are people out there who can improve on this, but I've done all I can for it.
This post has been edited for the purpose of posting the updated script, as well as summarizing what it does.
EDIT2: I've updated the collisions... they should be a bit better than before with wall walking. You may still encounter minor problems, but nothing too serious or permenant.