Allright, never mind. I solved it myself. Here's the winning code:
Code:
WeaponSet
Conditions = None
Weapon = PRIMARY OverlordTankGun
PreferredAgainst = PRIMARY VEHICLE
AutoChooseSources = PRIMARY FROM_PLAYER FROM_SCRIPT FROM_AI
Weapon = SECONDARY OverlordTankGun
PreferredAgainst = SECONDARY STRUCTURE
AutoChooseSources = SECONDARY FROM_PLAYER FROM_SCRIPT FROM_AI
Weapon = TERTIARY MammothTuskMissile
PreferredAgainst = TERTIARY INFANTRY
AutoChooseSources = TERTIARY FROM_PLAYER FROM_SCRIPT FROM_AI
ShareWeaponReloadTime = Yes
End
So, as you can see, I cheated a bit by giving it the gun twice. It uses the first gun against vehicles and the second against buildings, but because the two are identical you won't see any difference ingame.