From c0fdb2e8c47a67a44764d12012ab7bd4a28de161 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 18 Dec 2023 13:40:58 +0200 Subject: [PATCH] Level temperature affects monster generation Hot levels generate more fire-resistant monsters, cold levels cold-resistant ones. --- doc/fixes3-7-0.txt | 1 + src/makemon.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 001a5cee7..86eeb5f54 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1332,6 +1332,7 @@ demons cannot be frightened by showing them their reflection HP regeneration formula has changed, primarily to be less fast in the endgame riding negates stealth unless the steed is flying previous hero rising as undead in bones retains intrinsics +level temperature affects monster generation Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/makemon.c b/src/makemon.c index 26c0dadd3..f1ad1213a 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -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;