Here's how I do it:
If enemy.mode="wandering"
- wandering code
- if distance(enemy.x, enemy.y, player.x, player.y) is less than 1000, set enemy.mode to "chasing"
If enemy.mode="chasing"
- move toward player
- if distance(enemy.x, enemy.y, player.x, player.y) is less than 100, set mode to "preparing to attack" and set enemy.timervariable to 1
If enemy.mode="preparing to attack"
- subtract dt from enemy.timervariable
- if enemy.timervariable is equal to or less than 0, set enemy.mode and animation to "attacking"
If enemy.mode="attacking"
- on animation finished, set enemy.mode to "wandering"
I also use submodes and/or numbered steps like so:
If enemy.mode="attacking"
- If enemy.mode2="start"
- - if enemy.stepnumber=0
Using this technique it keeps the code isolated and easy to follow while enabling complex behavior, and you don't have to worry about trigger once not working for multiple instances.