diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-24 01:00:14 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-24 03:19:36 -0800 |
commit | 2805b3beebfd7913794a412cc5a2d68042051257 (patch) | |
tree | db1ae39d931770bcee89ed11f1f4c9d25a634451 | |
parent | 6ca662b8cced71f9eb5938519540cd9aa2207c09 (diff) | |
download | crawl-ref-2805b3beebfd7913794a412cc5a2d68042051257.tar.gz crawl-ref-2805b3beebfd7913794a412cc5a2d68042051257.zip |
you.never_die (player::never_die)
If the macros DEBUG or WIZARD are defined, then class player will have
the member never_die, which if set to true makes any deadly calls to
ouch() return without the game ending.
-rw-r--r-- | crawl-ref/source/l_debug.cc | 17 | ||||
-rw-r--r-- | crawl-ref/source/ouch.cc | 9 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/player.h | 6 |
4 files changed, 36 insertions, 0 deletions
diff --git a/crawl-ref/source/l_debug.cc b/crawl-ref/source/l_debug.cc index 1e961152fa..defa56bdbc 100644 --- a/crawl-ref/source/l_debug.cc +++ b/crawl-ref/source/l_debug.cc @@ -107,6 +107,22 @@ LUAFN(debug_bouncy_beam) return (0); } +LUAFN(debug_never_die) +{ +#if WIZARD || DEBUG + if (lua_isnone(ls, 1)) + { + luaL_argerror(ls, 1, "needs a boolean argument"); + return (0); + } + you.never_die = lua_toboolean(ls, 1); +#else + luaL_error(ls, "only works if DEBUG or WIZARD is defined"); +#endif + + return (0); +} + const struct luaL_reg debug_dlib[] = { { "goto_place", debug_goto_place }, @@ -115,6 +131,7 @@ const struct luaL_reg debug_dlib[] = { "dump_map", debug_dump_map }, { "test_explore", _debug_test_explore }, { "bouncy_beam", debug_bouncy_beam }, +{ "never_die", debug_never_die }, { NULL, NULL } }; diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index da61e3fc34..4698c7f506 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -1137,6 +1137,15 @@ void ouch(int dam, int death_source, kill_method_type death_type, death_type = KILLED_BY_XOM; } +#if WIZARD || DEBUG + if (you.never_die) + { + mpr("you.never_die set to true, avoiding death", + MSGCH_DIAGNOSTICS); + return; + } +#endif + // Construct scorefile entry. scorefile_entry se(dam, death_source, death_type, aux); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index fcc151096f..dbc36d491c 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5484,6 +5484,10 @@ void player::init() reset_escaped_death(); on_current_level = true; + +#if WIZARD || DEBUG + you.never_die = false; +#endif } player_save_info player_save_info::operator=(const player& rhs) diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index c6963afdf0..b255150950 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -295,6 +295,12 @@ public: // and restored. std::vector<int> beholders; +#if WIZARD || DEBUG + // If set to true, then any call to ouch() which would cuase the player + // to die automatically returns without ending the game. + bool never_die; +#endif + protected: FixedVector<PlaceInfo, NUM_BRANCHES> branch_info; FixedVector<PlaceInfo, NUM_LEVEL_AREA_TYPES - 1> non_branch_info; |