Alright, I'm assuming you know how to set up debugging, if not, tell me and I'll go into that.
So, first, add a level of your modern hero but nothing else. Now go to "Show Selection Fields" and choose the Modern Hero Class Helper. There should be field called "cCst2Expr". This stores the Candidate Expression which determines what secondary abilities are displayed for you to pick from.
For just the class, I am showing it as "(SpecSource.cHelpMdH) & Helper.Secondary". This means "Display any Secondary Ability with the SpecSource.cHelpMdH tag". And since all your secondary class abilities have the SpecSource.cHelpMdH tag, all are displayed.
Archetypes have their own, automated method of changing the candidate expression. Once you add an archetype (for example the Medical Examiner archetype) it changes to "(SpecSource.arMHInvest | SpecSource.arMPSGGMdE | SpecSource.cHelpMdH) & Helper.Secondary". This means "Display any Secondary Ability with the SpecSource.cHelpMdH tag, or the SpecSource.arMPSGGMdE tag, or the SpecSource.arMHInvest tag"
So looking at the secondary custom abilities in these files, it looks like many of them are marked with the SpecSource.cHelpMdH tag (this is marked in the "Available to Class(es)" button, which is the second thing in the editor for Custom Abilities). The first thing I'd do is replace that tag with the one specific to their particular archetype. For example, the Defensive Position custom ability needs to be switched.
Sidenote, is the Medical Examiner archetype supposed to have 2 SpecSource tags, or is that a bug?
Now half the work is done, Yay!
So how do we get talents to do the same thing as archetypes? Well, that does take scripting. At the same phase and priority you're currently setting the tertiary candidate expression, you can set the secondary like this:
Code:
~ we'll overwrite the secondary abilities' expression, since we need
~ to allow it to choose the abilities of our associated archetype
~ First set up a variable to hold and modify the expression
var newexpr as string
~ It starts the same as the original
newexpr = linkage[table].field[cCstS2Expr].text
~ Then we replace the end with our own, which appends an additional SpecSource tag as an option
newexpr = replace(newexpr,") & Helper.Secondary"," | SpecSource.arBLARG) & Helper.Secondary",0)
~ Now replace the old expresson with our modified one
linkage[table].field[cCstS2Expr].text = newexpr
"arBlarg" should be replaced with the unique ID of the archetype this cross training talent mimics.
Once that's done, make sure you test it, and verify everything works, including the interaction between archetypes and cross training Talents.