From 7dab95158865a69a9dc3c79af4027c780507efb7 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Thu, 4 Jan 2007 18:38:39 +0000 Subject: Autoprayer should not activate in damaging clouds. Fixed '5' resting being broken. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@788 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 1 + crawl-ref/source/direct.cc | 31 ++---------------- crawl-ref/source/misc.cc | 79 +++++++++++++++++++++++++++++++++++++++++++++- crawl-ref/source/misc.h | 3 ++ crawl-ref/source/travel.cc | 12 ++----- 5 files changed, 87 insertions(+), 39 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 696d031e34..12d715e18f 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2402,6 +2402,7 @@ command_type keycode_to_command( keycode_type key ) { case '\'': return CMD_WEAPON_SWAP; case '0': return CMD_NO_CMD; + case '5': return CMD_REST; case CONTROL('B'): return CMD_OPEN_DOOR_DOWN_LEFT; case CONTROL('H'): return CMD_OPEN_DOOR_LEFT; diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc index 706bee5edb..e1228305ba 100644 --- a/crawl-ref/source/direct.cc +++ b/crawl-ref/source/direct.cc @@ -1517,34 +1517,9 @@ static void describe_cell(int mx, int my) { const char cloud_inspected = env.cgrid[mx][my]; - const char cloud_type = env.cloud[ cloud_inspected ].type; - - strcpy(info, "There is a cloud of "); - strcat(info, - (cloud_type == CLOUD_FIRE - || cloud_type == CLOUD_FIRE_MON) ? "flame" : - (cloud_type == CLOUD_STINK - || cloud_type == CLOUD_STINK_MON) ? "noxious fumes" : - (cloud_type == CLOUD_COLD - || cloud_type == CLOUD_COLD_MON) ? "freezing vapour" : - (cloud_type == CLOUD_POISON - || cloud_type == CLOUD_POISON_MON) ? "poison gases" : - (cloud_type == CLOUD_GREY_SMOKE - || cloud_type == CLOUD_GREY_SMOKE_MON) ? "grey smoke" : - (cloud_type == CLOUD_BLUE_SMOKE - || cloud_type == CLOUD_BLUE_SMOKE_MON) ? "blue smoke" : - (cloud_type == CLOUD_PURP_SMOKE - || cloud_type == CLOUD_PURP_SMOKE_MON) ? "purple smoke" : - (cloud_type == CLOUD_STEAM - || cloud_type == CLOUD_STEAM_MON) ? "steam" : - (cloud_type == CLOUD_MIASMA - || cloud_type == CLOUD_MIASMA_MON) ? "foul pestilence" : - (cloud_type == CLOUD_BLACK_SMOKE - || cloud_type == CLOUD_BLACK_SMOKE_MON) ? "black smoke" : - (cloud_type == CLOUD_MIST)? "thin mist" : - "buggy goodness"); - strcat(info, " here."); - mpr(info); + const cloud_type ctype = (cloud_type) env.cloud[ cloud_inspected ].type; + + mprf("There is a cloud of %s here.", cloud_name(ctype).c_str()); } int targ_item = igrd[ mx ][ my ]; diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 58d48b64a5..747e4f8457 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1771,6 +1771,69 @@ int trap_at_xy(int which_x, int which_y) return (-1); } // end trap_at_xy() +bool is_damaging_cloud(cloud_type type) +{ + switch (type) + { + case CLOUD_FIRE: + case CLOUD_FIRE_MON: + case CLOUD_STINK: + case CLOUD_STINK_MON: + case CLOUD_COLD: + case CLOUD_COLD_MON: + case CLOUD_POISON: + case CLOUD_POISON_MON: + case CLOUD_STEAM: + case CLOUD_STEAM_MON: + case CLOUD_MIASMA: + case CLOUD_MIASMA_MON: + return (true); + default: + return (false); + } +} + +std::string cloud_name(cloud_type type) +{ + switch (type) + { + case CLOUD_FIRE: + case CLOUD_FIRE_MON: + return "flame"; + case CLOUD_STINK: + case CLOUD_STINK_MON: + return "noxious fumes"; + case CLOUD_COLD: + case CLOUD_COLD_MON: + return "freezing vapour"; + case CLOUD_POISON: + case CLOUD_POISON_MON: + return "poison gases"; + case CLOUD_GREY_SMOKE: + case CLOUD_GREY_SMOKE_MON: + return "grey smoke"; + case CLOUD_BLUE_SMOKE: + case CLOUD_BLUE_SMOKE_MON: + return "blue smoke"; + case CLOUD_PURP_SMOKE: + case CLOUD_PURP_SMOKE_MON: + return "purple smoke"; + case CLOUD_STEAM: + case CLOUD_STEAM_MON: + return "steam"; + case CLOUD_MIASMA: + case CLOUD_MIASMA_MON: + return "foul pestilence"; + case CLOUD_BLACK_SMOKE: + case CLOUD_BLACK_SMOKE_MON: + return "black smoke"; + case CLOUD_MIST: + return "thin mist"; + default: + return "buggy goodness"; + } +} + bool i_feel_safe(bool announce) { /* This is probably unnecessary, but I'm not sure that @@ -1789,7 +1852,21 @@ bool i_feel_safe(bool announce) if (announce) mprf(MSGCH_WARN, "There are scary statues in view."); - return false; + return (false); + } + + if (in_bounds(you.x_pos, you.y_pos) + && env.cgrid[you.x_pos][you.y_pos] != EMPTY_CLOUD) + { + const cloud_type type = (cloud_type) + env.cloud[ env.cgrid[you.x_pos][you.y_pos] ].type; + if (is_damaging_cloud(type)) + { + if (announce) + mprf(MSGCH_WARN, "You're standing in a cloud of %s!", + cloud_name(type).c_str()); + return (false); + } } std::vector mons; diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index 475c577dcf..2ae9ebad77 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -143,6 +143,9 @@ bool grid_is_branch_stairs( unsigned char grid ); int grid_secret_door_appearance( int gx, int gy ); bool grid_destroys_items( int grid ); +std::string cloud_name(cloud_type type); +bool is_damaging_cloud(cloud_type type); + const char *grid_item_destruction_message( unsigned char grid ); void curare_hits_player(int agent, int degree); diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 544eabbd6e..8cdb247a1e 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -471,16 +471,8 @@ static bool is_safe(int x, int y) return true; // We can also safely run through smoke. - const int cloud_type = env.cloud[ cloud ].type; - return cloud_type == CLOUD_GREY_SMOKE || - cloud_type == CLOUD_GREY_SMOKE_MON || - cloud_type == CLOUD_BLUE_SMOKE || - cloud_type == CLOUD_BLUE_SMOKE_MON || - cloud_type == CLOUD_PURP_SMOKE || - cloud_type == CLOUD_PURP_SMOKE_MON || - cloud_type == CLOUD_BLACK_SMOKE || - cloud_type == CLOUD_BLACK_SMOKE_MON || - cloud_type == CLOUD_MIST; + const cloud_type ctype = (cloud_type) env.cloud[ cloud ].type; + return !is_damaging_cloud(ctype); } static bool player_is_permalevitating() -- cgit v1.2.3-54-g00ecf