Source:NetHack 3.0.0/were.c

Below is the full text to were.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/were.c#line123 ]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

1.   /*	SCCS Id: @(#)were.c	3.0	88/07/06 2.   /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    #include	"hack.h"  6. 7.   void 8.   were_change(mon) 9.   register struct monst *mon; 10.  {  11.   	register int pm = monsndx(mon->data); 12.   13.   	if(Protection_from_shape_changers) return; 14.  	if(is_were(mon->data)) 15.  	    if(is_human(mon->data)) { 16.  		if(!rn2(50-(night*20)) || flags.moonphase == FULL_MOON) { 17.  		    new_were(mon); 18.  		    if(pm != PM_WERERAT && flags.soundok) 19.  			You("hear a %s howling at the moon.",  20.   			      pm == PM_WEREJACKAL ? "jackal" : "wolf"); 21.  		}  22.   	    } else if(!rn2(30)) new_were(mon); 23.  }  24.    25.   void 26.  new_were(mon) 27.  register struct monst *mon; 28.  {  29.   	int pm; 30.   31.   	switch((pm = monsndx(mon->data))) { 32.   33.   	    case PM_WEREWOLF:	pm = PM_WOLFWERE; 34.  				break; 35.  	    case PM_WOLFWERE:	pm = PM_WEREWOLF; 36.  				break; 37.  	    case PM_WEREJACKAL:	pm = PM_JACKALWERE; 38.  				break; 39.  	    case PM_JACKALWERE:	pm = PM_WEREJACKAL; 40.  				break; 41.  	    case PM_WERERAT:	pm = PM_RATWERE; 42.  				break; 43.  	    case PM_RATWERE:	pm = PM_WERERAT; 44.  				break; 45.  	    default:	impossible("unknown lycanthrope %s.", mon->data->mname); 46.  			return; 47.  	}  48.    49.   	if(canseemon(mon)) 50.  	    pline("%s changes into a %s.", Monnam(mon), mons[pm].mname); 51.   52.   	mon->data = &mons[pm]; 53.  	/* regenerate by 1/4 of the lost hit points */ 54.  	mon->mhp += (mon->mhpmax - mon->mhp) / 4; 55.  	unpmon(mon); 56.  	pmon(mon);		/* display new appearance */ 57.  }  58.    59.   boolean 60.  were_summon(ptr,yours)	/* were-creature (even you) summons a horde */ 61.  register struct permonst *ptr; 62.  register boolean yours; 63.  {  64.   	register int i, typ, pm = monsndx(ptr); 65.  	register struct monst *mtmp; 66.  	boolean success = FALSE; 67.   68.   	if(Protection_from_shape_changers) 69.  		return FALSE; 70.  	for(i = rnd(5); i > 0; i--) { 71.  	   switch(pm) { 72.   73.   		case PM_WERERAT: 74.  		case PM_RATWERE: 75.  			typ = rn2(3) ? PM_SEWER_RAT : rn2(3) ? PM_GIANT_RAT : PM_RABID_RAT ; 76.  			break; 77.  		case PM_WEREJACKAL: 78.  		case PM_JACKALWERE: 79.  			typ = PM_JACKAL; 80.  			break; 81.  		case PM_WEREWOLF: 82.  		case PM_WOLFWERE: 83.  			typ = rn2(5) ? PM_WOLF : PM_WINTER_WOLF ; 84.  			break; 85.  		default: 86.  			continue; 87.  	    }  88.   	    mtmp = makemon(&mons[typ], u.ux, u.uy); 89.  	    if (mtmp) success = TRUE; 90.  	    if (yours && mtmp) 91.  		(void) tamedog(mtmp, (struct obj *) 0); 92.  	}  93.   	return success; 94.  }  95.    96.   #ifdef POLYSELF 97.  void 98.  you_were { 99.  	if(u.umonnum == u.ulycn) return; 100. 	if(Polymorph_control) { 101. 	    pline("Do you want to change into a %s? ", mons[u.ulycn].mname); 102. 	    if(yn == 'n') return; 103. 	}  104.  	(void) polymon(u.ulycn); 105. }  106.  #endif