Source:SLASH'EM 0.0.7E7F2/mondata.c

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to mondata.c from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[Source:SLASH'EM 0.0.7E7F2/mondata.c#line123]], for example.

Source code for vanilla NetHack is at Source code.


The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1.    /*	SCCS Id: @(#)mondata.c	3.4	2003/06/02	*/
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    #include "hack.h"
6.    #include "eshk.h"
7.    #include "epri.h"
8.    
9.    /*	These routines provide basic data for any type of monster. */
10.   
11.   #ifdef OVLB
12.   
13.   void
14.   set_mon_data(mon, ptr, flag)
15.   struct monst *mon;
16.   struct permonst *ptr;
17.   int flag;
18.   {
19.       mon->data = ptr;
20.       if (flag == -1) return;		/* "don't care" */
21.   
22.       if (flag == 1)
23.   	mon->mintrinsics |= (ptr->mresists & MR_TYPEMASK);
24.       else
25.   	mon->mintrinsics = (ptr->mresists & MR_TYPEMASK);
26.       return;
27.   }
28.   
29.   #endif /* OVLB */
30.   #ifdef OVL0
31.   
32.   struct attack *
33.   attacktype_fordmg(ptr, atyp, dtyp)
34.   struct permonst *ptr;
35.   int atyp, dtyp;
36.   {
37.       struct attack *a;
38.   
39.       for (a = &ptr->mattk[0]; a < &ptr->mattk[NATTK]; a++)
40.   	if (a->aatyp == atyp && (dtyp == AD_ANY || a->adtyp == dtyp))
41.   	    return a;
42.   
43.       return (struct attack *)0;
44.   }
45.   
46.   boolean
47.   attacktype(ptr, atyp)
48.   struct permonst *ptr;
49.   int atyp;
50.   {
51.       return attacktype_fordmg(ptr, atyp, AD_ANY) ? TRUE : FALSE;
52.   }
53.   
54.   #endif /* OVL0 */
55.   #ifdef OVLB
56.   
57.   boolean
58.   poly_when_stoned(ptr)
59.       struct permonst *ptr;
60.   {
61.       return((boolean)(is_golem(ptr) && ptr != &mons[PM_STONE_GOLEM] &&
62.   	    !(mvitals[PM_STONE_GOLEM].mvflags & G_GENOD)));
63.   	    /* allow G_EXTINCT */
64.   }
65.   
66.   boolean
67.   resists_drli(mon)	/* returns TRUE if monster is drain-life resistant */
68.   struct monst *mon;
69.   {
70.   	struct permonst *ptr = mon->data;
71.   	struct obj *wep = ((mon == &youmonst) ? uwep : MON_WEP(mon));
72.   
73.   	return (boolean)(is_undead(ptr) || is_demon(ptr) || is_were(ptr) ||
74.   			 ptr == &mons[PM_DEATH] || is_golem(ptr) ||
75.   			 resists_drain(mon) ||
76.   			 (wep && wep->oartifact && defends(AD_DRLI, wep)));
77.   }
78.   
79.   boolean
80.   resists_magm(mon)	/* TRUE if monster is magic-missile resistant */
81.   struct monst *mon;
82.   {
83.   	struct permonst *ptr = mon->data;
84.   	struct obj *o;
85.   
86.   	/* as of 3.2.0:  gray dragons, Angels, Oracle, Yeenoghu */
87.   	if (dmgtype(ptr, AD_MAGM) || ptr == &mons[PM_BABY_GRAY_DRAGON] ||
88.   		dmgtype(ptr, AD_RBRE))	/* Chromatic Dragon */
89.   	    return TRUE;
90.   	/* check for magic resistance granted by wielded weapon */
91.   	o = (mon == &youmonst) ? uwep : MON_WEP(mon);
92.   	if (o && o->oartifact && defends(AD_MAGM, o))
93.   	    return TRUE;
94.   	/* check for magic resistance granted by worn or carried items */
95.   	o = (mon == &youmonst) ? invent : mon->minvent;
96.   	for ( ; o; o = o->nobj)
97.   	    if ((o->owornmask && objects[o->otyp].oc_oprop == ANTIMAGIC) ||
98.   		    (o->oartifact && protects(AD_MAGM, o)))
99.   		return TRUE;
100.  	return FALSE;
101.  }
102.  
103.  /* TRUE iff monster is resistant to light-induced blindness */
104.  boolean
105.  resists_blnd(mon)
106.  struct monst *mon;
107.  {
108.  	struct permonst *ptr = mon->data;
109.  	boolean is_you = (mon == &youmonst);
110.  	struct obj *o;
111.  
112.  	if (is_you ? (Blind || u.usleep) :
113.  		(mon->mblinded || !mon->mcansee || !haseyes(ptr) ||
114.  		    /* BUG: temporary sleep sets mfrozen, but since
115.  			    paralysis does too, we can't check it */
116.  		    mon->msleeping))
117.  	    return TRUE;
118.  	/* yellow light, Archon; !dust vortex, !cobra, !raven */
119.  	if (dmgtype_fromattack(ptr, AD_BLND, AT_EXPL) ||
120.  		dmgtype_fromattack(ptr, AD_BLND, AT_GAZE))
121.  	    return TRUE;
122.  	o = is_you ? uwep : MON_WEP(mon);
123.  	if (o && o->oartifact && defends(AD_BLND, o))
124.  	    return TRUE;
125.  	o = is_you ? invent : mon->minvent;
126.  	for ( ; o; o = o->nobj)
127.  	    if ((o->owornmask && objects[o->otyp].oc_oprop == BLINDED) ||
128.  		    (o->oartifact && protects(AD_BLND, o)))
129.  		return TRUE;
130.  	return FALSE;
131.  }
132.  
133.  /* TRUE iff monster can be blinded by the given attack */
134.  /* Note: may return TRUE when mdef is blind (e.g. new cream-pie attack) */
135.  boolean
136.  can_blnd(magr, mdef, aatyp, obj)
137.  struct monst *magr;		/* NULL == no specific aggressor */
138.  struct monst *mdef;
139.  uchar aatyp;
140.  struct obj *obj;		/* aatyp == AT_WEAP, AT_SPIT */
141.  {
142.  	boolean is_you = (mdef == &youmonst);
143.  	boolean check_visor = FALSE;
144.  	struct obj *o;
145.  	const char *s;
146.  
147.  	/* no eyes protect against all attacks for now */
148.  	if (!haseyes(mdef->data))
149.  	    return FALSE;
150.  
151.  	switch(aatyp) {
152.  	case AT_EXPL: case AT_BOOM: case AT_GAZE: case AT_MAGC:
153.  	case AT_BREA: /* assumed to be lightning */
154.  	    /* light-based attacks may be cancelled or resisted */
155.  	    if (magr && magr->mcan)
156.  		return FALSE;
157.  	    return !resists_blnd(mdef);
158.  
159.  	case AT_WEAP: case AT_SPIT: case AT_NONE:
160.  	    /* an object is used (thrown/spit/other) */
161.  	    if (obj && (obj->otyp == CREAM_PIE)) {
162.  		if (is_you && Blindfolded)
163.  		    return FALSE;
164.  	    } else if (obj && (obj->otyp == BLINDING_VENOM)) {
165.  		/* all ublindf, including LENSES, protect, cream-pies too */
166.  		if (is_you && (ublindf || u.ucreamed))
167.  		    return FALSE;
168.  		check_visor = TRUE;
169.  	    } else if (obj && (obj->otyp == POT_BLINDNESS)) {
170.  		return TRUE;	/* no defense */
171.  	    } else
172.  		return FALSE;	/* other objects cannot cause blindness yet */
173.  	    if ((magr == &youmonst) && u.uswallow)
174.  		return FALSE;	/* can't affect eyes while inside monster */
175.  	    break;
176.  
177.  	case AT_ENGL:
178.  	    if (is_you && (Blindfolded || u.usleep || u.ucreamed))
179.  		return FALSE;
180.  	    if (!is_you && mdef->msleeping)
181.  		return FALSE;
182.  	    break;
183.  
184.  	case AT_CLAW:
185.  	    /* e.g. raven: all ublindf, including LENSES, protect */
186.  	    if (is_you && ublindf)
187.  		return FALSE;
188.  	    if ((magr == &youmonst) && u.uswallow)
189.  		return FALSE;	/* can't affect eyes while inside monster */
190.  	    check_visor = TRUE;
191.  	    break;
192.  
193.  	case AT_TUCH: case AT_STNG:
194.  	    /* some physical, blind-inducing attacks can be cancelled */
195.  	    if (magr && magr->mcan)
196.  		return FALSE;
197.  	    break;
198.  
199.  	default:
200.  	    break;
201.  	}
202.  
203.  	/* check if wearing a visor (only checked if visor might help) */
204.  	if (check_visor) {
205.  	    o = (mdef == &youmonst) ? invent : mdef->minvent;
206.  	    for ( ; o; o = o->nobj)
207.  		if ((o->owornmask & W_ARMH) &&
208.  		    (s = OBJ_DESCR(objects[o->otyp])) != (char *)0 &&
209.  		    !strcmp(s, "visored helmet"))
210.  		    return FALSE;
211.  	}
212.  
213.  	return TRUE;
214.  }
215.  
216.  #endif /* OVLB */
217.  #ifdef OVL0
218.  
219.  boolean
220.  ranged_attk(ptr)	/* returns TRUE if monster can attack at range */
221.  struct permonst *ptr;
222.  {
223.  	register int i, atyp;
224.  	long atk_mask = (1L << AT_BREA) | (1L << AT_SPIT) | (1L << AT_GAZE);
225.  
226.  	/* was: (attacktype(ptr, AT_BREA) || attacktype(ptr, AT_WEAP) ||
227.  		attacktype(ptr, AT_SPIT) || attacktype(ptr, AT_GAZE) ||
228.  		attacktype(ptr, AT_MAGC));
229.  	   but that's too slow -dlc
230.  	 */
231.  	for(i = 0; i < NATTK; i++) {
232.  	    atyp = ptr->mattk[i].aatyp;
233.  	    if (atyp >= AT_WEAP) return TRUE;
234.  	 /* assert(atyp < 32); */
235.  	    if ((atk_mask & (1L << atyp)) != 0L) return TRUE;
236.  	}
237.  
238.  	return FALSE;
239.  }
240.  
241.  /* true iff the type of monster pass through iron bars */
242.  boolean
243.  passes_bars(mptr)
244.  struct permonst *mptr;
245.  {
246.      return (boolean) (passes_walls(mptr) || amorphous(mptr) ||
247.  		      is_whirly(mptr) || verysmall(mptr) ||
248.  		      (slithy(mptr) && !bigmonst(mptr)));
249.  }
250.  
251.  #endif /* OVL0 */
252.  #ifdef OVL1
253.  
254.  boolean
255.  can_track(ptr)		/* returns TRUE if monster can track well */
256.  	register struct permonst *ptr;
257.  {
258.  	if (uwep && uwep->oartifact == ART_EXCALIBUR)
259.  		return TRUE;
260.  	else
261.  		return((boolean)haseyes(ptr));
262.  }
263.  
264.  #endif /* OVL1 */
265.  #ifdef OVLB
266.  
267.  boolean
268.  sliparm(ptr)	/* creature will slide out of armor */
269.  	register struct permonst *ptr;
270.  {
271.  	return((boolean)(is_whirly(ptr) || ptr->msize <= MZ_SMALL ||
272.  			 noncorporeal(ptr)));
273.  }
274.  
275.  boolean
276.  breakarm(ptr)	/* creature will break out of armor */
277.  	register struct permonst *ptr;
278.  {
279.  	return ((bigmonst(ptr) || (ptr->msize > MZ_SMALL && !humanoid(ptr)) ||
280.  		/* special cases of humanoids that cannot wear body armor */
281.  		ptr == &mons[PM_MARILITH] || ptr == &mons[PM_WINGED_GARGOYLE])
282.  	      && !sliparm(ptr));
283.  }
284.  #endif /* OVLB */
285.  #ifdef OVL1
286.  
287.  boolean
288.  sticks(ptr)	/* creature sticks other creatures it hits */
289.  	register struct permonst *ptr;
290.  {
291.  	return((boolean)(dmgtype(ptr,AD_STCK) || dmgtype(ptr,AD_WRAP) ||
292.  		attacktype(ptr,AT_HUGS)));
293.  }
294.  
295.  /* number of horns this type of monster has on its head */
296.  int
297.  num_horns(ptr)
298.  struct permonst *ptr;
299.  {
300.      switch (monsndx(ptr)) {
301.      case PM_LAMB:
302.      case PM_SHEEP:
303.      case PM_GOAT:
304.      case PM_COW:
305.      case PM_BULL:
306.      case PM_HORNED_DEVIL:	/* ? "more than one" */
307.      case PM_MINOTAUR:
308.      case PM_ASMODEUS:
309.      case PM_BALROG:
310.  	return 2;
311.      case PM_WHITE_UNICORN:
312.      case PM_GRAY_UNICORN:
313.      case PM_BLACK_UNICORN:
314.      case PM_KI_RIN:
315.  	return 1;
316.      default:
317.  	break;
318.      }
319.      return 0;
320.  }
321.  
322.  struct attack *
323.  dmgtype_fromattack(ptr, dtyp, atyp)
324.  struct permonst *ptr;
325.  int dtyp, atyp;
326.  {
327.      struct attack *a;
328.  
329.      for (a = &ptr->mattk[0]; a < &ptr->mattk[NATTK]; a++)
330.  	if (a->adtyp == dtyp && (atyp == AT_ANY || a->aatyp == atyp))
331.  	    return a;
332.  
333.      return (struct attack *)0;
334.  }
335.  
336.  boolean
337.  dmgtype(ptr, dtyp)
338.  struct permonst *ptr;
339.  int dtyp;
340.  {
341.      return dmgtype_fromattack(ptr, dtyp, AT_ANY) ? TRUE : FALSE;
342.  }
343.  
344.  /* returns the maximum damage a defender can do to the attacker via
345.   * a passive defense */
346.  int
347.  max_passive_dmg(mdef, magr)
348.      register struct monst *mdef, *magr;
349.  {
350.      int	i, dmg = 0;
351.      uchar adtyp;
352.  
353.      for(i = 0; i < NATTK; i++)
354.  	if(mdef->data->mattk[i].aatyp == AT_NONE ||
355.  		mdef->data->mattk[i].aatyp == AT_BOOM) {
356.  	    adtyp = mdef->data->mattk[i].adtyp;
357.  	    if ((adtyp == AD_ACID && !resists_acid(magr)) ||
358.  		    (adtyp == AD_COLD && !resists_cold(magr)) ||
359.  		    (adtyp == AD_FIRE && !resists_fire(magr)) ||
360.  		    (adtyp == AD_ELEC && !resists_elec(magr)) ||
361.  		    adtyp == AD_PHYS) {
362.  		dmg = mdef->data->mattk[i].damn;
363.  		if(!dmg) dmg = mdef->data->mlevel+1;
364.  		dmg *= mdef->data->mattk[i].damd;
365.  	    } else dmg = 0;
366.  
367.  	    return dmg;
368.  	}
369.      return 0;
370.  }
371.  
372.  #endif /* OVL1 */
373.  #ifdef OVL0
374.  
375.  int
376.  monsndx(ptr)		/* return an index into the mons array */
377.  	struct	permonst	*ptr;
378.  {
379.  	register int	i;
380.  
381.  	if (ptr == &upermonst) return PM_PLAYERMON;
382.  
383.  	i = (int)(ptr - &mons[0]);
384.  	if (i < LOW_PM || i >= NUMMONS) {
385.  		/* ought to switch this to use `fmt_ptr' */
386.  	    panic("monsndx - could not index monster (%d)",
387.  		  i);
388.  	    return NON_PM;		/* will not get here */
389.  	}
390.  
391.  	return(i);
392.  }
393.  
394.  #endif /* OVL0 */
395.  #ifdef OVL1
396.  
397.  
398.  int
399.  name_to_mon(in_str)
400.  const char *in_str;
401.  {
402.  	/* Be careful.  We must check the entire string in case it was
403.  	 * something such as "ettin zombie corpse".  The calling routine
404.  	 * doesn't know about the "corpse" until the monster name has
405.  	 * already been taken off the front, so we have to be able to
406.  	 * read the name with extraneous stuff such as "corpse" stuck on
407.  	 * the end.
408.  	 * This causes a problem for names which prefix other names such
409.  	 * as "ettin" on "ettin zombie".  In this case we want the _longest_
410.  	 * name which exists.
411.  	 * This also permits plurals created by adding suffixes such as 's'
412.  	 * or 'es'.  Other plurals must still be handled explicitly.
413.  	 */
414.  	register int i;
415.  	register int mntmp = NON_PM;
416.  	register char *s, *str, *term;
417.  	char buf[BUFSZ];
418.  	int len, slen;
419.  
420.  	str = strcpy(buf, in_str);
421.  
422.  	if (!strncmp(str, "a ", 2)) str += 2;
423.  	else if (!strncmp(str, "an ", 3)) str += 3;
424.  
425.  	slen = strlen(str);
426.  	term = str + slen;
427.  
428.  	if ((s = strstri(str, "vortices")) != 0)
429.  	    Strcpy(s+4, "ex");
430.  	/* be careful with "ies"; "priest", "zombies" */
431.  	else if (slen > 3 && !strcmpi(term-3, "ies") &&
432.  		    (slen < 7 || strcmpi(term-7, "zombies")))
433.  	    Strcpy(term-3, "y");
434.  	/* luckily no monster names end in fe or ve with ves plurals */
435.  	else if (slen > 3 && !strcmpi(term-3, "ves"))
436.  	    Strcpy(term-3, "f");
437.  
438.  	slen = strlen(str); /* length possibly needs recomputing */
439.  
440.      {
441.  	static const struct alt_spl { const char* name; short pm_val; }
442.  	    names[] = {
443.  	    /* Alternate spellings */
444.  		{ "grey dragon",	PM_GRAY_DRAGON },
445.  		{ "baby grey dragon",	PM_BABY_GRAY_DRAGON },
446.  		{ "grey unicorn",	PM_GRAY_UNICORN },
447.  		{ "grey ooze",		PM_GRAY_OOZE },
448.  		{ "gray-elf",		PM_GREY_ELF },
449.  		{ "mindflayer",         PM_MIND_FLAYER },
450.  		{ "master mindflayer",  PM_MASTER_MIND_FLAYER },
451.  	    /* Hyphenated names */
452.  		{ "ki rin",		PM_KI_RIN },
453.  		{ "uruk hai",		PM_URUK_HAI },
454.  		{ "orc captain",	PM_ORC_CAPTAIN },
455.  		{ "woodland elf",	PM_WOODLAND_ELF },
456.  		{ "green elf",		PM_GREEN_ELF },
457.  		{ "grey elf",		PM_GREY_ELF },
458.  		{ "gray elf",		PM_GREY_ELF },
459.  		{ "elf lord",		PM_ELF_LORD },
460.  #if 0	/* OBSOLETE */
461.  		{ "high elf",		PM_HIGH_ELF },
462.  #endif
463.  		{ "olog hai",		PM_OLOG_HAI },
464.  		{ "arch lich",		PM_ARCH_LICH },
465.  	    /* Some irregular plurals */
466.  		{ "incubi",		PM_INCUBUS },
467.  		{ "succubi",		PM_SUCCUBUS },
468.  		{ "violet fungi",	PM_VIOLET_FUNGUS },
469.  		{ "homunculi",		PM_HOMUNCULUS },
470.  		{ "baluchitheria",	PM_BALUCHITHERIUM },
471.  		{ "lurkers above",	PM_LURKER_ABOVE },
472.  		{ "cavemen",		PM_CAVEMAN },
473.  		{ "cavewomen",		PM_CAVEWOMAN },
474.  #ifndef ZOUTHERN
475.  /*		{ "zruties",            PM_ZRUTY },*/
476.  #endif
477.  		{ "djinn",		PM_DJINNI },
478.  		{ "mumakil",		PM_MUMAK },
479.  		{ "erinyes",		PM_ERINYS },
480.  		{ "giant lice",         PM_GIANT_LOUSE },	/* RJ */
481.  	    /* falsely caught by -ves check above */
482.  		{ "master of thief",	PM_MASTER_OF_THIEVES },
483.  	    /* end of list */
484.  		{ 0, 0 }
485.  	};
486.  	register const struct alt_spl *namep;
487.  
488.  	for (namep = names; namep->name; namep++)
489.  	    if (!strncmpi(str, namep->name, (int)strlen(namep->name)))
490.  		return namep->pm_val;
491.      }
492.  
493.  	for (len = 0, i = LOW_PM; i < NUMMONS; i++) {
494.  	    register int m_i_len = strlen(mons[i].mname);
495.  	    if (m_i_len > len && !strncmpi(mons[i].mname, str, m_i_len)) {
496.  		if (m_i_len == slen) return i;	/* exact match */
497.  		else if (slen > m_i_len &&
498.  			(str[m_i_len] == ' ' ||
499.  			 !strcmpi(&str[m_i_len], "s") ||
500.  			 !strncmpi(&str[m_i_len], "s ", 2) ||
501.  			 !strcmpi(&str[m_i_len], "'") ||
502.  			 !strncmpi(&str[m_i_len], "' ", 2) ||
503.  			 !strcmpi(&str[m_i_len], "'s") ||
504.  			 !strncmpi(&str[m_i_len], "'s ", 3) ||
505.  			 !strcmpi(&str[m_i_len], "es") ||
506.  			 !strncmpi(&str[m_i_len], "es ", 3))) {
507.  		    mntmp = i;
508.  		    len = m_i_len;
509.  		}
510.  	    }
511.  	}
512.  	if (mntmp == NON_PM) mntmp = title_to_mon(str, (int *)0, (int *)0);
513.  	return mntmp;
514.  }
515.  
516.  #endif /* OVL1 */
517.  #ifdef OVL2
518.  
519.  /* returns 3 values (0=male, 1=female, 2=none) */
520.  int
521.  gender(mtmp)
522.  register struct monst *mtmp;
523.  {
524.  	if (is_neuter(mtmp->data)) return 2;
525.  	return mtmp->female;
526.  }
527.  
528.  /* Like gender(), but lower animals and such are still "it". */
529.  /* This is the one we want to use when printing messages. */
530.  int
531.  pronoun_gender(mtmp)
532.  register struct monst *mtmp;
533.  {
534.  	if (!mtmp->isshk && (is_neuter(mtmp->data) || !canspotmon(mtmp))) return 2;
535.  	return (humanoid(mtmp->data) || (mtmp->data->geno & G_UNIQ) ||
536.  		type_is_pname(mtmp->data)) ? (int)mtmp->female : 2;
537.  }
538.  
539.  #endif /* OVL2 */
540.  #ifdef OVLB
541.  
542.  /* used for nearby monsters when you go to another level */
543.  boolean
544.  levl_follower(mtmp)
545.  struct monst *mtmp;
546.  {
547.  	/* monsters with the Amulet--even pets--won't follow across levels */
548.  	if (mon_has_amulet(mtmp)) return FALSE;
549.  
550.  	/* some monsters will follow even while intending to flee from you */
551.  	if (mtmp->mtame || mtmp->iswiz || is_fshk(mtmp)) return TRUE;
552.  
553.  	/* stalking types follow, but won't when fleeing unless you hold
554.  	   the Amulet */
555.  	return (boolean)((mtmp->data->mflags2 & M2_STALK) &&
556.  				(!mtmp->mflee || u.uhave.amulet));
557.  }
558.  
559.  static const short grownups[][2] = {
560.  	{PM_LITTLE_DOG, PM_DOG}, {PM_DOG, PM_LARGE_DOG},
561.  	{PM_HELL_HOUND_PUP, PM_HELL_HOUND},
562.  	{PM_KITTEN, PM_HOUSECAT}, {PM_HOUSECAT, PM_LARGE_CAT},
563.  	{PM_KOBOLD, PM_LARGE_KOBOLD}, {PM_LARGE_KOBOLD, PM_KOBOLD_LORD},
564.  	{PM_GNOME, PM_GNOME_LORD}, {PM_GNOME_LORD, PM_GNOME_WARRIOR},
565.  	{PM_DWARF, PM_DWARF_LORD}, {PM_DWARF_LORD, PM_DWARF_KING},
566.  	{PM_MIND_FLAYER, PM_MASTER_MIND_FLAYER},
567.  	{PM_ORC, PM_ORC_CAPTAIN}, {PM_HILL_ORC, PM_ORC_CAPTAIN},
568.  	{PM_MORDOR_ORC, PM_ORC_CAPTAIN}, {PM_URUK_HAI, PM_ORC_CAPTAIN},
569.  	{PM_SEWER_RAT, PM_GIANT_RAT},
570.  	{PM_CAVE_SPIDER, PM_GIANT_SPIDER},
571.  	{PM_OGRE, PM_OGRE_LORD}, {PM_OGRE_LORD, PM_OGRE_KING},
572.  	{PM_ELF, PM_ELF_LORD}, {PM_WOODLAND_ELF, PM_ELF_LORD},
573.  	{PM_GREEN_ELF, PM_ELF_LORD}, {PM_GREY_ELF, PM_ELF_LORD},
574.  	{PM_ELF_LORD, PM_ELVENKING},
575.  	{PM_LICH, PM_DEMILICH}, {PM_DEMILICH, PM_MASTER_LICH},
576.  	{PM_MASTER_LICH, PM_ARCH_LICH},
577.  	{PM_VAMPIRE, PM_VAMPIRE_LORD}, {PM_VAMPIRE_LORD, PM_VAMPIRE_MAGE}, 
578.  	{PM_BAT, PM_GIANT_BAT},
579.  	{PM_CHICKATRICE, PM_COCKATRICE},
580.  	{PM_BABY_GRAY_DRAGON, PM_GRAY_DRAGON},
581.  	{PM_BABY_RED_DRAGON, PM_RED_DRAGON},
582.  	{PM_BABY_SILVER_DRAGON, PM_SILVER_DRAGON},
583.  	{PM_BABY_DEEP_DRAGON, PM_DEEP_DRAGON},
584.  	{PM_BABY_SHIMMERING_DRAGON, PM_SHIMMERING_DRAGON},
585.  	{PM_BABY_WHITE_DRAGON, PM_WHITE_DRAGON},
586.  	{PM_BABY_ORANGE_DRAGON, PM_ORANGE_DRAGON},
587.  	{PM_BABY_BLACK_DRAGON, PM_BLACK_DRAGON},
588.  	{PM_BABY_BLUE_DRAGON, PM_BLUE_DRAGON},
589.  	{PM_BABY_GREEN_DRAGON, PM_GREEN_DRAGON},
590.  	{PM_BABY_YELLOW_DRAGON, PM_YELLOW_DRAGON},
591.  	{PM_RED_NAGA_HATCHLING, PM_RED_NAGA},
592.  	{PM_BLACK_NAGA_HATCHLING, PM_BLACK_NAGA},
593.  	{PM_GOLDEN_NAGA_HATCHLING, PM_GOLDEN_NAGA},
594.  	{PM_GUARDIAN_NAGA_HATCHLING, PM_GUARDIAN_NAGA},
595.  	{PM_SMALL_MIMIC, PM_LARGE_MIMIC}, {PM_LARGE_MIMIC, PM_GIANT_MIMIC},
596.  	{PM_BABY_LONG_WORM, PM_LONG_WORM},
597.  	{PM_BABY_PURPLE_WORM, PM_PURPLE_WORM},
598.  	{PM_BABY_CROCODILE, PM_CROCODILE},
599.  	{PM_SOLDIER, PM_SERGEANT},
600.  	{PM_SERGEANT, PM_LIEUTENANT},
601.  	{PM_LIEUTENANT, PM_CAPTAIN},
602.  	{PM_WATCHMAN, PM_WATCH_CAPTAIN},
603.  	{PM_ALIGNED_PRIEST, PM_HIGH_PRIEST},
604.  	{PM_STUDENT, PM_ARCHEOLOGIST},
605.  	{PM_ATTENDANT, PM_HEALER},
606.  	{PM_PAGE, PM_KNIGHT},
607.  	{PM_ACOLYTE, PM_PRIEST},
608.  	{PM_APPRENTICE, PM_WIZARD},
609.  	{PM_MANES,PM_LEMURE},
610.  #ifdef KOPS
611.  	{PM_KEYSTONE_KOP, PM_KOP_SERGEANT},
612.  	{PM_KOP_SERGEANT, PM_KOP_LIEUTENANT},
613.  	{PM_KOP_LIEUTENANT, PM_KOP_KAPTAIN},
614.  #endif
615.  	/* WAC -- added killer coin piles */
616.  	{PM_PILE_OF_KILLER_COINS, PM_LARGE_PILE_OF_KILLER_COINS},
617.  	{PM_LARGE_PILE_OF_KILLER_COINS,PM_HUGE_PILE_OF_KILLER_COINS},
618.  	/* KMH -- added more sequences */
619.  	{PM_DINGO_PUPPY, PM_DINGO}, {PM_DINGO, PM_LARGE_DINGO},
620.  	{PM_PONY, PM_HORSE}, {PM_HORSE, PM_WARHORSE},
621.  	{PM_LARVA, PM_MAGGOT}, {PM_MAGGOT, PM_DUNG_WORM},
622.  	{PM_WINTER_WOLF_CUB, PM_WINTER_WOLF},
623.  	{PM_GIANT_TICK, PM_GIANT_FLEA}, {PM_GIANT_FLEA, PM_GIANT_LOUSE},	/* RJ */
624.  	/* DS -- growing up, Lethe style */
625.  	{PM_DEEP_ONE, PM_DEEPER_ONE}, {PM_DEEPER_ONE, PM_DEEPEST_ONE},
626.  	{PM_LAMB, PM_SHEEP}, 
627.  	{PM_SHOGGOTH, PM_GIANT_SHOGGOTH},
628.  	{PM_GNOLL, PM_GNOLL_WARRIOR}, {PM_GNOLL_WARRIOR, PM_GNOLL_CHIEFTAIN},
629.  	{PM_MIGO_DRONE, PM_MIGO_WARRIOR},
630.  
631.  	{NON_PM,NON_PM}
632.  };
633.  
634.  int
635.  little_to_big(montype)
636.  int montype;
637.  {
638.  #ifndef AIXPS2_BUG
639.  	register int i;
640.  
641.  	for (i = 0; grownups[i][0] >= LOW_PM; i++)
642.  		if(montype == grownups[i][0]) return grownups[i][1];
643.  	return montype;
644.  #else
645.  /* AIX PS/2 C-compiler 1.1.1 optimizer does not like the above for loop,
646.   * and causes segmentation faults at runtime.  (The problem does not
647.   * occur if -O is not used.)
648.   * lehtonen@cs.Helsinki.FI (Tapio Lehtonen) 28031990
649.   */
650.  	int i;
651.  	int monvalue;
652.  
653.  	monvalue = montype;
654.  	for (i = 0; grownups[i][0] >= LOW_PM; i++)
655.  		if(montype == grownups[i][0]) monvalue = grownups[i][1];
656.  
657.  	return monvalue;
658.  #endif
659.  }
660.  
661.  int
662.  big_to_little(montype)
663.  int montype;
664.  {
665.  	register int i;
666.  
667.  	for (i = 0; grownups[i][0] >= LOW_PM; i++)
668.  		if(montype == grownups[i][1]) return grownups[i][0];
669.  	return montype;
670.  }
671.  
672.  /*
673.   * Return the permonst ptr for the race of the monster.
674.   * Returns correct pointer for non-polymorphed and polymorphed
675.   * player.  It does not return a pointer to player role character.
676.   */
677.  const struct permonst *
678.  raceptr(mtmp)
679.  struct monst *mtmp;
680.  {
681.      if (mtmp == &youmonst && !Upolyd) return(&mons[urace.malenum]);
682.      else return(mtmp->data);
683.  }
684.  
685.  static const char *levitate[4]	= { "float", "Float", "wobble", "Wobble" };
686.  static const char *flys[4]	= { "fly", "Fly", "flutter", "Flutter" };
687.  static const char *flyl[4]	= { "fly", "Fly", "stagger", "Stagger" };
688.  static const char *slither[4]	= { "slither", "Slither", "falter", "Falter" };
689.  static const char *ooze[4]	= { "ooze", "Ooze", "tremble", "Tremble" };
690.  static const char *immobile[4]	= { "wiggle", "Wiggle", "pulsate", "Pulsate" };
691.  static const char *crawl[4]	= { "crawl", "Crawl", "falter", "Falter" };
692.  
693.  const char *
694.  locomotion(ptr, def)
695.  const struct permonst *ptr;
696.  const char *def;
697.  {
698.  	int capitalize = (*def == highc(*def));
699.  
700.  	return (
701.  		is_floater(ptr) ? levitate[capitalize] :
702.  		(is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[capitalize] :
703.  		(is_flyer(ptr) && ptr->msize > MZ_SMALL)  ? flyl[capitalize] :
704.  		slithy(ptr)     ? slither[capitalize] :
705.  		amorphous(ptr)  ? ooze[capitalize] :
706.  		!ptr->mmove	? immobile[capitalize] :
707.  		nolimbs(ptr)    ? crawl[capitalize] :
708.  		def
709.  	       );
710.  
711.  }
712.  
713.  const char *
714.  stagger(ptr, def)
715.  const struct permonst *ptr;
716.  const char *def;
717.  {
718.  	int capitalize = 2 + (*def == highc(*def));
719.  
720.  	return (
721.  		is_floater(ptr) ? levitate[capitalize] :
722.  		(is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[capitalize] :
723.  		(is_flyer(ptr) && ptr->msize > MZ_SMALL)  ? flyl[capitalize] :
724.  		slithy(ptr)     ? slither[capitalize] :
725.  		amorphous(ptr)  ? ooze[capitalize] :
726.  		!ptr->mmove	? immobile[capitalize] :
727.  		nolimbs(ptr)    ? crawl[capitalize] :
728.  		def
729.  	       );
730.  
731.  }
732.  
733.  /* return a phrase describing the effect of fire attack on a type of monster */
734.  const char *
735.  on_fire(mptr, mattk)
736.  struct permonst *mptr;
737.  struct attack *mattk;
738.  {
739.      const char *what;
740.  
741.      switch (monsndx(mptr)) {
742.      case PM_FLAMING_SPHERE:
743.      case PM_FIRE_VORTEX:
744.      case PM_FIRE_ELEMENTAL:
745.      case PM_SALAMANDER:
746.  	what = "already on fire";
747.  	break;
748.      case PM_WATER_ELEMENTAL:
749.      case PM_FOG_CLOUD:
750.      case PM_STEAM_VORTEX:
751.  	what = "boiling";
752.  	break;
753.      case PM_ICE_VORTEX:
754.      case PM_GLASS_GOLEM:
755.  	what = "melting";
756.  	break;
757.      case PM_STONE_GOLEM:
758.      case PM_CLAY_GOLEM:
759.      case PM_GOLD_GOLEM:
760.      case PM_AIR_ELEMENTAL:
761.      case PM_EARTH_ELEMENTAL:
762.      case PM_DUST_VORTEX:
763.      case PM_ENERGY_VORTEX:
764.  	what = "heating up";
765.  	break;
766.      default:
767.  	what = (mattk->aatyp == AT_HUGS) ? "being roasted" : "on fire";
768.  	break;
769.      }
770.      return what;
771.  }
772.  
773.  #endif /* OVLB */
774.  
775.  /*mondata.c*/