diff options
-rw-r--r-- | npc/functions/maze.txt | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/npc/functions/maze.txt b/npc/functions/maze.txt index 23caede37..27c026c4f 100644 --- a/npc/functions/maze.txt +++ b/npc/functions/maze.txt @@ -51,26 +51,25 @@ function script CreateMaze { if (MAZE_ID == .@r) continue; MAZE_ID = .@r; - break; - } while (true); - .@MAZEMP$=sprintf("030-%02d", MAZE_ID); - MAZE_MAP$=sprintf("mz%02d@"+getcharid(0), MAZE_ID); + .@MAZEMP$=sprintf("030-%02d", MAZE_ID); + MAZE_MAP$=sprintf("mz%02d@"+getcharid(0), MAZE_ID); - // Maze is not yet started - if (.@scope == IOT_CHAR) { - MAZE_INST = instance_create("Maze "+MAZE_ID+" "+getcharid(0), getcharid(3), IOT_CHAR); - // Failed - if (MAZE_INST < 0) { - consolebug("Instance \"%s\" already exists! (Error %d)", "Maze "+MAZE_ID+" "+getcharid(0), MAZE_INST); - return 0; + // Maze is not yet started + if (.@scope == IOT_CHAR) { + MAZE_INST = instance_create("Maze "+MAZE_ID+" "+getcharid(0), getcharid(3), IOT_CHAR); + // Failed + if (MAZE_INST < 0) { + consolebug("Instance \"%s\" already exists! (Error %d)", "Maze "+MAZE_ID+" "+getcharid(0), MAZE_INST); + continue; // Get a new maze + } + // Attach map + instance_attachmap(.@MAZEMP$, MAZE_INST, false, MAZE_MAP$); + } else { + consolebug("Scope %d not yet supported by maze system", .@scope); + return 0; // Exit early } - // Attach map - instance_attachmap(.@MAZEMP$, .@inst, false, MAZE_MAP$); - } else { - consolebug("Scope %d not yet supported by maze system", .@scope); - return 0; - } + } while (MAZE_INST < 0); return MAZE_ID; } |