Gray wrote more than 30 plays, including “Quartermaine’s Terms,” “Otherwise Engaged” and “The Old Masters,” as well as five novels and the screenplay for the 1987 film “A Month in the Country.” A rakish figure who claimed to have consumed three bottles of champagne a day for years, Gray also was steeped in the academic world.