Wizard coders, I need yall’s help.
I’m making a gamemode in which objects will be spawned in random parts of the map for players to find. I’m trying to make a code solution that will work on most every map. I started with this:
choose a random position vector within 50,000 units of center if that point passes a util.IsInWorld() check and a util.PointContents (testfogvolume or empty) check, spawn here
But this ran into problems with a lot of maps having random huge technically playable, but not actually accessible un-spaces (really weird shit, Flatgrass is a good example) that the code would spawn things in. Like huge pockets of physically exist-able space leagues outside of the main area of the map. In some maps, the ground was non-solid only several meters below, where you’d be walking around in this freaky limbo type area. Problem is that the code sees this as playable space and sticks shit in it.
I tried to create another solution that would perform a one-time function that recursively mapped-out a single contiguous volume by using multiple steps and a shitload of spatial traces starting at a player’s spawnpoint (“into_player_start”). While the function worked very well in generating for me a table of world-vectors that represented good spawn points, it had two problems.
- in order to get enough granularity to both be able to map out large outdoor spaces as well as zoom around all in buildings with winding corridors, I had to do a fuckton of calculations, which was just too much calculation.
- not all maps have info_player_starts. What the fuck.
I’ve resorted to just having players run around before the game starts spawning little nodes from the spawnmenu in places, which I then use as anchors for spatial calculations when spawning things (line-of-sight etc). But it’s tedious to spawn these things at every hallway intersection like in cs_office.
Is there some kind of existing info_ entity or ai_ or some other type of invisible whatever that exists on hammer maps in order to mark the normal playable player-space? Or even the boundaries? Either would solve my problem. Howabout some existing info_ or hint_ whatever nodes that I can just rely on to be anchor points for spatial spawning calculations?
Or am I doomed to just have to use manually-spawned nodes to combat bullshit maps that have huge un-reachable spaces in the ether… does anyone have any ideas?
TL;DR: how do i reliably find the contiguous player-space on a map
Is there a way for lua to detect if a map has ai nodes? (nav nodes)? Is there a class of object that I can search for?