From d47fe12623e5af04e210c87eb7b656c753419565 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Wed, 22 Apr 2020 22:40:28 -0300 Subject: Extra debug code --- npc/maze0/config.txt | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/npc/maze0/config.txt b/npc/maze0/config.txt index 1615adac5..67d972fa4 100644 --- a/npc/maze0/config.txt +++ b/npc/maze0/config.txt @@ -40,6 +40,58 @@ function script UpdateMazeCon { return; } +///////////////////////////////////////////////////////////////////////////////// +// FindMazeTypeByCon(Maze) +function script FindMazeTypeByCon { + .@n=false;.@s=false;.@w=false;.@e=false; + if (getd(getarg(0)+"$["+MAZENORTH+"]") != "WALL") + .@n=true; + + if (getd(getarg(0)+"$["+MAZE_WEST+"]") != "WALL") + .@w=true; + + if (getd(getarg(0)+"$["+MAZE_EAST+"]") != "WALL") + .@e=true; + + if (getd(getarg(0)+"$["+MAZESOUTH+"]") != "WALL") + .@s=true; + + if (.@n && .@w && .@e && .@s) + return MAZEMAPTYPE_CROSS; + else if (.@n && .@w && .@s) + return MAZEMAPTYPE_TNWS; + else if (.@n && .@e && .@s) + return MAZEMAPTYPE_TNES; + else if (.@w && .@e && .@n) + return MAZEMAPTYPE_TEWN; + else if (.@w && .@e && .@s) + return MAZEMAPTYPE_TWES; + else if (.@n && .@w) + return MAZEMAPTYPE_CURVENW; + else if (.@n && .@e) + return MAZEMAPTYPE_CURVENE; + else if (.@s && .@w) + return MAZEMAPTYPE_CURVESW; + else if (.@s && .@w) + return MAZEMAPTYPE_CURVESE; + else if (.@n && .@s) + return MAZEMAPTYPE_LINENS; + else if (.@w && .@e) + return MAZEMAPTYPE_LINEWE; + else if (.@s) + return MAZEMAPTYPE_DEADS; + else if (.@w) + return MAZEMAPTYPE_DEADW; + else if (.@n) + return MAZEMAPTYPE_DEADN; + else if (.@e) + return MAZEMAPTYPE_DEADE; + else + return MAZEMAPTYPE_NULL; + + return -1; +} + ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// @@ -214,6 +266,67 @@ function script ParseMaze { return true; } +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +// MazeFix() → Breaks islands at cost of randomness +// runs after ParseMaze. By now, maze structure is set and working +function script MazeFix { + return; + // FIXME: BROKEN + .@x=0; .@y=0; + debugmes "(%d, %d)", MAZE_MX, MAZE_MY; + while (.@x < MAZE_MX) { + // For every cell: + while (.@y < MAZE_MY) { + .@v$=MazeVar(.@x, .@y); // Our ID + .@skip=false; + + // It need to have either a way east, or a way south + if (getd(.@v$+"$["+MAZE_EAST+"]") != "WALL") + .@skip=true; + if (getd(.@v$+"$["+MAZE_SOUTH+"]") != "WALL") + .@skip=true; + + // If it doesn't, but is an edge, we don't care + if (.@x == MAZE_MX || .@y == MAZE_MY) + .@skip=true; + + // Finally skip + if (.@skip) { + .@y++; + debugmes "(%d, %d)", .@x, .@y; + continue; + } + + // At least one of those paths must be open + if (any(true, false)) { + // Force the opening to south + .@v2$=MazeVar(.@x, .@y+1); + setd(.@v$+"$["+MAZE_SOUTH+"]", str(.@x)+"_"+str(.@y+1)); + setd(.@v2$+"$["+MAZENORTH+"]", str(.@x)+"_"+str(.@y)); + } else { + // Force the opening to east + .@v2$=MazeVar(.@x+1, .@y); + setd(.@v$+"$["+MAZE_SOUTH+"]", str(.@x+1)+"_"+str(.@y)); + setd(.@v2$+"$["+MAZENORTH+"]", str(.@x)+"_"+str(.@y)); + } + // Fix type + setd(.@v$+"_ID", FindMazeTypeByCon(.@v$)); + setd(.@v2$+"_ID", FindMazeTypeByCon(.@v2$)); + + // End the fix loop + .@y++; + debugmes "(%d, %d)", .@x, .@y; + } + .@x++; + .@y=0; + debugmes "(%d, %d)", .@x, .@y; + } + debugmes "(%d, %d)", .@x, .@y; + return; +} + ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// @@ -350,17 +463,30 @@ function script GenerateMaze { .@x=0; } + // Lose some randomness to try to ensure every place is accessible + debugmes "[STATUS] Island Fix"; + MazeFix(); + // Debug the statuses .@x=0; .@y=0; + setarray .@debug$, ".", + "↑", "→", "↓", "←", + "⮠", "⮡", "⮢", "⮣", + "ㅓ", "ㅏ", "ㅗ", "T", + "|", "—", "𐘁"; debugmes "[STATUS] Finishing..."; for (.@y=0; .@y < MAZE_MY; .@y++) { .@l$=""; + .@lb$=""; freeloop(true); for (.@x=0; .@x < MAZE_MX; .@x++) { + .@symbol$=getd(".@debug$["+getd(MazeVar(.@x, .@y, "_ID"))+"]"); //debugmes "[rpts] %d %d = %d", .@x, .@y, getd(MazeVar(.@x, .@y, "_ID")); .@l$=.@l$+","+getd(MazeVar(.@x, .@y, "_ID")); + .@lb$=.@lb$+" "+.@symbol$; } debugmes "[REPORT] %s", .@l$; + debugmes "[REPORT] %s", .@lb$; } @@ -453,7 +579,7 @@ function script WarpToMaze { ///////////////////////////////////////////////////////////////////////////////// // InitMaze(maze_x, maze_y) function script InitMaze { -MAZE_X=getarg(0); + MAZE_X=getarg(0); MAZE_Y=getarg(1); .@id=getd(MazeVar(MAZE_X, MAZE_Y, "_ID")); warp "mz"+.@id+"@"+getcharid(0), 30, 30; -- cgit v1.2.3-60-g2f50