User Tools

Site Tools


4rpl:commands:refreshunitloscache

This is an old revision of the document!


Index

RefreshUnitLosCache

RefreshUnitLosCache(<-unit)

Description

Causes the unit to perform line of sight calculations based on the LOS settings. The results are stored and used by API's like FindUnitEnemy. The LOS cache should be updated when the unit is moved, but not more frequently than absolutely necessary due to it's high performance cost.


The range of the unit is also a major factor in the performance intensity of calling this API. It is highly discouraged to use this API for any unit with a range larger than 100. If you however still do, the best way to deal with the performance intensity is to have each unit call RefreshUnitLosCache at a slightly different frame from each other to prevent major stutters and make the performance impact unnoticeable.

For additional reference, do not use this API for a unit with a range more than 200. Any much higher and this API on it's own even when called by a single unit has enough performance impact to cause a noticeable stutter. Besides, you should only really need a max of 200 range for any moving unit if it can go off map, even less if it can't. 300 range should be map-sized most of the time too and best suited for units like the Bertha which don't need this API due to being stationary and having indirect line of sight, being mortar like, or other such units which use GetMaxCreeperCell or GetMaxCreeperCellWithDamage instead of this far more expensive API.

In fact, when using GetMaxCreeperCell but you still want line-of-sight as a factor for a non-mortar-like unit, you can use the API GetTerrainLOS but the unit will only target a specific location so you will need to fill in the details on how it reacts to having a blocked line-of-sight.

There isn't much difference between a unit with 200 range and a unit with 300 range for most maps and circumstances anyways. So please consider this when using this API.

Examples

RefreshUnitLOSCache(self)

Index

4rpl/commands/refreshunitloscache.1648013391.txt.gz · Last modified: 2022/03/23 01:29 by Vertu