Inducible defence and the social evolution of herd immunity