'on demand random retraceable maze
North
AS INTEGER 'what room lies in direction Walls
AS Roomlook
'walls or passages Created
AS _BYTE 'as this room been visited?
Loose
AS _BYTE 'in a container or loose on ground locked
AS _BYTE 'is container locked? Corner
AS _BYTE 'which corner is treasure lying in?'OPEN "debug.txt" FOR OUTPUT AS #1
DIM SHARED Maze
(32000) AS room
, a$
, b$
, c$
(1), d$
(5), e$
(1)
'Preliminary monster controls
CONST Max_Mons_Count
= 250 'how many monsters to try to add to the maze(max 64000) CONST Mons_Chance
= 75 'chance of monster appearing in room being made 0-100 CONST Max_Mons_Room
= 100 'the highest room number to contain a monster(max 32000) '-----------------------------
CONST UP
= 1, DOWN
= 2, LEFT
= 3, RIGHT
= 4 a$ = "To the "
b$ = " there is a "
c$(0) = "wall": c$(1) = "passage"
d$(UP) = "north": d$(DOWN) = "south": d$(LEFT) = "west": d$(RIGHT) = "east"
e$(0) = "unknown": e$(1) = "known"
Nouns:
DATA 11,"Rat","Spider","Bat","Snake","Dog","Cat","Lizard","Bear","Politician","Bearded Woman","Hairy Man" Adjectives:
DATA 7,"Large","Huge","Mal-formed","Curvaceous","Busty","Masculine","Foul" Verbs:
DATA 6,"swing","lunge","assault","gnaw","slash","suffocate" Weapon:
DATA 9,"Bare Fist","Teeth","Fangs","Claws","Whip-like Tail","Racid Odor","Acidic Bile","Hard Feces","Grotesque Looks" Treasure:
DATA 6,"Coin","Gem","Goblet","Ingot","Crown","Artifact" 'make maze ready to explore
ClearMaze
makerooms 'premake some wall sections
Load_Monsters
Add_Mons
'create the starting room
'pick which walls you can pass
Maze
(0).Walls.up
= INT(RND * 2)Maze
(0).Walls.down
= INT(RND * 2)Maze
(0).Walls.left
= INT(RND * 2)Maze
(0).Walls.right
= INT(RND * 2)Maze(0).Created = TRUE
current% = 0 'room player is in
lastmade% = 0 'last room created
LOCATE 8, , 0 ' turn cursor off DescribeRoom current%
drawroom current%
LOCATE 8, 1, 1 ' turn cursor on
MessageHandler "You head north..."
IF Maze
(current%
).Walls.up
THEN 'if you can go up IF Maze
(current%
).North
>= 0 THEN 'is north already referenced MessageHandler "you have been here before"
current% = Maze(current%).North
ELSE 'never been north in this room MessageHandler "you find somewhere new"
lastmade% = lastmade% + 1
nul% = CreateRoom(lastmade%, current%, UP)
current% = lastmade%
MessageHandler "You head south..."
IF Maze
(current%
).Walls.down
THEN 'if you can go down IF Maze
(current%
).South
>= 0 THEN 'is south already referenced MessageHandler "you have been here before"
current% = Maze(current%).South
ELSE 'never been south in this room MessageHandler "you find somewhere new"
lastmade% = lastmade% + 1
nul% = CreateRoom(lastmade%, current%, DOWN)
current% = lastmade%
MessageHandler "You head west..."
IF Maze
(current%
).Walls.left
THEN 'if you can go left IF Maze
(current%
).West
>= 0 THEN 'is west already referenced MessageHandler "you have been here before"
current% = Maze(current%).West
ELSE 'never been west in this room MessageHandler "you find somewhere new"
lastmade% = lastmade% + 1
nul% = CreateRoom(lastmade%, current%, LEFT)
current% = lastmade%
MessageHandler "You head east..."
IF Maze
(current%
).Walls.right
THEN 'if you can go right IF Maze
(current%
).East
>= 0 THEN 'is east already referenced MessageHandler "you have been here before"
current% = Maze(current%).East
ELSE 'never been north in this room MessageHandler "you find somewhere new"
lastmade% = lastmade% + 1
nul% = CreateRoom(lastmade%, current%, RIGHT)
current% = lastmade%
exitflag%% = TRUE
kbd& = 0
FUNCTION CreateRoom
(Going%
, From%
, Direction%%
) Maze
(Going%
).Walls.up
= INT(RND * 2) Maze
(Going%
).Walls.down
= INT(RND * 2) Maze
(Going%
).Walls.left
= INT(RND * 2) Maze
(Going%
).Walls.right
= INT(RND * 2) Maze(Going%).Created = TRUE
'which direction did player head
Maze(Going%).Walls.down = 1 'down has to be open, direction coming from
Maze(Going%).South = From% 'south goes back to previous room
Maze(From%).North = Going% 'the room id north of previous room
Maze(Going%).Walls.up = 1 'up has to be open, direction coming from
Maze(Going%).North = From% 'north goes back to previous room
Maze(From%).South = Going% 'the room id south of previous room
Maze(Going%).Walls.right = 1 'left has to be open, direction coming from
Maze(Going%).East = From% 'east goes back to previous room
Maze(From%).West = Going% 'the room id west of previous room
Maze(Going%).Walls.left = 1 'right has to be open, direction coming from
Maze(Going%).West = From% 'west goes back to previous room
Maze(From%).East = Going% 'the room id east of previous room
MessageHandler
"You are currently in room" + STR$(id%
) MessageHandler a$ + d$(UP) + b$ + c$(Maze(id%).Walls.up)
MessageHandler a$ + d$(DOWN) + b$ + c$(Maze(id%).Walls.down)
MessageHandler a$ + d$(LEFT) + b$ + c$(Maze(id%).Walls.left)
MessageHandler a$ + d$(RIGHT) + b$ + c$(Maze(id%).Walls.right)
MessageHandler blank$
IF Maze
(id%
).Has_Mons
THEN Describe_Mons
(id%
)
Maze(i%).North = -1
Maze(i%).South = -1
Maze(i%).West = -1
Maze(i%).East = -1
Maze(i%).Created = FALSE
PRINT #1, "north leads to "; Maze
(i%
).North
PRINT #1, "south leads to "; Maze
(i%
).South
PRINT #1, "west leads to "; Maze
(i%
).West
PRINT #1, "east leads to "; Maze
(i%
).East
PRINT #1, "up wall status "; Maze
(i%
).Walls.up
PRINT #1, "down wall status "; Maze
(i%
).Walls.down
PRINT #1, "left wall status "; Maze
(i%
).Walls.left
PRINT #1, "right wall status "; Maze
(i%
).Walls.right
IF Maze
(id%
).Walls.up
THEN 'has passage IF Maze
(id%
).Walls.left
THEN 'has passage IF Maze
(id%
).Walls.right
THEN 'has passage IF Maze
(id%
).Walls.down
THEN 'has passage
'ÚÄ¿³ÀÙ
wall$(0) = " ÚÄÄÄÄÄÄÄÄ¿ "
wall$(1) = " ÚÄÄÙ ÀÄÄ¿ "
wall$(2) = " ÀÄÄÄÄÄÄÄÄÙ "
wall$(3) = " ÀÄÄ¿ ÚÄÄÙ "
FOR I~%
= 1 TO Max_Mons_Count
Chance%%
= INT(RND * 100) 'create a random chance for monster to be made (0-99) IF Chance%%
< Mons_Chance
THEN 'if value is benieth the monster cutoff then make one Room%
= INT(RND * Max_Mons_Room
) 'which room should monster appear in?(0-[Max room to find monster-1]) IF Maze
(Room%
).Has_Mons
< 3 THEN 'only add monster to room if its not full already Mon%%
= INT(RND * Max_Mons_Noun
) + 1 'pick a monster to populate room with Mons(Current_Monster~%).Noun = Mon%%
Mons
(Current_Monster~%
).Hp
= INT(RND * Mon%%
^ 2) + 1 Mons
(Current_Monster~%
).Atk
= INT(RND * Max_Mons_Weapon
) + 1 Mons
(Current_Monster~%
).Verb
= INT(RND * Max_Mons_Verb
) + 1 Mons
(Current_Monster~%
).Adjt
= INT(RND * Max_Mons_Adj
) + 1 Maze(Room%).Has_Mons = Maze(Room%).Has_Mons + 1
Mons(Current_Monster~%).Roomid = Room%
Current_Monster~% = Current_Monster~% + 1
Monster_Count = Current_Monster~%
SUB MessageHandler
(txt$
) 'define message area
'display message
'restore screen area
FOR i%%
= 1 TO Max_Mons_Noun
FOR i%%
= 1 TO Max_Mons_Adj
FOR i%%
= 1 TO Max_Mons_Verb
FOR i%%
= 1 TO Max_Mons_Weapon
FOR i~%
= 0 TO Monster_Count
IF Mons
(i~%
).Roomid
= id%
THEN M1$
= "In the room there is a " + RTRIM$(A
(Mons
(i~%
).Adjt
)) + " " + RTRIM$(M
(Mons
(i~%
).Noun
)) + "." M2$
= "It can " + RTRIM$(V
(Mons
(i~%
).Verb
)) + " with " + RTRIM$(W
(Mons
(i~%
).Atk
)) + " " + STR$(i~%
) MessageHandler M1$
MessageHandler M2$
Found%% = Found%% + 1
IF Found%%
= Maze
(id%
).Has_Mons
THEN i~%
= Monster_Count
+ 1 'if all the monsters have been found for this room exit routine