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

Function tele_trap

src/teleport.c:1491–1535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1489}
1490
1491void
1492tele_trap(struct trap *trap)
1493{
1494 /* a fixed-destination teleport trap could theoretically place hero onto a
1495 * second teleport trap; prevent the recursive call from spoteffects() from
1496 * triggering the trap at the destination */
1497 static boolean in_tele_trap = FALSE;
1498 if (in_tele_trap)
1499 return;
1500
1501 in_tele_trap = TRUE;
1502 if (In_endgame(&u.uz) || Antimagic || noteleport_level(&gy.youmonst)) {
1503 if (Antimagic)
1504 shieldeff(u.ux, u.uy);
1505 You_feel("a wrenching sensation.");
1506 } else if (!next_to_u()) {
1507 You1(shudder_for_moment);
1508 } else if (trap->once) {
1509 deltrap(trap);
1510 newsym(u.ux, u.uy); /* get rid of trap symbol */
1511 vault_tele();
1512 } else if (isok(trap->teledest.x, trap->teledest.y)) {
1513 coord cc;
1514 struct monst *mtmp = m_at(trap->teledest.x, trap->teledest.y);
1515
1516 settrack();
1517 if (mtmp) {
1518 if (!enexto(&cc, mtmp->mx, mtmp->my, mtmp->data)) {
1519 /* could not find some other place to put mtmp; the level must
1520 * be nearly or completely full */
1521 You1(shudder_for_moment);
1522 }
1523 else {
1524 rloc_to(mtmp, cc.x, cc.y);
1525 mtmp = (struct monst *) 0; /* no longer a monster at dest */
1526 }
1527 }
1528 if (!mtmp) {
1529 teleds(trap->teledest.x, trap->teledest.y, TELEDS_TELEPORT);
1530 }
1531 } else
1532 tele();
1533
1534 in_tele_trap = FALSE;
1535}
1536
1537void
1538level_tele_trap(struct trap *trap, unsigned int trflags)

Callers 1

trapeffect_telep_trapFunction · 0.85

Calls 13

noteleport_levelFunction · 0.85
shieldeffFunction · 0.85
You_feelFunction · 0.85
next_to_uFunction · 0.85
deltrapFunction · 0.85
newsymFunction · 0.85
vault_teleFunction · 0.85
isokFunction · 0.85
settrackFunction · 0.85
enextoFunction · 0.85
rloc_toFunction · 0.85
teledsFunction · 0.85

Tested by

no test coverage detected