1 /* SCCS Id: @(#)minion.c 3.4 2003/01/09 */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
10 msummon(mon) /* mon summons a monster */
13 register struct permonst *ptr;
14 register int dtype = NON_PM, cnt = 0;
20 atyp = (ptr->maligntyp==A_NONE) ? A_NONE : sgn(ptr->maligntyp);
21 if (mon->ispriest || mon->data == &mons[PM_ALIGNED_PRIEST]
22 || mon->data == &mons[PM_ANGEL])
23 atyp = EPRI(mon)->shralign;
25 ptr = &mons[PM_WIZARD_OF_YENDOR];
26 atyp = (ptr->maligntyp==A_NONE) ? A_NONE : sgn(ptr->maligntyp);
29 if (is_dprince(ptr) || (ptr == &mons[PM_WIZARD_OF_YENDOR])) {
30 dtype = (!rn2(20)) ? dprince(atyp) :
31 (!rn2(4)) ? dlord(atyp) : ndemon(atyp);
32 cnt = (!rn2(4) && is_ndemon(&mons[dtype])) ? 2 : 1;
33 } else if (is_dlord(ptr)) {
34 dtype = (!rn2(50)) ? dprince(atyp) :
35 (!rn2(20)) ? dlord(atyp) : ndemon(atyp);
36 cnt = (!rn2(4) && is_ndemon(&mons[dtype])) ? 2 : 1;
37 } else if (is_ndemon(ptr)) {
38 dtype = (!rn2(20)) ? dlord(atyp) :
39 (!rn2(6)) ? ndemon(atyp) : monsndx(ptr);
41 } else if (is_lminion(mon)) {
42 dtype = (is_lord(ptr) && !rn2(20)) ? llord() :
43 (is_lord(ptr) || !rn2(6)) ? lminion() : monsndx(ptr);
44 cnt = (!rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1;
45 } else if (ptr == &mons[PM_ANGEL]) {
46 /* non-lawful angels can also summon */
48 switch (atyp) { /* see summon_minion */
50 dtype = PM_AIR_ELEMENTAL + rn2(4);
60 cnt = (!rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1;
63 if (dtype == NON_PM) return;
66 if (cnt > 1 && (mons[dtype].geno & G_UNIQ)) cnt = 1;
68 * If this daemon is unique and being re-summoned (the only way we
69 * could get this far with an extinct dtype), try another.
71 if (mvitals[dtype].mvflags & G_GONE) {
73 if (dtype == NON_PM) return;
77 mtmp = makemon(&mons[dtype], u.ux, u.uy, NO_MM_FLAGS);
78 if (mtmp && (dtype == PM_ANGEL)) {
79 /* alignment should match the summoner */
80 EPRI(mtmp)->shralign = atyp;
87 summon_minion(alignment, talk)
91 register struct monst *mon;
94 switch ((int)alignment) {
99 mnum = PM_AIR_ELEMENTAL + rn2(4);
103 mnum = ndemon(alignment);
106 impossible("unaligned player?");
107 mnum = ndemon(A_NONE);
110 if (mnum == NON_PM) {
112 } else if (mons[mnum].pxlth == 0) {
113 struct permonst *pm = &mons[mnum];
114 mon = makemon(pm, u.ux, u.uy, MM_EMIN);
116 mon->isminion = TRUE;
117 EMIN(mon)->min_align = alignment;
119 } else if (mnum == PM_ANGEL) {
120 mon = makemon(&mons[mnum], u.ux, u.uy, NO_MM_FLAGS);
122 mon->isminion = TRUE;
123 EPRI(mon)->shralign = alignment; /* always A_LAWFUL here */
126 mon = makemon(&mons[mnum], u.ux, u.uy, NO_MM_FLAGS);
129 pline_The("voice of %s booms:", align_gname(alignment));
130 verbalize("Thou shalt pay for thy indiscretion!");
132 pline("%s appears before you.", Amonnam(mon));
134 mon->mpeaceful = FALSE;
135 /* don't call set_malign(); player was naughty */
139 #define Athome (Inhell && !mtmp->cham)
142 demon_talk(mtmp) /* returns 1 if it won't attack. */
143 register struct monst *mtmp;
145 long cash, demand, offer;
147 if (uwep && uwep->oartifact == ART_EXCALIBUR) {
148 pline("%s looks very angry.", Amonnam(mtmp));
149 mtmp->mpeaceful = mtmp->mtame = 0;
151 newsym(mtmp->mx, mtmp->my);
155 /* Slight advantage given. */
156 if (is_dprince(mtmp->data) && mtmp->minvis) {
157 mtmp->minvis = mtmp->perminvis = 0;
158 if (!Blind) pline("%s appears before you.", Amonnam(mtmp));
159 newsym(mtmp->mx,mtmp->my);
161 if (youmonst.data->mlet == S_DEMON) { /* Won't blackmail their own. */
162 pline("%s says, \"Good hunting, %s.\"",
163 Amonnam(mtmp), flags.female ? "Sister" : "Brother");
164 if (!tele_restrict(mtmp)) (void) rloc(mtmp, FALSE);
170 cash = money_cnt(invent);
172 demand = (cash * (rnd(80) + 20 * Athome)) /
173 (100 * (1 + (sgn(u.ualign.type) == sgn(mtmp->data->maligntyp))));
175 if (!demand) { /* you have no gold */
180 /* make sure that the demand is unmeetable if the monster
181 has the Amulet, preventing monster from being satisified
182 and removed from the game (along with said Amulet...) */
183 if (mon_has_amulet(mtmp))
184 demand = cash + (long)rn1(1000,40);
186 pline("%s demands %ld %s for safe passage.",
187 Amonnam(mtmp), demand, currency(demand));
189 if ((offer = bribe(mtmp)) >= demand) {
190 pline("%s vanishes, laughing about cowardly mortals.",
192 } else if (offer > 0L && (long)rnd(40) > (demand - offer)) {
193 pline("%s scowls at you menacingly, then vanishes.",
196 pline("%s gets angry...", Amonnam(mtmp));
213 long umoney = money_cnt(invent);
216 getlin("How much will you offer?", buf);
217 if (sscanf(buf, "%ld", &offer) != 1) offer = 0L;
219 /*Michael Paddon -- fix for negative offer to monster*/
222 You("try to shortchange %s, but fumble.",
225 } else if (offer == 0L) {
229 } else if (offer >= u.ugold) {
230 You("give %s all your gold.", mon_nam(mtmp));
233 You("give %s %ld %s.", mon_nam(mtmp), offer, currency(offer));
236 mtmp->mgold += offer;
238 } else if (offer >= umoney) {
239 You("give %s all your gold.", mon_nam(mtmp));
242 You("give %s %ld %s.", mon_nam(mtmp), offer, currency(offer));
244 (void) money2mon(mtmp, offer);
256 for (tryct = 0; tryct < 20; tryct++) {
257 pm = rn1(PM_DEMOGORGON + 1 - PM_ORCUS, PM_ORCUS);
258 if (!(mvitals[pm].mvflags & G_GONE) &&
259 (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
262 return(dlord(atyp)); /* approximate */
271 for (tryct = 0; tryct < 20; tryct++) {
272 pm = rn1(PM_YEENOGHU + 1 - PM_JUIBLEX, PM_JUIBLEX);
273 if (!(mvitals[pm].mvflags & G_GONE) &&
274 (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
277 return(ndemon(atyp)); /* approximate */
280 /* create lawful (good) lord */
284 if (!(mvitals[PM_ARCHON].mvflags & G_GONE))
287 return(lminion()); /* approximate */
294 struct permonst *ptr;
296 for (tryct = 0; tryct < 20; tryct++) {
297 ptr = mkclass(S_ANGEL,0);
298 if (ptr && !is_lord(ptr))
299 return(monsndx(ptr));
310 struct permonst *ptr;
312 for (tryct = 0; tryct < 20; tryct++) {
313 ptr = mkclass(S_DEMON, 0);
314 if (ptr && is_ndemon(ptr) &&
315 (atyp == A_NONE || sgn(ptr->maligntyp) == sgn(atyp)))
316 return(monsndx(ptr));