From ec71b5552d0e2270677d6769239f5276c6c890dc Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 13 Oct 2019 01:47:26 -0300 Subject: More data --- npc/maze0/config.txt | 206 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 186 insertions(+), 20 deletions(-) diff --git a/npc/maze0/config.txt b/npc/maze0/config.txt index 7a8ac3d31..36a520ee5 100644 --- a/npc/maze0/config.txt +++ b/npc/maze0/config.txt @@ -19,6 +19,33 @@ function script WarpToMaze { end; } +///////////////////////////////////////////////////////////////////////////////// +// SetMazeCon(Maze, north, west, east, south) +function script SetMazeCon { + setd(getarg(0)+"$["+MAZENORTH+"]", getarg(1)); + setd(getarg(0)+"$["+MAZE_WEST+"]", getarg(2)); + setd(getarg(0)+"$["+MAZE_EAST+"]", getarg(3)); + setd(getarg(0)+"$["+MAZESOUTH+"]", getarg(4)); + return; +} + +///////////////////////////////////////////////////////////////////////////////// +// UpdateMazeCon(Maze, x, y) +function script UpdateMazeCon { + if (getd(getarg(0)+"$["+MAZENORTH+"]") != "WALL") + setd(getarg(0)+"$["+MAZENORTH+"]", str(getarg(1))+"_"+str(getarg(2)+1)); + + if (getd(getarg(0)+"$["+MAZE_WEST+"]") != "WALL") + setd(getarg(0)+"$["+MAZE_WEST+"]", str(getarg(1)-1)+"_"+str(getarg(2))); + + if (getd(getarg(0)+"$["+MAZE_EAST+"]") != "WALL") + setd(getarg(0)+"$["+MAZE_EAST+"]", str(getarg(1)+1)+"_"+str(getarg(2))); + + if (getd(getarg(0)+"$["+MAZESOUTH+"]") != "WALL") + setd(getarg(0)+"$["+MAZESOUTH+"]", str(getarg(1))+"_"+str(getarg(2)+1)); + return; +} + ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// @@ -28,31 +55,149 @@ function script ParseMaze { .@x=getarg(1); .@y=getarg(2); + /* // Prepare .@sim, the simulator array copyarray(.@sim, getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")), getarraysize(getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")))); + */ + + // Setup the maze connectors + .@v$=MazeVar(.@x, .@y); + switch (.@t) { + case MAZEMAPTYPE_NULL: + SetMazeCon(.@v$, "WALL", "WALL", "WALL", "WALL"); + break; + + // N W E S + case MAZEMAPTYPE_DEADS: + SetMazeCon(.@v$, "WALL", "WALL", "WALL", ""); + break; + case MAZEMAPTYPE_DEADW: + SetMazeCon(.@v$, "WALL", "", "WALL", "WALL"); + break; + case MAZEMAPTYPE_DEADN: + SetMazeCon(.@v$, "", "WALL", "WALL", "WALL"); + break; + case MAZEMAPTYPE_DEADE: + SetMazeCon(.@v$, "WALL", "WALL", "", "WALL"); + break; + + // N W E S + case MAZEMAPTYPE_CURVENW: + SetMazeCon(.@v$, "", "", "WALL", "WALL"); + break; + case MAZEMAPTYPE_CURVENE: + SetMazeCon(.@v$, "", "WALL", "", "WALL"); + break; + case MAZEMAPTYPE_CURVESW: + SetMazeCon(.@v$, "WALL", "", "WALL", ""); + break; + case MAZEMAPTYPE_CURVESE: + SetMazeCon(.@v$, "WALL", "WALL", "", ""); + break; + + // N W E S + case MAZEMAPTYPE_TNWS: + SetMazeCon(.@v$, "", "", "WALL", ""); + break; + case MAZEMAPTYPE_TNES: + SetMazeCon(.@v$, "", "WALL", "", ""); + break; + case MAZEMAPTYPE_TWEN: + SetMazeCon(.@v$, "", "", "", "WALL"); + break; + case MAZEMAPTYPE_TWES: + SetMazeCon(.@v$, "WALL", "", "", ""); + break; + + // N W E S + case MAZEMAPTYPE_LINENS: + SetMazeCon(.@v$, "", "WALL", "WALL", ""); + break; + case MAZEMAPTYPE_LINEWE: + SetMazeCon(.@v$, "WALL", "", "", "WALL"); + break; + + // N W E S + case MAZEMAPTYPE_CROSS: + SetMazeCon(.@v$, "", "", "", ""); + break; + } + + // Now that connectors are set, we do simulations + /* + debugmes "(%d, %d) is with north %s (ID %d)", .@x, .@y, getd(MazeVar(.@x, .@y, "$["+MAZENORTH+"]")), getd(MazeVar(.@x, .@y, "_ID")); + debugmes ".@v$ is %s", .@v$; + debugmes ".@v$[NORTH] is %s", getd(.@v$+"$["+MAZENORTH+"]"); + */ + + ////////////////////////// + // Way north + if (getd(.@v$+"$["+MAZENORTH+"]") != "WALL") { + // Does north map accept this? + //debugmes "(%d, %d) is worth proccessing in NORTH", .@x, .@y; + + // Case 1: We're in the edge + if (.@y == 0) + return false; + + // Case 2: South direction thinks it is a wall + if (getd(MazeVar(.@x, .@y-1, "$["+MAZESOUTH+"]")) == "WALL") + return false; + + //debugmes "(%d, %d) found %s (ID %d)", .@x, .@y, getd(MazeVar(.@x, .@y-1, "$["+MAZESOUTH+"]")), getd(MazeVar(.@x, .@y-1, "_ID")); + // Okay, this is a valid movement, we continue + } + ////////////////////////// + // Way west + if (getd(.@v$+"$["+MAZE_WEST+"]") != "WALL") { + // Does west map accept this? + + // Case 1: We're in the edge + if (.@x == 0) + return false; - switch (@t) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - return true; + // Case 2: West direction thinks it is a wall + if (getd(MazeVar(.@x-1, .@y, "$["+MAZE_EAST+"]")) == "WALL") + return false; + + // Okay, this is a valid movement, we continue + } + + ////////////////////////// + // Way down + if (getd(.@v$+"$["+MAZESOUTH+"]") != "WALL") { + // Can we do this? + + // Case 1: We're in the edge + if (.@y == MAZE_MY) + return false; + + // Case 2: Down direction is invalid? + // TODO + + // Okay, this is a valid movement, we continue + } + + ////////////////////////// + // Way east + if (getd(.@v$+"$["+MAZE_EAST+"]") != "WALL") { + // Can we do this? + + // Case 1: We're in the edge + if (.@x == MAZE_MX) + return false; + + // Case 2: Right direction is invalid? + // TODO + + // Okay, this is a valid movement, we continue } - return false; + + // All checks passed! + UpdateMazeCon(.@v$, .@x, .@y); + return true; } ///////////////////////////////////////////////////////////////////////////////// @@ -155,6 +300,7 @@ function script GenerateMaze { while (.@y < MAZE_MY) { // For every cell: while (.@x < MAZE_MX) { + freeloop(true); //debugmes "[STATUS] [BUILD %d %d] Running...", .@x, .@y; // While connections weren't parsed @@ -195,6 +341,25 @@ function script GenerateMaze { debugmes "[REPORT] %s", .@l$; } + + // Sanity Check + for (.@y=0; .@y < MAZE_MY; .@y++) { + freeloop(true); + for (.@x=0; .@x < MAZE_MX; .@x++) { + .@mid=getd(MazeVar(.@x, .@y, "_ID")); + .@v$=MazeVar(.@x, .@y); + .@n$=getd(.@v$+"$["+MAZENORTH+"]"); + .@w$=getd(.@v$+"$["+MAZE_WEST+"]"); + .@e$=getd(.@v$+"$["+MAZE_EAST+"]"); + .@s$=getd(.@v$+"$["+MAZESOUTH+"]"); + debugmes "%s (%d): %s ", .@v$, .@mid, .@n$; + //debugmes "%s | %s | %s", .@w$, .@s$, .@e$; + + } + debugmes "[REPORT] %s", .@l$; + } + + freeloop(false); debugmes "[STATUS] Finished"; end; @@ -207,7 +372,8 @@ maze0,30,30,0 script #MazeMaster NPC_MONA,{ function mazeGen; function parseConnections; */ - GenerateMaze(7, 7, 0); + //GenerateMaze(7, 7, 0); + GenerateMaze(5, 5, 0); end; } -- cgit v1.2.3-60-g2f50