So, I'm starting to struggle with my medicine degree in the final year, I've basically spent most of my time so far playing video games and masturbating. Is there a scientific method to combat this demon?
Just don't become a NEET. Some people phase out of this well, for lack of a better word phase. I've played video games my whole life and I wonder when I will quit. You can use other less time \-consuming sources of media or get a new hobby. As for the porn situation, just go outside man.
The problem is it has become an ingrained habit, I've been doing it habitually since my early teens. For instance, if I go onto the computer to do some research, write an essay or simply check social media, I end up debasing myself with some disgusting fetishism shit because I have to look for ever more extreme forms.
You study in the library or on campus somewhere where whipping your dick out isn't an option.
Ex. I'm a grad student and when I need to study and ensure that I don't have distractions, I go to my grad student office and study there with my laptop. Studying at home is too often interrupted by masturbation marathons so I basically don't even try it anymore.