Attached Files |
0001-Add-CMD_SAFE_MOVE_-direction-and-CMD_SAFE_WAIT.patch [^] (4,667 bytes) 2013-01-29 02:38 [Show Content] [Hide Content]From 0f3b9b45257e5f5c430aef12ef2452ef8c2b4714 Mon Sep 17 00:00:00 2001
From: Mark Lodato <lodatom@gmail.com>
Date: Mon, 28 Jan 2013 00:52:17 -0500
Subject: [PATCH 1/3] Add CMD_SAFE_MOVE_<direction> and CMD_SAFE_WAIT.
These commands move the player in <direction> or wait a turn, but only
if there is no monster around, equivalent to running one tile or
resting one turn.
This commit does not bind these commands to any keys by default.
---
crawl-ref/source/dat/descript/commands.txt | 9 ++++++++
crawl-ref/source/enum.h | 10 +++++++++
crawl-ref/source/main.cc | 32 ++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
diff --git a/crawl-ref/source/dat/descript/commands.txt b/crawl-ref/source/dat/descript/commands.txt
index beb43d2..e40f459 100644
--- a/crawl-ref/source/dat/descript/commands.txt
+++ b/crawl-ref/source/dat/descript/commands.txt
@@ -160,6 +160,15 @@ CMD_WAIT verbose
Spend a single turn waiting and resting.
%%%%
+CMD_SAFE_WAIT
+
+Wait a single turn if safe
+%%%%
+CMD_SAFE_WAIT verbose
+
+Spend a single turn waiting and resting, but only if there are no hostile
+monsters in view.
+%%%%
CMD_DISPLAY_INVENTORY
Display the contents of your inventory
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index a131bf5..4176403 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -629,6 +629,16 @@ enum command_type
CMD_RUN_DOWN_LEFT,
CMD_RUN_UP_RIGHT,
CMD_RUN_DOWN_RIGHT,
+ CMD_SAFE_WAIT,
+ CMD_SAFE_MOVE_NOWHERE,
+ CMD_SAFE_MOVE_LEFT,
+ CMD_SAFE_MOVE_DOWN,
+ CMD_SAFE_MOVE_UP,
+ CMD_SAFE_MOVE_RIGHT,
+ CMD_SAFE_MOVE_UP_LEFT,
+ CMD_SAFE_MOVE_DOWN_LEFT,
+ CMD_SAFE_MOVE_UP_RIGHT,
+ CMD_SAFE_MOVE_DOWN_RIGHT,
CMD_OPEN_DOOR_LEFT,
CMD_OPEN_DOOR_DOWN,
CMD_OPEN_DOOR_UP,
diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc
index 151f0e7..3bbbbf3 100644
--- a/crawl-ref/source/main.cc
+++ b/crawl-ref/source/main.cc
@@ -195,6 +195,7 @@ static void _launch_game();
static void _do_berserk_no_combat_penalty(void);
static void _input(void);
+static void _safe_move_player(int move_x, int move_y);
static void _move_player(int move_x, int move_y);
static void _move_player(coord_def move);
static int _check_adjacent(dungeon_feature_type feat, coord_def& delta);
@@ -1016,6 +1017,16 @@ static bool _cmd_is_repeatable(command_type cmd, bool is_again = false)
case CMD_MOVE_NOWHERE:
case CMD_REST:
case CMD_WAIT:
+ case CMD_SAFE_WAIT:
+ case CMD_SAFE_MOVE_NOWHERE:
+ case CMD_SAFE_MOVE_LEFT:
+ case CMD_SAFE_MOVE_DOWN:
+ case CMD_SAFE_MOVE_UP:
+ case CMD_SAFE_MOVE_RIGHT:
+ case CMD_SAFE_MOVE_UP_LEFT:
+ case CMD_SAFE_MOVE_DOWN_LEFT:
+ case CMD_SAFE_MOVE_UP_RIGHT:
+ case CMD_SAFE_MOVE_DOWN_RIGHT:
return i_feel_safe(true);
case CMD_MOVE_LEFT:
@@ -1841,6 +1852,15 @@ void process_command(command_type cmd)
case CMD_MOVE_DOWN_RIGHT: _move_player(1, 1); break;
case CMD_MOVE_RIGHT: _move_player(1, 0); break;
+ case CMD_SAFE_MOVE_DOWN_LEFT: _safe_move_player(-1, 1); break;
+ case CMD_SAFE_MOVE_DOWN: _safe_move_player(0, 1); break;
+ case CMD_SAFE_MOVE_UP_RIGHT: _safe_move_player(1, -1); break;
+ case CMD_SAFE_MOVE_UP: _safe_move_player(0, -1); break;
+ case CMD_SAFE_MOVE_UP_LEFT: _safe_move_player(-1, -1); break;
+ case CMD_SAFE_MOVE_LEFT: _safe_move_player(-1, 0); break;
+ case CMD_SAFE_MOVE_DOWN_RIGHT: _safe_move_player(1, 1); break;
+ case CMD_SAFE_MOVE_RIGHT: _safe_move_player(1, 0); break;
+
case CMD_RUN_DOWN_LEFT: _start_running(RDIR_DOWN_LEFT, RMODE_START); break;
case CMD_RUN_DOWN: _start_running(RDIR_DOWN, RMODE_START); break;
case CMD_RUN_UP_RIGHT: _start_running(RDIR_UP_RIGHT, RMODE_START); break;
@@ -1914,6 +1934,11 @@ void process_command(command_type cmd)
case CMD_SHOW_TERRAIN: toggle_show_terrain(); break;
case CMD_ADJUST_INVENTORY: adjust(); break;
+ case CMD_SAFE_MOVE_NOWHERE:
+ case CMD_SAFE_WAIT:
+ if (!i_feel_safe(true))
+ break;
+ // else fall-through
case CMD_MOVE_NOWHERE:
case CMD_WAIT:
you.check_clinging(false);
@@ -4091,6 +4116,13 @@ static void _do_berserk_no_combat_penalty(void)
return;
}
+static void _safe_move_player(int move_x, int move_y)
+{
+ if (!i_feel_safe(true))
+ return;
+ _move_player(move_x, move_y);
+}
+
// Called when the player moves by walking/running. Also calls attack
// function etc when necessary.
static void _move_player(int move_x, int move_y)
--
1.7.10.4
0002-Bind-CMD_SAFE_MOVE_-direction-to-ALT-numpad.patch [^] (1,741 bytes) 2013-01-29 02:38 [Show Content] [Hide Content]From 43605a9bc1b33e2d64b09928f2267b17f3f125b7 Mon Sep 17 00:00:00 2001
From: Mark Lodato <lodatom@gmail.com>
Date: Mon, 28 Jan 2013 01:13:53 -0500
Subject: [PATCH 2/3] Bind CMD_SAFE_MOVE_<direction> to ALT-<numpad>.
This only works in tiles, since there is not a generic way to add ALT
mappings, and the workaround to map ALT-<numap> is specific to tiles.
---
crawl-ref/source/cio.h | 11 +++++++++++
crawl-ref/source/cmd-keys.h | 9 +++++++++
2 files changed, 20 insertions(+)
diff --git a/crawl-ref/source/cio.h b/crawl-ref/source/cio.h
index cdd1de9..daffcc1 100644
--- a/crawl-ref/source/cio.h
+++ b/crawl-ref/source/cio.h
@@ -189,6 +189,17 @@ enum KEYS
CK_NUMPAD_MINUS,
#endif
+ CK_ALT_NUMPAD_8 = 1770,
+ CK_ALT_NUMPAD_2,
+ CK_ALT_NUMPAD_4,
+ CK_ALT_NUMPAD_6,
+ CK_ALT_NUMPAD_0,
+ CK_ALT_NUMPAD_7,
+ CK_ALT_NUMPAD_1,
+ CK_ALT_NUMPAD_5,
+ CK_ALT_NUMPAD_9,
+ CK_ALT_NUMPAD_3,
+
// Mouse codes.
CK_MOUSE_MOVE = -10009,
CK_MOUSE_CMD,
diff --git a/crawl-ref/source/cmd-keys.h b/crawl-ref/source/cmd-keys.h
index 76f77c0..be5bc94 100644
--- a/crawl-ref/source/cmd-keys.h
+++ b/crawl-ref/source/cmd-keys.h
@@ -72,6 +72,15 @@
{'N', CMD_RUN_DOWN_RIGHT},
{'U', CMD_RUN_UP_RIGHT},
{'Y', CMD_RUN_UP_LEFT},
+{CK_ALT_NUMPAD_1, CMD_SAFE_MOVE_DOWN_LEFT},
+{CK_ALT_NUMPAD_4, CMD_SAFE_MOVE_LEFT},
+{CK_ALT_NUMPAD_2, CMD_SAFE_MOVE_DOWN},
+{CK_ALT_NUMPAD_8, CMD_SAFE_MOVE_UP},
+{CK_ALT_NUMPAD_6, CMD_SAFE_MOVE_RIGHT},
+{CK_ALT_NUMPAD_3, CMD_SAFE_MOVE_DOWN_RIGHT},
+{CK_ALT_NUMPAD_9, CMD_SAFE_MOVE_UP_RIGHT},
+{CK_ALT_NUMPAD_7, CMD_SAFE_MOVE_UP_LEFT},
+{CK_ALT_NUMPAD_5, CMD_SAFE_MOVE_NOWHERE},
{'A', CMD_DISPLAY_MUTATIONS},
{'C', CMD_CLOSE_DOOR},
{'D', CMD_DROP_LAST},
--
1.7.10.4
0003-Add-Alt-numpad-digit-to-quick-reference.patch [^] (1,023 bytes) 2013-01-29 02:38 [Show Content] [Hide Content]From 68621e6fe50415dd91d4823f20415de869ea5e90 Mon Sep 17 00:00:00 2001
From: Mark Lodato <lodatom@gmail.com>
Date: Mon, 28 Jan 2013 01:44:45 -0500
Subject: [PATCH 3/3] Add "Alt-numpad-digit" to quick reference.
This command is still not referenced anywhere else in the help files.
---
crawl-ref/source/command.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index f22a203..bd3bf3b 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -2153,6 +2153,12 @@ static void _add_formatted_keyhelp(column_composer &cols)
"<w>* Dir.</w>, <w>Ctrl-Dir.</w> : open/close door, \n"
" untrap, attack without move\n",
false, true, _cmdhelp_textfilter);
+#ifdef USE_TILE_LOCAL
+ cols.add_formatted(
+ 0,
+ "<w>Alt-numpad-digit</w>: move/wait if safe\n",
+ false, true, _cmdhelp_textfilter);
+#endif
cols.add_formatted(
0,
--
1.7.10.4
|