MCPcopy Index your code
hub / github.com/NetHack/NetHack / hit_bars

Function hit_bars

src/mthrowu.c:1416–1495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1414}
1415
1416void
1417hit_bars(
1418 struct obj **objp, /* *objp will be set to NULL if object breaks */
1419 coordxy objx, coordxy objy, /* hero's (when wielded) or missile's spot */
1420 coordxy barsx, coordxy barsy, /* adjacent spot where bars are located */
1421 unsigned breakflags) /* breakage control */
1422{
1423 struct obj *otmp = *objp;
1424 int obj_type = otmp->otyp;
1425 boolean nodissolve = (levl[barsx][barsy].wall_info & W_NONDIGGABLE) != 0,
1426 your_fault = (breakflags & BRK_BY_HERO) != 0,
1427 melee_attk = (breakflags & BRK_MELEE) != 0;
1428 int noise = 0;
1429
1430 if (your_fault
1431 ? hero_breaks(otmp, objx, objy, breakflags)
1432 : breaks(otmp, objx, objy)) {
1433 *objp = 0; /* object is now gone */
1434 /* breakage makes its own noises */
1435 if (obj_type == POT_ACID) {
1436 if (cansee(barsx, barsy) && !nodissolve) {
1437 pline_The("iron bars are dissolved!");
1438 } else {
1439 Soundeffect(se_angry_snakes, 100);
1440 You_hear(Hallucination ? "angry snakes!"
1441 : "a hissing noise.");
1442 }
1443 if (!nodissolve)
1444 dissolve_bars(barsx, barsy);
1445 }
1446 } else {
1447 if (!Deaf) {
1448 static enum sound_effect_entries se[] = {
1449 se_zero_invalid,
1450 se_bars_whang, se_bars_whap, se_bars_flapp,
1451 se_bars_clink, se_bars_clonk
1452 };
1453 static const char *const barsounds[] = {
1454 "", "Whang", "Whap", "Flapp", "Clink", "Clonk"
1455 };
1456 int bsindx = (obj_type == BOULDER || obj_type == HEAVY_IRON_BALL)
1457 ? 1
1458 : harmless_missile(otmp) ? 2
1459 : is_flimsy(otmp) ? 3
1460 : (otmp->oclass == COIN_CLASS
1461 || objects[obj_type].oc_material == GOLD
1462 || objects[obj_type].oc_material == SILVER)
1463 ? 4
1464 : SIZE(barsounds) - 1;
1465
1466 Soundeffect(se[bsindx], 100);
1467 pline("%s!", barsounds[bsindx]);
1468 nhUse(se[bsindx]);
1469 }
1470 if (!(harmless_missile(otmp) || is_flimsy(otmp)))
1471 noise = 4 * 4;
1472
1473 if (your_fault && (otmp->otyp == WAR_HAMMER

Callers 2

domove_fight_ironbarsFunction · 0.85
hits_barsFunction · 0.85

Calls 11

hero_breaksFunction · 0.85
breaksFunction · 0.85
pline_TheFunction · 0.85
You_hearFunction · 0.85
dissolve_barsFunction · 0.85
harmless_missileFunction · 0.85
acurrstrFunction · 0.85
rn2Function · 0.85
YouFunction · 0.85
wake_neartoFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected