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