I am creating a large mod that replaces the core 3 units with 4 custom (Soon to be 5) races. The mod is a blast, exept for the fact that AIs are as dumb as heck. They seem to be able to do upgrades, buildings and low tier infantry units, but I can't get them to train T2-T4 units. Could anyone show me a trigger that could work for this?
Look at how the melee AI is constructed. You basically need to make sure the build requirements flag is enabled and then order them to stock at least the desired number of that unit periodically. Unit stock orders have to be refreshed periodically (every 30-60 seconds) as well since the AI may forget them. If some units have particularly complex requirements it may not be possible for the AI to infer what must be done so one will either have to order they be stocked explicitly, or even design custom AI logic to help them meet the requirements.
For a simple AI a good idea is to design your stocking logic into different tiers. Tiers are advanced once certain requirements are met, such as building availability or game time. One can separate the base stocking and army stocking logic as usually a common base allows for many different army compositions that should be chosen dynamically based on the enemy composition, but this is a more advanced AI feature.