Perimeter Scan Formulae Example:
There are probably many ways of doing this, which each give subtley different
results. These two examples are the ways in which I use the perimeter scan
formulae.
1. Using the "Math" Command (version 4 or lower):
math v1 = #x_pos - #enemy_x * #x_pos / #enemy_x
- #x_pos + #enemy_x * #enemy_x / #y_pos + #y_pos - #enemy_y * #y_pos /
#enemy_y - #y_pos + #enemy_y * #enemy_y
; Calculates the distance between the enemy and
you
if value ~v1 < 3 then goto attack
; If the value is less than 3, an enemy is next
to you!
2. Using the "Cmath" Command (version 5 and above):
cmath v1 = (#x_pos - #enemy_x)^2 + (#y_pos - #enemy_y)^2
; Calculates the distance between the enemy and
you
if value ~v1 < 3 then goto attack
; If the value is less than 3, an enemy is next
to you!