-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 2 lane highways w/ infra for larger ones #71822
base: master
Are you sure you want to change the base?
Add 2 lane highways w/ infra for larger ones #71822
Conversation
This will be interesting to watch in the game.... I guess. Have you raised the question of increasing the default distance between cities? Say from 4 to 5, maybe 6? |
c5a7198
to
fd31b4e
Compare
stop_when_chosen_offet++; | ||
} | ||
} | ||
debugmsg( "Failed to seed highway offset with chosen value %s and expected max %s", chosen_offset, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both parameters are integers so %d
should be used here
debugmsg( "Failed to seed highway offset with chosen value %s and expected max %s", chosen_offset, | |
debugmsg( "Failed to seed highway offset with chosen value %d and expected max %d", chosen_offset, |
Amazing. I was just wishing we had these! |
I don't see how that's particularly relevant to this PR, this makes traversal of multiple overmap distances easier not distances between cities |
Just in case, I'll clarify what I said about settings. Parameter: city spacing. The logic is as follows.
So, in my opinion, new roads and distances between cities are interconnected. P.S. I hope I didn't mistranslate anywhere. |
There will still be vehicles on the road you won't be safely barrelling down the road at 100mph. The number of vehicles will probably be comparable to regular roads to begin with both because that's an amount that works and hopefully won't require too many line changes from the vehicle placement JSON I wrote for them so this PR saves on some bloat. I'll make sure auto drive works pre merge too.
Changes are pushing for more content further away from spawn with urbanosity leading to varying city sizes to explore that can contain different buildings set by city_sizes on the buildings special, oceans will likely have unique content by 0.Is release and hopefully at some point more region stuff will be pushed forward. Personally I don't think the default city distance is bad but I wouldn't be opposed to it changing either, I just don't think this PR does anything that warrants a change to it.
Mostly correct, most specials rely on being in a range of distances away from the nearest city so increasing the distance between cities will leave more "gaps" where nothing that tried to spawn could because it was too far from a city, though things with larger minimum distances would be more likely to succeed in spawning. |
But it's still faster than on a normal road. It's all about braking in time. I'm concerned about the issue of roadblocks. More specifically, robots with a grenade launcher at +1 level and a player at 0 level. Will the character be able to see the danger? Will the robot fire? And where will it shoot to. (Shoot through the roadway?) |
Are... are we playing the same game? There are no grenade wielding robots and there aren't any robots on the surface nowadays. Also your character doesn't level and I've no idea how this has anything to do with what I said, think deep translate got confused translating one of us. |
You're right. I should be more accurate. robots with a grenade launcher = riot control platform (M203A) at +1 level = I was talking about 1 level above the ground, z=1. Can a roadblock appear at z=1? (debug menu / m /m / 8) |
fb13247
to
060f0ff
Compare
I checked this patch out and poked around the map with debug mode. Mostly it looks good, but on the third overmap in from the ocean’s edge every overmap has a highway extending from the center of the overmap to the western edge. I expected a highway traveling north–south near the ocean, not a bunch of disconnected east–west segments, so I suspect that it’s a bug. |
Eh it was working at some point so that shouldn't be too bad to fix, this isn't mergable though, see above |
Yea, I had to fix some very minor errors. I suppose that could have broken it, but my changes look quite benign… |
By at some point I meant like May, I doubt whatever you did borked it |
Summary
Features "Adds highways"
Purpose of change
The recent additions of forestosity, urbanity and ocean mean that players are more likely to want to travel further now to explore the differing geography
Closes #7534
Describe the solution
Adds region setting controlled highways that spawn in multiple overmap wide straight grids across the very centre of overmaps
Screenshots in Testing section
Merger:
One of the commits is a nice function by @anothersimulacrum so make sure it's not squashed to remove them, just thought I'd add this bc I doubt you'd see in the pile of messy commits '^^
Players:
The current maps are 2 OMTs wide and appear every 5 overmaps north/south and 7 east/west with these distances being easily customisable.
Highways bridge over lakes and rivers but don't cross oceans.
Regular roads cross under/over the highway
Currently there's one common special that connects regular roads to highways.
Highways are currently disabled in region overhaul mods and the Railroads mod until I add tailored maps and support in follow-up PRs.
Devs:
First an offset for the grids is calculated based on the world seed.
Next for each overmap it decides whether highway should spawn based on ocean positions and the region setting defined x and y separations modified by the offset. Placement over oceans is disallowed but forces on the overmap before* (see additional content) ocean, so if you set the ocean to be on all sides there would be a square highway around the edge of your island for example.
Then highways reserve land before city and special placement and then place appropriate OMTs after this in order to achieve overpasses over cities and so regular roads cross the highway rather than intersect it.
Intersection specials are placed when appropriate
The road connection special and rest area specials are placed over the reserved highway as part of conventional special placement with very high priority.
The region setting defined maps are then placed in width*1 segment specials based on the underlying terrain after city and conventional special placement.
This placement places segments based on any of the width tiles containing something of interest and decides the whole segment based on that, ie if one tile is over water the whole segment will be bridge.
Finally some OMTs are overwritten with symbolic ones that don't alter the physical map but change the symbol used on the
m
ap as well as the flags and name used.The maps can be changed in both appearance and width entirely with JSON (changing width requires changing all the maps though, making width neutral segments would be doable with conditional nests but wouldn't help with intersections/road connections)
City streets either place fully crossing under the highway or stop short depending if there's an open OMT on the other side.
In order to place overpasses well I've added a new member to each overmap that keeps track of what OMTs belong to cities and fills gaps after finising placement of all cities. Look at this commit if you want to laugh at my awful first implementation of this.
Future scope:
I appreciate these highways aren't remotely accurate to life but this is just an initial implementation, in the future I'd like to have highways form interconnected but non continuous networks with deliberate city links and spawning randomly offset from the centre of overmaps, in my head none of these individually require significant change to achieve. If you however have concerns about how this specific implementation might cause problems in the future please raise them below.
If we add semi-set city/faction base spawns it should be very easy to guarentee/prevent highways near those similar to how ocean forces/prevents placement.
Describe alternatives you've considered
Not planning:
Making the fallback specials conditional nests of the base maps instead but that seemed like it would be very messy
I were going to use looks_like to make the highways look like roads but bc roads are linear while highways are just regular maps it defaults to a 0 connected tile road which looks really dumb
At first I had all highways at z1 with sloped ground under them and had roads tunnel under them rather than bridge over but decided that looked kinda silly. Having them sometimes spawn like this might be nice however. This change has made the need to handle intersections where the road is already raised though.
Placing the OMTs after special placement is unideal as it means specials that should widely ignore placement restrictions like craters and nether monster corpses can't spawn over them. There are various ways to work around this but I'd prefer to keep everything together for now so it's easier to understand (the same reason for example why I'm reserving the water tiles rather than immediately placing the correct OMTs so everything is grouped appropriately)
Alot of the special intersections etc OMTs could be replaced with nests but it'd be considerably harder to read, I already have reservations on my use of null tiles dispersed inbetween.
City placement could favour starting close to highways when present.
Realistically highways would have areas that are close to unnavigable due to pileups which could be mimicked while still remaining navigable by spawning lots of vehicles then applying snaking nests utilising "remove_vehicles" to make a clear path. Currently we lack any way I'm aware of to do this in a scope that makes sense though.
Unsure:
Making highways spawn in not full grids based on like a binary noise graph generated from the seed is probably quite doable but seemed unnecessary for an initial implementation. Ensuring good interconnectivety and maintaining general direction might be more challenging and it somewhat defeats the purpose of them if they go in circles or start and end one overmap over etc.
The highways can fit an extra lane on flat sections but I like them being separated when raised for the aesthetics at which point they can't fit 3 without increasing the OMT width
Nesting the region settings into grid_seperation, reserved_terrain, intersections, symbolic_terrain and segments for example
@GuardianDll wants me to make the specials even larger, the clover leaf for example is roughly 330x330 tiles in game whereas they're closer to 500mx500m irl but I wanted to keep them as small as possible while looking sensible so they don't get too in the way of other mapgen and are more likely to be able to be placed
Halving/doubling the frequencies based on direction of urbanity increase/decrease but halving them somewhat defeats the purpose of them being to explore the new geography changes easier and doubling them seems a bit severe, a log increase after baseline ubanity could work but it provides less control with the region setting, I guess you could add a way to turn it off.
ORTHOGANAL_STRICT flag to prevent road turns under highway altogether.
I were manually placing the road connections but our special placement is just about robust enough to spawn them reliably on it's own, infrastructure for being able to set a minimum distance between them in future would be nice though. The only major difference is the number of occurrences can't be tied to the presence and amount of highway in an overmap so minimum occurrences has to be 0 bc otherwise it will moan about failing mandatory placements on overmaps without highway and an excess may spawn when there are less than 4 half highways in an overmap.
Follow-up PRs:
CI
More map variety in general.
I have plenty of ideas for the map under the overpass based on looking at irl NE ones I just didn't want to bog this PR down with more unnecessary maps.
Support for ravines and railroad in order to enable highways in Aftershock Exoplanet and the Railroads mods respectively.
Maps for region overhaul mods in order to enable highways in them.
Varying the offset per row/column of highway so it isn't perfectly central in each overmap should be easily doable.
Adding more terrain/furniture to differentiate more between regular roads and highways (ie overhead signs, lights under overpass etc).
I have an in-progress PR working on improving stream intersections for vanilla and will likely allow them to pass "under" highways in that.
Adding start locations, achievs etc.
The new city tracking will allow a much more accurate city_distance rather than a heavily approximated one based on the city size and the centre point which would allow adding an extra road connection special entry that tries to place close to cities.
Testing
Screenshots
Basic Map
#########################################################################################
Road Bridge
#########################################################################################
Overpass w/ pic of map to show how the city forms around the highway
#########################################################################################
Clover Leaf w/ size on map for scale
#########################################################################################
Trumpet Intersection
#########################################################################################
Bend
#########################################################################################
Diamond Intersection
#########################################################################################
Rest Area Parking
Current bugs:
Additional context
Still to do:
Upload a exe release to my repo so peeps can test easier
Upload aseprite file
OMT symbols for all the specials >_< (Apologies in advance to overmap spriters)
@I-am-Erk is there a better way to tell when the oceans will occur than just using the region setting values? The current way works reliably but is overly conservative and stops several overmaps early in some cases, if there's a more accurate but still reliable method that'd be great. Depending how lakes work I wouldn't mind using the same avoidance technique for lakes in a follow-up PR bc obviously them crossing large lakes or even having intersections on lakes is dubious at best.
The region settings should be entirely optional if the external option is set to false
Ensure ramps always appear where expected
Mess with polish_river() to get the best result I can manage without major changes
Basic vehicle/zed/item spawns (not that much effort bc I already did lane based placement for vehicles in the JSON road PR)
special_field_highway more OMTs adjacent to specials where it looks silly if a building spawns
Improve symbolic OMTs on overmap edges?
Make some of the lambda functions private regular functions for readability?
Rename stuff that's changed use (ie place_highways) and reorganise stuff (also typo fix seperation -> separation), remove now unused code (road connection hardcoded placement, HIGHWAY_SPECIAL flag)
Check city road code still works after tweaks to specials and flags
Check documentation matches final functionality and naming