A_FadeOut and
A_FadeIn by default remove and add from an actor's alpha without limit. Which means they can make it drop below 0 and above 1.0, at which point you'd need to increase them above 0 / reduce them below 1.0 to see any effect.
Which means you're seeing the consequences of the following:
- Looping the Spawn states and See states will result in the player's alpha increasing by 1.0, at an extreme rate in the case of the Spawn states, while A_FadeIn isn't commented out. This results in the player's alpha shooting up to 36.0 in a second of standing still.
- The Pain state has a chance to be entered and its function executed during each separate damage instance. So, say, if your player is hit by a SSG or a functionally identical equivalent, it has a 75% chance of reducing its alpha by 0.333. Then it has another 75% chance of reducing it by 0.333. Then another. Then another. Then another. Then another until it's had 20 chances to do this, as the SSG launches 20 hitscans which all count as separate damage instances. This means that a full-power SSG blast will, by average, reduce your player's alpha by 4.995, likely resulting in an alpha of about -2.995 to -0.995 if its alpha hasn't been shot up ridiculously by standing still. Combine that with the fact that only the last instance will raise this by 0.333 ( since the other A_FadeIn is canceled out by the second A_FadeOut ) and it's not hard to see why the player would remain invisible for a while if they didn't stand still and let the extreme rate of alpha increase go into effect, especifcally if they get constantly bombarded by damage instances that don't allow the A_FadeIns following the Pain state to apply.
So, yeah. Not really surprising that it ends of being all wonky.
Your best bet is to use
A_FadeTo instead, since it will prevent the alpha from going over or under a cap you manually set. You could also use
A_SetTranslucent, since you're not exactly utilizing the dynamic transluency adjustment the Fade functions provide. Finally, you can use A_FadeIn and A_FadeOut's FTF_CLAMP flag to prevent them from setting the alpha below 0 and above 1.0, which will also disable one of the main reasons why I would never recommend using the Fade functions on a player: the fact that they will remove an actor at or below 0 alpha after altering its alpha, which may have been special cased to not apply to player actors but either way removing a player actor while a player is current controlling it is a Bad Thing.
That will cause ZDoom to crash. Because it's that Bad.