Expose scaled mazes to special level lua
Adds a new level init type which directly creates a maze,
optionally setting corridor width and wall thickness,
and removing dead ends.
des.level_init({ style = "maze", corrwid = 3, wallthick = 1, deadends = false });
This commit is contained in:
@@ -329,6 +329,7 @@ Example:
|
|||||||
|
|
||||||
des.level_init({ style = "solidfill", fg = " " });
|
des.level_init({ style = "solidfill", fg = " " });
|
||||||
des.level_init({ style = "mines", fg = ".", bg = "}", smoothed=1, joined=1, lit=0 })
|
des.level_init({ style = "mines", fg = ".", bg = "}", smoothed=1, joined=1, lit=0 })
|
||||||
|
des.level_init({ style = "maze", corrwid = 3, wallthick = 1, deadends = false });
|
||||||
|
|
||||||
=== levregion
|
=== levregion
|
||||||
|
|
||||||
|
|||||||
@@ -1340,6 +1340,7 @@ E boolean FDECL(litstate_rnd, (int));
|
|||||||
|
|
||||||
/* ### mkmaze.c ### */
|
/* ### mkmaze.c ### */
|
||||||
|
|
||||||
|
E void FDECL(create_maze, (int, int, BOOLEAN_P));
|
||||||
E void FDECL(wallification, (int, int, int, int));
|
E void FDECL(wallification, (int, int, int, int));
|
||||||
E void FDECL(fix_wall_spines, (int, int, int, int));
|
E void FDECL(fix_wall_spines, (int, int, int, int));
|
||||||
E void FDECL(walkfrom, (int, int, SCHAR_P));
|
E void FDECL(walkfrom, (int, int, SCHAR_P));
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ enum lvlinit_types {
|
|||||||
LVLINIT_NONE = 0,
|
LVLINIT_NONE = 0,
|
||||||
LVLINIT_SOLIDFILL,
|
LVLINIT_SOLIDFILL,
|
||||||
LVLINIT_MAZEGRID,
|
LVLINIT_MAZEGRID,
|
||||||
|
LVLINIT_MAZE,
|
||||||
LVLINIT_MINES,
|
LVLINIT_MINES,
|
||||||
LVLINIT_ROGUE,
|
LVLINIT_ROGUE,
|
||||||
LVLINIT_SWAMP
|
LVLINIT_SWAMP
|
||||||
@@ -110,6 +111,8 @@ typedef struct {
|
|||||||
boolean smoothed, joined;
|
boolean smoothed, joined;
|
||||||
xchar lit, walled;
|
xchar lit, walled;
|
||||||
boolean icedpools;
|
boolean icedpools;
|
||||||
|
int corrwid, wallthick;
|
||||||
|
boolean rm_deadends;
|
||||||
} lev_init;
|
} lev_init;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
+13
-9
@@ -26,7 +26,6 @@ static void FDECL(shiny_orc_stuff, (struct monst *));
|
|||||||
static void NDECL(stolen_booty);
|
static void NDECL(stolen_booty);
|
||||||
static boolean FDECL(maze_inbounds, (int, int));
|
static boolean FDECL(maze_inbounds, (int, int));
|
||||||
static void FDECL(maze_remove_deadends, (XCHAR_P));
|
static void FDECL(maze_remove_deadends, (XCHAR_P));
|
||||||
static void FDECL(create_maze, (int, int));
|
|
||||||
|
|
||||||
/* adjust a coordinate one step in the specified direction */
|
/* adjust a coordinate one step in the specified direction */
|
||||||
#define mz_move(X, Y, dir) \
|
#define mz_move(X, Y, dir) \
|
||||||
@@ -842,10 +841,10 @@ xchar typ;
|
|||||||
/* Create a maze with specified corridor width and wall thickness
|
/* Create a maze with specified corridor width and wall thickness
|
||||||
* TODO: rewrite walkfrom so it works on temp space, not levl
|
* TODO: rewrite walkfrom so it works on temp space, not levl
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
create_maze(corrwid, wallthick)
|
create_maze(corrwid, wallthick, rmdeadends)
|
||||||
int corrwid;
|
int corrwid, wallthick;
|
||||||
int wallthick;
|
boolean rmdeadends;
|
||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
coord mm;
|
coord mm;
|
||||||
@@ -855,6 +854,12 @@ int wallthick;
|
|||||||
int rdy = 0;
|
int rdy = 0;
|
||||||
int scale;
|
int scale;
|
||||||
|
|
||||||
|
if (corrwid == -1)
|
||||||
|
corrwid = rnd(4);
|
||||||
|
|
||||||
|
if (wallthick == -1)
|
||||||
|
wallthick = rnd(4) - corrwid;
|
||||||
|
|
||||||
if (wallthick < 1)
|
if (wallthick < 1)
|
||||||
wallthick = 1;
|
wallthick = 1;
|
||||||
else if (wallthick > 5)
|
else if (wallthick > 5)
|
||||||
@@ -886,7 +891,7 @@ int wallthick;
|
|||||||
maze0xy(&mm);
|
maze0xy(&mm);
|
||||||
walkfrom((int) mm.x, (int) mm.y, 0);
|
walkfrom((int) mm.x, (int) mm.y, 0);
|
||||||
|
|
||||||
if (!rn2(5))
|
if (rmdeadends)
|
||||||
maze_remove_deadends((g.level.flags.corrmaze) ? CORR : ROOM);
|
maze_remove_deadends((g.level.flags.corrmaze) ? CORR : ROOM);
|
||||||
|
|
||||||
/* restore bounds */
|
/* restore bounds */
|
||||||
@@ -1004,10 +1009,9 @@ const char *s;
|
|||||||
g.level.flags.corrmaze = !rn2(3);
|
g.level.flags.corrmaze = !rn2(3);
|
||||||
|
|
||||||
if (!Invocation_lev(&u.uz) && rn2(2)) {
|
if (!Invocation_lev(&u.uz) && rn2(2)) {
|
||||||
int corrscale = rnd(4);
|
create_maze(-1, -1, !rn2(5));
|
||||||
create_maze(corrscale,rnd(4)-corrscale);
|
|
||||||
} else {
|
} else {
|
||||||
create_maze(1,1);
|
create_maze(1, 1, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g.level.flags.corrmaze)
|
if (!g.level.flags.corrmaze)
|
||||||
|
|||||||
+8
-2
@@ -2901,6 +2901,9 @@ lev_init *linit;
|
|||||||
case LVLINIT_MAZEGRID:
|
case LVLINIT_MAZEGRID:
|
||||||
lvlfill_maze_grid(2, 0, g.x_maze_max, g.y_maze_max, linit->bg);
|
lvlfill_maze_grid(2, 0, g.x_maze_max, g.y_maze_max, linit->bg);
|
||||||
break;
|
break;
|
||||||
|
case LVLINIT_MAZE:
|
||||||
|
create_maze(linit->corrwid, linit->wallthick, linit->rm_deadends);
|
||||||
|
break;
|
||||||
case LVLINIT_ROGUE:
|
case LVLINIT_ROGUE:
|
||||||
makeroguerooms();
|
makeroguerooms();
|
||||||
break;
|
break;
|
||||||
@@ -3574,10 +3577,10 @@ lspo_level_init(L)
|
|||||||
lua_State *L;
|
lua_State *L;
|
||||||
{
|
{
|
||||||
static const char *const initstyles[] = {
|
static const char *const initstyles[] = {
|
||||||
"solidfill", "mazegrid", "rogue", "mines", "swamp", NULL
|
"solidfill", "mazegrid", "maze", "rogue", "mines", "swamp", NULL
|
||||||
};
|
};
|
||||||
static const int initstyles2i[] = {
|
static const int initstyles2i[] = {
|
||||||
LVLINIT_SOLIDFILL, LVLINIT_MAZEGRID, LVLINIT_ROGUE,
|
LVLINIT_SOLIDFILL, LVLINIT_MAZEGRID, LVLINIT_MAZE, LVLINIT_ROGUE,
|
||||||
LVLINIT_MINES, LVLINIT_SWAMP, 0
|
LVLINIT_MINES, LVLINIT_SWAMP, 0
|
||||||
};
|
};
|
||||||
lev_init init_lev;
|
lev_init init_lev;
|
||||||
@@ -3597,6 +3600,9 @@ lua_State *L;
|
|||||||
init_lev.lit = get_table_int_or_random(L, "lit", -1); /* TODO: allow lit=BOOL */
|
init_lev.lit = get_table_int_or_random(L, "lit", -1); /* TODO: allow lit=BOOL */
|
||||||
init_lev.walled = get_table_boolean_opt(L, "walled", 0);
|
init_lev.walled = get_table_boolean_opt(L, "walled", 0);
|
||||||
init_lev.filling = get_table_mapchr_opt(L, "filling", init_lev.fg);
|
init_lev.filling = get_table_mapchr_opt(L, "filling", init_lev.fg);
|
||||||
|
init_lev.corrwid = get_table_int_opt(L, "corrwid", -1);
|
||||||
|
init_lev.wallthick = get_table_int_opt(L, "wallthick", -1);
|
||||||
|
init_lev.rm_deadends = !get_table_boolean_opt(L, "deadends", 1);
|
||||||
|
|
||||||
g.coder->lvl_is_joined = init_lev.joined;
|
g.coder->lvl_is_joined = init_lev.joined;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user