User Tools

Site Tools


4rpl:commands:refreshunitloscache

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
4rpl:commands:refreshunitloscache [2021/02/07 16:06] virgilw4rpl:commands:refreshunitloscache [2022/03/23 01:29] – Further advise and applications on top of previous edit Vertu
Line 6: Line 6:
  
 ===== Description ===== ===== Description =====
-Causes the unit to perform line of sight calculations based on the LOS settings. The results are stored and used by APIs like FindEnemy. The LOS cache should be updated when the unit is moved, but not more frequently than necessary.+Causes the unit to perform line of sight calculations based on the LOS settings. The results are stored and used by API'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 ===== ===== Examples =====
 <code 4rpl> <code 4rpl>
4rpl/commands/refreshunitloscache.txt · Last modified: 2024/01/19 01:11 by Vertu