How to make the A.I scared of you?

How would I make the ai back away from the player in fear? Like if I had a zombie and then the player pulled out a torch, the zombie would keep his distance but keep following the player until it runs out.

I would probably have the player character generate a certain amount of “threat” that the A.I. responds to. So for instance, if the amount of threat generated by the player is zero, it would attack. But if the player pulls out a torch that would increase the amount of threat to 50, causing the A.I. to back down. You could further expand on this and have a mechanic where the A.I. will run away when the amount of threat gets even higher. You could also stack multiple effects together. For instance, if the player pulls out a torch it causes +50 threat, but if the player also pulls out a gun, it would add another 50 threat, causing the A.I. to respond differently.

Thinking even further you could also calculate the amount of threat depending on the pawn looking to attack the player. What is threatening to a zombie might not be threatening to a human and you could have different responses.

I hope that helps.