From a personal experience, I used to self medicate with marijuana and other things through out high-school (in retrospect now) because of a growing loss of self and interactions with my family. I had a step parent who could be quite verbally abusive, and the other would never do anything to negate the negative interactions between all of us. After a few years of self destructive habits and relationships, I tried mushrooms and it ironically got me to stop using drugs as I came to realize the scope of the win-lose relationships I got sucked into because of it (e.g. friends who were there just for drugs etc.) and after awhile came to the terms of the social anxiety I have which I repressed with drugs.
I can't quite relate to the extreme physical pains you speak of, but I know for my case it filled the emotional/social gap for awhile I couldn't relate to people who were sober and rather couldn't empathize with my self because it was too anxiety provoking to come to the truth of the matter.
I got a lot of work to do, but is this the kind of thing you are alluding to The Wandering Shaman? Anyway, sorry for all the negative things mentioned so far, I hope you all find peace with it!