From dee1ed97a1c031a9c055088c53fd4189d09d81ab Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 15 Oct 2011 17:17:43 +0000 Subject: Add weapon cycling keys for Heretic. Subversion-branch: /branches/v2-branch Subversion-revision: 2430 --- src/heretic/g_game.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 99 insertions(+), 8 deletions(-) diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c index 69a3d5b7..74942653 100644 --- a/src/heretic/g_game.c +++ b/src/heretic/g_game.c @@ -165,6 +165,28 @@ static int *weapon_keys[] = &key_weapon7 }; +// Set to -1 or +1 to switch to the previous or next weapon. + +static int next_weapon = 0; + +// Used for prev/next weapon keys. + +static const struct +{ + weapontype_t weapon; + weapontype_t weapon_num; +} weapon_order_table[] = { + { wp_staff, wp_staff }, + { wp_gauntlets, wp_staff }, + { wp_goldwand, wp_goldwand }, + { wp_crossbow, wp_crossbow }, + { wp_blaster, wp_blaster }, + { wp_skullrod, wp_skullrod }, + { wp_phoenixrod, wp_phoenixrod }, + { wp_mace, wp_mace }, + { wp_beak, wp_beak }, +}; + #define SLOWTURNTICS 6 #define NUMKEYS 256 @@ -210,6 +232,51 @@ int G_CmdChecksum(ticcmd_t *cmd) } */ +static boolean WeaponSelectable(weapontype_t weapon) +{ + if (weapon == wp_beak) + { + return false; + } + + return players[consoleplayer].weaponowned[weapon]; +} + +static int G_NextWeapon(int direction) +{ + weapontype_t weapon; + int i; + + // Find index in the table. + + if (players[consoleplayer].pendingweapon == wp_nochange) + { + weapon = players[consoleplayer].readyweapon; + } + else + { + weapon = players[consoleplayer].pendingweapon; + } + + for (i=0; ibuttons |= BT_CHANGE; + cmd->buttons |= i << BT_WEAPONSHIFT; + } + else + { + for (i=0; ibuttons |= BT_CHANGE; - cmd->buttons |= i<buttons |= BT_CHANGE; + cmd->buttons |= i<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: -- cgit v1.2.3