From bb8c144809db7cce43cbcdbd9681a4adc815243e Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 17 Jan 2023 20:07:24 +0200 Subject: [PATCH] Level temperature Allow setting a per-level "temperature": hot, cold, or temperate via special level flags. Currently it only affects some messages in Gehennom, but it could be expanded to ice melting, water freezing, or monster generation, for example. Invalidates saves and bones. --- dat/hellfill.lua | 2 +- dat/valley.lua | 2 +- doc/fixes3-7-0.txt | 2 ++ doc/lua.adoc | 3 +++ include/patchlevel.h | 2 +- include/rm.h | 1 + src/do.c | 26 +++++++++++++++++++------- src/sp_lev.c | 7 +++++++ 8 files changed, 35 insertions(+), 10 deletions(-) diff --git a/dat/hellfill.lua b/dat/hellfill.lua index 061292365..964b4a24e 100644 --- a/dat/hellfill.lua +++ b/dat/hellfill.lua @@ -231,7 +231,7 @@ hells = { function () local cwid = math.random(4); des.level_init({ style = "solidfill", fg = " ", lit = 0 }); - des.level_flags("mazelevel", "noflip"); + des.level_flags("mazelevel", "noflip", "cold"); des.level_init({ style = "maze", wallthick = 1, corrwid = cwid }); local outside_walls = selection.match(" "); local icey = selection.negate():percentage(10):grow():filter_mapchar("."); diff --git a/dat/valley.lua b/dat/valley.lua index 097fb2925..96bceb997 100644 --- a/dat/valley.lua +++ b/dat/valley.lua @@ -7,7 +7,7 @@ des.level_init({ style = "solidfill", fg = " " }); -des.level_flags("mazelevel", "noteleport", "hardfloor", "nommap"); +des.level_flags("mazelevel", "noteleport", "hardfloor", "nommap", "temperate"); des.map([[ ---------------------------------------------------------------------------- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 4e942b63e..1b57649b2 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1085,6 +1085,8 @@ slightly more interesting Gehennom filler levels don't reveal color of potions, gems, or spellbooks that haven't been seen up close (seeing faraway monster operate on an object counts as up close) fix freeing a worn object when forced to drop it by falling down stairs +allow setting per-level "temperature": hot, cold, or temperate, currently + only affects some messages Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/doc/lua.adoc b/doc/lua.adoc index 8e0c7aaf6..a5032f093 100644 --- a/doc/lua.adoc +++ b/doc/lua.adoc @@ -532,6 +532,9 @@ Set flags for this level. | noflip | Prevent flipping the level. | noflipx | Prevent flipping the level horizontally. | noflipy | Prevent flipping the level vertically. +| hot | Level is hot. Dungeon flag "hellish" automatically sets this. +| cold | Level is cold. +| temperate | Level is neither hot nor cold. |=== Example: diff --git a/include/patchlevel.h b/include/patchlevel.h index 181788e0c..317d7b2d2 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -17,7 +17,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 69 +#define EDITLEVEL 70 /* * Development status possibilities. diff --git a/include/rm.h b/include/rm.h index bba37b89e..792f28727 100644 --- a/include/rm.h +++ b/include/rm.h @@ -386,6 +386,7 @@ struct levelflags { normal mode descendant of such) */ Bitfield(corrmaze, 1); /* Whether corridors are used for the maze rather than ROOM */ + schar temperature; /* +1 == hot, -1 == cold */ }; typedef struct { diff --git a/src/do.c b/src/do.c index 0ed523884..2461506a9 100644 --- a/src/do.c +++ b/src/do.c @@ -1360,6 +1360,7 @@ goto_level( char *annotation; int dist = depth(newlevel) - depth(&u.uz); boolean do_fall_dmg = FALSE; + schar prev_temperature = gl.level.flags.temperature; if (dunlev(newlevel) > dunlevs_in_dungeon(newlevel)) newlevel->dlevel = dunlevs_in_dungeon(newlevel); @@ -1711,8 +1712,7 @@ goto_level( display_nhwindow(WIN_MESSAGE, FALSE); #endif You_hear("groans and moans everywhere."); - } else - hellish_smoke_mesg(); /* "It is hot here. You smell smoke..." */ + } record_achievement(ACH_HELL); /* reached Gehennom */ } @@ -1759,9 +1759,6 @@ goto_level( } } else if (In_quest(&u.uz)) { onquest(); /* might be reaching locate|goal level */ - } else if (In_V_tower(&u.uz)) { - if (newdungeon && In_hell(&u.uz0)) - pline_The("heat and smoke are gone."); } else if (Is_knox(&u.uz)) { /* alarm stops working once Croesus has died */ if (new || !gm.mvitals[PM_CROESUS].died) { @@ -1803,6 +1800,17 @@ goto_level( } } + if (prev_temperature != gl.level.flags.temperature) { + if (gl.level.flags.temperature) + hellish_smoke_mesg(); + else if (prev_temperature > 0) + pline_The("heat %s gone.", + In_hell(&u.uz0) + ? "and smoke are" : "is"); + else if (prev_temperature < 0) + You("are out of the cold."); + } + /* this was originally done earlier; moved here to be logged after any achievement related to entering a dungeon branch [TODO: if an achievement for receiving quest call from leader @@ -1858,8 +1866,12 @@ RESTORE_WARNING_FORMAT_NONLITERAL void hellish_smoke_mesg(void) { - if (Inhell && !Is_valley(&u.uz)) - pline("It is hot here. You %s smoke...", + if (gl.level.flags.temperature) + pline("It is %s here.", + gl.level.flags.temperature > 0 ? "hot" : "cold"); + + if (In_hell(&u.uz) && gl.level.flags.temperature > 0) + pline("You %s smoke...", olfaction(gy.youmonst.data) ? "smell" : "sense"); } diff --git a/src/sp_lev.c b/src/sp_lev.c index 2a79b2ee7..61af4c58e 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -3694,6 +3694,12 @@ lspo_level_flags(lua_State *L) gc.coder->allow_flips &= ~1; else if (!strcmpi(s, "noflip")) gc.coder->allow_flips = 0; + else if (!strcmpi(s, "temperate")) + gl.level.flags.temperature = 0; + else if (!strcmpi(s, "hot")) + gl.level.flags.temperature = 1; + else if (!strcmpi(s, "cold")) + gl.level.flags.temperature = -1; else { char buf[BUFSZ]; Sprintf(buf, "Unknown level flag %s", s); @@ -6798,6 +6804,7 @@ sp_level_coder_init(void) (void) memset((genericptr_t) SpLev_Map, 0, sizeof SpLev_Map); gl.level.flags.is_maze_lev = 0; + gl.level.flags.temperature = In_hell(&u.uz) ? 1 : 0; reset_xystart_size();