Few things test a cat owner like finding a puddle by the door, and the instinct to read it as revenge is exactly the wrong start. A cat that abandons its box has a reason, and the reasons run in a rough order of urgency worth following.
The vet comes first
A sudden change in toilet habits is a medical symptom until proven otherwise. Cystitis, a urinary infection, crystals or stones and simple pain can all drive a cat off its box, and in a male cat straining to urinate with little coming out is a genuine emergency that needs a vet the same day. Before you rearrange the litter, rule out the thing that a litter tray cannot fix.
Then the box, from the cat's point of view
Cats are exacting about their toilet, and most protests are about the box rather than the cat. The usual culprits are a tray that is not clean enough, a litter the cat dislikes underfoot, a box that is too small or covered, an awkward or busy location, and too few trays — the rule of thumb is one per cat plus a spare. Change one thing at a time and the fussy cat usually tells you which it was.
Then stress and territory
Once health and housekeeping are ruled out, look at what has changed — a new pet, a new baby, building work, or tension with another cat guarding the route to the tray. Clean any soiled spot with an enzyme cleaner rather than an ordinary one, because a lingering scent invites a repeat, and never punish the accident: to the cat it reads as a reason to avoid you, not the spot, and the stress makes matters worse.
Why has my cat suddenly started peeing outside the litter box?
Treat a sudden change as medical first — infections, crystals, stones and pain all cause it, and a male cat straining with little result is an emergency. Only once the vet has ruled those out is it worth looking at the box, the litter and stress.
How many litter boxes should I have?
The common guide is one box per cat plus one spare, in separate, quiet spots. Too few trays, or all of them in one place, is a frequent reason a cat starts going elsewhere.
Should I punish my cat for going outside the box?
No. Punishment teaches a cat to avoid you rather than to use the tray, and the added stress often makes the problem worse. Find and fix the cause instead, and clean accidents with an enzyme cleaner so the scent does not draw a repeat.