Allow webs to be placed without a giant spider on them

Allow creating webs without spiders in the lua level scripts:

des.trap({ type = "web", spider_on_web = 0 });

Based on xNetHack commit by copperwater <aosdict@gmail.com>.

Also changes the Spider nest themed room to generate without
spiders when the level difficulty is 8 or less.
This commit is contained in:
Pasi Kallinen
2021-05-10 17:48:47 +03:00
parent 09b71fcc95
commit 1e1d580336
6 changed files with 29 additions and 15 deletions

View File

@@ -769,7 +769,7 @@ fill_ordinary_room(struct mkroom *croom)
if (x <= 1)
x = 2;
while (!rn2(x) && (++trycnt < 1000))
mktrap(0, 0, croom, (coord *) 0);
mktrap(0, MKTRAP_NOFLAGS, croom, (coord *) 0);
if (!rn2(3) && somexyspace(croom, &pos))
(void) mkgold(0L, pos.x, pos.y);
if (Is_rogue_level(&u.uz))
@@ -1322,7 +1322,7 @@ occupied(register xchar x, register xchar y)
/* make a trap somewhere (in croom if mazeflag = 0 && !tm) */
/* if tm != null, make trap at that location */
void
mktrap(int num, int mazeflag, struct mkroom *croom, coord *tm)
mktrap(int num, int mktrapflags, struct mkroom *croom, coord *tm)
{
register int kind;
struct trap *t;
@@ -1390,7 +1390,7 @@ mktrap(int num, int mazeflag, struct mkroom *croom, coord *tm)
kind = NO_TRAP;
break;
case WEB:
if (lvl < 7)
if (lvl < 7 && !(mktrapflags & MKTRAP_NOSPIDERONWEB))
kind = NO_TRAP;
break;
case STATUE_TRAP:
@@ -1427,7 +1427,7 @@ mktrap(int num, int mazeflag, struct mkroom *croom, coord *tm)
do {
if (++tryct > 200)
return;
if (mazeflag)
if (mktrapflags & MKTRAP_MAZEFLAG)
mazexy(&m);
else if (!somexy(croom, &m))
return;
@@ -1440,7 +1440,7 @@ mktrap(int num, int mazeflag, struct mkroom *croom, coord *tm)
should prevent cases where that might not happen) but be paranoid */
kind = t ? t->ttyp : NO_TRAP;
if (kind == WEB)
if (kind == WEB && !(mktrapflags & MKTRAP_NOSPIDERONWEB))
(void) makemon(&mons[PM_GIANT_SPIDER], m.x, m.y, NO_MM_FLAGS);
/* The hero isn't the only person who's entered the dungeon in

View File

@@ -1062,7 +1062,7 @@ makemaz(const char *s)
(void) mkgold(0L, mm.x, mm.y);
}
for (x = rn1(6, 7); x; x--)
mktrap(0, 1, (struct mkroom *) 0, (coord *) 0);
mktrap(0, MKTRAP_MAZEFLAG, (struct mkroom *) 0, (coord *) 0);
}
#ifdef MICRO

View File

@@ -1686,6 +1686,7 @@ create_trap(spltrap* t, struct mkroom* croom)
{
xchar x = -1, y = -1;
coord tm;
int mktrap_flags = MKTRAP_MAZEFLAG;
if (croom) {
get_free_room_loc(&x, &y, croom, t->coord);
@@ -1700,10 +1701,13 @@ create_trap(spltrap* t, struct mkroom* croom)
return;
}
if (!t->spider_on_web)
mktrap_flags |= MKTRAP_NOSPIDERONWEB;
tm.x = x;
tm.y = y;
mktrap(t->type, 1, (struct mkroom *) 0, &tm);
mktrap(t->type, mktrap_flags, (struct mkroom *) 0, &tm);
}
/*
@@ -3995,6 +3999,7 @@ get_traptype_byname(const char *trapname)
}
/* trap({ type = "hole", x = 1, y = 1 }); */
/* trap({ type = "web", spider_on_web = 0 }); */
/* trap("hole", 3, 4); */
/* trap("level teleport", {5, 8}); */
/* trap("rust") */
@@ -4008,6 +4013,8 @@ lspo_trap(lua_State* L)
create_des_coder();
tmptrap.spider_on_web = TRUE;
if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) {
const char *trapstr = luaL_checkstring(L, 1);
@@ -4030,6 +4037,8 @@ lspo_trap(lua_State* L)
get_table_xy_or_coord(L, &x, &y);
tmptrap.type = get_table_traptype_opt(L, "type", -1);
tmptrap.spider_on_web
= get_table_boolean_opt(L, "spider_on_web", 1);
}
if (tmptrap.type == NO_TRAP)