How many states does the sprite have? I'm guessing that the following is happening:

.CurState == K where K the max number of states, and K is even.

so when the line

`If (.CurState MOD 2) = 0 Then .CurState = .CurState + 1`

executes, it attempts to increase .CurState to greater than K, that is, greater than the max number of states. Hence, subscript out of range when the engine tries to access the sprite's [K+1]th state.

What you need to do, in that case, is simply make sure that .CurState doesn't get to that point. If you want it to loop around back to zero, you could simply change the line to this:

`If (.CurState MOD 2) = 0 Then .CurState = (.CurState + 1) MOD .rDef.StateCount`

I'm not sure if that's the answer, but it's highly likely that either that, or the opposite is true (with the line right below it). My guess, however, is that it's not a problem with the line below, since 0 MOD 2 != 1