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

Function trapeffect_landmine

src/trap.c:2527–2657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2525}
2526
2527staticfn int
2528trapeffect_landmine(
2529 struct monst *mtmp,
2530 struct trap *trap,
2531 unsigned int trflags)
2532{
2533 int damage = rnd(16);
2534 /* iron shoes protect against much of the damage from the
2535 explosion, but you still take some damage (and wound legs)
2536 because they can't fully block the blast */
2537 if (wearing_iron_shoes(mtmp))
2538 damage = (damage + 3) / 4;
2539
2540 if (mtmp == &gy.youmonst) {
2541 boolean already_seen = trap->tseen;
2542 boolean forcetrap = ((trflags & FORCETRAP) != 0
2543 || (trflags & FAILEDUNTRAP) != 0);
2544 boolean forcebungle = (trflags & FORCEBUNGLE) != 0;
2545 unsigned steed_mid = 0;
2546 struct obj *saddle = 0;
2547
2548 if ((Levitation || Flying) && !forcetrap) {
2549 if (!already_seen && rn2(3))
2550 return Trap_Effect_Finished;
2551 feeltrap(trap);
2552 pline("%s %s in a pile of soil below you.",
2553 already_seen ? "There is" : "You discover",
2554 trap->madeby_u ? "the trigger of your mine" : "a trigger");
2555 if (already_seen && rn2(3))
2556 return Trap_Effect_Finished;
2557 Soundeffect(se_kaablamm_of_mine, 80);
2558 pline("KAABLAMM!!! %s %s%s off!",
2559 forcebungle ? "Your inept attempt sets"
2560 : "The air currents set",
2561 already_seen ? a_your[trap->madeby_u] : "",
2562 already_seen ? " land mine" : "it");
2563 } else {
2564 /* prevent landmine from killing steed, throwing you to
2565 * the ground, and then that same landmine affecting you
2566 * again because it hasn't been deleted yet
2567 */
2568 static boolean recursive_mine = FALSE;
2569
2570 if (recursive_mine)
2571 return Trap_Effect_Finished;
2572 feeltrap(trap);
2573 pline("KAABLAMM!!! You triggered %s land mine!",
2574 a_your[trap->madeby_u]);
2575 if (u.usteed)
2576 steed_mid = u.usteed->m_id;
2577 recursive_mine = TRUE;
2578 (void) steedintrap(trap, (struct obj *) 0);
2579 recursive_mine = FALSE;
2580 saddle = sobj_at(SADDLE, u.ux, u.uy);
2581 set_wounded_legs(LEFT_SIDE, rn1(35, 41));
2582 set_wounded_legs(RIGHT_SIDE, rn1(35, 41));
2583 exercise(A_DEX, FALSE);
2584 }

Callers 1

trapeffect_selectorFunction · 0.85

Calls 15

rndFunction · 0.85
wearing_iron_shoesFunction · 0.85
rn2Function · 0.85
feeltrapFunction · 0.85
steedintrapFunction · 0.85
sobj_atFunction · 0.85
set_wounded_legsFunction · 0.85
exerciseFunction · 0.85
losehpFunction · 0.85
blow_up_landmineFunction · 0.85
newsymFunction · 0.85

Tested by

no test coverage detected