shithub: choc

Download patch

ref: ae2c47344237e341a979adba4b2a20b68e4de559
parent: ecf457ddcbf481b451f37474b057a06e7d843b66
author: Fabian Greffrath <[email protected]>
date: Thu Mar 13 03:25:31 EDT 2014

Allow to rebind artifact keys in Hexen.

--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -396,46 +396,46 @@
     }
 
     // Artifact hot keys
-    if (gamekeydown[KEY_BACKSPACE] && !cmd->arti)
+    if (gamekeydown[key_arti_all] && !cmd->arti)
     {
-        gamekeydown[KEY_BACKSPACE] = false;     // Use one of each artifact
+        gamekeydown[key_arti_all] = false;     // Use one of each artifact
         cmd->arti = NUMARTIFACTS;
     }
-    else if (gamekeydown['\\'] && !cmd->arti
+    else if (gamekeydown[key_arti_health] && !cmd->arti
              && (players[consoleplayer].mo->health < MAXHEALTH))
     {
-        gamekeydown['\\'] = false;
+        gamekeydown[key_arti_health] = false;
         cmd->arti = arti_health;
     }
-    else if (gamekeydown['0'] && !cmd->arti)
+    else if (gamekeydown[key_arti_poisonbag] && !cmd->arti)
     {
-        gamekeydown['0'] = false;
+        gamekeydown[key_arti_poisonbag] = false;
         cmd->arti = arti_poisonbag;
     }
-    else if (gamekeydown['9'] && !cmd->arti)
+    else if (gamekeydown[key_arti_blastradius] && !cmd->arti)
     {
-        gamekeydown['9'] = false;
+        gamekeydown[key_arti_blastradius] = false;
         cmd->arti = arti_blastradius;
     }
-    else if (gamekeydown['8'] && !cmd->arti)
+    else if (gamekeydown[key_arti_teleport] && !cmd->arti)
     {
-        gamekeydown['8'] = false;
+        gamekeydown[key_arti_teleport] = false;
         cmd->arti = arti_teleport;
     }
-    else if (gamekeydown['7'] && !cmd->arti)
+    else if (gamekeydown[key_arti_teleportother] && !cmd->arti)
     {
-        gamekeydown['7'] = false;
+        gamekeydown[key_arti_teleportother] = false;
         cmd->arti = arti_teleportother;
     }
-    else if (gamekeydown['6'] && !cmd->arti)
+    else if (gamekeydown[key_arti_egg] && !cmd->arti)
     {
-        gamekeydown['6'] = false;
+        gamekeydown[key_arti_egg] = false;
         cmd->arti = arti_egg;
     }
-    else if (gamekeydown['5'] && !cmd->arti
+    else if (gamekeydown[key_arti_invulnerability] && !cmd->arti
              && !players[consoleplayer].powers[pw_invulnerability])
     {
-        gamekeydown['5'] = false;
+        gamekeydown[key_arti_invulnerability] = false;
         cmd->arti = arti_invulnerability;
     }
 
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1298,6 +1298,70 @@
     CONFIG_VARIABLE_KEY(key_nextweapon),
 
     //!
+    // @game hexen
+    //
+    // Key to use one of each artifact.
+    //
+
+    CONFIG_VARIABLE_KEY(key_arti_all),
+
+    //!
+    // @game hexen
+    //
+    // Key to use "quartz flask" artifact.
+    //
+
+    CONFIG_VARIABLE_KEY(key_arti_health),
+
+    //!
+    // @game hexen
+    //
+    // Key to use "flechette" artifact.
+    //
+
+    CONFIG_VARIABLE_KEY(key_arti_poisonbag),
+
+    //!
+    // @game hexen
+    //
+    // Key to use "disc of repulsion" artifact.
+    //
+
+    CONFIG_VARIABLE_KEY(key_arti_blastradius),
+
+    //!
+    // @game hexen
+    //
+    // Key to use "chaos device" artifact.
+    //
+
+    CONFIG_VARIABLE_KEY(key_arti_teleport),
+
+    //!
+    // @game hexen
+    //
+    // Key to use "banishment device" artifact.
+    //
+
+    CONFIG_VARIABLE_KEY(key_arti_teleportother),
+
+    //!
+    // @game hexen
+    //
+    // Key to use "porkalator" artifact.
+    //
+
+    CONFIG_VARIABLE_KEY(key_arti_egg),
+
+    //!
+    // @game hexen
+    //
+    // Key to use "icon of the defender" artifact.
+    //
+
+    CONFIG_VARIABLE_KEY(key_arti_invulnerability),
+
+    //!
     // Key to re-display last message.
     //
 
--- a/src/m_controls.c
+++ b/src/m_controls.c
@@ -67,6 +67,15 @@
 
 int key_jump = '/';
 
+int key_arti_all             = KEY_BACKSPACE;
+int key_arti_health          = '\\';
+int key_arti_poisonbag       = '0';
+int key_arti_blastradius     = '9';
+int key_arti_teleport        = '8';
+int key_arti_teleportother   = '7';
+int key_arti_egg             = '6';
+int key_arti_invulnerability = '5';
+
 //
 // Strife key controls
 //
@@ -252,6 +261,15 @@
     M_BindVariable("key_jump",           &key_jump);
     M_BindVariable("mouseb_jump",        &mousebjump);
     M_BindVariable("joyb_jump",          &joybjump);
+
+    M_BindVariable("key_arti_all",             &key_arti_all);
+    M_BindVariable("key_arti_health",          &key_arti_health);
+    M_BindVariable("key_arti_poisonbag",       &key_arti_poisonbag);
+    M_BindVariable("key_arti_blastradius",     &key_arti_blastradius);
+    M_BindVariable("key_arti_teleport",        &key_arti_teleport);
+    M_BindVariable("key_arti_teleportother",   &key_arti_teleportother);
+    M_BindVariable("key_arti_egg",             &key_arti_egg);
+    M_BindVariable("key_arti_invulnerability", &key_arti_invulnerability);
 }
 
 void M_BindStrifeControls(void)
--- a/src/m_controls.h
+++ b/src/m_controls.h
@@ -75,6 +75,15 @@
 extern int key_weapon7;
 extern int key_weapon8;
 
+extern int key_arti_all;
+extern int key_arti_health;
+extern int key_arti_poisonbag;
+extern int key_arti_blastradius;
+extern int key_arti_teleport;
+extern int key_arti_teleportother;
+extern int key_arti_egg;
+extern int key_arti_invulnerability;
+
 extern int key_demo_quit;
 extern int key_spy;
 extern int key_prevweapon;
--- a/src/setup/keyboard.c
+++ b/src/setup/keyboard.c
@@ -49,6 +49,10 @@
                            &key_weapon1, &key_weapon2, &key_weapon3,
                            &key_weapon4, &key_weapon5, &key_weapon6,
                            &key_weapon7, &key_weapon8,
+                           &key_arti_all, &key_arti_health, &key_arti_poisonbag,
+                           &key_arti_blastradius, &key_arti_teleport,
+                           &key_arti_teleportother, &key_arti_egg,
+                           &key_arti_invulnerability,
                            &key_prevweapon, &key_nextweapon, NULL };
 
 static int *menu_nav[] = { &key_menu_activate, &key_menu_up, &key_menu_down,
@@ -184,7 +188,7 @@
 
     table = TXT_NewTable(2);
 
-    TXT_SetColumnWidths(table, 20, 9);
+    TXT_SetColumnWidths(table, 21, 9);
 
     if (extra_keys)
     {
@@ -228,6 +232,20 @@
         else
         {
             AddKeyControl(table, "Use artifact", &key_useartifact);
+        }
+
+        if (gamemission == hexen)
+        {
+            AddSectionLabel(table, "Artifacts", true);
+
+            AddKeyControl(table, "One of each", &key_arti_all);
+            AddKeyControl(table, "Quartz Flask", &key_arti_health);
+            AddKeyControl(table, "Flechette", &key_arti_poisonbag);
+            AddKeyControl(table, "Disc of Repulsion", &key_arti_blastradius);
+            AddKeyControl(table, "Chaos Device", &key_arti_teleport);
+            AddKeyControl(table, "Banishment Device", &key_arti_teleportother);
+            AddKeyControl(table, "Porkalator", &key_arti_egg);
+            AddKeyControl(table, "Icon of the Defender", &key_arti_invulnerability);
         }
     }
     else