PDA

View Full Version : Fixed Direction



eXodus
11-09-2006, 02:44 AM
My brother and I have been working on a script that allows you to force the player to face a certain direction regardless of how they move. The purpose of it is to essentially make Link strafe all the time whether you can turn around or not - handy when fighting something on the other side of the screen like Aquamentus, Gohma, Gleeok, shooting gallery, etc. There are still a few problems with it though:

http://www.filespace.org/coolest_rm_ever/Facing.z


// Facing - a script to hold Link in one direction by eXodus
//
// This script is intended to keep Link facing the same way
// as he moves about the screen. You may choose the direction
// Link starts off in and whether he can turn with L and R.
// The parameters are:
//
// bool canTurn - if true, pressing L or R will turn Link
// int initDir - which direction you enter the screen facing;
// if negative, do not change Link's direction
//

import "std.zh"
// DIR_ constants included for use in b14
const int DIR_UP = 0;
const int DIR_DOWN = 1;
const int DIR_LEFT = 2;
const int DIR_RIGHT = 3;

ffc script Facing {
int currDir;
bool turned = false;

// change Link's direction; right == true to turn clockwise
void turn(bool right) {
if (right) {
// I really wish switch statements worked in ZScript...
if (currDir == DIR_RIGHT) { currDir = DIR_DOWN; }
else { if (currDir == DIR_DOWN) { currDir = DIR_LEFT; }
else { if (currDir == DIR_LEFT) { currDir = DIR_UP; }
else { if (currDir == DIR_UP) { currDir = DIR_RIGHT; }
} } }
} else {
if (currDir == DIR_RIGHT) { currDir = DIR_UP; }
else { if (currDir == DIR_UP) { currDir = DIR_LEFT; }
else { if (currDir == DIR_LEFT) { currDir = DIR_DOWN; }
else { if (currDir == DIR_DOWN) { currDir = DIR_RIGHT; }
} } }
}
turned = true;
Link->Dir = currDir;
}

void run(bool canTurn, int initDir) {
// initialise currDir to initDir or Link's current facing
if (initDir >= 0) { currDir = initDir; } else { currDir = Link->Dir; }

while(true) {
// don't mess with Link's movement while using the raft
// ... or bad things will happen (like getting stuck)
// I still need to find a way to do this whenever Link
// tries to get in or out of the water though...
if (Link->Action == LA_RAFTING) { Waitframe(); continue; }
Link->Dir = currDir;

// hardcoded means to stop Link turning while attacking;
// (while I love that little trick, it ruins the effect)
// note that this also prevents the Boomerang's aiming
if (Link->Action == LA_ATTACKING) {
Link->InputUp = false;
Link->InputDown = false;
Link->InputLeft = false;
Link->InputRight = false;
}

// the turning logic; if Link can move and turn, do this;
// turned keeps Link from spinning if you hold down L or R
if (canTurn && (Link->Action == LA_NONE || Link->Action == LA_WALKING || Link->Action == LA_SWIMMING)) {
if (!Link->InputL && !Link->InputR) {
turned = false;
}
if (Link->InputL) {
Link->InputL = false;
if (!turned) turn(false);
}
if (Link->InputR) {
Link->InputR = false;
if (!turned) turn(true);
}
} else {
// don't let Link switch items if he can still turn;
// that condition could always be removed if preffered
if (canTurn) { Link->InputL = false; Link->InputR = false; }
}

Link->Dir = currDir;
Waitframe();
}
}
}


As stated in the comments, there are some fundamental problems with how this script interacts with the Boomerang and Flippers (if anyone knows how to detect if Link is hopping in or out of the water, please respond). Also, I would like to parameterise the ability to choose which ways Link can turn. I've never really worked with bitmasks before, so I'd appreciate any help with that...

The hardest part is that while walking, Link still animates (and pushes, and scrolls, etc.) in the direction you press. That shortcoming does prevent a lot of in-game issues but, above all else, it makes it hard to tell which way you're facing. Any suggestions on how this might be overcome, or if it even should?

C-Dawg
11-10-2006, 11:51 AM
This is a great idea. You can link it up with holding down the sword button to recreate strafeing from LttP, too.

Saffith
11-14-2006, 02:54 PM
It's probably more trouble than it's worth to get Link to face the same direction while walking. You'd have to override the controls completely and handle the walking yourself. That means figuring out when he's trying to walk and whether he's able to do so, changing his state and direction so that he animates properly, and changing his position.