Source:NetHack 3.6.2/src/dokick.c
Jump to navigation
Jump to search
Below is the full text to dokick.c from the source code of NetHack 3.6.2. To link to a particular line, write [[Source:NetHack 3.6.2/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: 1551920353 2019/03/07 00:59:13 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.131 $ */ 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); 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. if (!rn2(3)) 1062. goto ouch; 1063. altar_wrath(x, y); 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. pline("Flupp! %s.", 1201. (Blind ? "You hear a sloshing sound" 1202. : "Muddy waste pops up from the drain")); 1203. if (!(maploc->looted & S_LRING)) { /* once per sink */ 1204. if (!Blind) 1205. You_see("a ring shining in its midst."); 1206. (void) mkobj_at(RING_CLASS, x, y, TRUE); 1207. newsym(x, y); 1208. exercise(A_DEX, TRUE); 1209. exercise(A_WIS, TRUE); /* a discovery! */ 1210. maploc->looted |= S_LRING; 1211. } 1212. return 1; 1213. } 1214. goto ouch; 1215. } 1216. if (maploc->typ == STAIRS || maploc->typ == LADDER 1217. || IS_STWALL(maploc->typ)) { 1218. if (!IS_STWALL(maploc->typ) && maploc->ladder == LA_DOWN) 1219. goto dumb; 1220. ouch: 1221. pline("Ouch! That hurts!"); 1222. exercise(A_DEX, FALSE); 1223. exercise(A_STR, FALSE); 1224. if (isok(x, y)) { 1225. if (Blind) 1226. feel_location(x, y); /* we know we hit it */ 1227. if (is_drawbridge_wall(x, y) >= 0) { 1228. pline_The("drawbridge is unaffected."); 1229. /* update maploc to refer to the drawbridge */ 1230. (void) find_drawbridge(&x, &y); 1231. maploc = &levl[x][y]; 1232. } 1233. } 1234. if (!rn2(3)) 1235. set_wounded_legs(RIGHT_SIDE, 5 + rnd(5)); 1236. dmg = rnd(ACURR(A_CON) > 15 ? 3 : 5); 1237. losehp(Maybe_Half_Phys(dmg), kickstr(buf, kickobjnam), KILLED_BY); 1238. if (Is_airlevel(&u.uz) || Levitation) 1239. hurtle(-u.dx, -u.dy, rn1(2, 4), TRUE); /* assume it's heavy */ 1240. return 1; 1241. } 1242. goto dumb; 1243. } 1244. 1245. if (maploc->doormask == D_ISOPEN || maploc->doormask == D_BROKEN 1246. || maploc->doormask == D_NODOOR) { 1247. dumb: 1248. exercise(A_DEX, FALSE); 1249. if (martial() || ACURR(A_DEX) >= 16 || rn2(3)) { 1250. You("kick at empty space."); 1251. if (Blind) 1252. feel_location(x, y); 1253. } else { 1254. pline("Dumb move! You strain a muscle."); 1255. exercise(A_STR, FALSE); 1256. set_wounded_legs(RIGHT_SIDE, 5 + rnd(5)); 1257. } 1258. if ((Is_airlevel(&u.uz) || Levitation) && rn2(2)) 1259. hurtle(-u.dx, -u.dy, 1, TRUE); 1260. return 1; /* uses a turn */ 1261. } 1262. 1263. /* not enough leverage to kick open doors while levitating */ 1264. if (Levitation) 1265. goto ouch; 1266. 1267. exercise(A_DEX, TRUE); 1268. /* door is known to be CLOSED or LOCKED */ 1269. if (rnl(35) < avrg_attrib + (!martial() ? 0 : ACURR(A_DEX))) { 1270. boolean shopdoor = *in_rooms(x, y, SHOPBASE) ? TRUE : FALSE; 1271. /* break the door */ 1272. if (maploc->doormask & D_TRAPPED) { 1273. if (flags.verbose) 1274. You("kick the door."); 1275. exercise(A_STR, FALSE); 1276. maploc->doormask = D_NODOOR; 1277. b_trapped("door", FOOT); 1278. } else if (ACURR(A_STR) > 18 && !rn2(5) && !shopdoor) { 1279. pline("As you kick the door, it shatters to pieces!"); 1280. exercise(A_STR, TRUE); 1281. maploc->doormask = D_NODOOR; 1282. } else { 1283. pline("As you kick the door, it crashes open!"); 1284. exercise(A_STR, TRUE); 1285. maploc->doormask = D_BROKEN; 1286. } 1287. feel_newsym(x, y); /* we know we broke it */ 1288. unblock_point(x, y); /* vision */ 1289. if (shopdoor) { 1290. add_damage(x, y, SHOP_DOOR_COST); 1291. pay_for_damage("break", FALSE); 1292. } 1293. if (in_town(x, y)) 1294. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 1295. if (DEADMONSTER(mtmp)) 1296. continue; 1297. if (is_watch(mtmp->data) && couldsee(mtmp->mx, mtmp->my) 1298. && mtmp->mpeaceful) { 1299. mon_yells(mtmp, "Halt, thief! You're under arrest!"); 1300. (void) angry_guards(FALSE); 1301. break; 1302. } 1303. } 1304. } else { 1305. if (Blind) 1306. feel_location(x, y); /* we know we hit it */ 1307. exercise(A_STR, TRUE); 1308. pline("WHAMMM!!!"); 1309. if (in_town(x, y)) 1310. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 1311. if (DEADMONSTER(mtmp)) 1312. continue; 1313. if (is_watch(mtmp->data) && mtmp->mpeaceful 1314. && couldsee(mtmp->mx, mtmp->my)) { 1315. if (levl[x][y].looted & D_WARNED) { 1316. mon_yells(mtmp, 1317. "Halt, vandal! You're under arrest!"); 1318. (void) angry_guards(FALSE); 1319. } else { 1320. mon_yells(mtmp, "Hey, stop damaging that door!"); 1321. levl[x][y].looted |= D_WARNED; 1322. } 1323. break; 1324. } 1325. } 1326. } 1327. return 1; 1328. } 1329. 1330. STATIC_OVL void 1331. drop_to(cc, loc) 1332. coord *cc; 1333. schar loc; 1334. { 1335. /* cover all the MIGR_xxx choices generated by down_gate() */ 1336. switch (loc) { 1337. case MIGR_RANDOM: /* trap door or hole */ 1338. if (Is_stronghold(&u.uz)) { 1339. cc->x = valley_level.dnum; 1340. cc->y = valley_level.dlevel; 1341. break; 1342. } else if (In_endgame(&u.uz) || Is_botlevel(&u.uz)) { 1343. cc->y = cc->x = 0; 1344. break; 1345. } 1346. /*FALLTHRU*/ 1347. case MIGR_STAIRS_UP: 1348. case MIGR_LADDER_UP: 1349. cc->x = u.uz.dnum; 1350. cc->y = u.uz.dlevel + 1; 1351. break; 1352. case MIGR_SSTAIRS: 1353. cc->x = sstairs.tolev.dnum; 1354. cc->y = sstairs.tolev.dlevel; 1355. break; 1356. default: 1357. case MIGR_NOWHERE: 1358. /* y==0 means "nowhere", in which case x doesn't matter */ 1359. cc->y = cc->x = 0; 1360. break; 1361. } 1362. } 1363. 1364. /* player or missile impacts location, causing objects to fall down */ 1365. void 1366. impact_drop(missile, x, y, dlev) 1367. struct obj *missile; /* caused impact, won't drop itself */ 1368. xchar x, y; /* location affected */ 1369. xchar dlev; /* if !0 send to dlev near player */ 1370. { 1371. schar toloc; 1372. register struct obj *obj, *obj2; 1373. register struct monst *shkp; 1374. long oct, dct, price, debit, robbed; 1375. boolean angry, costly, isrock; 1376. coord cc; 1377. 1378. if (!OBJ_AT(x, y)) 1379. return; 1380. 1381. toloc = down_gate(x, y); 1382. drop_to(&cc, toloc); 1383. if (!cc.y) 1384. return; 1385. 1386. if (dlev) { 1387. /* send objects next to player falling through trap door. 1388. * checked in obj_delivery(). 1389. */ 1390. toloc = MIGR_WITH_HERO; 1391. cc.y = dlev; 1392. } 1393. 1394. costly = costly_spot(x, y); 1395. price = debit = robbed = 0L; 1396. angry = FALSE; 1397. shkp = (struct monst *) 0; 1398. /* if 'costly', we must keep a record of ESHK(shkp) before 1399. * it undergoes changes through the calls to stolen_value. 1400. * the angry bit must be reset, if needed, in this fn, since 1401. * stolen_value is called under the 'silent' flag to avoid 1402. * unsavory pline repetitions. 1403. */ 1404. if (costly) { 1405. if ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0) { 1406. debit = ESHK(shkp)->debit; 1407. robbed = ESHK(shkp)->robbed; 1408. angry = !shkp->mpeaceful; 1409. } 1410. } 1411. 1412. isrock = (missile && missile->otyp == ROCK); 1413. oct = dct = 0L; 1414. for (obj = level.objects[x][y]; obj; obj = obj2) { 1415. obj2 = obj->nexthere; 1416. if (obj == missile) 1417. continue; 1418. /* number of objects in the pile */ 1419. oct += obj->quan; 1420. if (obj == uball || obj == uchain) 1421. continue; 1422. /* boulders can fall too, but rarely & never due to rocks */ 1423. if ((isrock && obj->otyp == BOULDER) 1424. || rn2(obj->otyp == BOULDER ? 30 : 3)) 1425. continue; 1426. obj_extract_self(obj); 1427. 1428. if (costly) { 1429. price += stolen_value(obj, x, y, 1430. (costly_spot(u.ux, u.uy) 1431. && index(u.urooms, 1432. *in_rooms(x, y, SHOPBASE))), 1433. TRUE); 1434. /* set obj->no_charge to 0 */ 1435. if (Has_contents(obj)) 1436. picked_container(obj); /* does the right thing */ 1437. if (obj->oclass != COIN_CLASS) 1438. obj->no_charge = 0; 1439. } 1440. 1441. add_to_migration(obj); 1442. obj->ox = cc.x; 1443. obj->oy = cc.y; 1444. obj->owornmask = (long) toloc; 1445. 1446. /* number of fallen objects */ 1447. dct += obj->quan; 1448. } 1449. 1450. if (dct && cansee(x, y)) { /* at least one object fell */ 1451. const char *what = (dct == 1L ? "object falls" : "objects fall"); 1452. 1453. if (missile) 1454. pline("From the impact, %sother %s.", 1455. dct == oct ? "the " : dct == 1L ? "an" : "", what); 1456. else if (oct == dct) 1457. pline("%s adjacent %s %s.", dct == 1L ? "The" : "All the", what, 1458. gate_str); 1459. else 1460. pline("%s adjacent %s %s.", 1461. dct == 1L ? "One of the" : "Some of the", 1462. dct == 1L ? "objects falls" : what, gate_str); 1463. } 1464. 1465. if (costly && shkp && price) { 1466. if (ESHK(shkp)->robbed > robbed) { 1467. You("removed %ld %s worth of goods!", price, currency(price)); 1468. if (cansee(shkp->mx, shkp->my)) { 1469. if (ESHK(shkp)->customer[0] == 0) 1470. (void) strncpy(ESHK(shkp)->customer, plname, PL_NSIZ); 1471. if (angry) 1472. pline("%s is infuriated!", Monnam(shkp)); 1473. else 1474. pline("\"%s, you are a thief!\"", plname); 1475. } else 1476. You_hear("a scream, \"Thief!\""); 1477. hot_pursuit(shkp); 1478. (void) angry_guards(FALSE); 1479. return; 1480. } 1481. if (ESHK(shkp)->debit > debit) { 1482. long amt = (ESHK(shkp)->debit - debit); 1483. You("owe %s %ld %s for goods lost.", Monnam(shkp), amt, 1484. currency(amt)); 1485. } 1486. } 1487. } 1488. 1489. /* NOTE: ship_object assumes otmp was FREED from fobj or invent. 1490. * <x,y> is the point of drop. otmp is _not_ an <x,y> resident: 1491. * otmp is either a kicked, dropped, or thrown object. 1492. */ 1493. boolean 1494. ship_object(otmp, x, y, shop_floor_obj) 1495. xchar x, y; 1496. struct obj *otmp; 1497. boolean shop_floor_obj; 1498. { 1499. schar toloc; 1500. xchar ox, oy; 1501. coord cc; 1502. struct obj *obj; 1503. struct trap *t; 1504. boolean nodrop, unpaid, container, impact = FALSE; 1505. long n = 0L; 1506. 1507. if (!otmp) 1508. return FALSE; 1509. if ((toloc = down_gate(x, y)) == MIGR_NOWHERE) 1510. return FALSE; 1511. drop_to(&cc, toloc); 1512. if (!cc.y) 1513. return FALSE; 1514. 1515. /* objects other than attached iron ball always fall down ladder, 1516. but have a chance of staying otherwise */ 1517. nodrop = (otmp == uball) || (otmp == uchain) 1518. || (toloc != MIGR_LADDER_UP && rn2(3)); 1519. 1520. container = Has_contents(otmp); 1521. unpaid = is_unpaid(otmp); 1522. 1523. if (OBJ_AT(x, y)) { 1524. for (obj = level.objects[x][y]; obj; obj = obj->nexthere) 1525. if (obj != otmp) 1526. n += obj->quan; 1527. if (n) 1528. impact = TRUE; 1529. } 1530. /* boulders never fall through trap doors, but they might knock 1531. other things down before plugging the hole */ 1532. if (otmp->otyp == BOULDER && ((t = t_at(x, y)) != 0) 1533. && is_hole(t->ttyp)) { 1534. if (impact) 1535. impact_drop(otmp, x, y, 0); 1536. return FALSE; /* let caller finish the drop */ 1537. } 1538. 1539. if (cansee(x, y)) 1540. otransit_msg(otmp, nodrop, n); 1541. 1542. if (nodrop) { 1543. if (impact) 1544. impact_drop(otmp, x, y, 0); 1545. return FALSE; 1546. } 1547. 1548. if (unpaid || shop_floor_obj) { 1549. if (unpaid) { 1550. (void) stolen_value(otmp, u.ux, u.uy, TRUE, FALSE); 1551. } else { 1552. ox = otmp->ox; 1553. oy = otmp->oy; 1554. (void) stolen_value( 1555. otmp, ox, oy, 1556. (costly_spot(u.ux, u.uy) 1557. && index(u.urooms, *in_rooms(ox, oy, SHOPBASE))), 1558. FALSE); 1559. } 1560. /* set otmp->no_charge to 0 */ 1561. if (container) 1562. picked_container(otmp); /* happens to do the right thing */ 1563. if (otmp->oclass != COIN_CLASS) 1564. otmp->no_charge = 0; 1565. } 1566. 1567. if (otmp->owornmask) 1568. remove_worn_item(otmp, TRUE); 1569. 1570. /* some things break rather than ship */ 1571. if (breaktest(otmp)) { 1572. const char *result; 1573. 1574. if (objects[otmp->otyp].oc_material == GLASS 1575. || otmp->otyp == EXPENSIVE_CAMERA) { 1576. if (otmp->otyp == MIRROR) 1577. change_luck(-2); 1578. result = "crash"; 1579. } else { 1580. /* penalty for breaking eggs laid by you */ 1581. if (otmp->otyp == EGG && otmp->spe && otmp->corpsenm >= LOW_PM) 1582. change_luck((schar) -min(otmp->quan, 5L)); 1583. result = "splat"; 1584. } 1585. You_hear("a muffled %s.", result); 1586. obj_extract_self(otmp); 1587. obfree(otmp, (struct obj *) 0); 1588. return TRUE; 1589. } 1590. 1591. add_to_migration(otmp); 1592. otmp->ox = cc.x; 1593. otmp->oy = cc.y; 1594. otmp->owornmask = (long) toloc; 1595. /* boulder from rolling boulder trap, no longer part of the trap */ 1596. if (otmp->otyp == BOULDER) 1597. otmp->otrapped = 0; 1598. 1599. if (impact) { 1600. /* the objs impacted may be in a shop other than 1601. * the one in which the hero is located. another 1602. * check for a shk is made in impact_drop. it is, e.g., 1603. * possible to kick/throw an object belonging to one 1604. * shop into another shop through a gap in the wall, 1605. * and cause objects belonging to the other shop to 1606. * fall down a trap door--thereby getting two shopkeepers 1607. * angry at the hero in one shot. 1608. */ 1609. impact_drop(otmp, x, y, 0); 1610. newsym(x, y); 1611. } 1612. return TRUE; 1613. } 1614. 1615. void 1616. obj_delivery(near_hero) 1617. boolean near_hero; 1618. { 1619. register struct obj *otmp, *otmp2; 1620. register int nx, ny; 1621. int where; 1622. boolean nobreak, noscatter; 1623. 1624. for (otmp = migrating_objs; otmp; otmp = otmp2) { 1625. otmp2 = otmp->nobj; 1626. if (otmp->ox != u.uz.dnum || otmp->oy != u.uz.dlevel) 1627. continue; 1628. 1629. where = (int) (otmp->owornmask & 0x7fffL); /* destination code */ 1630. if ((where & MIGR_TO_SPECIES) != 0) 1631. continue; 1632. 1633. nobreak = (where & MIGR_NOBREAK) != 0; 1634. noscatter = (where & MIGR_WITH_HERO) != 0; 1635. where &= ~(MIGR_NOBREAK | MIGR_NOSCATTER); 1636. 1637. if (!near_hero ^ (where == MIGR_WITH_HERO)) 1638. continue; 1639. 1640. obj_extract_self(otmp); 1641. otmp->owornmask = 0L; 1642. 1643. switch (where) { 1644. case MIGR_STAIRS_UP: 1645. nx = xupstair, ny = yupstair; 1646. break; 1647. case MIGR_LADDER_UP: 1648. nx = xupladder, ny = yupladder; 1649. break; 1650. case MIGR_SSTAIRS: 1651. nx = sstairs.sx, ny = sstairs.sy; 1652. break; 1653. case MIGR_WITH_HERO: 1654. nx = u.ux, ny = u.uy; 1655. break; 1656. default: 1657. case MIGR_RANDOM: 1658. nx = ny = 0; 1659. break; 1660. } 1661. if (nx > 0) { 1662. place_object(otmp, nx, ny); 1663. if (!nobreak && !IS_SOFT(levl[nx][ny].typ)) { 1664. if (where == MIGR_WITH_HERO) { 1665. if (breaks(otmp, nx, ny)) 1666. continue; 1667. } else if (breaktest(otmp)) { 1668. /* assume it broke before player arrived, no messages */ 1669. delobj(otmp); 1670. continue; 1671. } 1672. } 1673. stackobj(otmp); 1674. if (!noscatter) 1675. (void) scatter(nx, ny, rnd(2), 0, otmp); 1676. else 1677. newsym(nx, ny); 1678. } else { /* random location */ 1679. /* set dummy coordinates because there's no 1680. current position for rloco() to update */ 1681. otmp->ox = otmp->oy = 0; 1682. if (rloco(otmp) && !nobreak && breaktest(otmp)) { 1683. /* assume it broke before player arrived, no messages */ 1684. delobj(otmp); 1685. } 1686. } 1687. } 1688. } 1689. 1690. void 1691. deliver_obj_to_mon(mtmp, cnt, deliverflags) 1692. int cnt; 1693. struct monst *mtmp; 1694. unsigned long deliverflags; 1695. { 1696. struct obj *otmp, *otmp2; 1697. int where, maxobj = 1; 1698. boolean at_crime_scene = In_mines(&u.uz); 1699. 1700. if ((deliverflags & DF_RANDOM) && cnt > 1) 1701. maxobj = rnd(cnt); 1702. else if (deliverflags & DF_ALL) 1703. maxobj = 0; 1704. else 1705. maxobj = 1; 1706. 1707. cnt = 0; 1708. for (otmp = migrating_objs; otmp; otmp = otmp2) { 1709. otmp2 = otmp->nobj; 1710. where = (int) (otmp->owornmask & 0x7fffL); /* destination code */ 1711. if ((where & MIGR_TO_SPECIES) == 0) 1712. continue; 1713. 1714. if ((mtmp->data->mflags2 & otmp->corpsenm) != 0) { 1715. obj_extract_self(otmp); 1716. otmp->owornmask = 0L; 1717. otmp->ox = otmp->oy = 0; 1718. 1719. /* special treatment for orcs and their kind */ 1720. if ((otmp->corpsenm & M2_ORC) != 0 && has_oname(otmp)) { 1721. if (!has_mname(mtmp)) { 1722. if (at_crime_scene || !rn2(2)) 1723. mtmp = christen_orc(mtmp, 1724. at_crime_scene ? ONAME(otmp) 1725. : (char *) 0, 1726. /* bought the stolen goods */ 1727. " the Fence"); 1728. } 1729. free_oname(otmp); 1730. } 1731. otmp->corpsenm = 0; 1732. (void) add_to_minv(mtmp, otmp); 1733. cnt++; 1734. if (maxobj && cnt >= maxobj) 1735. break; 1736. /* getting here implies DF_ALL */ 1737. } 1738. } 1739. } 1740. 1741. STATIC_OVL void 1742. otransit_msg(otmp, nodrop, num) 1743. register struct obj *otmp; 1744. register boolean nodrop; 1745. long num; 1746. { 1747. char *optr = 0, obuf[BUFSZ], xbuf[BUFSZ]; 1748. 1749. if (otmp->otyp == CORPSE) { 1750. /* Tobjnam() calls xname() and would yield "The corpse"; 1751. we want more specific "The newt corpse" or "Medusa's corpse" */ 1752. optr = upstart(corpse_xname(otmp, (char *) 0, CXN_PFX_THE)); 1753. } else { 1754. optr = Tobjnam(otmp, (char *) 0); 1755. } 1756. Strcpy(obuf, optr); 1757. 1758. if (num) { /* means: other objects are impacted */ 1759. /* 3.6.2: use a separate buffer for the suffix to avoid risk of 1760. overrunning obuf[] (let pline() handle truncation if necessary) */ 1761. Sprintf(xbuf, " %s %s object%s", otense(otmp, "hit"), 1762. (num == 1L) ? "another" : "other", (num > 1L) ? "s" : ""); 1763. if (nodrop) 1764. Sprintf(eos(xbuf), "."); 1765. else 1766. Sprintf(eos(xbuf), " and %s %s.", otense(otmp, "fall"), gate_str); 1767. pline("%s%s", obuf, xbuf); 1768. } else if (!nodrop) 1769. pline("%s %s %s.", obuf, otense(otmp, "fall"), gate_str); 1770. } 1771. 1772. /* migration destination for objects which fall down to next level */ 1773. schar 1774. down_gate(x, y) 1775. xchar x, y; 1776. { 1777. struct trap *ttmp; 1778. 1779. gate_str = 0; 1780. /* this matches the player restriction in goto_level() */ 1781. if (on_level(&u.uz, &qstart_level) && !ok_to_quest()) 1782. return MIGR_NOWHERE; 1783. 1784. if ((xdnstair == x && ydnstair == y) 1785. || (sstairs.sx == x && sstairs.sy == y && !sstairs.up)) { 1786. gate_str = "down the stairs"; 1787. return (xdnstair == x && ydnstair == y) ? MIGR_STAIRS_UP 1788. : MIGR_SSTAIRS; 1789. } 1790. if (xdnladder == x && ydnladder == y) { 1791. gate_str = "down the ladder"; 1792. return MIGR_LADDER_UP; 1793. } 1794. 1795. if (((ttmp = t_at(x, y)) != 0 && ttmp->tseen) 1796. && is_hole(ttmp->ttyp)) { 1797. gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door" 1798. : "through the hole"; 1799. return MIGR_RANDOM; 1800. } 1801. return MIGR_NOWHERE; 1802. } 1803. 1804. /*dokick.c*/