how do yahtzee makes tha 1213 ai (shoot-dead effect on guards and the following AI on bosses)?
Simply put, he uses the x and y coordinates of the characters and the player.
E.g. the guards start shooting you as soon as you get to their level (guard.y == player.y).