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