MCPcopy Create free account
hub / github.com/NetHack/NetHack / mhitm_ad_legs

Function mhitm_ad_legs

src/uhitm.c:4424–4489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4422}
4423
4424void
4425mhitm_ad_legs(
4426 struct monst *magr, struct attack *mattk,
4427 struct monst *mdef, struct mhitm_data *mhm)
4428{
4429 if (magr == &gy.youmonst) {
4430 /* uhitm */
4431#if 0
4432 if (u.ucancelled) {
4433 mhm->damage = 0;
4434 return;
4435 }
4436#endif
4437 mhitm_ad_phys(magr, mattk, mdef, mhm);
4438 if (mhm->done)
4439 return;
4440 } else if (mdef == &gy.youmonst) {
4441 /* mhitu */
4442 long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE;
4443 const char *sidestr = (side == RIGHT_SIDE) ? "right" : "left",
4444 *Monst_name = Monnam(magr), *leg = body_part(LEG);
4445
4446 /* This case is too obvious to ignore, but Nethack is not in
4447 * general very good at considering height--most short monsters
4448 * still _can_ attack you when you're flying or mounted.
4449 */
4450 if ((u.usteed || Levitation || Flying) && !is_flyer(magr->data)) {
4451 pline("%s tries to reach your %s %s!", Monst_name, sidestr, leg);
4452 mhm->damage = 0;
4453 } else if (magr->mcan) {
4454 pline_mon(magr, "%s nuzzles against your %s %s!", Monnam(magr),
4455 sidestr, leg);
4456 mhm->damage = 0;
4457 } else {
4458 if (uarmf) {
4459 if (rn2(2) && (uarmf->otyp == LOW_BOOTS
4460 || uarmf->otyp == IRON_SHOES)) {
4461 pline("%s pricks the exposed part of your %s %s!",
4462 Monst_name, sidestr, leg);
4463 } else if (!rn2(5)) {
4464 pline("%s pricks through your %s boot!", Monst_name,
4465 sidestr);
4466 } else {
4467 pline("%s scratches your %s boot!", Monst_name,
4468 sidestr);
4469 mhm->damage = 0;
4470 return;
4471 }
4472 } else
4473 pline("%s pricks your %s %s!", Monst_name, sidestr, leg);
4474
4475 set_wounded_legs(side, rnd(60 - ACURR(A_DEX)));
4476 exercise(A_STR, FALSE);
4477 exercise(A_DEX, FALSE);
4478 }
4479 } else {
4480 /* mhitm */
4481 if (magr->mcan) {

Callers 1

mhitm_adtypingFunction · 0.85

Calls 9

mhitm_ad_physFunction · 0.85
rn2Function · 0.85
MonnamFunction · 0.85
body_partFunction · 0.85
pline_monFunction · 0.85
set_wounded_legsFunction · 0.85
rndFunction · 0.85
exerciseFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected