I am trying to do what Kalin gave code for. I want 2 separate trees for learning magic, 1 is for path of the mage and the other for all other classes. By all rights the code above should work, but the unlockunitability does not work. All the rest works fine, we get the icons for Air1-5 but can not cast even one spell from that tree.
I wonder if something is wrong with something I've modded in (as I've done quite a bit in other areas etc) and is why the unlockunitability does not work? Can you verify that it does or does not?
Even if it does not work, perhaps someone knows of a way to auto-cast a spell that gives the Air1 immediately as that does work. Or a way to give an item to the player? If that is possible, could it also be an auto-use item?
Short of any thing else, I could duplicate all spells and set the prereq's from Air1, Air2, etc to Air1PotM, Air2PotM, etc.
Appreciate all the help here, trying to learn the intricacies of how you do this or that, and what is not possible is aggravating.
Strange, I guess you can't unlock abilities inside another ability... which is a bit odd, because you can unlock spells inside spells. I'm not sure if I messed up somewhere, but anyway, to address your current problem...
You can also unlock spells like you do abilities with UnlockSpell (and this definitely works inside a trait). Basically you'd add the following:
<Provides>Unlocks Haste: Target unit is +3 to Initiative (+1 per air shard)</Provides>
... to Air1POTM, and the same for all other spells in their appropriate location. This will allow you to unlock the spells without duplicating everything. The problem with this approach would be the multi-path spells. Which you could either ignore, put into one of the other paths, or you can duplicate just those multi-path spells (much less than everything).
As to your question, you can try to create an item to give you the path... using GiveItem (quest reward style). Although I haven't tested to see if this works with unit level up traits (or how it would handled if you're in an army with other heroes). I don't think you can make it auto use though.
Basically, something like this:
Regarding autocast spells, you can only do that at the beginning of a battle... via BattleAutoCastSpell, so you might be able to do it that way, but you'd need to enter another tactical battle before you gain that path. So you'd have to have something along the lines of "training Air1" trait in PoTM (with high likelihood) that would then autocast a spell that give you that Air1 path when you enter a battle. That SHOULD give you the appropriate trait and the spells that goes with it.
<DisplayName>Training Air Apprentice</DisplayName>
<Description>This mage is currently practicing Air magic, and will become an Air Apprentice by the next battle.</Description>
<Provides>This mage has become an Air Apprentice.</Provides>
You'd need the auto cast spell (Air1POTMUnlockSpell) that unlocks Air1 as well, of course...