diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hexen/g_game.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c index 5dcfb478..b1d9e6b1 100644 --- a/src/hexen/g_game.c +++ b/src/hexen/g_game.c @@ -144,6 +144,8 @@ static int *weapon_keys[] = &key_weapon4, }; +static int next_weapon = 0; + #define SLOWTURNTICS 6 #define NUMKEYS 256 @@ -457,18 +459,44 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) dclicks = 0; // clear double clicks if hit use button } - for (i=0; i<arrlen(weapon_keys); ++i) + // Weapon cycling. Switch to previous or next weapon. + // (Disabled when player is a pig). + + if (players[consoleplayer].morphTics == 0 && next_weapon != 0) { - int key = *weapon_keys[i]; + if (players[consoleplayer].pendingweapon == WP_NOCHANGE) + { + i = players[consoleplayer].readyweapon; + } + else + { + i = players[consoleplayer].pendingweapon; + } + + do { + i = (i + next_weapon) % NUMWEAPONS; + } while (!players[consoleplayer].weaponowned[i]); - if (gamekeydown[key]) + cmd->buttons |= BT_CHANGE; + cmd->buttons |= i << BT_WEAPONSHIFT; + } + else + { + for (i=0; i<arrlen(weapon_keys); ++i) { - cmd->buttons |= BT_CHANGE; - cmd->buttons |= i<<BT_WEAPONSHIFT; - break; + int key = *weapon_keys[i]; + + if (gamekeydown[key]) + { + cmd->buttons |= BT_CHANGE; + cmd->buttons |= i<<BT_WEAPONSHIFT; + break; + } } } + next_weapon = 0; + // // mouse // @@ -712,6 +740,15 @@ boolean G_Responder(event_t * ev) testcontrols_mousespeed = abs(ev->data2); } + if (ev->type == ev_keydown && ev->data1 == key_prevweapon) + { + next_weapon = -1; + } + else if (ev->type == ev_keydown && ev->data1 == key_nextweapon) + { + next_weapon = 1; + } + switch (ev->type) { case ev_keydown: |