Pretty straight forward. This code will accurately measure the distance between Selected and Target token. I have made this for my automated attack macro, this distance is designed to measure reach of a melee attack. distance required for a ranged or magic attack hit The output is already converted to ft. This
code prints the result to [$Total_distance_non_euclidean] so its pretty
plug and play with any other scriptcard. Just copy and past into an
already existing macro and it should just work All other code and references you use should go below --:FINALPRINT| Code is Bellow !script {{ --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --?[*S:t-height] -gt 70|BigBoi --?[*S:t-width] -gt 70|BigBoi --=source_Height|[*S:t-height]/70 / 2 - 1 {CEIL} --=source_Width|[*S:t-width]/70 / 2 - 1 {CEIL} --=target_Height|[*T:t-height]/70 / 2 - 1 {CEIL} --=target_Width|[*T:t-width]/70 / 2 - 1 {CEIL} --=source_Y|[*S:t-top]/70 --=source_X|[*S:t-left]/70 --=token_diff_height|[$target_Height] + [$source_Height] --=token_diff_width|[$target_Width] + [$source_Width] --=target_Y|[*T:t-top]/70 --=target_X|[*T:t-left]/70 --=Y_diff|[$source_Y]-[$target_Y] {ABS} {FLOOR} --=X_diff|[$source_X]-[$target_X] {ABS} {FLOOR} --?[$Y_diff] -lt [$token_diff_height]|[ --=Y_diff|1 --]|[ --=Y_diff|[$Y_diff] - [$token_diff_height] {ABS} --]| --?[$X_diff] -lt [$token_diff_width]|[ --=X_diff|1 --]|[ --=X_diff|[$X_diff] - [$token_diff_width] {ABS} --]| --?[$Y_diff] -lt [$X_diff]|[ --=X_diff_non_euclidean|[$X_diff]-[$Y_diff] --=X_diff_non_euclidean|[$X_diff_non_euclidean] *5 --=Y_diff_non_euclidean|[$Y_diff]*1.5 {FLOOR} *5 --=Total_distance_non_euclidean|[$X_diff_non_euclidean]+[$Y_diff_non_euclidean] --]|[ --=Y_diff_non_euclidean|[$Y_diff]-[$X_diff] --=Y_diff_non_euclidean|[$Y_diff_non_euclidean]*5 --=X_diff_non_euclidean|[$X_diff]*1.5 {FLOOR} *5 --=Total_distance_non_euclidean|[$X_diff_non_euclidean] + [$Y_diff_non_euclidean] --]| --^FINALPRINT| --X| --:BigBoi| --=source_Height_even_odd|[*S:t-height]/70 --%loop|until;[$source_Height_even_odd] -lt 1 --=source_Height_even_odd|[$source_Height_even_odd]-2 --%| --=source_Width_even_odd|[*S:t-width]/70 --%loop|until;[$source_Width_even_odd] -lt 1 --=source_Width_even_odd|[$source_Width_even_odd]-2 --%| --=target_Height_even_odd|[*T:t-height]/70 --%loop|until;[$target_Height_even_odd] -lt 1 --=target_Height_even_odd|[$target_Height_even_odd]-2 --%| --=target_Width_even_odd|[*T:t-width]/70 --%loop|until;[$target_Width_even_odd] -lt 1 --=target_Width_even_odd|[$target_Width_even_odd]-2 --%| --?[$source_Height_even_odd] -eq 0|[ --=source_Height|[*S:t-height]/70 / 2 {CEIL} --]|[ --=source_Height|[*S:t-height]/70 / 2 - 1 {CEIL} --]| --?[$source_Width_even_odd] -eq 0|[ --=source_Width|[*S:t-width]/70 / 2 {CEIL} --]|[ --=source_Width|[*S:t-width]/70 / 2 - 1 {CEIL} --]| --?[$target_Height_even_odd] -eq 0|[ --=target_Height|[*T:t-height]/70 / 2 {CEIL} --]|[ --=target_Height|[*T:t-height]/70 / 2 - 1 {CEIL} --]| --?[$target_Width_even_odd] -eq 0|[ --=target_Width|[*T:t-width]/70 / 2 {CEIL} --]|[ --=target_Width|[*T:t-width]/70 / 2 - 1 {CEIL} --]| --?[$source_Height] -gt 0|[ --=source_Height|[$source_Height]-1 --]|[ --]| --?[$source_Width] -gt 0|[ --=source_Width|[$source_Width]-1 --]|[ --]| --=source_Y|[*S:t-top]/70 --=source_X|[*S:t-left]/70 --=token_diff_height|[$target_Height] + [$source_Height] --=token_diff_width|[$target_Width] + [$source_Width] --=target_Y|[*T:t-top]/70 --=target_X|[*T:t-left]/70 --=Y_diff|[$source_Y]-[$target_Y] {ABS} {FLOOR} --=X_diff|[$source_X]-[$target_X] {ABS} {FLOOR} --?[$Y_diff] -lt [$token_diff_height]|[ --=Y_diff|1 --]|[ --=Y_diff|[$Y_diff] - [$token_diff_height] {ABS} --]| --?[$X_diff] -lt [$token_diff_width]|[ --=X_diff|1 --]|[ --=X_diff|[$X_diff] - [$token_diff_width] {ABS} --]| --?[$Y_diff] -lt [$X_diff]|[ --=X_diff_non_euclidean|[$X_diff]-[$Y_diff] --=X_diff_non_euclidean|[$X_diff_non_euclidean] *5 --=Y_diff_non_euclidean|[$Y_diff]*1.5 {FLOOR} *5 --=Total_distance_non_euclidean|[$X_diff_non_euclidean]+[$Y_diff_non_euclidean] --]|[ --=Y_diff_non_euclidean|[$Y_diff]-[$X_diff] --=Y_diff_non_euclidean|[$Y_diff_non_euclidean]*5 --=X_diff_non_euclidean|[$X_diff]*1.5 {FLOOR} *5 --=Total_distance_non_euclidean|[$X_diff_non_euclidean] + [$Y_diff_non_euclidean] --]| --:FINALPRINT| --+|[$Total_distance_non_euclidean] TOTAL FT. }}