From cd85f89af12067e72343ad5c2b3a79583108464a Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 4 Jun 2022 02:00:35 -0300 Subject: Random mazes may now have random treasure chests on them. Currently disabled by default. --- npc/functions/maze.txt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/npc/functions/maze.txt b/npc/functions/maze.txt index c1a8d86d1..8cb7a2be5 100644 --- a/npc/functions/maze.txt +++ b/npc/functions/maze.txt @@ -74,7 +74,7 @@ function script CreateMaze { } ///////////////////////////////////////////////////////////////////////////////// -// InitMaze(duration=2 hours, random=yes) +// InitMaze(duration=2 hours, random_coords=yes, treasure=no) // Puts maze to work and send player there. // Exit must have been configured prior to the maze. function script InitMaze { @@ -101,7 +101,23 @@ function script InitMaze { } } while (!checknpccell(MAZE_MAP$, .@x, .@y, cell_chkpass)); + // Teleport the player warp MAZE_MAP$, .@x, .@y; + + // Add a random treasure chest if set to do so + if (getarg(2, false)) { + .@n$=instance_npcname("#T_"+MAZE_MAP$, MAZE_INST); + .@mx=getmapinfo(MAPINFO_SIZE_X, MAZE_MAP$)-20; + .@my=getmapinfo(MAPINFO_SIZE_Y, MAZE_MAP$)-20; + do { + .@x = rand2(20, .@mx); + .@y = rand2(20, .@my); + .@e += 1; + if (.@e > 20) + break; + } while (!checknpccell(MAZE_MAP$, .@x, .@y, cell_chkpass)); + movenpc(.@n$, .@x, .@y); + } return true; } -- cgit v1.2.3-60-g2f50