WoW-style Autorun
authorDuane Robertson <duane@duanerobertson.com>
Mon, 28 Sep 2015 18:59:03 +0000 (13:59 -0500)
committersfan5 <sfan5@live.de>
Thu, 29 Oct 2015 20:48:57 +0000 (21:48 +0100)
This allows the player to toggle continuous forward with a key (F by default),
so we don't have to hold down the forward key endlessly.

src/defaultsettings.cpp
src/game.cpp

index 4a420445c70aedfa4b5a4818334f3284d2411970..3315f4aaa7766f18d1963b6b69883cd7d55e3569 100644 (file)
@@ -33,6 +33,7 @@ void set_default_settings(Settings *settings)
        // Client stuff
        settings->setDefault("remote_port", "30000");
        settings->setDefault("keymap_forward", "KEY_KEY_W");
+       settings->setDefault("keymap_autorun", "");
        settings->setDefault("keymap_backward", "KEY_KEY_S");
        settings->setDefault("keymap_left", "KEY_KEY_A");
        settings->setDefault("keymap_right", "KEY_KEY_D");
index 36945f343aa0ed411deaca7a5bf8cb3f3d1f2652..df5ab701a96893ab6b36d59c7996d2d13d1cc24f 100644 (file)
@@ -1234,6 +1234,7 @@ struct KeyCache {
                KEYMAP_ID_JUMP,
                KEYMAP_ID_SPECIAL1,
                KEYMAP_ID_SNEAK,
+               KEYMAP_ID_AUTORUN,
 
                // Other
                KEYMAP_ID_DROP,
@@ -1286,6 +1287,8 @@ void KeyCache::populate()
        key[KEYMAP_ID_SPECIAL1]     = getKeySetting("keymap_special1");
        key[KEYMAP_ID_SNEAK]        = getKeySetting("keymap_sneak");
 
+       key[KEYMAP_ID_AUTORUN]      = getKeySetting("keymap_autorun");
+
        key[KEYMAP_ID_DROP]         = getKeySetting("keymap_drop");
        key[KEYMAP_ID_INVENTORY]    = getKeySetting("keymap_inventory");
        key[KEYMAP_ID_CHAT]         = getKeySetting("keymap_chat");
@@ -2615,6 +2618,10 @@ void Game::processKeyboardInput(VolatileRunFlags *flags,
 
        if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_DROP])) {
                dropSelectedItem();
+       // Add WoW-style autorun by toggling continuous forward.
+       } else if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_AUTORUN])) {
+               bool autorun_setting = g_settings->getBool("continuous_forward");
+               g_settings->setBool("continuous_forward", !autorun_setting);
        } else if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_INVENTORY])) {
                openInventory();
        } else if (input->wasKeyDown(EscapeKey) || input->wasKeyDown(CancelKey)) {