[Add] Added keybinding to cycle through secondary weapons backwards.
This commit is contained in:
parent
23ec93cad4
commit
5a84266a4f
3
README
3
README
@ -104,7 +104,8 @@ Keys:
|
|||||||
-- 'f' : Faces the target.
|
-- 'f' : Faces the target.
|
||||||
-- 'b' : Board the target.
|
-- 'b' : Board the target.
|
||||||
-- 'LALT' : Fires secondary weapon.
|
-- 'LALT' : Fires secondary weapon.
|
||||||
-- 'e' : Switches to the next secondary weapon.
|
-- 'e' : Cycle through secondary weapons.
|
||||||
|
-- 'LCTRL+e' : Cycle backwards through secondary weapons.
|
||||||
|
|
||||||
Escorts:
|
Escorts:
|
||||||
-- Cycle through secondary weapons until you find fighter bay, then fire
|
-- Cycle through secondary weapons until you find fighter bay, then fire
|
||||||
|
@ -44,7 +44,7 @@ const char* keybindNames[] = {
|
|||||||
/* Fighting. */
|
/* Fighting. */
|
||||||
"primary", "face", "board",
|
"primary", "face", "board",
|
||||||
/* Secondary weapons. */
|
/* Secondary weapons. */
|
||||||
"secondary", "secondary_next",
|
"secondary", "secondary_next", "secondary_prev",
|
||||||
/* Escorts. */
|
/* Escorts. */
|
||||||
"e_attack", "e_hold", "e_return", "e_clear",
|
"e_attack", "e_hold", "e_return", "e_clear",
|
||||||
/* Space Navigation. */
|
/* Space Navigation. */
|
||||||
@ -78,6 +78,7 @@ const char* keybindDescription[] = {
|
|||||||
/* Secondary weapons. */
|
/* Secondary weapons. */
|
||||||
"Fires your secondary weapon.",
|
"Fires your secondary weapon.",
|
||||||
"Cycles through secondary weapons.",
|
"Cycles through secondary weapons.",
|
||||||
|
"Cycles backwards through secondary weapons.",
|
||||||
/* Escorts. */
|
/* 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.",
|
||||||
@ -145,6 +146,7 @@ void input_setDefault(void) {
|
|||||||
/* Secondary weapon. */
|
/* Secondary weapon. */
|
||||||
input_setKeybind("secondary", KEYBIND_KEYBOARD, SDLK_LALT, KMOD_ALL, 0);
|
input_setKeybind("secondary", KEYBIND_KEYBOARD, SDLK_LALT, KMOD_ALL, 0);
|
||||||
input_setKeybind("secondary_next", KEYBIND_KEYBOARD, SDLK_e, KMOD_NONE, 0);
|
input_setKeybind("secondary_next", KEYBIND_KEYBOARD, SDLK_e, KMOD_NONE, 0);
|
||||||
|
input_setKeybind("secondary_prev", KEYBIND_KEYBOARD, SDLK_e, KMOD_LCTRL, 0);
|
||||||
/* Space */
|
/* Space */
|
||||||
input_setKeybind("autonav", KEYBIND_KEYBOARD, SDLK_j, KMOD_LCTRL, 0);
|
input_setKeybind("autonav", KEYBIND_KEYBOARD, SDLK_j, KMOD_LCTRL, 0);
|
||||||
input_setKeybind("target_planet", KEYBIND_KEYBOARD, SDLK_p, KMOD_NONE, 0);
|
input_setKeybind("target_planet", KEYBIND_KEYBOARD, SDLK_p, KMOD_NONE, 0);
|
||||||
@ -449,6 +451,7 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
else if(INGAME() && NODEAD() && KEY("e_clear")) {
|
else if(INGAME() && NODEAD() && KEY("e_clear")) {
|
||||||
if(value == KEY_PRESS) escorts_clear(player);
|
if(value == KEY_PRESS) escorts_clear(player);
|
||||||
}
|
}
|
||||||
|
/* Secondary weapons. */
|
||||||
/* Shooting secondary weapon. */
|
/* Shooting secondary weapon. */
|
||||||
else if(KEY("secondary") && NOHYP()) {
|
else if(KEY("secondary") && NOHYP()) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
@ -462,6 +465,9 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
else if(KEY("secondary_next") && INGAME()) {
|
else if(KEY("secondary_next") && INGAME()) {
|
||||||
if(value == KEY_PRESS) player_secondaryNext();
|
if(value == KEY_PRESS) player_secondaryNext();
|
||||||
}
|
}
|
||||||
|
else if(KEY("secondary_prev") && INGAME()) {
|
||||||
|
if(value == KEY_PRESS) player_secondaryPrev();
|
||||||
|
}
|
||||||
/* Space. */
|
/* Space. */
|
||||||
else if(KEY("autonav") && INGAME() && NOHYP()) {
|
else if(KEY("autonav") && INGAME() && NOHYP()) {
|
||||||
if(value == KEY_PRESS) player_startAutonav();
|
if(value == KEY_PRESS) player_startAutonav();
|
||||||
|
38
src/player.c
38
src/player.c
@ -1911,15 +1911,14 @@ void player_setRadarRel(int mod) {
|
|||||||
* @brief Get the next secondary weapon.
|
* @brief Get the next secondary weapon.
|
||||||
*/
|
*/
|
||||||
void player_secondaryNext(void) {
|
void player_secondaryNext(void) {
|
||||||
int i = 0;
|
int i;
|
||||||
|
|
||||||
/* Get the current secondary weapon pos. */
|
/* Get the current secondary weapon pos. */
|
||||||
if(player->secondary != NULL)
|
if(player->secondary != NULL)
|
||||||
for(i = 0; i < player->noutfits; i++)
|
i = player->secondary - player->outfits + 1;
|
||||||
if(&player->outfits[i] == player->secondary) {
|
else
|
||||||
i++;
|
i = 0;
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Get the next secondary weapon. */
|
/* Get the next secondary weapon. */
|
||||||
for(; i < player->noutfits; i++)
|
for(; i < player->noutfits; i++)
|
||||||
if(outfit_isProp(player->outfits[i].outfit, OUTFIT_PROP_WEAP_SECONDARY)) {
|
if(outfit_isProp(player->outfits[i].outfit, OUTFIT_PROP_WEAP_SECONDARY)) {
|
||||||
@ -1933,6 +1932,33 @@ void player_secondaryNext(void) {
|
|||||||
pilot_setAmmo(player);
|
pilot_setAmmo(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the previous secondary weapon.
|
||||||
|
*/
|
||||||
|
void player_secondaryPrev(void) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Get current secondary weapon pos. */
|
||||||
|
if(player->secondary != NULL)
|
||||||
|
i = player->secondary - player->outfits - 1;
|
||||||
|
else
|
||||||
|
i = player->noutfits - 1;
|
||||||
|
|
||||||
|
/* Get next secondary weapon. */
|
||||||
|
for(; i >= 0; i--)
|
||||||
|
if(outfit_isProp(player->outfits[i].outfit, OUTFIT_PROP_WEAP_SECONDARY)) {
|
||||||
|
pilot_switchSecondary(player, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Found no bigger outfit. */
|
||||||
|
if(i < 0)
|
||||||
|
pilot_switchSecondary(player, -1);
|
||||||
|
|
||||||
|
/* Set ammo. */
|
||||||
|
pilot_setAmmo(player);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Cycle through planet targets.
|
* @brief Cycle through planet targets.
|
||||||
*/
|
*/
|
||||||
|
@ -86,6 +86,7 @@ void player_targetPrev(void);
|
|||||||
void player_targetNearest(void);
|
void player_targetNearest(void);
|
||||||
void player_setRadarRel(int mod);
|
void player_setRadarRel(int mod);
|
||||||
void player_secondaryNext(void);
|
void player_secondaryNext(void);
|
||||||
|
void player_secondaryPrev(void);
|
||||||
void player_targetPlanet(void);
|
void player_targetPlanet(void);
|
||||||
void player_land(void);
|
void player_land(void);
|
||||||
void player_targetHyperspace(void);
|
void player_targetHyperspace(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user