summaryrefslogtreecommitdiff
path: root/src/hexen
diff options
context:
space:
mode:
authorSimon Howard2011-10-15 17:39:33 +0000
committerSimon Howard2011-10-15 17:39:33 +0000
commit74e95f3f2b632798d08be675f7fd7abb53303239 (patch)
treebc9b33ece4041d36a00cfeb2f78d4ff65db6610e /src/hexen
parentdee1ed97a1c031a9c055088c53fd4189d09d81ab (diff)
downloadchocolate-doom-74e95f3f2b632798d08be675f7fd7abb53303239.tar.gz
chocolate-doom-74e95f3f2b632798d08be675f7fd7abb53303239.tar.bz2
chocolate-doom-74e95f3f2b632798d08be675f7fd7abb53303239.zip
Add weapon cycling keys for Hexen.
Subversion-branch: /branches/v2-branch Subversion-revision: 2431
Diffstat (limited to 'src/hexen')
-rw-r--r--src/hexen/g_game.c49
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: