Doc Gooden -- It Was an Ambien High

Not the best defense for sure ... but former New York Mets great Dwight Gooden wants everyone to know ... when he got busted for DWI, he was not doing coke.

Doc's agent told the former player was apparently under the influence of Ambien when he was arrested Tuesday after striking a car -- allegedly.

The agent, Ronald Goldstein, says Doc got the script for Ambien recently, which he admitted "affected [Gooden's] ability to drive."

Ambien does pack a punch.