User Tools

Site Tools


4rpl:commands:findunitenemy

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
4rpl:commands:findunitenemy [2023/03/01 14:19] – Performance information added Vertu4rpl:commands:findunitenemy [2025/02/14 14:57] (current) – external edit 127.0.0.1
Line 13: Line 13:
 firePriority is interpreted differently in each case. For deepest (the mortar) firepriority chooses between targeting creeper or mesh (it picks one and ignores the other). firePriority is interpreted differently in each case. For deepest (the mortar) firepriority chooses between targeting creeper or mesh (it picks one and ignores the other).
 For nearest (the cannon) firePriority will find either if the other (creeper or mesh) is not present. For nearest (the cannon) firePriority will find either if the other (creeper or mesh) is not present.
 +
 +If the unit can move, you'll want to use [[4rpl:commands:refreshunitloscache|RefreshUnitLosCache]] after it has finished moving to properly calculate its new line of sight to make sure it can target properly.
 ===== Performance ===== ===== Performance =====
 This API is performance expensive when many custom units call it. There for, it would be utmost wise to not call FindUnitEnemy more than absolutely necessary within a unit's script.\\ This API is performance expensive when many custom units call it. There for, it would be utmost wise to not call FindUnitEnemy more than absolutely necessary within a unit's script.\\
 As to be expected, the larger the range of the unit, the more expensive this API becomes.\\ As to be expected, the larger the range of the unit, the more expensive this API becomes.\\
-A performance efficient example is provided. Units with longer range should have a higher upper bound in [[4rpl:commands:randint|RandInt]].+A performance efficient example is provided. Units with longer range should have a higher upper and lower bound in [[4rpl:commands:randint|RandInt]].
 ===== Examples ===== ===== Examples =====
 <code 4rpl> <code 4rpl>
4rpl/commands/findunitenemy.1677680389.txt.gz · Last modified: 2025/02/14 14:56 (external edit)