Skip to content
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

Draft
wants to merge 51 commits into
base: master
Choose a base branch
from

Conversation

Procyonae
Copy link
Contributor

@Procyonae Procyonae commented Feb 18, 2024

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 map 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

image

Basic Map

#########################################################################################

image

Road Bridge

#########################################################################################
image

image

Overpass w/ pic of map to show how the city forms around the highway

#########################################################################################
image

image

image

PRPicClover

Clover Leaf w/ size on map for scale

#########################################################################################
image

image

PRPicTrumpet

Trumpet Intersection

#########################################################################################
image

Bend

#########################################################################################
image

image

PRPicDiamond

Diamond Intersection

#########################################################################################
image

Rest Area Parking

Current bugs:

  • Symbolic ramps are placed on overmap boundaries and at the edge of fallback intersections where there's no actual ramp
  • Occasionally non-city roads pay the extortionate cost of pathing non-straight through the highway, might be able to just "delete" non perpendicular roads in finalize_highways() to get around this

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

@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. [JSON] Changes (can be) made in JSON Mods Issues related to mods or modding Map / Mapgen Overmap, Mapgen, Map extras, Map display [C++] Changes (can be) made in C++. Previously named `Code` Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. [Markdown] Markdown issues and PRs Mods: Aftershock Anything to do with the Aftershock mod Mods: MA Massachussetts mod. Cata in one state Mods: Defense Mode Anything to do with the Defense Mode mod Mods: Innawood 🌲 Anything to do with Innawood mod Mods: TropiCataclysm 🌴 Having to do with the tropical region mod for DDA. Mods: Desert Region Anything relating to the Desert Region mod <Enhancement / Feature> New features, or enhancements on existing labels Feb 18, 2024
@Procyonae Procyonae changed the title ~~0.Highways~~ 0.Interstates 0.Interstates Feb 18, 2024
@IdleSol
Copy link
Contributor

IdleSol commented Feb 18, 2024

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?

@Procyonae Procyonae force-pushed the HighwaysForRealisieThisTime branch from c5a7198 to fd31b4e Compare February 18, 2024 15:26
@github-actions github-actions bot added the <Bugfix> This is a fix for a bug (or closes open issue) label Feb 18, 2024
stop_when_chosen_offet++;
}
}
debugmsg( "Failed to seed highway offset with chosen value %s and expected max %s", chosen_offset,
Copy link
Member

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

Suggested change
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,

@worm-girl
Copy link
Contributor

Amazing. I was just wishing we had these!

@Procyonae
Copy link
Contributor Author

Have you raised the question of increasing the default distance between cities? Say from 4 to 5, maybe 6?

I don't see how that's particularly relevant to this PR, this makes traversal of multiple overmap distances easier not distances between cities

src/mapgen.cpp Outdated Show resolved Hide resolved
@IdleSol
Copy link
Contributor

IdleSol commented Feb 18, 2024

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.

  1. We get new good roads. And most importantly, they're straight. You can get the maximum speed and maintain it not for a couple of minutes, but much longer.
  2. You may disagree. But the distances between cities are too small now. Moreover, interesting locations are also close by. What's the point of traveling somewhere far away? Another city, another lab. The ocean? Look at it and forget it.
  3. Changing the "city spacing" parameter will increase the distance between cities and, as I understand it, increase the distance between points of interest.
  4. The result is that the places of interest are farther away, the speed of travel is faster. The player will spend about the same amount of time. And the world will become more real.

So, in my opinion, new roads and distances between cities are interconnected.

P.S. I hope I didn't mistranslate anywhere.

@Procyonae
Copy link
Contributor Author

Procyonae commented Feb 18, 2024

  1. We get new good roads. And most importantly, they're straight. You can get the maximum speed and maintain it not for a couple of minutes, but much longer.

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.

  1. You may disagree. But the distances between cities are too small now. Moreover, interesting locations are also close by. What's the point of traveling somewhere far away? Another city, another lab. The ocean? Look at it and forget it.

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.
Erk is also suggesting adding semi set faction base and city locations which will heavily encourage long distance exploration #70056

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.

  1. Changing the "city spacing" parameter will increase the distance between cities and, as I understand it, increase the distance between points of interest.

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.

@IdleSol
Copy link
Contributor

IdleSol commented Feb 18, 2024

There will still be vehicles on the road you won't be safely barrelling down the road at 100mph

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?)

@Procyonae
Copy link
Contributor Author

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.

@IdleSol
Copy link
Contributor

IdleSol commented Feb 19, 2024

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.
at 0 level = surface or z=0.

Can a roadblock appear at z=1? (debug menu / m /m / 8)

@IdleSol
Copy link
Contributor

IdleSol commented Feb 19, 2024

I made a little testbed. To be honest, I'm not sure everything is accounted for.

z=0
1

z=1
2

Character (z=0) looks up (z=1)
3
4

Character, can't see the platform. Platforms do not see the character. But if you get up close and stand on the tiles marked by the target.
5

Both the character and the platform see each other. Moreover, the platform hits the character.

And if you pay attention, you can see the casing from the other platform, but you can't see the platform itself. How normal that is, I don't know. Maybe it's a bug?

UPD.
Did I understand correctly that the 3D view takes into account the character's height? And monsters have no height, so for the game it is 0? In fact, they are flat? So they can only see on neighboring squares. Should we create a new topic? (bug or issue?)

@ehughsbaird ehughsbaird force-pushed the HighwaysForRealisieThisTime branch from fb13247 to 060f0ff Compare December 3, 2024 17:27
@db48x
Copy link
Contributor

db48x commented Dec 7, 2024

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.

@Procyonae
Copy link
Contributor Author

Eh it was working at some point so that shouldn't be too bad to fix, this isn't mergable though, see above

@db48x
Copy link
Contributor

db48x commented Dec 7, 2024

Yea, I had to fix some very minor errors. I suppose that could have broken it, but my changes look quite benign…

@Procyonae
Copy link
Contributor Author

By at some point I meant like May, I doubt whatever you did borked it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. <Documentation> Design documents, internal info, guides and help. <Enhancement / Feature> New features, or enhancements on existing EOC: Effects On Condition Anything concerning Effects On Condition Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Map / Mapgen Overmap, Mapgen, Map extras, Map display [Markdown] Markdown issues and PRs Mods: Aftershock Anything to do with the Aftershock mod Mods: Backrooms Mods: Defense Mode Anything to do with the Defense Mode mod Mods: Desert Region Anything relating to the Desert Region mod Mods: Innawood 🌲 Anything to do with Innawood mod Mods: MA Massachussetts mod. Cata in one state Mods: TropiCataclysm 🌴 Having to do with the tropical region mod for DDA. Mods Issues related to mods or modding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Highways do not spawn
9 participants