[Change] Polished autonav system a bit more.
This commit is contained in:
parent
75e438a98f
commit
97944d44b3
22
src/input.c
22
src/input.c
@ -199,8 +199,8 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
else {
|
else {
|
||||||
/* Prevent it from getting stuck. */
|
/* Prevent it from getting stuck. */
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_accel(1.);
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_accel(1.);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) player_accelOver();
|
else if(value == KEY_RELEASE) player_accelOver();
|
||||||
}
|
}
|
||||||
@ -223,8 +223,8 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
else if(KEY("left")) {
|
else if(KEY("left")) {
|
||||||
/* Set flags for facing correction. */
|
/* Set flags for facing correction. */
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_setFlag(PLAYER_TURN_LEFT);
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_setFlag(PLAYER_TURN_LEFT);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_TURN_LEFT); }
|
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_TURN_LEFT); }
|
||||||
|
|
||||||
@ -236,8 +236,8 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
else if(KEY("right")) {
|
else if(KEY("right")) {
|
||||||
/* Set flags for facing correction. */
|
/* Set flags for facing correction. */
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_setFlag(PLAYER_TURN_RIGHT);
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_setFlag(PLAYER_TURN_RIGHT);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_TURN_RIGHT); }
|
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_TURN_RIGHT); }
|
||||||
|
|
||||||
@ -249,8 +249,8 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
/* Turn around to face vel. */
|
/* Turn around to face vel. */
|
||||||
else if(KEY("reverse")) {
|
else if(KEY("reverse")) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_setFlag(PLAYER_REVERSE);
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_setFlag(PLAYER_REVERSE);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) {
|
else if(value == KEY_RELEASE) {
|
||||||
player_rmFlag(PLAYER_REVERSE);
|
player_rmFlag(PLAYER_REVERSE);
|
||||||
@ -262,8 +262,8 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
/* Shoot primary weapon. BOOM BOOM. */
|
/* Shoot primary weapon. BOOM BOOM. */
|
||||||
else if(KEY("primary")) {
|
else if(KEY("primary")) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_setFlag(PLAYER_PRIMARY);
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_setFlag(PLAYER_PRIMARY);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_PRIMARY); }
|
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_PRIMARY); }
|
||||||
}
|
}
|
||||||
@ -280,8 +280,8 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
/* Face the target. */
|
/* Face the target. */
|
||||||
else if(KEY("face")) {
|
else if(KEY("face")) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_setFlag(PLAYER_FACE);
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_setFlag(PLAYER_FACE);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) {
|
else if(value == KEY_RELEASE) {
|
||||||
player_rmFlag(PLAYER_FACE);
|
player_rmFlag(PLAYER_FACE);
|
||||||
@ -295,8 +295,8 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
/* Board those ships. */
|
/* Board those ships. */
|
||||||
else if(KEY("board") && INGAME() && NOHYP()) {
|
else if(KEY("board") && INGAME() && NOHYP()) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_board();
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_board();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Shooting secondary weapon. */
|
/* Shooting secondary weapon. */
|
||||||
@ -319,14 +319,14 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
/* Target nearest planet or attempt to land. */
|
/* Target nearest planet or attempt to land. */
|
||||||
else if(KEY("land") && INGAME() && NOHYP()) {
|
else if(KEY("land") && INGAME() && NOHYP()) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_land();
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_land();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(KEY("thyperspace") && INGAME() && NOHYP()) {
|
else if(KEY("thyperspace") && INGAME() && NOHYP()) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_targetHyperspace();
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_targetHyperspace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(KEY("starmap") && NOHYP()) {
|
else if(KEY("starmap") && NOHYP()) {
|
||||||
@ -334,8 +334,8 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
}
|
}
|
||||||
else if(KEY("jump") && INGAME()) {
|
else if(KEY("jump") && INGAME()) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_jump();
|
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
player_jump();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Zoom in. */
|
/* Zoom in. */
|
||||||
@ -401,7 +401,7 @@ static void input_joyevent(int event, const unsigned int button) {
|
|||||||
static void input_keyevent(int event, SDLKey key, SDLMod mod) {
|
static void input_keyevent(int event, SDLKey key, SDLMod mod) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mod &= (KMOD_CAPS | KMOD_NUM | KMOD_MODE); /* We want to ignore "global" modifiers. */
|
mod &= ~(KMOD_CAPS | KMOD_NUM | KMOD_MODE); /* We want to ignore "global" modifiers. */
|
||||||
|
|
||||||
for(i = 0; strcmp(keybindNames[i], "end"); i++)
|
for(i = 0; strcmp(keybindNames[i], "end"); i++)
|
||||||
if((input_keybinds[i]->type == KEYBIND_KEYBOARD) &&
|
if((input_keybinds[i]->type == KEYBIND_KEYBOARD) &&
|
||||||
|
@ -1495,6 +1495,7 @@ void player_startAutonav(void) {
|
|||||||
void player_abortAutonav(void) {
|
void player_abortAutonav(void) {
|
||||||
if(player_isFlag(PLAYER_AUTONAV)) {
|
if(player_isFlag(PLAYER_AUTONAV)) {
|
||||||
player_message("Autonav aborted!");
|
player_message("Autonav aborted!");
|
||||||
|
player_acc = 0.; /* Might be acceling. */
|
||||||
player_rmFlag(PLAYER_AUTONAV);
|
player_rmFlag(PLAYER_AUTONAV);
|
||||||
if(pilot_isFlag(player, PILOT_HYP_PREP)) {
|
if(pilot_isFlag(player, PILOT_HYP_PREP)) {
|
||||||
pilot_hyperspaceAbort(player);
|
pilot_hyperspaceAbort(player);
|
||||||
@ -1524,9 +1525,10 @@ void player_think(Pilot* pplayer) {
|
|||||||
if(pplayer->lockons > 0)
|
if(pplayer->lockons > 0)
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
|
|
||||||
if(space_canHyperspace(pplayer))
|
if(space_canHyperspace(pplayer)) {
|
||||||
|
player_acc = 0.;
|
||||||
player_jump();
|
player_jump();
|
||||||
else {
|
} else {
|
||||||
pilot_face(pplayer, VANGLE(pplayer->solid->pos));
|
pilot_face(pplayer, VANGLE(pplayer->solid->pos));
|
||||||
player_acc = 1.;
|
player_acc = 1.;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user