summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/docs/crawl_options.txt6
-rw-r--r--crawl-ref/init.txt1
-rw-r--r--crawl-ref/source/externs.h3
-rw-r--r--crawl-ref/source/initfile.cc7
-rw-r--r--crawl-ref/source/item_use.cc1
-rw-r--r--crawl-ref/source/player.cc59
-rw-r--r--crawl-ref/source/travel.cc2
-rw-r--r--crawl-ref/source/travel.h3
8 files changed, 61 insertions, 21 deletions
diff --git a/crawl-ref/docs/crawl_options.txt b/crawl-ref/docs/crawl_options.txt
index 2f05dd79cf..bab4930b2b 100644
--- a/crawl-ref/docs/crawl_options.txt
+++ b/crawl-ref/docs/crawl_options.txt
@@ -757,6 +757,12 @@ trapwalk_safe_hp = <trap_name>:<minimum_hp>, ...
is easily possible. Defaults to none. For example,
trapwalk_safe_hp = dart:15, needle:25, spear:50
+trap_prompt = true
+ If trap_prompt is set to true Crawl will use the trapwalk_safe_hp
+ values to decide whether the player should be prompted before
+ stepping on a mechanical trap. Note that you'll always be prompted
+ for non-mechanical traps.
+
4-h Stashes.
----------------
diff --git a/crawl-ref/init.txt b/crawl-ref/init.txt
index b4b493401c..a42e98ac31 100644
--- a/crawl-ref/init.txt
+++ b/crawl-ref/init.txt
@@ -165,6 +165,7 @@ stab_brand = hi:blue
# runrest_ignore_poison = 4:100
# runrest_ignore_monster = fish:3
# trapwalk_safe_hp = dart:15, needle:25, spear:50
+# trap_prompt = false
##### 4-h Stashes ###############################
#
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 60e4a1abb2..61b6c6ad8f 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1669,6 +1669,9 @@ public:
unsigned may_stab_brand; // Highlight potential stab candidates
unsigned feature_item_brand; // Highlight features covered by items.
unsigned trap_item_brand; // Highlight traps covered by items.
+
+ bool trap_prompt; // Prompt when stepping on mechnical traps
+ // without enough hp (using trapwalk.lua)
// What is the minimum number of items in a stack for which
// you show summary (one-line) information
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index da5415202f..08d7c4a55c 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -741,7 +741,8 @@ void game_options::reset_options()
explore_greedy = true;
explore_improved = false;
-
+ trap_prompt = true;
+
target_zero_exp = false;
target_wrap = true;
target_oos = true;
@@ -2516,6 +2517,10 @@ void game_options::read_option_line(const std::string &str, bool runscript)
{
explore_improved = read_bool(field, explore_improved);
}
+ else if (key == "trap_prompt")
+ {
+ trap_prompt = read_bool(field, trap_prompt);
+ }
else if (key == "stash_tracking")
{
stash_tracking =
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index f0d61637e2..71f883ba74 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -3286,6 +3286,7 @@ bool remove_ring(int slot, bool announce)
return (false);
}
}
+
if (!check_warning_inscriptions(you.inv[you.equip[hand_used]],
OPER_REMOVE))
{
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 431ff9b546..854e600352 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -119,16 +119,10 @@ bool move_player_to_grid( int x, int y, bool stepped, bool allow_shift,
// really must be clear
ASSERT( you.can_pass_through_feat( new_grid ) );
- // if (grid_is_solid( new_grid ))
- // return (false);
-
// better not be an unsubmerged monster either:
ASSERT( mgrd[x][y] == NON_MONSTER
|| mons_is_submerged( &menv[ mgrd[x][y] ] ));
- // if (mgrd[x][y] != NON_MONSTER && !mons_is_submerged( &menv[ mgrd[x][y] ] ))
- // return (false);
-
// if we're walking along, give a chance to avoid trap
if (stepped && !force && !you.confused())
{
@@ -158,22 +152,49 @@ bool move_player_to_grid( int x, int y, bool stepped, bool allow_shift,
}
} // unknown trap
else if (new_grid == DNGN_TRAP_MAGICAL
+#ifdef CLUA_BINDINGS
+ || new_grid == DNGN_TRAP_MECHANICAL
+ && Options.trap_prompt
+#endif
|| new_grid == DNGN_TRAP_NATURAL)
{
- std::string prompt = "Really step ";
- prompt += (trap_type_at_xy(x,y) == TRAP_ALARM ?
- "onto" : "into");
- prompt += " that ";
- prompt += feature_description(new_grid, trap_type_at_xy(x,y),
- false, DESC_BASENAME, false);
- prompt += '?';
-
- // Zot traps require capital confirmation
- bool harmless = (trap_type_at_xy(x,y) != TRAP_ZOT);
- if (!yesno(prompt.c_str(), harmless, 'n'))
+ if (trap_type_at_xy(x,y) == TRAP_ZOT)
{
- you.turn_is_over = false;
- return (false);
+ mpr("Do you really want to step into the Zot trap? "
+ "(Confirm with \"yes\".) ", MSGCH_PROMPT);
+
+ char buf[10];
+ if (cancelable_get_line(buf, sizeof buf)
+ || strcasecmp(buf, "yes"))
+ {
+ canned_msg(MSG_OK);
+ you.turn_is_over = false;
+ return (false);
+ }
+ }
+ else
+#ifdef CLUA_BINDINGS
+ // prompt for any trap where you might not have enough hp
+ // as defined in init.txt (see trapwalk.lua)
+ if (new_grid != DNGN_TRAP_MECHANICAL
+ || !clua.callbooleanfn(false, "ch_cross_trap",
+ "s", trap_name(x, y)))
+#endif
+ {
+ std::string prompt = "Really step ";
+ prompt += (trap_type_at_xy(x,y) == TRAP_ALARM ?
+ "onto" : "into");
+ prompt += " that ";
+ prompt += feature_description(new_grid, trap_type_at_xy(x,y),
+ false, DESC_BASENAME, false);
+ prompt += '?';
+
+ if (!yesno(prompt.c_str(), true, 'n'))
+ {
+ canned_msg(MSG_OK);
+ you.turn_is_over = false;
+ return (false);
+ }
}
}
}
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index d43b3a49f2..4aa8ae8d32 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -187,7 +187,7 @@ static void init_traps()
traps_inited = true;
}
-static const char *trap_name(int x, int y)
+const char *trap_name(int x, int y)
{
if (!traps_inited)
init_traps();
diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h
index c71853285b..c0ce805db7 100644
--- a/crawl-ref/source/travel.h
+++ b/crawl-ref/source/travel.h
@@ -72,6 +72,9 @@ bool is_travelable_stair(dungeon_feature_type gridc);
command_type direction_to_command( char x, char y );
bool is_resting( void );
bool can_travel_interlevel();
+#ifdef CLUA_BINDINGS
+const char *trap_name(int x, int y);
+#endif
bool is_traversable(dungeon_feature_type grid);
void explore_pickup_event(int did_pickup, int tried_pickup);
bool is_excluded(const coord_def &p);