The best answer is maybe.  Most criminal offenses require some type of mental state:  like intentional conduct or negligent conduct.  There are a couple of offenses, like DUI, which tend to be what is called a "strict liability offense."  Basically, a few years ago DUI defendants tried to argue that they couldn't be convicted of driving on purpose, because they were too intoxicated to know better.  This argument has been consistently struck down-- noting that the DUI really was a strict liability offense that didn't require a mental state.So....if you are charged with an offense that is an intent offense, then you can use the ammonia poisoning as a defense.  If you are charged with a strict liaiblity offense, you may or may not be able to use it as a defense.   Even if you have the defense, the defense may be defeated if the prosecutor can show that you intentionally engaged in the conduct which resulted in your poisoning-- and you should have reasonably known that your mental state would be altered, thereby resulting in a criminal act.