Shooting someone is an intentional act. Setting up a booby trap to shoot intruders is automating something that you could have done legally (shoot an intruder) except there is NOT intent. Intent to shoot the intruder is what makes it legal, so long as you meet the other requirements for self defense or the castle doctrine. Shooting someone without intending to shoot someone is negligence or worse. Building a contraption to shoot someone is setting in motion a chain of events specifically to cause a person to be shot with no possibility of satisfying the requirements to justify it.
Here's another scenario: you are cleaning your gun, when unknown to you a home invader is preparing to kick your front door in. Your gun goes off accidentally, shooting the home invader before he gets to your door. Legally it is not self defense, you have negligently shot someone. However, the robber can't sue you as felons do not have a recourse for injuries proximately caused by their own felony (if they are convicted) in California. In other states, the robber may be able to successfully sue even if he is convicted. Laws are weird.