From c0f5d2dd9286f1d7365483b70f62cf2f1c729474 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 23 Mar 2026 12:44:14 +0200 Subject: [PATCH] Allow monster level adjustments in special levels Add a new parameter to des.monster, m_lev_adj, which is a level adjustment for the monster. This only applies to the monster's level, so basically only affects the spellcasting, it does not change the monster's hit die or inventory. Change one of the shamans in Orctown to be 3 levels higher. --- dat/minetn-1.lua | 6 ++++-- doc/fixes3-7-0.txt | 1 + doc/lua.adoc | 1 + include/sp_lev.h | 1 + src/sp_lev.c | 9 +++++++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dat/minetn-1.lua b/dat/minetn-1.lua index 590817bf4..960553d4e 100644 --- a/dat/minetn-1.lua +++ b/dat/minetn-1.lua @@ -130,8 +130,10 @@ for i=1,5 + math.random(1 - 1,1*10) do end end -- shamans can be hanging out in/near the temple -for i=1,math.random(2 - 1,2*3) do - des.monster({ id = "orc shaman", coord = near_temple:rndcoord(0), peaceful=0 }); +-- one of the shamans is higher level +for i=1,math.random(1,6) do + des.monster({ id = "orc shaman", coord = near_temple:rndcoord(0), peaceful=0, + m_lev_adj = (i == 1) and 3 or 0 }); end -- these are not such a big deal -- to run into outside the bars diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index f4d2a35ca..9d7415ba5 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1588,6 +1588,7 @@ priest donation amounts are explicitly stated, randomized slightly, based on amulet of magical breathing increases power regeneration change some command keys, 'v' is now chronicle, 'V' is versionshort, m-prefix 'V' is longer version, remove key binding of #history +one orc-town shaman has a higher level, affecting spellcasting Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/doc/lua.adoc b/doc/lua.adoc index 3d03342b8..9cfa1cd8e 100644 --- a/doc/lua.adoc +++ b/doc/lua.adoc @@ -819,6 +819,7 @@ The hash parameter accepts the following keys: | stunned | boolean | | confused | boolean | | waiting | boolean | monster will wait until hero gets next to it +| m_lev_adj | integer | monster's level adjustment | tail | boolean | generate worm without a tail? | group | boolean | generate a group of monsters? | adjacentok | boolean | is adjacent location ok, if given one is not suitable? diff --git a/include/sp_lev.h b/include/sp_lev.h index 769c6a1c7..52e89978c 100644 --- a/include/sp_lev.h +++ b/include/sp_lev.h @@ -145,6 +145,7 @@ typedef struct { schar peaceful, asleep; short female, invis, cancelled, revived, avenge, fleeing, blinded, paralyzed, stunned, confused, waiting; + short m_lev_adj; long seentraps; short has_invent; mmflags_nht mm_flags; /* makemon flags */ diff --git a/src/sp_lev.c b/src/sp_lev.c index 2e1b4ab65..d6324827e 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -2165,6 +2165,14 @@ create_monster(monster *m, struct mkroom *croom) if (vampshifted(mtmp) && m->appear != M_AP_MONSTER) (void) newcham(mtmp, &mons[mtmp->cham], NO_NC_FLAGS); } + if (m->m_lev_adj) { + if (mtmp->m_lev + m->m_lev_adj > 49) + mtmp->m_lev = 49; + else if (mtmp->m_lev + m->m_lev_adj < 0) + mtmp->m_lev = 0; + else + mtmp->m_lev += m->m_lev_adj; + } if (!(m->has_invent & DEFAULT_INVENT)) { /* guard against someone accidentally specifying e.g. quest nemesis * with custom inventory that lacks Bell or quest artifact but @@ -3298,6 +3306,7 @@ lspo_monster(lua_State *L) tmpmons.stunned = get_table_boolean_opt(L, "stunned", FALSE); tmpmons.confused = get_table_boolean_opt(L, "confused", FALSE); tmpmons.waiting = get_table_boolean_opt(L, "waiting", FALSE); + tmpmons.m_lev_adj = get_table_int_opt(L, "m_lev_adj", 0); tmpmons.seentraps = 0; /* TODO: list of trap names to bitfield */ keep_default_invent = get_table_boolean_opt(L, "keep_default_invent", -1);