Source:NetHack 3.2.0/were.c

Below is the full text to were.c from the source code of NetHack 3.2.0. To link to a particular line, write [[NetHack 3.2.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.2	95/07/29	*/ 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.   #ifdef OVL0 8.    9.    void 10.  were_change(mon) 11.  register struct monst *mon; 12.  {  13.   	register int pm = monsndx(mon->data); 14.   15.   	if(is_were(mon->data)) 16.  	    if(is_human(mon->data)) { 17.  		if(Protection_from_shape_changers) return; 18.  		if(!rn2(50-(night*20)) || flags.moonphase == FULL_MOON) { 19.  		    new_were(mon); 20.  		    if(mons[pm].msound == MS_BARK && flags.soundok) 21.  			You_hear("a %s howling at the moon.",  22.   			    pm == PM_HUMAN_WEREJACKAL ? "jackal" : "wolf"); 23.  		}  24.   	    } else if(!rn2(30) || Protection_from_shape_changers) new_were(mon); 25.  }  26.    27.   #endif /* OVL0 */ 28.  #ifdef OVLB 29.   30.   static int FDECL(counter_were,(int)); 31.   32.   static int 33.  counter_were(pm) 34.  int pm; 35.  {  36.   	switch(pm) { 37.  	    case PM_WEREWOLF:	      return(PM_HUMAN_WEREWOLF); 38.  	    case PM_HUMAN_WEREWOLF:   return(PM_WEREWOLF); 39.  	    case PM_WEREJACKAL:	      return(PM_HUMAN_WEREJACKAL); 40.  	    case PM_HUMAN_WEREJACKAL: return(PM_WEREJACKAL); 41.  	    case PM_WERERAT:	      return(PM_HUMAN_WERERAT); 42.  	    case PM_HUMAN_WERERAT:    return(PM_WERERAT); 43.  	    default:		      return(0); 44.  	}  45.   }  46.    47.   void 48.  new_were(mon) 49.  register struct monst *mon; 50.  {  51.   	register int pm; 52.   53.   	pm = counter_were(monsndx(mon->data)); 54.  	if(!pm) { 55.  	    impossible("unknown lycanthrope %s.", mon->data->mname); 56.  	    return; 57.  	}  58.    59.   	if(canseemon(mon)) 60.  	    pline("%s changes into a %s.", Monnam(mon),  61.   			Hallucination ? rndmonnam :  62.   			is_human(&mons[pm]) ? "human" :  63.   			mons[pm].mname+4); 64.   65.   	set_mon_data(mon, &mons[pm], 0); 66.  	if (mon->msleep || !mon->mcanmove) { 67.  	    /* transformation wakens and/or revitalizes */ 68.  	    mon->msleep = 0; 69.  	    mon->mfrozen = 0;	/* not asleep or paralyzed */ 70.  	    mon->mcanmove = 1; 71.  	}  72.   	/* regenerate by 1/4 of the lost hit points */ 73.  	mon->mhp += (mon->mhpmax - mon->mhp) / 4; 74.  	newsym(mon->mx,mon->my); 75.  	mon_break_armor(mon); 76.  	possibly_unwield(mon); 77.  }  78.    79.   boolean 80.  were_summon(ptr,yours)	/* were-creature (even you) summons a horde */ 81.  register struct permonst *ptr; 82.  register boolean yours; 83.  {  84.   	register int i, typ, pm = monsndx(ptr); 85.  	register struct monst *mtmp; 86.  	boolean success = FALSE; 87.   88.   	if(Protection_from_shape_changers && !yours) 89.  		return FALSE; 90.  	for(i = rnd(5); i > 0; i--) { 91.  	   switch(pm) { 92.   93.   		case PM_WERERAT: 94.  		case PM_HUMAN_WERERAT: 95.  			typ = rn2(3) ? PM_SEWER_RAT : rn2(3) ? PM_GIANT_RAT : PM_RABID_RAT ; 96.  			break; 97.  		case PM_WEREJACKAL: 98.  		case PM_HUMAN_WEREJACKAL: 99.  			typ = PM_JACKAL; 100. 			break; 101. 		case PM_WEREWOLF: 102. 		case PM_HUMAN_WEREWOLF: 103. 			typ = rn2(5) ? PM_WOLF : PM_WINTER_WOLF ; 104. 			break; 105. 		default: 106. 			continue; 107. 	    }  108.  	    mtmp = makemon(&mons[typ], u.ux, u.uy); 109. 	    if (mtmp) success = TRUE; 110. 	    if (yours && mtmp) 111. 		(void) tamedog(mtmp, (struct obj *) 0); 112. 	}  113.  	return success; 114. }  115.   116.  void 117. you_were { 118. 	char qbuf[80]; 119. 	if(u.umonnum == u.ulycn) return; 120. 	if(Polymorph_control) { 121. 	    Sprintf(qbuf,"Do you want to change into a %s? ",  122.  					mons[u.ulycn].mname+4); 123. 	    if(yn(qbuf) == 'n') return; 124. 	}  125.  	(void) polymon(u.ulycn); 126. }  127.   128.  #endif /* OVLB */ 129.  130.  /*were.c*/