#814
Mind flayers have to grapple your head before they can successfully suck your brain (like in D&D), forcing them to spend a turn doing this. If you have a greased helm, this gives you at least one extra turn to act since they will not be able to grapple your head until the grease dissolves.
This would probably best be implemented by giving them a sticky grab or bear hug attack and ignoring the existence of their tentacle attack if they aren’t already grappling you (or you are being held by another enemy and thus can’t avoid them). Either way, checking u.ustuck is the key.
Possibly, they need to spend another attack getting your helm off, which will unequip it, though this will get weird if your helm is cursed. A cursed helm shouldn’t offer total protection against them. Possibly, they should be able to remove a cursed helm (like nymphs and foocubi do) despite its curse; this could be handwaved as them using their psionic powers to do it.
In variants that implement zombies eating your brain, it should work on basically this same system, where the zombie needs to hold onto you before it can eat your brain (and which also works that way in D&D).