3/9/19

A Map to a Goal

It was easy to re-integrate that event-to-event code.  However, adding more variables to the notetags didn't work, but it could be that I accessed something wrong.  I will try it once more, probably make the keys separate this time.

Anyway, I had a thought about making a semi-random dungeon.  In other words, the rooms are already pre-designed and the path is set, but the layout is different when you start a new run.  I have a general idea of mapping as I was able to use randomized hallways to connect to different parts of a haunted house.




1.  To create a semi-random dungeon, I will need a batch of preset maps and connecting maps.  My preset maps are designed for special purposes like an entrance, boss or save point.  For my connecting maps, I may need to include a tag to exclude some directions but I need at least two entrances on each.  Extra tags may be needed to force some directions.

2.  I assume I need two arrays at least, one to hold the maps and another with forward directions.  Assuming a ten-room dungeon, I'm planning to have an start and end as well as two mid-boss rooms, so my map array looks like this:
[A,0,0,B,0,0,C,0,0,D]
A- Exclude <v>
B- Exclude <>
C- Forbid ^ (a four-entrance map but you cannot enter from the top)
D- Exclude ^
And I will be making my forward array as I draft my first:
-Map 1 is skipped as it already has Map A.  It can only choose North.
-Map 2 needs to have a South (direction -  north).  Once a map with a south outlet is chosen, a random direction is chosen excluding any tagged or previous direction (north, east, west).
-Map 3 needs a direction from Map 2, then needs to have direction from North or South.  It may be possible that Map 2 goes straight up, so Map 3 would have a south direction and needs one that goes north

3.  To clarify, the forward array gets added on per map array at first.  So for the first map, we have 8.  The second map, we exclude south which is 10 - 8 = 2 leaving us to choose from a pool of 4, 6, 8.  In the case of Map 3, if we come from 4 or 6, we can chose 2 or 8, but if we come from 8, we must choose 2. Also, we need to place 0s at the beginning and end of this array.

4.  Now that we have a map array and forward array, we would need a few more variables and switches. One variable will simply depict the current order of our map array.  And assuming we're on Map B (3), we can access the direction array's 3rd and 4th index, which we convert to (10-8) = 2/8.  Our teleport event in the north will require an 8 from either of the two and either increase or decrease our map order if it's the first or later.

5.  The updated map order will pick out the map we want to go to from the array.  However, maps can be of different sizes which will alter the arrival points.  I believe I will have to include notetags in each of these maps for their preferred spawn points.  For example, leaving South of Map B will get the X and Y points of "North's" notetag.

---

Now that we got the basics out of the way...

A. On a four-way crossroad, it would suck to go one path and find out the teleport doesn't work.  Since I want rocks to block the way to those unused paths, I load up my directions and remove the directions that are used and activate switches with the rest.  I might also activate some "diagonal" switches if their other directions are close (1 when 2 and 4 can teleport) so that I can force the player to walk around the long way.

B.  Normal-teleports shouldn't mess with the dungeon-specific teleports, so it should be possible to create side-areas to from Map 3 and you can teleport back to Map 3.  And also, if Map 3 looks like Map 6, that teleport goes to the same map but Map 3 goes to Map 2 and Map B so you shouldn't have to worry aobut skipping ahead.

C.  It's obvious but I would need some more switches to handle respawns for chests and bosses.

---

This map system isn't perfect, which is my end zone has 3 entrances instead of one.  But it would be interesting to tackle.

No comments:

Post a Comment