C7-Game / Prototype

An early-stage, open-source 4X strategy game
https://c7-game.github.io/
MIT License
32 stars 9 forks source link

Fog of war - consider tile elevation and obstacles #103

Open QuintillusCFC opened 2 years ago

QuintillusCFC commented 2 years ago

Certain type of terrain affect fog of war.

Hills and mountains and volcanoes let you see farther, but also prevent you from seeing past them.

This issue is to consider and implement that.

We should probably do this by adding a Height property to TerrainType, and setting it appropriately when importing from Civ3.

TBD whether Babylon or Carthage.

QuintillusCFC commented 1 year ago

Some notes:

Mountain rules Mountains see two unless blocked Other mountains block mountains Hills do not block mountain visibility Forest/jungle do not block mountain visibility

image Abe Lincoln can see two tiles across the jungle from the Mountain

Hills rules

Hills see two unless blocked Hills block hills Forest/jungle block hills Mountains block hills

image The Scout can see distance 2, with nothing blocking the view

Flatland rules

Hills and mountains visible at distance 2 over Marsh Mountains visible at distance 2 over Jungle and Forest Hills not visible at distance 2 over Jungle Cannot see forests/jungle at distance 2 Mountains visible at distance 2 over Hills

image The settler can see the Hill at distance 2 across the Marsh

image Theodora cannot see the Hill across the Jungle

image Theodora can see the Mountain across the Jungle

image Theodora cannot see the forest that is SE of the game

image The Worker can see the Mountain despite the Hill in front of it

Coast rules

Can see distance 2 over water, but cannot use water to see around obstacles Can see distance 2 across water even when it's across a pond into an ocean

image Abe Lincoln can see distance 2 across water, but not around the forest.

image Theodora can see across the fish-pond into the ocean even though there's a strait across the pond

General Rules

Either of the tiles that connect your tile to the tile two tiles away can be used for visibility

image Theodora's view of the Hill is blocked by another Hill in one direction, but she can still see it over the Grassland

QuintillusCFC commented 1 year ago

Based on these observations, I think the height property idea is still valid, although my understanding has evolved a bit, particularly with regards to forest/jungle (but not marsh) blocking hill visibility.

One potential approach:

Tiles with a height of 2 are visible from distance 2, as long as the tile in between has a height at least 2 less than their height.

You can also see tiles whose height is at least 2 lower than where you are standing at distance 2, as long as the tile in between has a height at least 2 lower than where you are standing.

Sean-Brown commented 7 months ago

Can these values be configurable and the logic made more generally applicable? For example if we add new terrain types or want the terrain to have different visibility modifiers in mods/scenarios?

QuintillusCFC commented 6 months ago

I think it should be configurable. The imported-from-Civ3 rules would have values that would cause equivalent behavior to Civ3, but by making the visibility depend on a general elevation system, a scenario could add/modify terrains to cause it to behave differently.

Using the numbers I proposed previously, this would allow something like a "Highlands" terrain with a value of 3.