Closed clintbellanger closed 11 years ago
I added a debug line in Animation::isLastFrame().
After the zombie freezes, cur_frame keeps incrementing beyond number_frames.
I could resolve the issue by changing isLastFrame() to this (greater/equal instead of just equal)
bool isLastFrame() { return cur_frame >= number_frames - 1; }
But that seems like hiding a bug that exists somewhere else. BehaviorStandard says that the enemy should switch back to Stance if we're on the last frame of Enemy Hit:
https://github.com/clintbellanger/flare/blob/master/src/BehaviorStandard.cpp#L427
Somehow that's not happening correctly when the enemy is hit twice in a row, with specific timing.
Sequence of events from debug mode:
cur_state = ENEMY_HIT
cur_frame=1 cur_frame_index=0
cur_state = ENEMY_HIT
cur_frame=2 cur_frame_index=1
cur_frame=3 cur_frame_index=1
cur_frame=4 cur_frame_index=1
cur_frame=5 cur_frame_index=1
Because of the zombie's speed boost, his hit animation is only 1 frame.
"Hit" is the only sequence-breaking animation that can happen twice in a row (the others are Death/Crit-Death which always happen once). This is a bit confusing because state changes and animation changes are happening at different places, for significant reasons.
The main bad thing is that cur_frame is allowed to go beyond number_frames, which should be forbidden.
I'm going to specifically add code to prevent this from happening, instead of relying on outside functionality to behave.
I added Rapid Fire shot and I've been testing it.
It seems that if it doesn't kill an enemy (e.g. one with a lot of health) the enemy can be stuck in the "Hit" animation/state.
I'm working on debugging it. Here's what I know so far: