Source:SLASH'EM 0.0.7E7F2/were.c

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

The latest source code for vanilla NetHack is at Source code.

1.   /*	SCCS Id: @(#)were.c	3.4	2002/11/07	*/ 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.   	if (!is_were(mon->data)) 14.  	    return; 15.   16.   	if (is_human(mon->data)) { 17.  	    if (!Protection_from_shape_changers &&  18.   			!rn2(night ? (flags.moonphase == FULL_MOON ? 3 : 30) 19.  				     : (flags.moonphase == FULL_MOON ? 10 : 50))) { 20.  		new_were(mon);		/* change into animal form */ 21.  		if (flags.soundok && !canseemon(mon)) { 22.  		    const char *howler; 23.   24.   		    switch (monsndx(mon->data)) { 25.  		    case PM_HUMAN_WEREWOLF:	howler = "wolf";    break; 26.  		    case PM_HUMAN_WEREJACKAL:	howler = "jackal";  break; 27.  		    case PM_HUMAN_WEREPANTHER:	howler = "panther"; break; 28.  		    case PM_HUMAN_WERETIGER:	howler = "tiger";   break; 29.  		    default:			howler = (char *)0; break; 30.  		    }  31.   		    if (howler) 32.  			You_hear("a %s howling at the moon.", howler); 33.  		}  34.   	    }  35.   	} else if (!rn2(30) || Protection_from_shape_changers) { 36.  	    new_were(mon);		/* change back into human form */ 37.  	}  38.   }  39.    40.   #endif /* OVL0 */ 41.  #ifdef OVLB 42.   43.   int 44.  counter_were(pm) 45.  int pm; 46.  {  47.   	switch(pm) { 48.  	    case PM_WEREWOLF:	      return(PM_HUMAN_WEREWOLF); 49.  	    case PM_HUMAN_WEREWOLF:   return(PM_WEREWOLF); 50.  	    case PM_WEREJACKAL:	      return(PM_HUMAN_WEREJACKAL); 51.  	    case PM_HUMAN_WEREJACKAL: return(PM_WEREJACKAL); 52.  	    case PM_WERERAT:	      return(PM_HUMAN_WERERAT); 53.  	    case PM_HUMAN_WERERAT:    return(PM_WERERAT); 54.  	    case PM_WEREPANTHER:      return(PM_HUMAN_WEREPANTHER); 55.  	    case PM_HUMAN_WEREPANTHER:return(PM_WEREPANTHER); 56.  	    case PM_WERETIGER:        return(PM_HUMAN_WERETIGER); 57.  	    case PM_HUMAN_WERETIGER:  return(PM_WERETIGER); 58.  	    case PM_WERESNAKE:        return(PM_HUMAN_WERESNAKE); 59.  	    case PM_HUMAN_WERESNAKE:  return(PM_WERESNAKE); 60.  	    case PM_WERESPIDER:       return(PM_HUMAN_WERESPIDER); 61.  	    case PM_HUMAN_WERESPIDER: return(PM_WERESPIDER); 62.  	    default:		      return(0); 63.  	}  64.   }  65.    66.   void 67.  new_were(mon) 68.  register struct monst *mon; 69.  {  70.   	register int pm; 71.   72.   	pm = counter_were(monsndx(mon->data)); 73.  	if(!pm) { 74.  	    impossible("unknown lycanthrope %s.", mon->data->mname); 75.  	    return; 76.  	}  77.    78.   	if(canseemon(mon) && !Hallucination) 79.  	    pline("%s changes into a %s.", Monnam(mon),  80.   			is_human(&mons[pm]) ? "human" :  81.   			mons[pm].mname+4); 82.   83.   	set_mon_data(mon, &mons[pm], 0); 84.  	if (mon->msleeping || !mon->mcanmove) { 85.  	    /* transformation wakens and/or revitalizes */ 86.  	    mon->msleeping = 0; 87.  	    mon->mfrozen = 0;	/* not asleep or paralyzed */ 88.  	    mon->mcanmove = 1; 89.  	}  90.   	/* regenerate by 1/4 of the lost hit points */ 91.  	mon->mhp += (mon->mhpmax - mon->mhp) / 4; 92.  	newsym(mon->mx,mon->my); 93.  	mon_break_armor(mon, FALSE); 94.  	possibly_unwield(mon, FALSE); 95.  	(void) stop_timer(UNPOLY_MON, (genericptr_t) mon); 96.  	(void) start_timer(rn1(1000,1000), TIMER_MONSTER,  97.   		UNPOLY_MON, (genericptr_t) mon); 98.  }  99.    100.  int 101. were_summon(ptr,yours,visible,genbuf)	/* were-creature (even you) summons a horde */ 102. register struct permonst *ptr; 103. register boolean yours; 104. int *visible;			/* number of visible helpers created */ 105. char *genbuf; 106. {  107.  	register int i, typ, pm = monsndx(ptr); 108. 	register struct monst *mtmp; 109. 	int total = 0; 110.  111.  	*visible = 0; 112. 	if(Protection_from_shape_changers && !yours) 113. 		return 0; 114. 	/*  115.  	 * Allow lycanthropes in normal form to summon hordes as well. --ALI 116. 	 */  117.  	if (pm == PM_PLAYERMON) 118. 	    pm = urace.malenum; 119. 	for(i = rnd(2); i > 0; i--) { 120. 	   switch(pm) { 121.  122.  		case PM_WERERAT: 123. 		case PM_HUMAN_WERERAT: 124. 			typ = rn2(3) ? PM_SEWER_RAT : rn2(3) ? PM_GIANT_RAT : PM_RABID_RAT ; 125. 			if (genbuf) Strcpy(genbuf, "rat"); 126. 			break; 127. 		case PM_WEREJACKAL: 128. 		case PM_HUMAN_WEREJACKAL: 129. 			typ = PM_JACKAL; 130. 			if (genbuf) Strcpy(genbuf, "jackal"); 131. 			break; 132. 		case PM_WEREWOLF: 133. 		case PM_HUMAN_WEREWOLF: 134. 			typ = rn2(5) ? PM_WOLF : PM_WINTER_WOLF ; 135. 			if (genbuf) Strcpy(genbuf, "wolf"); 136. 			break; 137. 		case PM_WEREPANTHER: 138. 		case PM_HUMAN_WEREPANTHER: 139. 			typ = rn2(5) ? PM_JAGUAR : PM_PANTHER ; 140. 			if (genbuf) Strcpy(genbuf, "large cat"); 141. 			break; 142. 		case PM_WERETIGER: 143. 		case PM_HUMAN_WERETIGER: 144. 			typ = rn2(5) ? PM_JAGUAR : PM_TIGER ; 145. 			if (genbuf) Strcpy(genbuf, "large cat"); 146. 			break; 147. 		case PM_WERESNAKE: 148. 		case PM_HUMAN_WERESNAKE: 149. 			typ = rn2(5) ? PM_SNAKE : PM_PIT_VIPER ; 150. 			if (genbuf) Strcpy(genbuf, "snake"); 151. 			break; 152. 		case PM_WERESPIDER: 153. 		case PM_HUMAN_WERESPIDER: 154. 			typ = rn2(5) ? PM_CAVE_SPIDER : PM_RECLUSE_SPIDER ; 155. 			if (genbuf) Strcpy(genbuf, "spider"); 156. 			break; 157. 		default: 158. 			continue; 159. 	    }  160.  	    mtmp = makemon(&mons[typ], u.ux, u.uy, NO_MM_FLAGS); 161. 	    if (mtmp) { 162. 		total++; 163. 		if (canseemon(mtmp)) *visible += 1; 164. 	    }  165.  	    if (yours && mtmp) 166. 		(void) tamedog(mtmp, (struct obj *) 0); 167. 	}  168.  	return total; 169. }  170.   171.  void 172. you_were 173. {  174.  	char qbuf[QBUFSZ]; 175.  176.  	if (Unchanging || (u.umonnum == u.ulycn)) return; 177. 	if (Polymorph_control) { 178. 	    /* `+4' => skip "were" prefix to get name of beast */ 179. 	    Sprintf(qbuf, "Do you want to change into %s? ",  180.  		    an(mons[u.ulycn].mname+4)); 181. 	    if(yn(qbuf) == 'n') return; 182. 	}  183.  	(void) polymon(u.ulycn); 184. }  185.   186.  void 187. you_unwere(purify) 188. boolean purify; 189. {  190.  	boolean in_wereform = (u.umonnum == u.ulycn); 191.  192.  	if (purify) { 193. 	    if (Race_if(PM_HUMAN_WEREWOLF)) { 194. 		/* An attempt to purify you has been made! */ 195.  		if (in_wereform && Unchanging) { 196. 		    killer_format = NO_KILLER_PREFIX; 197. 		    killer = "purified while stuck in creature form"; 198. 		    pline_The("purification was deadly..."); 199. 		    done(DIED); 200. 		} else { 201. 		    You_feel("very bad!"); 202. 		    if (in_wereform) 203. 			rehumanize; 204. 		    (void) adjattrib(A_STR, -rn1(3,3), 2); 205. 		    (void) adjattrib(A_CON, -rn1(3,3), 1); 206. 		    losehp(u.uhp - (u.uhp > 10 ? rnd(5) : 1), "purification", 207.  			    KILLED_BY); 208. 		}  209.  		return; 210. 	    }  211.  	    You_feel("purified."); 212. 	    u.ulycn = NON_PM;	/* cure lycanthropy */ 213. 	    upermonst.mflags2 &= ~M2_WERE; 214. 	}  215.  	if (!Unchanging && in_wereform &&  216.  		(!Polymorph_control || yn("Remain in beast form?") == 'n')) 217. 	    rehumanize; 218. }  219.   220.  #endif /* OVLB */ 221.  222.  /*were.c*/