Skip to content

Commit

Permalink
Cleanup makekops and imported kop kommissioners (from SlashTHEM).
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
elunna committed Sep 19, 2023
1 parent 10ad7fa commit a4cbdf2
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 61 deletions.
1 change: 1 addition & 0 deletions hackem_changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/mondata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
8 changes: 8 additions & 0 deletions src/monst.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
117 changes: 56 additions & 61 deletions src/shk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand All @@ -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) {
Expand All @@ -428,18 +427,17 @@ 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;
mm.y = shkp->my;
makekops(&mm);
}


void
blkmar_guards(mtmp)
register struct monst *mtmp;
Expand Down Expand Up @@ -5642,49 +5640,46 @@ register int fall;
}
}

/* modified by M. Campostrini ([email protected]) */
/* 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
Expand Down
19 changes: 19 additions & 0 deletions win/share/monsters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
................
Expand Down

0 comments on commit a4cbdf2

Please sign in to comment.