What to do if this happens? Get to a place of security, armed until they go away?
Heres what I used to do when I lived in the city, I was about 5 blocks from a "housing project" every friday nite and sometimes every nite shots would ring out, sometmes lasting a long time as the gang bangers celebrated or whatever. I would get tired of it and tired of reporting it to the cops so I would unload my 30-06. 5 Rounds out of the cannon would silence the area for the nite. Guess they knew they were underpowered? not sure, but I got my sleep in.
Had a customer of the shop I worked at get killed in that project, they kicked in his door and shot up the place killing him. He always paid cash too