just found out I was pregnant at 20 weeks

I had a miscarriage earlier this year that really sent me into a depression where I started smoking cigarettes again after quitting 1.5 years ago (my friends smoke so it was a drunk night filled with emotions that lead me back to cigarettes) I guess I mentally wasn't ready to notice but I honestly didn't "feel" pregnant and my period wasn't back to normal yet so it was hard to track. I found out before getting some other tests done because they ask you when your last period was and I said "honestly, I haven't tracked it since but it's been a while." Here I am almost 22 weeks and my doctor said the patch is dangerous. My anxiety and depression is so bad I quitting is crippling. I know I need to but how? Will my baby be okay since I've smoked this long? 😔 I feel like such a piece of sh!t...