[Add] Added keybindings for targetting escorts.
This commit is contained in:
parent
ab741a257f
commit
d366fec5b8
12
src/input.c
12
src/input.c
@ -47,7 +47,7 @@ const char* keybindNames[] = {
|
|||||||
/* Secondary weapons. */
|
/* Secondary weapons. */
|
||||||
"secondary", "secondary_next", "secondary_prev",
|
"secondary", "secondary_next", "secondary_prev",
|
||||||
/* Escorts. */
|
/* Escorts. */
|
||||||
"e_attack", "e_hold", "e_return", "e_clear",
|
"e_targetNext", "e_targetPrev", "e_attack", "e_hold", "e_return", "e_clear",
|
||||||
/* Space Navigation. */
|
/* Space Navigation. */
|
||||||
"autonav", "target_planet", "land", "thyperspace","starmap", "jump",
|
"autonav", "target_planet", "land", "thyperspace","starmap", "jump",
|
||||||
/* Communication. */
|
/* Communication. */
|
||||||
@ -81,6 +81,8 @@ const char* keybindDescription[] = {
|
|||||||
"Cycles through secondary weapons.",
|
"Cycles through secondary weapons.",
|
||||||
"Cycles backwards through secondary weapons.",
|
"Cycles backwards through secondary weapons.",
|
||||||
/* Escorts. */
|
/* Escorts. */
|
||||||
|
"Cycles through your esorts.",
|
||||||
|
"Cycles backwards through your escorts.",
|
||||||
"Tells your escorts to attack your target.",
|
"Tells your escorts to attack your target.",
|
||||||
"Tells your escorts to hold their posistion.",
|
"Tells your escorts to hold their posistion.",
|
||||||
"Tells your escorts to return to your ships hanger.",
|
"Tells your escorts to return to your ships hanger.",
|
||||||
@ -143,6 +145,8 @@ void input_setDefault(void) {
|
|||||||
input_setKeybind("face", KEYBIND_KEYBOARD, SDLK_f, KMOD_NONE);
|
input_setKeybind("face", KEYBIND_KEYBOARD, SDLK_f, KMOD_NONE);
|
||||||
input_setKeybind("board", KEYBIND_KEYBOARD, SDLK_b, KMOD_NONE);
|
input_setKeybind("board", KEYBIND_KEYBOARD, SDLK_b, KMOD_NONE);
|
||||||
/* Escorts. */
|
/* Escorts. */
|
||||||
|
input_setKeybind("e_targetNext", KEYBIND_KEYBOARD, SDLK_g, KMOD_NONE); /* Tmp keybind. */
|
||||||
|
input_setKeybind("e_targetPrev", KEYBIND_KEYBOARD, SDLK_g, KMOD_LCTRL); /* Tmp keybind. */
|
||||||
input_setKeybind("e_attack", KEYBIND_KEYBOARD, SDLK_1, KMOD_NONE);
|
input_setKeybind("e_attack", KEYBIND_KEYBOARD, SDLK_1, KMOD_NONE);
|
||||||
input_setKeybind("e_hold", KEYBIND_KEYBOARD, SDLK_2, KMOD_NONE);
|
input_setKeybind("e_hold", KEYBIND_KEYBOARD, SDLK_2, KMOD_NONE);
|
||||||
input_setKeybind("e_return", KEYBIND_KEYBOARD, SDLK_3, KMOD_NONE);
|
input_setKeybind("e_return", KEYBIND_KEYBOARD, SDLK_3, KMOD_NONE);
|
||||||
@ -486,6 +490,12 @@ static void input_key(int keynum, double value, double kabs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Escorts. */
|
/* Escorts. */
|
||||||
|
else if(INGAME() && NODEAD() && KEY("e_targetNext")) {
|
||||||
|
if(value == KEY_PRESS) player_targetEscort(0);
|
||||||
|
}
|
||||||
|
else if(INGAME() && NODEAD() && KEY("e_targetPrev")) {
|
||||||
|
if(value == KEY_PRESS) player_targetEscort(1);
|
||||||
|
}
|
||||||
else if(INGAME() && NODEAD() && KEY("e_attack")) {
|
else if(INGAME() && NODEAD() && KEY("e_attack")) {
|
||||||
if(value == KEY_PRESS) escorts_attack(player);
|
if(value == KEY_PRESS) escorts_attack(player);
|
||||||
}
|
}
|
||||||
|
19
src/pilot.c
19
src/pilot.c
@ -689,6 +689,25 @@ int pilot_dock(Pilot* p, Pilot* target) {
|
|||||||
if(vect_dist(&p->solid->vel, &target->solid->vel) > 2*MIN_VEL_ERR)
|
if(vect_dist(&p->solid->vel, &target->solid->vel) > 2*MIN_VEL_ERR)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
/* Remove from pilots escort list. */
|
||||||
|
for(i = 0; i < target->nescorts; i++) {
|
||||||
|
if(target->escorts[i] == p->id)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Not found as pilots escorts. */
|
||||||
|
if(i >= target->nescorts)
|
||||||
|
return -1;
|
||||||
|
/* Free if last pilot. */
|
||||||
|
if(target->nescorts == 1) {
|
||||||
|
free(target->escorts);
|
||||||
|
target->escorts = NULL;
|
||||||
|
target->nescorts = 0;
|
||||||
|
} else {
|
||||||
|
memmove(&target->escorts[i], &target->escorts[i+1],
|
||||||
|
sizeof(unsigned int) * p->nescorts-i-1);
|
||||||
|
target->nescorts--;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check to see if target has an available bay. */
|
/* Check to see if target has an available bay. */
|
||||||
for(i = 0; i < target->noutfits; i++) {
|
for(i = 0; i < target->noutfits; i++) {
|
||||||
if(outfit_isFighterBay(target->outfits[i].outfit)) {
|
if(outfit_isFighterBay(target->outfits[i].outfit)) {
|
||||||
|
38
src/player.c
38
src/player.c
@ -1238,6 +1238,44 @@ void player_targetPrev(void) {
|
|||||||
player_playSound(snd_target, 1);
|
player_playSound(snd_target, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Target the pilot.
|
||||||
|
* @param prev 1 if is cycling backwords.
|
||||||
|
*/
|
||||||
|
void player_targetEscort(int prev) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Check if current target is an escort. */
|
||||||
|
for(i = 0; i < player->nescorts; i++) {
|
||||||
|
if(player->target == player->escorts[i]) {
|
||||||
|
/* Cycle targets. */
|
||||||
|
if(prev)
|
||||||
|
player->target = (i > 0) ?
|
||||||
|
player->escorts[i-1] : PLAYER_ID;
|
||||||
|
else
|
||||||
|
player->target = (i < player->nescorts-1) ?
|
||||||
|
player->escorts[i+1] : PLAYER_ID;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Not found in loop. */
|
||||||
|
if(i > player->nescorts) {
|
||||||
|
/* check see if she actually has escorts. */
|
||||||
|
if(player->nescorts > 0) {
|
||||||
|
/* Cycle forward or backwords. */
|
||||||
|
if(prev)
|
||||||
|
player->target = player->escorts[player->nescorts-1];
|
||||||
|
else
|
||||||
|
player->target = player->escorts[0];
|
||||||
|
} else
|
||||||
|
player->target = PLAYER_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player->target != PLAYER_ID)
|
||||||
|
player_playSound(snd_target, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Player targets nearest pilot.
|
* @brief Player targets nearest pilot.
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +85,7 @@ void player_targetHostile(void);
|
|||||||
void player_targetNext(void);
|
void player_targetNext(void);
|
||||||
void player_targetPrev(void);
|
void player_targetPrev(void);
|
||||||
void player_targetNearest(void);
|
void player_targetNearest(void);
|
||||||
|
void player_targetEscort(int prev);
|
||||||
void player_secondaryNext(void);
|
void player_secondaryNext(void);
|
||||||
void player_secondaryPrev(void);
|
void player_secondaryPrev(void);
|
||||||
void player_targetPlanet(void);
|
void player_targetPlanet(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user