by gramps » Mon Dec 03, 2018 11:16 am
Alright, this is sort of a weird question. Bear with me.
I have a map with a bunch of unconnected, square-ish areas with up to four portals, one on each side. When the level loads, the portals are semi-randomly linked up to connect these areas. The end result is the areas are all layed out on an imaginary grid.
Obviously for this to work, the script that links the portals together needs to know which portals belong to which areas, and what direction they're facing. Unfortunately this kind of information doesn't seem to be available to user scripts (if not please correct me), so I need to store it somehow on the portal lines.
What I'm doing for now is giving the east portal in each area an id that's a multiple of four, then going around the room counterclockwise and giving each portal the next id. So you can check if two portals are in the same room with i/4==j/4, and you can check which direction a portal is facing with i%4.
What I'd like to do is move from a grid to something closer to a quadtree, so larger areas would take up a complete grid square, medium areas would only take a quarter of a grid square, small areas would take a quarter of a medium one, etc..
The problem I'm running into is I'm no longer sure how to store the information on the portal lines. What I would love to do is get away from having the line ids be numerically significant, and somehow figure out what they're supposed to be by looking at their length, angle, and position relative to other lines. I'm way out of practice with this stuff and don't know if that's possible or where to look, or if there's some other way to approach it that I'm just not thinking of.
Any suggestions here? I don't care if the idea is fully fleshed out, spitballing is fine...
Alright, this is sort of a weird question. Bear with me.
I have a map with a bunch of unconnected, square-ish areas with up to four portals, one on each side. When the level loads, the portals are semi-randomly linked up to connect these areas. The end result is the areas are all layed out on an imaginary grid.
Obviously for this to work, the script that links the portals together needs to know which portals belong to which areas, and what direction they're facing. Unfortunately this kind of information doesn't seem to be available to user scripts (if not please correct me), so I need to store it somehow on the portal lines.
What I'm doing for now is giving the east portal in each area an id that's a multiple of four, then going around the room counterclockwise and giving each portal the next id. So you can check if two portals are in the same room with [i]i/4==j/4[/i], and you can check which direction a portal is facing with [i]i%4[/i].
What I'd like to do is move from a grid to something closer to a quadtree, so larger areas would take up a complete grid square, medium areas would only take a quarter of a grid square, small areas would take a quarter of a medium one, etc..
The problem I'm running into is I'm no longer sure how to store the information on the portal lines. What I would love to do is get away from having the line ids be numerically significant, and somehow figure out what they're supposed to be by looking at their length, angle, and position relative to other lines. I'm way out of practice with this stuff and don't know if that's possible or where to look, or if there's some other way to approach it that I'm just not thinking of.
Any suggestions here? I don't care if the idea is fully fleshed out, spitballing is fine...