Page 1 of 1
Line of Sight specifics
Posted: Fri Aug 13, 2021 11:51 am
by kronenblatt
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?
Re: Line of Sight specifics
Posted: Fri Aug 13, 2021 2:11 pm
by kronenblatt
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.

Re: Line of Sight specifics
Posted: Fri Aug 13, 2021 2:24 pm
by kronenblatt
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).

Re: Line of Sight specifics
Posted: Fri Aug 13, 2021 3:10 pm
by kronenblatt
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).

Re: Line of Sight specifics
Posted: Fri Aug 13, 2021 4:23 pm
by pipfromslitherine
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
Re: Line of Sight specifics
Posted: Fri Aug 13, 2021 4:24 pm
by kronenblatt
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.
Thanks, Pip! In which files are this scripted?
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'.
What do you mean by 'actual size' by the way?
Re: Line of Sight specifics
Posted: Fri Aug 13, 2021 8:27 pm
by pipfromslitherine
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
Re: Line of Sight specifics
Posted: Sat Aug 14, 2021 9:11 pm
by kronenblatt
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.
Thanks, I'm getting a feel for it now, and the height differentials' effects on LoS: will need to test a bit more though.
Re: Line of Sight specifics
Posted: Wed Aug 18, 2021 8:39 pm
by Schweetness101
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
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?
Re: Line of Sight specifics
Posted: Thu Aug 19, 2021 6:25 am
by rbodleyscott
Schweetness101 wrote: ↑Wed Aug 18, 2021 8:39 pm
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
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?
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.
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.
Re: Line of Sight specifics
Posted: Thu Aug 19, 2021 3:21 pm
by Schweetness101
rbodleyscott wrote: ↑Thu Aug 19, 2021 6:25 am
Schweetness101 wrote: ↑Wed Aug 18, 2021 8:39 pm
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
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?
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.
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.
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.