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.
This commit is contained in:
Pasi Kallinen
2026-03-23 12:44:14 +02:00
parent 1ba9be09fa
commit c0f5d2dd92
5 changed files with 16 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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?

View File

@@ -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 */

View File

@@ -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);