Use Timer and LineOfSight behaviors. You can have multiple LineOfSight behaviors with different settings - for example one for long range, where the unit needs to move to the target, and another for close range where it can start shooting at the target.
Use instance variables for states. And NEVER use "Trigger once" condition in state machine code!
Here is a very simplified example, just to demonstrate the idea:
On Start of layout
----> Ally Start recurring Timer "find_new_target" every 2 seconds
Ally On Timer "find_new_target"
Ally has LineOfSightClose to Enemy
Enemy pick nearest to Ally
----> Ally set enemyUID to Enemy.UID
----> Ally set state to "attack"
Else
Ally has LineOfSightFar to Enemy
Enemy pick nearest to Ally
----> Ally find path to Enemy
----> Ally set state to "chase"