Source:NetHack 3.4.3/src/were.c

From NetHackWiki
Jump to: navigation, search

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

Top of file

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

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"

were_change

  1. #ifdef OVL0
  2.  
  3. void
  4. were_change(mon)
  5. register struct monst *mon;
  6. {
  7. 	if (!is_were(mon->data))
  8. 	    return;
  9.  
  10. 	if (is_human(mon->data)) {
  11. 	    if (!Protection_from_shape_changers &&
  12. 		!rn2(night() ? (flags.moonphase == FULL_MOON ?  3 : 30)
  13. 			     : (flags.moonphase == FULL_MOON ? 10 : 50))) {
  14. 		new_were(mon);		/* change into animal form */
  15. 		if (flags.soundok && !canseemon(mon)) {
  16. 		    const char *howler;
  17.  
  18. 		    switch (monsndx(mon->data)) {
  19. 		    case PM_WEREWOLF:	howler = "wolf";    break;
  20. 		    case PM_WEREJACKAL: howler = "jackal";  break;
  21. 		    default:		howler = (char *)0; break;
  22. 		    }
  23. 		    if (howler)
  24. 			You_hear("a %s howling at the moon.", howler);
  25. 		}
  26. 	    }
  27. 	} else if (!rn2(30) || Protection_from_shape_changers) {
  28. 	    new_were(mon);		/* change back into human form */
  29. 	}
  30. }
  31.  
  32. #endif /* OVL0 */

counter_were

  1. #ifdef OVLB
  2.  
  3. STATIC_DCL int FDECL(counter_were,(int));
  4.  
  5. STATIC_OVL int
  6. counter_were(pm)
  7. int pm;
  8. {
  9. 	switch(pm) {
  10. 	    case PM_WEREWOLF:	      return(PM_HUMAN_WEREWOLF);
  11. 	    case PM_HUMAN_WEREWOLF:   return(PM_WEREWOLF);
  12. 	    case PM_WEREJACKAL:	      return(PM_HUMAN_WEREJACKAL);
  13. 	    case PM_HUMAN_WEREJACKAL: return(PM_WEREJACKAL);
  14. 	    case PM_WERERAT:	      return(PM_HUMAN_WERERAT);
  15. 	    case PM_HUMAN_WERERAT:    return(PM_WERERAT);
  16. 	    default:		      return(0);
  17. 	}
  18. }

new_were

  1. void
  2. new_were(mon)
  3. register struct monst *mon;
  4. {
  5. 	register int pm;
  6.  
  7. 	pm = counter_were(monsndx(mon->data));
  8. 	if(!pm) {
  9. 	    impossible("unknown lycanthrope %s.", mon->data->mname);
  10. 	    return;
  11. 	}
  12.  
  13. 	if(canseemon(mon) && !Hallucination)
  14. 	    pline("%s changes into a %s.", Monnam(mon),
  15. 			is_human(&mons[pm]) ? "human" :
  16. 			mons[pm].mname+4);
  17.  
  18. 	set_mon_data(mon, &mons[pm], 0);
  19. 	if (mon->msleeping || !mon->mcanmove) {
  20. 	    /* transformation wakens and/or revitalizes */
  21. 	    mon->msleeping = 0;
  22. 	    mon->mfrozen = 0;	/* not asleep or paralyzed */
  23. 	    mon->mcanmove = 1;
  24. 	}
  25. 	/* regenerate by 1/4 of the lost hit points */
  26. 	mon->mhp += (mon->mhpmax - mon->mhp) / 4;
  27. 	newsym(mon->mx,mon->my);
  28. 	mon_break_armor(mon, FALSE);
  29. 	possibly_unwield(mon, FALSE);
  30. }

were_summon

  1. int
  2. were_summon(ptr,yours,visible,genbuf)	/* were-creature (even you) summons a horde */
  3. register struct permonst *ptr;
  4. register boolean yours;
  5. int *visible;			/* number of visible helpers created */
  6. char *genbuf;
  7. {
  8. 	register int i, typ, pm = monsndx(ptr);
  9. 	register struct monst *mtmp;
  10. 	int total = 0;
  11.  
  12. 	*visible = 0;
  13. 	if(Protection_from_shape_changers && !yours)
  14. 		return 0;
  15. 	for(i = rnd(5); i > 0; i--) {
  16. 	   switch(pm) {
  17.  
  18. 		case PM_WERERAT:
  19. 		case PM_HUMAN_WERERAT:
  20. 			typ = rn2(3) ? PM_SEWER_RAT : rn2(3) ? PM_GIANT_RAT : PM_RABID_RAT ;
  21. 			if (genbuf) Strcpy(genbuf, "rat");
  22. 			break;
  23. 		case PM_WEREJACKAL:
  24. 		case PM_HUMAN_WEREJACKAL:
  25. 			typ = PM_JACKAL;
  26. 			if (genbuf) Strcpy(genbuf, "jackal");
  27. 			break;
  28. 		case PM_WEREWOLF:
  29. 		case PM_HUMAN_WEREWOLF:
  30. 			typ = rn2(5) ? PM_WOLF : PM_WINTER_WOLF ;
  31. 			if (genbuf) Strcpy(genbuf, "wolf");
  32. 			break;
  33. 		default:
  34. 			continue;
  35. 	    }
  36. 	    mtmp = makemon(&mons[typ], u.ux, u.uy, NO_MM_FLAGS);
  37. 	    if (mtmp) {
  38. 		total++;
  39. 		if (canseemon(mtmp)) *visible += 1;
  40. 	    }
  41. 	    if (yours && mtmp)
  42. 		(void) tamedog(mtmp, (struct obj *) 0);
  43. 	}
  44. 	return total;
  45. }

you_were

  1. void
  2. you_were()
  3. {
  4. 	char qbuf[QBUFSZ];
  5.  
  6. 	if (Unchanging || (u.umonnum == u.ulycn)) return;
  7. 	if (Polymorph_control) {
  8. 	    /* `+4' => skip "were" prefix to get name of beast */
  9. 	    Sprintf(qbuf, "Do you want to change into %s? ",
  10. 		    an(mons[u.ulycn].mname+4));
  11. 	    if(yn(qbuf) == 'n') return;
  12. 	}
  13. 	(void) polymon(u.ulycn);
  14. }

you_unwere

  1. void
  2. you_unwere(purify)
  3. boolean purify;
  4. {
  5. 	if (purify) {
  6. 	    You_feel("purified.");
  7. 	    u.ulycn = NON_PM;	/* cure lycanthropy */
  8. 	}
  9. 	if (!Unchanging && is_were(youmonst.data) &&
  10. 		(!Polymorph_control || yn("Remain in beast form?") == 'n'))
  11. 	    rehumanize();
  12. }
  13.  
  14. #endif /* OVLB */
  15.  
  16. /*were.c*/