You have to sit down go within and contemplate. Ask yourself questions and seriously attempt to find an answer. Find your voice of reason. Another thing to do, sit down and notice all the areas of your body that are tense during an episode and focus on it, don't untense it but just pay attention to it until it relaxes and move on the the next tense area. Our thoughts and emotions and desires even, get bundled up in our automatic physiological habits and if we don't pay attention we get lost in translation, irrational thoughts are the product of an unexamined body . Learning to be with each breath in and out without holding on to the ones that have passed, enjoy breathing unencumbered with smoking. Everytime you get distracted by thought allow your attention to find that tense part of your body that is responsible and sit with it until your breath again invites your attention back and the tension in that area of your body dissipates naturally. Realize you never stopped breathing during all this and that THIS breath is the only one that's real and that all is happening now. Enjoy the process of life unencumbered with smoking.
Get familiar with how your thoughts are tied with your physiological habits and how your emotions are tied with your thoughts, it is a river. You must sit by this river and find your true voice of reason and direct it, create new channels. All addictions are an attempt to stay away from this act of self enquiry and meditation.