Source:NetHack 3.3.0/mhitm.c

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

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

1.   /*	SCCS Id: @(#)mhitm.c	3.3	98/08/15	*/ 2.   /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    #include "hack.h"  6.    #include "artifact.h"  7.    #include "edog.h"  8. 9.   extern boolean notonhead; 10.   11.   #ifdef OVLB 12.   13.   static NEARDATA boolean vis, far_noise; 14.  static NEARDATA long noisetime; 15.  static NEARDATA struct obj *otmp; 16.   17.   static const char brief_feeling[] = 18.  	"have a %s feeling for a moment, then it passes."; 19.   20.   STATIC_DCL char *FDECL(mon_nam_too, (char *,struct monst *,struct monst *)); 21.  STATIC_DCL void FDECL(mrustm, (struct monst *, struct monst *, struct obj *)); 22.  STATIC_DCL int FDECL(hitmm, (struct monst *,struct monst *,struct attack *)); 23.  STATIC_DCL int FDECL(gazemm, (struct monst *,struct monst *,struct attack *)); 24.  STATIC_DCL int FDECL(gulpmm, (struct monst *,struct monst *,struct attack *)); 25.  STATIC_DCL int FDECL(explmm, (struct monst *,struct monst *,struct attack *)); 26.  STATIC_DCL int FDECL(mdamagem, (struct monst *,struct monst *,struct attack *)); 27.  STATIC_DCL void FDECL(mswingsm, (struct monst *, struct monst *, struct obj *)); 28.  STATIC_DCL void FDECL(noises,(struct monst *,struct attack *)); 29.  STATIC_DCL void FDECL(missmm,(struct monst *,struct monst *,struct attack *)); 30.  STATIC_DCL int FDECL(passivemm, (struct monst *, struct monst *, BOOLEAN_P, int)); 31.   32.   /* Needed for the special case of monsters wielding vorpal blades (rare). 33.   * If we use this a lot it should probably be a parameter to mdamagem 34.   * instead of a global variable. 35.   */  36.   static int dieroll; 37.   38.   /* returns mon_nam(mon) relative to other_mon; normal name unless they're  39. the same, in which case the reference is to {him|her|it} self */ 40.  STATIC_OVL char * 41.  mon_nam_too(outbuf, mon, other_mon) 42.  char *outbuf; 43.  struct monst *mon, *other_mon; 44.  {  45.   	Strcpy(outbuf, mon_nam(mon)); 46.  	if (mon == other_mon) 47.  	    switch (pronoun_gender(mon)) { 48.  	    case 0:	Strcpy(outbuf, "himself");  break; 49.  	    case 1:	Strcpy(outbuf, "herself");  break; 50.  	    default:	Strcpy(outbuf, "itself"); break; 51.  	    }  52.   	return outbuf; 53.  }  54.    55.   STATIC_OVL void 56.  noises(magr, mattk) 57.  	register struct monst *magr; 58.  	register struct	attack *mattk; 59.  {  60.   	boolean farq = (distu(magr->mx, magr->my) > 15); 61.   62.   	if(flags.soundok && (farq != far_noise || moves-noisetime > 10)) { 63.  		far_noise = farq; 64.  		noisetime = moves; 65.  		You_hear("%s%s.",  66.   			(mattk->aatyp == AT_EXPL) ? "an explosion" : "some noises",  67.   			farq ? " in the distance" : ""); 68.  	}  69.   }  70.    71.   STATIC_OVL 72.  void 73.  missmm(magr, mdef, mattk) 74.  	register struct monst *magr, *mdef; 75.  	struct attack *mattk; 76.  {  77.   	const char *fmt; 78.  	char buf[BUFSZ], mdef_name[BUFSZ]; 79.   80.   	if (vis) { 81.  		if (!canspotmon(mdef)) 82.  		    map_invisible(mdef->mx, mdef->my); 83.  		if (mdef->m_ap_type) seemimic(mdef); 84.  		if (magr->m_ap_type) seemimic(magr); 85.  		fmt = (could_seduce(magr,mdef,mattk) && !magr->mcan) ? 86.  			"%s pretends to be friendly to" : "%s misses"; 87.  		Sprintf(buf, fmt, Monnam(magr)); 88.  		pline("%s %s.", buf, mon_nam_too(mdef_name, mdef, magr)); 89.  	} else  noises(magr, mattk); 90.  }  91.    92.   /*  93.    *  fightm  -- fight some other monster 94.   *  95.    *  Returns: 96.   *	0 - Monster did nothing. 97.   *	1 - If the monster made an attack. The monster might have died. 98.   *  99.    *  There is an exception to the above. If mtmp has the hero swallowed, 100.  *  then we report that the monster did nothing so it will continue to  101. * digest the hero. 102.  */  103.  int 104. fightm(mtmp)		/* have monsters fight each other */ 105. 	register struct monst *mtmp; 106. {  107.  	register struct monst *mon, *nmon; 108. 	int result, has_u_swallowed; 109. #ifdef LINT 110. 	nmon = 0; 111. #endif 112. 	/* perhaps the monster will resist Conflict */ 113. 	if(resist(mtmp, RING_CLASS, 0, 0)) 114. 	    return(0); 115.  116.  	if(u.ustuck == mtmp) { 117. 	    /* perhaps we're holding it... */ 118.  	    if(itsstuck(mtmp)) 119. 		return(0); 120. 	}  121.  	has_u_swallowed = (u.uswallow && (mtmp == u.ustuck)); 122.  123.  	for(mon = fmon; mon; mon = nmon) { 124. 	    nmon = mon->nmon; 125. 	    if(nmon == mtmp) nmon = mtmp->nmon; 126. 	    if(mon != mtmp) { 127. 		if(monnear(mtmp,mon->mx,mon->my)) { 128. 		    if(!u.uswallow && (mtmp == u.ustuck)) { 129. 			if(!rn2(4)) { 130. 			    pline("%s releases you!", Monnam(mtmp)); 131. 			    u.ustuck = 0; 132. 			} else 133. 			    break; 134. 		    }  135.   136.  		    /* mtmp can be killed */ 137. 		    bhitpos.x = mon->mx; 138. 		    bhitpos.y = mon->my; 139. 		    notonhead = 0; 140. 		    result = mattackm(mtmp,mon); 141.  142.  		    if (result & MM_AGR_DIED) return 1;	/* mtmp died */ 143. 		    /*  144.  		     *  If mtmp has the hero swallowed, lie and say there 145. 		     *  was no attack (this allows mtmp to digest the hero). 146. 		     */  147.  		    if (has_u_swallowed) return 0; 148.  149.  		    return ((result & MM_HIT) ? 1 : 0); 150. 		}  151.  	    }  152.  	}  153.  	return 0; 154. }  155.   156.  /*  157.   * mattackm -- a monster attacks another monster. 158.  *  159.   * This function returns a result bitfield: 160.  *  161.   *	    - agressor died 162.  *	   /  --- defender died 163.  *	  /  /  - defender was hit 164.  *	 /  /  /  165.   *	x  x  x  166. * 167.   *	0x4	MM_AGR_DIED 168.  *	0x2	MM_DEF_DIED 169.  *	0x1	MM_HIT 170.  *	0x0	MM_MISS 171.  *  172.   * Each successive attack has a lower probability of hitting. Some rely on the 173.  * success of previous attacks. ** this doen't seem to be implemented -dl ** 174.  *  175.   * In the case of exploding monsters, the monster dies as well. 176.  */  177.  int 178. mattackm(magr, mdef) 179.     register struct monst *magr,*mdef; 180. {  181.      int		    i,		/* loop counter */ 182. 		    tmp,	/* amour class difference */ 183. 		    strike,	/* hit this attack */ 184. 		    attk,	/* attack attempted this time */ 185. 		    struck = 0,	/* hit at least once */ 186. 		    res[NATTK];	/* results of all attacks */ 187.     struct attack   *mattk; 188.     struct permonst *pa, *pd; 189.  190.      if (!magr || !mdef) return(MM_MISS);		/* mike@genat */ 191.     if (!magr->mcanmove) return(MM_MISS);		/* riv05!a3 */ 192.     pa = magr->data;  pd = mdef->data; 193.  194.      /* Grid bugs cannot attack at an angle. */ 195.      if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx  196.  						&& magr->my != mdef->my) 197. 	return(MM_MISS); 198.  199.      /* Calculate the armour class differential. */ 200.      tmp = find_mac(mdef) + magr->m_lev; 201.     if (mdef->mconf || !mdef->mcanmove || mdef->msleeping) { 202. 	tmp += 4; 203. 	mdef->msleeping = 0; 204.     }  205.   206.      /* undetect monsters become un-hidden if they are attacked */ 207.     if (mdef->mundetected) { 208. 	mdef->mundetected = 0; 209. 	newsym(mdef->mx, mdef->my); 210. 	if(canseemon(mdef) && !sensemon(mdef)) 211. 	    pline("Suddenly, you notice %s.", a_monnam(mdef)); 212.     }  213.   214.      /* Elves hate orcs. */ 215.      if (is_elf(pa) && is_orc(pd)) tmp++; 216.  217.   218.      /* Set up the visibility of action */ 219.     vis = (cansee(magr->mx,magr->my) && cansee(mdef->mx,mdef->my)); 220.  221.      /*	Set flag indicating monster has moved this turn. Necessary since a 222. *	monster might get an attack out of sequence (i.e. before its move) in 223. *	some cases, in which case this still counts as its move for the round 224.      *	and it shouldn't move again. 225.      */  226.      magr->mlstmv = monstermoves; 227.  228.      /* Now perform all attacks for the monster. */ 229.      for (i = 0; i < NATTK; i++) { 230. 	res[i] = MM_MISS; 231. 	mattk = &(pa->mattk[i]); 232. 	otmp = (struct obj *)0; 233. 	attk = 1; 234. 	switch (mattk->aatyp) { 235. 	    case AT_WEAP:		/* "hand to hand" attacks */ 236. 		if (magr->weapon_check == NEED_WEAPON || !MON_WEP(magr)) { 237. 		    magr->weapon_check = NEED_HTH_WEAPON; 238. 		    if (mon_wield_item(magr) != 0) return 0; 239. 		}  240.  		possibly_unwield(magr); 241. 		otmp = MON_WEP(magr); 242.  243.  		if (otmp) { 244. 		    if (vis) mswingsm(magr, mdef, otmp); 245. 		    tmp += hitval(otmp, mdef); 246. 		}  247.  		/* fall through */ 248. 	    case AT_CLAW: 249. 	    case AT_KICK: 250. 	    case AT_BITE: 251. 	    case AT_STNG: 252. 	    case AT_TUCH: 253. 	    case AT_BUTT: 254. 	    case AT_TENT: 255. 		/* Monsters won't attack cockatrices physically if they 256. 		 * have a weapon instead. This instinct doesn't work for 257. 		 * players, or under conflict or confusion. 258. 		 */  259.  		if (!magr->mconf && !Conflict && otmp &&  260.  		    mattk->aatyp != AT_WEAP && touch_petrifies(mdef->data)) { 261. 		    strike = 0; 262. 		    break; 263. 		}  264.  		dieroll = rnd(20 + i); 265. 		strike = (tmp > dieroll); 266. 		/* KMH -- don't accumulate to-hit bonuses */ 267. 		if (otmp) 268. 		    tmp -= hitval(otmp, mdef); 269. 		if (strike) 270. 		    res[i] = hitmm(magr, mdef, mattk); 271. 		else 272. 		    missmm(magr, mdef, mattk); 273. 		break; 274.  275.  	    case AT_HUGS:	/* automatic if prev two attacks succeed */ 276. 		strike = (i >= 2 && res[i-1] == MM_HIT && res[i-2] == MM_HIT); 277. 		if (strike) 278. 		    res[i] = hitmm(magr, mdef, mattk); 279.  280.  		break; 281.  282.  	    case AT_GAZE: 283. 		strike = 0;	/* will not wake up a sleeper */ 284. 		res[i] = gazemm(magr, mdef, mattk); 285. 		break; 286.  287.  	    case AT_EXPL: 288. 		strike = 1;	/* automatic hit */ 289. 		res[i] = explmm(magr, mdef, mattk); 290. 		break; 291.  292.  	    case AT_ENGL: 293. 		/* Engulfing attacks are directed at the hero if  294. * possible. -dlc 295. 		 */  296.  		if (u.uswallow && magr == u.ustuck) 297. 		    strike = 0; 298. 		else { 299. 		    if ((strike = (tmp > rnd(20+i)))) 300. 			res[i] = gulpmm(magr, mdef, mattk); 301. 		    else 302. 			missmm(magr, mdef, mattk); 303. 		}  304.  		break; 305.  306.  	    default:		/* no attack */ 307. 		strike = 0; 308. 		attk = 0; 309. 		break; 310. 	}  311.   312.  	if (attk && !(res[i] & MM_AGR_DIED)) 313. 	    res[i] = passivemm(magr, mdef, strike, res[i] & MM_DEF_DIED); 314.  315.  	if (res[i] & MM_DEF_DIED) return res[i]; 316.  317.  	/*  318.  	 *  Wake up the defender. NOTE: this must follow the check 319. 	 *  to see if the defender died. We don't want to modify 320. 	 *  unallocated monsters! 321. 	 */  322.  	if (strike) mdef->msleeping = 0; 323.  324.  	if (res[i] & MM_AGR_DIED)  return res[i]; 325. 	/* return if aggressor can no longer attack */ 326. 	if (!magr->mcanmove || magr->msleeping) return res[i]; 327. 	if (res[i] & MM_HIT) struck = 1;	/* at least one hit */ 328.     }  329.   330.      return(struck ? MM_HIT : MM_MISS); 331. }  332.   333.  /* Returns the result of mdamagem. */ 334.  STATIC_OVL int 335. hitmm(magr, mdef, mattk) 336. 	register struct monst *magr,*mdef; 337. 	struct	attack *mattk; 338. {  339.  	if(vis){ 340. 		int compat; 341. 		char buf[BUFSZ], mdef_name[BUFSZ]; 342.  343.  		if (!canspotmon(mdef)) 344. 		    map_invisible(mdef->mx, mdef->my); 345. 		if(mdef->m_ap_type) seemimic(mdef); 346. 		if(magr->m_ap_type) seemimic(magr); 347. 		if((compat = could_seduce(magr,mdef,mattk)) && !magr->mcan) { 348. 			Sprintf(buf, "%s %s", Monnam(magr),  349.  				mdef->mcansee ? "smiles at" : "talks to"); 350. 			pline("%s %s %s.", buf, mon_nam(mdef),  351.  				compat == 2 ?  352.  					"engagingly" : "seductively"); 353. 		} else { 354. 		    char magr_name[BUFSZ]; 355.  356.  		    Strcpy(magr_name, Monnam(magr)); 357. 		    switch (mattk->aatyp) { 358. 			case AT_BITE: 359. 				Sprintf(buf,"%s bites", magr_name); 360. 				break; 361. 			case AT_STNG: 362. 				Sprintf(buf,"%s stings", magr_name); 363. 				break; 364. 			case AT_BUTT: 365. 				Sprintf(buf,"%s butts", magr_name); 366. 				break; 367. 			case AT_TUCH: 368. 				Sprintf(buf,"%s touches", magr_name); 369. 				break; 370. 			case AT_TENT: 371. 				Sprintf(buf, "%s tentacles suck",  372.  					s_suffix(magr_name)); 373. 				break; 374. 			case AT_HUGS: 375. 				if (magr != u.ustuck) { 376. 				    Sprintf(buf,"%s squeezes", magr_name); 377. 				    break; 378. 				}  379.  			default: 380. 				Sprintf(buf,"%s hits", magr_name); 381. 		    }  382.  		}  383.  		pline("%s %s.", buf, mon_nam_too(mdef_name, mdef, magr)); 384. 	} else  noises(magr, mattk); 385. 	return(mdamagem(magr, mdef, mattk)); 386. }  387.   388.  /* Returns the same values as mdamagem. */ 389.  STATIC_OVL int 390. gazemm(magr, mdef, mattk) 391. 	register struct monst *magr, *mdef; 392. 	struct attack *mattk; 393. {  394.  	char buf[BUFSZ]; 395.  396.  	if(vis) { 397. 		Sprintf(buf,"%s gazes at", Monnam(magr)); 398. 		pline("%s %s...", buf, mon_nam(mdef)); 399. 	}  400.   401.  	if (!mdef->mcansee || mdef->msleeping) { 402. 	    if(vis) pline("but nothing happens."); 403. 	    return(MM_MISS); 404. 	}  405.   406.  	return(mdamagem(magr, mdef, mattk)); 407. }  408.   409.  /* Returns the same values as mattackm. */ 410.  STATIC_OVL int 411. gulpmm(magr, mdef, mattk) 412. 	register struct monst *magr, *mdef; 413. 	register struct	attack *mattk; 414. {  415.  	xchar	ax, ay, dx, dy; 416. 	int	status; 417. 	char buf[BUFSZ]; 418. 	struct obj *obj; 419.  420.  	if (mdef->data->msize >= MZ_HUGE) return MM_MISS; 421.  422.  	if (vis) { 423. 		Sprintf(buf,"%s swallows", Monnam(magr)); 424. 		pline("%s %s.", buf, mon_nam(mdef)); 425. 	}  426.  	for (obj = mdef->minvent; obj; obj = obj->nobj) 427. 	    (void) snuff_lit(obj); 428.  429.  	/*  430.  	 *  All of this maniuplation is needed to keep the display correct. 431. 	 *  There is a flush at the next pline. 432. 	 */  433.  	ax = magr->mx; 434. 	ay = magr->my; 435. 	dx = mdef->mx; 436. 	dy = mdef->my; 437. 	/*  438.  	 *  Leave the defender in the monster chain at it's current position, 439. 	 *  but don't leave it on the screen. Move the agressor to the def- 440. 	 *  ender's position. 441. 	 */  442.  	remove_monster(ax, ay); 443. 	place_monster(magr, dx, dy); 444. 	newsym(ax,ay);			/* erase old position */ 445. 	newsym(dx,dy);			/* update new position */ 446.  447.  	status = mdamagem(magr, mdef, mattk); 448.  449.  	if ((status & MM_AGR_DIED) && (status & MM_DEF_DIED)) { 450. 	    ;					/* both died -- do nothing  */ 451. 	}  452.  	else if (status & MM_DEF_DIED) {	/* defender died */ 453. 	    /*  454.  	     *  Note:  remove_monster was called in relmon, wiping out 455. 	     *  magr from level.monsters[mdef->mx][mdef->my]. We need to 456. * put it back and display it. -kd 457. 	     */  458.  	    place_monster(magr, dx, dy); 459. 	    newsym(dx, dy); 460. 	}  461.  	else if (status & MM_AGR_DIED) {	/* agressor died */ 462. 	    place_monster(mdef, dx, dy); 463. 	    newsym(dx, dy); 464. 	}  465.  	else {					/* both alive, put them back */ 466. 	    if (cansee(dx, dy)) 467. 		pline("%s is regurgitated!", Monnam(mdef)); 468.  469.  	    place_monster(magr, ax, ay); 470. 	    place_monster(mdef, dx, dy); 471. 	    newsym(ax, ay); 472. 	    newsym(dx, dy); 473. 	}  474.   475.  	return status; 476. }  477.   478.  STATIC_OVL int 479. explmm(magr, mdef, mattk) 480. 	register struct monst *magr, *mdef; 481. 	register struct	attack *mattk; 482. {  483.  	int result; 484.  485.  	if(cansee(magr->mx, magr->my)) 486. 		pline("%s explodes!", Monnam(magr)); 487. 	else	noises(magr, mattk); 488.  489.  	result = mdamagem(magr, mdef, mattk); 490.  491.  	/* Kill off agressor if it didn't die. */ 492.  	if (!(result & MM_AGR_DIED)) { 493. 	    mondead(magr); 494. 	    if (magr->mhp > 0) return result;	/* life saved */ 495. 	    result |= MM_AGR_DIED; 496. 	}  497.  	if (magr->mtame)	/* give this one even if it was visible */ 498. 	    You(brief_feeling, "melancholy"); 499.  500.  	return result; 501. }  502.   503.  /*  504.   *  See comment at top of mattackm, for return values. 505.  */  506.  STATIC_OVL int 507. mdamagem(magr, mdef, mattk) 508. 	register struct monst	*magr, *mdef; 509. 	register struct attack	*mattk; 510. {  511.  	struct	permonst *pa = magr->data, *pd = mdef->data; 512. 	int	tmp = d((int)mattk->damn,(int)mattk->damd); 513. 	char buf[BUFSZ]; 514.  515.  	if (touch_petrifies(pd) && !resists_ston(magr) &&  516.  	   (mattk->aatyp != AT_WEAP || !otmp) &&  517.  	   (mattk->aatyp != AT_GAZE && mattk->aatyp != AT_EXPL) &&  518.  	   !(magr->misc_worn_check & W_ARMG)) { 519. 		if (poly_when_stoned(pa)) { 520. 		    mon_to_stone(magr); 521. 		    return MM_HIT; /* no damage during the polymorph */ 522. 		}  523.  		if (vis) pline("%s turns to stone!", Monnam(magr)); 524. 		monstone(magr); 525. 		if (magr->mhp > 0) return 0; 526. 		else if (magr->mtame && !vis) 527. 		    You(brief_feeling, "peculiarly sad"); 528. 		return MM_AGR_DIED; 529. 	}  530.   531.  	switch(mattk->adtyp) { 532. 	    case AD_DGST: 533. 		/* eating a Rider or its corpse is fatal */ 534. 		if (is_rider(mdef->data)) { 535. 		    if (vis) 536. 			pline("%s %s!", Monnam(magr),  537.  			      mdef->data == &mons[PM_FAMINE] ?  538.  				"belches feebly, shrivels up and dies" :  539.  			      mdef->data == &mons[PM_PESTILENCE] ?  540.  				"coughs spasmodically and collapses" :  541.  				"vomits violently and drops dead"); 542. 		    mondied(magr); 543. 		    if (magr->mhp > 0) return 0;	/* lifesaved */ 544. 		    else if (magr->mtame && !vis) 545. 			You(brief_feeling, "queasy"); 546. 		    return MM_AGR_DIED; 547. 		}  548.  		if(flags.verbose && flags.soundok) verbalize("Burrrrp!"); 549. 		tmp = mdef->mhp; 550. 		break; 551. 	    case AD_STUN: 552. 		if (magr->mcan) break; 553. 		if(vis) pline("%s staggers for a moment.", Monnam(mdef)); 554. 		mdef->mstun = 1; 555. 		/* fall through */ 556. 	    case AD_WERE: 557. 	    case AD_HEAL: 558. 	    case AD_LEGS: 559. 	    case AD_PHYS: 560. 		if (mattk->aatyp == AT_KICK && thick_skinned(pd)) 561. 			tmp = 0; 562. 		else if(mattk->aatyp == AT_WEAP) { 563. 		    if(otmp) { 564. 			if (otmp->otyp == CORPSE &&  565.  				touch_petrifies(&mons[otmp->corpsenm])) 566. 			    goto do_stone_goto_label; 567. 			tmp += dmgval(otmp, mdef); 568. 			if (otmp->oartifact) { 569. 			    (void)artifact_hit(magr,mdef, otmp, &tmp, dieroll); 570. 			    if (mdef->mhp <= 0) 571. 				return (MM_DEF_DIED |  572.  					(grow_up(magr,mdef) ? 0 : MM_AGR_DIED)); 573. 			}  574.  			if (tmp) 575. 				mrustm(magr, mdef, otmp); 576. 		    }  577.  		} else if (magr->data == &mons[PM_PURPLE_WORM] &&  578.  			    mdef->data == &mons[PM_SHRIEKER]) { 579. 		    /* hack to enhance mm_aggression; we don't want purple 580. 		       worm's bite attack to kill a shrieker because then it  581. won't swallow the corpse; but if the target survives, 582. 		       the subsequent engulf attack should accomplish that */ 583. 		    if (tmp >= mdef->mhp) tmp = mdef->mhp - 1; 584. 		}  585.  		break; 586. 	    case AD_FIRE: 587. 		if (magr->mcan) { 588. 		    tmp = 0; 589. 		    break; 590. 		}  591.  		if (vis) 592. 		    pline("%s is %s!", Monnam(mdef),  593.  			  mattk->aatyp == AT_HUGS ?  594.  				"being roasted" : "on fire"); 595. 		if (pd == &mons[PM_STRAW_GOLEM] ||  596.  		    pd == &mons[PM_PAPER_GOLEM]) { 597. 			if (vis) pline("%s burns completely!", Monnam(mdef)); 598. 			mondied(mdef); 599. 			if (mdef->mhp > 0) return 0; 600. 			else if (mdef->mtame && !vis) 601. 			    pline("May %s roast in peace.", mon_nam(mdef)); 602. 			return (MM_DEF_DIED | (grow_up(magr,mdef) ? 603. 							0 : MM_AGR_DIED)); 604. 		}  605.  		tmp += destroy_mitem(mdef, SCROLL_CLASS, AD_FIRE); 606. 		tmp += destroy_mitem(mdef, SPBOOK_CLASS, AD_FIRE); 607. 		if (resists_fire(mdef)) { 608. 		    if (vis) 609. 			pline_The("fire doesn't seem to burn %s!",  610.  								mon_nam(mdef)); 611. 		    shieldeff(mdef->mx, mdef->my); 612. 		    golemeffects(mdef, AD_FIRE, tmp); 613. 		    tmp = 0; 614. 		}  615.  		/* only potions damage resistant players in destroy_item */ 616. 		tmp += destroy_mitem(mdef, POTION_CLASS, AD_FIRE); 617. 		break; 618. 	    case AD_COLD: 619. 		if (magr->mcan) { 620. 		    tmp = 0; 621. 		    break; 622. 		}  623.  		if (vis) pline("%s is covered in frost!", Monnam(mdef)); 624. 		if (resists_cold(mdef)) { 625. 		    if (vis) 626. 			pline_The("frost doesn't seem to chill %s!",  627.  								mon_nam(mdef)); 628. 		    shieldeff(mdef->mx, mdef->my); 629. 		    golemeffects(mdef, AD_COLD, tmp); 630. 		    tmp = 0; 631. 		}  632.  		tmp += destroy_mitem(mdef, POTION_CLASS, AD_COLD); 633. 		break; 634. 	    case AD_ELEC: 635. 		if (magr->mcan) { 636. 		    tmp = 0; 637. 		    break; 638. 		}  639.  		if (vis) pline("%s gets zapped!", Monnam(mdef)); 640. 		tmp += destroy_mitem(mdef, WAND_CLASS, AD_ELEC); 641. 		if (resists_elec(mdef)) { 642. 		    if (vis) pline_The("zap doesn't shock %s!", mon_nam(mdef)); 643. 		    shieldeff(mdef->mx, mdef->my); 644. 		    golemeffects(mdef, AD_ELEC, tmp); 645. 		    tmp = 0; 646. 		}  647.  		/* only rings damage resistant players in destroy_item */ 648. 		tmp += destroy_mitem(mdef, RING_CLASS, AD_ELEC); 649. 		break; 650. 	    case AD_ACID: 651. 		if (magr->mcan) { 652. 		    tmp = 0; 653. 		    break; 654. 		}  655.  		if (resists_acid(mdef)) { 656. 		    if (vis) 657. 			pline("%s is covered in acid, but it seems harmless.",  658.  			      Monnam(mdef)); 659. 		    tmp = 0; 660. 		} else if (vis) { 661. 		    pline("%s is covered in acid!", Monnam(mdef)); 662. 		    pline("It burns %s!", mon_nam(mdef)); 663. 		}  664.  		if(!rn2(30)) erode_armor(mdef, TRUE); 665. 		if(!rn2(6)) erode_weapon(mdef, TRUE); 666. 		break; 667. 	    case AD_RUST: 668. 		if (!magr->mcan && pd == &mons[PM_IRON_GOLEM]) { 669. 			if (vis) pline("%s falls to pieces!", Monnam(mdef)); 670. 			mondied(mdef); 671. 			if (mdef->mhp > 0) return 0; 672. 			else if (mdef->mtame && !vis) 673. 			    pline("May %s rust in peace.", mon_nam(mdef)); 674. 			return (MM_DEF_DIED | (grow_up(magr,mdef) ? 675. 							0 : MM_AGR_DIED)); 676. 		}  677.  		hurtmarmor(magr->data, mdef, AD_RUST); 678. 		tmp = 0; 679. 		break; 680. 	    case AD_DCAY: 681. 		if (!magr->mcan && (pd == &mons[PM_WOOD_GOLEM] || 682. 		    pd == &mons[PM_LEATHER_GOLEM])) { 683. 			if (vis) pline("%s falls to pieces!", Monnam(mdef)); 684. 			mondied(mdef); 685. 			if (mdef->mhp > 0) return 0; 686. 			else if (mdef->mtame && !vis) 687. 			    pline("May %s rot in peace.", mon_nam(mdef)); 688. 			return (MM_DEF_DIED | (grow_up(magr,mdef) ? 689. 							0 : MM_AGR_DIED)); 690. 		}  691.  		hurtmarmor(magr->data, mdef, AD_DCAY); 692. 		tmp = 0; 693. 		break; 694. 	    case AD_STON: 695. do_stone_goto_label: 696. 		/* may die from the acid if it eats a stone-curing corpse */ 697. 		if (munstone(mdef, FALSE)) goto label2; 698. 		if (poly_when_stoned(pd)) { 699. 			mon_to_stone(mdef); 700. 			tmp = 0; 701. 			break; 702. 		}  703.  		if (!resists_ston(mdef)) { 704. 			if (vis) pline("%s turns to stone!", Monnam(mdef)); 705. 			monstone(mdef); 706. label2:			if (mdef->mhp > 0) return 0; 707. 			else if (mdef->mtame && !vis) 708. 			    You(brief_feeling, "peculiarly sad"); 709. 			return (MM_DEF_DIED | (grow_up(magr,mdef) ? 710. 							0 : MM_AGR_DIED)); 711. 		}  712.  		tmp = (mattk->adtyp == AD_STON ? 0 : 1); 713. 		break; 714. 	    case AD_TLPT: 715. 		if (!magr->mcan && tmp < mdef->mhp && !tele_restrict(mdef)) { 716. 		    char mdef_Monnam[BUFSZ]; 717. 		    /* save the name before monster teleports, otherwise 718. 		       we'll get "it" in the suddenly disappears message */ 719. 		    if (vis) Strcpy(mdef_Monnam, Monnam(mdef)); 720. 		    rloc(mdef); 721. 		    if (vis && !cansee(mdef->mx, mdef->my)) 722. 			pline("%s suddenly disappears!", mdef_Monnam); 723. 		}  724.  		break; 725. 	    case AD_SLEE: 726. 		if (!magr->mcan && !mdef->msleeping &&  727.  			sleep_monst(mdef, rnd(10), -1)) { 728. 		    if (vis) { 729. 			Strcpy(buf, Monnam(mdef)); 730. 			pline("%s is put to sleep by %s.", buf, mon_nam(magr)); 731. 		    }  732.  		    slept_monst(mdef); 733. 		}  734.  		break; 735. 	    case AD_PLYS: 736. 		if(!magr->mcan && mdef->mcanmove) { 737. 		    if (vis) { 738. 			Strcpy(buf, Monnam(mdef)); 739. 			pline("%s is frozen by %s.", buf, mon_nam(magr)); 740. 		    }  741.  		    mdef->mcanmove = 0; 742. 		    mdef->mfrozen = rnd(10); 743. 		}  744.  		break; 745. 	    case AD_SLOW: 746. 		if (!magr->mcan && vis && mdef->mspeed != MSLOW) { 747. 		    unsigned int oldspeed = mdef->mspeed; 748.  749.  		    mon_adjust_speed(mdef, -1); 750. 		    if (mdef->mspeed != oldspeed && vis) 751. 			pline("%s slows down.", Monnam(mdef)); 752. 		}  753.  		break; 754. 	    case AD_CONF: 755. 		/* Since confusing another monster doesn't have a real time 756. 		 * limit, setting spec_used would not really be right (though  757.  		 * we still should check for it). 758. 		 */  759.  		if (!magr->mcan && !mdef->mconf && !magr->mspec_used) { 760. 		    if (vis) pline("%s looks confused.", Monnam(mdef)); 761. 		    mdef->mconf = 1; 762. 		}  763.  		break; 764. 	    case AD_BLND: 765. 		if (!magr->mcan && !resists_blnd(mdef)) { 766. 		    register unsigned rnd_tmp; 767.  768.  		    if (vis) 769. 			pline("%s is blinded.", Monnam(mdef)); 770. 		    rnd_tmp = d((int)mattk->damn, (int)mattk->damd); 771. 		    if ((rnd_tmp += mdef->mblinded) > 127) rnd_tmp = 127; 772. 		    mdef->mblinded = rnd_tmp; 773. 		    mdef->mcansee = 0; 774. 		}  775.  		tmp = 0; 776. 		break; 777. 	    case AD_HALU: 778. 		if (!magr->mcan && haseyes(pd) && mdef->mcansee) { 779. 		    if (vis) pline("%s looks %sconfused.",  780.  				    Monnam(mdef), mdef->mconf ? "more " : ""); 781. 		    mdef->mconf = 1; 782. 		}  783.  		tmp = 0; 784. 		break; 785. 	    case AD_CURS: 786. 		if (!night && (pa == &mons[PM_GREMLIN])) break; 787. 		if (!magr->mcan && !rn2(10)) { 788. 		    mdef->mcan = 1;	/* cancelled regardless of lifesave */ 789. 		    if (is_were(pd) && pd->mlet != S_HUMAN) 790. 			were_change(mdef); 791. 		    if (pd == &mons[PM_CLAY_GOLEM]) { 792. 			    if (vis) { 793. 				pline("Some writing vanishes from %s head!",  794.  				    s_suffix(mon_nam(mdef))); 795. 				pline("%s is destroyed!", Monnam(mdef)); 796. 			    }  797.  			    mondied(mdef); 798. 			    if (mdef->mhp > 0) return 0; 799. 			    else if (mdef->mtame && !vis) 800. 				You(brief_feeling, "strangely sad"); 801. 			    return (MM_DEF_DIED | (grow_up(magr,mdef) ? 802. 							0 : MM_AGR_DIED)); 803. 		    }  804.  		    if (flags.soundok) { 805. 			    if (!vis) You_hear("laughter."); 806. 			    else pline("%s chuckles.", Monnam(magr)); 807. 		    }  808.  		}  809.  		break; 810. 	    case AD_SGLD: 811. 		tmp = 0; 812. 		if (magr->mcan || !mdef->mgold) break; 813. 		/* technically incorrect; no check for stealing gold from 814. 		 * between mdef's feet...  815. */ 816.  		magr->mgold += mdef->mgold; 817. 		mdef->mgold = 0; 818. 		if (vis) { 819. 			Strcpy(buf, Monnam(magr)); 820. 			pline("%s steals some gold from %s.", buf,  821.  								mon_nam(mdef)); 822. 		}  823.  		break; 824. 	    case AD_DRLI: 825. 		if (rn2(2) && !resists_drli(mdef)) { 826. 			tmp = d(2,6); 827. 			if (vis) 828. 			    pline("%s suddenly seems weaker!", Monnam(mdef)); 829. 			mdef->mhpmax -= tmp; 830. 			if (mdef->m_lev == 0) 831. 				tmp = mdef->mhp; 832. 			else mdef->m_lev--; 833. 			/* Automatic kill if drained past level 0 */ 834. 		}  835.  		break; 836. #ifdef SEDUCE 837. 	    case AD_SSEX: 838. #endif 839. 	    case AD_SITM:	/* for now these are the same */ 840. 	    case AD_SEDU: 841. 		if (!magr->mcan && mdef->minvent) { 842. 			char onambuf[BUFSZ]; 843.  844.  			otmp = mdef->minvent; 845. 			obj_extract_self(otmp); 846. 			if (otmp->owornmask) { 847. 				mdef->misc_worn_check &= ~otmp->owornmask; 848. 				otmp->owornmask = 0L; 849. 				update_mon_intrinsics(mdef, otmp, FALSE); 850. 			}  851.  			/* add_to_minv might free otmp [if it merges] */ 852. 			if (vis) 853. 				Strcpy(onambuf, doname(otmp)); 854. 			add_to_minv(magr, otmp); 855. 			if (vis) { 856. 				Strcpy(buf, Monnam(magr)); 857. 				pline("%s steals %s from %s!", buf,  858.  				      onambuf, mon_nam(mdef)); 859. 			}  860.  			possibly_unwield(mdef); 861. 			mselftouch(mdef, (const char *)0, FALSE); 862. 			if (mdef->mhp <= 0) 863. 				return (MM_DEF_DIED | (grow_up(magr,mdef) ? 864. 							0 : MM_AGR_DIED)); 865. 		}  866.  		tmp = 0; 867. 		break; 868. 	    case AD_DRST: 869. 	    case AD_DRDX: 870. 	    case AD_DRCO: 871. 		if (!magr->mcan && !rn2(8)) { 872. 		    if (vis) 873. 			pline("%s %s was poisoned!", s_suffix(Monnam(magr)),  874.  			      mpoisons_subj(magr, mattk)); 875. 		    if (resists_poison(mdef)) { 876. 			if (vis) 877. 			    pline_The("poison doesn't seem to affect %s.",  878.  				mon_nam(mdef)); 879. 		    } else { 880. 			if (rn2(10)) tmp += rn1(10,6); 881. 			else { 882. 			    if (vis) pline_The("poison was deadly..."); 883. 			    tmp = mdef->mhp; 884. 			}  885.  		    }  886.  		}  887.  		break; 888. 	    case AD_DRIN: 889. 		if (notonhead || !has_head(pd)) { 890. 		    if (vis) pline("%s doesn't seem harmed.", Monnam(mdef)); 891. 		    tmp = 0; 892. 		    break; 893. 		}  894.  		if ((mdef->misc_worn_check & W_ARMH) && rn2(8)) { 895. 		    if (vis) { 896. 			Strcpy(buf, s_suffix(Monnam(mdef))); 897. 			pline("%s helmet blocks %s attack to %s head.",  898.  				buf, s_suffix(mon_nam(magr)),  899.  				his[pronoun_gender(mdef)]); 900. 		    }  901.  		    break; 902. 		}  903.  		if (vis) pline("%s brain is eaten!", s_suffix(Monnam(mdef))); 904. 		if (mindless(pd)) { 905. 		    if (vis) pline("%s doesn't notice.", Monnam(mdef)); 906. 		    break; 907. 		}  908.  		tmp += rnd(10); /* fakery, since monsters lack INT scores */ 909. 		if (magr->mtame && !magr->isminion) { 910. 		    EDOG(magr)->hungrytime += rnd(60); 911. 		    magr->mconf = 0; 912. 		}  913.  		if (tmp >= mdef->mhp && vis) 914. 		    pline("%s last thought fades away...",  915.  			          s_suffix(Monnam(mdef))); 916. 		break; 917. 	    case AD_SLIM: 918. 	    	if (!rn2(4) && mdef->data != &mons[PM_FIRE_VORTEX] &&  919.  	    			mdef->data != &mons[PM_FIRE_ELEMENTAL] &&  920.  	    			mdef->data != &mons[PM_GREEN_SLIME]) { 921. 	    	    if (vis) pline("%s turns into slime.", Monnam(mdef)); 922. 	    	    (void) newcham(mdef, &mons[PM_GREEN_SLIME]); 923. 	    	    tmp = 0; 924. 	    	}  925.  	    	break; 926. 	    case AD_STCK: 927. 	    case AD_WRAP: /* monsters cannot grab one another, it's too hard */ 928. 	    case AD_ENCH: /* There's no msomearmor function, so just do damage */ 929. 		break; 930. 	    default:	tmp = 0; 931. 			break; 932. 	}  933.  	if(!tmp) return(MM_MISS); 934.  935.  	if((mdef->mhp -= tmp) < 1) { 936. 	    if (m_at(mdef->mx, mdef->my) == magr) {  /* see gulpmm */ 937. 		remove_monster(mdef->mx, mdef->my); 938. 		place_monster(mdef, mdef->mx, mdef->my); 939. 	    }  940.  	    monkilled(mdef, "", (int)mattk->adtyp); 941. 	    if (mdef->mhp > 0) return 0; /* mdef lifesaved */ 942. 	    return (MM_DEF_DIED | (grow_up(magr,mdef) ? 0 : MM_AGR_DIED)); 943. 	}  944.  	return(MM_HIT); 945. }  946.   947.  #endif /* OVLB */ 948.  949.   950.  #ifdef OVL0 951.  952.  int 953. noattacks(ptr)			/* returns 1 if monster doesn't attack */ 954. 	struct	permonst *ptr; 955. {  956.  	int i;  957. 958. 	for(i = 0; i < NATTK; i++) 959. 		if(ptr->mattk[i].aatyp) return(0); 960.  961.  	return(1); 962. }  963.   964.  /* `mon' is hit by a sleep attack; return 1 if it's affected, 0 otherwise */ 965. int 966. sleep_monst(mon, amt, how) 967. struct monst *mon; 968. int amt, how; 969. {  970.  	if (resists_sleep(mon) ||  971.  		(how >= 0 && resist(mon, (char)how, 0, NOTELL))) { 972. 	    shieldeff(mon->mx, mon->my); 973. 	} else if (mon->mcanmove) { 974. 	    amt += (int) mon->mfrozen; 975. 	    if (amt > 0) {	/* sleep for N turns */ 976. 		mon->mcanmove = 0; 977. 		mon->mfrozen = min(amt, 127); 978. 	    } else {		/* sleep until awakened */ 979. 		mon->msleeping = 1; 980. 	    }  981.  	    return 1; 982. 	}  983.  	return 0; 984. }  985.   986.  /* sleeping grabber releases, engulfer doesn't; don't use for paralysis! */ 987.  void 988. slept_monst(mon) 989. struct monst *mon; 990. {  991.  	if ((mon->msleeping || !mon->mcanmove) && mon == u.ustuck &&  992.  		!sticks(youmonst.data) && !u.uswallow) { 993. 	    pline("%s grip relaxes.", s_suffix(Monnam(mon))); 994. 	    unstuck(mon); 995. 	}  996.  }  997.   998.  #endif /* OVL0 */ 999. #ifdef OVLB 1000. 1001. STATIC_OVL void 1002. mrustm(magr, mdef, obj) 1003. register struct monst *magr, *mdef; 1004. register struct obj *obj; 1005. { 1006. 	if (!magr || !mdef || !obj) return; /* just in case */ 1007. 	if (mdef->data == &mons[PM_RUST_MONSTER] && !mdef->mcan && 1008. 	    is_rustprone(obj) && obj->oeroded < MAX_ERODE) { 1009. 		if (obj->greased || obj->oerodeproof || (obj->blessed && rn2(3))) { 1010. 		   if (cansee(mdef->mx, mdef->my) && flags.verbose) 1011. 			pline("%s weapon is not affected.", 1012. 			                 s_suffix(Monnam(magr))); 1013. 		   if (obj->greased && !rn2(2)) obj->greased = 0; 1014. 		} else { 1015. 		   if (cansee(mdef->mx, mdef->my)) { 1016. 			pline("%s %s%s!", s_suffix(Monnam(magr)), 1017. 			      aobjnam(obj, "rust"),  1018. 			      obj->oeroded ? " further" : ""); 1019. 		   }  1020. 		    obj->oeroded++; 1021. 		} 1022. 	}  1023. }  1024.  1025. STATIC_OVL void 1026. mswingsm(magr, mdef, otemp) 1027. register struct monst *magr, *mdef; 1028. register struct obj *otemp; 1029. { 1030. 	char buf[BUFSZ]; 1031. 	Strcpy(buf, mon_nam(mdef)); 1032. 	if (!flags.verbose || Blind) return; 1033. 	pline("%s %s %s %s at %s.", Monnam(magr), 1034. 	      (objects[otemp->otyp].oc_dir & PIERCE) ? "thrusts" : "swings",  1035. 	      his[pronoun_gender(magr)], xname(otemp), buf); 1036. } 1037.  1038. /*  1039.  * Passive responses by defenders. Does not replicate responses already 1040. * handled above. Returns same values as mattackm. 1041. */  1042. STATIC_OVL int 1043. passivemm(magr,mdef,mhit,mdead) 1044. register struct monst *magr, *mdef; 1045. boolean mhit; 1046. int mdead; 1047. { 1048. 	register struct permonst *mddat = mdef->data; 1049. 	register struct permonst *madat = magr->data; 1050. 	char buf[BUFSZ]; 1051. 	int i, tmp; 1052. 1053. 	for(i = 0; ; i++) { 1054. 	   if(i >= NATTK) return (mdead | mhit); /* no passive attacks */ 1055. 	   if(mddat->mattk[i].aatyp == AT_NONE) break; 1056. 	} 1057. 	if (mddat->mattk[i].damn) 1058. 	   tmp = d((int)mddat->mattk[i].damn,  1059. 				    (int)mddat->mattk[i].damd); 1060. 	else if(mddat->mattk[i].damd) 1061. 	   tmp = d((int)mddat->mlevel+1, (int)mddat->mattk[i].damd); 1062. 	else 1063. 	   tmp = 0; 1064. 1065. 	/* These affect the enemy even if defender killed */ 1066. 	switch(mddat->mattk[i].adtyp) { 1067. 	   case AD_ACID: 1068. 		if (mhit && !rn2(2)) { 1069. 		   Strcpy(buf, Monnam(magr)); 1070. 		   if(canseemon(magr)) 1071. 			pline("%s is splashed by %s acid!", 1072. 			      buf, s_suffix(mon_nam(mdef))); 1073. 		   if (resists_acid(magr)) { 1074. 			if(canseemon(magr)) 1075. 			   pline("%s is not affected.", Monnam(magr)); 1076. 			tmp = 0; 1077. 		   }  1078. 		} else tmp = 0; 1079. 		goto assess_dmg; 1080. 	   case AD_ENCH:	/* KMH -- remove enchantment (disenchanter) */ 1081. 		if (mhit && !mdef->mcan && otmp) { 1082. 		   (void) drain_item(otmp); 1083. 		   /* No message */ 1084. 		} 1085. 		break; 1086. 	   default: 1087. 		break; 1088. 	} 1089. 	if (mdead || mdef->mcan) return (mdead|mhit); 1090. 1091. 	/* These affect the enemy only if defender is still alive */ 1092. 	if (rn2(3)) switch(mddat->mattk[i].adtyp) { 1093. 	   case AD_PLYS: /* Floating eye */ 1094. 		if (tmp > 127) tmp = 127; 1095. 		if (mddat == &mons[PM_FLOATING_EYE]) { 1096. 		   if (!rn2(4)) tmp = 127; 1097. 		   if (magr->mcansee && haseyes(madat) && mdef->mcansee &&  1098. 			(perceives(madat) || !mdef->minvis)) { 1099. 			Sprintf(buf, "%s gaze is reflected by %%s %%s.", 1100. 				s_suffix(mon_nam(mdef))); 1101. 			if (mon_reflects(magr, 1102. 					 canseemon(magr) ? buf : (char *)0)) 1103. 				return(mdead|mhit); 1104. 			Strcpy(buf, Monnam(magr)); 1105. 			if(canseemon(magr)) 1106. 			   pline("%s is frozen by %s gaze!",  1107. 				  buf, s_suffix(mon_nam(mdef))); 1108. 			magr->mcanmove = 0; 1109. 			magr->mfrozen = tmp; 1110. 			return (mdead|mhit); 1111. 		   }  1112. 		} else { /* gelatinous cube */ 1113. 		   Strcpy(buf, Monnam(magr)); 1114. 		   if(canseemon(magr)) 1115. 			pline("%s is frozen by %s.", buf, mon_nam(mdef)); 1116. 		   magr->mcanmove = 0; 1117. 		   magr->mfrozen = tmp; 1118. 		   return (mdead|mhit); 1119. 		} 1120. 		return 1; 1121. 	   case AD_COLD: 1122. 		if (resists_cold(magr)) { 1123. 		   if (canseemon(magr)) { 1124. 			pline("%s is mildly chilly.", Monnam(magr)); 1125. 			golemeffects(magr, AD_COLD, tmp); 1126. 		   }  1127. 		    tmp = 0; 1128. 		   break; 1129. 		} 1130. 		if(canseemon(magr)) 1131. 		   pline("%s is suddenly very cold!", Monnam(magr)); 1132. 		mdef->mhp += tmp / 2; 1133. 		if (mdef->mhpmax < mdef->mhp) mdef->mhpmax = mdef->mhp; 1134. 		if (mdef->mhpmax > ((int) (mdef->m_lev+1) * 8)) 1135. 		   (void)split_mon(mdef, magr); 1136. 		break; 1137. 	   case AD_STUN: 1138. 		if (!magr->mstun) { 1139. 		   magr->mstun = 1; 1140. 		   if (canseemon(magr)) 1141. 			pline("%s staggers...", Monnam(magr)); 1142. 		} 1143. 		tmp = 0; 1144. 		break; 1145. 	   case AD_FIRE: 1146. 		if (resists_fire(magr)) { 1147. 		   if (canseemon(magr)) { 1148. 			pline("%s is mildly warmed.", Monnam(magr)); 1149. 			golemeffects(magr, AD_FIRE, tmp); 1150. 		   }  1151. 		    tmp = 0; 1152. 		   break; 1153. 		} 1154. 		if(canseemon(magr)) 1155. 		   pline("%s is suddenly very hot!", Monnam(magr)); 1156. 		break; 1157. 	   case AD_ELEC: 1158. 		if (resists_elec(magr)) { 1159. 		   if (canseemon(magr)) { 1160. 			pline("%s is mildly tingled.", Monnam(magr)); 1161. 			golemeffects(magr, AD_ELEC, tmp); 1162. 		   }  1163. 		    tmp = 0; 1164. 		   break; 1165. 		} 1166. 		if(canseemon(magr)) 1167. 		   pline("%s is jolted with electricity!", Monnam(magr)); 1168. 		break; 1169. 	   default: tmp = 0; 1170. 		break; 1171. 	} 1172. 	else tmp = 0; 1173. 1174.     assess_dmg: 1175. 	if((magr->mhp -= tmp) <= 0) { 1176. 		monkilled(magr, "", (int)mddat->mattk[i].adtyp); 1177. 		return (mdead | mhit | MM_AGR_DIED); 1178. 	} 1179. 	return (mdead | mhit); 1180. } 1181.  1182. #endif /* OVLB */ 1183. 1184. /*mhitm.c*/ 1185.