From 5ce0d0260a82bfb4b60e52b85070e08c867d14eb Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Wed, 12 Mar 2008 16:43:37 +0000 Subject: 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 --- crawl-ref/source/player.cc | 59 +++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 19 deletions(-) (limited to 'crawl-ref/source/player.cc') 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); + } } } } -- cgit v1.2.3-54-g00ecf