I'm making a standard fighting game damage system (velocity effect meaning both speed and direction). The velocity effect is based solely on the direction the player is facing, so it should work regardless of the direction the enemy is facing.

First step is programming straight horizontal push/pull (direction is 0 or 16) effect of Player's attack

Direction effect of Player's attacks on Enemy
Values:
Push away = 0
Pull towards player = 16
Player's Direction facing right = 0
Player's Direction facing left = 16

Player facing Right + Push away effect
0 + 0 = 0

Player facing Right + Pull effect
0 + 16 = 16

Player facing Left + Push away effect
16 + 0 = 16

Player facing Left + Pull effect
16 + 16 = 32
What I do is set the direction (value of 0 to 31) to a variable, then add Player's direction (0 for facing right, 16 for facing left), then set the speed of enemy by retrieving the value of that said variable

As for the direction being a value of 32, I have an event like this

+Direction value = 32
+ limit to one action if event loops
-> Set Direction value to 0

I have problems when the player is facing left while attacking. It's weird because it sometimes works, it sometimes doesn't (has opposite direction effect). By sometimes, I mean I keep testing it countless times. I have no idea why it keeps

Player facing Left + Push away effect
16 + 0 = 16
^this above should result to the enemy being pushed to the left (because player is facing left), but sometimes, the enemy is "pulled" towards the player (therefore moving to the right)

Player facing Left + Pull effect
16 + 16 = 32

^this above should result to the enemy being "pulled" to the right (because player is facing left), but sometimes, the enemy is "pushed" away from the player (therefore moving to the left)

Anyone please help? thanks.