From 92741d91b85dfe530f4cf2be9e1993fcf7dc8e83 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 13 Oct 2019 00:56:59 -0300 Subject: Populates some data, but there's lot of missing data and meaningless data --- npc/maze0/config.txt | 111 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 99 insertions(+), 12 deletions(-) diff --git a/npc/maze0/config.txt b/npc/maze0/config.txt index 9b81fa7ed..fcaac6d30 100644 --- a/npc/maze0/config.txt +++ b/npc/maze0/config.txt @@ -5,34 +5,81 @@ // Maze generation script // Based on https://wiki.themanaworld.org/index.php/Archive:Afterlife#maze_generation // Begin script, instance is required. Maze is Saved to player data. -// Scopes: MAZE_ {ID, MX, MY} or {X_Y$} or {X_Y_ALLOWEDTYPES} +// Scopes: MAZE_ {ID, MX, MY} or {X_Y$} or {X_Y_ALLOWEDTYPES} or {X_Y_ID} +///////////////////////////////////////////////////////////////////////////////// // MazeVar(x,y,param) function script MazeVar { return "MAZE_"+getarg(0)+"_"+getarg(1)+getarg(2, ""); - end; -} - -// ParseMaze(instanceID, mapType) -function script ParseMaze { - end; } +///////////////////////////////////////////////////////////////////////////////// // WarpToMaze(instanceID, x, y) function script WarpToMaze { end; } +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +// ParseMaze(mapType, x, y) +function script ParseMaze { + .@t=getarg(0); + .@x=getarg(1); + .@y=getarg(2); + + // Prepare .@sim, the simulator array + copyarray(.@sim, + getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")), + getarraysize(getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")))); + + 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; + } + return false; +} + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// // GenerateMaze(width, height, instanceID) function script GenerateMaze { // Save maze configuration MAZE_ID=getarg(2); MAZE_MX=getarg(0); MAZE_MY=getarg(1); + freeloop(true); + + // Delete previous maze data as relevant + debugmes "[STATUS] Clean up"; + for (.@y=0; .@y < MAZE_MY; .@y++) { + for (.@x=0; .@x < MAZE_MX; .@x++) { + setd(MazeVar(.@x, .@y, "_ID"), 0); + deletearray(getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES"))); + deletearray(getd(MazeVar(.@x, .@y, "$"))); + } + } //////////////////// // SETUP .@x=0; .@y=0; + debugmes "[STATUS] Setup"; // For every column: while (.@x < MAZE_MX) { @@ -92,35 +139,75 @@ function script GenerateMaze { // End the setup loop + .@y++; } + .@x++; + .@y=0; } //////////////////// // BUILDING .@x=0; .@y=0; + debugmes "[STATUS] Build"; // For every line: while (.@y < MAZE_MY) { // For every cell: while (.@x < MAZE_MX) { + //debugmes "[STATUS] [BUILD %d %d] Running...", .@x, .@y; + // While connections weren't parsed + do { + // We start at (0,0) and go to (MAZE_MX,0) + // Then we go to (0,MAZE_MY) until (MAZE_MX,MAZE_MY) + // Shuffle the array + array_shuffle(getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES"))); + .@maze_typexy=array_pop(getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES"))); + + // XXX: MAZEMAPTYPE_NULL is also a bug + if (.@maze_typexy <= 0) { + Exception("ERROR IN MAZE BUILDER ("+.@x+","+.@y+") MTYPEXY"); + .@maze_typexy=MAZEMAPTYPE_NULL; + } + setd(MazeVar(.@x, .@y, "_ID"), .@maze_typexy); + + // Attempt to parse connections + } while (!ParseMaze(.@maze_typexy, .@x, .@y)); + // End the build loop + .@x++; } + .@y++; + .@x=0; } - end; -} + // Debug the statuses + .@x=0; .@y=0; + debugmes "[STATUS] Finishing..."; + for (.@y=0; .@y < MAZE_MY; .@y++) { + .@l$=""; + freeloop(true); + for (.@x=0; .@x < MAZE_MX; .@x++) { + //debugmes "[rpts] %d %d = %d", .@x, .@y, getd(MazeVar(.@x, .@y, "_ID")); + .@l$=.@l$+","+getd(MazeVar(.@x, .@y, "_ID")); + } + debugmes "[REPORT] %s", .@l$; + } -// ParseMaze(instanceID, mapType) -function script ParseMaze { + freeloop(false); + debugmes "[STATUS] Finished"; end; } + // One warp handler per maze map -maze0,30,30,0 script #MazeMaster NPC_HIDDEN,{ +maze0,30,30,0 script #MazeMaster NPC_MONA,{ + /* function mazeGen; function parseConnections; + */ + GenerateMaze(7, 7, 0); end; } -- cgit v1.2.3-60-g2f50