Speaking as someone who's dealt with chronic pain for, well decades, this applies to humans as well. I've noticed in myself and in others who I knew had pain issues that pain makes you cranky. The level of crank scales with the intensity of the pain.
It sounds kind of lame, but this principal helps my marriage at times. DH and I both deal with pain at times from chronic musculoskeletal issues - or as I like to say for the alliteration, connective tissue issues. If I comment on DH being grumpy and then ask if he's hurting and he says yes, then I'm like "ahh" and get off his back. On the other hand when he's just cranky for mood reasons, then I poke his cage a bit to try to snap him out of it. It never works, but who doesn't enjoy poking the other guy a bit?