Source:NetHack 3.6.5/src/dokick.c

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to dokick.c from the source code of NetHack 3.6.5. To link to a particular line, write [[Source:NetHack 3.6.5/src/dokick.c#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1. /* NetHack 3.6	dokick.c	$NHDT-Date: 1575245057 2019/12/02 00:04:17 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.136 $ */
2. /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
3. /* NetHack may be freely redistributed.  See license for details. */
4. 
5. #include "hack.h"
6. 
7. #define is_bigfoot(x) ((x) == &mons[PM_SASQUATCH])
8. #define martial()                                 \
9.     (martial_bonus() || is_bigfoot(youmonst.data) \
10.      || (uarmf && uarmf->otyp == KICKING_BOOTS))
11. 
12. static NEARDATA struct rm *maploc, nowhere;
13. static NEARDATA const char *gate_str;
14. 
15. /* kickedobj (decl.c) tracks a kicked object until placed or destroyed */
16. 
17. extern boolean notonhead; /* for long worms */
18. 
19. STATIC_DCL void FDECL(kickdmg, (struct monst *, BOOLEAN_P));
20. STATIC_DCL boolean FDECL(maybe_kick_monster, (struct monst *,
21.                                               XCHAR_P, XCHAR_P));
22. STATIC_DCL void FDECL(kick_monster, (struct monst *, XCHAR_P, XCHAR_P));
23. STATIC_DCL int FDECL(kick_object, (XCHAR_P, XCHAR_P, char *));
24. STATIC_DCL int FDECL(really_kick_object, (XCHAR_P, XCHAR_P));
25. STATIC_DCL char *FDECL(kickstr, (char *, const char *));
26. STATIC_DCL void FDECL(otransit_msg, (struct obj *, BOOLEAN_P, long));
27. STATIC_DCL void FDECL(drop_to, (coord *, SCHAR_P));
28. 
29. static const char kick_passes_thru[] = "kick passes harmlessly through";
30. 
31. /* kicking damage when not poly'd into a form with a kick attack */
32. STATIC_OVL void
33. kickdmg(mon, clumsy)
34. struct monst *mon;
35. boolean clumsy;
36. {
37.     int mdx, mdy;
38.     int dmg = (ACURRSTR + ACURR(A_DEX) + ACURR(A_CON)) / 15;
39.     int specialdmg, kick_skill = P_NONE;
40.     boolean trapkilled = FALSE;
41. 
42.     if (uarmf && uarmf->otyp == KICKING_BOOTS)
43.         dmg += 5;
44. 
45.     /* excessive wt affects dex, so it affects dmg */
46.     if (clumsy)
47.         dmg /= 2;
48. 
49.     /* kicking a dragon or an elephant will not harm it */
50.     if (thick_skinned(mon->data))
51.         dmg = 0;
52. 
53.     /* attacking a shade is normally useless */
54.     if (mon->data == &mons[PM_SHADE])
55.         dmg = 0;
56. 
57.     specialdmg = special_dmgval(&youmonst, mon, W_ARMF, (long *) 0);
58. 
59.     if (mon->data == &mons[PM_SHADE] && !specialdmg) {
60.         pline_The("%s.", kick_passes_thru);
61.         /* doesn't exercise skill or abuse alignment or frighten pet,
62.            and shades have no passive counterattack */
63.         return;
64.     }
65. 
66.     if (M_AP_TYPE(mon))
67.         seemimic(mon);
68. 
69.     check_caitiff(mon);
70. 
71.     /* squeeze some guilt feelings... */
72.     if (mon->mtame) {
73.         abuse_dog(mon);
74.         if (mon->mtame)
75.             monflee(mon, (dmg ? rnd(dmg) : 1), FALSE, FALSE);
76.         else
77.             mon->mflee = 0;
78.     }
79. 
80.     if (dmg > 0) {
81.         /* convert potential damage to actual damage */
82.         dmg = rnd(dmg);
83.         if (martial()) {
84.             if (dmg > 1)
85.                 kick_skill = P_MARTIAL_ARTS;
86.             dmg += rn2(ACURR(A_DEX) / 2 + 1);
87.         }
88.         /* a good kick exercises your dex */
89.         exercise(A_DEX, TRUE);
90.     }
91.     dmg += specialdmg; /* for blessed (or hypothetically, silver) boots */
92.     if (uarmf)
93.         dmg += uarmf->spe;
94.     dmg += u.udaminc; /* add ring(s) of increase damage */
95.     if (dmg > 0)
96.         mon->mhp -= dmg;
97.     if (!DEADMONSTER(mon) && martial() && !bigmonst(mon->data) && !rn2(3)
98.         && mon->mcanmove && mon != u.ustuck && !mon->mtrapped) {
99.         /* see if the monster has a place to move into */
100.         mdx = mon->mx + u.dx;
101.         mdy = mon->my + u.dy;
102.         if (goodpos(mdx, mdy, mon, 0)) {
103.             pline("%s reels from the blow.", Monnam(mon));
104.             if (m_in_out_region(mon, mdx, mdy)) {
105.                 remove_monster(mon->mx, mon->my);
106.                 newsym(mon->mx, mon->my);
107.                 place_monster(mon, mdx, mdy);
108.                 newsym(mon->mx, mon->my);
109.                 set_apparxy(mon);
110.                 if (mintrap(mon) == 2)
111.                     trapkilled = TRUE;
112.             }
113.         }
114.     }
115. 
116.     (void) passive(mon, uarmf, TRUE, !DEADMONSTER(mon), AT_KICK, FALSE);
117.     if (DEADMONSTER(mon) && !trapkilled)
118.         killed(mon);
119. 
120.     /* may bring up a dialog, so put this after all messages */
121.     if (kick_skill != P_NONE) /* exercise proficiency */
122.         use_skill(kick_skill, 1);
123. }
124. 
125. STATIC_OVL boolean
126. maybe_kick_monster(mon, x, y)
127. struct monst *mon;
128. xchar x, y;
129. {
130.     if (mon) {
131.         boolean save_forcefight = context.forcefight;
132. 
133.         bhitpos.x = x;
134.         bhitpos.y = y;
135.         if (!mon->mpeaceful || !canspotmon(mon))
136.             context.forcefight = TRUE; /* attack even if invisible */
137.         /* kicking might be halted by discovery of hidden monster,
138.            by player declining to attack peaceful monster,
139.            or by passing out due to encumbrance */
140.         if (attack_checks(mon, (struct obj *) 0) || overexertion())
141.             mon = 0; /* don't kick after all */
142.         context.forcefight = save_forcefight;
143.     }
144.     return (boolean) (mon != 0);
145. }
146. 
147. STATIC_OVL void
148. kick_monster(mon, x, y)
149. struct monst *mon;
150. xchar x, y;
151. {
152.     boolean clumsy = FALSE;
153.     int i, j;
154. 
155.     /* anger target even if wild miss will occur */
156.     setmangry(mon, TRUE);
157. 
158.     if (Levitation && !rn2(3) && verysmall(mon->data)
159.         && !is_flyer(mon->data)) {
160.         pline("Floating in the air, you miss wildly!");
161.         exercise(A_DEX, FALSE);
162.         (void) passive(mon, uarmf, FALSE, 1, AT_KICK, FALSE);
163.         return;
164.     }
165. 
166.     /* reveal hidden target even if kick ends up missing (note: being
167.        hidden doesn't affect chance to hit so neither does this reveal) */
168.     if (mon->mundetected
169.         || (M_AP_TYPE(mon) && M_AP_TYPE(mon) != M_AP_MONSTER)) {
170.         if (M_AP_TYPE(mon))
171.             seemimic(mon);
172.         mon->mundetected = 0;
173.         if (!canspotmon(mon))
174.             map_invisible(x, y);
175.         else
176.             newsym(x, y);
177.         There("is %s here.",
178.               canspotmon(mon) ? a_monnam(mon) : "something hidden");
179.     }
180. 
181.     /* Kick attacks by kicking monsters are normal attacks, not special.
182.      * This is almost always worthless, since you can either take one turn
183.      * and do all your kicks, or else take one turn and attack the monster
184.      * normally, getting all your attacks _including_ all your kicks.
185.      * If you have >1 kick attack, you get all of them.
186.      */
187.     if (Upolyd && attacktype(youmonst.data, AT_KICK)) {
188.         struct attack *uattk;
189.         int sum, kickdieroll, armorpenalty, specialdmg,
190.             attknum = 0,
191.             tmp = find_roll_to_hit(mon, AT_KICK, (struct obj *) 0, &attknum,
192.                                    &armorpenalty);
193. 
194.         for (i = 0; i < NATTK; i++) {
195.             /* first of two kicks might have provoked counterattack
196.                that has incapacitated the hero (ie, floating eye) */
197.             if (multi < 0)
198.                 break;
199. 
200.             uattk = &youmonst.data->mattk[i];
201.             /* we only care about kicking attacks here */
202.             if (uattk->aatyp != AT_KICK)
203.                 continue;
204. 
205.             kickdieroll = rnd(20);
206.             specialdmg = special_dmgval(&youmonst, mon, W_ARMF, (long *) 0);
207.             if (mon->data == &mons[PM_SHADE] && !specialdmg) {
208.                 /* doesn't matter whether it would have hit or missed,
209.                    and shades have no passive counterattack */
210.                 Your("%s %s.", kick_passes_thru, mon_nam(mon));
211.                 break; /* skip any additional kicks */
212.             } else if (tmp > kickdieroll) {
213.                 You("kick %s.", mon_nam(mon));
214.                 sum = damageum(mon, uattk, specialdmg);
215.                 (void) passive(mon, uarmf, (boolean) (sum > 0),
216.                                (sum != 2), AT_KICK, FALSE);
217.                 if (sum == 2)
218.                     break; /* Defender died */
219.             } else {
220.                 missum(mon, uattk, (tmp + armorpenalty > kickdieroll));
221.                 (void) passive(mon, uarmf, FALSE, 1, AT_KICK, FALSE);
222.             }
223.         }
224.         return;
225.     }
226. 
227.     i = -inv_weight();
228.     j = weight_cap();
229. 
230.     if (i < (j * 3) / 10) {
231.         if (!rn2((i < j / 10) ? 2 : (i < j / 5) ? 3 : 4)) {
232.             if (martial() && !rn2(2))
233.                 goto doit;
234.             Your("clumsy kick does no damage.");
235.             (void) passive(mon, uarmf, FALSE, 1, AT_KICK, FALSE);
236.             return;
237.         }
238.         if (i < j / 10)
239.             clumsy = TRUE;
240.         else if (!rn2((i < j / 5) ? 2 : 3))
241.             clumsy = TRUE;
242.     }
243. 
244.     if (Fumbling)
245.         clumsy = TRUE;
246. 
247.     else if (uarm && objects[uarm->otyp].oc_bulky && ACURR(A_DEX) < rnd(25))
248.         clumsy = TRUE;
249.  doit:
250.     You("kick %s.", mon_nam(mon));
251.     if (!rn2(clumsy ? 3 : 4) && (clumsy || !bigmonst(mon->data))
252.         && mon->mcansee && !mon->mtrapped && !thick_skinned(mon->data)
253.         && mon->data->mlet != S_EEL && haseyes(mon->data) && mon->mcanmove
254.         && !mon->mstun && !mon->mconf && !mon->msleeping
255.         && mon->data->mmove >= 12) {
256.         if (!nohands(mon->data) && !rn2(martial() ? 5 : 3)) {
257.             pline("%s blocks your %skick.", Monnam(mon),
258.                   clumsy ? "clumsy " : "");
259.             (void) passive(mon, uarmf, FALSE, 1, AT_KICK, FALSE);
260.             return;
261.         } else {
262.             maybe_mnexto(mon);
263.             if (mon->mx != x || mon->my != y) {
264.                 (void) unmap_invisible(x, y);
265.                 pline("%s %s, %s evading your %skick.", Monnam(mon),
266.                       (!level.flags.noteleport && can_teleport(mon->data))
267.                           ? "teleports"
268.                           : is_floater(mon->data)
269.                                 ? "floats"
270.                                 : is_flyer(mon->data) ? "swoops"
271.                                                       : (nolimbs(mon->data)
272.                                                          || slithy(mon->data))
273.                                                             ? "slides"
274.                                                             : "jumps",
275.                       clumsy ? "easily" : "nimbly", clumsy ? "clumsy " : "");
276.                 (void) passive(mon, uarmf, FALSE, 1, AT_KICK, FALSE);
277.                 return;
278.             }
279.         }
280.     }
281.     kickdmg(mon, clumsy);
282. }
283. 
284. /*
285.  *  Return TRUE if caught (the gold taken care of), FALSE otherwise.
286.  *  The gold object is *not* attached to the fobj chain!
287.  */
288. boolean
289. ghitm(mtmp, gold)
290. register struct monst *mtmp;
291. register struct obj *gold;
292. {
293.     boolean msg_given = FALSE;
294. 
295.     if (!likes_gold(mtmp->data) && !mtmp->isshk && !mtmp->ispriest
296.         && !mtmp->isgd && !is_mercenary(mtmp->data)) {
297.         wakeup(mtmp, TRUE);
298.     } else if (!mtmp->mcanmove) {
299.         /* too light to do real damage */
300.         if (canseemon(mtmp)) {
301.             pline_The("%s harmlessly %s %s.", xname(gold),
302.                       otense(gold, "hit"), mon_nam(mtmp));
303.             msg_given = TRUE;
304.         }
305.     } else {
306.         long umoney, value = gold->quan * objects[gold->otyp].oc_cost;
307. 
308.         mtmp->msleeping = 0;
309.         finish_meating(mtmp);
310.         if (!mtmp->isgd && !rn2(4)) /* not always pleasing */
311.             setmangry(mtmp, TRUE);
312.         /* greedy monsters catch gold */
313.         if (cansee(mtmp->mx, mtmp->my))
314.             pline("%s catches the gold.", Monnam(mtmp));
315.         (void) mpickobj(mtmp, gold);
316.         gold = (struct obj *) 0; /* obj has been freed */
317.         if (mtmp->isshk) {
318.             long robbed = ESHK(mtmp)->robbed;
319. 
320.             if (robbed) {
321.                 robbed -= value;
322.                 if (robbed < 0L)
323.                     robbed = 0L;
324.                 pline_The("amount %scovers %s recent losses.",
325.                           !robbed ? "" : "partially ", mhis(mtmp));
326.                 ESHK(mtmp)->robbed = robbed;
327.                 if (!robbed)
328.                     make_happy_shk(mtmp, FALSE);
329.             } else {
330.                 if (mtmp->mpeaceful) {
331.                     ESHK(mtmp)->credit += value;
332.                     You("have %ld %s in credit.", ESHK(mtmp)->credit,
333.                         currency(ESHK(mtmp)->credit));
334.                 } else
335.                     verbalize("Thanks, scum!");
336.             }
337.         } else if (mtmp->ispriest) {
338.             if (mtmp->mpeaceful)
339.                 verbalize("Thank you for your contribution.");
340.             else
341.                 verbalize("Thanks, scum!");
342.         } else if (mtmp->isgd) {
343.             umoney = money_cnt(invent);
344.             /* Some of these are iffy, because a hostile guard
345.                won't become peaceful and resume leading hero
346.                out of the vault.  If he did do that, player
347.                could try fighting, then weasle out of being
348.                killed by throwing his/her gold when losing. */
349.             verbalize(
350.                 umoney
351.                     ? "Drop the rest and follow me."
352.                     : hidden_gold()
353.                           ? "You still have hidden gold.  Drop it now."
354.                           : mtmp->mpeaceful
355.                                 ? "I'll take care of that; please move along."
356.                                 : "I'll take that; now get moving.");
357.         } else if (is_mercenary(mtmp->data)) {
358.             long goldreqd = 0L;
359. 
360.             if (rn2(3)) {
361.                 if (mtmp->data == &mons[PM_SOLDIER])
362.                     goldreqd = 100L;
363.                 else if (mtmp->data == &mons[PM_SERGEANT])
364.                     goldreqd = 250L;
365.                 else if (mtmp->data == &mons[PM_LIEUTENANT])
366.                     goldreqd = 500L;
367.                 else if (mtmp->data == &mons[PM_CAPTAIN])
368.                     goldreqd = 750L;
369. 
370.                 if (goldreqd) {
371.                     umoney = money_cnt(invent);
372.                     if (value
373.                         > goldreqd
374.                               + (umoney + u.ulevel * rn2(5)) / ACURR(A_CHA))
375.                         mtmp->mpeaceful = TRUE;
376.                 }
377.             }
378.             if (mtmp->mpeaceful)
379.                 verbalize("That should do.  Now beat it!");
380.             else
381.                 verbalize("That's not enough, coward!");
382.         }
383.         return TRUE;
384.     }
385. 
386.     if (!msg_given)
387.         miss(xname(gold), mtmp);
388.     return FALSE;
389. }
390. 
391. /* container is kicked, dropped, thrown or otherwise impacted by player.
392.  * Assumes container is on floor.  Checks contents for possible damage. */
393. void
394. container_impact_dmg(obj, x, y)
395. struct obj *obj;
396. xchar x, y; /* coordinates where object was before the impact, not after */
397. {
398.     struct monst *shkp;
399.     struct obj *otmp, *otmp2;
400.     long loss = 0L;
401.     boolean costly, insider, frominv;
402. 
403.     /* only consider normal containers */
404.     if (!Is_container(obj) || !Has_contents(obj) || Is_mbag(obj))
405.         return;
406. 
407.     costly = ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE)))
408.               && costly_spot(x, y));
409.     insider = (*u.ushops && inside_shop(u.ux, u.uy)
410.                && *in_rooms(x, y, SHOPBASE) == *u.ushops);
411.     /* if dropped or thrown, shop ownership flags are set on this obj */
412.     frominv = (obj != kickedobj);
413. 
414.     for (otmp = obj->cobj; otmp; otmp = otmp2) {
415.         const char *result = (char *) 0;
416. 
417.         otmp2 = otmp->nobj;
418.         if (objects[otmp->otyp].oc_material == GLASS
419.             && otmp->oclass != GEM_CLASS && !obj_resists(otmp, 33, 100)) {
420.             result = "shatter";
421.         } else if (otmp->otyp == EGG && !rn2(3)) {
422.             result = "cracking";
423.         }
424.         if (result) {
425.             if (otmp->otyp == MIRROR)
426.                 change_luck(-2);
427. 
428.             /* eggs laid by you.  penalty is -1 per egg, max 5,
429.              * but it's always exactly 1 that breaks */
430.             if (otmp->otyp == EGG && otmp->spe && otmp->corpsenm >= LOW_PM)
431.                 change_luck(-1);
432.             You_hear("a muffled %s.", result);
433.             if (costly) {
434.                 if (frominv && !otmp->unpaid)
435.                     otmp->no_charge = 1;
436.                 loss +=
437.                     stolen_value(otmp, x, y, (boolean) shkp->mpeaceful, TRUE);
438.             }
439.             if (otmp->quan > 1L) {
440.                 useup(otmp);
441.             } else {
442.                 obj_extract_self(otmp);
443.                 obfree(otmp, (struct obj *) 0);
444.             }
445.             /* contents of this container are no longer known */
446.             obj->cknown = 0;
447.         }
448.     }
449.     if (costly && loss) {
450.         if (!insider) {
451.             You("caused %ld %s worth of damage!", loss, currency(loss));
452.             make_angry_shk(shkp, x, y);
453.         } else {
454.             You("owe %s %ld %s for objects destroyed.", mon_nam(shkp), loss,
455.                 currency(loss));
456.         }
457.     }
458. }
459. 
460. /* jacket around really_kick_object */
461. STATIC_OVL int
462. kick_object(x, y, kickobjnam)
463. xchar x, y;
464. char *kickobjnam;
465. {
466.     int res = 0;
467. 
468.     *kickobjnam = '\0';
469.     /* if a pile, the "top" object gets kicked */
470.     kickedobj = level.objects[x][y];
471.     if (kickedobj) {
472.         /* kick object; if doing is fatal, done() will clean up kickedobj */
473.         Strcpy(kickobjnam, killer_xname(kickedobj)); /* matters iff res==0 */
474.         res = really_kick_object(x, y);
475.         kickedobj = (struct obj *) 0;
476.     }
477.     return res;
478. }
479. 
480. /* guts of kick_object */
481. STATIC_OVL int
482. really_kick_object(x, y)
483. xchar x, y;
484. {
485.     int range;
486.     struct monst *mon, *shkp = 0;
487.     struct trap *trap;
488.     char bhitroom;
489.     boolean costly, isgold, slide = FALSE;
490. 
491.     /* kickedobj should always be set due to conditions of call */
492.     if (!kickedobj || kickedobj->otyp == BOULDER || kickedobj == uball
493.         || kickedobj == uchain)
494.         return 0;
495. 
496.     if ((trap = t_at(x, y)) != 0) {
497.         if ((is_pit(trap->ttyp) && !Passes_walls) || trap->ttyp == WEB) {
498.             if (!trap->tseen)
499.                 find_trap(trap);
500.             You_cant("kick %s that's in a %s!", something,
501.                      Hallucination ? "tizzy"
502.                          : (trap->ttyp == WEB) ? "web"
503.                              : "pit");
504.             return 1;
505.         }
506.         if (trap->ttyp == STATUE_TRAP) {
507.             activate_statue_trap(trap, x,y, FALSE);
508.             return 1;
509.         }
510.     }
511. 
512.     if (Fumbling && !rn2(3)) {
513.         Your("clumsy kick missed.");
514.         return 1;
515.     }
516. 
517.     if (!uarmf && kickedobj->otyp == CORPSE
518.         && touch_petrifies(&mons[kickedobj->corpsenm]) && !Stone_resistance) {
519.         You("kick %s with your bare %s.",
520.             corpse_xname(kickedobj, (const char *) 0, CXN_PFX_THE),
521.             makeplural(body_part(FOOT)));
522.         if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM)) {
523.             ; /* hero has been transformed but kick continues */
524.         } else {
525.             /* normalize body shape here; foot, not body_part(FOOT) */
526.             Sprintf(killer.name, "kicking %s barefoot",
527.                     killer_xname(kickedobj));
528.             instapetrify(killer.name);
529.         }
530.     }
531. 
532.     isgold = (kickedobj->oclass == COIN_CLASS);
533.     {
534.         int k_owt = (int) kickedobj->owt;
535. 
536.         /* for non-gold stack, 1 item will be split off below (unless an
537.            early return occurs, so we aren't moving the split to here);
538.            calculate the range for that 1 rather than for the whole stack */
539.         if (kickedobj->quan > 1L && !isgold) {
540.             long save_quan = kickedobj->quan;
541. 
542.             kickedobj->quan = 1L;
543.             k_owt = weight(kickedobj);
544.             kickedobj->quan = save_quan;
545.         }
546. 
547.         /* range < 2 means the object will not move
548.            (maybe dexterity should also figure here) */
549.         range = ((int) ACURRSTR) / 2 - k_owt / 40;
550.     }
551. 
552.     if (martial())
553.         range += rnd(3);
554. 
555.     if (is_pool(x, y)) {
556.         /* you're in the water too; significantly reduce range */
557.         range = range / 3 + 1; /* {1,2}=>1, {3,4,5}=>2, {6,7,8}=>3 */
558.     } else if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) {
559.         /* you're in air, since is_pool did not match */
560.         range += rnd(3);
561.     } else {
562.         if (is_ice(x, y))
563.             range += rnd(3), slide = TRUE;
564.         if (kickedobj->greased)
565.             range += rnd(3), slide = TRUE;
566.     }
567. 
568.     /* Mjollnir is magically too heavy to kick */
569.     if (kickedobj->oartifact == ART_MJOLLNIR)
570.         range = 1;
571. 
572.     /* see if the object has a place to move into */
573.     if (!ZAP_POS(levl[x + u.dx][y + u.dy].typ)
574.         || closed_door(x + u.dx, y + u.dy))
575.         range = 1;
576. 
577.     costly = (!(kickedobj->no_charge && !Has_contents(kickedobj))
578.               && (shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0
579.               && costly_spot(x, y));
580. 
581.     if (IS_ROCK(levl[x][y].typ) || closed_door(x, y)) {
582.         if ((!martial() && rn2(20) > ACURR(A_DEX))
583.             || IS_ROCK(levl[u.ux][u.uy].typ) || closed_door(u.ux, u.uy)) {
584.             if (Blind)
585.                 pline("It doesn't come loose.");
586.             else
587.                 pline("%s %sn't come loose.",
588.                       The(distant_name(kickedobj, xname)),
589.                       otense(kickedobj, "do"));
590.             return (!rn2(3) || martial());
591.         }
592.         if (Blind)
593.             pline("It comes loose.");
594.         else
595.             pline("%s %s loose.", The(distant_name(kickedobj, xname)),
596.                   otense(kickedobj, "come"));
597.         obj_extract_self(kickedobj);
598.         newsym(x, y);
599.         if (costly && (!costly_spot(u.ux, u.uy)
600.                        || !index(u.urooms, *in_rooms(x, y, SHOPBASE))))
601.             addtobill(kickedobj, FALSE, FALSE, FALSE);
602.         if (!flooreffects(kickedobj, u.ux, u.uy, "fall")) {
603.             place_object(kickedobj, u.ux, u.uy);
604.             stackobj(kickedobj);
605.             newsym(u.ux, u.uy);
606.         }
607.         return 1;
608.     }
609. 
610.     /* a box gets a chance of breaking open here */
611.     if (Is_box(kickedobj)) {
612.         boolean otrp = kickedobj->otrapped;
613. 
614.         if (range < 2)
615.             pline("THUD!");
616.         container_impact_dmg(kickedobj, x, y);
617.         if (kickedobj->olocked) {
618.             if (!rn2(5) || (martial() && !rn2(2))) {
619.                 You("break open the lock!");
620.                 breakchestlock(kickedobj, FALSE);
621.                 if (otrp)
622.                     (void) chest_trap(kickedobj, LEG, FALSE);
623.                 return 1;
624.             }
625.         } else {
626.             if (!rn2(3) || (martial() && !rn2(2))) {
627.                 pline_The("lid slams open, then falls shut.");
628.                 kickedobj->lknown = 1;
629.                 if (otrp)
630.                     (void) chest_trap(kickedobj, LEG, FALSE);
631.                 return 1;
632.             }
633.         }
634.         if (range < 2)
635.             return 1;
636.         /* else let it fall through to the next cases... */
637.     }
638. 
639.     /* fragile objects should not be kicked */
640.     if (hero_breaks(kickedobj, kickedobj->ox, kickedobj->oy, FALSE))
641.         return 1;
642. 
643.     /* too heavy to move.  range is calculated as potential distance from
644.      * player, so range == 2 means the object may move up to one square
645.      * from its current position
646.      */
647.     if (range < 2) {
648.         if (!Is_box(kickedobj))
649.             pline("Thump!");
650.         return (!rn2(3) || martial());
651.     }
652. 
653.     if (kickedobj->quan > 1L) {
654.         if (!isgold) {
655.             kickedobj = splitobj(kickedobj, 1L);
656.         } else {
657.             if (rn2(20)) {
658.                 static NEARDATA const char *const flyingcoinmsg[] = {
659.                     "scatter the coins", "knock coins all over the place",
660.                     "send coins flying in all directions",
661.                 };
662. 
663.                 pline("Thwwpingg!");
664.                 You("%s!", flyingcoinmsg[rn2(SIZE(flyingcoinmsg))]);
665.                 (void) scatter(x, y, rn2(3) + 1, VIS_EFFECTS | MAY_HIT,
666.                                kickedobj);
667.                 newsym(x, y);
668.                 return 1;
669.             }
670.             if (kickedobj->quan > 300L) {
671.                 pline("Thump!");
672.                 return (!rn2(3) || martial());
673.             }
674.         }
675.     }
676. 
677.     if (slide && !Blind)
678.         pline("Whee!  %s %s across the %s.", Doname2(kickedobj),
679.               otense(kickedobj, "slide"), surface(x, y));
680. 
681.     if (costly && !isgold)
682.         addtobill(kickedobj, FALSE, FALSE, TRUE);
683.     obj_extract_self(kickedobj);
684.     (void) snuff_candle(kickedobj);
685.     newsym(x, y);
686.     mon = bhit(u.dx, u.dy, range, KICKED_WEAPON,
687.                (int FDECL((*), (MONST_P, OBJ_P))) 0,
688.                (int FDECL((*), (OBJ_P, OBJ_P))) 0, &kickedobj);
689.     if (!kickedobj)
690.         return 1; /* object broken */
691. 
692.     if (mon) {
693.         if (mon->isshk && kickedobj->where == OBJ_MINVENT
694.             && kickedobj->ocarry == mon)
695.             return 1; /* alert shk caught it */
696.         notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y);
697.         if (isgold ? ghitm(mon, kickedobj)      /* caught? */
698.                    : thitmonst(mon, kickedobj)) /* hit && used up? */
699.             return 1;
700.     }
701. 
702.     /* the object might have fallen down a hole;
703.        ship_object() will have taken care of shop billing */
704.     if (kickedobj->where == OBJ_MIGRATING)
705.         return 1;
706. 
707.     bhitroom = *in_rooms(bhitpos.x, bhitpos.y, SHOPBASE);
708.     if (costly && (!costly_spot(bhitpos.x, bhitpos.y)
709.                    || *in_rooms(x, y, SHOPBASE) != bhitroom)) {
710.         if (isgold)
711.             costly_gold(x, y, kickedobj->quan);
712.         else
713.             (void) stolen_value(kickedobj, x, y, (boolean) shkp->mpeaceful,
714.                                 FALSE);
715.     }
716. 
717.     if (flooreffects(kickedobj, bhitpos.x, bhitpos.y, "fall"))
718.         return 1;
719.     if (kickedobj->unpaid)
720.         subfrombill(kickedobj, shkp);
721.     place_object(kickedobj, bhitpos.x, bhitpos.y);
722.     stackobj(kickedobj);
723.     newsym(kickedobj->ox, kickedobj->oy);
724.     return 1;
725. }
726. 
727. /* cause of death if kicking kills kicker */
728. STATIC_OVL char *
729. kickstr(buf, kickobjnam)
730. char *buf;
731. const char *kickobjnam;
732. {
733.     const char *what;
734. 
735.     if (*kickobjnam)
736.         what = kickobjnam;
737.     else if (maploc == &nowhere)
738.         what = "nothing";
739.     else if (IS_DOOR(maploc->typ))
740.         what = "a door";
741.     else if (IS_TREE(maploc->typ))
742.         what = "a tree";
743.     else if (IS_STWALL(maploc->typ))
744.         what = "a wall";
745.     else if (IS_ROCK(maploc->typ))
746.         what = "a rock";
747.     else if (IS_THRONE(maploc->typ))
748.         what = "a throne";
749.     else if (IS_FOUNTAIN(maploc->typ))
750.         what = "a fountain";
751.     else if (IS_GRAVE(maploc->typ))
752.         what = "a headstone";
753.     else if (IS_SINK(maploc->typ))
754.         what = "a sink";
755.     else if (IS_ALTAR(maploc->typ))
756.         what = "an altar";
757.     else if (IS_DRAWBRIDGE(maploc->typ))
758.         what = "a drawbridge";
759.     else if (maploc->typ == STAIRS)
760.         what = "the stairs";
761.     else if (maploc->typ == LADDER)
762.         what = "a ladder";
763.     else if (maploc->typ == IRONBARS)
764.         what = "an iron bar";
765.     else
766.         what = "something weird";
767.     return strcat(strcpy(buf, "kicking "), what);
768. }
769. 
770. int
771. dokick()
772. {
773.     int x, y;
774.     int avrg_attrib;
775.     int dmg = 0, glyph, oldglyph = -1;
776.     register struct monst *mtmp;
777.     boolean no_kick = FALSE;
778.     char buf[BUFSZ], kickobjnam[BUFSZ];
779. 
780.     kickobjnam[0] = '\0';
781.     if (nolimbs(youmonst.data) || slithy(youmonst.data)) {
782.         You("have no legs to kick with.");
783.         no_kick = TRUE;
784.     } else if (verysmall(youmonst.data)) {
785.         You("are too small to do any kicking.");
786.         no_kick = TRUE;
787.     } else if (u.usteed) {
788.         if (yn_function("Kick your steed?", ynchars, 'y') == 'y') {
789.             You("kick %s.", mon_nam(u.usteed));
790.             kick_steed();
791.             return 1;
792.         } else {
793.             return 0;
794.         }
795.     } else if (Wounded_legs) {
796.         /* note: jump() has similar code */
797.         long wl = (EWounded_legs & BOTH_SIDES);
798.         const char *bp = body_part(LEG);
799. 
800.         if (wl == BOTH_SIDES)
801.             bp = makeplural(bp);
802.         Your("%s%s %s in no shape for kicking.",
803.              (wl == LEFT_SIDE) ? "left " : (wl == RIGHT_SIDE) ? "right " : "",
804.              bp, (wl == BOTH_SIDES) ? "are" : "is");
805.         no_kick = TRUE;
806.     } else if (near_capacity() > SLT_ENCUMBER) {
807.         Your("load is too heavy to balance yourself for a kick.");
808.         no_kick = TRUE;
809.     } else if (youmonst.data->mlet == S_LIZARD) {
810.         Your("legs cannot kick effectively.");
811.         no_kick = TRUE;
812.     } else if (u.uinwater && !rn2(2)) {
813.         Your("slow motion kick doesn't hit anything.");
814.         no_kick = TRUE;
815.     } else if (u.utrap) {
816.         no_kick = TRUE;
817.         switch (u.utraptype) {
818.         case TT_PIT:
819.             if (!Passes_walls)
820.                 pline("There's not enough room to kick down here.");
821.             else
822.                 no_kick = FALSE;
823.             break;
824.         case TT_WEB:
825.         case TT_BEARTRAP:
826.             You_cant("move your %s!", body_part(LEG));
827.             break;
828.         default:
829.             break;
830.         }
831.     }
832. 
833.     if (no_kick) {
834.         /* ignore direction typed before player notices kick failed */
835.         display_nhwindow(WIN_MESSAGE, TRUE); /* --More-- */
836.         return 0;
837.     }
838. 
839.     if (!getdir((char *) 0))
840.         return 0;
841.     if (!u.dx && !u.dy)
842.         return 0;
843. 
844.     x = u.ux + u.dx;
845.     y = u.uy + u.dy;
846. 
847.     /* KMH -- Kicking boots always succeed */
848.     if (uarmf && uarmf->otyp == KICKING_BOOTS)
849.         avrg_attrib = 99;
850.     else
851.         avrg_attrib = (ACURRSTR + ACURR(A_DEX) + ACURR(A_CON)) / 3;
852. 
853.     if (u.uswallow) {
854.         switch (rn2(3)) {
855.         case 0:
856.             You_cant("move your %s!", body_part(LEG));
857.             break;
858.         case 1:
859.             if (is_animal(u.ustuck->data)) {
860.                 pline("%s burps loudly.", Monnam(u.ustuck));
861.                 break;
862.             }
863.             /*FALLTHRU*/
864.         default:
865.             Your("feeble kick has no effect.");
866.             break;
867.         }
868.         return 1;
869.     } else if (u.utrap && u.utraptype == TT_PIT) {
870.         /* must be Passes_walls */
871.         You("kick at the side of the pit.");
872.         return 1;
873.     }
874.     if (Levitation) {
875.         int xx, yy;
876. 
877.         xx = u.ux - u.dx;
878.         yy = u.uy - u.dy;
879.         /* doors can be opened while levitating, so they must be
880.          * reachable for bracing purposes
881.          * Possible extension: allow bracing against stuff on the side?
882.          */
883.         if (isok(xx, yy) && !IS_ROCK(levl[xx][yy].typ)
884.             && !IS_DOOR(levl[xx][yy].typ)
885.             && (!Is_airlevel(&u.uz) || !OBJ_AT(xx, yy))) {
886.             You("have nothing to brace yourself against.");
887.             return 0;
888.         }
889.     }
890. 
891.     mtmp = isok(x, y) ? m_at(x, y) : 0;
892.     /* might not kick monster if it is hidden and becomes revealed,
893.        if it is peaceful and player declines to attack, or if the
894.        hero passes out due to encumbrance with low hp; context.move
895.        will be 1 unless player declines to kick peaceful monster */
896.     if (mtmp) {
897.         oldglyph = glyph_at(x, y);
898.         if (!maybe_kick_monster(mtmp, x, y))
899.             return context.move;
900.     }
901. 
902.     wake_nearby();
903.     u_wipe_engr(2);
904. 
905.     if (!isok(x, y)) {
906.         maploc = &nowhere;
907.         goto ouch;
908.     }
909.     maploc = &levl[x][y];
910. 
911.     /*
912.      * The next five tests should stay in their present order:
913.      * monsters, pools, objects, non-doors, doors.
914.      *
915.      * [FIXME:  Monsters who are hidden underneath objects or
916.      * in pools should lead to hero kicking the concealment
917.      * rather than the monster, probably exposing the hidden
918.      * monster in the process.  And monsters who are hidden on
919.      * ceiling shouldn't be kickable (unless hero is flying?);
920.      * kicking toward them should just target whatever is on
921.      * the floor at that spot.]
922.      */
923. 
924.     if (mtmp) {
925.         /* save mtmp->data (for recoil) in case mtmp gets killed */
926.         struct permonst *mdat = mtmp->data;
927. 
928.         kick_monster(mtmp, x, y);
929.         glyph = glyph_at(x, y);
930.         /* see comment in attack_checks() */
931.         if (DEADMONSTER(mtmp)) { /* DEADMONSTER() */
932.             /* if we mapped an invisible monster and immediately
933.                killed it, we don't want to forget what we thought
934.                was there before the kick */
935.             if (glyph != oldglyph && glyph_is_invisible(glyph))
936.                 show_glyph(x, y, oldglyph);
937.         } else if (!canspotmon(mtmp)
938.                    /* check <x,y>; monster that evades kick by jumping
939.                       to an unseen square doesn't leave an I behind */
940.                    && mtmp->mx == x && mtmp->my == y
941.                    && !glyph_is_invisible(glyph)
942.                    && !(u.uswallow && mtmp == u.ustuck)) {
943.             map_invisible(x, y);
944.         }
945.         /* recoil if floating */
946.         if ((Is_airlevel(&u.uz) || Levitation) && context.move) {
947.             int range;
948. 
949.             range =
950.                 ((int) youmonst.data->cwt + (weight_cap() + inv_weight()));
951.             if (range < 1)
952.                 range = 1; /* divide by zero avoidance */
953.             range = (3 * (int) mdat->cwt) / range;
954. 
955.             if (range < 1)
956.                 range = 1;
957.             hurtle(-u.dx, -u.dy, range, TRUE);
958.         }
959.         return 1;
960.     }
961.     (void) unmap_invisible(x, y);
962.     if (is_pool(x, y) ^ !!u.uinwater) {
963.         /* objects normally can't be removed from water by kicking */
964.         You("splash some %s around.", hliquid("water"));
965.         return 1;
966.     }
967. 
968.     if (OBJ_AT(x, y) && (!Levitation || Is_airlevel(&u.uz)
969.                          || Is_waterlevel(&u.uz) || sobj_at(BOULDER, x, y))) {
970.         if (kick_object(x, y, kickobjnam)) {
971.             if (Is_airlevel(&u.uz))
972.                 hurtle(-u.dx, -u.dy, 1, TRUE); /* assume it's light */
973.             return 1;
974.         }
975.         goto ouch;
976.     }
977. 
978.     if (!IS_DOOR(maploc->typ)) {
979.         if (maploc->typ == SDOOR) {
980.             if (!Levitation && rn2(30) < avrg_attrib) {
981.                 cvt_sdoor_to_door(maploc); /* ->typ = DOOR */
982.                 pline("Crash!  %s a secret door!",
983.                       /* don't "kick open" when it's locked
984.                          unless it also happens to be trapped */
985.                       (maploc->doormask & (D_LOCKED | D_TRAPPED)) == D_LOCKED
986.                           ? "Your kick uncovers"
987.                           : "You kick open");
988.                 exercise(A_DEX, TRUE);
989.                 if (maploc->doormask & D_TRAPPED) {
990.                     maploc->doormask = D_NODOOR;
991.                     b_trapped("door", FOOT);
992.                 } else if (maploc->doormask != D_NODOOR
993.                            && !(maploc->doormask & D_LOCKED))
994.                     maploc->doormask = D_ISOPEN;
995.                 feel_newsym(x, y); /* we know it's gone */
996.                 if (maploc->doormask == D_ISOPEN
997.                     || maploc->doormask == D_NODOOR)
998.                     unblock_point(x, y); /* vision */
999.                 return 1;
1000.             } else
1001.                 goto ouch;
1002.         }
1003.         if (maploc->typ == SCORR) {
1004.             if (!Levitation && rn2(30) < avrg_attrib) {
1005.                 pline("Crash!  You kick open a secret passage!");
1006.                 exercise(A_DEX, TRUE);
1007.                 maploc->typ = CORR;
1008.                 feel_newsym(x, y); /* we know it's gone */
1009.                 unblock_point(x, y); /* vision */
1010.                 return 1;
1011.             } else
1012.                 goto ouch;
1013.         }
1014.         if (IS_THRONE(maploc->typ)) {
1015.             register int i;
1016.             if (Levitation)
1017.                 goto dumb;
1018.             if ((Luck < 0 || maploc->doormask) && !rn2(3)) {
1019.                 maploc->typ = ROOM;
1020.                 maploc->doormask = 0; /* don't leave loose ends.. */
1021.                 (void) mkgold((long) rnd(200), x, y);
1022.                 if (Blind)
1023.                     pline("CRASH!  You destroy it.");
1024.                 else {
1025.                     pline("CRASH!  You destroy the throne.");
1026.                     newsym(x, y);
1027.                 }
1028.                 exercise(A_DEX, TRUE);
1029.                 return 1;
1030.             } else if (Luck > 0 && !rn2(3) && !maploc->looted) {
1031.                 (void) mkgold((long) rn1(201, 300), x, y);
1032.                 i = Luck + 1;
1033.                 if (i > 6)
1034.                     i = 6;
1035.                 while (i--)
1036.                     (void) mksobj_at(
1037.                         rnd_class(DILITHIUM_CRYSTAL, LUCKSTONE - 1), x, y,
1038.                         FALSE, TRUE);
1039.                 if (Blind)
1040.                     You("kick %s loose!", something);
1041.                 else {
1042.                     You("kick loose some ornamental coins and gems!");
1043.                     newsym(x, y);
1044.                 }
1045.                 /* prevent endless milking */
1046.                 maploc->looted = T_LOOTED;
1047.                 return 1;
1048.             } else if (!rn2(4)) {
1049.                 if (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)) {
1050.                     fall_through(FALSE, 0);
1051.                     return 1;
1052.                 } else
1053.                     goto ouch;
1054.             }
1055.             goto ouch;
1056.         }
1057.         if (IS_ALTAR(maploc->typ)) {
1058.             if (Levitation)
1059.                 goto dumb;
1060.             You("kick %s.", (Blind ? something : "the altar"));
1061.             altar_wrath(x, y);
1062.             if (!rn2(3))
1063.                 goto ouch;
1064.             exercise(A_DEX, TRUE);
1065.             return 1;
1066.         }
1067.         if (IS_FOUNTAIN(maploc->typ)) {
1068.             if (Levitation)
1069.                 goto dumb;
1070.             You("kick %s.", (Blind ? something : "the fountain"));
1071.             if (!rn2(3))
1072.                 goto ouch;
1073.             /* make metal boots rust */
1074.             if (uarmf && rn2(3))
1075.                 if (water_damage(uarmf, "metal boots", TRUE) == ER_NOTHING) {
1076.                     Your("boots get wet.");
1077.                     /* could cause short-lived fumbling here */
1078.                 }
1079.             exercise(A_DEX, TRUE);
1080.             return 1;
1081.         }
1082.         if (IS_GRAVE(maploc->typ)) {
1083.             if (Levitation)
1084.                 goto dumb;
1085.             if (rn2(4))
1086.                 goto ouch;
1087.             exercise(A_WIS, FALSE);
1088.             if (Role_if(PM_ARCHEOLOGIST) || Role_if(PM_SAMURAI)
1089.                 || ((u.ualign.type == A_LAWFUL) && (u.ualign.record > -10))) {
1090.                 adjalign(-sgn(u.ualign.type));
1091.             }
1092.             maploc->typ = ROOM;
1093.             maploc->doormask = 0;
1094.             (void) mksobj_at(ROCK, x, y, TRUE, FALSE);
1095.             del_engr_at(x, y);
1096.             if (Blind)
1097.                 pline("Crack!  %s broke!", Something);
1098.             else {
1099.                 pline_The("headstone topples over and breaks!");
1100.                 newsym(x, y);
1101.             }
1102.             return 1;
1103.         }
1104.         if (maploc->typ == IRONBARS)
1105.             goto ouch;
1106.         if (IS_TREE(maploc->typ)) {
1107.             struct obj *treefruit;
1108. 
1109.             /* nothing, fruit or trouble? 75:23.5:1.5% */
1110.             if (rn2(3)) {
1111.                 if (!rn2(6) && !(mvitals[PM_KILLER_BEE].mvflags & G_GONE))
1112.                     You_hear("a low buzzing."); /* a warning */
1113.                 goto ouch;
1114.             }
1115.             if (rn2(15) && !(maploc->looted & TREE_LOOTED)
1116.                 && (treefruit = rnd_treefruit_at(x, y))) {
1117.                 long nfruit = 8L - rnl(7), nfall;
1118.                 short frtype = treefruit->otyp;
1119. 
1120.                 treefruit->quan = nfruit;
1121.                 treefruit->owt = weight(treefruit);
1122.                 if (is_plural(treefruit))
1123.                     pline("Some %s fall from the tree!", xname(treefruit));
1124.                 else
1125.                     pline("%s falls from the tree!", An(xname(treefruit)));
1126.                 nfall = scatter(x, y, 2, MAY_HIT, treefruit);
1127.                 if (nfall != nfruit) {
1128.                     /* scatter left some in the tree, but treefruit
1129.                      * may not refer to the correct object */
1130.                     treefruit = mksobj(frtype, TRUE, FALSE);
1131.                     treefruit->quan = nfruit - nfall;
1132.                     pline("%ld %s got caught in the branches.",
1133.                           nfruit - nfall, xname(treefruit));
1134.                     dealloc_obj(treefruit);
1135.                 }
1136.                 exercise(A_DEX, TRUE);
1137.                 exercise(A_WIS, TRUE); /* discovered a new food source! */
1138.                 newsym(x, y);
1139.                 maploc->looted |= TREE_LOOTED;
1140.                 return 1;
1141.             } else if (!(maploc->looted & TREE_SWARM)) {
1142.                 int cnt = rnl(4) + 2;
1143.                 int made = 0;
1144.                 coord mm;
1145. 
1146.                 mm.x = x;
1147.                 mm.y = y;
1148.                 while (cnt--) {
1149.                     if (enexto(&mm, mm.x, mm.y, &mons[PM_KILLER_BEE])
1150.                         && makemon(&mons[PM_KILLER_BEE], mm.x, mm.y,
1151.                                    MM_ANGRY))
1152.                         made++;
1153.                 }
1154.                 if (made)
1155.                     pline("You've attracted the tree's former occupants!");
1156.                 else
1157.                     You("smell stale honey.");
1158.                 maploc->looted |= TREE_SWARM;
1159.                 return 1;
1160.             }
1161.             goto ouch;
1162.         }
1163.         if (IS_SINK(maploc->typ)) {
1164.             int gend = poly_gender();
1165.             short washerndx = (gend == 1 || (gend == 2 && rn2(2)))
1166.                                   ? PM_INCUBUS
1167.                                   : PM_SUCCUBUS;
1168. 
1169.             if (Levitation)
1170.                 goto dumb;
1171.             if (rn2(5)) {
1172.                 if (!Deaf)
1173.                     pline("Klunk!  The pipes vibrate noisily.");
1174.                 else
1175.                     pline("Klunk!");
1176.                 exercise(A_DEX, TRUE);
1177.                 return 1;
1178.             } else if (!(maploc->looted & S_LPUDDING) && !rn2(3)
1179.                        && !(mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) {
1180.                 if (Blind)
1181.                     You_hear("a gushing sound.");
1182.                 else
1183.                     pline("A %s ooze gushes up from the drain!",
1184.                           hcolor(NH_BLACK));
1185.                 (void) makemon(&mons[PM_BLACK_PUDDING], x, y, NO_MM_FLAGS);
1186.                 exercise(A_DEX, TRUE);
1187.                 newsym(x, y);
1188.                 maploc->looted |= S_LPUDDING;
1189.                 return 1;
1190.             } else if (!(maploc->looted & S_LDWASHER) && !rn2(3)
1191.                        && !(mvitals[washerndx].mvflags & G_GONE)) {
1192.                 /* can't resist... */
1193.                 pline("%s returns!", (Blind ? Something : "The dish washer"));
1194.                 if (makemon(&mons[washerndx], x, y, NO_MM_FLAGS))
1195.                     newsym(x, y);
1196.                 maploc->looted |= S_LDWASHER;
1197.                 exercise(A_DEX, TRUE);
1198.                 return 1;
1199.             } else if (!rn2(3)) {
1200.                 if (Blind && Deaf)
1201.                     Sprintf(buf, " %s", body_part(FACE));
1202.                 else
1203.                     buf[0] = '\0';
1204.                 pline("%s%s%s.", !Deaf ? "Flupp! " : "",
1205.                       !Blind
1206.                           ? "Muddy waste pops up from the drain"
1207.                           : !Deaf
1208.                               ? "You hear a sloshing sound"  /* Deaf-aware */
1209.                               : "Something splashes you in the", buf);
1210.                 if (!(maploc->looted & S_LRING)) { /* once per sink */
1211.                     if (!Blind)
1212.                         You_see("a ring shining in its midst.");
1213.                     (void) mkobj_at(RING_CLASS, x, y, TRUE);
1214.                     newsym(x, y);
1215.                     exercise(A_DEX, TRUE);
1216.                     exercise(A_WIS, TRUE); /* a discovery! */
1217.                     maploc->looted |= S_LRING;
1218.                 }
1219.                 return 1;
1220.             }
1221.             goto ouch;
1222.         }
1223.         if (maploc->typ == STAIRS || maploc->typ == LADDER
1224.             || IS_STWALL(maploc->typ)) {
1225.             if (!IS_STWALL(maploc->typ) && maploc->ladder == LA_DOWN)
1226.                 goto dumb;
1227.  ouch:
1228.             pline("Ouch!  That hurts!");
1229.             exercise(A_DEX, FALSE);
1230.             exercise(A_STR, FALSE);
1231.             if (isok(x, y)) {
1232.                 if (Blind)
1233.                     feel_location(x, y); /* we know we hit it */
1234.                 if (is_drawbridge_wall(x, y) >= 0) {
1235.                     pline_The("drawbridge is unaffected.");
1236.                     /* update maploc to refer to the drawbridge */
1237.                     (void) find_drawbridge(&x, &y);
1238.                     maploc = &levl[x][y];
1239.                 }
1240.             }
1241.             if (!rn2(3))
1242.                 set_wounded_legs(RIGHT_SIDE, 5 + rnd(5));
1243.             dmg = rnd(ACURR(A_CON) > 15 ? 3 : 5);
1244.             losehp(Maybe_Half_Phys(dmg), kickstr(buf, kickobjnam), KILLED_BY);
1245.             if (Is_airlevel(&u.uz) || Levitation)
1246.                 hurtle(-u.dx, -u.dy, rn1(2, 4), TRUE); /* assume it's heavy */
1247.             return 1;
1248.         }
1249.         goto dumb;
1250.     }
1251. 
1252.     if (maploc->doormask == D_ISOPEN || maploc->doormask == D_BROKEN
1253.         || maploc->doormask == D_NODOOR) {
1254.  dumb:
1255.         exercise(A_DEX, FALSE);
1256.         if (martial() || ACURR(A_DEX) >= 16 || rn2(3)) {
1257.             You("kick at empty space.");
1258.             if (Blind)
1259.                 feel_location(x, y);
1260.         } else {
1261.             pline("Dumb move!  You strain a muscle.");
1262.             exercise(A_STR, FALSE);
1263.             set_wounded_legs(RIGHT_SIDE, 5 + rnd(5));
1264.         }
1265.         if ((Is_airlevel(&u.uz) || Levitation) && rn2(2))
1266.             hurtle(-u.dx, -u.dy, 1, TRUE);
1267.         return 1; /* uses a turn */
1268.     }
1269. 
1270.     /* not enough leverage to kick open doors while levitating */
1271.     if (Levitation)
1272.         goto ouch;
1273. 
1274.     exercise(A_DEX, TRUE);
1275.     /* door is known to be CLOSED or LOCKED */
1276.     if (rnl(35) < avrg_attrib + (!martial() ? 0 : ACURR(A_DEX))) {
1277.         boolean shopdoor = *in_rooms(x, y, SHOPBASE) ? TRUE : FALSE;
1278.         /* break the door */
1279.         if (maploc->doormask & D_TRAPPED) {
1280.             if (flags.verbose)
1281.                 You("kick the door.");
1282.             exercise(A_STR, FALSE);
1283.             maploc->doormask = D_NODOOR;
1284.             b_trapped("door", FOOT);
1285.         } else if (ACURR(A_STR) > 18 && !rn2(5) && !shopdoor) {
1286.             pline("As you kick the door, it shatters to pieces!");
1287.             exercise(A_STR, TRUE);
1288.             maploc->doormask = D_NODOOR;
1289.         } else {
1290.             pline("As you kick the door, it crashes open!");
1291.             exercise(A_STR, TRUE);
1292.             maploc->doormask = D_BROKEN;
1293.         }
1294.         feel_newsym(x, y); /* we know we broke it */
1295.         unblock_point(x, y); /* vision */
1296.         if (shopdoor) {
1297.             add_damage(x, y, SHOP_DOOR_COST);
1298.             pay_for_damage("break", FALSE);
1299.         }
1300.         if (in_town(x, y))
1301.             for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
1302.                 if (DEADMONSTER(mtmp))
1303.                     continue;
1304.                 if (is_watch(mtmp->data) && couldsee(mtmp->mx, mtmp->my)
1305.                     && mtmp->mpeaceful) {
1306.                     mon_yells(mtmp, "Halt, thief!  You're under arrest!");
1307.                     (void) angry_guards(FALSE);
1308.                     break;
1309.                 }
1310.             }
1311.     } else {
1312.         if (Blind)
1313.             feel_location(x, y); /* we know we hit it */
1314.         exercise(A_STR, TRUE);
1315.         pline("WHAMMM!!!");
1316.         if (in_town(x, y))
1317.             for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
1318.                 if (DEADMONSTER(mtmp))
1319.                     continue;
1320.                 if (is_watch(mtmp->data) && mtmp->mpeaceful
1321.                     && couldsee(mtmp->mx, mtmp->my)) {
1322.                     if (levl[x][y].looted & D_WARNED) {
1323.                         mon_yells(mtmp,
1324.                                   "Halt, vandal!  You're under arrest!");
1325.                         (void) angry_guards(FALSE);
1326.                     } else {
1327.                         mon_yells(mtmp, "Hey, stop damaging that door!");
1328.                         levl[x][y].looted |= D_WARNED;
1329.                     }
1330.                     break;
1331.                 }
1332.             }
1333.     }
1334.     return 1;
1335. }
1336. 
1337. STATIC_OVL void
1338. drop_to(cc, loc)
1339. coord *cc;
1340. schar loc;
1341. {
1342.     /* cover all the MIGR_xxx choices generated by down_gate() */
1343.     switch (loc) {
1344.     case MIGR_RANDOM: /* trap door or hole */
1345.         if (Is_stronghold(&u.uz)) {
1346.             cc->x = valley_level.dnum;
1347.             cc->y = valley_level.dlevel;
1348.             break;
1349.         } else if (In_endgame(&u.uz) || Is_botlevel(&u.uz)) {
1350.             cc->y = cc->x = 0;
1351.             break;
1352.         }
1353.         /*FALLTHRU*/
1354.     case MIGR_STAIRS_UP:
1355.     case MIGR_LADDER_UP:
1356.         cc->x = u.uz.dnum;
1357.         cc->y = u.uz.dlevel + 1;
1358.         break;
1359.     case MIGR_SSTAIRS:
1360.         cc->x = sstairs.tolev.dnum;
1361.         cc->y = sstairs.tolev.dlevel;
1362.         break;
1363.     default:
1364.     case MIGR_NOWHERE:
1365.         /* y==0 means "nowhere", in which case x doesn't matter */
1366.         cc->y = cc->x = 0;
1367.         break;
1368.     }
1369. }
1370. 
1371. /* player or missile impacts location, causing objects to fall down */
1372. void
1373. impact_drop(missile, x, y, dlev)
1374. struct obj *missile; /* caused impact, won't drop itself */
1375. xchar x, y;          /* location affected */
1376. xchar dlev;          /* if !0 send to dlev near player */
1377. {
1378.     schar toloc;
1379.     register struct obj *obj, *obj2;
1380.     register struct monst *shkp;
1381.     long oct, dct, price, debit, robbed;
1382.     boolean angry, costly, isrock;
1383.     coord cc;
1384. 
1385.     if (!OBJ_AT(x, y))
1386.         return;
1387. 
1388.     toloc = down_gate(x, y);
1389.     drop_to(&cc, toloc);
1390.     if (!cc.y)
1391.         return;
1392. 
1393.     if (dlev) {
1394.         /* send objects next to player falling through trap door.
1395.          * checked in obj_delivery().
1396.          */
1397.         toloc = MIGR_WITH_HERO;
1398.         cc.y = dlev;
1399.     }
1400. 
1401.     costly = costly_spot(x, y);
1402.     price = debit = robbed = 0L;
1403.     angry = FALSE;
1404.     shkp = (struct monst *) 0;
1405.     /* if 'costly', we must keep a record of ESHK(shkp) before
1406.      * it undergoes changes through the calls to stolen_value.
1407.      * the angry bit must be reset, if needed, in this fn, since
1408.      * stolen_value is called under the 'silent' flag to avoid
1409.      * unsavory pline repetitions.
1410.      */
1411.     if (costly) {
1412.         if ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0) {
1413.             debit = ESHK(shkp)->debit;
1414.             robbed = ESHK(shkp)->robbed;
1415.             angry = !shkp->mpeaceful;
1416.         }
1417.     }
1418. 
1419.     isrock = (missile && missile->otyp == ROCK);
1420.     oct = dct = 0L;
1421.     for (obj = level.objects[x][y]; obj; obj = obj2) {
1422.         obj2 = obj->nexthere;
1423.         if (obj == missile)
1424.             continue;
1425.         /* number of objects in the pile */
1426.         oct += obj->quan;
1427.         if (obj == uball || obj == uchain)
1428.             continue;
1429.         /* boulders can fall too, but rarely & never due to rocks */
1430.         if ((isrock && obj->otyp == BOULDER)
1431.             || rn2(obj->otyp == BOULDER ? 30 : 3))
1432.             continue;
1433.         obj_extract_self(obj);
1434. 
1435.         if (costly) {
1436.             price += stolen_value(obj, x, y,
1437.                                   (costly_spot(u.ux, u.uy)
1438.                                    && index(u.urooms,
1439.                                             *in_rooms(x, y, SHOPBASE))),
1440.                                   TRUE);
1441.             /* set obj->no_charge to 0 */
1442.             if (Has_contents(obj))
1443.                 picked_container(obj); /* does the right thing */
1444.             if (obj->oclass != COIN_CLASS)
1445.                 obj->no_charge = 0;
1446.         }
1447. 
1448.         add_to_migration(obj);
1449.         obj->ox = cc.x;
1450.         obj->oy = cc.y;
1451.         obj->owornmask = (long) toloc;
1452. 
1453.         /* number of fallen objects */
1454.         dct += obj->quan;
1455.     }
1456. 
1457.     if (dct && cansee(x, y)) { /* at least one object fell */
1458.         const char *what = (dct == 1L ? "object falls" : "objects fall");
1459. 
1460.         if (missile)
1461.             pline("From the impact, %sother %s.",
1462.                   dct == oct ? "the " : dct == 1L ? "an" : "", what);
1463.         else if (oct == dct)
1464.             pline("%s adjacent %s %s.", dct == 1L ? "The" : "All the", what,
1465.                   gate_str);
1466.         else
1467.             pline("%s adjacent %s %s.",
1468.                   dct == 1L ? "One of the" : "Some of the",
1469.                   dct == 1L ? "objects falls" : what, gate_str);
1470.     }
1471. 
1472.     if (costly && shkp && price) {
1473.         if (ESHK(shkp)->robbed > robbed) {
1474.             You("removed %ld %s worth of goods!", price, currency(price));
1475.             if (cansee(shkp->mx, shkp->my)) {
1476.                 if (ESHK(shkp)->customer[0] == 0)
1477.                     (void) strncpy(ESHK(shkp)->customer, plname, PL_NSIZ);
1478.                 if (angry)
1479.                     pline("%s is infuriated!", Monnam(shkp));
1480.                 else
1481.                     pline("\"%s, you are a thief!\"", plname);
1482.             } else
1483.                 You_hear("a scream, \"Thief!\"");
1484.             hot_pursuit(shkp);
1485.             (void) angry_guards(FALSE);
1486.             return;
1487.         }
1488.         if (ESHK(shkp)->debit > debit) {
1489.             long amt = (ESHK(shkp)->debit - debit);
1490.             You("owe %s %ld %s for goods lost.", Monnam(shkp), amt,
1491.                 currency(amt));
1492.         }
1493.     }
1494. }
1495. 
1496. /* NOTE: ship_object assumes otmp was FREED from fobj or invent.
1497.  * <x,y> is the point of drop.  otmp is _not_ an <x,y> resident:
1498.  * otmp is either a kicked, dropped, or thrown object.
1499.  */
1500. boolean
1501. ship_object(otmp, x, y, shop_floor_obj)
1502. xchar x, y;
1503. struct obj *otmp;
1504. boolean shop_floor_obj;
1505. {
1506.     schar toloc;
1507.     xchar ox, oy;
1508.     coord cc;
1509.     struct obj *obj;
1510.     struct trap *t;
1511.     boolean nodrop, unpaid, container, impact = FALSE;
1512.     long n = 0L;
1513. 
1514.     if (!otmp)
1515.         return FALSE;
1516.     if ((toloc = down_gate(x, y)) == MIGR_NOWHERE)
1517.         return FALSE;
1518.     drop_to(&cc, toloc);
1519.     if (!cc.y)
1520.         return FALSE;
1521. 
1522.     /* objects other than attached iron ball always fall down ladder,
1523.        but have a chance of staying otherwise */
1524.     nodrop = (otmp == uball) || (otmp == uchain)
1525.              || (toloc != MIGR_LADDER_UP && rn2(3));
1526. 
1527.     container = Has_contents(otmp);
1528.     unpaid = is_unpaid(otmp);
1529. 
1530.     if (OBJ_AT(x, y)) {
1531.         for (obj = level.objects[x][y]; obj; obj = obj->nexthere)
1532.             if (obj != otmp)
1533.                 n += obj->quan;
1534.         if (n)
1535.             impact = TRUE;
1536.     }
1537.     /* boulders never fall through trap doors, but they might knock
1538.        other things down before plugging the hole */
1539.     if (otmp->otyp == BOULDER && ((t = t_at(x, y)) != 0)
1540.         && is_hole(t->ttyp)) {
1541.         if (impact)
1542.             impact_drop(otmp, x, y, 0);
1543.         return FALSE; /* let caller finish the drop */
1544.     }
1545. 
1546.     if (cansee(x, y))
1547.         otransit_msg(otmp, nodrop, n);
1548. 
1549.     if (nodrop) {
1550.         if (impact)
1551.             impact_drop(otmp, x, y, 0);
1552.         return FALSE;
1553.     }
1554. 
1555.     if (unpaid || shop_floor_obj) {
1556.         if (unpaid) {
1557.             (void) stolen_value(otmp, u.ux, u.uy, TRUE, FALSE);
1558.         } else {
1559.             ox = otmp->ox;
1560.             oy = otmp->oy;
1561.             (void) stolen_value(
1562.                 otmp, ox, oy,
1563.                 (costly_spot(u.ux, u.uy)
1564.                  && index(u.urooms, *in_rooms(ox, oy, SHOPBASE))),
1565.                 FALSE);
1566.         }
1567.         /* set otmp->no_charge to 0 */
1568.         if (container)
1569.             picked_container(otmp); /* happens to do the right thing */
1570.         if (otmp->oclass != COIN_CLASS)
1571.             otmp->no_charge = 0;
1572.     }
1573. 
1574.     if (otmp->owornmask)
1575.         remove_worn_item(otmp, TRUE);
1576. 
1577.     /* some things break rather than ship */
1578.     if (breaktest(otmp)) {
1579.         const char *result;
1580. 
1581.         if (objects[otmp->otyp].oc_material == GLASS
1582.             || otmp->otyp == EXPENSIVE_CAMERA) {
1583.             if (otmp->otyp == MIRROR)
1584.                 change_luck(-2);
1585.             result = "crash";
1586.         } else {
1587.             /* penalty for breaking eggs laid by you */
1588.             if (otmp->otyp == EGG && otmp->spe && otmp->corpsenm >= LOW_PM)
1589.                 change_luck((schar) -min(otmp->quan, 5L));
1590.             result = "splat";
1591.         }
1592.         You_hear("a muffled %s.", result);
1593.         obj_extract_self(otmp);
1594.         obfree(otmp, (struct obj *) 0);
1595.         return TRUE;
1596.     }
1597. 
1598.     add_to_migration(otmp);
1599.     otmp->ox = cc.x;
1600.     otmp->oy = cc.y;
1601.     otmp->owornmask = (long) toloc;
1602.     /* boulder from rolling boulder trap, no longer part of the trap */
1603.     if (otmp->otyp == BOULDER)
1604.         otmp->otrapped = 0;
1605. 
1606.     if (impact) {
1607.         /* the objs impacted may be in a shop other than
1608.          * the one in which the hero is located.  another
1609.          * check for a shk is made in impact_drop.  it is, e.g.,
1610.          * possible to kick/throw an object belonging to one
1611.          * shop into another shop through a gap in the wall,
1612.          * and cause objects belonging to the other shop to
1613.          * fall down a trap door--thereby getting two shopkeepers
1614.          * angry at the hero in one shot.
1615.          */
1616.         impact_drop(otmp, x, y, 0);
1617.         newsym(x, y);
1618.     }
1619.     return TRUE;
1620. }
1621. 
1622. void
1623. obj_delivery(near_hero)
1624. boolean near_hero;
1625. {
1626.     register struct obj *otmp, *otmp2;
1627.     register int nx, ny;
1628.     int where;
1629.     boolean nobreak, noscatter;
1630. 
1631.     for (otmp = migrating_objs; otmp; otmp = otmp2) {
1632.         otmp2 = otmp->nobj;
1633.         if (otmp->ox != u.uz.dnum || otmp->oy != u.uz.dlevel)
1634.             continue;
1635. 
1636.         where = (int) (otmp->owornmask & 0x7fffL); /* destination code */
1637.         if ((where & MIGR_TO_SPECIES) != 0)
1638.             continue;
1639. 
1640.         nobreak = (where & MIGR_NOBREAK) != 0;
1641.         noscatter = (where & MIGR_WITH_HERO) != 0;
1642.         where &= ~(MIGR_NOBREAK | MIGR_NOSCATTER);
1643. 
1644.         if (!near_hero ^ (where == MIGR_WITH_HERO))
1645.             continue;
1646. 
1647.         obj_extract_self(otmp);
1648.         otmp->owornmask = 0L;
1649. 
1650.         switch (where) {
1651.         case MIGR_STAIRS_UP:
1652.             nx = xupstair, ny = yupstair;
1653.             break;
1654.         case MIGR_LADDER_UP:
1655.             nx = xupladder, ny = yupladder;
1656.             break;
1657.         case MIGR_SSTAIRS:
1658.             nx = sstairs.sx, ny = sstairs.sy;
1659.             break;
1660.         case MIGR_WITH_HERO:
1661.             nx = u.ux, ny = u.uy;
1662.             break;
1663.         default:
1664.         case MIGR_RANDOM:
1665.             nx = ny = 0;
1666.             break;
1667.         }
1668.         if (nx > 0) {
1669.             place_object(otmp, nx, ny);
1670.             if (!nobreak && !IS_SOFT(levl[nx][ny].typ)) {
1671.                 if (where == MIGR_WITH_HERO) {
1672.                     if (breaks(otmp, nx, ny))
1673.                         continue;
1674.                 } else if (breaktest(otmp)) {
1675.                     /* assume it broke before player arrived, no messages */
1676.                     delobj(otmp);
1677.                     continue;
1678.                 }
1679.             }
1680.             stackobj(otmp);
1681.             if (!noscatter)
1682.                 (void) scatter(nx, ny, rnd(2), 0, otmp);
1683.             else
1684.                 newsym(nx, ny);
1685.         } else { /* random location */
1686.             /* set dummy coordinates because there's no
1687.                current position for rloco() to update */
1688.             otmp->ox = otmp->oy = 0;
1689.             if (rloco(otmp) && !nobreak && breaktest(otmp)) {
1690.                 /* assume it broke before player arrived, no messages */
1691.                 delobj(otmp);
1692.             }
1693.         }
1694.     }
1695. }
1696. 
1697. void
1698. deliver_obj_to_mon(mtmp, cnt, deliverflags)
1699. int cnt;
1700. struct monst *mtmp;
1701. unsigned long deliverflags;
1702. {
1703.     struct obj *otmp, *otmp2;
1704.     int where, maxobj = 1;
1705.     boolean at_crime_scene = In_mines(&u.uz);
1706. 
1707.     if ((deliverflags & DF_RANDOM) && cnt > 1)
1708.         maxobj = rnd(cnt);
1709.     else if (deliverflags & DF_ALL)
1710.         maxobj = 0;
1711.     else
1712.         maxobj = 1;
1713. 
1714.     cnt = 0;
1715.     for (otmp = migrating_objs; otmp; otmp = otmp2) {
1716.         otmp2 = otmp->nobj;
1717.         where = (int) (otmp->owornmask & 0x7fffL); /* destination code */
1718.         if ((where & MIGR_TO_SPECIES) == 0)
1719.             continue;
1720. 
1721.         if ((mtmp->data->mflags2 & otmp->corpsenm) != 0) {
1722.             obj_extract_self(otmp);
1723.             otmp->owornmask = 0L;
1724.             otmp->ox = otmp->oy = 0;
1725. 
1726.             /* special treatment for orcs and their kind */
1727.             if ((otmp->corpsenm & M2_ORC) != 0 && has_oname(otmp)) {
1728.                 if (!has_mname(mtmp)) {
1729.                     if (at_crime_scene || !rn2(2))
1730.                         mtmp = christen_orc(mtmp,
1731.                                             at_crime_scene ? ONAME(otmp)
1732.                                                            : (char *) 0,
1733.                                             /* bought the stolen goods */
1734.                                             " the Fence");
1735.                 }
1736.                 free_oname(otmp);
1737.             }
1738.             otmp->corpsenm = 0;
1739.             (void) add_to_minv(mtmp, otmp);
1740.             cnt++;
1741.             if (maxobj && cnt >= maxobj)
1742.                 break;
1743.             /* getting here implies DF_ALL */
1744.         }
1745.     }
1746. }
1747. 
1748. STATIC_OVL void
1749. otransit_msg(otmp, nodrop, num)
1750. register struct obj *otmp;
1751. register boolean nodrop;
1752. long num;
1753. {
1754.     char *optr = 0, obuf[BUFSZ], xbuf[BUFSZ];
1755. 
1756.     if (otmp->otyp == CORPSE) {
1757.         /* Tobjnam() calls xname() and would yield "The corpse";
1758.            we want more specific "The newt corpse" or "Medusa's corpse" */
1759.         optr = upstart(corpse_xname(otmp, (char *) 0, CXN_PFX_THE));
1760.     } else {
1761.         optr = Tobjnam(otmp, (char *) 0);
1762.     }
1763.     Strcpy(obuf, optr);
1764. 
1765.     if (num) { /* means: other objects are impacted */
1766.         /* As of 3.6.2: use a separate buffer for the suffix to avoid risk of
1767.            overrunning obuf[] (let pline() handle truncation if necessary) */
1768.         Sprintf(xbuf, " %s %s object%s", otense(otmp, "hit"),
1769.                 (num == 1L) ? "another" : "other", (num > 1L) ? "s" : "");
1770.         if (nodrop)
1771.             Sprintf(eos(xbuf), ".");
1772.         else
1773.             Sprintf(eos(xbuf), " and %s %s.", otense(otmp, "fall"), gate_str);
1774.         pline("%s%s", obuf, xbuf);
1775.     } else if (!nodrop)
1776.         pline("%s %s %s.", obuf, otense(otmp, "fall"), gate_str);
1777. }
1778. 
1779. /* migration destination for objects which fall down to next level */
1780. schar
1781. down_gate(x, y)
1782. xchar x, y;
1783. {
1784.     struct trap *ttmp;
1785. 
1786.     gate_str = 0;
1787.     /* this matches the player restriction in goto_level() */
1788.     if (on_level(&u.uz, &qstart_level) && !ok_to_quest())
1789.         return MIGR_NOWHERE;
1790. 
1791.     if ((xdnstair == x && ydnstair == y)
1792.         || (sstairs.sx == x && sstairs.sy == y && !sstairs.up)) {
1793.         gate_str = "down the stairs";
1794.         return (xdnstair == x && ydnstair == y) ? MIGR_STAIRS_UP
1795.                                                 : MIGR_SSTAIRS;
1796.     }
1797.     if (xdnladder == x && ydnladder == y) {
1798.         gate_str = "down the ladder";
1799.         return MIGR_LADDER_UP;
1800.     }
1801. 
1802.     if (((ttmp = t_at(x, y)) != 0 && ttmp->tseen)
1803.         && is_hole(ttmp->ttyp)) {
1804.         gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door"
1805.                                             : "through the hole";
1806.         return MIGR_RANDOM;
1807.     }
1808.     return MIGR_NOWHERE;
1809. }
1810. 
1811. /*dokick.c*/