Two very useful tools in game dev -
Cross Product: "Tell if someone is to my right or left"
Dot Product: "Tell if someone is in front or behind me"
I cut off at the end, so look at the thumbnail for how I finished it, where I have the NPC yaw left or right based on if the player is to their left or right.