Line of Sight specifics
-
kronenblatt
- General - Carrier

- Posts: 4821
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Line of Sight specifics
I'm trying to finally understand line of sight (LoS) in FoG2 a bit better. In particular when it comes to height differences, slopes, corner slopes, and angles.
1. What height above the terrain are the units assumed to be located?
2. Does the LoS then originate from:
2a. the centre of the unit's tile (in x and y, 2D)?
2b. and from the height of the unit or of the terrain itself (in z, 3D)?
3. (Ignoring terrain like forest, marsh, BuA), does LoS extend (the same point) of all tiles to which there is an uninterrupted straight line (x,y,z), "seeing" all these tiles?
4. (Again, ignoring terrain like forest, marsh, BuA), and finally: if my unit can see an enemy unit, the LoS works in the other direction, i.e., that enemy unit can always see my unit?
1. What height above the terrain are the units assumed to be located?
2. Does the LoS then originate from:
2a. the centre of the unit's tile (in x and y, 2D)?
2b. and from the height of the unit or of the terrain itself (in z, 3D)?
3. (Ignoring terrain like forest, marsh, BuA), does LoS extend (the same point) of all tiles to which there is an uninterrupted straight line (x,y,z), "seeing" all these tiles?
4. (Again, ignoring terrain like forest, marsh, BuA), and finally: if my unit can see an enemy unit, the LoS works in the other direction, i.e., that enemy unit can always see my unit?
kronenblatt's campaign and tournament thread hub:
https://www.slitherine.com/forum/viewtopic.php?t=108643
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
kronenblatt
- General - Carrier

- Posts: 4821
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Line of Sight specifics
Example:
The selected Brythonic Foot (at height 100) can "see" all nearby tiles at height 200 (marked with green dots), plus the one beyond with height 175 (green right dot at the top) but none of the height 150 (or lower) tiles beyond (marked with red dots).
So apparently the 175 height is acceptable LoS wise, but not the 150 and below.

The selected Brythonic Foot (at height 100) can "see" all nearby tiles at height 200 (marked with green dots), plus the one beyond with height 175 (green right dot at the top) but none of the height 150 (or lower) tiles beyond (marked with red dots).
So apparently the 175 height is acceptable LoS wise, but not the 150 and below.

kronenblatt's campaign and tournament thread hub:
https://www.slitherine.com/forum/viewtopic.php?t=108643
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
kronenblatt
- General - Carrier

- Posts: 4821
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Line of Sight specifics
In contrast, the Sub-Roman Foot to its right (at height 150) can see fully beyond the height 200 tiles, including a height 100 tile (left green dot, and the height 50 and 75 tiles to its left and right, respectively) and a height 75 tile (right green dot).


kronenblatt's campaign and tournament thread hub:
https://www.slitherine.com/forum/viewtopic.php?t=108643
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
kronenblatt
- General - Carrier

- Posts: 4821
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Line of Sight specifics
So it seemed at first that all tiles upslope and then flat are visible until downslope again, at which some of the downslope tiles beyond the flat area were visible and some weren't, depending on the height of the unit's tile and the respective tiles plus some angles. But then again, not...
... Since the cavalry here (at height 150) can "see" some tiles in the height 300 area in front of it (marked with green dots), but not all (marked with red dots).

... Since the cavalry here (at height 150) can "see" some tiles in the height 300 area in front of it (marked with green dots), but not all (marked with red dots).

kronenblatt's campaign and tournament thread hub:
https://www.slitherine.com/forum/viewtopic.php?t=108643
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
pipfromslitherine
- Site Admin

- Posts: 9933
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Line of Sight specifics
It's much more abstracted than that. It only uses the tile heights and their differentials. But it also has other internal rules to do with height going up and down again. The key thing to remember is that none of the units or terrain are 'actual size'.
There is no doubt that the logic can generate unintuitive results, but it is internally consistent.
Cheers
Pip
There is no doubt that the logic can generate unintuitive results, but it is internally consistent.
Cheers
Pip
follow me on Twitter here
-
kronenblatt
- General - Carrier

- Posts: 4821
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Line of Sight specifics
Thanks, Pip! In which files are this scripted?pipfromslitherine wrote: ↑Fri Aug 13, 2021 4:23 pm It only uses the tile heights and their differentials.
But it also has other internal rules to do with height going up and down again.
What do you mean by 'actual size' by the way?pipfromslitherine wrote: ↑Fri Aug 13, 2021 4:23 pm The key thing to remember is that none of the units or terrain are 'actual size'.
kronenblatt's campaign and tournament thread hub:
https://www.slitherine.com/forum/viewtopic.php?t=108643
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
pipfromslitherine
- Site Admin

- Posts: 9933
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Line of Sight specifics
The LOS is one of the few things which is hardcoded inside the engine, it would not be fast enough to run in script.
By actual size I mean that nothing is to scale, and none of the LOS logic happens based on the drawn size of the objects.
Cheers
Pip
By actual size I mean that nothing is to scale, and none of the LOS logic happens based on the drawn size of the objects.
Cheers
Pip
follow me on Twitter here
-
kronenblatt
- General - Carrier

- Posts: 4821
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Line of Sight specifics
Thanks, I'm getting a feel for it now, and the height differentials' effects on LoS: will need to test a bit more though.pipfromslitherine wrote: ↑Fri Aug 13, 2021 4:23 pm It only uses the tile heights and their differentials.
But it also has other internal rules to do with height going up and down again.
kronenblatt's campaign and tournament thread hub:
https://www.slitherine.com/forum/viewtopic.php?t=108643
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
Schweetness101
- Captain - Heavy Cruiser

- Posts: 928
- Joined: Tue Nov 29, 2016 6:12 am
Re: Line of Sight specifics
would it then be effectively impossible to make a mod that makes units themselves limit line of sight, in addition to terrain? IE where you cannot see enemy units that are behind other enemy units on the same terrain level?pipfromslitherine wrote: ↑Fri Aug 13, 2021 8:27 pm The LOS is one of the few things which is hardcoded inside the engine, it would not be fast enough to run in script.
By actual size I mean that nothing is to scale, and none of the LOS logic happens based on the drawn size of the objects.
Cheers
Pip
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
-
rbodleyscott
- Field of Glory 2

- Posts: 28411
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Line of Sight specifics
Not impossible, I have already done it in scripts for shooting, but for general LOS it would cause a large performance hit, because it would have to be done for every unit in the player's army vs every unit in the enemy army. (Because if any unit in your army can see them, they should be visible on the map). That's a lot of iterations, in the slower scripts.Schweetness101 wrote: ↑Wed Aug 18, 2021 8:39 pmwould it then be effectively impossible to make a mod that makes units themselves limit line of sight, in addition to terrain? IE where you cannot see enemy units that are behind other enemy units on the same terrain level?pipfromslitherine wrote: ↑Fri Aug 13, 2021 8:27 pm The LOS is one of the few things which is hardcoded inside the engine, it would not be fast enough to run in script.
By actual size I mean that nothing is to scale, and none of the LOS logic happens based on the drawn size of the objects.
Cheers
Pip
And every time a unit of either side moves, it has to be tested vs every unit in the enemy army, in case it has become visible or disappeared again.
See UnitBlockingLOS() and CheckRouteForBlockingUnit() in CombatTools.BSF. Note that it checks 3 different variant routes, otherwise there will be cases where a unit will be taking as blocking LOS when it really shouldn't.
So I suspect the performance hit would be too high to be acceptable, but you could try it and see.
Richard Bodley Scott


-
Schweetness101
- Captain - Heavy Cruiser

- Posts: 928
- Joined: Tue Nov 29, 2016 6:12 am
Re: Line of Sight specifics
Yeah I think it would probably be too high, I'm also not sure about all the places to call it. I was doing it in Callbacks.bsf->FLAG_TILES_CALLBACK which seemed to do the dim color/fog but not the actual blocking of unit visibility, plus it slowed the game to like 3 fps.rbodleyscott wrote: ↑Thu Aug 19, 2021 6:25 amNot impossible, I have already done it in scripts for shooting, but for general LOS it would cause a large performance hit, because it would have to be done for every unit in the player's army vs every unit in the enemy army. (Because if any unit in your army can see them, they should be visible on the map). That's a lot of iterations, in the slower scripts.Schweetness101 wrote: ↑Wed Aug 18, 2021 8:39 pmwould it then be effectively impossible to make a mod that makes units themselves limit line of sight, in addition to terrain? IE where you cannot see enemy units that are behind other enemy units on the same terrain level?pipfromslitherine wrote: ↑Fri Aug 13, 2021 8:27 pm The LOS is one of the few things which is hardcoded inside the engine, it would not be fast enough to run in script.
By actual size I mean that nothing is to scale, and none of the LOS logic happens based on the drawn size of the objects.
Cheers
Pip
And every time a unit of either side moves, it has to be tested vs every unit in the enemy army, in case it has become visible or disappeared again.
See UnitBlockingLOS() and CheckRouteForBlockingUnit() in CombatTools.BSF. Note that it checks 3 different variant routes, otherwise there will be cases where a unit will be taking as blocking LOS when it really shouldn't.
So I suspect the performance hit would be too high to be acceptable, but you could try it and see.
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488