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

Function drop_boulder_on_monster

src/read.c:2340–2410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2338}
2339
2340boolean
2341drop_boulder_on_monster(coordxy x, coordxy y, boolean confused, boolean byu)
2342{
2343 struct obj *otmp2;
2344 struct monst *mtmp;
2345
2346 /* Make the object(s) */
2347 otmp2 = mksobj(confused ? ROCK : BOULDER, FALSE, FALSE);
2348 if (!otmp2)
2349 return FALSE; /* Shouldn't happen */
2350 otmp2->quan = confused ? rn1(5, 2) : 1;
2351 otmp2->owt = weight(otmp2);
2352
2353 /* Find the monster here (won't be player) */
2354 mtmp = m_at(x, y);
2355 if (mtmp && !amorphous(mtmp->data) && !passes_walls(mtmp->data)
2356 && !noncorporeal(mtmp->data) && !unsolid(mtmp->data)) {
2357 struct obj *helmet = which_armor(mtmp, W_ARMH);
2358 long mdmg;
2359
2360 if (cansee(mtmp->mx, mtmp->my)) {
2361 pline("%s is hit by %s!", Monnam(mtmp), doname(otmp2));
2362 if (mtmp->minvis && !canspotmon(mtmp))
2363 map_invisible(mtmp->mx, mtmp->my);
2364 } else if (engulfing_u(mtmp))
2365 You_hear("something hit %s %s over your %s!",
2366 s_suffix(mon_nam(mtmp)), mbodypart(mtmp, STOMACH),
2367 body_part(HEAD));
2368
2369 mdmg = dmgval(otmp2, mtmp) * otmp2->quan;
2370 if (helmet) {
2371 if (hard_helmet(helmet)) {
2372 if (canspotmon(mtmp))
2373 pline("Fortunately, %s is wearing a hard helmet.",
2374 mon_nam(mtmp));
2375 else if (!Deaf)
2376 You_hear("a clanging sound.");
2377 if (mdmg > 2)
2378 mdmg = 2;
2379 } else {
2380 if (canspotmon(mtmp))
2381 pline("%s's %s does not protect %s.", Monnam(mtmp),
2382 xname(helmet), mhim(mtmp));
2383 }
2384 }
2385 mtmp->mhp -= mdmg;
2386 if (DEADMONSTER(mtmp)) {
2387 if (byu) {
2388 killed(mtmp);
2389 } else {
2390 pline("%s is killed.", Monnam(mtmp));
2391 mondied(mtmp);
2392 }
2393 } else {
2394 wakeup(mtmp, byu);
2395 }
2396 wake_nearto(x, y, 4 * 4);
2397 } else if (engulfing_u(mtmp)) {

Callers 3

use_offensiveFunction · 0.85
seffect_earthFunction · 0.85
drop_boulder_on_playerFunction · 0.85

Calls 15

mksobjFunction · 0.85
weightFunction · 0.85
which_armorFunction · 0.85
MonnamFunction · 0.85
donameFunction · 0.85
map_invisibleFunction · 0.85
You_hearFunction · 0.85
s_suffixFunction · 0.85
mon_namFunction · 0.85
mbodypartFunction · 0.85
body_partFunction · 0.85
dmgvalFunction · 0.85

Tested by

no test coverage detected