-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
5 changed files
with
85 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,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; | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters