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:
+7
-8
@@ -101,22 +101,21 @@ themerooms = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
-- Spider nest
|
-- Spider nest
|
||||||
{
|
function()
|
||||||
mindiff = 10,
|
des.room({ type = "themed",
|
||||||
contents = function()
|
|
||||||
des.room({ type = "themed",
|
|
||||||
contents = function(rm)
|
contents = function(rm)
|
||||||
|
local spooders = nh.level_difficulty() > 8;
|
||||||
for x = 0, rm.width - 1 do
|
for x = 0, rm.width - 1 do
|
||||||
for y = 0, rm.height - 1 do
|
for y = 0, rm.height - 1 do
|
||||||
if (percent(30)) then
|
if (percent(30)) then
|
||||||
des.trap("web", x, y);
|
des.trap({ type = "web", x = x, y = y,
|
||||||
|
spider_on_web = spooders and percent(80) });
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
});
|
});
|
||||||
end
|
end,
|
||||||
},
|
|
||||||
|
|
||||||
-- Trap room
|
-- Trap room
|
||||||
function()
|
function()
|
||||||
|
|||||||
@@ -475,6 +475,11 @@ enum bodypart_types {
|
|||||||
#define TELEDS_ALLOW_DRAG 1
|
#define TELEDS_ALLOW_DRAG 1
|
||||||
#define TELEDS_TELEPORT 2
|
#define TELEDS_TELEPORT 2
|
||||||
|
|
||||||
|
/* flags for mktrap() */
|
||||||
|
#define MKTRAP_NOFLAGS 0x0
|
||||||
|
#define MKTRAP_MAZEFLAG 0x1 /* trap placed on coords as if in maze */
|
||||||
|
#define MKTRAP_NOSPIDERONWEB 0x2 /* web will not generate a spider */
|
||||||
|
|
||||||
#define MON_POLE_DIST 5 /* How far monsters can use pole-weapons */
|
#define MON_POLE_DIST 5 /* How far monsters can use pole-weapons */
|
||||||
#define PET_MISSILE_RANGE2 36 /* Square of distance within which pets shoot */
|
#define PET_MISSILE_RANGE2 36 /* Square of distance within which pets shoot */
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
packed_coord coord;
|
packed_coord coord;
|
||||||
xchar x, y, type;
|
xchar x, y, type;
|
||||||
|
boolean spider_on_web;
|
||||||
} spltrap;
|
} spltrap;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
+5
-5
@@ -769,7 +769,7 @@ fill_ordinary_room(struct mkroom *croom)
|
|||||||
if (x <= 1)
|
if (x <= 1)
|
||||||
x = 2;
|
x = 2;
|
||||||
while (!rn2(x) && (++trycnt < 1000))
|
while (!rn2(x) && (++trycnt < 1000))
|
||||||
mktrap(0, 0, croom, (coord *) 0);
|
mktrap(0, MKTRAP_NOFLAGS, croom, (coord *) 0);
|
||||||
if (!rn2(3) && somexyspace(croom, &pos))
|
if (!rn2(3) && somexyspace(croom, &pos))
|
||||||
(void) mkgold(0L, pos.x, pos.y);
|
(void) mkgold(0L, pos.x, pos.y);
|
||||||
if (Is_rogue_level(&u.uz))
|
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) */
|
/* make a trap somewhere (in croom if mazeflag = 0 && !tm) */
|
||||||
/* if tm != null, make trap at that location */
|
/* if tm != null, make trap at that location */
|
||||||
void
|
void
|
||||||
mktrap(int num, int mazeflag, struct mkroom *croom, coord *tm)
|
mktrap(int num, int mktrapflags, struct mkroom *croom, coord *tm)
|
||||||
{
|
{
|
||||||
register int kind;
|
register int kind;
|
||||||
struct trap *t;
|
struct trap *t;
|
||||||
@@ -1390,7 +1390,7 @@ mktrap(int num, int mazeflag, struct mkroom *croom, coord *tm)
|
|||||||
kind = NO_TRAP;
|
kind = NO_TRAP;
|
||||||
break;
|
break;
|
||||||
case WEB:
|
case WEB:
|
||||||
if (lvl < 7)
|
if (lvl < 7 && !(mktrapflags & MKTRAP_NOSPIDERONWEB))
|
||||||
kind = NO_TRAP;
|
kind = NO_TRAP;
|
||||||
break;
|
break;
|
||||||
case STATUE_TRAP:
|
case STATUE_TRAP:
|
||||||
@@ -1427,7 +1427,7 @@ mktrap(int num, int mazeflag, struct mkroom *croom, coord *tm)
|
|||||||
do {
|
do {
|
||||||
if (++tryct > 200)
|
if (++tryct > 200)
|
||||||
return;
|
return;
|
||||||
if (mazeflag)
|
if (mktrapflags & MKTRAP_MAZEFLAG)
|
||||||
mazexy(&m);
|
mazexy(&m);
|
||||||
else if (!somexy(croom, &m))
|
else if (!somexy(croom, &m))
|
||||||
return;
|
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 */
|
should prevent cases where that might not happen) but be paranoid */
|
||||||
kind = t ? t->ttyp : NO_TRAP;
|
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);
|
(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
|
/* The hero isn't the only person who's entered the dungeon in
|
||||||
|
|||||||
+1
-1
@@ -1062,7 +1062,7 @@ makemaz(const char *s)
|
|||||||
(void) mkgold(0L, mm.x, mm.y);
|
(void) mkgold(0L, mm.x, mm.y);
|
||||||
}
|
}
|
||||||
for (x = rn1(6, 7); x; x--)
|
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
|
#ifdef MICRO
|
||||||
|
|||||||
+10
-1
@@ -1686,6 +1686,7 @@ create_trap(spltrap* t, struct mkroom* croom)
|
|||||||
{
|
{
|
||||||
xchar x = -1, y = -1;
|
xchar x = -1, y = -1;
|
||||||
coord tm;
|
coord tm;
|
||||||
|
int mktrap_flags = MKTRAP_MAZEFLAG;
|
||||||
|
|
||||||
if (croom) {
|
if (croom) {
|
||||||
get_free_room_loc(&x, &y, croom, t->coord);
|
get_free_room_loc(&x, &y, croom, t->coord);
|
||||||
@@ -1700,10 +1701,13 @@ create_trap(spltrap* t, struct mkroom* croom)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!t->spider_on_web)
|
||||||
|
mktrap_flags |= MKTRAP_NOSPIDERONWEB;
|
||||||
|
|
||||||
tm.x = x;
|
tm.x = x;
|
||||||
tm.y = y;
|
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 = "hole", x = 1, y = 1 }); */
|
||||||
|
/* trap({ type = "web", spider_on_web = 0 }); */
|
||||||
/* trap("hole", 3, 4); */
|
/* trap("hole", 3, 4); */
|
||||||
/* trap("level teleport", {5, 8}); */
|
/* trap("level teleport", {5, 8}); */
|
||||||
/* trap("rust") */
|
/* trap("rust") */
|
||||||
@@ -4008,6 +4013,8 @@ lspo_trap(lua_State* L)
|
|||||||
|
|
||||||
create_des_coder();
|
create_des_coder();
|
||||||
|
|
||||||
|
tmptrap.spider_on_web = TRUE;
|
||||||
|
|
||||||
if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) {
|
if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) {
|
||||||
const char *trapstr = luaL_checkstring(L, 1);
|
const char *trapstr = luaL_checkstring(L, 1);
|
||||||
|
|
||||||
@@ -4030,6 +4037,8 @@ lspo_trap(lua_State* L)
|
|||||||
|
|
||||||
get_table_xy_or_coord(L, &x, &y);
|
get_table_xy_or_coord(L, &x, &y);
|
||||||
tmptrap.type = get_table_traptype_opt(L, "type", -1);
|
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)
|
if (tmptrap.type == NO_TRAP)
|
||||||
|
|||||||
Reference in New Issue
Block a user