[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. */
|
/* Accelerating. */
|
||||||
if(KEY("accel")) {
|
if(KEY("accel")) {
|
||||||
if(kabs) {
|
if(kabs) {
|
||||||
player_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_accel(value);
|
player_accel(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Prevent it from getting stuck. */
|
/* Prevent it from getting stuck. */
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_accel(1.);
|
player_accel(1.);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) player_accelOver();
|
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")) {
|
else if(KEY("left")) {
|
||||||
/* Set flags for facing correction. */
|
/* Set flags for facing correction. */
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_setFlag(PLAYER_TURN_LEFT);
|
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); }
|
||||||
@ -251,7 +251,7 @@ 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_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_setFlag(PLAYER_TURN_RIGHT);
|
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); }
|
||||||
@ -264,7 +264,7 @@ 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_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_setFlag(PLAYER_REVERSE);
|
player_setFlag(PLAYER_REVERSE);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) {
|
else if(value == KEY_RELEASE) {
|
||||||
@ -277,7 +277,7 @@ 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_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_setFlag(PLAYER_PRIMARY);
|
player_setFlag(PLAYER_PRIMARY);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) { player_rmFlag(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. */
|
/* Face the target. */
|
||||||
else if(KEY("face")) {
|
else if(KEY("face")) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_setFlag(PLAYER_FACE);
|
player_setFlag(PLAYER_FACE);
|
||||||
}
|
}
|
||||||
else if(value == KEY_RELEASE) {
|
else if(value == KEY_RELEASE) {
|
||||||
@ -313,7 +313,7 @@ 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_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_board();
|
player_board();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,13 +350,13 @@ 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_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_land();
|
player_land();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(KEY("thyperspace") && NOHYP() && NOLAND() && NODEAD()) {
|
else if(KEY("thyperspace") && NOHYP() && NOLAND() && NODEAD()) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_targetHyperspace();
|
player_targetHyperspace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,7 +365,7 @@ 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_abortAutonav();
|
player_abortAutonav(NULL);
|
||||||
player_jump();
|
player_jump();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ static int pilot_mstack = 0; /** Memory allocated for pilot_stack. */
|
|||||||
|
|
||||||
extern Pilot* player;
|
extern Pilot* player;
|
||||||
extern double player_crating; /**< Players combat rating. */
|
extern double player_crating; /**< Players combat rating. */
|
||||||
extern void player_abortAutonav(void);
|
extern void player_abortAutonav(char* reason);
|
||||||
|
|
||||||
/* Stack of fleets. */
|
/* Stack of fleets. */
|
||||||
static Fleet* fleet_stack = NULL; /** Fleet stack. */
|
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);
|
outfit_calcDamage(&damage_shield, &damage_armour, &knockback, dtype, damage);
|
||||||
|
|
||||||
if(p->id == PLAYER_ID)
|
if(p->id == PLAYER_ID)
|
||||||
player_abortAutonav();
|
player_abortAutonav("Sustaining Damage");
|
||||||
|
|
||||||
if(p->shield - damage_shield > 0.) { /* Shields take the whole blow. */
|
if(p->shield - damage_shield > 0.) { /* Shields take the whole blow. */
|
||||||
p->shield -= damage_shield;
|
p->shield -= damage_shield;
|
||||||
|
13
src/player.c
13
src/player.c
@ -1535,12 +1535,17 @@ void player_startAutonav(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn void player_abortAutonav(void)
|
|
||||||
*
|
|
||||||
* @brief Aborts autonav
|
* @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)) {
|
if(player_isFlag(PLAYER_AUTONAV)) {
|
||||||
|
if(reason != NULL)
|
||||||
|
player_message("Autonav aborting: %s!", reason);
|
||||||
|
else
|
||||||
player_message("Autonav aborted!");
|
player_message("Autonav aborted!");
|
||||||
player_rmFlag(PLAYER_AUTONAV);
|
player_rmFlag(PLAYER_AUTONAV);
|
||||||
|
|
||||||
@ -1573,7 +1578,7 @@ void player_think(Pilot* pplayer) {
|
|||||||
/* Autonav takes over normal controls. */
|
/* Autonav takes over normal controls. */
|
||||||
if(player_isFlag(PLAYER_AUTONAV)) {
|
if(player_isFlag(PLAYER_AUTONAV)) {
|
||||||
if(pplayer->lockons > 0)
|
if(pplayer->lockons > 0)
|
||||||
player_abortAutonav();
|
player_abortAutonav("Missile Lockon Detected");
|
||||||
|
|
||||||
if(space_canHyperspace(pplayer)) {
|
if(space_canHyperspace(pplayer)) {
|
||||||
player_jump();
|
player_jump();
|
||||||
|
@ -88,6 +88,6 @@ void player_afterburnOver(void);
|
|||||||
void player_accel(double acc);
|
void player_accel(double acc);
|
||||||
void player_accelOver(void);
|
void player_accelOver(void);
|
||||||
void player_startAutonav(void);
|
void player_startAutonav(void);
|
||||||
void player_abortAutonav(void);
|
void player_abortAutonav(char* reason);
|
||||||
void player_hail(void);
|
void player_hail(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user