trust me: it's stupidly huge, first area is 57,600 squares big so far
' Grid Locations
define game <Game Name>
asl-version <350>
gametype singleplayer
game version <1.0>
game author <MaDbRiT>
game copyright <© 2005 AGB>
game info <Enter any additional information about this game here.>
start <StartRoom>
startscript {
set numeric <xpos;3>
set numeric <ypos;1>
}
end define
define room <StartRoom>
look <It looks very familiar...>
north {
do <MakeExits>
goto <gridroom>
}
end define
define room <GridRoom>
script {
outputon
exec <look>
}
command <north> {
outputoff
exec <north;normal>
}
command <south> {
if (%xpos%<>3) or (%ypos%<>1) then outputoff
exec <south;normal>
}
command <west> {
outputoff
exec <west;normal>
}
command <east> {
outputoff
exec <east;normal>
}
end define
define room <North_Dummy>
script {
inc <ypos>
do <MakeExits>
goto <GridRoom>
}
end define
define room <South_Dummy>
script {
dec <ypos>
do <MakeExits>
goto <GridRoom>
}
end define
define room <East_Dummy>
script {
inc <xpos>
do <MakeExits>
goto <GridRoom>
}
end define
define room <West_Dummy>
script {
dec <xpos>
do <MakeExits>
goto <GridRoom>
}
end define
define procedure <MakeExits>
outputoff
create exit north <GridRoom;>
create exit south <GridRoom;>
create exit east <GridRoom;>
create exit west <GridRoom;>
if (%xpos% <>1) then create exit west <GridRoom; West_Dummy>
if (%xpos% <>5) then create exit east <GridRoom; East_Dummy>
if (%ypos% <>1) then create exit south <GridRoom; South_Dummy>
if (%ypos% <>5) then create exit north <GridRoom; North_Dummy>
if (%xpos% = 3) and (%ypos% =1) then create exit south <GridRoom; StartRoom>
property <Gridroom;alias=Location X=%xpos%, Y=%ypos%>
end define
define text <intro>
Enter intro text here
end define
define text <win>
Enter win text here
end define
define text <lose>
Enter lose text here
end define
+-----+-----+-----+-----+-----+
¦ ¦ ¦ ¦ ¦ ¦
+-----+-----+-----+-----+-----+
¦ ¦ ***¦ ¦ ¦ ¦
+-----+-----+-----+-----+-----+
¦ ¦ ¦ ¦ ***¦ ¦
+-----+-----+-----+-----+-----+
¦ ¦ ¦ ¦ ¦ ¦
+-----+-----+-----+-----+-----+
¦ start ¦
*** blockage.how can i make bigger areas with lots of blockages
MaDbRiT wrote:
The above method works great with minimal coding required for (say) wandering about in a featureless desert of forest or whatever, but if you want a "maze" (for want of a better word) you have to cater for too many exceptions for it to be a practical exercise.
For a maze I'd use a grid based on a simple numeric array. I won't try to explain it here because it isn't easy without an example and I'm at work presently so I don't have time to code one.
I'll knock up a simple example later, assuming "real life" doesn't get in the way...
Al (MaDbRiT)
X X
XX X XXXXXX
X X X
XXXXXXXXX
' Grid of locations within one room
define game <Grid Demo>
asl-version <350>
gametype singleplayer
game version <1.0>
game author <MaDbRiT>
game copyright <© 2005 AGB>
game info <Demo>
start <StartRoom>
startscript {
do <MakeGrid> 'This builds a 10 x 10 grid (with hard boundaries)
' Calling 'KillAccess' procedure with the cell number as a parameter closes all
' (N,S,E & W) entrances to the cell referenced.
do <KillAccess(1)>
do <KillAccess(3)>
for <x;5;11> do <KillAccess(%x%)>
for <x;20;26> do <KillAccess(%x%)>
for <x;28;30> do <KillAccess(%x%)>
for <x;42;62;10> do <KillAccess(%x%)>
for <x;44;84;10> do <KillAccess(%x%)>
for <x;82;83> do <KillAccess(%x%)>
for <x;46;47> do <KillAccess(%x%)>
for <x;49;50> do <KillAccess(%x%)>
do <KillAccess(57)>
for <x;66;70> do <KillAccess(%x%)>
do <KillAccess(77)>
do <KillAccess(89)>
for <x;96;99> do <KillAccess(%x%)>
'Open additional (special) Exits to south in Cell 95 and to north in cell 4
'These are the entry to / exit from the gridroom maze
set <grid[95];2>
set <grid[4];10>
}
end define
define room <StartRoom>
alias <a small, gloomy room.>
look <The room is completely bare and featureless.>
north {
set <gridPos;95>
do <makeExits>
goto <gridroom>
}
end define
define room <exitroom>
alias <the treasure chamber>
look <Its a bit dark and spooky.>
south {
set <gridPos;4>
do <makeExits>
goto <gridroom>
}
end define
define room <GridRoom>
script {
' msg <DEBUG: Exit code for this (%gridPos%) room is = %grid[gridPos]%>
}
alias <a maze of seemingly identical corridors>
command <north> {
set <gridPos;%gridPos%-10>
if (%gridpos%<>-6) then {
do <makeExits>
goto <GridRoom>
}
else goto <exitroom>
}
command <south> {
set <gridPos;%gridPos%+10>
if (%gridpos%<>105) then {
do <makeExits>
goto <GridRoom>
}
else goto <startroom>
}
command <east> {
set <gridPos;%gridPos%+1>
do <makeExits>
goto <GridRoom>
}
command <west> {
set <gridPos;%gridPos%-1>
do <makeExits>
goto <GridRoom>
}
end define
define room <dummy>
end define
define procedure <MakeGrid>
set numeric <gridPos;0>
' ** Set Basic boundaries of 10 x 10 grid
' ** Set exit north OFF for top row of grid
for <i;1;10> {
set numeric <grid[i];1>
}
' ** Set exit south OFF for bottom row of grid
for <i;91;100> {
set numeric <grid[i];4>
}
' ** Set exit east OFF for right row of grid
for <i;10;100;10> {
set numeric <grid[i];%grid[i]%+2>
}
' ** Set exit west OFF for left of grid
for <i;1;91;10> {
set numeric <grid[i];%grid[i]%+8>
}
end define
define procedure <makeExits>
create exit north <GridRoom;dummy>
create exit east <GridRoom;dummy>
create exit south <GridRoom;dummy>
create exit west <GridRoom;dummy>
set numeric <gridVal;%grid[gridPos]%>
if (%gridVal% >7) then {
create exit west <GridRoom;>
set <gridVal;%gridVal%-8>
}
if (%gridVal% >3) then {
create exit south <GridRoom;>
set <gridVal;%gridVal%-4>
}
if (%gridVal% >1) then {
create exit east <GridRoom;>
set <gridVal;%gridVal%-2>
}
if (%gridVal% >0) then {
create exit north <GridRoom;>
}
end define
define procedure <KillAccess>
set numeric <BlockBox;$parameter(1)$>
' In this procedure we need to modify the boxes bordering the chosen box
' rather than the box to be blocked itself. First up is to block the
' exit to this box from the south.
' Move down a row.
set <BlockBox;%BlockBox%+10>
set numeric <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8> ' Discard WEST bit
if (%ExitsBlocked% >3) then set <ExitsBlocked;%ExitsBlocked%-4> ' Discard SOUTH bit
if (%ExitsBlocked% >1) then set <ExitsBlocked;%ExitsBlocked%-2> ' Discard EAST bit
if (%ExitsBlocked% =0) then set <grid[BlockBox];%grid[BlockBox]%+1> ' Set NORTH bit if not set
'Now the access from the north.
set <BlockBox;%BlockBox%-20>
' IF Makes sure we're not in the top row, (we can ignore this stage if we are)
if (%BlockBox%>10) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8> ' Discard WEST bit
if (%ExitsBlocked% <4) then set <grid[BlockBox];%grid[BlockBox]%+4> ' Set SOUTH bit if not set
}
'Now the access from the west
set <BlockBox;%BlockBox%+9>
make sure we aren't in the leftmost columnn
set numeric <isLeftCol;0>
for <i;10;100;10> {
if (%BlockBox%=%i%) then set <isLeftCol;1>
}
if (%isLeftCol%<>1) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8> ' Discard WEST bit
if (%ExitsBlocked% >3) then set <ExitsBlocked;%ExitsBlocked%-4> ' Discard SOUTH bit
if (%ExitsBlocked% <2) then set <grid[BlockBox];%grid[BlockBox]%+2> ' Set EAST bit if not set
}
'Now the access from the east
set <BlockBox;%BlockBox%+2>
make sure we aren't in the rightmost columnn
set numeric <isRightCol;0>
for <i;1;91;10> {
if (%BlockBox%=%i%) then set <isRightCol;1>
}
if (%isRightCol%<>1) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% <8) then set <grid[BlockBox];%grid[BlockBox]%+8> ' Set WEST bit if not set
}
end define
define text <intro>
A demonstration of using one Quest room to represent a grid of locations, in this example a 10 x 10 (100 cell) grid, with lots of the cells inaccessible to form a "maze"
end define
define text <win>
Enter win text here
end define
define text <lose>
Enter lose text here
end defineI kinda don't get it, its the arrays..... help
do <KillAccess(1)>
do <KillAccess(3)>
for <x;5;11> do <KillAccess(%x%)>
for <x;20;26> do <KillAccess(%x%)>
for <x;28;30> do <KillAccess(%x%)>
for <x;42;62;10> do <KillAccess(%x%)>
for <x;44;84;10> do <KillAccess(%x%)>
for <x;82;83> do <KillAccess(%x%)> ....but then I don't understand why you go from 42 to 62 and throw a 10 in there...
for <x;42;62;10> do <KillAccess(%x%)> for <x;42;62> do <KillAccess(%x%)> for <x;42;62;10> do <KillAccess(%x%)> can you make me a general code for the array
set numeric <myvariable;10>set numeric <totalBeer;%bottle1% + %bottle2% + %bottle3%+ %bottle2% + %bottle3%+ %bottle2% + %bottle3%+ %bottle4% + %bottle5%+ %bottle6% + %bottle6%+ %bottle8% + %bottle9%+ %bottle10% + %bottle11%+ %bottle12% + %bottle13%+ %bottle14% + %bottle15%+ %bottle16% + %bottle17%+ %bottle18% + %bottle19%+ %bottle20% + %bottle21%+ %bottle22% + %bottle23%+ %bottle24% + %bottle25%+ %bottle26% + %bottle27%+ %bottle28% + %bottle29%+ %bottle30% + %bottle31%+ %bottle32% + %bottle33%+ %bottle34% + %bottle35%+ %bottle36% + %bottle37+ %bottle38% + %bottle39%
+ %bottle40% + %bottle41%+ %bottle42% + %bottle43%+ %bottle44% + %bottle45%+ %bottle46% + %bottle47%+ %bottle48% + %bottle49%+ %bottle50%>for <n;1;50> {
set numeric <totalbeer;%totalbeer% + %bottles[n]%>
}
set numeric <mostBeer;0>
set numeric <maxBeer;0>
for <n;1;50> {
if (%bottles[n]% >%maxbeer%) then {
set numeric <maxBeer;%bottles[n]%>
set numeric <mostbeer;%n%>
}
}
'This code will return the array index of the fullest bottle in the variable 'mostbeer'.
%array[34]% %array[myvariable]% can you go back and explain the logic of the maze (like the 0,1,2,4,8 thing)


I'm pretty sure I understand what your <42;62;10> means now! Since blocks 42, 52 and 62 were in the same column (and 10 cells apart), you told the program that those three blocks were inaccessible.
I'm just about completely understood on your arrays explanation.
And the binary thing, Wow! That's cool! What I'm looking at in your diagram is that depending on your total number, tells the program where the exits are.
So if your total was one (1), then your exit would be W.
If your total was fifteen (15), then all four exits are open.
If your total was nine (9), then your exits are N and W.
...and so on...
Am I right?
set <grid[95];2>
set <grid[4];10> define room <GridRoom>
script {
' msg <DEBUG: Exit code for this (%gridPos%) room is = %grid[gridPos]%>
}
alias <a maze of seemingly identical corridors>
command <north> {
set <gridPos;%gridPos%-10>
if (%gridpos%<>-6) then {
do <makeExits>
goto <GridRoom>
}
else goto <exitroom>
}
command <south> {
set <gridPos;%gridPos%+10>
if (%gridpos%<>105) then {
do <makeExits>
goto <GridRoom>
}
else goto <startroom>
}
define procedure <MakeGrid>
set numeric <gridPos;0>
' ** Set Basic boundaries of 10 x 10 grid
' ** Set exit north OFF for top row of grid
for <i;1;10> {
set numeric <grid[i];1>
}
' ** Set exit south OFF for bottom row of grid
for <i;91;100> {
set numeric <grid[i];4>
}
' ** Set exit east OFF for right row of grid
for <i;10;100;10> {
set numeric <grid[i];%grid[i]%+2>
}
' ** Set exit west OFF for left of grid
for <i;1;91;10> {
set numeric <grid[i];%grid[i]%+8>
}
end define Alright, I'm trying to break this down. In the following code from your demo, what does the 2 and 10 mean?
set <grid[95];2>
set <grid[4];10> What does the -6 and 105 in this part of the code?
...and the 91's?
for <i;91;100> {
set numeric <grid[i];4>
}
for <i;1;91;10> {
set numeric <grid[i];%grid[i]%+8>
}
I was really trying to figure this out to the very last detail. I am currently working on an 8x8 grid and I just needed to see what these certain numbers were for
' ** Set Basic boundaries of 8 x 8 grid
' ** Set exit north OFF for top row of grid
for <i;1;8> {
set numeric <grid[i];1>
}
' ** Set exit south OFF for bottom row of grid
for <i;71;80> {
set numeric <grid[i];4>
}
' ** Set exit east OFF for right row of grid
for <i;8;78;10> {
set numeric <grid[i];%grid[i]%+2>
}
' ** Set exit west OFF for left of grid
for <i;1;71;10> {
set numeric <grid[i];%grid[i]%+8>
} 
' Grid of locations within one room
define game <Grid Demo>
asl-version <350>
gametype singleplayer
game version <1.0>
game author <MaDbRiT>
game copyright <© 2005 AGB>
game info <Demo>
start <StartRoom>
startscript {
do <MakeGrid> 'This builds a 8 x 8 grid (with hard boundaries)
' Calling 'KillAccess' procedure with the cell number as a parameter
closes all
' (N,S,E & W) entrances to the cell referenced.
do <KillAccess(1)>
do <KillAccess(2)>
do <KillAccess(4)>
for <x;6;7> do <KillAccess(%x%)>
do <KillAccess(9)>
do <KillAccess(12)>
do <KillAccess(19)>
for <x;21;22> do <KillAccess(%x%)>
do <KillAccess(24)>
do <KillAccess(26)>
do <KillAccess(29)>
do <KillAccess(36)>
for <x;39;42> do <KillAccess(%x%)>
do <KillAccess(46)>
do <KillAccess(50)>
do <KillAccess(52)>
do <KillAccess(56)>
do <KillAccess(62)>
'Open additional (special) Exits to south in Cell 95 and to north in
cell 4
'These are the entry to / exit from the gridroom maze
set <grid[5];2>
}
end define
define room <StartRoom>
alias <a small, gloomy room.>
look <The room is completely bare and featureless.>
north {
set <gridPos;27>
do <makeExits>
goto <gridroom>
}
south {
set <gridPos;43>
do <makeExits>
goto <gridroom>
}
west {
set <gridPos;34>
do <makeExits>
goto <gridroom>
}
end define
define room <DoorRoom>
alias <a small, gloomy room.>
look <The room is completely bare and featureless except for a
single door to the north.>
end define
define room <GridRoom>
script {
' msg <DEBUG: Exit code for this (%gridPos%) room is =
%grid[gridPos]%>
}
alias <a maze of seemingly identical corridors>
command <north> {
set <gridPos;%gridPos%-8>
if (%gridpos%<>-3) then {
do <makeExits>
goto <GridRoom>
}
else goto <exitroom>
}
command <south> {
set <gridPos;%gridPos%+8>
' if (%gridpos%<>105) then {
'
' }
' else goto <startroom>
do <makeExits>
goto <GridRoom>
}
command <east> {
set <gridPos;%gridPos%+1>
do <makeExits>
goto <GridRoom>
}
command <west> {
set <gridPos;%gridPos%-1>
do <makeExits>
goto <GridRoom>
}
end define
define room <dummy>
end define
define procedure <MakeGrid>
set numeric <gridPos;0>
' ** Set Basic boundaries of 10 x 10 grid
' ** Set exit north OFF for top row of grid
for <i;1;8> {
set numeric <grid[i];1>
}
' ** Set exit south OFF for bottom row of grid
for <i;71;80> {
set numeric <grid[i];4>
}
' ** Set exit east OFF for right row of grid
for <i;8;78;10> {
set numeric <grid[i];%grid[i]%+2>
}
' ** Set exit west OFF for left of grid
for <i;1;71;10> {
set numeric <grid[i];%grid[i]%+8>
}
end define
define procedure <makeExits>
create exit north <GridRoom;dummy>
create exit east <GridRoom;dummy>
create exit south <GridRoom;dummy>
create exit west <GridRoom;dummy>
set numeric <gridVal;%grid[gridPos]%>
if (%gridVal% >7) then {
create exit west <GridRoom;>
set <gridVal;%gridVal%-8>
}
if (%gridVal% >3) then {
create exit south <GridRoom;>
set <gridVal;%gridVal%-4>
}
if (%gridVal% >1) then {
create exit east <GridRoom;>
set <gridVal;%gridVal%-2>
}
if (%gridVal% >0) then {
create exit north <GridRoom;>
}
end define
define procedure <KillAccess>
set numeric <BlockBox;$parameter(1)$>
' In this procedure we need to modify the boxes bordering the chosen
box
' rather than the box to be blocked itself. First up is to block the
' exit to this box from the south.
' Move down a row.
set <BlockBox;%BlockBox%+8>
set numeric <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8>
' Discard WEST bit
if (%ExitsBlocked% >3) then set <ExitsBlocked;%ExitsBlocked%-4>
' Discard SOUTH bit
if (%ExitsBlocked% >1) then set <ExitsBlocked;%ExitsBlocked%-2>
' Discard EAST bit
if (%ExitsBlocked% =0) then set
<grid[BlockBox];%grid[BlockBox]%+1> ' Set NORTH bit if not set
'Now the access from the north.
set <BlockBox;%BlockBox%-16>
' IF Makes sure we're not in the top row, (we can ignore this stage
if we are)
if (%BlockBox%>8) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8>
' Discard WEST bit
if (%ExitsBlocked% <4) then set
<grid[BlockBox];%grid[BlockBox]%+4> ' Set SOUTH bit if not set
}
'Now the access from the west
set <BlockBox;%BlockBox%+7>
make sure we aren't in the leftmost columnn
set numeric <isLeftCol;0>
for <i;8;78;10> {
if (%BlockBox%=%i%) then set <isLeftCol;1>
}
if (%isLeftCol%<>1) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8>
' Discard WEST bit
if (%ExitsBlocked% >3) then set <ExitsBlocked;%ExitsBlocked%-4>
' Discard SOUTH bit
if (%ExitsBlocked% <2) then set
<grid[BlockBox];%grid[BlockBox]%+2> ' Set EAST bit if not set
}
'Now the access from the east
set <BlockBox;%BlockBox%+2>
make sure we aren't in the rightmost columnn
set numeric <isRightCol;0>
for <i;1;71;8> {
if (%BlockBox%=%i%) then set <isRightCol;1>
}
if (%isRightCol%<>1) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% <8) then set
<grid[BlockBox];%grid[BlockBox]%+8> ' Set WEST bit if not set
}
end define
define text <intro>
A demonstration of using one Quest room to represent a grid of
locations, in this example a 8 x 8 (64 cell) grid, with lots of the
cells inaccessible to form a "maze"
end define
define text <win>
Enter win text here
end define
define text <lose>
Enter lose text here
end define
' Grid of locations within one room
define game <Grid Demo>
asl-version <350>
gametype singleplayer
game version <1.0>
game author <MaDbRiT>
game copyright <© 2005 AGB>
game info <Demo>
start <StartRoom>
startscript {
do <MakeGrid> 'This builds a 8 x 8 grid (with hard boundaries)
' Calling 'KillAccess' procedure with the cell number as a parameter
closes all
' (N,S,E & W) entrances to the cell referenced.
do <KillAccess(1)>
do <KillAccess(2)>
do <KillAccess(4)>
for <x;6;7> do <KillAccess(%x%)>
do <KillAccess(9)>
do <KillAccess(12)>
do <KillAccess(19)>
for <x;21;22> do <KillAccess(%x%)>
do <KillAccess(24)>
do <KillAccess(26)>
do <KillAccess(29)>
do <KillAccess(36)>
for <x;39;42> do <KillAccess(%x%)>
do <KillAccess(46)>
do <KillAccess(50)>
do <KillAccess(52)>
do <KillAccess(56)>
do <KillAccess(62)>
'Open additional (special) Exits to north/south in Cell 5
'This is the exit from the gridroom maze
set <grid[5];10>
}
end define
define room <StartRoom>
script {
set <gridPos;35>
do <makeExits>
goto <gridroom>
}
end define
define room <DoorRoom>
alias <a small, gloomy room.>
look <The room is completely bare and featureless except for a single door to the north.>
end define
define room <GridRoom>
script {
msg <DEBUG: Exit code for this (%gridPos%) room is = %grid[gridPos]%>
}
alias <a maze of seemingly identical corridors>
command <north> {
set <gridPos;%gridPos%-8>
if (%gridpos%<>5) then {
do <makeExits>
goto <GridRoom>
}
else goto <doorroom>
}
command <south> {
set <gridPos;%gridPos%+8>
do <makeExits>
goto <GridRoom>
}
command <east> {
set <gridPos;%gridPos%+1>
do <makeExits>
goto <GridRoom>
}
command <west> {
set <gridPos;%gridPos%-1>
do <makeExits>
goto <GridRoom>
}
end define
define room <dummy>
end define
define procedure <MakeGrid>
set numeric <gridPos;0>
' ** Set Basic boundaries of 8 x 8 grid
' ** Set exit north OFF for top row of grid
for <i;1;8> {
set numeric <grid[i];1>
}
' ** Set exit south OFF for bottom row of grid
for <i;57;64> {
set numeric <grid[i];4>
}
' ** Set exit east OFF for right row of grid
for <i;8;64;8> {
set numeric <grid[i];%grid[i]%+2>
}
' ** Set exit west OFF for left of grid
for <i;1;57;8> {
set numeric <grid[i];%grid[i]%+8>
}
end define
define procedure <makeExits>
create exit north <GridRoom;dummy>
create exit east <GridRoom;dummy>
create exit south <GridRoom;dummy>
create exit west <GridRoom;dummy>
set numeric <gridVal;%grid[gridPos]%>
if (%gridVal% >7) then {
create exit west <GridRoom;>
set <gridVal;%gridVal%-8>
}
if (%gridVal% >3) then {
create exit south <GridRoom;>
set <gridVal;%gridVal%-4>
}
if (%gridVal% >1) then {
create exit east <GridRoom;>
set <gridVal;%gridVal%-2>
}
if (%gridVal% >0) then {
create exit north <GridRoom;>
}
end define
define procedure <KillAccess>
set numeric <BlockBox;$parameter(1)$>
' In this procedure we need to modify the boxes bordering the chosen box
' rather than the box to be blocked itself. First up is to block the
' exit to this box from the south.
' Move down a row.
set <BlockBox;%BlockBox%+8>
set numeric <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8>
' Discard WEST bit
if (%ExitsBlocked% >3) then set <ExitsBlocked;%ExitsBlocked%-4>
' Discard SOUTH bit
if (%ExitsBlocked% >1) then set <ExitsBlocked;%ExitsBlocked%-2>
' Discard EAST bit
if (%ExitsBlocked% =0) then set <grid[BlockBox];%grid[BlockBox]%+1> ' Set NORTH bit if not set
'Now the access from the north.
set <BlockBox;%BlockBox%-16>
' IF Makes sure we're not in the top row, (we can ignore this stage if we are)
if (%BlockBox%>8) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8>
' Discard WEST bit
if (%ExitsBlocked% <4) then set <grid[BlockBox];%grid[BlockBox]%+4> ' Set SOUTH bit if not set
}
'Now the access from the west
set <BlockBox;%BlockBox%+7>
make sure we aren't in the leftmost columnn
set numeric <isLeftCol;0>
for <i;8;64;8> {
if (%BlockBox%=%i%) then set <isLeftCol;1>
}
if (%isLeftCol%<>1) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8>
' Discard WEST bit
if (%ExitsBlocked% >3) then set <ExitsBlocked;%ExitsBlocked%-4>
' Discard SOUTH bit
if (%ExitsBlocked% <2) then set <grid[BlockBox];%grid[BlockBox]%+2> ' Set EAST bit if not set
}
'Now the access from the east
set <BlockBox;%BlockBox%+2>
make sure we aren't in the rightmost columnn
set numeric <isRightCol;0>
for <i;1;57;8> {
if (%BlockBox%=%i%) then set <isRightCol;1>
}
if (%isRightCol%<>1) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% <8) then set <grid[BlockBox];%grid[BlockBox]%+8> ' Set WEST bit if not set
}
end define
define text <intro>
A demonstration of using one Quest room to represent a grid of locations, in this example a 8 x 8 (64 cell) grid, with lots of the cells inaccessible to form a "maze"
end define
define text <win>
Enter win text here
end define
define text <lose>
Enter lose text here
end define
' "Grid Demo"
' Created with QDK 3.53 - UNREGISTERED VERSION
define game <Grid Demo>
asl-version <350>
gametype singleplayer
start <StartRoom>
game author <MaDbRiT>
game version <1.0>
game copyright <© 2005 AGB>
game info <Created with QDK 3.53 - UNREGISTERED EVALUATION VERSION.>
startscript {
do <MakeGrid>
closes all
do <KillAccess(1)>
do <KillAccess(2)>
do <KillAccess(4)>
for <x;6;7> do <KillAccess(%x%)>
do <KillAccess(9)>
do <KillAccess(12)>
do <KillAccess(19)>
for <x;21;22> do <KillAccess(%x%)>
do <KillAccess(24)>
do <KillAccess(26)>
do <KillAccess(29)>
do <KillAccess(36)>
for <x;39;42> do <KillAccess(%x%)>
do <KillAccess(46)>
do <KillAccess(50)>
do <KillAccess(52)>
do <KillAccess(56)>
do <KillAccess(62)>
set <grid[5];10>
}
end define
define synonyms
end define
define room <StartRoom>
script {
set <gridPos;35>
do <makeExits>
goto <gridroom>
}
end define
define room <DoorRoom>
alias <a small, gloomy room.>
look <The room is completely bare and featureless except for a single door to the north.>
south <GridRoom>
script set <gridPos;5>
end define
define room <GridRoom>
alias <a maze of seemingly identical corridors>
script msg <DEBUG: Exit code for this (%gridPos%) room is = %grid[gridPos]%>
command <north> {
set <gridPos;%gridPos%-8>
if ( %gridpos% <> 5 ) then {
do <makeExits>
goto <GridRoom>
}
else goto <doorroom>
}
command <south> {
set <gridPos;%gridPos%+8>
do <makeExits>
goto <GridRoom>
}
command <east> {
set <gridPos;%gridPos%+1>
do <makeExits>
goto <GridRoom>
}
command <west> {
set <gridPos;%gridPos%-1>
do <makeExits>
goto <GridRoom>
}
end define
define room <dummy>
end define
define room <DropRoom>
look <This is the part of the maze underneath the grate where Graham dropped in.>
north <GridRoom>
south <GridRoom>
west <GridRoom>
script set <gridPos; 35>
end define
define room <MonsterRoom>
alias <a maze of seemingly identical corridors>
look <In this area of the maze, it is evident that a creature has roamed through here.>
south <GridRoom>
script set <gridPos; 8>
end define
define room <MonsterRoom2>
alias <a maze of seemingly identical corridors>
look <In this area of the maze, it is evident that a creature has roamed through here.>
south <GridRoom>
script set <gridPos; 49>
end define
define room <MonsterRoom3>
alias <a maze of seemingly identical corridors>
look <In this area of the maze, it is evident that a creature has roamed through here.>
west <GridRoom>
script set <gridPos; 64>
end define
define procedure <MakeGrid>
set numeric <gridPos;0>
for <i;1;8> set numeric <grid[i];1>
for <i;57;64> set numeric <grid[i];4>
for <i;8;64;8> set numeric <grid[i];%grid[i]%+2>
for <i;1;57;8> set numeric <grid[i];%grid[i]%+8>
end define
define procedure <makeExits>
create exit north <GridRoom;dummy>
create exit east <GridRoom;dummy>
create exit south <GridRoom;dummy>
create exit west <GridRoom;dummy>
set numeric <gridVal;%grid[gridPos]%>
if ( %gridVal% > 7 ) then {
create exit west <GridRoom;>
set <gridVal;%gridVal%-8>
}
if ( %gridVal% > 3 ) then {
create exit south <GridRoom;>
set <gridVal;%gridVal%-4>
}
if ( %gridVal% > 1 ) then {
create exit east <GridRoom;>
set <gridVal;%gridVal%-2>
}
if ( %gridVal% > 0 ) then {
create exit north <GridRoom;>
}
end define
define procedure <KillAccess>
set numeric <BlockBox;$parameter(1)$>
set <BlockBox;%BlockBox%+8>
set numeric <ExitsBlocked;%grid[BlockBox]%>
if ( %ExitsBlocked% > 7 ) then set <ExitsBlocked;%ExitsBlocked%-8>
if ( %ExitsBlocked% > 3 ) then set <ExitsBlocked;%ExitsBlocked%-4>
if ( %ExitsBlocked% > 1 ) then set <ExitsBlocked;%ExitsBlocked%-2>
if ( %ExitsBlocked% = 0 ) then set <grid[BlockBox];%grid[BlockBox]%+1>
set <BlockBox;%BlockBox%-16>
if ( %BlockBox% > 8 ) then {
set <ExitsBlocked;%grid[BlockBox]%>
if ( %ExitsBlocked% > 7 ) then set <ExitsBlocked;%ExitsBlocked%-8>
if ( %ExitsBlocked% < 4 ) then set <grid[BlockBox];%grid[BlockBox]%+4>
}
set <BlockBox;%BlockBox%+7>
make sure we aren
set numeric <isLeftCol;0>
for <i;8;64;8> {
if ( %BlockBox% = %i% ) then set <isLeftCol;1>
}
if ( %isLeftCol% <> 1 ) then {
set <ExitsBlocked;%grid[BlockBox]%>
if ( %ExitsBlocked% > 7 ) then set <ExitsBlocked;%ExitsBlocked%-8>
if ( %ExitsBlocked% > 3 ) then set <ExitsBlocked;%ExitsBlocked%-4>
if ( %ExitsBlocked% < 2 ) then set <grid[BlockBox];%grid[BlockBox]%+2>
}
set <BlockBox;%BlockBox%+2>
make sure we aren
set numeric <isRightCol;0>
for <i;1;57;8> {
if ( %BlockBox% = %i% ) then set <isRightCol;1>
}
if ( %isRightCol% <> 1 ) then {
set <ExitsBlocked;%grid[BlockBox]%>
if ( %ExitsBlocked% < 8 ) then set <grid[BlockBox];%grid[BlockBox]%+8>
}
end define
define text <intro>
A demonstration of using one Quest room to represent a grid of locations, in this example a 8 x 8 (64 cell) grid, with lots of the cells inaccessible to form a "maze"
end define
define text <win>
Enter win text here
end define
define text <lose>
Enter lose text here
end define
In your code, when you finally reach the room with the door, you can’t return south back into the maze. So I thought if I put the south exit of the DoorRoom set to “GridRoomâ€, it would send me back into the maze. After testing it, it seemed to work, however, if you go further into the maze and try to find the DoorRoom again, you’ll get an error 9 and the game shuts down.
Further, I wanted to make the room that you start out in different so people roaming through the maze would realize that they’re back to the room that they started in. So in other words, I wanted them to get a description similar to “This seems to be the room that you started from since you can see the open grate above youâ€. Then of course, there should be an object in the room called “grate†so they can examine it if they chose to.
Finally, I wanted to make three rooms [8, 49, 64] (labeled as MonsterRoom, MonsterRoom2, and MonsterRoom3)where a creature would randomly appear in. The discussion of this general idea is in another recent thread but my question relates to the one above in reference to the DoorRoom. Whether or not the creature is in the room, I want the player to be able to “notice†that a creature had been in the room so these three rooms would have their own room descriptions similar to “It appears that in this part of the maze, a creature has recently passed throughâ€
When I began trying to create room 8, I received worse results than when I threw in the “GridRoom†exit on the DoorRoom. I couldn’t even get an exit out of room 8.
' Grid of locations within one room
define game <Grid Demo>
asl-version <350>
gametype singleplayer
game version <1.0>
game author <MaDbRiT>
game copyright <© 2005 AGB>
game info <Demo>
start <StartRoom>
startscript {
do <MakeGrid> 'This builds a 8 x 8 grid (with hard boundaries)
' Calling 'KillAccess' procedure with the cell number as a parameter closes all
' (N,S,E & W) entrances to the cell referenced.
do <KillAccess(1)>
do <KillAccess(2)>
do <KillAccess(4)>
for <x;6;7> do <KillAccess(%x%)>
do <KillAccess(9)>
do <KillAccess(12)>
do <KillAccess(19)>
for <x;21;22> do <KillAccess(%x%)>
do <KillAccess(24)>
do <KillAccess(26)>
do <KillAccess(29)>
do <KillAccess(36)>
for <x;39;42> do <KillAccess(%x%)>
do <KillAccess(46)>
do <KillAccess(50)>
do <KillAccess(52)>
do <KillAccess(56)>
do <KillAccess(62)>
'Open additional (special) Exits to north/south in Cell 5
'This is the exit from the gridroom maze
set <grid[5];10>
}
end define
define room <StartRoom>
script {
set <gridPos;35>
do <makeExits>
goto <gridroom>
}
end define
define room <DoorRoom>
alias <a small, gloomy room.>
look <The room is completely bare and featureless except _
for a single door to the north. A corridor leads south...>
south {
set <gridPos;13>
do <makeExits>
goto <gridroom>
}
end define
define room <GridRoom>
script {
' msg <DEBUG: Exit code for this (%gridPos%) room is = %grid[gridPos]%>
}
alias <a maze of seemingly identical corridors>
description {
if ( %gridpos%=35 ) then {
msg <This is the part of the maze underneath the grate where Graham dropped in. |nThere is a |bgrate|xb here.>
}
if ( %gridpos%=8 ) or (%gridpos%=49) or (%gridpos%=64) then {
msg <In this area of the maze, it is evident that a creature has roamed through here.>
}
}
command <north> {
set <gridPos;%gridPos%-8>
if (%gridpos%<>5) then {
do <makeExits>
goto <GridRoom>
}
else goto <doorroom>
}
command <south> {
set <gridPos;%gridPos%+8>
do <makeExits>
goto <GridRoom>
}
command <east> {
set <gridPos;%gridPos%+1>
do <makeExits>
goto <GridRoom>
}
command <west> {
set <gridPos;%gridPos%-1>
do <makeExits>
goto <GridRoom>
}
define object <grate>
look <a large ornamental grate.>
end define
end define
define room <dummy>
end define
define procedure <MakeGrid>
set numeric <gridPos;0>
' ** Set Basic boundaries of 8 x 8 grid
' ** Set exit north OFF for top row of grid
for <i;1;8> {
set numeric <grid[i];1>
}
' ** Set exit south OFF for bottom row of grid
for <i;57;64> {
set numeric <grid[i];4>
}
' ** Set exit east OFF for right row of grid
for <i;8;64;8> {
set numeric <grid[i];%grid[i]%+2>
}
' ** Set exit west OFF for left of grid
for <i;1;57;8> {
set numeric <grid[i];%grid[i]%+8>
}
end define
define procedure <makeExits>
create exit north <GridRoom;dummy>
create exit east <GridRoom;dummy>
create exit south <GridRoom;dummy>
create exit west <GridRoom;dummy>
set numeric <gridVal;%grid[gridPos]%>
if (%gridpos%=35) then reveal <grate>
else conceal <grate>
if (%gridVal% >7) then {
create exit west <GridRoom;>
set <gridVal;%gridVal%-8>
}
if (%gridVal% >3) then {
create exit south <GridRoom;>
set <gridVal;%gridVal%-4>
}
if (%gridVal% >1) then {
create exit east <GridRoom;>
set <gridVal;%gridVal%-2>
}
if (%gridVal% >0) then {
create exit north <GridRoom;>
}
end define
define procedure <KillAccess>
set numeric <BlockBox;$parameter(1)$>
' In this procedure we need to modify the boxes bordering the chosen box
' rather than the box to be blocked itself. First up is to block the
' exit to this box from the south.
' Move down a row.
set <BlockBox;%BlockBox%+8>
set numeric <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8>
' Discard WEST bit
if (%ExitsBlocked% >3) then set <ExitsBlocked;%ExitsBlocked%-4>
' Discard SOUTH bit
if (%ExitsBlocked% >1) then set <ExitsBlocked;%ExitsBlocked%-2>
' Discard EAST bit
if (%ExitsBlocked% =0) then set <grid[BlockBox];%grid[BlockBox]%+1> ' Set NORTH bit if not set
'Now the access from the north.
set <BlockBox;%BlockBox%-16>
' IF Makes sure we're not in the top row, (we can ignore this stage if we are)
if (%BlockBox%>8) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8>
' Discard WEST bit
if (%ExitsBlocked% <4) then set <grid[BlockBox];%grid[BlockBox]%+4> ' Set SOUTH bit if not set
}
'Now the access from the west
set <BlockBox;%BlockBox%+7>
' make sure we aren't in the leftmost columnn
set numeric <isLeftCol;0>
for <i;8;64;8> {
if (%BlockBox%=%i%) then set <isLeftCol;1>
}
if (%isLeftCol%<>1) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% >7) then set <ExitsBlocked;%ExitsBlocked%-8>
' Discard WEST bit
if (%ExitsBlocked% >3) then set <ExitsBlocked;%ExitsBlocked%-4>
' Discard SOUTH bit
if (%ExitsBlocked% <2) then set <grid[BlockBox];%grid[BlockBox]%+2> ' Set EAST bit if not set
}
'Now the access from the east
set <BlockBox;%BlockBox%+2>
' make sure we aren't in the rightmost columnn
set numeric <isRightCol;0>
for <i;1;57;8> {
if (%BlockBox%=%i%) then set <isRightCol;1>
}
if (%isRightCol%<>1) then {
set <ExitsBlocked;%grid[BlockBox]%>
if (%ExitsBlocked% <8) then set <grid[BlockBox];%grid[BlockBox]%+8> ' Set WEST bit if not set
}
end define
define text <intro>
A demonstration of using one Quest room to represent a grid of locations, in this example a 8 x 8 (64 cell) grid, with lots of the cells inaccessible to form a "maze"
end define
define text <win>
Enter win text here
end define
define text <lose>
Enter lose text here
end defineThe three "rooms" where the creature will randomly appear in...won't that be a little more difficult to make it appear in one of these three rooms when the rooms are actually the same room but different grid positions?
define object <monster>
look <it looks very hungry, and you are snack-sized!>
end define hide <monster>
if (%gridpos%=8) or (%gridpos%=64) or (%gridpos%=49) then {
set numeric <monsterhere;$rand(1;3)$>
if (%monsterhere%=3) then show <monster>
} description {
if ( %gridpos%=35 ) then {
msg <This is the part of the maze underneath the grate where Graham dropped in. |nThere is a |bgrate|xb here.>
}
if ( %gridpos%=8 ) or (%gridpos%=49) or (%gridpos%=64) and not here <monster> then {
msg <In this area of the maze, it is evident that a creature has roamed through here.>
}
if here <monster> then msg <|nI don't wish to alarm you, but there is a |bmonster|xb here!>
}ooooh, I ran into a problem while testing. Although it is quite convenient to use the map in the lower right corner, there are some players who prefer to type in the commands. If you type nsw or e it sends you to the dummy room and you’re done. If you type it out (north, south, etc), it moves you correctly. I did a quick fix by making synonyms (n=north, etc). That actually fixed that problem
if you type out your commands, although the map shows the correct exits available, the player can still walk through walls. For instance, when you start on grid 35, there is no doorway east. But when you type “eastâ€, you appear in grid 0. If you try this in several different parts of the maze, you eventually get a code 9 error and it shuts the game down.
command <north> {
if ($instr(#quest.doorways.dirs#,north)$<>) then {
set <gridPos;%gridPos%-8>
if (%gridpos%<>5) then {
do <makeExits>
goto <GridRoom>
}
else goto <doorroom>
}
else msg <You can't go there.>
}
command <south> {
if ($instr(#quest.doorways.dirs#,south)$<>) then {
set <gridPos;%gridPos%+8>
do <makeExits>
goto <GridRoom>
}
else msg <You can't go there.>
}
command <east> {
if ($instr(#quest.doorways.dirs#,east)$<>) then {
set <gridPos;%gridPos%+1>
do <makeExits>
goto <GridRoom>
}
else msg <You can't go there.>
}
command <west> {
if ($instr(#quest.doorways.dirs#,west)$<>) then {
set <gridPos;%gridPos%-1>
do <makeExits>
goto <GridRoom>
}
else msg <You can't go there.>
}Now I've changed it and when you start the game, it shows the available exits but if you try to take any exits (even the non-exits), it says you can't go there.
command <north> {
if ($instr(#quest.doorways.dirs#;north)$<>0) then {
set <gridPos;%gridPos%-8>
if (%gridpos%<>5) then {
do <makeExits>
goto <GridRoom>
}
else goto <doorroom>
}
else msg <You can't go there.>
}
command <south> {
if ($instr(#quest.doorways.dirs#;south)$<>0) then {
set <gridPos;%gridPos%+8>
do <makeExits>
goto <GridRoom>
}
else msg <You can't go there.>
}
command <east> {
if ($instr(#quest.doorways.dirs#;east)$<>0) then {
set <gridPos;%gridPos%+1>
do <makeExits>
goto <GridRoom>
}
else msg <You can't go there.>
}
command <west> {
if ($instr(#quest.doorways.dirs#;west)$<>0) then {
set <gridPos;%gridPos%-1>
do <makeExits>
goto <GridRoom>
}
else msg <You can't go there.>
}