Ideas about accessing map geometry info from scripts?

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Ideas about accessing map geometry info from scripts?

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...
gramps

Joined: 18 Oct 2018

Re: Ideas about accessing map geometry info from scripts?

You say "scripting". Are you talking about ACS or ZScript?
In ZScript you have full access to the map geometry structures like sectors, sidedefs and linedefs so this should be possible.

Graf Zahl

Joined: 19 Jul 2003
Location: Germany

Re: Ideas about accessing map geometry info from scripts?

Was using ACS so far, but will probably move to zscript anyway for the quadtrees. Fixed-size arrays work fine for a fixed-size grid, but I think I'll want dynamic arrays for what I'm trying to do.

Yeah, looks like zscript has a ton of useful stuff for this, even for portals specifically. Will play around with it and try to find a good balance between explicitly defining stuff in the map and inferring things from the geometry in the script.
gramps

Joined: 18 Oct 2018