From a4cbdf22a50a0f1b1d877d26ede47af06ccc6c71 Mon Sep 17 00:00:00 2001 From: Erik Lunna Date: Tue, 19 Sep 2023 23:25:09 +0200 Subject: [PATCH] Cleanup makekops and imported kop kommissioners (from SlashTHEM). While investigating issue #479, I discovered some of the kop code wasn't quite right. I had used some of the code from Unnethack but was able to adjust it back to the better 3.6. I also brought in the kommissioners because we had generals (for the black market summons) but no 5th level kop. --- hackem_changelog.txt | 1 + src/mondata.c | 1 + src/monst.c | 8 +++ src/shk.c | 117 ++++++++++++++++++++--------------------- win/share/monsters.txt | 19 +++++++ 5 files changed, 85 insertions(+), 61 deletions(-) diff --git a/hackem_changelog.txt b/hackem_changelog.txt index 4f30f5ef5..bc10c7062 100644 --- a/hackem_changelog.txt +++ b/hackem_changelog.txt @@ -5,6 +5,7 @@ Version 1.2.1 (unreleased) +Cleanup makekops and imported kop kommissioners (from SlashTHEM). Fix lightsaber deflection message (reported by Umbire). Fixes #480. fix #K4006 - 'null obj after quiver merge' panic (NetHack 3.7) Gave fire bolt a little to-hit boost. diff --git a/src/mondata.c b/src/mondata.c index 490e784d3..dac2135fa 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -1354,6 +1354,7 @@ static const short grownups[][2] = { { PM_KEYSTONE_KOP, PM_KOP_SERGEANT }, { PM_KOP_SERGEANT, PM_KOP_LIEUTENANT }, { PM_KOP_LIEUTENANT, PM_KOP_KAPTAIN }, + { PM_KOP_KAPTAIN, PM_KOP_KOMMISSIONER }, { PM_BABY_OWLBEAR, PM_OWLBEAR }, { PM_ARCTIC_FERN_SPROUT, PM_ARCTIC_FERN }, { PM_BLAZING_FERN_SPROUT, PM_BLAZING_FERN }, diff --git a/src/monst.c b/src/monst.c index b257cb850..d9626c885 100644 --- a/src/monst.c +++ b/src/monst.c @@ -4389,6 +4389,14 @@ struct permonst _mons2[] = { SIZ(WT_HUMAN, 200, MS_ARREST, MZ_HUMAN), 0, 0, M1_HUMANOID | M1_CARNIVORE, M2_WANDER | M2_HOSTILE | M2_STRONG | M2_MALE | M2_COLLECT | M2_FLANK, M3_ACCURATE | M3_INFRAVISIBLE, 0, MH_HUMAN, 6, HI_LORD), + MON("Kop Kommissioner", S_KOP, + LVL(10, 14, 10, 20, 12), (G_NOGEN), + A(ATTK(AT_WEAP, AD_PHYS, 2, 8), + NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), + SIZ(WT_HUMAN, 200, MS_ARREST, MZ_HUMAN), 0, 0, M1_HUMANOID | M1_CARNIVORE, + M2_WANDER | M2_HOSTILE | M2_STRONG | M2_MALE | M2_COLLECT | M2_FLANK, + M3_INFRAVISIBLE, 0, MH_HUMAN, 8, HI_LORD), + /* * Liches */ diff --git a/src/shk.c b/src/shk.c index ddc013e3c..8de3f40be 100644 --- a/src/shk.c +++ b/src/shk.c @@ -372,18 +372,12 @@ register boolean nearshop; Strcpy(kopname, "Keystone Kops"); - if (!shkp) + if (!shkp) return; - if (!Deaf) { + if (!Deaf) pline("An alarm sounds!"); - } - - nokops = ((mvitals[PM_KEYSTONE_KOP].mvflags & G_GONE) && - (mvitals[PM_KOP_SERGEANT].mvflags & G_GONE) && - (mvitals[PM_KOP_LIEUTENANT].mvflags & G_GONE) && - (mvitals[PM_KOP_KAPTAIN].mvflags & G_GONE)); - + if (Is_blackmarket(&u.uz)) { nokops = ((mvitals[PM_SOLDIER].mvflags & G_GONE) && (mvitals[PM_SERGEANT].mvflags & G_GONE) && @@ -392,33 +386,38 @@ register boolean nearshop; (mvitals[PM_GENERAL].mvflags & G_GONE)); Strcpy(kopname, "guards"); + } else { + nokops = ((mvitals[PM_KEYSTONE_KOP].mvflags & G_GONE) && + (mvitals[PM_KOP_SERGEANT].mvflags & G_GONE) && + (mvitals[PM_KOP_LIEUTENANT].mvflags & G_GONE) && + (mvitals[PM_KOP_KAPTAIN].mvflags & G_GONE) && + (mvitals[PM_KOP_KOMMISSIONER].mvflags & G_GONE)); } if (!angry_guards(!!Deaf) && nokops) { - if (flags.verbose && !Deaf) { + if (flags.verbose && !Deaf) pline("But no one seems to respond to it."); - } return; } - if (nokops) + if (nokops) return; if (nearshop) if (!Is_blackmarket(&u.uz)) { - /* Create swarm around you, if you merely "stepped out" */ - if (flags.verbose) - pline_The("%s appear!", kopname); - mm.x = u.ux; - mm.y = u.uy; - makekops(&mm); - return; - } + /* Create swarm around you, if you merely "stepped out" */ + if (flags.verbose) + pline_The("%s appear!", kopname); + mm.x = u.ux; + mm.y = u.uy; + makekops(&mm); + return; + } if (flags.verbose) pline_The("%s are after you!", kopname); - /* Create swarm near down staircase (hinders return to level) */ - + if (Is_blackmarket(&u.uz)) { + /* Create swarm near portal (hinders escape) */ struct trap *trap = ftrap; while (trap) { if (trap->ttyp == MAGIC_PORTAL) { @@ -428,10 +427,10 @@ register boolean nearshop; trap = trap->ntrap; } } else { + /* Create swarm near down staircase (hinders return to level) */ mm.x = xdnstair; mm.y = ydnstair; } - makekops(&mm); /* Create swarm near shopkeeper (hinders return to shop) */ mm.x = shkp->mx; @@ -439,7 +438,6 @@ register boolean nearshop; makekops(&mm); } - void blkmar_guards(mtmp) register struct monst *mtmp; @@ -5642,49 +5640,46 @@ register int fall; } } -/* modified by M. Campostrini (campo@sunthpi3.difi.unipi.it) */ -/* to allow for multiple choices of kops */ STATIC_OVL void makekops(mm) coord *mm; { - int kop_cnt[5]; - int kop_pm[5]; - int ik, cnt; - coord *mc; - - kop_pm[0] = PM_KEYSTONE_KOP; - kop_pm[1] = PM_KOP_SERGEANT; - kop_pm[2] = PM_KOP_LIEUTENANT; - kop_pm[3] = PM_KOP_KAPTAIN; - kop_pm[4] = 0; - - cnt = abs(depth(&u.uz)) + rnd(5); - + const int TYPES = 5; + short k_mndx[TYPES]; + int k_cnt[TYPES], cnt, mndx, k; if (Is_blackmarket(&u.uz)) { - kop_pm[0] = PM_SOLDIER; - kop_pm[1] = PM_SERGEANT; - kop_pm[2] = PM_LIEUTENANT; - kop_pm[3] = PM_CAPTAIN; - kop_pm[4] = 0; - - cnt = 7 + rnd(10); - } - - kop_cnt[0] = cnt; - kop_cnt[1] = (cnt / 3) + 1; /* at least one sarge */ - kop_cnt[2] = (cnt / 6); /* maybe a lieutenant */ - kop_cnt[3] = (cnt / 9); /* and maybe a kaptain */ - - mc = (coord *)alloc(cnt * sizeof(coord)); - for (ik=0; kop_pm[ik]; ik++) { - if (!(mvitals[kop_pm[ik]].mvflags & G_GONE)) { - cnt = epathto(mc, kop_cnt[ik], mm->x, mm->y, &mons[kop_pm[ik]]); - while (--cnt >= 0) - (void) makemon(&mons[kop_pm[ik]], mc[cnt].x, mc[cnt].y, NO_MM_FLAGS); - } + cnt = 7 + rnd(5); + k_mndx[0] = PM_SOLDIER; + k_mndx[1] = PM_SERGEANT; + k_mndx[2] = PM_LIEUTENANT; + k_mndx[3] = PM_CAPTAIN; + k_mndx[4] = PM_GENERAL; + } else { + cnt = abs(depth(&u.uz)) + rnd(5); + k_mndx[0] = PM_KEYSTONE_KOP; + k_mndx[1] = PM_KOP_SERGEANT; + k_mndx[2] = PM_KOP_LIEUTENANT; + k_mndx[3] = PM_KOP_KAPTAIN; + k_mndx[4] = PM_KOP_KOMMISSIONER; + } + + k_cnt[0] = cnt; + k_cnt[1] = (cnt / 3) + 1; /* at least one sarge */ + k_cnt[2] = (cnt / 6); /* maybe a lieutenant */ + k_cnt[3] = (cnt / 9); /* and maybe a kaptain */ + k_cnt[4] = (cnt / 12); /* and maybe a general */ + + for (k = 0; k < TYPES; k++) { + if ((cnt = k_cnt[k]) == 0) + break; + mndx = k_mndx[k]; + if (mvitals[mndx].mvflags & G_GONE) + continue; + + while (cnt--) + if (enexto(mm, mm->x, mm->y, &mons[mndx])) + (void) makemon(&mons[mndx], mm->x, mm->y, NO_MM_FLAGS); } - free((genericptr_t)mc); } void diff --git a/win/share/monsters.txt b/win/share/monsters.txt index bd6754568..58dfa562a 100644 --- a/win/share/monsters.txt +++ b/win/share/monsters.txt @@ -8639,6 +8639,25 @@ Z = (195, 195, 195) ..AA....AA...... ................ } +# tile 614 (Kop Kommissioner) +{ + ................ + ....AA.......... + ...ADDA......... + ...ADDA...C..... + ..AAAAAA..C..... + ...LLLL...C..... + ....LL....C..... + ...AAAA.AAA..... + ..AAAAAAAAC.P... + .AA.AAAAA.PPPP.. + ..AAAAAA.PPPPPP. + ....AAAAPPPAPP.. + .A.AAAAAAPAAA... + AAAAA.PAAAAA.... + ..AA....AA...... + ................ +} # tile 453 (lich) { ................