Allow fixed-destination teleport traps

Add a theme room with multiple visible teleportation traps
which will always teleport to specific locations in the same level.

Teleport trap change from xNetHack by copperwater <aosdict@gmail.com>.
This commit is contained in:
Pasi Kallinen
2024-06-14 19:47:29 +03:00
parent a8099edca6
commit 951401e52a
6 changed files with 76 additions and 3 deletions

View File

@@ -4362,7 +4362,19 @@ lspo_trap(lua_State *L)
lua_pop(L, 1);
gl.launchplace.x = lx;
gl.launchplace.y = ly;
}
} else
lua_pop(L, 1);
lua_getfield(L, -1, "teledest");
if (lua_type(L, -1) == LUA_TTABLE) {
lua_Integer lx = -1, ly = -1;
(void) get_coord(L, -1, &lx, &ly);
lua_pop(L, 1);
gl.launchplace.x = lx;
gl.launchplace.y = ly;
} else
lua_pop(L, 1);
}
if (tmptrap.type == NO_TRAP)

View File

@@ -1098,6 +1098,8 @@ dotele(
if (next_to_u()) {
if (trap && trap_once)
vault_tele();
else if (trap && isok(trap->teledest.x, trap->teledest.y))
teleds(trap->teledest.x, trap->teledest.y, TELEDS_TELEPORT);
else
tele();
(void) next_to_u();
@@ -1450,6 +1452,20 @@ tele_trap(struct trap *trap)
deltrap(trap);
newsym(u.ux, u.uy); /* get rid of trap symbol */
vault_tele();
} else if (isok(trap->teledest.x, trap->teledest.y)) {
coord cc;
struct monst *mtmp = m_at(trap->teledest.x, trap->teledest.y);
if (mtmp) {
if (!enexto(&cc, mtmp->mx, mtmp->my, mtmp->data)) {
/* could not find some other place to put mtmp; the level must
* be nearly or completely full */
You1(shudder_for_moment);
return;
}
rloc_to(mtmp, cc.x, cc.y);
}
teleds(trap->teledest.x, trap->teledest.y, TELEDS_TELEPORT);
} else
tele();
}
@@ -1882,7 +1898,16 @@ mtele_trap(struct monst *mtmp, struct trap *trap, int in_sight)
*/
if (trap->once)
mvault_tele(mtmp);
else
else if (isok(trap->teledest.x, trap->teledest.y)) {
/* monster teleporting onto hero's or another monster's spot does
* not work the same as hero teleporting onto monster's spot where
* the incoming monster displaces the resident to the nearest
* possible space - instead it just doesn't work. */
if (!(m_at(trap->teledest.x, trap->teledest.y)
|| u_at(trap->teledest.x, trap->teledest.y))) {
rloc_to_core(mtmp, trap->teledest.x, trap->teledest.y, RLOC_MSG);
}
} else
(void) rloc(mtmp, RLOC_NONE);
if (in_sight) {

View File

@@ -541,6 +541,15 @@ maketrap(coordxy x, coordxy y, int typ)
unearth_objs(x, y);
break;
case TELEP_TRAP:
if (isok(gl.launchplace.x, gl.launchplace.y)) {
ttmp->teledest.x = gx.xstart + gl.launchplace.x;
ttmp->teledest.y = gy.ystart + gl.launchplace.y;
if (ttmp->teledest.x == x && ttmp->teledest.y == y) {
impossible("making fixed-dest tele trap pointing to itself");
}
}
break;
}
if (!oldplace) {