| 1489 | } |
| 1490 | |
| 1491 | void |
| 1492 | tele_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 | |
| 1537 | void |
| 1538 | level_tele_trap(struct trap *trap, unsigned int trflags) |
no test coverage detected