How can you set Minecraft npcs?

Lu
2

I wanted to build an adventure map there npcs. Stand and don't move 2 should stand next to each other. The adventure map should be able to play 2. The 2 npcs. Stand opposite each other and should be such that you can't see from 5 blocks to 10 blocks away. If they do see one in the 10 blocks, an alarm should go off and they should get angry. If you shoot the outside of the 10 blocks nothing should happen unless I shoot one but my friend doesn't shoot him across the street. Should an alarm also go off. How do I program the npc or command blocks

Ri

For which Minecraft version?

Lu

1.15.2