I pseudocode as follows:
We'll use a boss fight, since they tend to be rather complicated:
states:
-lock-on single shot - FASTEST
-pattern-fire, 3 patterns - FAST
-change positions / dash to new spot - MEDIUM
-dash at player / become vulnerable - SLOW (OVERARCHING LOOP)
-vulnerable - NO TIMER / HINGES ON DASH EVENT
progression:
-lock on and pattern fire count down together
-pattern fire should take approx twice as long - add double the time-remaining after each shot
-every time either shot occurs, set new dash position to one of 8 nodes
-if change-position counter hits 0 and:
-boss isn't already shooting
-boss isn't already dashing
-dash to new spot
-if dash timer is 0, halt all other actions and dash in direction of player
-when boss collides with a background tile, halt position / change state to "vulnerable"
There's more to this fight - but this is enough for me to start working. As I worked, I realized that I needed other state control, like the timings between the "i'm about to shoot" animation and the shot actually launching - and I needed to pause appropriate timers during these phases so my state machine wouldn't get confused.
Pseudocode in simple english, THEN move to pretend-programming language - and if something you planned ends up being a nightmare of state-juggling.. change it! Originally, the boss was supposed to dash at the player, hit a platform, then change states to "bouncing back / falling towards ground" - he could kill on contact in this state - and then would mode to a dead animation on the ground. I screwed something up logically aht burned a half day fixing it... So eventually I just nixed the "hit wall, bounce back, fall to ground" in favor of "hit wall, change animation, stop in that position" - battle still feels great and all is well!
Example of this finished boss fight in action:
http://www.youtube.com/watch?v=suy9g5_llAU