Difference between revisions of "Source:NetHack 3.4.3/src/wizard.c"

From NetHackWiki
Jump to navigation Jump to search
(Automated source code upload)
 
m (add headers for nasties and wizapp)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
__MIXEDSYNTAXHIGHLIGHT__
 +
Below is the full text to src/wizard.c from NetHack 3.4.3. To link to a particular line, write [[wizard.c#line123|<nowiki>[[wizard.c#line123]]</nowiki>]], for example.
 +
 +
== Top of file ==
  
Below is the full text to src/wizard.c from NetHack 3.4.3. To link to a particular line, write [[wizard.c#line123|<nowiki>[[wizard.c#line123]]</nowiki>]], for example.
 
 
  <span id="line1">1.    /* SCCS Id: @(#)wizard.c 3.4 2003/02/18 */</span>
 
  <span id="line1">1.    /* SCCS Id: @(#)wizard.c 3.4 2003/02/18 */</span>
 
  <span id="line2">2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */</span>
 
  <span id="line2">2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */</span>
Line 29: Line 32:
 
  <span id="line24">24.  STATIC_DCL long FDECL(strategy, (struct monst *));</span>
 
  <span id="line24">24.  STATIC_DCL long FDECL(strategy, (struct monst *));</span>
 
  <span id="line25">25.  </span>
 
  <span id="line25">25.  </span>
 +
 +
== nasties ==
 +
 
  <span id="line26">26.  static NEARDATA const int nasties[] = {</span>
 
  <span id="line26">26.  static NEARDATA const int nasties[] = {</span>
 
  <span id="line27">27.  PM_COCKATRICE, PM_ETTIN, PM_STALKER, PM_MINOTAUR, PM_RED_DRAGON,</span>
 
  <span id="line27">27.  PM_COCKATRICE, PM_ETTIN, PM_STALKER, PM_MINOTAUR, PM_RED_DRAGON,</span>
Line 41: Line 47:
 
  <span id="line36">36.  };</span>
 
  <span id="line36">36.  };</span>
 
  <span id="line37">37.  </span>
 
  <span id="line37">37.  </span>
 +
 +
== wizapp ==
 +
 
  <span id="line38">38.  static NEARDATA const unsigned wizapp[] = {</span>
 
  <span id="line38">38.  static NEARDATA const unsigned wizapp[] = {</span>
 
  <span id="line39">39.  PM_HUMAN, PM_WATER_DEMON, PM_VAMPIRE,</span>
 
  <span id="line39">39.  PM_HUMAN, PM_WATER_DEMON, PM_VAMPIRE,</span>
Line 53: Line 62:
 
  <span id="line48">48.  #ifdef OVL0</span>
 
  <span id="line48">48.  #ifdef OVL0</span>
 
  <span id="line49">49.  </span>
 
  <span id="line49">49.  </span>
 +
 +
== amulet ==
 +
 
  <span id="line50">50.  /* If you've found the Amulet, make the Wizard appear after some time */</span>
 
  <span id="line50">50.  /* If you've found the Amulet, make the Wizard appear after some time */</span>
 
  <span id="line51">51.  /* Also, give hints about portal locations, if amulet is worn/wielded -dlc */</span>
 
  <span id="line51">51.  /* Also, give hints about portal locations, if amulet is worn/wielded -dlc */</span>
Line 101: Line 113:
 
  <span id="line96">96.  #ifdef OVLB</span>
 
  <span id="line96">96.  #ifdef OVLB</span>
 
  <span id="line97">97.  </span>
 
  <span id="line97">97.  </span>
 +
 +
== mon_has_amulet ==
 +
 
  <span id="line98">98.  int</span>
 
  <span id="line98">98.  int</span>
 
  <span id="line99">99.  mon_has_amulet(mtmp)</span>
 
  <span id="line99">99.  mon_has_amulet(mtmp)</span>
Line 112: Line 127:
 
  <span id="line107">107.  }</span>
 
  <span id="line107">107.  }</span>
 
  <span id="line108">108.  </span>
 
  <span id="line108">108.  </span>
 +
 +
== mon_has_special ==
 +
 
  <span id="line109">109.  int</span>
 
  <span id="line109">109.  int</span>
 
  <span id="line110">110.  mon_has_special(mtmp)</span>
 
  <span id="line110">110.  mon_has_special(mtmp)</span>
Line 127: Line 145:
 
  <span id="line122">122.  }</span>
 
  <span id="line122">122.  }</span>
 
  <span id="line123">123.  </span>
 
  <span id="line123">123.  </span>
 +
 
  <span id="line124">124.  /*</span>
 
  <span id="line124">124.  /*</span>
 
  <span id="line125">125.  * New for 3.1  Strategy / Tactics for the wiz, as well as other</span>
 
  <span id="line125">125.  * New for 3.1  Strategy / Tactics for the wiz, as well as other</span>
Line 138: Line 157:
 
  <span id="line133">133.  #define M_Wants(mask) (mtmp->data->mflags3 & (mask))</span>
 
  <span id="line133">133.  #define M_Wants(mask) (mtmp->data->mflags3 & (mask))</span>
 
  <span id="line134">134.  </span>
 
  <span id="line134">134.  </span>
 +
 +
== which_arti ==
 +
 
  <span id="line135">135.  STATIC_OVL short</span>
 
  <span id="line135">135.  STATIC_OVL short</span>
 
  <span id="line136">136.  which_arti(mask)</span>
 
  <span id="line136">136.  which_arti(mask)</span>
Line 152: Line 174:
 
  <span id="line147">147.  }</span>
 
  <span id="line147">147.  }</span>
 
  <span id="line148">148.  </span>
 
  <span id="line148">148.  </span>
 +
 +
== mon_has_arti ==
 +
 
  <span id="line149">149.  /*</span>
 
  <span id="line149">149.  /*</span>
 
  <span id="line150">150.  * If "otyp" is zero, it triggers a check for the quest_artifact,</span>
 
  <span id="line150">150.  * If "otyp" is zero, it triggers a check for the quest_artifact,</span>
Line 175: Line 200:
 
  <span id="line170">170.  }</span>
 
  <span id="line170">170.  }</span>
 
  <span id="line171">171.  </span>
 
  <span id="line171">171.  </span>
 +
 +
== other_mon_has_arti ==
 +
 
  <span id="line172">172.  STATIC_OVL struct monst *</span>
 
  <span id="line172">172.  STATIC_OVL struct monst *</span>
 
  <span id="line173">173.  other_mon_has_arti(mtmp, otyp)</span>
 
  <span id="line173">173.  other_mon_has_arti(mtmp, otyp)</span>
Line 190: Line 218:
 
  <span id="line185">185.  }</span>
 
  <span id="line185">185.  }</span>
 
  <span id="line186">186.  </span>
 
  <span id="line186">186.  </span>
 +
 +
== on_ground ==
 +
 
  <span id="line187">187.  STATIC_OVL struct obj *</span>
 
  <span id="line187">187.  STATIC_OVL struct obj *</span>
 
  <span id="line188">188.  on_ground(otyp)</span>
 
  <span id="line188">188.  on_ground(otyp)</span>
Line 205: Line 236:
 
  <span id="line200">200.  }</span>
 
  <span id="line200">200.  }</span>
 
  <span id="line201">201.  </span>
 
  <span id="line201">201.  </span>
 +
 +
== you_have ==
 +
 
  <span id="line202">202.  STATIC_OVL boolean</span>
 
  <span id="line202">202.  STATIC_OVL boolean</span>
 
  <span id="line203">203.  you_have(mask)</span>
 
  <span id="line203">203.  you_have(mask)</span>
Line 220: Line 254:
 
  <span id="line215">215.  }</span>
 
  <span id="line215">215.  }</span>
 
  <span id="line216">216.  </span>
 
  <span id="line216">216.  </span>
 +
 +
== target_on ==
 +
 
  <span id="line217">217.  STATIC_OVL long</span>
 
  <span id="line217">217.  STATIC_OVL long</span>
 
  <span id="line218">218.  target_on(mask, mtmp)</span>
 
  <span id="line218">218.  target_on(mask, mtmp)</span>
Line 243: Line 280:
 
  <span id="line238">238.  }</span>
 
  <span id="line238">238.  }</span>
 
  <span id="line239">239.  </span>
 
  <span id="line239">239.  </span>
 +
 +
== strategy ==
 +
 
  <span id="line240">240.  STATIC_OVL long</span>
 
  <span id="line240">240.  STATIC_OVL long</span>
 
  <span id="line241">241.  strategy(mtmp)</span>
 
  <span id="line241">241.  strategy(mtmp)</span>
Line 302: Line 342:
 
  <span id="line297">297.  }</span>
 
  <span id="line297">297.  }</span>
 
  <span id="line298">298.  </span>
 
  <span id="line298">298.  </span>
 +
 +
== tactics ==
 +
 
  <span id="line299">299.  int</span>
 
  <span id="line299">299.  int</span>
 
  <span id="line300">300.  tactics(mtmp)</span>
 
  <span id="line300">300.  tactics(mtmp)</span>
Line 380: Line 423:
 
  <span id="line375">375.  }</span>
 
  <span id="line375">375.  }</span>
 
  <span id="line376">376.  </span>
 
  <span id="line376">376.  </span>
 +
 +
== aggravate ==
 +
 
  <span id="line377">377.  void</span>
 
  <span id="line377">377.  void</span>
 
  <span id="line378">378.  aggravate()</span>
 
  <span id="line378">378.  aggravate()</span>
Line 395: Line 441:
 
  <span id="line390">390.  }</span>
 
  <span id="line390">390.  }</span>
 
  <span id="line391">391.  </span>
 
  <span id="line391">391.  </span>
 +
 +
== clonewiz ==
 +
 
  <span id="line392">392.  void</span>
 
  <span id="line392">392.  void</span>
 
  <span id="line393">393.  clonewiz()</span>
 
  <span id="line393">393.  clonewiz()</span>
Line 413: Line 462:
 
  <span id="line408">408.  }</span>
 
  <span id="line408">408.  }</span>
 
  <span id="line409">409.  </span>
 
  <span id="line409">409.  </span>
 +
 +
== pick_nasty ==
 +
 
  <span id="line410">410.  /* also used by newcham() */</span>
 
  <span id="line410">410.  /* also used by newcham() */</span>
 
  <span id="line411">411.  int</span>
 
  <span id="line411">411.  int</span>
Line 422: Line 474:
 
  <span id="line417">417.  }</span>
 
  <span id="line417">417.  }</span>
 
  <span id="line418">418.  </span>
 
  <span id="line418">418.  </span>
 +
 +
== nasty ==
 +
 
  <span id="line419">419.  /* create some nasty monsters, aligned or neutral with the caster */</span>
 
  <span id="line419">419.  /* create some nasty monsters, aligned or neutral with the caster */</span>
 
  <span id="line420">420.  /* a null caster defaults to a chaotic caster (e.g. the wizard) */</span>
 
  <span id="line420">420.  /* a null caster defaults to a chaotic caster (e.g. the wizard) */</span>
Line 474: Line 529:
 
  <span id="line469">469.  }</span>
 
  <span id="line469">469.  }</span>
 
  <span id="line470">470.  </span>
 
  <span id="line470">470.  </span>
 +
 +
== resurrect ==
 +
 
  <span id="line471">471.  /* Let's resurrect the wizard, for some unexpected fun. */</span>
 
  <span id="line471">471.  /* Let's resurrect the wizard, for some unexpected fun. */</span>
 
  <span id="line472">472.  void</span>
 
  <span id="line472">472.  void</span>
Line 523: Line 581:
 
  <span id="line518">518.  }</span>
 
  <span id="line518">518.  }</span>
 
  <span id="line519">519.  </span>
 
  <span id="line519">519.  </span>
 +
 +
== intervene ==
 +
 
  <span id="line520">520.  /* Here, we make trouble for the poor shmuck who actually */</span>
 
  <span id="line520">520.  /* Here, we make trouble for the poor shmuck who actually */</span>
 
  <span id="line521">521.  /* managed to do in the Wizard. */</span>
 
  <span id="line521">521.  /* managed to do in the Wizard. */</span>
Line 548: Line 609:
 
  <span id="line543">543.  }</span>
 
  <span id="line543">543.  }</span>
 
  <span id="line544">544.  </span>
 
  <span id="line544">544.  </span>
 +
 +
== wizdead ==
 +
 
  <span id="line545">545.  void</span>
 
  <span id="line545">545.  void</span>
 
  <span id="line546">546.  wizdead()</span>
 
  <span id="line546">546.  wizdead()</span>
Line 558: Line 622:
 
  <span id="line553">553.  }</span>
 
  <span id="line553">553.  }</span>
 
  <span id="line554">554.  </span>
 
  <span id="line554">554.  </span>
 +
 +
==random_insult==
 
  <span id="line555">555.  const char * const random_insult[] = {</span>
 
  <span id="line555">555.  const char * const random_insult[] = {</span>
 
  <span id="line556">556.  "antic",</span>
 
  <span id="line556">556.  "antic",</span>
Line 589: Line 655:
 
  <span id="line584">584.  };</span>
 
  <span id="line584">584.  };</span>
 
  <span id="line585">585.  </span>
 
  <span id="line585">585.  </span>
 +
 +
Many of these words are archaic and some explanation is in order:
 +
 +
{|class="wikitable"
 +
!Word!!Definition used here
 +
|-
 +
|antic||A performer of a ludicrous part
 +
|-
 +
|caitiff||Despicable coward
 +
|-
 +
|coistrel||A mean fellow
 +
|-
 +
|footpad||Highwayman, robber
 +
|-
 +
|maledict||Accursed
 +
|-
 +
|niddering||Coward, wretch
 +
|-
 +
|poltroon||Base coward
 +
|-
 +
|varlet||Knave; also a knight's attendant
 +
|-
 +
|villein||A peasant who must serve a feudal lord but is free with respect to others
 +
|-
 +
|wittol||A man whose wife is unfaithful and who consents to her infidelity
 +
|}
 +
 +
==random_malediction==
 
  <span id="line586">586.  const char * const random_malediction[] = {</span>
 
  <span id="line586">586.  const char * const random_malediction[] = {</span>
 
  <span id="line587">587.  "Hell shall soon claim thy remains,",</span>
 
  <span id="line587">587.  "Hell shall soon claim thy remains,",</span>
Line 603: Line 697:
 
  <span id="line598">598.  };</span>
 
  <span id="line598">598.  };</span>
 
  <span id="line599">599.  </span>
 
  <span id="line599">599.  </span>
 +
 +
== cuss ==
 +
 
  <span id="line600">600.  /* Insult or intimidate the player */</span>
 
  <span id="line600">600.  /* Insult or intimidate the player */</span>
 
  <span id="line601">601.  void</span>
 
  <span id="line601">601.  void</span>

Latest revision as of 17:32, 28 November 2012

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

Top of file

/*	SCCS Id: @(#)wizard.c	3.4	2003/02/18	*/
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* 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.

/* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
/*	       - heavily modified to give the wiz balls.  (genat!mike)   */
/*	       - dewimped and given some maledictions. -3. */
/*	       - generalized for 3.1 (mike@bullns.on01.bull.ca) */

#include "hack.h"
#include "qtext.h"
#include "epri.h"

extern const int monstr[];

#ifdef OVLB

STATIC_DCL short FDECL(which_arti, (int));
STATIC_DCL boolean FDECL(mon_has_arti, (struct monst *,SHORT_P));
STATIC_DCL struct monst *FDECL(other_mon_has_arti, (struct monst *,SHORT_P));
STATIC_DCL struct obj *FDECL(on_ground, (SHORT_P));
STATIC_DCL boolean FDECL(you_have, (int));
STATIC_DCL long FDECL(target_on, (int,struct monst *));
STATIC_DCL long FDECL(strategy, (struct monst *));

nasties

static NEARDATA const int nasties[] = {
	PM_COCKATRICE, PM_ETTIN, PM_STALKER, PM_MINOTAUR, PM_RED_DRAGON,
	PM_BLACK_DRAGON, PM_GREEN_DRAGON, PM_OWLBEAR, PM_PURPLE_WORM,
	PM_ROCK_TROLL, PM_XAN, PM_GREMLIN, PM_UMBER_HULK, PM_VAMPIRE_LORD,
	PM_XORN, PM_ZRUTY, PM_ELF_LORD, PM_ELVENKING, PM_YELLOW_DRAGON,
	PM_LEOCROTTA, PM_BALUCHITHERIUM, PM_CARNIVOROUS_APE, PM_FIRE_GIANT,
	PM_COUATL, PM_CAPTAIN, PM_WINGED_GARGOYLE, PM_MASTER_MIND_FLAYER,
	PM_FIRE_ELEMENTAL, PM_JABBERWOCK, PM_ARCH_LICH, PM_OGRE_KING,
	PM_OLOG_HAI, PM_IRON_GOLEM, PM_OCHRE_JELLY, PM_GREEN_SLIME,
	PM_DISENCHANTER
	};

wizapp

static NEARDATA const unsigned wizapp[] = {
	PM_HUMAN, PM_WATER_DEMON, PM_VAMPIRE,
	PM_RED_DRAGON, PM_TROLL, PM_UMBER_HULK,
	PM_XORN, PM_XAN, PM_COCKATRICE,
	PM_FLOATING_EYE,
	PM_GUARDIAN_NAGA,
	PM_TRAPPER
};

#endif /* OVLB */
#ifdef OVL0

amulet

/* If you've found the Amulet, make the Wizard appear after some time */
/* Also, give hints about portal locations, if amulet is worn/wielded -dlc */
void
amulet()
{
	struct monst *mtmp;
	struct trap *ttmp;
	struct obj *amu;

#if 0		/* caller takes care of this check */
	if (!u.uhave.amulet)
		return;
#endif
	if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR) ||
	     ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR))
	    && !rn2(15)) {
	    for(ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) {
		if(ttmp->ttyp == MAGIC_PORTAL) {
		    int du = distu(ttmp->tx, ttmp->ty);
		    if (du <= 9)
			pline("%s hot!", Tobjnam(amu, "feel"));
		    else if (du <= 64)
			pline("%s very warm.", Tobjnam(amu, "feel"));
		    else if (du <= 144)
			pline("%s warm.", Tobjnam(amu, "feel"));
		    /* else, the amulet feels normal */
		    break;
		}
	    }
	}

	if (!flags.no_of_wizards)
		return;
	/* find Wizard, and wake him if necessary */
	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
	    if (!DEADMONSTER(mtmp) && mtmp->iswiz && mtmp->msleeping && !rn2(40)) {
		mtmp->msleeping = 0;
		if (distu(mtmp->mx,mtmp->my) > 2)
		    You(
"get the creepy feeling that somebody noticed your taking the Amulet."
		    );
		return;
	    }
}

#endif /* OVL0 */
#ifdef OVLB

mon_has_amulet

int
mon_has_amulet(mtmp)
register struct monst *mtmp;
{
	register struct obj *otmp;

	for(otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
		if(otmp->otyp == AMULET_OF_YENDOR) return(1);
	return(0);
}

mon_has_special

int
mon_has_special(mtmp)
register struct monst *mtmp;
{
	register struct obj *otmp;

	for(otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
		if(otmp->otyp == AMULET_OF_YENDOR ||
			is_quest_artifact(otmp) ||
			otmp->otyp == BELL_OF_OPENING ||
			otmp->otyp == CANDELABRUM_OF_INVOCATION ||
			otmp->otyp == SPE_BOOK_OF_THE_DEAD) return(1);
	return(0);
}
/*
*	New for 3.1  Strategy / Tactics for the wiz, as well as other
*	monsters that are "after" something (defined via mflag3).
*
*	The strategy section decides *what* the monster is going
*	to attempt, the tactics section implements the decision.
*/
#define STRAT(w, x, y, typ) (w | ((long)(x)<<16) | ((long)(y)<<8) | (long)typ)

#define M_Wants(mask)	(mtmp->data->mflags3 & (mask))

which_arti

STATIC_OVL short
which_arti(mask)
	register int mask;
{
	switch(mask) {
	    case M3_WANTSAMUL:	return(AMULET_OF_YENDOR);
	    case M3_WANTSBELL:	return(BELL_OF_OPENING);
	    case M3_WANTSCAND:	return(CANDELABRUM_OF_INVOCATION);
	    case M3_WANTSBOOK:	return(SPE_BOOK_OF_THE_DEAD);
	    default:		break;	/* 0 signifies quest artifact */
	}
	return(0);
}

mon_has_arti

/*
*	If "otyp" is zero, it triggers a check for the quest_artifact,
*	since bell, book, candle, and amulet are all objects, not really
*	artifacts right now.	[MRS]
*/
STATIC_OVL boolean
mon_has_arti(mtmp, otyp)
	register struct monst *mtmp;
	register short	otyp;
{
	register struct obj *otmp;

	for(otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
	    if(otyp) {
		if(otmp->otyp == otyp)
			return(1);
	    }
	     else if(is_quest_artifact(otmp)) return(1);
	}
	return(0);

}

other_mon_has_arti

STATIC_OVL struct monst *
other_mon_has_arti(mtmp, otyp)
	register struct monst *mtmp;
	register short	otyp;
{
	register struct monst *mtmp2;

	for(mtmp2 = fmon; mtmp2; mtmp2 = mtmp2->nmon)
	    /* no need for !DEADMONSTER check here since they have no inventory */
	    if(mtmp2 != mtmp)
		if(mon_has_arti(mtmp2, otyp)) return(mtmp2);

	return((struct monst *)0);
}

on_ground

STATIC_OVL struct obj *
on_ground(otyp)
	register short	otyp;
{
	register struct obj *otmp;

	for (otmp = fobj; otmp; otmp = otmp->nobj)
	    if (otyp) {
		if (otmp->otyp == otyp)
		    return(otmp);
	    } else if (is_quest_artifact(otmp))
		return(otmp);
	return((struct obj *)0);
}

you_have

STATIC_OVL boolean
you_have(mask)
	register int mask;
{
	switch(mask) {
	    case M3_WANTSAMUL:	return(boolean)(u.uhave.amulet);
	    case M3_WANTSBELL:	return(boolean)(u.uhave.bell);
	    case M3_WANTSCAND:	return(boolean)(u.uhave.menorah);
	    case M3_WANTSBOOK:	return(boolean)(u.uhave.book);
	    case M3_WANTSARTI:	return(boolean)(u.uhave.questart);
	    default:		break;
	}
	return(0);
}

target_on

STATIC_OVL long
target_on(mask, mtmp)
	register int mask;
	register struct monst *mtmp;
{
	register short	otyp;
	register struct obj *otmp;
	register struct monst *mtmp2;

	if(!M_Wants(mask))	return(STRAT_NONE);

	otyp = which_arti(mask);
	if(!mon_has_arti(mtmp, otyp)) {
	    if(you_have(mask))
		return(STRAT(STRAT_PLAYER, u.ux, u.uy, mask));
	    else if((otmp = on_ground(otyp)))
		return(STRAT(STRAT_GROUND, otmp->ox, otmp->oy, mask));
	    else if((mtmp2 = other_mon_has_arti(mtmp, otyp)))
		return(STRAT(STRAT_MONSTR, mtmp2->mx, mtmp2->my, mask));
	}
	return(STRAT_NONE);
}

strategy

STATIC_OVL long
strategy(mtmp)
	register struct monst *mtmp;
{
	long strat, dstrat;

	if (!is_covetous(mtmp->data) ||
		/* perhaps a shopkeeper has been polymorphed into a master
		   lich; we don't want it teleporting to the stairs to heal
		   because that will leave its shop untended */
		(mtmp->isshk && inhishop(mtmp)))
	    return STRAT_NONE;

	switch((mtmp->mhp*3)/mtmp->mhpmax) {	/* 0-3 */

	   default:
	    case 0:	/* panic time - mtmp is almost snuffed */
			return(STRAT_HEAL);

	    case 1:	/* the wiz is less cautious */
			if(mtmp->data != &mons[PM_WIZARD_OF_YENDOR])
			    return(STRAT_HEAL);
			/* else fall through */

	    case 2:	dstrat = STRAT_HEAL;
			break;

	    case 3:	dstrat = STRAT_NONE;
			break;
	}

	if(flags.made_amulet)
	    if((strat = target_on(M3_WANTSAMUL, mtmp)) != STRAT_NONE)
		return(strat);

	if(u.uevent.invoked) {		/* priorities change once gate opened */

	    if((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
		return(strat);
	    if((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
		return(strat);
	    if((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
		return(strat);
	    if((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
		return(strat);
	} else {

	    if((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
		return(strat);
	    if((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
		return(strat);
	    if((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
		return(strat);
	    if((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
		return(strat);
	}
	return(dstrat);
}

tactics

int
tactics(mtmp)
	register struct monst *mtmp;
{
	long strat = strategy(mtmp);

	mtmp->mstrategy = (mtmp->mstrategy & STRAT_WAITMASK) | strat;

	switch (strat) {
	    case STRAT_HEAL:	/* hide and recover */
		/* if wounded, hole up on or near the stairs (to block them) */
		/* unless, of course, there are no stairs (e.g. endlevel) */
		mtmp->mavenge = 1; /* covetous monsters attack while fleeing */
		if (In_W_tower(mtmp->mx, mtmp->my, &u.uz) ||
			(mtmp->iswiz && !xupstair && !mon_has_amulet(mtmp))) {
		    if (!rn2(3 + mtmp->mhp/10)) (void) rloc(mtmp, FALSE);
		} else if (xupstair &&
			 (mtmp->mx != xupstair || mtmp->my != yupstair)) {
		    (void) mnearto(mtmp, xupstair, yupstair, TRUE);
		}
		/* if you're not around, cast healing spells */
		if (distu(mtmp->mx,mtmp->my) > (BOLT_LIM * BOLT_LIM))
		    if(mtmp->mhp <= mtmp->mhpmax - 8) {
			mtmp->mhp += rnd(8);
			return(1);
		    }
		/* fall through :-) */

	    case STRAT_NONE:	/* harrass */
		if (!rn2(!mtmp->mflee ? 5 : 33)) mnexto(mtmp);
		return(0);

	    default:		/* kill, maim, pillage! */
	    {
		long  where = (strat & STRAT_STRATMASK);
		xchar tx = STRAT_GOALX(strat),
		      ty = STRAT_GOALY(strat);
		int   targ = strat & STRAT_GOAL;
		struct obj *otmp;

		if(!targ) { /* simply wants you to close */
		    return(0);
		}
		if((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) {
		    /* player is standing on it (or has it) */
		    mnexto(mtmp);
		    return(0);
		}
		if(where == STRAT_GROUND) {
		    if(!MON_AT(tx, ty) || (mtmp->mx == tx && mtmp->my == ty)) {
			/* teleport to it and pick it up */
			rloc_to(mtmp, tx, ty);	/* clean old pos */

			if ((otmp = on_ground(which_arti(targ))) != 0) {
			    if (cansee(mtmp->mx, mtmp->my))
				pline("%s picks up %s.",
				    Monnam(mtmp),
				    (distu(mtmp->mx, mtmp->my) <= 5) ?
				     doname(otmp) : distant_name(otmp, doname));
			    obj_extract_self(otmp);
			    (void) mpickobj(mtmp, otmp);
			    return(1);
			} else return(0);
		    } else {
			/* a monster is standing on it - cause some trouble */
			if (!rn2(5)) mnexto(mtmp);
			return(0);
		    }
	        } else { /* a monster has it - 'port beside it. */
		    (void) mnearto(mtmp, tx, ty, FALSE);
		    return(0);
		}
	    }
	}
	/*NOTREACHED*/
	return(0);
}

aggravate

void
aggravate()
{
	register struct monst *mtmp;

	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
	    if (!DEADMONSTER(mtmp)) {
		mtmp->msleeping = 0;
		if(!mtmp->mcanmove && !rn2(5)) {
			mtmp->mfrozen = 0;
			mtmp->mcanmove = 1;
		}
	    }
}

clonewiz

void
clonewiz()
{
	register struct monst *mtmp2;

	if ((mtmp2 = makemon(&mons[PM_WIZARD_OF_YENDOR],
				u.ux, u.uy, NO_MM_FLAGS)) != 0) {
	    mtmp2->msleeping = mtmp2->mtame = mtmp2->mpeaceful = 0;
	    if (!u.uhave.amulet && rn2(2)) {  /* give clone a fake */
		(void) add_to_minv(mtmp2, mksobj(FAKE_AMULET_OF_YENDOR,
					TRUE, FALSE));
	    }
	    mtmp2->m_ap_type = M_AP_MONSTER;
	    mtmp2->mappearance = wizapp[rn2(SIZE(wizapp))];
	    newsym(mtmp2->mx,mtmp2->my);
	}
}

pick_nasty

/* also used by newcham() */
int
pick_nasty()
{
/* To do?  Possibly should filter for appropriate forms when
in the elemental planes or surrounded by water or lava. */
return nasties[rn2(SIZE(nasties))];
}

nasty

/* create some nasty monsters, aligned or neutral with the caster */
/* a null caster defaults to a chaotic caster (e.g. the wizard) */
int
nasty(mcast)
	struct monst *mcast;
{
register struct monst	*mtmp;
register int	i, j, tmp;
int castalign = (mcast ? mcast->data->maligntyp : -1);
coord bypos;
int count=0;

if(!rn2(10) && Inhell) {
	msummon((struct monst *) 0);	/* summons like WoY */
	count++;
} else {
	tmp = (u.ulevel > 3) ? u.ulevel/3 : 1; /* just in case -- rph */
	/* if we don't have a casting monster, the nasties appear around you */
	bypos.x = u.ux;
	bypos.y = u.uy;
	for(i = rnd(tmp); i > 0; --i)
	    for(j=0; j<20; j++) {
		int makeindex;

		/* Don't create more spellcasters of the monsters' level or
		 * higher--avoids chain summoners filling up the level.
		 */
		do {
		    makeindex = pick_nasty();
		} while(mcast && attacktype(&mons[makeindex], AT_MAGC) &&
			monstr[makeindex] >= monstr[mcast->mnum]);
		/* do this after picking the monster to place */
		if (mcast &&
		    !enexto(&bypos, mcast->mux, mcast->muy, &mons[makeindex]))
		    continue;
		if ((mtmp = makemon(&mons[makeindex],
				    bypos.x, bypos.y, NO_MM_FLAGS)) != 0) {
		    mtmp->msleeping = mtmp->mpeaceful = mtmp->mtame = 0;
		    set_malign(mtmp);
		} else /* GENOD? */
		    mtmp = makemon((struct permonst *)0,
					bypos.x, bypos.y, NO_MM_FLAGS);
		if(mtmp && (mtmp->data->maligntyp == 0 ||
		            sgn(mtmp->data->maligntyp) == sgn(castalign)) ) {
		    count++;
		    break;
		}
	    }
}
return count;
}

resurrect

/*	Let's resurrect the wizard, for some unexpected fun.	*/
void
resurrect()
{
	struct monst *mtmp, **mmtmp;
	long elapsed;
	const char *verb;

	if (!flags.no_of_wizards) {
	    /* make a new Wizard */
	    verb = "kill";
	    mtmp = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, MM_NOWAIT);
	} else {
	    /* look for a migrating Wizard */
	    verb = "elude";
	    mmtmp = &migrating_mons;
	    while ((mtmp = *mmtmp) != 0) {
		if (mtmp->iswiz &&
			/* if he has the Amulet, he won't bring it to you */
			!mon_has_amulet(mtmp) &&
			(elapsed = monstermoves - mtmp->mlstmv) > 0L) {
		    mon_catchup_elapsed_time(mtmp, elapsed);
		    if (elapsed >= LARGEST_INT) elapsed = LARGEST_INT - 1;
		    elapsed /= 50L;
		    if (mtmp->msleeping && rn2((int)elapsed + 1))
			mtmp->msleeping = 0;
		    if (mtmp->mfrozen == 1) /* would unfreeze on next move */
			mtmp->mfrozen = 0,  mtmp->mcanmove = 1;
		    if (mtmp->mcanmove && !mtmp->msleeping) {
			*mmtmp = mtmp->nmon;
			mon_arrive(mtmp, TRUE);
			/* note: there might be a second Wizard; if so,
			   he'll have to wait til the next resurrection */
			break;
		    }
		}
		mmtmp = &mtmp->nmon;
	    }
	}

	if (mtmp) {
		mtmp->msleeping = mtmp->mtame = mtmp->mpeaceful = 0;
		set_malign(mtmp);
		pline("A voice booms out...");
		verbalize("So thou thought thou couldst %s me, fool.", verb);
	}

}

intervene

/*	Here, we make trouble for the poor shmuck who actually	*/
/*	managed to do in the Wizard.				*/
void
intervene()
{
	int which = Is_astralevel(&u.uz) ? rnd(4) : rn2(6);
	/* cases 0 and 5 don't apply on the Astral level */
	switch (which) {
	    case 0:
	    case 1:	You_feel("vaguely nervous.");
			break;
	    case 2:	if (!Blind)
			    You("notice a %s glow surrounding you.",
				  hcolor(NH_BLACK));
			rndcurse();
			break;
	    case 3:	aggravate();
			break;
	    case 4:	(void)nasty((struct monst *)0);
			break;
	    case 5:	resurrect();
			break;
	}
}

wizdead

void
wizdead()
{
	flags.no_of_wizards--;
	if (!u.uevent.udemigod) {
		u.uevent.udemigod = TRUE;
		u.udg_cnt = rn1(250, 50);
	}
}

random_insult

const char * const random_insult[] = {
	"antic",
	"blackguard",
	"caitiff",
	"chucklehead",
	"coistrel",
	"craven",
	"cretin",
	"cur",
	"dastard",
	"demon fodder",
	"dimwit",
	"dolt",
	"fool",
	"footpad",
	"imbecile",
	"knave",
	"maledict",
	"miscreant",
	"niddering",
	"poltroon",
	"rattlepate",
	"reprobate",
	"scapegrace",
	"varlet",
	"villein",	/* (sic.) */
	"wittol",
	"worm",
	"wretch",
};

Many of these words are archaic and some explanation is in order:

Word Definition used here
antic A performer of a ludicrous part
caitiff Despicable coward
coistrel A mean fellow
footpad Highwayman, robber
maledict Accursed
niddering Coward, wretch
poltroon Base coward
varlet Knave; also a knight's attendant
villein A peasant who must serve a feudal lord but is free with respect to others
wittol A man whose wife is unfaithful and who consents to her infidelity

random_malediction

const char * const random_malediction[] = {
	"Hell shall soon claim thy remains,",
	"I chortle at thee, thou pathetic",
	"Prepare to die, thou",
	"Resistance is useless,",
	"Surrender or die, thou",
	"There shall be no mercy, thou",
	"Thou shalt repent of thy cunning,",
	"Thou art as a flea to me,",
	"Thou art doomed,",
	"Thy fate is sealed,",
	"Verily, thou shalt be one dead"
};

cuss

/* Insult or intimidate the player */
void
cuss(mtmp)
register struct monst	*mtmp;
{
	if (mtmp->iswiz) {
	    if (!rn2(5))  /* typical bad guy action */
		pline("%s laughs fiendishly.", Monnam(mtmp));
	    else
		if (u.uhave.amulet && !rn2(SIZE(random_insult)))
		    verbalize("Relinquish the amulet, %s!",
			  random_insult[rn2(SIZE(random_insult))]);
		else if (u.uhp < 5 && !rn2(2))	/* Panic */
		    verbalize(rn2(2) ?
			  "Even now thy life force ebbs, %s!" :
			  "Savor thy breath, %s, it be thy last!",
			  random_insult[rn2(SIZE(random_insult))]);
		else if (mtmp->mhp < 5 && !rn2(2))	/* Parthian shot */
		    verbalize(rn2(2) ?
			      "I shall return." :
			      "I'll be back.");
		else
		    verbalize("%s %s!",
			  random_malediction[rn2(SIZE(random_malediction))],
			  random_insult[rn2(SIZE(random_insult))]);
	} else if(is_lminion(mtmp)) {
		com_pager(rn2(QTN_ANGELIC - 1 + (Hallucination ? 1 : 0)) +
			      QT_ANGELIC);
	} else {
	    if (!rn2(5))
		pline("%s casts aspersions on your ancestry.", Monnam(mtmp));
	    else
	        com_pager(rn2(QTN_DEMONIC) + QT_DEMONIC);
	}
}

#endif /* OVLB */

/*wizard.c*/