Here's the logic for killing an enemy.
It first tries to skip the kill logic by doing some conditionals.
If it doesn't skip it, then it writes a space over the enemy, it sets the enemy state to -1 to set it as dead, and stops the shot.
It would be much clearer with significant variable identifiers.

プレイ済み