How could I make a turret like in the attached video, be in my generated structure?

So would like to make turrets like these generate in my datapack. I'm not a beginner but I never worked with projectiles.

(Incase the video is not enough, this turret, detects the player in a line, revs up then starts firing the same line.)

My main questions are:

  • What should I use a s projectiles? (I tried lama spit which wasn't bad but it doesn't damage me for some reason. Maybe some collision detection + /damage work)

  • How could I make sure the projectile is shot the right direction no matter which way the turret faces, because in the structure it can face any direction

  • How to detect a player is in front of the turret so that it starts firing

The rest I can figure out on my own, but these would be a tremendous amount of help, because I'm only versed in simpler commands and world generation.

Continue to help post