Fandom

Wikihack

Source:NetHack 3.2.0/uhitm.c

2,034pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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

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

The NetHack General Public License applies to screenshots, source code and other content from NetHack.
1.    /*	SCCS Id: @(#)uhitm.c	3.2	96/02/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.    static boolean FDECL(known_hitum, (struct monst *,int *,struct attack *));
8.    static boolean FDECL(hitum, (struct monst *,int,struct attack *));
9.    static int FDECL(explum, (struct monst *,struct attack *));
10.   static void FDECL(start_engulf, (struct monst *));
11.   static void NDECL(end_engulf);
12.   static int FDECL(gulpum, (struct monst *,struct attack *));
13.   static boolean FDECL(hmonas, (struct monst *,int));
14.   static void FDECL(nohandglow, (struct monst *));
15.   
16.   extern boolean notonhead;	/* for long worms */
17.   /* The below might become a parameter instead if we use it a lot */
18.   static int dieroll;
19.   /* Used to flag attacks caused by Stormbringer's maliciousness. */
20.   static boolean override_confirmation = FALSE;
21.   
22.   
23.   #ifdef WEAPON_SKILLS
24.   #define PROJECTILE(obj)	((obj) && objects[(obj)->otyp].oc_wepcat==WEP_MISSILE)
25.   #endif
26.   
27.   boolean
28.   attack_checks(mtmp, wep)
29.   register struct monst *mtmp;
30.   struct obj *wep;	/* uwep for attack(), null for kick_monster() */
31.   {
32.   	char qbuf[QBUFSZ];
33.   
34.   	/* if you're close enough to attack, alert any waiting monster */
35.   	mtmp->mstrategy &= ~STRAT_WAITMASK;
36.   
37.   	if(mtmp->m_ap_type && !Protection_from_shape_changers
38.   						&& !sensemon(mtmp)) {
39.   		stumble_onto_mimic(mtmp);
40.   		return TRUE;
41.   	}
42.   
43.   	if (mtmp->mundetected && !canseemon(mtmp) &&
44.   		(hides_under(mtmp->data) || mtmp->data->mlet == S_EEL)) {
45.   	    mtmp->mundetected = mtmp->msleep = 0;
46.   	    newsym(mtmp->mx, mtmp->my);
47.   	    if (!(Blind ? Telepat : (HTelepat & ~INTRINSIC))) {
48.   		struct obj *obj;
49.   
50.   		if (Blind || (is_pool(mtmp->mx,mtmp->my) && !Underwater))
51.   		    pline("Wait!  There's a hidden monster there!");
52.   		else if ((obj = level.objects[mtmp->mx][mtmp->my]) != 0)
53.   		    pline("Wait!  There's %s hiding under %s!",
54.   			  an(l_monnam(mtmp)), doname(obj));
55.   		return TRUE;
56.   	    }
57.   	}
58.   
59.   	if (flags.confirm && mtmp->mpeaceful
60.   	    && !Confusion && !Hallucination && !Stunned) {
61.   		/* Intelligent chaotic weapons (Stormbringer) want blood */
62.   		if (wep && wep->oartifact == ART_STORMBRINGER) {
63.   			override_confirmation = TRUE;
64.   			return(FALSE);
65.   		}
66.   		if (canspotmon(mtmp)) {
67.   			Sprintf(qbuf, "Really attack %s?", mon_nam(mtmp));
68.   			if (yn(qbuf) != 'y') {
69.   				flags.move = 0;
70.   				return(TRUE);
71.   			}
72.   		}
73.   	}
74.   
75.   	return(FALSE);
76.   }
77.   
78.   schar
79.   find_roll_to_hit(mtmp)
80.   register struct monst *mtmp;
81.   {
82.   	schar tmp;
83.   	int tmp2;
84.   
85.   	tmp = 1 + Luck + abon() + find_mac(mtmp) +
86.   		maybe_polyd(uasmon->mlevel, u.ulevel);
87.   
88.   /*	it is unchivalrous to attack the defenseless or from behind */
89.   	if (Role_is('K') && u.ualign.type == A_LAWFUL &&
90.   	    (!mtmp->mcanmove || mtmp->msleep || mtmp->mflee) &&
91.   	    u.ualign.record > -10) adjalign(-1);
92.   
93.   /*	attacking peaceful creatures is bad for the samurai's giri */
94.   	if (Role_is('S') && mtmp->mpeaceful &&
95.   	    u.ualign.record > -10) adjalign(-1);
96.   
97.   /*	Adjust vs. (and possibly modify) monster state.		*/
98.   
99.   	if(mtmp->mstun) tmp += 2;
100.  	if(mtmp->mflee) tmp += 2;
101.  
102.  	if(mtmp->msleep) {
103.  		mtmp->msleep = 0;
104.  		tmp += 2;
105.  	}
106.  	if(!mtmp->mcanmove) {
107.  		tmp += 4;
108.  		if(!rn2(10)) {
109.  			mtmp->mcanmove = 1;
110.  			mtmp->mfrozen = 0;
111.  		}
112.  	}
113.  	if (is_orc(mtmp->data) && maybe_polyd(is_elf(uasmon), Role_is('E')))
114.  	    tmp++;
115.  
116.  /*	with a lot of luggage, your agility diminishes */
117.  	if ((tmp2 = near_capacity()) != 0) tmp -= (tmp2*2) - 1;
118.  	if (u.utrap) tmp -= 3;
119.  /*	Some monsters have a combination of weapon attacks and non-weapon
120.   *	attacks.  It is therefore wrong to add hitval to tmp; we must add
121.   *	it only for the specific attack (in hmonas()).
122.   */
123.  	if (uwep) tmp += maybe_polyd(0, hitval(uwep, mtmp));
124.  	return tmp;
125.  }
126.  
127.  /* try to attack; return FALSE if monster evaded */
128.  /* u.dx and u.dy must be set */
129.  boolean
130.  attack(mtmp)
131.  register struct monst *mtmp;
132.  {
133.  	schar tmp;
134.  	register struct permonst *mdat = mtmp->data;
135.  
136.  	/* This section of code provides protection against accidentally
137.  	 * hitting peaceful (like '@') and tame (like 'd') monsters.
138.  	 * Protection is provided as long as player is not: blind, confused,
139.  	 * hallucinating or stunned.
140.  	 * changes by wwp 5/16/85
141.  	 * More changes 12/90, -dkh-. if its tame and safepet, (and protected
142.  	 * 07/92) then we assume that you're not trying to attack. Instead,
143.  	 * you'll usually just swap places if this is a movement command
144.  	 */
145.  	/* Intelligent chaotic weapons (Stormbringer) want blood */
146.  	if (is_safepet(mtmp)) {
147.  	    if (!uwep || uwep->oartifact != ART_STORMBRINGER) {
148.  		/* there are some additional considerations: this won't work
149.  		 * if in a shop or Punished or you miss a random roll or
150.  		 * if you can walk thru walls and your pet cannot (KAA) or
151.  		 * if your pet is a long worm (unless someone does better).
152.  		 * there's also a chance of displacing a "frozen" monster.
153.  		 * sleeping monsters might magically walk in their sleep.
154.  		 */
155.  		unsigned int foo = (Punished ||
156.  				    !rn2(7) || is_longworm(mtmp->data));
157.  
158.  		if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE) || foo
159.  			|| (IS_ROCK(levl[u.ux][u.uy].typ) &&
160.  					!passes_walls(mtmp->data))) {
161.  		    mtmp->mflee = 1;
162.  		    mtmp->mfleetim = rnd(6);
163.  		    You("stop.  %s is in your way!",
164.  			(mtmp->mnamelth ? NAME(mtmp) : Monnam(mtmp)));
165.  		    return(TRUE);
166.  		} else if ((mtmp->mfrozen || (! mtmp->mcanmove)
167.  				|| (mtmp->data->mmove == 0)) && rn2(6)) {
168.  		    pline("%s doesn't seem to move!", Monnam(mtmp));
169.  		    return(TRUE);
170.  		} else return(FALSE);
171.  	    }
172.  	}
173.  
174.  	/* possibly set in attack_checks;
175.  	   examined in known_hitum, called via hitum or hmonas below */
176.  	override_confirmation = FALSE;
177.  	if (attack_checks(mtmp, uwep)) return(TRUE);
178.  
179.  	if (Upolyd) {
180.  		/* certain "pacifist" monsters don't attack */
181.  		if(noattacks(uasmon)) {
182.  			You("have no way to attack monsters physically.");
183.  			mtmp->mstrategy &= ~STRAT_WAITMASK;
184.  			return(TRUE);
185.  		}
186.  	}
187.  
188.  	if(check_capacity("You cannot fight while so heavily loaded."))
189.  	    return (TRUE);
190.  
191.  	if(unweapon) {
192.  	    unweapon=FALSE;
193.  	    if(flags.verbose)
194.  		if(uwep)
195.  		    You("begin bashing monsters with your %s.",
196.  			aobjnam(uwep, (char *)0));
197.  		else if (!cantwield(uasmon))
198.  		    You("begin bashing monsters with your %s %s.",
199.  			uarmg ? "gloved" : "bare",	/* Del Lamb */
200.  			makeplural(body_part(HAND)));
201.  	}
202.  	exercise(A_STR, TRUE);		/* you're exercising muscles */
203.  	/* andrew@orca: prevent unlimited pick-axe attacks */
204.  	u_wipe_engr(3);
205.  
206.  	if(mdat->mlet == S_LEPRECHAUN && mtmp->mfrozen && !mtmp->msleep &&
207.  	   !mtmp->mconf && mtmp->mcansee && !rn2(7) &&
208.  	   (m_move(mtmp, 0) == 2 ||			    /* it died */
209.  	   mtmp->mx != u.ux+u.dx || mtmp->my != u.uy+u.dy)) /* it moved */
210.  		return(FALSE);
211.  
212.  	tmp = find_roll_to_hit(mtmp);
213.  	(void) maybe_polyd( hmonas(mtmp,tmp),
214.  		hitum(mtmp,tmp,playermon.mattk) );
215.  	mtmp->mstrategy &= ~STRAT_WAITMASK;
216.  	return(TRUE);
217.  }
218.  
219.  static boolean
220.  known_hitum(mon, mhit, uattk)	/* returns TRUE if monster still lives */
221.  register struct monst *mon;
222.  register int *mhit;
223.  struct attack *uattk;
224.  {
225.  	register boolean malive = TRUE, special;
226.  
227.  	/* we need to know whether the special monster was peaceful */
228.  	/* before the attack, to save idle calls to angry_guards()  */
229.  	special = (mon->mpeaceful && (mon->data == &mons[PM_WATCHMAN] ||
230.  				mon->data == &mons[PM_WATCH_CAPTAIN] ||
231.  				      mon->ispriest || mon->isshk));
232.  
233.  	if (override_confirmation) {
234.  	    /* this may need to be generalized if weapons other than
235.  	       Stormbringer acquire similar anti-social behavior... */
236.  	    if (flags.verbose) Your("bloodthirsty blade attacks!");
237.  	}
238.  
239.  	if(!*mhit) {
240.  	    missum(mon, uattk);
241.  	} else {
242.  	    int oldhp = mon->mhp;
243.  
244.  	    /* we hit the monster; be careful: it might die! */
245.  	    notonhead = (mon->mx != u.ux+u.dx || mon->my != u.uy+u.dy);
246.  	    if((malive = hmon(mon, uwep, 0)) == TRUE) {
247.  		/* monster still alive */
248.  		if(!rn2(25) && mon->mhp < mon->mhpmax/2) {
249.  			mon->mflee = 1;
250.  			if(!rn2(3)) mon->mfleetim = rnd(100);
251.  			if(u.ustuck == mon && !u.uswallow && !sticks(uasmon))
252.  				u.ustuck = 0;
253.  		}
254.  		/* Vorpal Blade hit converted to miss */
255.  		/* could be headless monster or worm tail */
256.  		if (mon->mhp == oldhp)
257.  			*mhit = 0;
258.  		if (mon->wormno && *mhit)
259.  			cutworm(mon, u.ux+u.dx, u.uy+u.dy, uwep);
260.  	    }
261.  	    if(mon->ispriest && !rn2(2)) ghod_hitsu(mon);
262.  	    if(special) (void) angry_guards(!flags.soundok);
263.  	}
264.  	return(malive);
265.  }
266.  
267.  static boolean
268.  hitum(mon, tmp, uattk)		/* returns TRUE if monster still lives */
269.  struct monst *mon;
270.  int tmp;
271.  struct attack *uattk;
272.  {
273.  	boolean malive;
274.  	int mhit = (tmp > (dieroll = rnd(20)) || u.uswallow);
275.  
276.  	if(tmp > dieroll) exercise(A_DEX, TRUE);
277.  	malive = known_hitum(mon, &mhit, uattk);
278.  	(void) passive(mon, mhit, malive, FALSE);
279.  	return(malive);
280.  }
281.  
282.  boolean			/* general "damage monster" routine */
283.  hmon(mon, obj, thrown)		/* return TRUE if mon still alive */
284.  register struct monst *mon;
285.  register struct obj *obj;
286.  register int thrown;
287.  {
288.  	int tmp;
289.  	struct permonst *mdat = mon->data;
290.  	/* Why all these booleans?  This stuff has to be done in the
291.  	 *      following order:
292.  	 * 1) Know what we're attacking with, and print special hittxt for
293.  	 *	unusual cases.
294.  	 * 2a) Know whether we did damage (depends on 1)
295.  	 * 2b) Know if it's poisoned (depends on 1)
296.  	 * 2c) Know whether we get a normal damage bonus or not (depends on 1)
297.  	 * 3a) Know what the value of the damage bonus is (depends on 2c)
298.  	 * 3b) Know how much poison damage was taken (depends on 2b) and if the
299.  	 *	poison instant-killed it
300.  	 * 4) Know if it was killed (requires knowing 3a, 3b) except by instant-
301.  	 *	kill poison
302.  	 * 5) Print hit message (depends on 1 and 4)
303.  	 * 6a) Print poison message (must be done after 5)
304.  #if 0
305.  	 * 6b) Rust weapon (must be done after 5)
306.  #endif
307.  	 * 7) Possibly kill monster (must be done after 6a, 6b)
308.  	 * 8) Instant-kill from poison (can happen anywhere between 5 and 9)
309.  	 * 9) Hands not glowing (must be done after 7 and 8)
310.  	 * The major problem is that since we don't want a "hit" message
311.  	 * when the monster dies, we have to know how much damage it did
312.  	 * _before_ outputting a hit message, but any messages associated with
313.  	 * the damage don't come out until _after_ outputting a hit message.
314.  	 */
315.  	boolean hittxt = FALSE, destroyed = FALSE;
316.  	boolean get_dmg_bonus = TRUE;
317.  	boolean ispoisoned = FALSE, needpoismsg = FALSE, poiskilled = FALSE;
318.  	boolean silvermsg = FALSE;
319.  #ifdef WEAPON_SKILLS
320.  	boolean valid_weapon_attack = FALSE;
321.  	int type;
322.  	struct obj *monwep, *wep;
323.  #endif /* WEAPON_SKILLS */
324.  
325.  	wakeup(mon);
326.  	if(!obj) {	/* attack with bare hands */
327.  	    if (mdat == &mons[PM_SHADE])
328.  		tmp = 0;
329.  #ifdef WEAPON_SKILLS
330.  	    else if (P_RESTRICTED(P_MARTIAL_ARTS))
331.  		tmp = rnd(2);
332.  	    else	/* knowing Martial Arts will increase base damage */
333.  		tmp = rnd(4);
334.  	    valid_weapon_attack = (tmp > 1);
335.  #else
336.  	    else
337.  		tmp = rnd(2);
338.  #endif /* WEAPON_SKILLS */
339.  	} else {
340.  	    if(obj->oclass == WEAPON_CLASS || is_weptool(obj) ||
341.  	       obj->oclass == GEM_CLASS) {
342.  
343.  		/* is it not a melee weapon? */
344.  		if (/* if you strike with a bow... */
345.  		    objects[obj->otyp].oc_wepcat == WEP_BOW ||
346.  		    /* or strike with a missile in your hand... */
347.  		    (!thrown && (objects[obj->otyp].oc_wepcat == WEP_MISSILE ||
348.  				 objects[obj->otyp].oc_wepcat == WEP_AMMO)) ||
349.  		    /* or throw a missile without the proper bow... */
350.  		    (objects[obj->otyp].oc_wepcat == WEP_AMMO &&
351.  		     (!uwep || objects[obj->otyp].w_propellor !=
352.  			       -objects[uwep->otyp].w_propellor))) {
353.  		    /* then do only 1-2 points of damage */
354.  		    if (mdat == &mons[PM_SHADE] && obj->otyp != SILVER_ARROW)
355.  			tmp = 0;
356.  		    else
357.  			tmp = rnd(2);
358.  		} else {
359.  		    tmp = dmgval(obj, mon);
360.  #ifdef WEAPON_SKILLS
361.  		    /* a minimal hit doesn't exercise proficiency */
362.  		    valid_weapon_attack = (tmp > 1);
363.  		    if (!valid_weapon_attack || mon == u.ustuck) {
364.  			;	/* no special bonuses */
365.  		    } else if (mon->mflee && Role_is('R') && !Upolyd) {
366.  			You("strike %s from behind!", mon_nam(mon));
367.  			tmp += rnd(u.ulevel);
368.  			hittxt = TRUE;
369.  		    } else if (dieroll == 2 && obj == uwep &&
370.  			  obj->oclass == WEAPON_CLASS &&
371.  			  (bimanual(obj) ||
372.  			    (Role_is('S') && obj->otyp == KATANA && !uarms)) &&
373.  			  ((type = weapon_type(obj)) != P_NO_TYPE &&
374.  			    P_SKILL(type) >= P_SKILLED) &&
375.  			  ((monwep = MON_WEP(mon)) != 0 &&
376.  			    !obj_resists(monwep,
377.  					 50 + 15 * (int)obj->oeroded, 100))) {
378.  			/*
379.  			 * 2.5% chance of shattering defender's weapon when
380.  			 * using a two-handed weapon; less if uwep is rusted.
381.  			 * [dieroll == 2 is most successful non-beheading or
382.  			 * -bisecting hit, in case of special artifact damage;
383.  			 * the percentage chance is (1/20)*(50/100).]
384.  			 */
385.  			monwep->owornmask &= ~W_WEP;
386.  			MON_NOWEP(mon);
387.  			mon->weapon_check = NEED_WEAPON;
388.  			pline("%s %s shatters from the force of your blow!",
389.  			      s_suffix(Monnam(mon)), xname(monwep));
390.  			m_useup(mon, monwep);
391.  			/* If someone just shattered MY weapon, I'd flee! */
392.  			if (rn2(4) && !mon->mflee) {
393.  			    mon->mflee = 1;
394.  			    mon->mfleetim = d(2,3);
395.  			}
396.  			hittxt = TRUE;
397.  		    }
398.  #endif /* WEAPON_SKILLS */
399.  		    if (obj->oartifact &&
400.  			artifact_hit(&youmonst, mon, obj, &tmp, dieroll)) {
401.  			if(mon->mhp <= 0) /* artifact killed monster */
402.  			    return FALSE;
403.  			if (tmp == 0) return TRUE;
404.  			hittxt = TRUE;
405.  		    }
406.  		    if (objects[obj->otyp].oc_material == SILVER
407.  				&& hates_silver(mdat))
408.  			silvermsg = TRUE;
409.  		    if(!thrown && obj == uwep && obj->otyp == BOOMERANG &&
410.  		       !rnl(3)) {
411.  			pline("As you hit %s, %s breaks into splinters.",
412.  			      mon_nam(mon), the(xname(obj)));
413.  			useup(obj);
414.  			obj = (struct obj *) 0;
415.  			hittxt = TRUE;
416.  			if (mdat != &mons[PM_SHADE])
417.  			    tmp++;
418.  		    } else if(thrown &&
419.  			      (objects[obj->otyp].oc_wepcat == WEP_AMMO ||
420.  			       objects[obj->otyp].oc_wepcat == WEP_MISSILE)) {
421.  			if(objects[obj->otyp].oc_wepcat == WEP_AMMO &&
422.  			   uwep && objects[obj->otyp].w_propellor ==
423.  			   -objects[uwep->otyp].w_propellor) {
424.  			    /* Elves and Samurai do extra damage using
425.  			     * their bows&arrows; they're highly trained.
426.  			     */
427.  			    if (Role_is('S') &&
428.  				obj->otyp == YA && uwep->otyp == YUMI)
429.  				tmp++;
430.  			    else if (Role_is('E') &&
431.  				     obj->otyp == ELVEN_ARROW &&
432.  				     uwep->otyp == ELVEN_BOW)
433.  				tmp++;
434.  			}
435.  			if(obj->opoisoned &&
436.  			   ((uwep && objects[obj->otyp].w_propellor ==
437.  				     -objects[uwep->otyp].w_propellor) ||
438.  			    objects[obj->otyp].oc_wepcat == WEP_MISSILE))
439.  			    ispoisoned = TRUE;
440.  		    }
441.  		}
442.  	    } else if(obj->oclass == POTION_CLASS) {
443.  			if (obj->quan > 1L) setworn(splitobj(obj, 1L), W_WEP);
444.  			else setuwep((struct obj *)0);
445.  			freeinv(obj);
446.  			potionhit(mon,obj);
447.  			hittxt = TRUE;
448.  			if (mdat == &mons[PM_SHADE])
449.  			    tmp = 0;
450.  			else
451.  			    tmp = 1;
452.  	    } else {
453.  		switch(obj->otyp) {
454.  		    case HEAVY_IRON_BALL:
455.  			tmp = rnd(25); break;
456.  		    case BOULDER:
457.  			tmp = rnd(20); break;
458.  		    case MIRROR:
459.  			You("break your mirror.  That's bad luck!");
460.  			change_luck(-2);
461.  			useup(obj);
462.  			obj = (struct obj *) 0;
463.  			hittxt = TRUE;
464.  			tmp = 1;
465.  			break;
466.  #ifdef TOURIST
467.  		    case EXPENSIVE_CAMERA:
468.  	You("succeed in destroying your camera.  Congratulations!");
469.  			useup(obj);
470.  			return(TRUE);
471.  #endif
472.  		    case CORPSE:		/* fixed by polder@cs.vu.nl */
473.  			if (obj->corpsenm == PM_COCKATRICE) {
474.  			    tmp = 1;
475.  			    hittxt = TRUE;
476.  			    You("hit %s with %s cockatrice corpse.",
477.  				mon_nam(mon), obj->dknown ? "the" : "a");
478.  			    if (!munstone(mon, TRUE))
479.  				minstapetrify(mon, TRUE);
480.  			    if (resists_ston(mon)) break;
481.  			    /* note: hp may be <= 0 even if munstoned==TRUE */
482.  			    return (boolean) (mon->mhp > 0);
483.  #if 0
484.  			} else if (mdat == &mons[PM_COCKATRICE]) {
485.  			    /* maybe turn the corpse into a statue? */
486.  #endif
487.  			}
488.  			tmp = (obj->corpsenm >= LOW_PM ?
489.  					mons[obj->corpsenm].msize : 0) + 1;
490.  			break;
491.  		    case EGG:
492.  		      {
493.  			/* setting quantity to 1 forces complete `useup' */
494.  #define useup_eggs(o)	{ o->quan = 1L; \
495.  			  if (thrown) obfree(o,(struct obj *)0); \
496.  			  else useup(o); \
497.  			  o = (struct obj *)0; }	/* now gone */
498.  			long cnt = obj->quan;
499.  
500.  			tmp = 1;		/* nominal physical damage */
501.  			get_dmg_bonus = FALSE;
502.  			hittxt = TRUE;		/* message always given */
503.  			/* egg is always either used up or transformed, so next
504.  			   hand-to-hand attack should yield a "bashing" mesg */
505.  			if (obj == uwep) unweapon = TRUE;
506.  			if (obj->spe && obj->corpsenm >= LOW_PM)
507.  			    if (obj->quan < 5)
508.  				change_luck((schar) -(obj->quan));
509.  			    else
510.  				change_luck(-5);
511.  
512.  			if (obj->corpsenm == PM_COCKATRICE) {
513.  			    /* minor bug: this identifies the type of egg,
514.  			       but if it is being thrown, any others it was
515.  			       grouped with can't be marked as known because
516.  			       it has already been split away from them... */
517.  			    You("hit %s with %s cockatrice egg%s.  Splat!",
518.  				mon_nam(mon),
519.  				obj->known ? "the" : cnt > 1L ? "some" : "a",
520.  				plur(cnt));
521.  			    obj->known = 1;	/* (not much point...) */
522.  			    useup_eggs(obj);
523.  			    if (!munstone(mon, TRUE))
524.  				minstapetrify(mon, TRUE);
525.  			    if (resists_ston(mon)) break;
526.  			    return (boolean) (mon->mhp > 0);
527.  			} else {	/* ordinary egg(s) */
528.  			    const char *eggp =
529.  				     (obj->corpsenm != NON_PM && obj->known) ?
530.  					      the(mons[obj->corpsenm].mname) :
531.  					      (cnt > 1L) ? "some" : "an";
532.  			    You("hit %s with %s egg%s.",
533.  				mon_nam(mon), eggp, plur(cnt));
534.  			    if (mdat == &mons[PM_COCKATRICE]) {
535.  				pline_The("egg%s %s alive any more...",
536.  				      plur(cnt),
537.  				      (cnt == 1L) ? "isn't" : "aren't");
538.  				if (obj->timed) obj_stop_timers(obj);
539.  				obj->otyp = ROCK;
540.  				obj->oclass = GEM_CLASS;
541.  				obj->oartifact = 0;
542.  				obj->spe = 0;
543.  				obj->known = obj->dknown = obj->bknown = 0;
544.  				obj->owt = weight(obj);
545.  				if (thrown) place_object(obj, mon->mx, mon->my);
546.  			    } else {
547.  				pline("Splat!");
548.  				useup_eggs(obj);
549.  				exercise(A_WIS, FALSE);
550.  			    }
551.  			}
552.  			break;
553.  #undef useup_eggs
554.  		      }
555.  		    case CLOVE_OF_GARLIC:	/* no effect against demons */
556.  			if (is_undead(mdat)) {
557.  			    mon->mflee = 1;
558.  			    mon->mfleetim += d(2,4);
559.  			}
560.  			tmp = 1;
561.  			break;
562.  		    case CREAM_PIE:
563.  		    case BLINDING_VENOM:
564.  			if (Blind || !haseyes(mdat))
565.  			    pline(obj->otyp==CREAM_PIE ? "Splat!" : "Splash!");
566.  			else if (obj->otyp == BLINDING_VENOM)
567.  			    pline_The("venom blinds %s%s!", mon_nam(mon),
568.  					mon->mcansee ? "" : " further");
569.  			else {
570.  			    char *whom = mon_nam(mon);
571.  			    /* note: s_suffix returns a modifiable buffer */
572.  			    if (haseyes(mdat) && mdat != &mons[PM_FLOATING_EYE])
573.  				whom = strcat(s_suffix(whom), " face");
574.  			    pline_The("cream pie splashes over %s!", whom);
575.  			}
576.  			if(mon->msleep) mon->msleep = 0;
577.  			setmangry(mon);
578.  			if(haseyes(mon->data)) {
579.  			    mon->mcansee = 0;
580.  			    tmp = rn1(25, 21);
581.  			    if(((int) mon->mblinded + tmp) > 127)
582.  				mon->mblinded = 127;
583.  			    else mon->mblinded += tmp;
584.  			}
585.  			if (thrown) obfree(obj, (struct obj *)0);
586.  			else useup(obj);
587.  			hittxt = TRUE;
588.  			get_dmg_bonus = FALSE;
589.  			tmp = 0;
590.  			break;
591.  		    case ACID_VENOM: /* thrown (or spit) */
592.  			if (resists_acid(mon)) {
593.  				Your("venom hits %s harmlessly.",
594.  					mon_nam(mon));
595.  				tmp = 0;
596.  			} else {
597.  				Your("venom burns %s!", mon_nam(mon));
598.  				tmp = dmgval(obj, mon);
599.  			}
600.  			if (thrown) obfree(obj, (struct obj *)0);
601.  			else useup(obj);
602.  			hittxt = TRUE;
603.  			get_dmg_bonus = FALSE;
604.  			break;
605.  		    default:
606.  			/* non-weapons can damage because of their weight */
607.  			/* (but not too much) */
608.  			tmp = obj->owt/100;
609.  			if(tmp < 1) tmp = 1;
610.  			else tmp = rnd(tmp);
611.  			if(tmp > 6) tmp = 6;
612.  		}
613.  		if (mdat == &mons[PM_SHADE] && obj &&
614.  				objects[obj->otyp].oc_material != SILVER)
615.  		    tmp = 0;
616.  	    }
617.  	}
618.  
619.  	/****** NOTE: perhaps obj is undefined!! (if !thrown && BOOMERANG)
620.  	 *      *OR* if attacking bare-handed!! */
621.  
622.  	if (get_dmg_bonus && tmp > 0) {
623.  		tmp += u.udaminc;
624.  		/* If you throw using a propellor, you don't get a strength
625.  		 * bonus but you do get an increase-damage bonus.
626.  		 */
627.  		if(!thrown || !obj || !uwep ||
628.  		   (obj->oclass != GEM_CLASS && obj->oclass != WEAPON_CLASS) ||
629.  		   !objects[obj->otyp].w_propellor ||
630.  		   (objects[obj->otyp].w_propellor !=
631.  				-objects[uwep->otyp].w_propellor))
632.  		    tmp += dbon();
633.  	}
634.  
635.  #ifdef WEAPON_SKILLS
636.  	if (valid_weapon_attack) {
637.  	    /* to be valid a projectile must have the correct projector */
638.  	    wep = PROJECTILE(obj) ? uwep : obj;
639.  	    tmp += weapon_dam_bonus(wep);
640.  	    type = weapon_type(wep);
641.  	    if (type != P_NO_TYPE)
642.  		P_ADVANCE(type)++;
643.  	}
644.  #endif /* WEAPON_SKILLS */
645.  
646.  	if (ispoisoned) {
647.  	    if (resists_poison(mon))
648.  		needpoismsg = TRUE;
649.  	    else if (rn2(10))
650.  		tmp += rnd(6);
651.  	    else poiskilled = TRUE;
652.  	}
653.  	if (tmp < 1 && !hittxt) {
654.  	    if (mdat == &mons[PM_SHADE]) {
655.  		Your("attack passes harmlessly through %s.",
656.  			mon_nam(mon));
657.  		hittxt = TRUE;
658.  		tmp = 0;
659.  	    } else
660.  		tmp = 1;
661.  	}
662.  
663.  #ifdef WEAPON_SKILLS
664.  	/* VERY small chance of stunning opponent if unarmed. */
665.  	if (tmp > 1 && !thrown && !obj && !uwep && !uarm && !uarms && !Upolyd) {
666.  	    if (rnd(100) < P_SKILL(weapon_type((struct obj *) 0)) &&
667.  			!bigmonst(mdat) && !thick_skinned(mdat)) {
668.  		if (canspotmon(mon))
669.  		    pline("%s staggers from your powerful strike!",
670.  			  Monnam(mon));
671.  		mon->mstun = 1;
672.  		hittxt = TRUE;
673.  		if (mon->mcanmove && mon != u.ustuck) {
674.  		    xchar mdx, mdy;
675.  
676.  		    /* see if the monster has a place to move into */
677.  		    mdx = mon->mx + u.dx;
678.  		    mdy = mon->my + u.dy;
679.  		    if (goodpos(mdx, mdy, mon, mon->data)) {
680.  			remove_monster(mon->mx, mon->my);
681.  			newsym(mon->mx, mon->my);
682.  			place_monster(mon, mdx, mdy);
683.  			newsym(mon->mx, mon->my);
684.  			set_apparxy(mon);
685.  		    }
686.  		}
687.  	    }
688.  	}
689.  #endif /* WEAPON_SKILLS */
690.  
691.  	mon->mhp -= tmp;
692.  	if(mon->mhp < 1)
693.  		destroyed = TRUE;
694.  	if (mon->mtame && (!mon->mflee || mon->mfleetim) && tmp > 0) {
695.  		unsigned fleetim;
696.  
697.  		abuse_dog(mon);
698.  		mon->mflee = TRUE;		/* Rick Richardson */
699.  		fleetim = mon->mfleetim + (unsigned)(10 * rnd(tmp));
700.  		mon->mfleetim = min(fleetim,127);
701.  	}
702.  	if((mdat == &mons[PM_BLACK_PUDDING] || mdat == &mons[PM_BROWN_PUDDING])
703.  		   && obj && obj == uwep
704.  		   && objects[obj->otyp].oc_material == IRON
705.  		   && mon->mhp > 1 && !thrown && !mon->mcan
706.  		   /* && !destroyed  -- guaranteed by mhp > 1 */ ) {
707.  		if (clone_mon(mon)) {
708.  			pline("%s divides as you hit it!", Monnam(mon));
709.  			hittxt = TRUE;
710.  		}
711.  	}
712.  
713.  	if(!hittxt && !destroyed) {
714.  		if(thrown)
715.  		    /* thrown => obj exists */
716.  		    hit(xname(obj), mon, exclam(tmp) );
717.  		else if(!flags.verbose) You("hit it.");
718.  		else You("%s %s%s", Role_is('B') ? "smite" : "hit",
719.  			 mon_nam(mon), canseemon(mon) ? exclam(tmp) : ".");
720.  	}
721.  
722.  	if (silvermsg) {
723.  		const char *fmt;
724.  		char *whom = mon_nam(mon);
725.  
726.  		if (canspotmon(mon)) {
727.  		    fmt = "The silver sears %s!";
728.  		} else {
729.  		    *whom = highc(*whom);	/* "it" -> "It" */
730.  		    fmt = "%s is seared!";
731.  		}
732.  		/* note: s_suffix returns a modifiable buffer */
733.  		if (!noncorporeal(mdat))
734.  		    whom = strcat(s_suffix(whom), " flesh");
735.  		pline(fmt, whom);
736.  	}
737.  
738.  	if (needpoismsg)
739.  		pline_The("poison doesn't seem to affect %s.", mon_nam(mon));
740.  	if (poiskilled) {
741.  		pline_The("poison was deadly...");
742.  		xkilled(mon, 0);
743.  		return FALSE;
744.  	} else if (destroyed) {
745.  		killed(mon);	/* takes care of most messages */
746.  	} else if(u.umconf && !thrown) {
747.  		nohandglow(mon);
748.  		if(!mon->mconf && !resist(mon, '+', 0, NOTELL)) {
749.  			mon->mconf = 1;
750.  			if(!mon->mstun && mon->mcanmove && !mon->msleep &&
751.  			   canseemon(mon))
752.  				pline("%s appears confused.", Monnam(mon));
753.  		}
754.  	}
755.  
756.  #if 0
757.  	if(mdat == &mons[PM_RUST_MONSTER] && obj && obj == uwep &&
758.  		is_rustprone(obj) && obj->oeroded < MAX_ERODE) {
759.  	    if (obj->greased)
760.  		grease_protect(obj,(char *)0,FALSE);
761.  	    else if (obj->oerodeproof || (obj->blessed && !rnl(4))) {
762.  	        if (flags.verbose)
763.  			pline("Somehow, your %s is not affected.",
764.  			      is_sword(obj) ? "sword" : "weapon");
765.  	    } else {
766.  		Your("%s%s!", aobjnam(obj, "rust"),
767.  		     obj->oeroded+1 == MAX_ERODE ? " completely" :
768.  		     obj->oeroded ? " further" : "");
769.  		obj->oeroded++;
770.  	    }
771.  	}
772.  #endif
773.  
774.  	return((boolean)(destroyed ? FALSE : TRUE));
775.  }
776.  
777.  static void NDECL(demonpet);
778.  /*
779.   * Send in a demon pet for the hero.  Exercise wisdom.
780.   *
781.   * This function used to be inline to damageum(), but the Metrowerks compiler
782.   * (DR4 and DR4.5) screws up with an internal error 5 "Expression Too Complex."
783.   * Pulling it out makes it work.
784.   */
785.  static void
786.  demonpet()
787.  {
788.  	struct permonst *pm;
789.  	struct monst *dtmp;
790.  
791.  	pline("Some hell-p has arrived!");
792.  	pm = !rn2(6) ? &mons[ndemon(u.ualign.type)] : uasmon;
793.  	if ((dtmp = makemon(pm, u.ux, u.uy)) != 0)
794.  	    (void)tamedog(dtmp, (struct obj *)0);
795.  	exercise(A_WIS, TRUE);
796.  }
797.  
798.  int
799.  damageum(mdef, mattk)
800.  register struct monst *mdef;
801.  register struct attack *mattk;
802.  {
803.  	register struct permonst *pd = mdef->data;
804.  	register int	tmp = d((int)mattk->damn, (int)mattk->damd);
805.  
806.  	if (is_demon(uasmon) && !rn2(13) && !uwep
807.  		&& u.umonnum != PM_SUCCUBUS && u.umonnum != PM_INCUBUS
808.  		&& u.umonnum != PM_BALROG) {
809.  	    demonpet();
810.  	    return(0);
811.  	}
812.  	switch(mattk->adtyp) {
813.  	    case AD_STUN:
814.  		if(!Blind)
815.  		    pline("%s staggers for a moment.", Monnam(mdef));
816.  		mdef->mstun = 1;
817.  		/* fall through to next case */
818.  	    case AD_WERE:	    /* no effect on monsters */
819.  	    case AD_HEAL:
820.  	    case AD_LEGS:
821.  	    case AD_PHYS:
822.  		if(mattk->aatyp == AT_WEAP) {
823.  			if(uwep) tmp = 0;
824.  		} else if(mattk->aatyp == AT_KICK)
825.  			if(thick_skinned(mdef->data)) tmp = 0;
826.  		break;
827.  	    case AD_FIRE:
828.  		if (!Blind)
829.  		    pline("%s is %s!", Monnam(mdef),
830.  			  mattk->aatyp == AT_HUGS ?
831.  				"being roasted" : "on fire");
832.  		tmp += destroy_mitem(mdef, SCROLL_CLASS, AD_FIRE);
833.  		tmp += destroy_mitem(mdef, SPBOOK_CLASS, AD_FIRE);
834.  		if (resists_fire(mdef)) {
835.  		    if (!Blind)
836.  			pline_The("fire doesn't heat %s!", mon_nam(mdef));
837.  		    golemeffects(mdef, AD_FIRE, tmp);
838.  		    shieldeff(mdef->mx, mdef->my);
839.  		    tmp = 0;
840.  		}
841.  		/* only potions damage resistant players in destroy_item */
842.  		tmp += destroy_mitem(mdef, POTION_CLASS, AD_FIRE);
843.  		break;
844.  	    case AD_COLD:
845.  		if (!Blind) pline("%s is covered in frost!", Monnam(mdef));
846.  		if (resists_cold(mdef)) {
847.  		    shieldeff(mdef->mx, mdef->my);
848.  		    if (!Blind)
849.  			pline_The("frost doesn't chill %s!", mon_nam(mdef));
850.  		    golemeffects(mdef, AD_COLD, tmp);
851.  		    tmp = 0;
852.  		}
853.  		tmp += destroy_mitem(mdef, POTION_CLASS, AD_COLD);
854.  		break;
855.  	    case AD_ELEC:
856.  		if (!Blind) pline("%s is zapped!", Monnam(mdef));
857.  		tmp += destroy_mitem(mdef, WAND_CLASS, AD_ELEC);
858.  		if (resists_elec(mdef)) {
859.  		    if (!Blind)
860.  			pline_The("zap doesn't shock %s!", mon_nam(mdef));
861.  		    golemeffects(mdef, AD_ELEC, tmp);
862.  		    shieldeff(mdef->mx, mdef->my);
863.  		    tmp = 0;
864.  		}
865.  		/* only rings damage resistant players in destroy_item */
866.  		tmp += destroy_mitem(mdef, RING_CLASS, AD_ELEC);
867.  		break;
868.  	    case AD_ACID:
869.  		if (resists_acid(mdef)) tmp = 0;
870.  		break;
871.  	    case AD_STON:
872.  		if (!munstone(mdef, TRUE))
873.  		    minstapetrify(mdef, TRUE);
874.  		tmp = 0;
875.  		break;
876.  #ifdef SEDUCE
877.  	    case AD_SSEX:
878.  #endif
879.  	    case AD_SEDU:
880.  	    case AD_SITM:
881.  		if(mdef->minvent) {
882.  		    struct obj *otmp, *stealoid;
883.  
884.  		    stealoid = (struct obj *)0;
885.  		    if (could_seduce(&youmonst,mdef,mattk)){
886.  			for(otmp = mdef->minvent; otmp; otmp=otmp->nobj)
887.  			    if (otmp->owornmask & W_ARM) {
888.  				stealoid = otmp;
889.  				/* unwear even if not stolen */
890.  				mdef->misc_worn_check &= ~W_ARM;
891.  				stealoid->owornmask = 0L;
892.  				update_mon_intrinsics(mdef, stealoid, FALSE);
893.  			    }
894.  		    }
895.  		    if (stealoid) {
896.  			boolean whoops = FALSE, stolen = FALSE;
897.  
898.  			if (gender(mdef) == u.mfemale &&
899.  						uasmon->mlet == S_NYMPH)
900.  			    You(
901.  			  "charm %s.  She gladly hands over her possessions.",
902.  				mon_nam(mdef));
903.  			else
904.  			    You(
905.  			    "seduce %s and %s starts to take off %s clothes.",
906.  				mon_nam(mdef), he[pronoun_gender(mdef)],
907.  				his[pronoun_gender(mdef)]);
908.  			while ((otmp = mdef->minvent) != 0) {
909.  				obj_extract_self(otmp);
910.  				if (otmp->owornmask) {
911.  				    mdef->misc_worn_check &= ~otmp->owornmask;
912.  				    otmp->owornmask = 0L;
913.  				    update_mon_intrinsics(mdef, otmp, FALSE);
914.  				}
915.  				if (!stolen && otmp==stealoid) {
916.  				    otmp = hold_another_object(otmp,
917.  					      (const char *)0, (const char *)0,
918.  							      (const char *)0);
919.  				    stealoid = otmp;
920.  				    stolen = TRUE;
921.  				} else {
922.  				    otmp = hold_another_object(otmp,
923.  						 "You steal %s.", doname(otmp),
924.  								"You steal: ");
925.  				}
926.  				if (otmp->otyp == CORPSE &&
927.  				    otmp->corpsenm == PM_COCKATRICE &&
928.  				    !uarmg) {
929.  					whoops = TRUE;
930.  					break;
931.  				}
932.  			}
933.  			pline("%s finishes taking off %s suit.",
934.  			      Monnam(mdef), his[pronoun_gender(mdef)]);
935.  			if (stolen) You("steal %s!", doname(stealoid));
936.  			if (whoops) instapetrify("cockatrice corpse");
937.  			possibly_unwield(mdef);
938.  		   } else {
939.  			otmp = mdef->minvent;
940.  			obj_extract_self(otmp);
941.  			if (otmp->owornmask) {
942.  			    mdef->misc_worn_check &= !otmp->owornmask;
943.  			    otmp->owornmask = 0L;
944.  			    update_mon_intrinsics(mdef, otmp, FALSE);
945.  			}
946.  			otmp = hold_another_object(otmp, "You steal %s.",
947.  						  doname(otmp), "You steal: ");
948.  			if (!(mdef->misc_worn_check & W_ARMG))
949.  			    mselftouch(mdef, (const char *)0, TRUE);
950.  			possibly_unwield(mdef);
951.  		   }
952.  		}
953.  		tmp = 0;
954.  		break;
955.  	    case AD_SGLD:
956.  		if (mdef->mgold) {
957.  		    u.ugold += mdef->mgold;
958.  		    mdef->mgold = 0;
959.  		    Your("purse feels heavier.");
960.  		}
961.  		exercise(A_DEX, TRUE);
962.  		tmp = 0;
963.  		break;
964.  	    case AD_TLPT:
965.  		if(tmp <= 0) tmp = 1;
966.  		if(tmp < mdef->mhp) {
967.  		    rloc(mdef);
968.  		    if(!Blind) pline("%s suddenly disappears!", Monnam(mdef));
969.  		}
970.  		break;
971.  	    case AD_BLND:
972.  		if(haseyes(pd)) {
973.  
974.  		    if(!Blind) pline("%s is blinded.", Monnam(mdef));
975.  		    mdef->mcansee = 0;
976.  		    mdef->mblinded += tmp;
977.  		}
978.  		tmp = 0;
979.  		break;
980.  	    case AD_CURS:
981.  		if (night() && !rn2(10) && !mdef->mcan) {
982.  		    if (mdef->data == &mons[PM_CLAY_GOLEM]) {
983.  			if (!Blind)
984.  			    pline("Some writing vanishes from %s head!",
985.  				s_suffix(mon_nam(mdef)));
986.  			xkilled(mdef, 0);
987.  			/* Don't return yet; keep hp<1 and tmp=0 for pet msg */
988.  		    } else {
989.  			mdef->mcan = 1;
990.  			You("chuckle.");
991.  		    }
992.  		}
993.  		tmp = 0;
994.  		break;
995.  	    case AD_DRLI:
996.  		if (rn2(2) && !resists_drli(mdef)) {
997.  			int xtmp = d(2,6);
998.  			pline("%s suddenly seems weaker!", Monnam(mdef));
999.  			mdef->mhpmax -= xtmp;
1000. 			if ((mdef->mhp -= xtmp) <= 0 || !mdef->m_lev) {
1001. 				pline("%s dies!", Monnam(mdef));
1002. 				xkilled(mdef,0);
1003. 			} else
1004. 				mdef->m_lev--;
1005. 		}
1006. 		tmp = 0;
1007. 		break;
1008. 	    case AD_RUST:
1009. 		if (pd == &mons[PM_IRON_GOLEM]) {
1010. 			pline("%s falls to pieces!", Monnam(mdef));
1011. 			xkilled(mdef,0);
1012. 		}
1013. 		tmp = 0;
1014. 		break;
1015. 	    case AD_DCAY:
1016. 		if (pd == &mons[PM_WOOD_GOLEM] ||
1017. 		    pd == &mons[PM_LEATHER_GOLEM]) {
1018. 			pline("%s falls to pieces!", Monnam(mdef));
1019. 			xkilled(mdef,0);
1020. 		}
1021. 		tmp = 0;
1022. 		break;
1023. 	    case AD_DRST:
1024. 	    case AD_DRDX:
1025. 	    case AD_DRCO:
1026. 		if (!rn2(8)) {
1027. 		    Your("%s was poisoned!", mpoisons_subj(&youmonst, mattk));
1028. 		    if (resists_poison(mdef))
1029. 			pline_The("poison doesn't seem to affect %s.",
1030. 				mon_nam(mdef));
1031. 		    else {
1032. 			if (!rn2(10)) {
1033. 			    Your("poison was deadly...");
1034. 			    tmp = mdef->mhp;
1035. 			} else tmp += rn1(10,6);
1036. 		    }
1037. 		}
1038. 		break;
1039. 	    case AD_DRIN:
1040. 		if (!has_head(mdef->data)) {
1041. 		    pline("%s doesn't seem harmed.", Monnam(mdef));
1042. 		    tmp = 0;
1043. 		    break;
1044. 		}
1045. 		if ((mdef->misc_worn_check & W_ARMH) && rn2(8)) {
1046. 		    pline("%s helmet blocks your attack to %s head.",
1047. 			  s_suffix(Monnam(mdef)), his[pronoun_gender(mdef)]);
1048. 		    break;
1049. 		}
1050. 
1051. 		You("eat %s brain!", s_suffix(mon_nam(mdef)));
1052. 		if (mindless(mdef->data)) {
1053. 		    pline("%s doesn't notice.", Monnam(mdef));
1054. 		    break;
1055. 		}
1056. 		tmp += rnd(10);
1057. 		morehungry(-rnd(30)); /* cannot choke */
1058. 		if (ABASE(A_INT) < AMAX(A_INT)) {
1059. 			ABASE(A_INT) += rnd(4);
1060. 			if (ABASE(A_INT) > AMAX(A_INT))
1061. 				ABASE(A_INT) = AMAX(A_INT);
1062. 			flags.botl = 1;
1063. 		}
1064. 		exercise(A_WIS, TRUE);
1065. 		break;
1066. 	    case AD_STCK:
1067. 		if (!sticks(mdef->data))
1068. 		    u.ustuck = mdef; /* it's now stuck to you */
1069. 		break;
1070. 	    case AD_WRAP:
1071. 		if (!sticks(mdef->data)) {
1072. 		    struct obj *obj = which_armor(mdef, W_ARMC);
1073. 		    if (!obj) obj = which_armor(mdef, W_ARM);
1074. #ifdef TOURIST
1075. 		    if (!obj) obj = which_armor(mdef, W_ARMU);
1076. #endif
1077. 		    if (!u.ustuck && !rn2(10)) {
1078. 			if (obj && obj->greased) {
1079. 			    tmp = 0;
1080. 			    You("slip off of %s%ss greased %s!",
1081. 				mon_nam(mdef),
1082. 				canspotmon(mdef) ? "'" : "",
1083. 				xname(obj));
1084. 			    if (!rn2(2)) {
1085. 				pline_The("grease wears off.");
1086. 				obj->greased = 0;
1087. 			    }
1088. 			} else {
1089. 			    You("swing yourself around %s!",
1090. 				  mon_nam(mdef));
1091. 			    u.ustuck = mdef;
1092. 			}
1093. 		    } else if(u.ustuck == mdef) {
1094. 			/* Monsters don't wear amulets of magical breathing */
1095. 			if (is_pool(u.ux,u.uy) && !is_swimmer(mdef->data)) {
1096. 			    You("drown %s...", mon_nam(mdef));
1097. 			    tmp = mdef->mhp;
1098. 			} else if(mattk->aatyp == AT_HUGS)
1099. 			    pline("%s is being crushed.", Monnam(mdef));
1100. 		    } else {
1101. 			tmp = 0;
1102. 			if(flags.verbose) {
1103. 			    struct permonst *pu;
1104. 
1105. 			    pu = uasmon;
1106. 			    uasmon = mdef->data;
1107. 			    You("brush against %s%ss %s.", mon_nam(mdef),
1108. 				canspotmon(mdef) ? "'" : "",
1109. 				body_part(LEG));
1110. 			    uasmon = pu;
1111. 			}
1112. 		    }
1113. 		} else tmp = 0;
1114. 		break;
1115. 	    case AD_PLYS:
1116. 		if (mdef->mcanmove && !rn2(3) && tmp < mdef->mhp) {
1117. 		    if (!Blind) pline("%s is frozen by you!", Monnam(mdef));
1118. 		    mdef->mcanmove = 0;
1119. 		    mdef->mfrozen = rnd(10);
1120. 		}
1121. 		break;
1122. 	    case AD_SLEE:
1123. 		if (!mdef->msleep && sleep_monst(mdef, rnd(10), -1)) {
1124. 		    if (!Blind)
1125. 			pline("%s is put to sleep by you!", Monnam(mdef));
1126. 		    slept_monst(mdef);
1127. 		}
1128. 		break;
1129. 	    default:	tmp = 0;
1130. 			break;
1131. 	}
1132. 
1133. 	if((mdef->mhp -= tmp) < 1) {
1134. 	    if (mdef->mtame && !cansee(mdef->mx,mdef->my)) {
1135. 		You_feel("embarrassed for a moment.");
1136. 		if (tmp) xkilled(mdef, 0); /* !tmp but hp<1: already killed */
1137. 	    } else if (!flags.verbose) {
1138. 		You("destroy it!");
1139. 		if (tmp) xkilled(mdef, 0);
1140. 	    } else
1141. 		if (tmp) killed(mdef);
1142. 	    return(2);
1143. 	}
1144. 	return(1);
1145. }
1146. 
1147. static int
1148. explum(mdef, mattk)
1149. register struct monst *mdef;
1150. register struct attack *mattk;
1151. {
1152. 	register int tmp = d((int)mattk->damn, (int)mattk->damd);
1153. 
1154. 	You("explode!");
1155. 	switch(mattk->adtyp) {
1156. 	    case AD_BLND:
1157. 		if (haseyes(mdef->data) && mdef->mcansee) {
1158. 		    pline("%s is blinded by your flash of light!", Monnam(mdef));
1159. 		    mdef->mblinded = min((int)mdef->mblinded + tmp, 127);
1160. 		    mdef->mcansee = 0;
1161. 		}
1162. 		break;
1163. 	    case AD_HALU:
1164. 		if (haseyes(mdef->data) && mdef->mcansee) {
1165. 		    pline("%s is affected by your flash of light!",
1166. 			  Monnam(mdef));
1167. 		    mdef->mconf = 1;
1168. 		}
1169. 		break;
1170. 	    case AD_COLD:
1171. 		if (!resists_cold(mdef)) {
1172. 		    pline("%s gets blasted!", Monnam(mdef));
1173. 		    mdef->mhp -= tmp;
1174. 		    if (mdef->mhp <= 0) {
1175. 			 killed(mdef);
1176. 			 return(2);
1177. 		    }
1178. 		} else {
1179. 		    shieldeff(mdef->mx, mdef->my);
1180. 		    if (is_golem(mdef->data))
1181. 			golemeffects(mdef, AD_COLD, tmp);
1182. 		    else
1183. 			pline_The("blast doesn't seem to affect %s.",
1184. 				mon_nam(mdef));
1185. 		}
1186. 		break;
1187. 	    default:
1188. 		break;
1189. 	}
1190. 	return(1);
1191. }
1192. 
1193. static void
1194. start_engulf(mdef)
1195. struct monst *mdef;
1196. {
1197. 	if (!Invisible) {
1198. 		map_location(u.ux, u.uy, TRUE);
1199. 		tmp_at(DISP_ALWAYS, mon_to_glyph(&youmonst));
1200. 		tmp_at(mdef->mx, mdef->my);
1201. 	}
1202. 	You("engulf %s!", mon_nam(mdef));
1203. 	delay_output();
1204. 	delay_output();
1205. }
1206. 
1207. static void
1208. end_engulf()
1209. {
1210. 	if (!Invisible) {
1211. 		tmp_at(DISP_END, 0);
1212. 		newsym(u.ux, u.uy);
1213. 	}
1214. }
1215. 
1216. static int
1217. gulpum(mdef,mattk)
1218. register struct monst *mdef;
1219. register struct attack *mattk;
1220. {
1221. 	register int tmp;
1222. 	register int dam = d((int)mattk->damn, (int)mattk->damd);
1223. 	struct obj *otmp;
1224. 	/* Not totally the same as for real monsters.  Specifically, these
1225. 	 * don't take multiple moves.  (It's just too hard, for too little
1226. 	 * result, to program monsters which attack from inside you, which
1227. 	 * would be necessary if done accurately.)  Instead, we arbitrarily
1228. 	 * kill the monster immediately for AD_DGST and we regurgitate them
1229. 	 * after exactly 1 round of attack otherwise.  -KAA
1230. 	 */
1231. 
1232. 	if(mdef->data->msize >= MZ_HUGE) return 0;
1233. 
1234. 	if(u.uhunger < 1500 && !u.uswallow) {
1235. 	    for (otmp = mdef->minvent; otmp; otmp = otmp->nobj)
1236. 		(void) snuff_lit(otmp);
1237. 
1238. 	    if(mdef->data->mlet != S_COCKATRICE || resists_ston(&youmonst)) {
1239. #ifdef LINT	/* static char msgbuf[BUFSZ]; */
1240. 		char msgbuf[BUFSZ];
1241. #else
1242. 		static char msgbuf[BUFSZ];
1243. #endif
1244. 		start_engulf(mdef);
1245. 		switch(mattk->adtyp) {
1246. 		    case AD_DGST:
1247. 			/* eating a Rider or its corpse is fatal */
1248. 			if (is_rider(mdef->data)) {
1249. 			 pline("Unfortunately, digesting any of it is fatal.");
1250. 			    end_engulf();
1251. 			    Sprintf(msgbuf, "unwisely tried to eat %s",
1252. 				    mdef->data->mname);
1253. 			    killer = msgbuf;
1254. 			    killer_format = NO_KILLER_PREFIX;
1255. 			    done(DIED);
1256. 			    return 0;		/* lifesaved */
1257. 			}
1258. 			u.uhunger += mdef->data->cnutrit;
1259. 			newuhs(FALSE);
1260. 			xkilled(mdef,2);
1261. 			Sprintf(msgbuf, "You totally digest %s.",
1262. 					mon_nam(mdef));
1263. 			if ((tmp = 3 + (mdef->data->cwt >> 6)) != 0) {
1264. 			    /* setting afternmv = end_engulf is tempting,
1265. 			     * but will cause problems if the player is
1266. 			     * attacked (which uses his real location) or
1267. 			     * if his See_invisible wears off
1268. 			     */
1269. 			    You("digest %s.", mon_nam(mdef));
1270. 			    nomul(-tmp);
1271. 			    nomovemsg = msgbuf;
1272. 			} else pline(msgbuf);
1273. 			end_engulf();
1274. 			exercise(A_CON, TRUE);
1275. 			return(2);
1276. 		    case AD_PHYS:
1277. 			pline("%s is pummeled with your debris!",Monnam(mdef));
1278. 			break;
1279. 		    case AD_ACID:
1280. 			pline("%s is covered with your goo!", Monnam(mdef));
1281. 			if (resists_acid(mdef)) {
1282. 			    pline("It seems harmless to %s.", mon_nam(mdef));
1283. 			    dam = 0;
1284. 			}
1285. 			break;
1286. 		    case AD_BLND:
1287. 			if(haseyes(mdef->data)) {
1288. 			    if (mdef->mcansee)
1289. 				pline("%s can't see in there!", Monnam(mdef));
1290. 			    mdef->mcansee = 0;
1291. 			    dam += mdef->mblinded;
1292. 			    if (dam > 127) dam = 127;
1293. 			    mdef->mblinded = dam;
1294. 			}
1295. 			dam = 0;
1296. 			break;
1297. 		    case AD_ELEC:
1298. 			if (rn2(2)) {
1299. 			    pline_The("air around %s crackles with electricity.", mon_nam(mdef));
1300. 			    if (resists_elec(mdef)) {
1301. 				pline("%s seems unhurt.", Monnam(mdef));
1302. 				dam = 0;
1303. 			    }
1304. 			    golemeffects(mdef,(int)mattk->adtyp,dam);
1305. 			} else dam = 0;
1306. 			break;
1307. 		    case AD_COLD:
1308. 			if (rn2(2)) {
1309. 			    if (resists_cold(mdef)) {
1310. 				pline("%s seems mildly chilly.", Monnam(mdef));
1311. 				dam = 0;
1312. 			    } else
1313. 				pline("%s is freezing to death!",Monnam(mdef));
1314. 			    golemeffects(mdef,(int)mattk->adtyp,dam);
1315. 			} else dam = 0;
1316. 			break;
1317. 		    case AD_FIRE:
1318. 			if (rn2(2)) {
1319. 			    if (resists_fire(mdef)) {
1320. 				pline("%s seems mildly hot.", Monnam(mdef));
1321. 				dam = 0;
1322. 			    } else
1323. 				pline("%s is burning to a crisp!",Monnam(mdef));
1324. 			    golemeffects(mdef,(int)mattk->adtyp,dam);
1325. 			} else dam = 0;
1326. 			break;
1327. 		}
1328. 		end_engulf();
1329. 		if ((mdef->mhp -= dam) <= 0) {
1330. 		    killed(mdef);
1331. 		    return(2);
1332. 		}
1333. 		You("%s %s!", is_animal(uasmon) ? "regurgitate"
1334. 			: "expel", mon_nam(mdef));
1335. 		if (is_animal(uasmon)) {
1336. 		    pline("Obviously, you didn't like %s taste.",
1337. 			  s_suffix(mon_nam(mdef)));
1338. 		}
1339. 	    } else {
1340. 		You("bite into %s", mon_nam(mdef));
1341. 		You("turn to stone...");
1342. 		killer_format = KILLED_BY;
1343. 		killer = "swallowing a cockatrice whole";
1344. 		done(STONING);
1345. 	    }
1346. 	}
1347. 	return(0);
1348. }
1349. 
1350. void
1351. missum(mdef,mattk)
1352. register struct monst *mdef;
1353. register struct attack *mattk;
1354. {
1355. 	if (could_seduce(&youmonst, mdef, mattk))
1356. 		You("pretend to be friendly to %s.", mon_nam(mdef));
1357. 	else if(canspotmon(mdef) && flags.verbose)
1358. 		You("miss %s.", mon_nam(mdef));
1359. 	else
1360. 		You("miss it.");
1361. 	if(!mdef->msleep && mdef->mcanmove)
1362. 		wakeup(mdef);
1363. }
1364. 
1365. static boolean
1366. hmonas(mon, tmp)		/* attack monster as a monster. */
1367. register struct monst *mon;
1368. register int tmp;
1369. {
1370. 	register struct attack *mattk;
1371. 	int	i, sum[NATTK];
1372. 	int	nsum = 0;
1373. 	int	dhit = 0;
1374. 
1375. 	for(i = 0; i < NATTK; i++) {
1376. 
1377. 	    sum[i] = 0;
1378. 	    mattk = &(uasmon->mattk[i]);
1379. 	    switch(mattk->aatyp) {
1380. 		case AT_WEAP:
1381. use_weapon:
1382. 	/* Certain monsters don't use weapons when encountered as enemies,
1383. 	 * but players who polymorph into them have hands or claws and thus
1384. 	 * should be able to use weapons.  This shouldn't prohibit the use
1385. 	 * of most special abilities, either.
1386. 	 */
1387. 	/* Potential problem: if the monster gets multiple weapon attacks,
1388. 	 * we currently allow the player to get each of these as a weapon
1389. 	 * attack.  Is this really desirable?
1390. 	 */
1391. 			if(uwep) tmp += hitval(uwep, mon);
1392. 			dhit = (tmp > (dieroll = rnd(20)) || u.uswallow);
1393. 			/* Enemy dead, before any special abilities used */
1394. 			if (!known_hitum(mon,&dhit,mattk)) return 0;
1395. 			/* might be a worm that gets cut in half */
1396. 			if (m_at(u.ux+u.dx, u.uy+u.dy) != mon) return((boolean)(nsum != 0));
1397. 			/* Do not print "You hit" message, since known_hitum
1398. 			 * already did it.
1399. 			 */
1400. 			if (dhit && mattk->adtyp != AD_SPEL
1401. 				&& mattk->adtyp != AD_PHYS)
1402. 				sum[i] = damageum(mon,mattk);
1403. 			break;
1404. 		case AT_CLAW:
1405. 			if (i==0 && uwep && !cantwield(uasmon)) goto use_weapon;
1406. #ifdef SEDUCE
1407. 			/* succubi/incubi are humanoid, but their _second_
1408. 			 * attack is AT_CLAW, not their first...
1409. 			 */
1410. 			if (i==1 && uwep && (u.umonnum == PM_SUCCUBUS ||
1411. 				u.umonnum == PM_INCUBUS)) goto use_weapon;
1412. #endif
1413. 		case AT_KICK:
1414. 		case AT_BITE:
1415. 		case AT_STNG:
1416. 		case AT_TUCH:
1417. 		case AT_BUTT:
1418. 		case AT_TENT:
1419. 			if (i==0 && uwep && (u.usym==S_LICH)) goto use_weapon;
1420. 			if ((dhit = (tmp > rnd(20) || u.uswallow)) != 0) {
1421. 			    int compat;
1422. 
1423. 			    if (!u.uswallow &&
1424. 				(compat=could_seduce(&youmonst, mon, mattk))) {
1425. 				You("%s %s %s.",
1426. 				    mon->mcansee && haseyes(mon->data)
1427. 				    ? "smile at" : "talk to",
1428. 				    mon_nam(mon),
1429. 				    compat == 2 ? "engagingly":"seductively");
1430. 				/* doesn't anger it; no wakeup() */
1431. 				sum[i] = damageum(mon, mattk);
1432. 				break;
1433. 			    }
1434. 			    wakeup(mon);
1435. 			    if (mon->data == &mons[PM_SHADE]) {
1436. 				Your("attack passes harmlessly through %s.",
1437. 				    mon_nam(mon));
1438. 				break;
1439. 			    }
1440. 			    if (mattk->aatyp == AT_KICK)
1441. 				    You("kick %s.", mon_nam(mon));
1442. 			    else if (mattk->aatyp == AT_BITE)
1443. 				    You("bite %s.", mon_nam(mon));
1444. 			    else if (mattk->aatyp == AT_STNG)
1445. 				    You("sting %s.", mon_nam(mon));
1446. 			    else if (mattk->aatyp == AT_BUTT)
1447. 				    You("butt %s.", mon_nam(mon));
1448. 			    else if (mattk->aatyp == AT_TUCH)
1449. 				    You("touch %s.", mon_nam(mon));
1450. 			    else if (mattk->aatyp == AT_TENT)
1451. 				    Your("tentacles suck %s.", mon_nam(mon));
1452. 			    else You("hit %s.", mon_nam(mon));
1453. 			    sum[i] = damageum(mon, mattk);
1454. 			} else
1455. 			    missum(mon, mattk);
1456. 			break;
1457. 
1458. 		case AT_HUGS:
1459. 			/* automatic if prev two attacks succeed, or if
1460. 			 * already grabbed in a previous attack
1461. 			 */
1462. 			dhit = 1;
1463. 			wakeup(mon);
1464. 			if (mon->data == &mons[PM_SHADE])
1465. 			    Your("hug passes harmlessly through %s.",
1466. 				mon_nam(mon));
1467. 			else if (!sticks(mon->data) && !u.uswallow)
1468. 			    if (mon==u.ustuck) {
1469. 				pline("%s is being %s.", Monnam(mon),
1470. 				    u.umonnum==PM_ROPE_GOLEM ? "choked":
1471. 				    "crushed");
1472. 				sum[i] = damageum(mon, mattk);
1473. 			    } else if(i >= 2 && sum[i-1] && sum[i-2]) {
1474. 				You("grab %s!", mon_nam(mon));
1475. 				u.ustuck = mon;
1476. 				sum[i] = damageum(mon, mattk);
1477. 			    }
1478. 			break;
1479. 
1480. 		case AT_EXPL:	/* automatic hit if next to */
1481. 			dhit = -1;
1482. 			wakeup(mon);
1483. 			sum[i] = explum(mon, mattk);
1484. 			break;
1485. 
1486. 		case AT_ENGL:
1487. 			if((dhit = (tmp > rnd(20+i)))) {
1488. 				wakeup(mon);
1489. 				if (mon->data == &mons[PM_SHADE])
1490. 				    Your("attempt to surround %s is harmless.",
1491. 					mon_nam(mon));
1492. 				else
1493. 				    sum[i]= gulpum(mon,mattk);
1494. 			} else
1495. 				missum(mon, mattk);
1496. 			break;
1497. 
1498. 		case AT_MAGC:
1499. 			/* No check for uwep; if wielding nothing we want to
1500. 			 * do the normal 1-2 points bare hand damage...
1501. 			 */
1502. 			if (i==0 && (u.usym==S_KOBOLD
1503. 				|| u.usym==S_ORC
1504. 				|| u.usym==S_GNOME
1505. 				)) goto use_weapon;
1506. 
1507. 		case AT_NONE:
1508. 			continue;
1509. 			/* Not break--avoid passive attacks from enemy */
1510. 
1511. 		case AT_BREA:
1512. 		case AT_SPIT:
1513. 		case AT_GAZE:	/* all done using #monster command */
1514. 			dhit = 0;
1515. 			break;
1516. 
1517. 		default: /* Strange... */
1518. 			impossible("strange attack of yours (%d)",
1519. 				 mattk->aatyp);
1520. 	    }
1521. 	    if (dhit == -1)
1522. 		rehumanize();
1523. 	    if (sum[i] == 2)
1524. 		return((boolean)passive(mon, 1, 0, (mattk->aatyp == AT_KICK)));
1525. 							/* defender dead */
1526. 	    else {
1527. 		(void) passive(mon, sum[i], 1, (mattk->aatyp==AT_KICK));
1528. 		nsum |= sum[i];
1529. 	    }
1530. 	    if (uasmon == &playermon)
1531. 		break; /* No extra attacks if no longer a monster */
1532. 	    if (multi < 0)
1533. 		break; /* If paralyzed while attacking, i.e. floating eye */
1534. 	}
1535. 	return((boolean)(nsum != 0));
1536. }
1537. 
1538. /*	Special (passive) attacks on you by monsters done here.		*/
1539. 
1540. int
1541. passive(mon, mhit, malive, kicked)
1542. register struct monst *mon;
1543. register boolean mhit;
1544. register int malive;
1545. boolean kicked;
1546. {
1547. 	register struct permonst *ptr = mon->data;
1548. 	register int i, tmp;
1549. 
1550. 	for(i = 0; ; i++) {
1551. 	    if(i >= NATTK) return(malive | mhit);	/* no passive attacks */
1552. 	    if(ptr->mattk[i].aatyp == AT_NONE) break;	/* try this one */
1553. 	}
1554. 	/* Note: tmp not always used */
1555. 	if (ptr->mattk[i].damn)
1556. 	    tmp = d((int)ptr->mattk[i].damn, (int)ptr->mattk[i].damd);
1557. 	else if(ptr->mattk[i].damd)
1558. 	    tmp = d((int)mon->m_lev+1, (int)ptr->mattk[i].damd);
1559. 	else
1560. 	    tmp = 0;
1561. 
1562. /*	These affect you even if they just died */
1563. 
1564. 	switch(ptr->mattk[i].adtyp) {
1565. 
1566. 	  case AD_ACID:
1567. 	    if(mhit && rn2(2)) {
1568. 		if (Blind || !flags.verbose) You("are splashed!");
1569. 		else	You("are splashed by %s acid!",
1570. 			                s_suffix(mon_nam(mon)));
1571. 
1572. 		if (!resists_acid(&youmonst))
1573. 			mdamageu(mon, tmp);
1574. 		if(!rn2(30)) erode_armor(TRUE);
1575. 	    }
1576. 	    if(mhit && !rn2(6)) {
1577. 		if (kicked) {
1578. 		    if (uarmf)
1579. 			(void) rust_dmg(uarmf, xname(uarmf), 3, TRUE);
1580. 		} else erode_weapon(TRUE);
1581. 	    }
1582. 	    exercise(A_STR, FALSE);
1583. 	    break;
1584. 	  case AD_STON:
1585. 	    if(mhit)
1586. 	      if ((kicked && !uarmf) || (!kicked && !uwep && !uarmg)) {
1587. 		if (!resists_ston(&youmonst) &&
1588. 		    !(poly_when_stoned(uasmon) && polymon(PM_STONE_GOLEM))) {
1589. 			You("turn to stone...");
1590. 			done_in_by(mon);
1591. 			return 2;
1592. 		}
1593. 	      }
1594. 	    break;
1595. 	  case AD_RUST:
1596. 	    if(mhit && !mon->mcan)
1597. 	      if (kicked) {
1598. 		if (uarmf)
1599. 		    (void) rust_dmg(uarmf, xname(uarmf), 1, TRUE);
1600. 	      } else
1601. 		erode_weapon(FALSE);
1602. 	    break;
1603. 	  case AD_MAGM:
1604. 	    /* wrath of gods for attacking Oracle */
1605. 	    if(Antimagic) {
1606. 		shieldeff(u.ux, u.uy);
1607. 		pline("A hail of magic missiles narrowly misses you!");
1608. 	    } else {
1609. 		You("are hit by magic missiles appearing from thin air!");
1610. 		mdamageu(mon, tmp);
1611. 	    }
1612. 	    break;
1613. 	  default:
1614. 	    break;
1615. 	}
1616. 
1617. /*	These only affect you if they still live */
1618. 
1619. 	if(malive && !mon->mcan && rn2(3)) {
1620. 
1621. 	    switch(ptr->mattk[i].adtyp) {
1622. 
1623. 	      case AD_PLYS:
1624. 		if(ptr == &mons[PM_FLOATING_EYE]) {
1625. 		    if (!canseemon(mon)) {
1626. 			break;
1627. 		    }
1628. 		    if(mon->mcansee) {
1629. 			if(Reflecting & W_AMUL) {
1630. 			    makeknown(AMULET_OF_REFLECTION);
1631. 			    pline("%s gaze is reflected by your medallion.",
1632. 				  s_suffix(Monnam(mon)));
1633. 			} else if(Reflecting & W_ARMS) {
1634. 			    makeknown(SHIELD_OF_REFLECTION);
1635. 			    pline("%s gaze is reflected by your shield.",
1636. 				  s_suffix(Monnam(mon)));
1637. 			} else {
1638. 			    You("are frozen by %s gaze!",
1639. 				  s_suffix(mon_nam(mon)));
1640. 			    nomul((ACURR(A_WIS) > 12 || rn2(4)) ? -tmp : -127);
1641. 			}
1642. 		    } else {
1643. 			pline("%s cannot defend itself.",
1644. 				Adjmonnam(mon,"blind"));
1645. 			if(!rn2(500)) change_luck(-1);
1646. 		    }
1647. 		} else { /* gelatinous cube */
1648. 		    You("are frozen by %s!", mon_nam(mon));
1649. 		    nomul(-tmp);
1650. 		    exercise(A_DEX, FALSE);
1651. 		}
1652. 		break;
1653. 	      case AD_COLD:		/* brown mold or blue jelly */
1654. 		if(monnear(mon, u.ux, u.uy)) {
1655. 		    if(Cold_resistance) {
1656. 			shieldeff(u.ux, u.uy);
1657. 			You_feel("a mild chill.");
1658. 			ugolemeffects(AD_COLD, tmp);
1659. 			break;
1660. 		    }
1661. 		    You("are suddenly very cold!");
1662. 		    mdamageu(mon, tmp);
1663. 		/* monster gets stronger with your heat! */
1664. 		    mon->mhp += tmp / 2;
1665. 		    if (mon->mhpmax < mon->mhp) mon->mhpmax = mon->mhp;
1666. 		/* at a certain point, the monster will reproduce! */
1667. 		    if(mon->mhpmax > ((int) (mon->m_lev+1) * 8)) {
1668. 			register struct monst *mtmp;
1669. 
1670. 			if ((mtmp = clone_mon(mon)) != 0) {
1671. 			    mtmp->mhpmax = mon->mhpmax /= 2;
1672. 			    if(!Blind)
1673. 				pline("%s multiplies from your heat!",
1674. 								Monnam(mon));
1675. 			}
1676. 		    }
1677. 		}
1678. 		break;
1679. 	      case AD_STUN:		/* specifically yellow mold */
1680. 		if(!Stunned)
1681. 		    make_stunned((long)tmp, TRUE);
1682. 		break;
1683. 	      case AD_FIRE:
1684. 		if(monnear(mon, u.ux, u.uy)) {
1685. 		    if(Fire_resistance) {
1686. 			shieldeff(u.ux, u.uy);
1687. 			You_feel("mildly warm.");
1688. 			ugolemeffects(AD_FIRE, tmp);
1689. 			break;
1690. 		    }
1691. 		    You("are suddenly very hot!");
1692. 		    mdamageu(mon, tmp);
1693. 		}
1694. 		break;
1695. 	      case AD_ELEC:
1696. 		if(Shock_resistance) {
1697. 		    shieldeff(u.ux, u.uy);
1698. 		    You_feel("a mild tingle.");
1699. 		    ugolemeffects(AD_ELEC, tmp);
1700. 		    break;
1701. 		}
1702. 		You("are jolted with electricity!");
1703. 		mdamageu(mon, tmp);
1704. 		break;
1705. 	      default:
1706. 		break;
1707. 	    }
1708. 	}
1709. 	return(malive | mhit);
1710. }
1711. 
1712. /* Note: caller must ascertain mtmp is mimicing... */
1713. void
1714. stumble_onto_mimic(mtmp)
1715. register struct monst *mtmp;
1716. {
1717. 	if(!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data,AD_STCK))
1718. 	    u.ustuck = mtmp;
1719. 	if (Blind) {
1720. 	    if(!Telepat)
1721. 		pline("Wait!  That's a monster!");
1722. 	} else if (glyph_is_cmap(levl[u.ux+u.dx][u.uy+u.dy].glyph) &&
1723. 		(glyph_to_cmap(levl[u.ux+u.dx][u.uy+u.dy].glyph) == S_hcdoor ||
1724. 		 glyph_to_cmap(levl[u.ux+u.dx][u.uy+u.dy].glyph) == S_vcdoor))
1725. 	    pline_The("door actually was %s!", a_monnam(mtmp));
1726. 	else if (glyph_is_object(levl[u.ux+u.dx][u.uy+u.dy].glyph) &&
1727. 		glyph_to_obj(levl[u.ux+u.dx][u.uy+u.dy].glyph) == GOLD_PIECE)
1728. 	    pline("That gold was %s!", a_monnam(mtmp));
1729. 	else {
1730. 	    pline("Wait!  That's %s!", a_monnam(mtmp));
1731. 	}
1732. 
1733. 	wakeup(mtmp);	/* clears mimicing */
1734. }
1735. 
1736. static void
1737. nohandglow(mon)
1738. struct monst *mon;
1739. {
1740. 	char *hands=makeplural(body_part(HAND));
1741. 
1742. 	if (!u.umconf || mon->mconf) return;
1743. 	if (u.umconf == 1) {
1744. 		if (Blind)
1745. 			Your("%s stop tingling.", hands);
1746. 		else
1747. 			Your("%s stop glowing %s.", hands, hcolor(red));
1748. 	} else {
1749. 		if (Blind)
1750. 			pline_The("tingling in your %s lessens.", hands);
1751. 		else
1752. 			Your("%s no longer glow so brightly %s.", hands,
1753. 				hcolor(red));
1754. 	}
1755. 	u.umconf--;
1756. }
1757. 
1758. int flash_hits_mon(mtmp, otmp)
1759. struct monst *mtmp;
1760. struct obj *otmp;	/* source of flash */
1761. {
1762. 	int tmp, amt, res = 0, useeit = canseemon(mtmp);
1763. 
1764. 	if (mtmp->msleep) {
1765. 	    mtmp->msleep = 0;
1766. 	    if (useeit) {
1767. 		pline_The("flash awakens %s.", mon_nam(mtmp));
1768. 		res = 1;
1769. 	    }
1770. 	} else if (mtmp->data->mlet != S_LIGHT) {
1771. 	    if (mtmp->mcansee && haseyes(mtmp->data)) {
1772. 		tmp = dist2(otmp->ox, otmp->oy, mtmp->mx, mtmp->my);
1773. 		if (useeit) {
1774. 		    pline("%s is blinded by the flash!", Monnam(mtmp));
1775. 		    res = 1;
1776. 		}
1777. 		if (mtmp->data == &mons[PM_GREMLIN]) {
1778. 		    /* Rule #1: Keep them out of the light. */
1779. 		    amt = otmp->otyp == WAN_LIGHT ? d(1 + otmp->spe, 4) :
1780. 		          rn2(min(mtmp->mhp,4));
1781. 		    pline("%s %s!", Monnam(mtmp), amt > mtmp->mhp / 2 ?
1782. 			  "wails in agony" : "cries out in pain");
1783. 		    if ((mtmp->mhp -= amt) <= 0) {
1784. 			if (flags.mon_moving)
1785. 			    monkilled(mtmp, (char *)0, AD_BLND);
1786. 			else
1787. 			    killed(mtmp);
1788. 		    }
1789. 		}
1790. 		if (mtmp->mhp > 0) {
1791. 		    if (!flags.mon_moving) setmangry(mtmp);
1792. 		    if (tmp < 9 && !mtmp->isshk && rn2(4)) {
1793. 			mtmp->mflee = 1;
1794. 			if (rn2(4)) mtmp->mfleetim = rnd(100);
1795. 		    }
1796. 		    mtmp->mcansee = 0;
1797. 		    mtmp->mblinded = (tmp < 3) ? 0 : rnd(1 + 50/tmp);
1798. 		}
1799. 	    }
1800. 	}
1801. 	return res;
1802. }
1803. 
1804. /*uhitm.c*/

Also on Fandom

Random Wiki