summaryrefslogtreecommitdiff
path: root/npc/maze0
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-04-22 22:40:28 -0300
committerJesusaves <cpntb1@ymail.com>2020-04-22 22:40:28 -0300
commitd47fe12623e5af04e210c87eb7b656c753419565 (patch)
tree5604ba5744538638f79fbe8411aa0e50be269137 /npc/maze0
parent2370f27793d03b12763283e5fdf9807edb136a15 (diff)
downloadserverdata-d47fe12623e5af04e210c87eb7b656c753419565.tar.gz
serverdata-d47fe12623e5af04e210c87eb7b656c753419565.tar.bz2
serverdata-d47fe12623e5af04e210c87eb7b656c753419565.tar.xz
serverdata-d47fe12623e5af04e210c87eb7b656c753419565.zip
Extra debug code
Diffstat (limited to 'npc/maze0')
-rw-r--r--npc/maze0/config.txt128
1 files changed, 127 insertions, 1 deletions
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
@@ -41,6 +41,58 @@ function script UpdateMazeCon {
}
/////////////////////////////////////////////////////////////////////////////////
+// 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;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// ParseMaze(mapType, x, y)
@@ -217,6 +269,67 @@ function script ParseMaze {
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
+// 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;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
// GenerateMaze(width, height) → Returns instance ID
function script GenerateMaze {
// Create the Maze instance or die trying
@@ -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;