
Okay. I've finished all the changes I wanted to make to the ship part of the loadout code and I'm about to start on the weapon code (after that I'll go to FRED and make it possible to add all this stuff without having to use notepad). I figured I'd post now and get people's opinions while it's still fresh in my mind and I'm inclined to make changes

I'm not posting a build at the moment cause the code is no fit state at the moment (FRED chokes completely on any mission using this stuff and it's non trivial to fix that). Anyway here's how the new code works.
Loadout changes- You can specify a string variable for the class of any ship in the loadout
- You can specify a number variable for the amount of any ship in the loadout
That means that code like this is now perfectly valid.
$Ship Choices: (
"Ulysses" @NumberOfUlysses
"GTF Hercules" @NumberOfHercs
@ShipClass1 @NumberOfRandom
@ShipClass2 5
)
If that's all you do then the team loadout code will simply work out the number of extra ships available based on the value of the variables you gave it. It won't however do anything about the ships in Alpha wing or any other wing specified in the mission file. That is controlled by changes to the ship object.
Ship Object stuff$Name: Alpha 1 ;! Object #0
$Class: GTF Ulysses
+Suggested_loadout_ship: @ShipClass1
+Suggested_loadout_ship: GTF Ulysses
+Optional_default_ship: @ShipClass1
$Team: Friendly
$Location: 0.000000, 0.000000, 0.000000
[ SNIP ]
$Departure Cue: ( false )
$Determination: 10
+Flags: ( "cargo-known" "ignore-count" "player-start" )
+Flags2: ( "class-set-by-loadout" )
New stuff is in red.
The class-set-by-loadout can be set on any fighter you wish (not just one in Alpha to Gamma wing and even hostiles if the mission requires it). Any ship with this flag will not automatically be set to the class the mission file specified. Instead the code will now check if there are any ships off that class left in the loadout pool. If there are then fine. If not it will then check to see if the +Suggested_loadout_ship: exists. If it does it will then parse in the name (or variable holding a name) and see if that is available. You are allowed to suggest the name of three different ship classes to the code (I've shown two. One static (the Ulysses) and one held in the ShipClass1 string variable.).
If none of the suggestions work (or if none were given) the game will then look to see if an Optional_default_ship was given. If this exists the ship will be set to this class regardless of whether or not there are any ships left (If there are ships left of this class they will be assigned to this ship).
If after going through the missions designers suggestions no match was found and no Optional_default_ship was given the game will then loop through the team loadout and assign the ship to the first class for which it can find any ships left.
Finally if this still fails to find a match the ship is assigned to whatever the mission file originally said it should be.
I know that sounds hideously complicated but it's actually quite simple once you get the hang of it and it gives the FREDder an enormous amount of choice in what will happen.
BHX Stuff@IP Andrews : I kept BHX in mind when I was writing the code cause even if you don't want to use it I'll probably want to do this with multiplayer at some point and it's easier to keep in mind an actual existing campaign than a hypothetical one
That said it can do what you've suggested in your first post quite easily.
First thing you do is edit the team loadout. I already know that you must have a pair of variables defining what class of fighters are available for each race so that bit is easy. You simply assign those variables as the ship class in the loadout.
$Ship Choices: (
@FighterClass1 @NumberOfFC1
@FighterClass2 @NumberOfFC2
)
Then you'd simply assign some suggestions and defaults for each ship. Assuming that FighterClass1 = basic fighter and FighterClass2 = advanced fighter. Then and assignment like this would give you what you want.
$Name: Alpha 1 ;! Object #0
$Class: EA Thunderbolt
+Suggested_loadout_ship: @ShipClass2
+Optional_default_ship: @ShipClass1
When playing the EA the player will be in a Thunderbolt if he has any left. If not he'll be in a starfury. If you wanted him to definitely fly a Thunderbolt you could simply set the Optional Default to ShipClass2 and still gain all the benifits of the team loadout code for any other wing.
If playing the League on the other hand the code above would automatically put the player in a Sky Serpent if he had one left and a Falkosi if he didn't.
Comments?I'm happy to take comments and suggestions. Doesn't mean I'll add them but I'll listen at least