Author Topic: How to Create A Random Maze  (Read 8050 times)

0 Members and 1 Guest are viewing this topic.

Offline Solaufein

  • Lord of the Realms
  • Administrator
  • Level 5
  • *****
  • Posts: 5164
  • Karma: +127/-19
  • Gender: Male
  • The night is dark and full of terrors...
    • ICQ Messenger - 251194643
    • Yahoo Instant Messenger - gscott7833
    • View Profile
    • http://teambg.net
How to Create A Random Maze
« on: July 11, 2012, 06:27:34 AM »
How to create random maze ?

(like Modron Maze in PS:T )

 

Q : Is it possible to make it so an area can be renewed through dialogue. I checked how they do it in the Modron Maze in Planescape Torment and it just says as effect CreateMordomMaze. I want it to do this for my area in BG2 but as far as i can tell it's hard coded only into Torment. Anyone know if theres a way to do it in BG2?

Rashamon : Yeah you could probably script it using a random choice of which area to go to next, eg:

Code:

IF
...
THEN
RESPONSE #100
EscapeAreaMove(AR4501, 50, 50, 15)
RESPONSE #100
EscapeAreaMove(AR4502, 50, 50, 15)
RESPONSE #100
EscapeAreaMove(AR4503, 50, 50, 15)
RESPONSE #100
EscapeAreaMove(AR4504, 50, 50, 15)
END  


Well if you remember, the modron maze was randomized when you were in the control room. Once you where in the maze, it was static until you went back to the control room again. That means that there were a lot of similar looking areas, so if you want your thing to be like the modron maze, you need more than one area.

An easy way of using one room only though, is through a script and item editing. Make all of the creatures, and items you want the creatures to have, but make sure EVERY item is destroyable, even gold and such. That way, you can, on exiting the room, have your script disintegrate any remaining creatures. Then make a random choice of creatures appear at random spawn points, via your area script.

So when you're leaving the room, put a wait command, move the pc's to a random place in the room, unexplore the area, disintegrate all the creatures, then respawn some new random creatures. It'll be a large script, but pretty easy if you really want to do it like that. Hope this gives you a few ideas




--------------------------------------------------------------------------------

Cat's advice  

The modron maze wasn't randonly shaped -- it was an 8x8 grid, and all that changed were exits were blocked. Scripting can easily create creatures in every room (each room's contents were in fact generated only when you entered it for the first time after any reset).

The script command in PST just randomized the maze; it put random blocks in the grid; I never figured out if there was simply a large number of preprogrammed patterns, or if it generated a maze, given certain parameters (like each room must be accessible, all rooms must connect to all other rooms, few rooms have 4 exits, etc.

It is very very easy to spawn creatures with a script. Each area has an area script, so, whenever you want to "reset" a room, do the following:

* Assume your area is named MZ1001. Then, to reset this, you use the following:



SetGlobal("MZ1001_created","GLOBAL",0)


* In the script for MZ1001:

IF
Global("MZ1001_created","GLOBAL",0)
THEN
RESPONSE #100
SetGlobal("MZ1001_created","GLOBAL",0)
UndoExplore()
//put one set of monster/loot spawning here
RESPONSE #100
SetGlobal("MZ1001_created","GLOBAL",0)
UndoExplore()
//put the second set of monster/loot spawning here

etc...
END


This is one way of doing things. The other (more random) way is something like this for each event you want to randomize (treasure, spawn, etc.):



IF
Global("MZ1001_created","GLOBAL",0)
THEN
RESPONSE #100
//random event option 1
Continue()
RESPONSE #100
//random event option 2
Continue()

etc.
END


You can put as many of these IF..THEN...END blocks as you feel like, each with many responses, to get your area really random. Each block could randomize one particular thing. Remember that each RESPONSE, though *must* end with Continue() or you will never reach the next IF block!

Finally, when you're done randomizing:

IF
Global("MZ1001_created","GLOBAL",0)
THEN
RESPONSE #100
SetGlobal("MZ1001_created","GLOBAL",1)
UndoExplore()
END
My mods:
Dark Horizons
The Undying
Nikita
IWD2 store

Co-contributor:
Dark Side of the Sword Coast BG1 Weidu
Aurils Bane
Encounters
Saerileth
Baldur's Gate - Enhanced Edition beta tester
Baldur's Gate 2 - Enhanced Edition beta tester
Icewind Dale - Enhanced Edition beta tester