There's a homeless man in my neighborhood named Kevin that I chat with most mornings when I walk my dog. He goes to a methadone clinic to help treat his addiction. I usually see him when I'm walking towards the coffee shop, ask him for his coffee/breakfast order, and he hangs out with my dog while I go inside. Most days he's a nice, personable, friendly guy who tells me "dad jokes" and has a bag of dog treats for his neighborhood friends. Sober Kevin is appreciative and would never dream of asking me for a dime. Some days he's coming off a bender and looking for money to buy more drugs and is kind of a dick. A lot of the benders coincide with him being unable to get to the clinic for one reason or another.
Occasionally sober Kevin will apologize for the way he spoke to me when he was single mindedly focused on his next high. He once offered the analogy of when you really need to pee. The absolute only thing your brain is capable of focusing on is finding a bathroom. You're urgently trying to solve this one, desperate problem. You're walking around asking and asking where the bathroom is and people keep saying "I can't help you find the bathroom, but here's a vending machine."
It's by no means an excuse for someone to be rude to a stranger trying to help but it certainly helps me have a little bit more compassion for those dealing with addiction. I think it's frustrating for them, too.