Level temperature affects monster generation

Hot levels generate more fire-resistant monsters, cold
levels cold-resistant ones.
This commit is contained in:
Pasi Kallinen
2023-12-18 13:40:58 +02:00
parent e4026d55fb
commit c0fdb2e8c4
2 changed files with 14 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
static boolean uncommon(int);
static int align_shift(struct permonst *);
static int temperature_shift(struct permonst *);
static boolean mk_gen_ok(int, unsigned, unsigned);
static boolean wrong_elem_type(struct permonst *);
static void m_initgrp(struct monst *, coordxy, coordxy, int, mmflags_nht);
@@ -1606,6 +1607,17 @@ align_shift(register struct permonst *ptr)
return alshift;
}
/* return larger value if monster prefers the level temperature */
static int
temperature_shift(struct permonst *ptr)
{
if (gl.level.flags.temperature
&& pm_resistance(ptr, (gl.level.flags.temperature > 0)
? MR_FIRE : MR_COLD))
return 3;
return 0;
}
/* select a random monster type */
struct permonst *
rndmonst(void)
@@ -1663,6 +1675,7 @@ rndmonst_adj(int minadj, int maxadj)
* potentially steal its spot.
*/
weight = (int) (ptr->geno & G_FREQ) + align_shift(ptr);
weight += temperature_shift(ptr);
if (weight < 0 || weight > 127) {
impossible("bad weight in rndmonst for mndx %d", mndx);
weight = 0;