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

Function maybe_explode_trap

src/zap.c:3593–3623  ·  view source on GitHub ↗

Maybe explode a trap hit by object otmp's effect; cancellation beam hitting a magical trap causes an explosion. Might delete the trap; won't destroy otmp. */

Source from the content-addressed store, hash-verified

3591 cancellation beam hitting a magical trap causes an explosion.
3592 Might delete the trap; won't destroy otmp. */
3593staticfn void
3594maybe_explode_trap(
3595 struct trap *ttmp,
3596 struct obj *otmp,
3597 boolean *learn_it)
3598{
3599 if (!ttmp || !otmp)
3600 return;
3601 if (otmp->otyp == WAN_CANCELLATION || otmp->otyp == SPE_CANCELLATION) {
3602 coordxy x = ttmp->tx, y = ttmp->ty;
3603
3604 if (undestroyable_trap(ttmp->ttyp)) {
3605 shieldeff(x, y);
3606 if (cansee(x, y)) {
3607 ttmp->tseen = 1;
3608 newsym(x, y);
3609 *learn_it = TRUE;
3610 }
3611 } else if (is_magical_trap(ttmp->ttyp)) {
3612 int seeit = cansee(x, y);
3613
3614 /* note: this explosion mustn't destroy otmp */
3615 explode(x, y, -WAN_CANCELLATION,
3616 20 + d(3, 6), TRAP_EXPLODE, EXPL_MAGICAL);
3617 deltrap(ttmp);
3618 newsym(x, y);
3619 if (seeit)
3620 *learn_it = TRUE;
3621 }
3622 }
3623}
3624
3625/* zap_map() occurs before hitting monsters or objects and handles wands or
3626 spells that don't dish out 'elemental' damage */

Callers 1

zap_mapFunction · 0.85

Calls 5

shieldeffFunction · 0.85
newsymFunction · 0.85
explodeFunction · 0.85
dFunction · 0.85
deltrapFunction · 0.85

Tested by

no test coverage detected