[Add] Provide reasons for aborting autonavigation.
This commit is contained in:
parent
9278a1851b
commit
8749453098
22
src/input.c
22
src/input.c
@ -208,13 +208,13 @@ static void input_key(int keynum, double value, int kabs) {
|
||||
/* Accelerating. */
|
||||
if(KEY("accel")) {
|
||||
if(kabs) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_accel(value);
|
||||
}
|
||||
else {
|
||||
/* Prevent it from getting stuck. */
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_accel(1.);
|
||||
}
|
||||
else if(value == KEY_RELEASE) player_accelOver();
|
||||
@ -238,7 +238,7 @@ static void input_key(int keynum, double value, int kabs) {
|
||||
else if(KEY("left")) {
|
||||
/* Set flags for facing correction. */
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_setFlag(PLAYER_TURN_LEFT);
|
||||
}
|
||||
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_TURN_LEFT); }
|
||||
@ -251,7 +251,7 @@ static void input_key(int keynum, double value, int kabs) {
|
||||
else if(KEY("right")) {
|
||||
/* Set flags for facing correction. */
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_setFlag(PLAYER_TURN_RIGHT);
|
||||
}
|
||||
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_TURN_RIGHT); }
|
||||
@ -264,7 +264,7 @@ static void input_key(int keynum, double value, int kabs) {
|
||||
/* Turn around to face vel. */
|
||||
else if(KEY("reverse")) {
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_setFlag(PLAYER_REVERSE);
|
||||
}
|
||||
else if(value == KEY_RELEASE) {
|
||||
@ -277,7 +277,7 @@ static void input_key(int keynum, double value, int kabs) {
|
||||
/* Shoot primary weapon. BOOM BOOM. */
|
||||
else if(KEY("primary")) {
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_setFlag(PLAYER_PRIMARY);
|
||||
}
|
||||
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_PRIMARY); }
|
||||
@ -298,7 +298,7 @@ static void input_key(int keynum, double value, int kabs) {
|
||||
/* Face the target. */
|
||||
else if(KEY("face")) {
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_setFlag(PLAYER_FACE);
|
||||
}
|
||||
else if(value == KEY_RELEASE) {
|
||||
@ -313,7 +313,7 @@ static void input_key(int keynum, double value, int kabs) {
|
||||
/* Board those ships. */
|
||||
else if(KEY("board") && INGAME() && NOHYP()) {
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_board();
|
||||
}
|
||||
}
|
||||
@ -350,13 +350,13 @@ static void input_key(int keynum, double value, int kabs) {
|
||||
/* Target nearest planet or attempt to land. */
|
||||
else if(KEY("land") && INGAME() && NOHYP()) {
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_land();
|
||||
}
|
||||
}
|
||||
else if(KEY("thyperspace") && NOHYP() && NOLAND() && NODEAD()) {
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_targetHyperspace();
|
||||
}
|
||||
}
|
||||
@ -365,7 +365,7 @@ static void input_key(int keynum, double value, int kabs) {
|
||||
}
|
||||
else if(KEY("jump") && INGAME()) {
|
||||
if(value == KEY_PRESS) {
|
||||
player_abortAutonav();
|
||||
player_abortAutonav(NULL);
|
||||
player_jump();
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ static int pilot_mstack = 0; /** Memory allocated for pilot_stack. */
|
||||
|
||||
extern Pilot* player;
|
||||
extern double player_crating; /**< Players combat rating. */
|
||||
extern void player_abortAutonav(void);
|
||||
extern void player_abortAutonav(char* reason);
|
||||
|
||||
/* Stack of fleets. */
|
||||
static Fleet* fleet_stack = NULL; /** Fleet stack. */
|
||||
@ -428,7 +428,7 @@ void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter,
|
||||
outfit_calcDamage(&damage_shield, &damage_armour, &knockback, dtype, damage);
|
||||
|
||||
if(p->id == PLAYER_ID)
|
||||
player_abortAutonav();
|
||||
player_abortAutonav("Sustaining Damage");
|
||||
|
||||
if(p->shield - damage_shield > 0.) { /* Shields take the whole blow. */
|
||||
p->shield -= damage_shield;
|
||||
|
15
src/player.c
15
src/player.c
@ -1535,13 +1535,18 @@ void player_startAutonav(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void player_abortAutonav(void)
|
||||
*
|
||||
* @brief Aborts autonav
|
||||
*/
|
||||
void player_abortAutonav(void) {
|
||||
void player_abortAutonav(char* reason) {
|
||||
/* No point if player is beyond aborting. */
|
||||
if(pilot_isFlag(player, PILOT_HYPERSPACE))
|
||||
return;
|
||||
|
||||
if(player_isFlag(PLAYER_AUTONAV)) {
|
||||
player_message("Autonav aborted!");
|
||||
if(reason != NULL)
|
||||
player_message("Autonav aborting: %s!", reason);
|
||||
else
|
||||
player_message("Autonav aborted!");
|
||||
player_rmFlag(PLAYER_AUTONAV);
|
||||
|
||||
/* Get rid of acceleration. */
|
||||
@ -1573,7 +1578,7 @@ void player_think(Pilot* pplayer) {
|
||||
/* Autonav takes over normal controls. */
|
||||
if(player_isFlag(PLAYER_AUTONAV)) {
|
||||
if(pplayer->lockons > 0)
|
||||
player_abortAutonav();
|
||||
player_abortAutonav("Missile Lockon Detected");
|
||||
|
||||
if(space_canHyperspace(pplayer)) {
|
||||
player_jump();
|
||||
|
@ -88,6 +88,6 @@ void player_afterburnOver(void);
|
||||
void player_accel(double acc);
|
||||
void player_accelOver(void);
|
||||
void player_startAutonav(void);
|
||||
void player_abortAutonav(void);
|
||||
void player_abortAutonav(char* reason);
|
||||
void player_hail(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user