Source:NetHack 3.4.3/src/mondata.c

From NetHackWiki
(Redirected from Source:Ref/big to little)
Jump to: navigation, search

Below is the full text to src/mondata.c from NetHack 3.4.3. To link to a particular line, write [[mondata.c#line123]], for example.

Top of file[edit]

  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. */

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. #include "hack.h"
  2. #include "eshk.h"
  3. #include "epri.h"
  4.  
  5. /*	These routines provide basic data for any type of monster. */
  6.  
  7. #ifdef OVLB

set_mon_data[edit]

  1. void
  2. set_mon_data(mon, ptr, flag)
  3. struct monst *mon;
  4. struct permonst *ptr;
  5. int flag;
  6. {
  7. mon->data = ptr;
  8. if (flag == -1) return;		/* "don't care" */
  9.  
  10. if (flag == 1)
  11. 	mon->mintrinsics |= (ptr->mresists & 0x00FF);
  12. else
  13. 	mon->mintrinsics = (ptr->mresists & 0x00FF);
  14. return;
  15. }
  16.  
  17. #endif /* OVLB */
  18. #ifdef OVL0

attacktype_fordmg[edit]

  1. struct attack *
  2. attacktype_fordmg(ptr, atyp, dtyp)
  3. struct permonst *ptr;
  4. int atyp, dtyp;
  5. {
  6. struct attack *a;
  7.  
  8. for (a = &ptr->mattk[0]; a < &ptr->mattk[NATTK]; a++)
  9. 	if (a->aatyp == atyp && (dtyp == AD_ANY || a->adtyp == dtyp))
  10. 	    return a;
  11.  
  12. return (struct attack *)0;
  13. }

attacktype[edit]

  1. boolean
  2. attacktype(ptr, atyp)
  3. struct permonst *ptr;
  4. int atyp;
  5. {
  6. return attacktype_fordmg(ptr, atyp, AD_ANY) ? TRUE : FALSE;
  7. }
  8.  
  9. #endif /* OVL0 */
  10. #ifdef OVLB

poly_when_stoned[edit]

  1. boolean
  2. poly_when_stoned(ptr)
  3. struct permonst *ptr;
  4. {
  5. return((boolean)(is_golem(ptr) && ptr != &mons[PM_STONE_GOLEM] &&
  6. 	    !(mvitals[PM_STONE_GOLEM].mvflags & G_GENOD)));
  7. 	    /* allow G_EXTINCT */
  8. }

resists_drli[edit]

  1. boolean
  2. resists_drli(mon)	/* returns TRUE if monster is drain-life resistant */
  3. struct monst *mon;
  4. {
  5. 	struct permonst *ptr = mon->data;
  6. 	struct obj *wep = ((mon == &youmonst) ? uwep : MON_WEP(mon));
  7.  
  8. 	return (boolean)(is_undead(ptr) || is_demon(ptr) || is_were(ptr) ||
  9. 			 ptr == &mons[PM_DEATH] ||
  10. 			 (wep && wep->oartifact && defends(AD_DRLI, wep)));
  11. }

resists_magm[edit]

  1. boolean
  2. resists_magm(mon)	/* TRUE if monster is magic-missile resistant */
  3. struct monst *mon;
  4. {
  5. 	struct permonst *ptr = mon->data;
  6. 	struct obj *o;
  7.  
  8. 	/* as of 3.2.0:  gray dragons, Angels, Oracle, Yeenoghu */
  9. 	if (dmgtype(ptr, AD_MAGM) || ptr == &mons[PM_BABY_GRAY_DRAGON] ||
  10. 		dmgtype(ptr, AD_RBRE))	/* Chromatic Dragon */
  11. 	    return TRUE;
  12. 	/* check for magic resistance granted by wielded weapon */
  13. 	o = (mon == &youmonst) ? uwep : MON_WEP(mon);
  14. 	if (o && o->oartifact && defends(AD_MAGM, o))
  15. 	    return TRUE;
  16. 	/* check for magic resistance granted by worn or carried items */
  17. 	o = (mon == &youmonst) ? invent : mon->minvent;
  18. 	for ( ; o; o = o->nobj)
  19. 	    if ((o->owornmask && objects[o->otyp].oc_oprop == ANTIMAGIC) ||
  20. 		    (o->oartifact && protects(AD_MAGM, o)))
  21. 		return TRUE;
  22. 	return FALSE;
  23. }

resists_blnd[edit]

  1. /* TRUE iff monster is resistant to light-induced blindness */
  2. boolean
  3. resists_blnd(mon)
  4. struct monst *mon;
  5. {
  6. 	struct permonst *ptr = mon->data;
  7. 	boolean is_you = (mon == &youmonst);
  8. 	struct obj *o;
  9.  
  10. 	if (is_you ? (Blind || u.usleep) :
  11. 		(mon->mblinded || !mon->mcansee || !haseyes(ptr) ||
  12. 		    /* BUG: temporary sleep sets mfrozen, but since
  13. 			    paralysis does too, we can't check it */
  14. 		    mon->msleeping))
  15. 	    return TRUE;
  16. 	/* yellow light, Archon; !dust vortex, !cobra, !raven */
  17. 	if (dmgtype_fromattack(ptr, AD_BLND, AT_EXPL) ||
  18. 		dmgtype_fromattack(ptr, AD_BLND, AT_GAZE))
  19. 	    return TRUE;
  20. 	o = is_you ? uwep : MON_WEP(mon);
  21. 	if (o && o->oartifact && defends(AD_BLND, o))
  22. 	    return TRUE;
  23. 	o = is_you ? invent : mon->minvent;
  24. 	for ( ; o; o = o->nobj)
  25. 	    if ((o->owornmask && objects[o->otyp].oc_oprop == BLINDED) ||
  26. 		    (o->oartifact && protects(AD_BLND, o)))
  27. 		return TRUE;
  28. 	return FALSE;
  29. }

can_blnd[edit]

  1. /* TRUE iff monster can be blinded by the given attack */
  2. /* Note: may return TRUE when mdef is blind (e.g. new cream-pie attack) */
  3. boolean
  4. can_blnd(magr, mdef, aatyp, obj)
  5. struct monst *magr;		/* NULL == no specific aggressor */
  6. struct monst *mdef;
  7. uchar aatyp;
  8. struct obj *obj;		/* aatyp == AT_WEAP, AT_SPIT */
  9. {
  10. 	boolean is_you = (mdef == &youmonst);
  11. 	boolean check_visor = FALSE;
  12. 	struct obj *o;
  13. 	const char *s;
  14.  
  15. 	/* no eyes protect against all attacks for now */
  16. 	if (!haseyes(mdef->data))
  17. 	    return FALSE;
  18.  
  19. 	switch(aatyp) {
  20. 	case AT_EXPL: case AT_BOOM: case AT_GAZE: case AT_MAGC:
  21. 	case AT_BREA: /* assumed to be lightning */
  22. 	    /* light-based attacks may be cancelled or resisted */
  23. 	    if (magr && magr->mcan)
  24. 		return FALSE;
  25. 	    return !resists_blnd(mdef);
  26.  
  27. 	case AT_WEAP: case AT_SPIT: case AT_NONE:
  28. 	    /* an object is used (thrown/spit/other) */
  29. 	    if (obj && (obj->otyp == CREAM_PIE)) {
  30. 		if (is_you && Blindfolded)
  31. 		    return FALSE;
  32. 	    } else if (obj && (obj->otyp == BLINDING_VENOM)) {
  33. 		/* all ublindf, including LENSES, protect, cream-pies too */
  34. 		if (is_you && (ublindf || u.ucreamed))
  35. 		    return FALSE;
  36. 		check_visor = TRUE;
  37. 	    } else if (obj && (obj->otyp == POT_BLINDNESS)) {
  38. 		return TRUE;	/* no defense */
  39. 	    } else
  40. 		return FALSE;	/* other objects cannot cause blindness yet */
  41. 	    if ((magr == &youmonst) && u.uswallow)
  42. 		return FALSE;	/* can't affect eyes while inside monster */
  43. 	    break;
  44.  
  45. 	case AT_ENGL:
  46. 	    if (is_you && (Blindfolded || u.usleep || u.ucreamed))
  47. 		return FALSE;
  48. 	    if (!is_you && mdef->msleeping)
  49. 		return FALSE;
  50. 	    break;
  51.  
  52. 	case AT_CLAW:
  53. 	    /* e.g. raven: all ublindf, including LENSES, protect */
  54. 	    if (is_you && ublindf)
  55. 		return FALSE;
  56. 	    if ((magr == &youmonst) && u.uswallow)
  57. 		return FALSE;	/* can't affect eyes while inside monster */
  58. 	    check_visor = TRUE;
  59. 	    break;
  60.  
  61. 	case AT_TUCH: case AT_STNG:
  62. 	    /* some physical, blind-inducing attacks can be cancelled */
  63. 	    if (magr && magr->mcan)
  64. 		return FALSE;
  65. 	    break;
  66.  
  67. 	default:
  68. 	    break;
  69. 	}
  70.  
  71. 	/* check if wearing a visor (only checked if visor might help) */
  72. 	if (check_visor) {
  73. 	    o = (mdef == &youmonst) ? invent : mdef->minvent;
  74. 	    for ( ; o; o = o->nobj)
  75. 		if ((o->owornmask & W_ARMH) &&
  76. 		    (s = OBJ_DESCR(objects[o->otyp])) != (char *)0 &&
  77. 		    !strcmp(s, "visored helmet"))
  78. 		    return FALSE;
  79. 	}
  80.  
  81. 	return TRUE;
  82. }
  83.  
  84. #endif /* OVLB */
  85. #ifdef OVL0

ranged_attk[edit]

  1. boolean
  2. ranged_attk(ptr)	/* returns TRUE if monster can attack at range */
  3. struct permonst *ptr;
  4. {
  5. 	register int i, atyp;
  6. 	long atk_mask = (1L << AT_BREA) | (1L << AT_SPIT) | (1L << AT_GAZE);
  7.  
  8. 	/* was: (attacktype(ptr, AT_BREA) || attacktype(ptr, AT_WEAP) ||
  9. 		attacktype(ptr, AT_SPIT) || attacktype(ptr, AT_GAZE) ||
  10. 		attacktype(ptr, AT_MAGC));
  11. 	   but that's too slow -dlc
  12. 	 */
  13. 	for (i = 0; i < NATTK; i++) {
  14. 	    atyp = ptr->mattk[i].aatyp;
  15. 	    if (atyp >= AT_WEAP) return TRUE;
  16. 	 /* assert(atyp < 32); */
  17. 	    if ((atk_mask & (1L << atyp)) != 0L) return TRUE;
  18. 	}
  19.  
  20. 	return FALSE;
  21. }

hates_silver[edit]

  1. boolean
  2. hates_silver(ptr)
  3. register struct permonst *ptr;
  4. /* returns TRUE if monster is especially affected by silver weapons */
  5. {
  6. 	return((boolean)(is_were(ptr) || ptr->mlet==S_VAMPIRE || is_demon(ptr) ||
  7. 		ptr == &mons[PM_SHADE] ||
  8. 		(ptr->mlet==S_IMP && ptr != &mons[PM_TENGU])));
  9. }

passes_bars[edit]

  1. /* true iff the type of monster pass through iron bars */
  2. boolean
  3. passes_bars(mptr)
  4. struct permonst *mptr;
  5. {
  6. return (boolean) (passes_walls(mptr) || amorphous(mptr) ||
  7. 		      is_whirly(mptr) || verysmall(mptr) ||
  8. 		      (slithy(mptr) && !bigmonst(mptr)));
  9. }
  10.  
  11. #endif /* OVL0 */
  12. #ifdef OVL1

can_track[edit]

  1. boolean
  2. can_track(ptr)		/* returns TRUE if monster can track well */
  3. 	register struct permonst *ptr;
  4. {
  5. 	if (uwep && uwep->oartifact == ART_EXCALIBUR)
  6. 		return TRUE;
  7. 	else
  8. 		return((boolean)haseyes(ptr));
  9. }
  10.  
  11. #endif /* OVL1 */
  12. #ifdef OVLB

sliparm[edit]

  1. boolean
  2. sliparm(ptr)	/* creature will slide out of armor */
  3. 	register struct permonst *ptr;
  4. {
  5. 	return((boolean)(is_whirly(ptr) || ptr->msize <= MZ_SMALL ||
  6. 			 noncorporeal(ptr)));
  7. }

breakarm[edit]

  1. boolean
  2. breakarm(ptr)	/* creature will break out of armor */
  3. 	register struct permonst *ptr;
  4. {
  5. 	return ((bigmonst(ptr) || (ptr->msize > MZ_SMALL && !humanoid(ptr)) ||
  6. 		/* special cases of humanoids that cannot wear body armor */
  7. 		ptr == &mons[PM_MARILITH] || ptr == &mons[PM_WINGED_GARGOYLE])
  8. 	      && !sliparm(ptr));
  9. }
  10. #endif /* OVLB */
  11. #ifdef OVL1

sticks[edit]

  1. boolean
  2. sticks(ptr)	/* creature sticks other creatures it hits */
  3. 	register struct permonst *ptr;
  4. {
  5. 	return((boolean)(dmgtype(ptr,AD_STCK) || dmgtype(ptr,AD_WRAP) ||
  6. 		attacktype(ptr,AT_HUGS)));
  7. }

num_horns[edit]

Used for correct pluralization of helm related messages in do_wear.c, worn.c, and polyself.c. There is also a macro, has_horns, defined in mondata.h line 48 ("#define has_horns(ptr) (num_horns(ptr) > 0)").

  1. /* number of horns this type of monster has on its head */
  2. int
  3. num_horns(ptr)
  4. struct permonst *ptr;
  5. {
  6. switch (monsndx(ptr)) {
  7. case PM_HORNED_DEVIL:	/* ? "more than one" */
  8. case PM_MINOTAUR:
  9. case PM_ASMODEUS:
  10. case PM_BALROG:
  11. 	return 2;
  12. case PM_WHITE_UNICORN:
  13. case PM_GRAY_UNICORN:
  14. case PM_BLACK_UNICORN:
  15. case PM_KI_RIN:
  16. 	return 1;
  17. default:
  18. 	break;
  19. }
  20. return 0;
  21. }

dmgtype_fromattack[edit]

  1. struct attack *
  2. dmgtype_fromattack(ptr, dtyp, atyp)
  3. struct permonst *ptr;
  4. int dtyp, atyp;
  5. {
  6. struct attack *a;
  7.  
  8. for (a = &ptr->mattk[0]; a < &ptr->mattk[NATTK]; a++)
  9. 	if (a->adtyp == dtyp && (atyp == AT_ANY || a->aatyp == atyp))
  10. 	    return a;
  11.  
  12. return (struct attack *)0;
  13. }

dmgtype[edit]

  1. boolean
  2. dmgtype(ptr, dtyp)
  3. struct permonst *ptr;
  4. int dtyp;
  5. {
  6. return dmgtype_fromattack(ptr, dtyp, AT_ANY) ? TRUE : FALSE;
  7. }

max_passive_dmg[edit]

  1. /* returns the maximum damage a defender can do to the attacker via
  2. * a passive defense */
  3. int
  4. max_passive_dmg(mdef, magr)
  5. register struct monst *mdef, *magr;
  6. {
  7. int	i, dmg = 0;
  8. uchar adtyp;
  9.  
  10. for(i = 0; i < NATTK; i++)
  11. 	if(mdef->data->mattk[i].aatyp == AT_NONE ||
  12. 		mdef->data->mattk[i].aatyp == AT_BOOM) {
  13. 	    adtyp = mdef->data->mattk[i].adtyp;
  14. 	    if ((adtyp == AD_ACID && !resists_acid(magr)) ||
  15. 		    (adtyp == AD_COLD && !resists_cold(magr)) ||
  16. 		    (adtyp == AD_FIRE && !resists_fire(magr)) ||
  17. 		    (adtyp == AD_ELEC && !resists_elec(magr)) ||
  18. 		    adtyp == AD_PHYS) {
  19. 		dmg = mdef->data->mattk[i].damn;
  20. 		if(!dmg) dmg = mdef->data->mlevel+1;
  21. 		dmg *= mdef->data->mattk[i].damd;
  22. 	    } else dmg = 0;
  23.  
  24. 	    return dmg;
  25. 	}
  26. return 0;
  27. }
  28.  
  29. #endif /* OVL1 */
  30. #ifdef OVL0

monsndx[edit]

  1. int
  2. monsndx(ptr)		/* return an index into the mons array */
  3. 	struct	permonst	*ptr;
  4. {
  5. 	register int	i;
  6.  
  7. 	i = (int)(ptr - &mons[0]);
  8. 	if (i < LOW_PM || i >= NUMMONS) {
  9. 		/* ought to switch this to use `fmt_ptr' */
  10. 	    panic("monsndx - could not index monster (%lx)",
  11. 		  (unsigned long)ptr);
  12. 	    return NON_PM;		/* will not get here */
  13. 	}
  14.  
  15. 	return(i);
  16. }
  17.  
  18. #endif /* OVL0 */
  19. #ifdef OVL1

name_to_mon[edit]

  1. int
  2. name_to_mon(in_str)
  3. const char *in_str;
  4. {
  5. 	/* Be careful.  We must check the entire string in case it was
  6. 	 * something such as "ettin zombie corpse".  The calling routine
  7. 	 * doesn't know about the "corpse" until the monster name has
  8. 	 * already been taken off the front, so we have to be able to
  9. 	 * read the name with extraneous stuff such as "corpse" stuck on
  10. 	 * the end.
  11. 	 * This causes a problem for names which prefix other names such
  12. 	 * as "ettin" on "ettin zombie".  In this case we want the _longest_
  13. 	 * name which exists.
  14. 	 * This also permits plurals created by adding suffixes such as 's'
  15. 	 * or 'es'.  Other plurals must still be handled explicitly.
  16. 	 */
  17. 	register int i;
  18. 	register int mntmp = NON_PM;
  19. 	register char *s, *str, *term;
  20. 	char buf[BUFSZ];
  21. 	int len, slen;
  22.  
  23. 	str = strcpy(buf, in_str);
  24.  
  25. 	if (!strncmp(str, "a ", 2)) str += 2;
  26. 	else if (!strncmp(str, "an ", 3)) str += 3;
  27.  
  28. 	slen = strlen(str);
  29. 	term = str + slen;
  30.  
  31. 	if ((s = strstri(str, "vortices")) != 0)
  32. 	    Strcpy(s+4, "ex");
  33. 	/* be careful with "ies"; "priest", "zombies" */
  34. 	else if (slen > 3 && !strcmpi(term-3, "ies") &&
  35. 		    (slen < 7 || strcmpi(term-7, "zombies")))
  36. 	    Strcpy(term-3, "y");
  37. 	/* luckily no monster names end in fe or ve with ves plurals */
  38. 	else if (slen > 3 && !strcmpi(term-3, "ves"))
  39. 	    Strcpy(term-3, "f");
  40.  
  41. 	slen = strlen(str); /* length possibly needs recomputing */
  42.  
  43. {
  44. 	static const struct alt_spl { const char* name; short pm_val; }
  45. 	    names[] = {
  46. 	    /* Alternate spellings */
  47. 		{ "grey dragon",	PM_GRAY_DRAGON },
  48. 		{ "baby grey dragon",	PM_BABY_GRAY_DRAGON },
  49. 		{ "grey unicorn",	PM_GRAY_UNICORN },
  50. 		{ "grey ooze",		PM_GRAY_OOZE },
  51. 		{ "gray-elf",		PM_GREY_ELF },
  52. 	    /* Hyphenated names */
  53. 		{ "ki rin",		PM_KI_RIN },
  54. 		{ "uruk hai",		PM_URUK_HAI },
  55. 		{ "orc captain",	PM_ORC_CAPTAIN },
  56. 		{ "woodland elf",	PM_WOODLAND_ELF },
  57. 		{ "green elf",		PM_GREEN_ELF },
  58. 		{ "grey elf",		PM_GREY_ELF },
  59. 		{ "gray elf",		PM_GREY_ELF },
  60. 		{ "elf lord",		PM_ELF_LORD },
  61. #if 0	/* OBSOLETE */
  62. 		{ "high elf",		PM_HIGH_ELF },
  63. #endif
  64. 		{ "olog hai",		PM_OLOG_HAI },
  65. 		{ "arch lich",		PM_ARCH_LICH },
  66. 	    /* Some irregular plurals */
  67. 		{ "incubi",		PM_INCUBUS },
  68. 		{ "succubi",		PM_SUCCUBUS },
  69. 		{ "violet fungi",	PM_VIOLET_FUNGUS },
  70. 		{ "homunculi",		PM_HOMUNCULUS },
  71. 		{ "baluchitheria",	PM_BALUCHITHERIUM },
  72. 		{ "lurkers above",	PM_LURKER_ABOVE },
  73. 		{ "cavemen",		PM_CAVEMAN },
  74. 		{ "cavewomen",		PM_CAVEWOMAN },
  75. 		{ "djinn",		PM_DJINNI },
  76. 		{ "mumakil",		PM_MUMAK },
  77. 		{ "erinyes",		PM_ERINYS },
  78. 	    /* falsely caught by -ves check above */
  79. 		{ "master of thief",	PM_MASTER_OF_THIEVES },
  80. 	    /* end of list */
  81. 		{ 0, 0 }
  82. 	};
  83. 	register const struct alt_spl *namep;
  84.  
  85. 	for (namep = names; namep->name; namep++)
  86. 	    if (!strncmpi(str, namep->name, (int)strlen(namep->name)))
  87. 		return namep->pm_val;
  88. }
  89.  
  90. 	for (len = 0, i = LOW_PM; i < NUMMONS; i++) {
  91. 	    register int m_i_len = strlen(mons[i].mname);
  92. 	    if (m_i_len > len && !strncmpi(mons[i].mname, str, m_i_len)) {
  93. 		if (m_i_len == slen) return i;	/* exact match */
  94. 		else if (slen > m_i_len &&
  95. 			(str[m_i_len] == ' ' ||
  96. 			 !strcmpi(&str[m_i_len], "s") ||
  97. 			 !strncmpi(&str[m_i_len], "s ", 2) ||
  98. 			 !strcmpi(&str[m_i_len], "'") ||
  99. 			 !strncmpi(&str[m_i_len], "' ", 2) ||
  100. 			 !strcmpi(&str[m_i_len], "'s") ||
  101. 			 !strncmpi(&str[m_i_len], "'s ", 3) ||
  102. 			 !strcmpi(&str[m_i_len], "es") ||
  103. 			 !strncmpi(&str[m_i_len], "es ", 3))) {
  104. 		    mntmp = i;
  105. 		    len = m_i_len;
  106. 		}
  107. 	    }
  108. 	}
  109. 	if (mntmp == NON_PM) mntmp = title_to_mon(str, (int *)0, (int *)0);
  110. 	return mntmp;
  111. }
  112.  
  113. #endif /* OVL1 */
  114. #ifdef OVL2

gender[edit]

  1. /* returns 3 values (0=male, 1=female, 2=none) */
  2. int
  3. gender(mtmp)
  4. register struct monst *mtmp;
  5. {
  6. 	if (is_neuter(mtmp->data)) return 2;
  7. 	return mtmp->female;
  8. }

pronoun_gender[edit]

  1. /* Like gender(), but lower animals and such are still "it". */
  2. /* This is the one we want to use when printing messages. */
  3. int
  4. pronoun_gender(mtmp)
  5. register struct monst *mtmp;
  6. {
  7. 	if (is_neuter(mtmp->data) || !canspotmon(mtmp)) return 2;
  8. 	return (humanoid(mtmp->data) || (mtmp->data->geno & G_UNIQ) ||
  9. 		type_is_pname(mtmp->data)) ? (int)mtmp->female : 2;
  10. }
  11.  
  12. #endif /* OVL2 */
  13. #ifdef OVLB

levl_follower[edit]

  1. /* used for nearby monsters when you go to another level */
  2. boolean
  3. levl_follower(mtmp)
  4. struct monst *mtmp;
  5. {
  6. 	/* monsters with the Amulet--even pets--won't follow across levels */
  7. 	if (mon_has_amulet(mtmp)) return FALSE;
  8.  
  9. 	/* some monsters will follow even while intending to flee from you */
  10. 	if (mtmp->mtame || mtmp->iswiz || is_fshk(mtmp)) return TRUE;
  11.  
  12. 	/* stalking types follow, but won't when fleeing unless you hold
  13. 	   the Amulet */
  14. 	return (boolean)((mtmp->data->mflags2 & M2_STALK) &&
  15. 				(!mtmp->mflee || u.uhave.amulet));
  16. }

grownups-array[edit]

  1. static const short grownups[][2] = {
  2. 	{PM_CHICKATRICE, PM_COCKATRICE},
  3. 	{PM_LITTLE_DOG, PM_DOG}, {PM_DOG, PM_LARGE_DOG},
  4. 	{PM_HELL_HOUND_PUP, PM_HELL_HOUND},
  5. 	{PM_WINTER_WOLF_CUB, PM_WINTER_WOLF},
  6. 	{PM_KITTEN, PM_HOUSECAT}, {PM_HOUSECAT, PM_LARGE_CAT},
  7. 	{PM_PONY, PM_HORSE}, {PM_HORSE, PM_WARHORSE},
  8. 	{PM_KOBOLD, PM_LARGE_KOBOLD}, {PM_LARGE_KOBOLD, PM_KOBOLD_LORD},
  9. 	{PM_GNOME, PM_GNOME_LORD}, {PM_GNOME_LORD, PM_GNOME_KING},
  10. 	{PM_DWARF, PM_DWARF_LORD}, {PM_DWARF_LORD, PM_DWARF_KING},
  11. 	{PM_MIND_FLAYER, PM_MASTER_MIND_FLAYER},
  12. 	{PM_ORC, PM_ORC_CAPTAIN}, {PM_HILL_ORC, PM_ORC_CAPTAIN},
  13. 	{PM_MORDOR_ORC, PM_ORC_CAPTAIN}, {PM_URUK_HAI, PM_ORC_CAPTAIN},
  14. 	{PM_SEWER_RAT, PM_GIANT_RAT},
  15. 	{PM_CAVE_SPIDER, PM_GIANT_SPIDER},
  16. 	{PM_OGRE, PM_OGRE_LORD}, {PM_OGRE_LORD, PM_OGRE_KING},
  17. 	{PM_ELF, PM_ELF_LORD}, {PM_WOODLAND_ELF, PM_ELF_LORD},
  18. 	{PM_GREEN_ELF, PM_ELF_LORD}, {PM_GREY_ELF, PM_ELF_LORD},
  19. 	{PM_ELF_LORD, PM_ELVENKING},
  20. 	{PM_LICH, PM_DEMILICH}, {PM_DEMILICH, PM_MASTER_LICH},
  21. 	{PM_MASTER_LICH, PM_ARCH_LICH},
  22. 	{PM_VAMPIRE, PM_VAMPIRE_LORD}, {PM_BAT, PM_GIANT_BAT},
  23. 	{PM_BABY_GRAY_DRAGON, PM_GRAY_DRAGON},
  24. 	{PM_BABY_SILVER_DRAGON, PM_SILVER_DRAGON},
  25. #if 0	/* DEFERRED */
  26. 	{PM_BABY_SHIMMERING_DRAGON, PM_SHIMMERING_DRAGON},
  27. #endif
  28. 	{PM_BABY_RED_DRAGON, PM_RED_DRAGON},
  29. 	{PM_BABY_WHITE_DRAGON, PM_WHITE_DRAGON},
  30. 	{PM_BABY_ORANGE_DRAGON, PM_ORANGE_DRAGON},
  31. 	{PM_BABY_BLACK_DRAGON, PM_BLACK_DRAGON},
  32. 	{PM_BABY_BLUE_DRAGON, PM_BLUE_DRAGON},
  33. 	{PM_BABY_GREEN_DRAGON, PM_GREEN_DRAGON},
  34. 	{PM_BABY_YELLOW_DRAGON, PM_YELLOW_DRAGON},
  35. 	{PM_RED_NAGA_HATCHLING, PM_RED_NAGA},
  36. 	{PM_BLACK_NAGA_HATCHLING, PM_BLACK_NAGA},
  37. 	{PM_GOLDEN_NAGA_HATCHLING, PM_GOLDEN_NAGA},
  38. 	{PM_GUARDIAN_NAGA_HATCHLING, PM_GUARDIAN_NAGA},
  39. 	{PM_SMALL_MIMIC, PM_LARGE_MIMIC}, {PM_LARGE_MIMIC, PM_GIANT_MIMIC},
  40. 	{PM_BABY_LONG_WORM, PM_LONG_WORM},
  41. 	{PM_BABY_PURPLE_WORM, PM_PURPLE_WORM},
  42. 	{PM_BABY_CROCODILE, PM_CROCODILE},
  43. 	{PM_SOLDIER, PM_SERGEANT},
  44. 	{PM_SERGEANT, PM_LIEUTENANT},
  45. 	{PM_LIEUTENANT, PM_CAPTAIN},
  46. 	{PM_WATCHMAN, PM_WATCH_CAPTAIN},
  47. 	{PM_ALIGNED_PRIEST, PM_HIGH_PRIEST},
  48. 	{PM_STUDENT, PM_ARCHEOLOGIST},
  49. 	{PM_ATTENDANT, PM_HEALER},
  50. 	{PM_PAGE, PM_KNIGHT},
  51. 	{PM_ACOLYTE, PM_PRIEST},
  52. 	{PM_APPRENTICE, PM_WIZARD},
  53. 	{PM_MANES,PM_LEMURE},
  54. #ifdef KOPS
  55. 	{PM_KEYSTONE_KOP, PM_KOP_SERGEANT},
  56. 	{PM_KOP_SERGEANT, PM_KOP_LIEUTENANT},
  57. 	{PM_KOP_LIEUTENANT, PM_KOP_KAPTAIN},
  58. #endif
  59. 	{NON_PM,NON_PM}
  60. };

little_to_big[edit]

  1. int
  2. little_to_big(montype)
  3. int montype;
  4. {
  5. #ifndef AIXPS2_BUG
  6. 	register int i;
  7.  
  8. 	for (i = 0; grownups[i][0] >= LOW_PM; i++)
  9. 		if(montype == grownups[i][0]) return grownups[i][1];
  10. 	return montype;
  11. #else
  12. /* AIX PS/2 C-compiler 1.1.1 optimizer does not like the above for loop,
  13. * and causes segmentation faults at runtime.  (The problem does not
  14. * occur if -O is not used.)
  15. * lehtonen@cs.Helsinki.FI (Tapio Lehtonen) 28031990
  16. */
  17. 	int i;
  18. 	int monvalue;
  19.  
  20. 	monvalue = montype;
  21. 	for (i = 0; grownups[i][0] >= LOW_PM; i++)
  22. 		if(montype == grownups[i][0]) monvalue = grownups[i][1];
  23.  
  24. 	return monvalue;
  25. #endif
  26. }

big_to_little[edit]

  1. int
  2. big_to_little(montype)
  3. int montype;
  4. {
  5. 	register int i;
  6.  
  7. 	for (i = 0; grownups[i][0] >= LOW_PM; i++)
  8. 		if(montype == grownups[i][1]) return grownups[i][0];
  9. 	return montype;
  10. }

raceptr[edit]

  1. /*
  2. * Return the permonst ptr for the race of the monster.
  3. * Returns correct pointer for non-polymorphed and polymorphed
  4. * player.  It does not return a pointer to player role character.
  5. */
  6. const struct permonst *
  7. raceptr(mtmp)
  8. struct monst *mtmp;
  9. {
  10. if (mtmp == &youmonst && !Upolyd) return(&mons[urace.malenum]);
  11. else return(mtmp->data);
  12. }

locomotion[edit]

  1. static const char *levitate[4]	= { "float", "Float", "wobble", "Wobble" };
  2. static const char *flys[4]	= { "fly", "Fly", "flutter", "Flutter" };
  3. static const char *flyl[4]	= { "fly", "Fly", "stagger", "Stagger" };
  4. static const char *slither[4]	= { "slither", "Slither", "falter", "Falter" };
  5. static const char *ooze[4]	= { "ooze", "Ooze", "tremble", "Tremble" };
  6. static const char *immobile[4]	= { "wiggle", "Wiggle", "pulsate", "Pulsate" };
  7. static const char *crawl[4]	= { "crawl", "Crawl", "falter", "Falter" };
  8.  
  9. const char *
  10. locomotion(ptr, def)
  11. const struct permonst *ptr;
  12. const char *def;
  13. {
  14. 	int capitalize = (*def == highc(*def));
  15.  
  16. 	return (
  17. 		is_floater(ptr) ? levitate[capitalize] :
  18. 		(is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[capitalize] :
  19. 		(is_flyer(ptr) && ptr->msize > MZ_SMALL)  ? flyl[capitalize] :
  20. 		slithy(ptr)     ? slither[capitalize] :
  21. 		amorphous(ptr)  ? ooze[capitalize] :
  22. 		!ptr->mmove	? immobile[capitalize] :
  23. 		nolimbs(ptr)    ? crawl[capitalize] :
  24. 		def
  25. 	       );
  26.  
  27. }

stagger[edit]

  1. const char *
  2. stagger(ptr, def)
  3. const struct permonst *ptr;
  4. const char *def;
  5. {
  6. 	int capitalize = 2 + (*def == highc(*def));
  7.  
  8. 	return (
  9. 		is_floater(ptr) ? levitate[capitalize] :
  10. 		(is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[capitalize] :
  11. 		(is_flyer(ptr) && ptr->msize > MZ_SMALL)  ? flyl[capitalize] :
  12. 		slithy(ptr)     ? slither[capitalize] :
  13. 		amorphous(ptr)  ? ooze[capitalize] :
  14. 		!ptr->mmove	? immobile[capitalize] :
  15. 		nolimbs(ptr)    ? crawl[capitalize] :
  16. 		def
  17. 	       );
  18.  
  19. }

on_fire[edit]

  1. /* return a phrase describing the effect of fire attack on a type of monster */
  2. const char *
  3. on_fire(mptr, mattk)
  4. struct permonst *mptr;
  5. struct attack *mattk;
  6. {
  7. const char *what;
  8.  
  9. switch (monsndx(mptr)) {
  10. case PM_FLAMING_SPHERE:
  11. case PM_FIRE_VORTEX:
  12. case PM_FIRE_ELEMENTAL:
  13. case PM_SALAMANDER:
  14. 	what = "already on fire";
  15. 	break;
  16. case PM_WATER_ELEMENTAL:
  17. case PM_FOG_CLOUD:
  18. case PM_STEAM_VORTEX:
  19. 	what = "boiling";
  20. 	break;
  21. case PM_ICE_VORTEX:
  22. case PM_GLASS_GOLEM:
  23. 	what = "melting";
  24. 	break;
  25. case PM_STONE_GOLEM:
  26. case PM_CLAY_GOLEM:
  27. case PM_GOLD_GOLEM:
  28. case PM_AIR_ELEMENTAL:
  29. case PM_EARTH_ELEMENTAL:
  30. case PM_DUST_VORTEX:
  31. case PM_ENERGY_VORTEX:
  32. 	what = "heating up";
  33. 	break;
  34. default:
  35. 	what = (mattk->aatyp == AT_HUGS) ? "being roasted" : "on fire";
  36. 	break;
  37. }
  38. return what;
  39. }
  40.  
  41. #endif /* OVLB */
  42.  
  43. /*mondata.c*/