Even if it is a bad guy and not a family member, pet, or drunk neighbor, ensconcing oneself in a safe position, dialing 911, and loudly announcing that you have a gun and have called the cops is likely to save money for carpet cleaning bills and legal fees.Tam pretty much states my plan. I have a loaded gun next to the sofa downstairs. My plan if I ever hear anything that sounds like an unwanted visitor breaking in is to grab the gun, release the safety, and... not try to go upstairs. Out the door and a phone call to the police would be the plan. Upstairs, same thing. Grab the gun, quietly close and lock the bedroom door, put the bed between myself and the door, and call 911. With the last part not so quiet. Bangety is great fun in the controlled environment of the range, and I've made the decision that I will go bangety if I ever really have to, but I'd rather not go bangety unless absolutely forced into it. And I don't want to be having to move myself and the cats into a hotel room in the middle of the night because there's a nasty mess in the hallway.
I do have the advantage of security cameras around the house that constantly feed to my phone. I don't have to go check out a noise: I just pull the feed up. Given that I live in the woods, there's lots of noise around my house, even in the winter. Raccoons and opossums are nightly visitors because I have food out for the ferals. After so many years, I can tell which one is out there just by how much noise they make: the opossum is much quieter in its explorations than the raccoon is. I hear movement and a bit of dish rattling but not the rambunctious thumping and bumping the raccoon makes.
Funny thing is that the largest of my visitors is the one I've never heard. I haven't seen any sign of him yet this year, but last year he explored my decks and porch several times. And pooped on my steps, wrecked the metal crook the bird feeder hangs from, and got into the garbage the one night I forgot and left the bin out. That was the only way I knew he'd been by until I checked the security video.