summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-12 16:43:37 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-12 16:43:37 +0000
commit5ce0d0260a82bfb4b60e52b85070e08c867d14eb (patch)
tree35356f34e8f3a7c569b45266347224d58bb6fd4a /crawl-ref/source
parent95786b6d3fc7194f2e859eb015034878c5706e13 (diff)
downloadcrawl-ref-5ce0d0260a82bfb4b60e52b85070e08c867d14eb.tar.gz
crawl-ref-5ce0d0260a82bfb4b60e52b85070e08c867d14eb.zip
Modify the Zot trap "Do you really ...?" prompt to only accept "yes" as a
confirming answer, and add an option trap_prompt that, if set to true (the default) will prompt the player before stepping on known mechanical traps trapwalk.lua considers unsafe. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3611 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-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
6 files changed, 54 insertions, 21 deletions
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);