User Tools

Site Tools


4rpl:commands:movetowardscellandavoid

Index

MoveTowardsCellAndAvoid

MoveTowardsCellAndAvoid(<-start <-targetCellX <-targetcellZ <-delta <-minHeight <-checkRange <-checkCreeper <-checkAC <-checkPseudoTerrain) ->pos

Description

Takes a starting 3D position (a 3-vector) and generates a new 3D position using two variables for the X and Z coordinates that can be used by SetUnitPosition to move towards the target location. The resulting point will not be displaced more than the delta argument.

  • The minHeight argument restricts how close, height wise, the resulting point can be to the terrain and/or creeper.
  • The checkRange argument is an integer that specifies how many cells outward to inspect when enforcing the minHeight. A value of 0 means to only check the map cell that the unit is currently occupying.
  • The checkCreeper argument is a Boolean indicating whether to look at creeper for enforcing the minHeight.
  • The checkAC argument is a Boolean indicating whether to look at anticreeper for enforcing the minHeight.
  • The checkPseudoTerrain argument is a Boolean indicating whether to look at invisible pseudo terrain (like from shields) for enforcing the minHeight.

:NOTE:
To clarify, the only difference in this API and MoveTowardsAndAvoid is that you can independently specify an X coordinate variable and an Z coordinate variable while not needing a Y coordinate variable. The generated next position will not be limited to the X and Z axis unlike how other TowardsCell API's like RotateUnitTowardsCell tend to behave.
So be sure to avoid thinking of this API as being similar in behavior to the other TowardsCell API's or it will get very confusing very quickly.
If you came to this API thinking it could generate a next position on only the X-Z axis's, a way to do so is to take the resulting V3 and set the Y-vector to the unit's Y-position.

Examples

#Move a unit towards a destination and crawl over creeper, anticreeper, and shields
42 ->targetX
23 ->targetZ
0.1 ->speed
1 ->minHeight
SetUnitPosition(self MoveTowardsCellAndAvoid(GetUnitPosition(self) <-targetX <-targetZ <-speed <-minHeight 1 true true true))

Index

4rpl/commands/movetowardscellandavoid.txt · Last modified: 2022/03/31 18:42 by Vertu