Opened 12 years ago

Closed 11 years ago

Last modified 8 years ago

#1610 closed defect (fixed)

[PATCH] Improve build restrictions for walls

Reported by: historic_bruno Owned by: peter
Priority: Should Have Milestone: Alpha 14
Component: UI & Simulation Keywords: patch
Cc: sanderd17@… Patch:

Description

  • Walls should be placeable on shores and even into shallow water, preventing enemy units from passing along the shoreline to reach fortified areas.
  • Walls should be placeable against cliffs and steep hills, to seal gaps on certain maps.

Walls likely need a separate passability class from other land buildings, but it's tricky given the current passability criteria: a shoreline might be too steep, regardless of water depth, for a unit to approach and build the wall - this could be resolved by an efficient pathfinder check but we don't have that yet. A similar problem occurs with building walls next to cliffs, the wall's height gets adjusted upward and it looks ugly but it also affects reachability (units can't pass too steep terrains).

Maybe the build restrictions need rethinking to be less coupled with the pathfinder since they are different problems.

Attachments (1)

walls.diff (12.5 KB ) - added by sanderd17 11 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by Deiz, 12 years ago

I'd like to do this for alpha 11. It seems like a logical bit of polish to add, being that there's been so much focus on walls and gates in this release.

The current shore building and regular unit passability classes are actually somewhat divergent.

As far as I know, the behaviour is as follows: A dock can be 2 tiles (8m) from shore and allows a maximum slope of 1.25, if you get it just right, you can put a dock in 2.5m deep water, which is slightly too deep for units to get to (they'll go into 2m deep water and have a 1m reach, IIRC), leading to validly-placed foundations that can never be built.

Giving the wooden outpost a shore passability class also let me place it in the middle of the water in the Romans Sandbox, far away from anything reachable by units. Oddly, I couldn't replicate that with the dock, even though the dock's obstruction isn't all that huge; might be that it relates to the dock's build-on-surface property.

I'm far too tired to grok the behaviour of the end of CCmpPathfinder::CheckBuildingPlacement, but it seems like on most maps, the coastline slopes downwards smoothly and then drops off fairly quickly. Because of that, it ought to be a lot easier to place unbuildable wall foundations using the shore passability class than it is for docks, as walls have much smaller and/or narrower obstructions.

A simple solution might combine the shore requirements with a maximum depth, allowing for a degree of terrain steepness but ensuring foundations beyond some arbitrary size are always reachable.

comment:2 by wraitii, 12 years ago

It seems like the easiest way would be to allow walls to be built on any walkable tile by a normal unit (perhaps completely disregarding the building passability class itself).

comment:3 by Deiz, 12 years ago

I gave that a shot a while ago. The issue with that actually blocking paths becomes extremely finnicky, because building placement becomes invalid as soon as any one tile fails the specified conditionals.

Crude ASCII example:

[ ] is a passable tile, [x] is impassable.
[ ][ ][ ][x]

A unit can walk into the third tile:
[ ][ ][u][x]

However, a tower that's two tiles wide can't overlap with
the impassable tile, so it can only be built like so:
[ ][T][T][x]

Essentially, using the unit passability criteria makes placement need to be near-perfect, else there will be one-tile gaps that remain unblocked, which units might slip through.

comment:4 by wraitii, 12 years ago

I've seen this before, but making walls placement check for the center would be a solution to that problem.

comment:5 by Deiz, 12 years ago

Assuming you mean only checking the center tile for each of the criteria, you might end up with a wall tower clipping into a cliff, or hanging halfway over top of one.

An important thing to note is that the range for builders is hard-coded to 2m, and that starts from the midpoint of their obstruction. Most infantry units have an obstruction radius of 0.8m, so effectively they can be at most 1.2m away from a target to build it. Keep in mind that a tile is 4m, so one row of impassable tiles between a builder and its target will easily prevent building, as will half a tile.

In light of that, it seems like at least one of the obstruction's border tiles should be required to meet the unit passability requirements, and perhaps everything else should be held to a looser standard.

by sanderd17, 11 years ago

Attachment: walls.diff added

comment:6 by sanderd17, 11 years ago

Cc: sanderd17@… added
Keywords: patch review added
Summary: Improve build restrictions for walls[PATCH] Improve build restrictions for walls

I added a new building restriction class ("land-shore") which is mapped to the "default" passibility class (i.e. everywhere a unit can go).

So now, walls can also be build in shallow water.

Next to that, I implemented Wraitii's suggestion. So the wall towers* only check for the passibility of the center point. That means it's a lot easier to aim, and it doesn't matter anymore how you rotate your wall tower. The obstruction check still uses the complete footprint. Just so you don't build on trees.

I did this by overloading some functions with a boolean argument. Just to keep as much of the original functions as possible.

(*)and also walls, but this doesn't matter, as you can't build a wall on its own, and nobody builds a wall parallel to impassable terrain

comment:7 by historic_bruno, 11 years ago

Milestone: BacklogAlpha 14

comment:8 by historic_bruno, 11 years ago

Should we simplify that to all buildings testing only the center point's passability? I think the same argument made for walls could be extended to any other building, even if walls are most problematic. It would make some sense, we only test the center point for territories.

comment:9 by sanderd17, 11 years ago

hmm, I don't think that would be looking good. Imagine important buildings like barracks or civil centers sticking half into a cliff, or hanging half over it. For wall towers, it works pretty good as they have a quite small footprint (which would certainly happen, as competitive players want to use all tha space they get, and the AI doesn't care about looking good).

If you want to try it, the change to make based on this patch is trivial, so you can always test it.

comment:10 by peter, 11 years ago

Owner: set to peter
Resolution: fixed
Status: newclosed

In 13542:

Allow building walls along the shore. Patch by sanderd17. Fix #1610.

comment:11 by alpha123, 11 years ago

Thanks for the patch. :)

I echo sanderd17's last comment, it doesn't make sense to check just the center point of every building.

comment:12 by sanderd17, 8 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.