summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/map/maps.conf16
-rw-r--r--db/constants.conf22
-rw-r--r--db/map_index.txt26
-rw-r--r--maps/re/maze0.mcachebin0 -> 58 bytes
-rw-r--r--maps/re/maze1.mcachebin0 -> 60 bytes
-rw-r--r--maps/re/maze10.mcachebin0 -> 67 bytes
-rw-r--r--maps/re/maze11.mcachebin0 -> 61 bytes
-rw-r--r--maps/re/maze12.mcachebin0 -> 63 bytes
-rw-r--r--maps/re/maze13.mcachebin0 -> 61 bytes
-rw-r--r--maps/re/maze14.mcachebin0 -> 58 bytes
-rw-r--r--maps/re/maze15.mcachebin0 -> 69 bytes
-rw-r--r--maps/re/maze2.mcachebin0 -> 58 bytes
-rw-r--r--maps/re/maze3.mcachebin0 -> 61 bytes
-rw-r--r--maps/re/maze4.mcachebin0 -> 58 bytes
-rw-r--r--maps/re/maze5.mcachebin0 -> 62 bytes
-rw-r--r--maps/re/maze6.mcachebin0 -> 62 bytes
-rw-r--r--maps/re/maze7.mcachebin0 -> 64 bytes
-rw-r--r--maps/re/maze8.mcachebin0 -> 62 bytes
-rw-r--r--maps/re/maze9.mcachebin0 -> 70 bytes
-rw-r--r--npc/_import.txt16
-rw-r--r--npc/maze0/_import.txt3
-rw-r--r--npc/maze0/config.txt563
-rw-r--r--npc/maze1/_import.txt2
-rw-r--r--npc/maze10/_import.txt2
-rw-r--r--npc/maze11/_import.txt2
-rw-r--r--npc/maze12/_import.txt2
-rw-r--r--npc/maze13/_import.txt2
-rw-r--r--npc/maze14/_import.txt2
-rw-r--r--npc/maze15/_import.txt2
-rw-r--r--npc/maze2/_import.txt2
-rw-r--r--npc/maze3/_import.txt2
-rw-r--r--npc/maze4/_import.txt2
-rw-r--r--npc/maze5/_import.txt2
-rw-r--r--npc/maze6/_import.txt2
-rw-r--r--npc/maze7/_import.txt2
-rw-r--r--npc/maze8/_import.txt2
-rw-r--r--npc/maze9/_import.txt2
37 files changed, 671 insertions, 5 deletions
diff --git a/conf/map/maps.conf b/conf/map/maps.conf
index 5abef6ff7..80adc2447 100644
--- a/conf/map/maps.conf
+++ b/conf/map/maps.conf
@@ -175,6 +175,22 @@ map_list: (
"boss",
"botcheck",
"guilds",
+ "maze0",
+ "maze1",
+ "maze10",
+ "maze11",
+ "maze12",
+ "maze13",
+ "maze14",
+ "maze15",
+ "maze2",
+ "maze3",
+ "maze4",
+ "maze5",
+ "maze6",
+ "maze7",
+ "maze8",
+ "maze9",
"sec_pri",
"soren-2",
"soren",
diff --git a/db/constants.conf b/db/constants.conf
index 1703a6f33..46363deb5 100644
--- a/db/constants.conf
+++ b/db/constants.conf
@@ -4439,5 +4439,27 @@ constants_db: {
LANG_ON_SEA: 1
LANG_IN_SHIP: 2
+ comment__: "Maze Generator constants"
+ MAZEMAPTYPE_NULL: 0
+ MAZEMAPTYPE_DEADS: 1
+ MAZEMAPTYPE_DEADW: 2
+ MAZEMAPTYPE_DEADN: 3
+ MAZEMAPTYPE_DEADE: 4
+ MAZEMAPTYPE_CURVENW: 5
+ MAZEMAPTYPE_CURVENE: 6
+ MAZEMAPTYPE_CURVESW: 7
+ MAZEMAPTYPE_CURVESE: 8
+ MAZEMAPTYPE_TNWS: 9
+ MAZEMAPTYPE_TNES: 10
+ MAZEMAPTYPE_TWEN: 11
+ MAZEMAPTYPE_TWES: 12
+ MAZEMAPTYPE_LINENS: 13
+ MAZEMAPTYPE_LINEWE: 14
+ MAZEMAPTYPE_CROSS: 15
+ MAZENORTH: 0
+ MAZE_WEST: 1
+ MAZE_EAST: 2
+ MAZESOUTH: 3
+
@include "conf/import/constants.conf"
}
diff --git a/db/map_index.txt b/db/map_index.txt
index 2dc2bd3ea..0d3f836ad 100644
--- a/db/map_index.txt
+++ b/db/map_index.txt
@@ -172,8 +172,24 @@
boss 172
botcheck 173
guilds 174
-sec_pri 175
-soren-2 176
-soren 177
-test 178
-testbg 179
+maze0 175
+maze1 176
+maze10 177
+maze11 178
+maze12 179
+maze13 180
+maze14 181
+maze15 182
+maze2 183
+maze3 184
+maze4 185
+maze5 186
+maze6 187
+maze7 188
+maze8 189
+maze9 190
+sec_pri 191
+soren-2 192
+soren 193
+test 194
+testbg 195
diff --git a/maps/re/maze0.mcache b/maps/re/maze0.mcache
new file mode 100644
index 000000000..283b0f0ac
--- /dev/null
+++ b/maps/re/maze0.mcache
Binary files differ
diff --git a/maps/re/maze1.mcache b/maps/re/maze1.mcache
new file mode 100644
index 000000000..d5d4296f9
--- /dev/null
+++ b/maps/re/maze1.mcache
Binary files differ
diff --git a/maps/re/maze10.mcache b/maps/re/maze10.mcache
new file mode 100644
index 000000000..16290fe26
--- /dev/null
+++ b/maps/re/maze10.mcache
Binary files differ
diff --git a/maps/re/maze11.mcache b/maps/re/maze11.mcache
new file mode 100644
index 000000000..497547205
--- /dev/null
+++ b/maps/re/maze11.mcache
Binary files differ
diff --git a/maps/re/maze12.mcache b/maps/re/maze12.mcache
new file mode 100644
index 000000000..d797ab2a4
--- /dev/null
+++ b/maps/re/maze12.mcache
Binary files differ
diff --git a/maps/re/maze13.mcache b/maps/re/maze13.mcache
new file mode 100644
index 000000000..fa525561d
--- /dev/null
+++ b/maps/re/maze13.mcache
Binary files differ
diff --git a/maps/re/maze14.mcache b/maps/re/maze14.mcache
new file mode 100644
index 000000000..dbda4a6d7
--- /dev/null
+++ b/maps/re/maze14.mcache
Binary files differ
diff --git a/maps/re/maze15.mcache b/maps/re/maze15.mcache
new file mode 100644
index 000000000..7a68581e1
--- /dev/null
+++ b/maps/re/maze15.mcache
Binary files differ
diff --git a/maps/re/maze2.mcache b/maps/re/maze2.mcache
new file mode 100644
index 000000000..4d118cddd
--- /dev/null
+++ b/maps/re/maze2.mcache
Binary files differ
diff --git a/maps/re/maze3.mcache b/maps/re/maze3.mcache
new file mode 100644
index 000000000..f74a50ca1
--- /dev/null
+++ b/maps/re/maze3.mcache
Binary files differ
diff --git a/maps/re/maze4.mcache b/maps/re/maze4.mcache
new file mode 100644
index 000000000..f1cef24a6
--- /dev/null
+++ b/maps/re/maze4.mcache
Binary files differ
diff --git a/maps/re/maze5.mcache b/maps/re/maze5.mcache
new file mode 100644
index 000000000..0749b84a6
--- /dev/null
+++ b/maps/re/maze5.mcache
Binary files differ
diff --git a/maps/re/maze6.mcache b/maps/re/maze6.mcache
new file mode 100644
index 000000000..401869839
--- /dev/null
+++ b/maps/re/maze6.mcache
Binary files differ
diff --git a/maps/re/maze7.mcache b/maps/re/maze7.mcache
new file mode 100644
index 000000000..5debe5807
--- /dev/null
+++ b/maps/re/maze7.mcache
Binary files differ
diff --git a/maps/re/maze8.mcache b/maps/re/maze8.mcache
new file mode 100644
index 000000000..e0212bfcd
--- /dev/null
+++ b/maps/re/maze8.mcache
Binary files differ
diff --git a/maps/re/maze9.mcache b/maps/re/maze9.mcache
new file mode 100644
index 000000000..509eeb76f
--- /dev/null
+++ b/maps/re/maze9.mcache
Binary files differ
diff --git a/npc/_import.txt b/npc/_import.txt
index e5596800e..69b3b3add 100644
--- a/npc/_import.txt
+++ b/npc/_import.txt
@@ -174,6 +174,22 @@
@include "npc/boss/_import.txt"
@include "npc/botcheck/_import.txt"
@include "npc/guilds/_import.txt"
+@include "npc/maze0/_import.txt"
+@include "npc/maze1/_import.txt"
+@include "npc/maze10/_import.txt"
+@include "npc/maze11/_import.txt"
+@include "npc/maze12/_import.txt"
+@include "npc/maze13/_import.txt"
+@include "npc/maze14/_import.txt"
+@include "npc/maze15/_import.txt"
+@include "npc/maze2/_import.txt"
+@include "npc/maze3/_import.txt"
+@include "npc/maze4/_import.txt"
+@include "npc/maze5/_import.txt"
+@include "npc/maze6/_import.txt"
+@include "npc/maze7/_import.txt"
+@include "npc/maze8/_import.txt"
+@include "npc/maze9/_import.txt"
@include "npc/sec_pri/_import.txt"
@include "npc/soren-2/_import.txt"
@include "npc/soren/_import.txt"
diff --git a/npc/maze0/_import.txt b/npc/maze0/_import.txt
new file mode 100644
index 000000000..8bad6906c
--- /dev/null
+++ b/npc/maze0/_import.txt
@@ -0,0 +1,3 @@
+// Map maze0: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
+"npc/maze0/config.txt",
diff --git a/npc/maze0/config.txt b/npc/maze0/config.txt
new file mode 100644
index 000000000..1615adac5
--- /dev/null
+++ b/npc/maze0/config.txt
@@ -0,0 +1,563 @@
+// TMW2 Scripts
+// Author:
+// Jesusalva
+// Description:
+// Maze generation script (Protip: (30,30) is ALWAYS reachable - for @warp)
+// 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} or {X_Y_ID}
+
+/////////////////////////////////////////////////////////////////////////////////
+// MazeVar(x,y,param)
+function script MazeVar {
+ return "MAZE_"+getarg(0)+"_"+getarg(1)+getarg(2, "");
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+// 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;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// 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"))));
+ */
+
+ // Setup the maze connectors
+ .@v$=MazeVar(.@x, .@y);
+ switch (.@t) {
+ case MAZEMAPTYPE_NULL:
+ SetMazeCon(.@v$, "WALL", "WALL", "WALL", "WALL");
+ // It's a fallback
+ Exception("ERROR IN PARSER, FALLBACK", RB_DEBUGMES|RB_IRCBROADCAST);
+ return true;
+ 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) found %s (ID %d)", .@x, .@y, getd(MazeVar(.@x, .@y, "$["+MAZENORTH+"]")), getd(MazeVar(.@x, .@y, "_ID"));
+
+ 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
+ } else {
+ // Case 1: We're in the edge
+ if (.@y != 0) {
+ // Case 2: South direction thinks it is a wall
+ if (getd(MazeVar(.@x, .@y-1, "$["+MAZESOUTH+"]")) != "WALL")
+ return false;
+ }
+ }
+
+ //////////////////////////
+ // 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;
+
+ // 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
+ } else {
+ // Case 1: We're in the edge
+ if (.@x != 0) {
+ // Case 2: West direction thinks it is a wall
+ if (getd(MazeVar(.@x-1, .@y, "$["+MAZE_EAST+"]")) != "WALL")
+ return false;
+ }
+ }
+
+ //////////////////////////
+ // Way down
+ if (getd(.@v$+"$["+MAZESOUTH+"]") != "WALL") {
+ // Can we do this?
+
+ // Case 1: We're in the edge
+ if (.@y == MAZE_MY-1)
+ 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-1)
+ return false;
+
+ // Case 2: Right direction is invalid?
+ // TODO
+
+ // Okay, this is a valid movement, we continue
+ }
+
+ // All checks passed!
+ UpdateMazeCon(.@v$, .@x, .@y);
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// GenerateMaze(width, height) → Returns instance ID
+function script GenerateMaze {
+ // Create the Maze instance or die trying
+ .@inst = instance_create("Maze "+getcharid(0), getcharid(3), IOT_CHAR);
+ if (.@inst < 0) end;
+ MAZE_ID=.@inst;
+
+ // Save maze configuration
+ 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) {
+ // For every cell:
+ while (.@y < MAZE_MY) {
+
+ // Case 1: Left column
+ if (.@y == 0) {
+
+ // NW edge
+ if (.@x == 0)
+ setarray getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")),
+ MAZEMAPTYPE_DEADS, MAZEMAPTYPE_DEADE,
+ MAZEMAPTYPE_CURVESE;
+ // NE edge
+ else if (.@x == MAZE_MX-1)
+ setarray getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")),
+ MAZEMAPTYPE_DEADS, MAZEMAPTYPE_DEADW,
+ MAZEMAPTYPE_CURVESW;
+ // North wall
+ else
+ setarray getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")),
+ MAZEMAPTYPE_DEADS, MAZEMAPTYPE_DEADW, MAZEMAPTYPE_DEADE,
+ MAZEMAPTYPE_TWES, MAZEMAPTYPE_LINEWE,
+ MAZEMAPTYPE_CURVESE, MAZEMAPTYPE_CURVESW;
+
+
+ // Case 2: Right column
+ } else if (.@y == MAZE_MY-1) {
+
+ // SW edge
+ if (.@x == 0)
+ setarray getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")),
+ MAZEMAPTYPE_DEADN, MAZEMAPTYPE_DEADE,
+ MAZEMAPTYPE_CURVENE;
+ // SE edge
+ else if (.@x == MAZE_MX-1)
+ setarray getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")),
+ MAZEMAPTYPE_DEADN, MAZEMAPTYPE_DEADW,
+ MAZEMAPTYPE_CURVENW;
+ // South wall
+ else
+ setarray getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")),
+ MAZEMAPTYPE_DEADN, MAZEMAPTYPE_DEADW, MAZEMAPTYPE_DEADE,
+ MAZEMAPTYPE_TWEN, MAZEMAPTYPE_LINEWE,
+ MAZEMAPTYPE_CURVENE, MAZEMAPTYPE_CURVENW;
+
+
+ // Case 3: Nothing in special
+ } else {
+ setarray getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")),
+ MAZEMAPTYPE_DEADN, MAZEMAPTYPE_DEADW, MAZEMAPTYPE_DEADE, MAZEMAPTYPE_DEADS,
+ MAZEMAPTYPE_CURVENW, MAZEMAPTYPE_CURVENE, MAZEMAPTYPE_CURVESW, MAZEMAPTYPE_CURVESE,
+ MAZEMAPTYPE_TNWS, MAZEMAPTYPE_TNES, MAZEMAPTYPE_TWEN, MAZEMAPTYPE_TWES,
+ MAZEMAPTYPE_LINEWE, MAZEMAPTYPE_LINENS, MAZEMAPTYPE_CROSS;
+ }
+
+
+ // 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")));
+ freeloop(true);
+
+ if (getarraysize(getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES"))))
+ .@mztype=array_pop(getd(MazeVar(.@x, .@y, "_ALLOWEDTYPES")));
+ else
+ .@mztype=-1;
+
+ // XXX: MAZEMAPTYPE_NULL is also a bug
+ if (.@mztype <= 0) {
+ Exception("ERROR IN MAZE BUILDER ("+.@x+","+.@y+") MTYPEXY", RB_DEBUGMES|RB_IRCBROADCAST);
+ .@mztype=MAZEMAPTYPE_NULL;
+ }
+ setd(MazeVar(.@x, .@y, "_ID"), .@mztype);
+
+ // Attempt to parse connections
+ } while (!ParseMaze(.@mztype, .@x, .@y));
+
+ // End the build loop
+ .@x++;
+ }
+ .@y++;
+ .@x=0;
+ }
+
+ // 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$;
+ }
+
+
+ // Sanity Check
+ if ($@GM_OVERRIDE) {
+ for (.@y=0; .@y < MAZE_MY; .@y++) {
+ 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 "\t%s\t\t\t", .@n$;
+ debugmes "%s|%s|%s\t\t", .@w$, .@s$, .@e$;
+ }
+ debugmes "%s (%d)", .@v$, .@mid;
+ }
+ }
+
+ freeloop(false);
+ debugmes "[STATUS] Finished";
+ // Attach instance maps
+ instance_attachmap("maze0", .@inst, false, "mz0@"+getcharid(0));
+ instance_attachmap("maze1", .@inst, false, "mz1@"+getcharid(0));
+ instance_attachmap("maze2", .@inst, false, "mz2@"+getcharid(0));
+ instance_attachmap("maze3", .@inst, false, "mz3@"+getcharid(0));
+ instance_attachmap("maze4", .@inst, false, "mz4@"+getcharid(0));
+ instance_attachmap("maze5", .@inst, false, "mz5@"+getcharid(0));
+ instance_attachmap("maze6", .@inst, false, "mz6@"+getcharid(0));
+ instance_attachmap("maze7", .@inst, false, "mz7@"+getcharid(0));
+ instance_attachmap("maze8", .@inst, false, "mz8@"+getcharid(0));
+ instance_attachmap("maze9", .@inst, false, "mz9@"+getcharid(0));
+ instance_attachmap("maze10", .@inst, false, "mz10@"+getcharid(0));
+ instance_attachmap("maze11", .@inst, false, "mz11@"+getcharid(0));
+ instance_attachmap("maze12", .@inst, false, "mz12@"+getcharid(0));
+ instance_attachmap("maze13", .@inst, false, "mz13@"+getcharid(0));
+ instance_attachmap("maze14", .@inst, false, "mz14@"+getcharid(0));
+ instance_attachmap("maze15", .@inst, false, "mz15@"+getcharid(0));
+ // Instance lasts one hour
+ instance_set_timeout(3600, 3600, .@inst);
+ instance_init(.@inst);
+ return .@inst;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+// WarpToMaze(dir)
+function script WarpToMaze {
+ // Look up the destination map
+ switch (getarg(0)) {
+ case DIR_NORTH:
+ .@dst$=getd(MazeVar(MAZE_X, MAZE_Y, "$["+MAZENORTH+"]"));
+ .@x=29; .@y=38;
+ break;
+ case DIR_SOUTH:
+ .@dst$=getd(MazeVar(MAZE_X, MAZE_Y, "$["+MAZESOUTH+"]"));
+ .@x=29; .@y=21;
+ break;
+ case DIR_WEST:
+ .@dst$=getd(MazeVar(MAZE_X, MAZE_Y, "$["+MAZE_WEST+"]"));
+ .@x=38; .@y=31;
+ break;
+ case DIR_EAST:
+ .@dst$=getd(MazeVar(MAZE_X, MAZE_Y, "$["+MAZE_EAST+"]"));
+ .@x=21; .@y=31;
+ break;
+ default:
+ return Exception("INVALID DIRECTION", RB_DEFAULT|RB_ISFATAL);
+ }
+
+ // Get MAPID
+ .@id=getd("MAZE_"+.@dst$+"_ID");
+ explode(.@crd$, .@dst$, "_");
+ debugmes "%s = (%d,%d)", .@dst$, .@crd$[0], .@crd$[1];
+ // Warp you based on MAPID and update your coordinates
+ MAZE_X=atoi(.@crd$[0]);
+ MAZE_Y=atoi(.@crd$[1]);
+
+ switch (.@id) {
+ // If a special map have different warp rules, specify here
+ case MAZEMAPTYPE_NULL:
+ .@x=30; .@y=30; break;
+ }
+
+ // We don't need MAZE_ID do we?
+ warp "mz"+.@id+"@"+getcharid(0), .@x, .@y;
+ return;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+// InitMaze(maze_x, maze_y)
+function script InitMaze {
+MAZE_X=getarg(0);
+ MAZE_Y=getarg(1);
+ .@id=getd(MazeVar(MAZE_X, MAZE_Y, "_ID"));
+ warp "mz"+.@id+"@"+getcharid(0), 30, 30;
+ dispbottom l("Good luck!");
+ return;
+}
+
+// Warp NPCs
+maze1,29,39,0 script #MZSOUTH NPC_SUMMONING_CIRC,0,0,{
+ end;
+OnTouch:
+ WarpToMaze(DIR_SOUTH);
+ end;
+}
+
+maze2,20,31,0 script #MZWEST NPC_SUMMONING_CIRC,0,0,{
+ end;
+OnTouch:
+ WarpToMaze(DIR_WEST);
+ end;
+}
+
+maze3,29,20,0 script #MZNORTH NPC_SUMMONING_CIRC,0,0,{
+ end;
+OnTouch:
+ WarpToMaze(DIR_NORTH);
+ end;
+}
+
+maze4,39,31,0 script #MZEAST NPC_SUMMONING_CIRC,0,0,{
+ end;
+OnTouch:
+ WarpToMaze(DIR_EAST);
+ end;
+}
+
+maze5,29,20,0 duplicate(#MZNORTH) #MZ5N NPC_SUMMONING_CIRC,0,0
+maze5,20,31,0 duplicate(#MZWEST) #MZ5W NPC_SUMMONING_CIRC,0,0
+
+maze6,29,20,0 duplicate(#MZNORTH) #MZ6N NPC_SUMMONING_CIRC,0,0
+maze6,39,31,0 duplicate(#MZEAST) #MZ6E NPC_SUMMONING_CIRC,0,0
+
+maze7,29,39,0 duplicate(#MZSOUTH) #MZ7S NPC_SUMMONING_CIRC,0,0
+maze7,20,31,0 duplicate(#MZWEST) #MZ7W NPC_SUMMONING_CIRC,0,0
+
+maze8,29,39,0 duplicate(#MZSOUTH) #MZ8S NPC_SUMMONING_CIRC,0,0
+maze8,39,31,0 duplicate(#MZEAST) #MZ8E NPC_SUMMONING_CIRC,0,0
+
+maze9,29,20,0 duplicate(#MZNORTH) #MZ9N NPC_SUMMONING_CIRC,0,0
+maze9,20,31,0 duplicate(#MZWEST) #MZ9W NPC_SUMMONING_CIRC,0,0
+maze9,29,39,0 duplicate(#MZSOUTH) #MZ9S NPC_SUMMONING_CIRC,0,0
+
+maze10,29,20,0 duplicate(#MZNORTH) #MZ10N NPC_SUMMONING_CIRC,0,0
+maze10,39,31,0 duplicate(#MZEAST) #MZ10E NPC_SUMMONING_CIRC,0,0
+maze10,29,39,0 duplicate(#MZSOUTH) #MZ10S NPC_SUMMONING_CIRC,0,0
+
+maze11,20,31,0 duplicate(#MZWEST) #MZ11W NPC_SUMMONING_CIRC,0,0
+maze11,39,31,0 duplicate(#MZEAST) #MZ11E NPC_SUMMONING_CIRC,0,0
+maze11,29,20,0 duplicate(#MZNORTH) #MZ11N NPC_SUMMONING_CIRC,0,0
+
+maze12,20,31,0 duplicate(#MZWEST) #MZ12W NPC_SUMMONING_CIRC,0,0
+maze12,39,31,0 duplicate(#MZEAST) #MZ12E NPC_SUMMONING_CIRC,0,0
+maze12,29,39,0 duplicate(#MZSOUTH) #MZ12S NPC_SUMMONING_CIRC,0,0
+
+maze13,29,20,0 duplicate(#MZNORTH) #MZ13N NPC_SUMMONING_CIRC,0,0
+maze13,29,39,0 duplicate(#MZSOUTH) #MZ13S NPC_SUMMONING_CIRC,0,0
+
+maze14,20,31,0 duplicate(#MZWEST) #MZ14W NPC_SUMMONING_CIRC,0,0
+maze14,39,31,0 duplicate(#MZEAST) #MZ14E NPC_SUMMONING_CIRC,0,0
+
+maze15,29,20,0 duplicate(#MZNORTH) #MZ15N NPC_SUMMONING_CIRC,0,0
+maze15,20,31,0 duplicate(#MZWEST) #MZ15W NPC_SUMMONING_CIRC,0,0
+maze15,29,39,0 duplicate(#MZSOUTH) #MZ15S NPC_SUMMONING_CIRC,0,0
+maze15,39,31,0 duplicate(#MZEAST) #MZ15E NPC_SUMMONING_CIRC,0,0
+
+// Testing framework
+maze0,30,30,0 script #MazeMaster NPC_MONA,{
+ /*
+ function mazeGen;
+ function parseConnections;
+ */
+ //GenerateMaze(7, 7, 0);
+ GenerateMaze(5, 5);
+ InitMaze(0, 0);
+ end;
+}
+
+// Mapflags
+/*
+maze0 mapflag nowarpto
+maze1 mapflag nowarpto
+maze2 mapflag nowarpto
+maze3 mapflag nowarpto
+maze4 mapflag nowarpto
+maze5 mapflag nowarpto
+maze6 mapflag nowarpto
+maze7 mapflag nowarpto
+maze8 mapflag nowarpto
+maze9 mapflag nowarpto
+maze10 mapflag nowarpto
+maze11 mapflag nowarpto
+maze12 mapflag nowarpto
+maze13 mapflag nowarpto
+maze14 mapflag nowarpto
+maze15 mapflag nowarpto
+*/
+
diff --git a/npc/maze1/_import.txt b/npc/maze1/_import.txt
new file mode 100644
index 000000000..432077154
--- /dev/null
+++ b/npc/maze1/_import.txt
@@ -0,0 +1,2 @@
+// Map maze1: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze10/_import.txt b/npc/maze10/_import.txt
new file mode 100644
index 000000000..63222b4b0
--- /dev/null
+++ b/npc/maze10/_import.txt
@@ -0,0 +1,2 @@
+// Map maze10: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze11/_import.txt b/npc/maze11/_import.txt
new file mode 100644
index 000000000..11592e845
--- /dev/null
+++ b/npc/maze11/_import.txt
@@ -0,0 +1,2 @@
+// Map maze11: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze12/_import.txt b/npc/maze12/_import.txt
new file mode 100644
index 000000000..08c1110b8
--- /dev/null
+++ b/npc/maze12/_import.txt
@@ -0,0 +1,2 @@
+// Map maze12: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze13/_import.txt b/npc/maze13/_import.txt
new file mode 100644
index 000000000..b7aaf0fe3
--- /dev/null
+++ b/npc/maze13/_import.txt
@@ -0,0 +1,2 @@
+// Map maze13: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze14/_import.txt b/npc/maze14/_import.txt
new file mode 100644
index 000000000..fd0a904b8
--- /dev/null
+++ b/npc/maze14/_import.txt
@@ -0,0 +1,2 @@
+// Map maze14: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze15/_import.txt b/npc/maze15/_import.txt
new file mode 100644
index 000000000..5833ba17c
--- /dev/null
+++ b/npc/maze15/_import.txt
@@ -0,0 +1,2 @@
+// Map maze15: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze2/_import.txt b/npc/maze2/_import.txt
new file mode 100644
index 000000000..bae535704
--- /dev/null
+++ b/npc/maze2/_import.txt
@@ -0,0 +1,2 @@
+// Map maze2: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze3/_import.txt b/npc/maze3/_import.txt
new file mode 100644
index 000000000..0b54276f5
--- /dev/null
+++ b/npc/maze3/_import.txt
@@ -0,0 +1,2 @@
+// Map maze3: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze4/_import.txt b/npc/maze4/_import.txt
new file mode 100644
index 000000000..acdfbcee2
--- /dev/null
+++ b/npc/maze4/_import.txt
@@ -0,0 +1,2 @@
+// Map maze4: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze5/_import.txt b/npc/maze5/_import.txt
new file mode 100644
index 000000000..7649a951e
--- /dev/null
+++ b/npc/maze5/_import.txt
@@ -0,0 +1,2 @@
+// Map maze5: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze6/_import.txt b/npc/maze6/_import.txt
new file mode 100644
index 000000000..be1fd23a5
--- /dev/null
+++ b/npc/maze6/_import.txt
@@ -0,0 +1,2 @@
+// Map maze6: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze7/_import.txt b/npc/maze7/_import.txt
new file mode 100644
index 000000000..f73cd9310
--- /dev/null
+++ b/npc/maze7/_import.txt
@@ -0,0 +1,2 @@
+// Map maze7: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze8/_import.txt b/npc/maze8/_import.txt
new file mode 100644
index 000000000..4bbc9eb09
--- /dev/null
+++ b/npc/maze8/_import.txt
@@ -0,0 +1,2 @@
+// Map maze8: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.
diff --git a/npc/maze9/_import.txt b/npc/maze9/_import.txt
new file mode 100644
index 000000000..abccc1d00
--- /dev/null
+++ b/npc/maze9/_import.txt
@@ -0,0 +1,2 @@
+// Map maze9: Jesusalva's Trap
+// This file is generated automatically. All manually added changes will be removed when running the Converter.