summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2023-10-08 01:38:40 -0300
committerJesusaves <cpntb1@ymail.com>2023-10-08 01:38:40 -0300
commite550b02b60a81b9d8b4882325e124df983ff5c2b (patch)
treebe0c0606ab0978c9e7c461c140eb3ece93201910
parenta05eca80ef42342be07756416be5f6b782941cc4 (diff)
downloadserverdata-e550b02b60a81b9d8b4882325e124df983ff5c2b.tar.gz
serverdata-e550b02b60a81b9d8b4882325e124df983ff5c2b.tar.bz2
serverdata-e550b02b60a81b9d8b4882325e124df983ff5c2b.tar.xz
serverdata-e550b02b60a81b9d8b4882325e124df983ff5c2b.zip
Update Maze code to work with IOT_NONE (requires special care).
Prepare 026-4 and 026-5 (mobs do not respawn) - they're not yet usable.
-rw-r--r--npc/026-4/ctrl.c16
-rw-r--r--npc/026-5/ctrl.c16
-rw-r--r--npc/functions/maze.txt60
3 files changed, 72 insertions, 20 deletions
diff --git a/npc/026-4/ctrl.c b/npc/026-4/ctrl.c
index 3398452d6..3419ac496 100644
--- a/npc/026-4/ctrl.c
+++ b/npc/026-4/ctrl.c
@@ -10,5 +10,21 @@
- script Impregnable#B4F NPC_HIDDEN,{
end;
+// On Tuesday, the map changes
+OnTue0000:
+ // TODO: Reload .InstId
+ //MazeMobs(145, false, 10, "026-4"); // Initiate Lv 145 mobs
+ end;
+
+// Initialize the dungeon
+OnInit:
+ sleep(6000); // Delay 6s before initialization
+ .InstId = CreateMaze(IOT_NONE, MAZE_SIZE_X, "026-4");
+ instance_set_timeout(0, 0, .InstId);
+ instance_init(.InstId);
+ debugmes "Impregnable Fortress B4F (%d): Init OK", .InstId;
+ MazeMobs(145, false, 10, "026-4"); // Initiate Lv 145 mobs
+ // TODO: Add the utilities
+ end;
}
diff --git a/npc/026-5/ctrl.c b/npc/026-5/ctrl.c
index 9255a145c..04de1832a 100644
--- a/npc/026-5/ctrl.c
+++ b/npc/026-5/ctrl.c
@@ -11,5 +11,21 @@
- script Impregnable#B5F NPC_HIDDEN,{
end;
+// On Tuesday, the map changes
+OnTue0000:
+ // TODO: Reload .InstId
+ //MazeMobs(145, false, 10, "026-4"); // Initiate Lv 145 mobs
+ end;
+
+// Initialize the dungeon
+OnInit:
+ sleep(7000); // Delay 7s before initialization
+ .InstId = CreateMaze(IOT_NONE, MAZE_SIZE_A, "026-5");
+ instance_set_timeout(0, 0, .InstId);
+ instance_init(.InstId);
+ debugmes "Impregnable Fortress B5F (%d): Init OK", .InstId;
+ MazeMobs(145, false, 10, "026-5"); // Initiate Lv 145 mobs
+ // TODO: Add the utilities
+ end;
}
diff --git a/npc/functions/maze.txt b/npc/functions/maze.txt
index b5dbf55a8..d03160c18 100644
--- a/npc/functions/maze.txt
+++ b/npc/functions/maze.txt
@@ -9,7 +9,7 @@
// MAZE_INST → Instance ID of the Maze
/////////////////////////////////////////////////////////////////////////////////
-// CreateMaze(scope=IOT_CHAR{, size=MAZE_SIZE_S})
+// CreateMaze(scope=IOT_CHAR{, size=MAZE_SIZE_S, name})
// Creates the maze instances so they can be configured
// But does not initializes anything.
function script CreateMaze {
@@ -44,19 +44,20 @@ function script CreateMaze {
setarray .@ids[.@p], 70, 71, 72, 73, 74, 75;
}
- // Get a random maze, but it must not be repeated
- do
- {
- .@r = any_of(.@ids);
- if (MAZE_ID == .@r)
- continue;
- MAZE_ID = .@r;
+ // Maze is not yet started
+ if (.@scope == IOT_CHAR) {
+ /////////////////////////////////////////////////////////////////////////
+ // Get a random maze, but it must not be repeated
+ do
+ {
+ .@r = any_of(.@ids);
+ if (MAZE_ID == .@r)
+ continue;
+ MAZE_ID = .@r;
- .@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) {
@@ -65,12 +66,30 @@ function script CreateMaze {
}
// Attach map
instance_attachmap(.@MAZEMP$, MAZE_INST, false, MAZE_MAP$);
- } else {
- consolebug("Scope %d not yet supported by maze system", .@scope);
+ } while (MAZE_INST < 0);
+ return MAZE_ID;
+ } else if (.@scope == IOT_NONE) {
+ /////////////////////////////////////////////////////////////////////////
+ // If no scope is defined, it will stick to #GlobalInstanceCore
+ // Meaning - no dupe check, pretense of everlastingness
+ .@r = any_of(.@ids);
+ .@MAZEMP$=sprintf("030-%02d", .@r);
+ //MAZE_MAP$ is getarg(3)
+
+ .@inst = instance_create("Maze "+.@r+" "+getarg(2), 0, IOT_NONE);
+ // Failed
+ if (.@inst < 0) {
+ consolebug("Instance \"%s\" already exists! (Error %d)", "Maze "+.@r+" "+getarg(3), .@inst);
return 0; // Exit early
}
- } while (MAZE_INST < 0);
- return MAZE_ID;
+ // Attach map
+ instance_attachmap(.@MAZEMP$, .@inst, false, getarg(2));
+ return .@inst;
+ } else {
+ /////////////////////////////////////////////////////////////////////////
+ consolebug("Scope %d not yet supported by maze system", .@scope);
+ return 0; // Exit early
+ }
}
/////////////////////////////////////////////////////////////////////////////////
@@ -122,11 +141,12 @@ function script InitMaze {
}
/////////////////////////////////////////////////////////////////////////////////
-// MazeMobs(level=BaseLevel, chests=yes, density_redux=10)
+// MazeMobs(level=BaseLevel, chests=yes, density_redux=10, map=MAZE_MAP$)
// Puts monsters on the maze. Less density_redux is more mobs.
function script MazeMobs {
- .@mx=getmapinfo(MAPINFO_SIZE_X, MAZE_MAP$)-20;
- .@my=getmapinfo(MAPINFO_SIZE_Y, MAZE_MAP$)-20;
+ .@m$=getarg(3, MAZE_MAP$);
+ .@mx=getmapinfo(MAPINFO_SIZE_X, .@m$)-20;
+ .@my=getmapinfo(MAPINFO_SIZE_Y, .@m$)-20;
.@tl=(20-.@mx)*(20-.@my) * 3 / 10; // Total tiles + collision guess
.@tl=.@tl / getarg(2, 10) + 1; // Monster density
@@ -371,7 +391,7 @@ function script MazeMobs {
freeloop(true);
for (.@i = 0; .@i < 1+(.@tl); .@i++) {
.@mid = any_of(.@mb);
- .@m=areamonster(MAZE_MAP$, 20, 20, .@mx, .@my, strmobinfo(1, .@mid), .@mid, 1);
+ .@m=areamonster(.@m$, 20, 20, .@mx, .@my, strmobinfo(1, .@mid), .@mid, 1);
set_aggro(.@m);
}
freeloop(false);