I have handled many cases where a litigant will lose control right in the courtroom, in front of the Judge. Similarly, a parent who acts out in front of the child's attorney, social workers, teachers, neighbors, etc.
will find himself confronted with a lot of negative testimony and evidence at trial.
If you have an issue with substance abuse, then seek treatment for it immediately.
If you are the perpetrator of domestic violence or abuse (which often goes hand in hand with alcohol use), this also pretty much guarantees that you will lose custody. Leaving a paper trail that will hang you in court: Thanks to new technology, virtually every custody trial features the submission of evidence that can be used to portray the other parent in a very damaging light.
Now, here is a list of the seven most common pitfalls of parties going through custody actions.