Oh. I think I know what this is. Demon Hunter has it to make sure you will not be able to summon another demon hunter after the one you are using turns into Demon Form.
I hope this works.
The only problem I can think of is that the techtree dependency will consider the other heroes as the same type.
This will affect the trigger that limits every type of hero to 1. Like if I put my Butcher hero with dependency of Elder Wolf. When I hire the Butcher from the tavern, wouldn't Elder wolf not be able to be hired because it is considered as Butcher and since you got Butcher, the game has already count it to the 1 limit?
Also, pleases pay no attention to whether this is old or not. Your answer is relevant to the question and the question had yet to be answered so it's a late answer and not necro (which is people pumping up an old thread with an irrelevant post to spam).
Yeah, I'm making a melee map just for fun with a bunch of custom races and 6 heros per race. It worked fine for a bit, but then I ran into the problem you described. (I trained 1 hero and the game counted it as 3 heros at once lol.)
The way I made it work, was to create 6 dummy heros and put only them on the hero list on the gameplay constants. Namely Hero 1 to 6.
Then on each of the dummies I added the dependency equivalents of 1 hero of each race.
Hero 1 = Paladin, Blademaster, Death Knight... Hero 2 = Archmage, Far Seer, Lich... and so on.
The only downside of this, is that if you charm a worker and build an altar of another race, you wouldn't be able to train a hero of that worker's race that is equivalent to one of the heros of your own race that you already trained.
To make things clearer, in my example form above, if you as Undead, posses a Peasant and make an Altar of Kings, you wouldn't be able to train a Paladin if you already have a Death Knight or an Archmage if you have a Lich.
However, it's very farfetched that player would do that normally since he'd need to either not build a hero of his own or also build a Keep or Castle that are the requirements of making a second or third Human hero. So it's not a concern I have.
For triggers, the Melee Game hero limit works for the melee Heros, but for custom Heros I needed to add Player - Limit training unit to 1 for each hero.
With those changes, it's working just as if all heros were on the gameplay constants hero list. The only problem would be tavern heros that I didn't get to make and test yet, but I can just add them to the hero list normally since I now only have 6 registers in there and I think the maximum is 54.