Grand Tactician: The Civil War (1861-1865)

Grand Tactician: The Civil War (1861-1865)

评价数不足
The Art of Save File Editing (WIP)
由 dad_father_of_all 制作
This guide will walk you through the basics of editing save files and initial campaign files. As there are a vast array of files/data stored in each save, I cannot hope to give a comprehensive description of each file. However, I will go over all of the most important parts of each file, and outline where you should go to perform common tasks (add new commanders, new groups etc).
   
奖励
收藏
已收藏
取消收藏
Preface
This guide will walk you through the structure of the save files, as well as how to edit them, and a few common modding ideas. It is important to BACK UP EVERYTHING you put your grubby hands on, and to understand that sometimes some things aren't configurable.

This guide is a Work In Progress, as there is A LOT of different files to be edited (and I'm quite lazy). On a practical note, this guide is very unlikely to leave WIP stage, as there are a truly disgusting number of things to decipher in each file (1 of these awful creations just has a list of 150 true falses. I thought once they were always false, until once I saw 1 true. I have absolutely no [REDACTED] idea what that could be, other than misery for me).

Regardless, any support, advice, or constructive criticism about this guide is welcomed.
Basic structure of the save files
This section will walk us through exactly how the save files are formatted, and broadly indicate the location of various important bits. An X marks that I've made the corresponding section, whilst an x means its a work in progress.

Save files are located with respect to their campaign file, which is indicated by a letter (A, B, etc), which is in turn under a campaign map number (001 for full USA, 002 for the Eastern Campaign). Unfortunately that's not super helpful for determining which file you're in.

Campaign Configuration
A better way to check is to look into each Campaign file and look at the campaign initialisation files, which are all the files not in a folder. Specifically, find the ScenarioDescr.txt file, and look at the first couple of lines, which should indicate what campaign they represent on the Main Menu. Alongside ScenarioDescr, you'll see the following files:
  • aipersonalities.dat - handles ai personalities, like what policies the ai should pick, how it should respond to a recruitment deficit etc.
  • armygroups.dat - handles where and what army groups exist
  • battledata.dat - handles initialising the positions and conditions of all campaign units
  • battleprefs.txt - a config file that handles how settings for use in battle should be used
  • Briefing0.txt - Briefing for the Union player
  • Briefing1.txt - Briefing for the Confederate player
  • campaignprefs.txt - config file for settings in the campaign map
  • cities.dat - not actually used for anything (as far as I can tell anyway)
  • dlcwl_config.dat - a config file for the W&L DLC
  • X groups.dat - handles what groups (armies, corps, divs etc) exist, who they belong to et
  • historicalevents.dat - handles what newspaper items occur during a normal game
  • nations.dat - initialises each nation for the campaign (whos at war, what territory they control etc)
  • X regiments.dat - handles what units (brigades/regiments) exist, which group they belong etc
  • ScenarioDescr.txt - sets up the description for the campaign on the main menu (ONLY CONTROLS DESCRIPTION, NO INFLUENCE ON ACTUAL GAME)
  • ships.dat - lists all ships at the campaign start
  • subsidies.dat - lists all subsidies at the campaign start
  • unitprefs.txt - a config file for unit behaviour, should be the first place to look for any mod!
  • weaponstock.dat - lists all weapon stocks at start of campaign
(NOTE: not all of these are guaranteed to be present, some instead take their defaults from the config files in the root/config directory, and yet others aren't relevant. Use some sense when working out how to edit things.)

Generally, these files are formed out of 2 types of data: A counter, and an entry. A counter describes how many of a set of entries (which can be 1-several hundred entries long) follow, and each entry gives a single data point (for example a commander name, or the number of men in a unit). Sometimes, there can be multiple counters per file, and even counters within a set of entries (and I've even found 3rd level counters - these make me sad). Generally speaking, you don't need to worry about the information contained in these 2nd and 3rd level counters, as they're immediately overwritten by the game as it runs. The important thing to know about them is that they will mess you up when you do deep dives on the save files, so be cautious. The top level counters are invariably very important though, and any edits must check that the number of items in a file remains the same as the counter responsible for it. The game does have error handling, but there is no guarantee your changes will make it into the save, and no guarantee you don't destroy the save file you intended to improve. BACK IT UP before any changes.


The above initalises the campaign. The below will help you tweak a live save. This can be a much harder task, as many more of these files are interlocking.

Save Files

Two types of Save file exist - one on the battle map, and one on the campaign map. Saves on the battle map will have 2 sets of files, one in a Battle directory, controlling the data inside of the Battle, and one in outside it controlling the data in the campaign as a whole.
These are the files you will find in the campaign save
  • addcommanders.dat
  • AICampaign.dat
  • AlarmInfos.dat
  • AllObjects.dat
  • armygrouprefs.dat
  • armygroups.dat
  • attributes.dat
  • battledata.dat
  • buildings.dat
  • CampaignObjectives.dat
  • ChartDatabase.dat
  • commanders.txt
  • garrisonrefs.dat
  • groups.dat
  • IIPsTowns.dat
  • nations.dat
  • paths.dat
  • Railroads.dat
  • regiments.dat
  • X scenario.dat
  • ships.dat
  • shiptype.dat
  • snow.dat
  • spottings.dat
  • version.dat
  • weapons.dat
  • weather.dat

These are the files you will find in the Battle directory of a save file (if and only if it has a battle ongoing)
  • armygrouprefs.dat - not sure
  • armygroups.dat - not sure
  • artillery.dat - controls where left guns are
  • attributes.dat - controls the attributes of commanders
  • battledata.dat - controls initialisation data for unit positions and similar
  • battleunits.dat - controls most of the data about unit positions etc (3rd level counters, beware)
  • buildings.dat - locations of buildings on the map
  • X commanders.txt - provides data on commanders during battle (believe its for battle init only)
  • entrypoints.dat - data on entry points
  • fallenlayers.dat - data on location of dead
  • frontlines.dat - describes sources of deployment area, empty if not deploy phase
  • X groups.dat - provides data on commanders during battle (believe its for battle init only)
  • objectives.dat - data about objectives and their condition
  • obstacles.dat - data on obstacles (unsure?)
  • paths.dat - pathing data
  • pontoons.dat - data on pontoon locations, conditions
  • X regiments.dat - provides data on regiments during battle (believe its for battle init only)
  • X scenario.dat - data about the scenario - times, date, weather etc
  • sideinfo.dat - data for each side controlling triggers and ai
  • version.dat - holds version data

How to edit a save file
It's all well and good knowing what can and can't be edited; but how do you edit a file, and how do you check on your edits?

In general (and there can be exceptions), it's fairly simple - simply make a save in whatever game you wish to edit, and then open up File Explorer (or your equivalent) and go to your GTCW folder, which is typically
C:\Program Files (x86)\Steam\steamapps\common\Grand Tactician The Civil War (1861-1865).

From here, you want to go into Campaigns, then either 001 for full USA map or 002 for Eastern campaign map, and then by the process outlined in {one with all the files} work out which letter folder your save is in. Finally, you want to go to your most recent save (or whichever one it is you want to work on). Saves are typically either "Save", which is your autosave folder, or "Save_DD_MM_YYYY_HH_MM_SS", which are your manual saves saved at that time.

Editing a file is as simple as opening up notepad or any similar plain text editor. I personally suggest notepad++ as it is very capable, complete with line numbers and mass find and replace, and a host of plugins. It is recommended you BACKUP THE FILE before making any changes, and it can be even better to simply copy the save directory beforehand. It is important to ensure the file structure remains as it was before you started editing - generally, best practice is to keep a note of the line count and make sure its the same before and after.

Once you've completed any edits you simply need to load the edited save, and you are likely (though not certain) to see the effects. It is now a good time to discuss the file hierarchy present in the game, or more specifically, who provides what data.

File Hierarchy - very WIP
What I mean by this is that some files store data about say, a unit's manpower, whilst other files read the data from this main file and use it. I'll be referring to this source file as the top of the hierarchy, and the 2nd one as below it. There also naturally exists a 0th file, which is the prebuilt code and script of the game, but that matters little for here. I will also be referring to files that initialise certain things (eg battledata.dat initialises battles) as source files.

This is what it looks like:
  • Top(either because no higher, or because no connections): commanders.txt, groups.dat, scenario.dat, regiments.dat
  • Layer 2(Depends on files in the top layer): battledata.dat, objectives.dat
  • Layer 3(Depends on files in any of the above layers): battleunits.dat, frontlines.dat
  • Layer 4(Highly dependent - don't bother editing as it is very prone to overwrites)

In general, you should edit the top most file -> it is the source from which all further information flows, and thus is the best chance of not getting data overwritten and actually making it into the game.

However, this rule is not true when trying to edit a game after initialisation - it is meaningless for example, to edit battledata.dat when the battle has already started, as there is no initialisation. You are best in this case to tweak battleunits.dat or similar.
Commanders.txt
This section will take you through editing commanders.txt.

First we will go through the file's structure, which is fairly straightforward. The first line is a counter that tells you how many commanders are described in this file. Then, for each commander in counter is a list of data structured as following
# For each member of commander count
["CommanderID (this should be a [b]unique id[/b], if it isn't weird things happen!)", "LastName (this is commonly the one used for defaults of the brigade under his control)", "FirstName", "CombinedName (Edit this if you'd like to give a commander a nickname)", "Nation (Where does his patriotism lie, see nations.dat)", "Experience", "Fame", "Leadership", "Initiative", "Administration", "Cunning", "isVeteran", "isWestPoint", "HistoricalBranch (-1 is none, 0 is inf, 1 is cav, 2 is arty, 3 is eng, 4 is navy)"]

These following repeat in threes like DD/MM/YYYY (so DoB_day, DoB_month, DoB_year, Lt_day ...)
["DateOfBirth", "Lt", "Cpt", "Maj", "Ltc", "Col", "BG", "MG", "LtG", "Gen", "Famous", "Defamed", "Unavailable"]

These go singly (as normal)
["DefaultPhoto", "StateID", "isPolitical", "ServiceHist", "BonusMalus", "Battle_Count", "Rank (see the ranks list)", "WIAorKIA (believe 0 is none, 1 is wia, 2 is kia)", "LatestRankToFit", "PortraitId", "PortraitFilename", "FrameID", "Active"]

So per commander there should be 66 lines

What to mod
Reviving Commanders: Active is I believe the one you want to change to revive commanders, but the game might check every day to see which commanders should be casulaties/unavailable. Changing all of them is a safe bet.
Rank: Dates of rank is date at which that rank is achieved. No idea if they strictly have to be higher after lower. Also naval commanders use the same rank dates, but Cpt thru General are replaced with the naval ranks (apparently no replacement for Lt rank)
Rank can also be overriden by assigning the commander to a unit that requires a higher/lower rank (will override to the minimum/maximum rank required)
Adding new Commanders: Simply copy and paste an existing commander, change the id and then edit his data. REMEMBER TO CHANGE THE TOP LINE

Note: if you want to change commanders in a SAVE file, you must do it in the save file. If you want to change them for a campaign's initialisation, change them in the campaign file.
Regiments.dat
Also simple, with just one counter - the number of regiments

For each member of regiments:
"Unit_ID", "Unit_Name", "Override_Name", "Parent_ID", "Unit_type", "Commander_ID", "Total_Men", "Wounded", "Captured", "SickRatio", "Experience", "Drill", "First_Battle", "Weapon_ID", "Chest_RGB", "Leg_RGB", "Colour_Variation", "Perk_ID", "Perk_Lvl", "Perk_Exp", "Battleflag_ID", "Unique_Icon_ID", "Unique_Music", "Horse_Art", "Unit_Tier", "Unit_Ranking", "Enlist_Date", "Contract", "Battle_Count", "State_ID", "Drafted", "Service_History", "Uniform", "Transfer_Time", "Transfer_target_x", "Transfer_target_y", "Transfer_target_z", "Last_Transfer_Update", "Morale"


Notable items to change:
Important: Unit_ID must be unique, else it will not display in the game. There may be more serious consequences, but I've yet to discover them.
Nicknames Simply change the Override Name to whatever your heart desires
Changing type Unit types are 0 - infantry, 1 - cavalry, 2 -artillery. If you want Horse artillery, change Horse_Art to 1 or True
Changing Unit Tier You can change a unit from eg a Brigade to a Battalion (with the accompanying rank requirements changed) by changing the Unit_Tier to your preference as found in the unitprefs. The game occasionally resets this under specific circumstances, but it's not too hard to revert. Be cautious not to put units at or above division level - the game freaks out and you will have to reload completely.

The result of changing unit tiers: 18 VA is now a battalion, 19 VA is a brigade and 28 VA is a "battery". These correspondingly change the ranks for commanders as well (potentially promoting or demoting commanders without you noticing).

Formation Tiers
The following are the numbers used for Unit_Tier both here and in groups.dat. This is correct for the brigade-level gameplay of the main game - for the regimental campaigns/battles, all unit tiers are shifted up by 1 (so regiment is tier 13), while fleet remains the same at 17. If in doubt, check the campaign's Unit Data section of the unitprefs.txt file.
  • 10 - Battery
  • 11 - Battalion
  • 12 - Regiment
  • 13 - Brigade
  • 14 - Division
  • 15 - Corps
  • 16 - Army
  • 17 - Fleet
  • 18 - Army Group


Unit Perks
These are the perk ids usable by units. In brackets are the unit type that the perk can be used for.
  • 0 None
  • 1 Engineering (INF)
  • 2 Sharpshooters (INF)
  • 3 Zouave (INF)
  • 4 Expert Skirmishers (INF)
  • 5 Spirited Charge (INF)
  • 6 Deadly Volley (INF)
  • 7 Ace of Spade (INF)
  • 8 Iron Discipline (INF)
  • 9 Expert Scouts (CAV)
  • 10 Cold Steel (CAV)
  • 11 Mounted Rifles (CAV)
  • 12 Stormers (CAV)
  • 13 Vanguard (CAV)
  • 14 Lightning Brigade (CAV)
  • 15 Close Support (ART)
  • 16 Skilled Laying (ART)
  • 17 Grand Battery (ART)
  • 18 Flying Battery (ART)
  • 19 Sapper Gunners (ART)
Groups.dat
Another simple one, with 1 counter at the start indicating the number of groups that exist. These are all of the formations that can have units under them (Typically your armies, corps and divisions), as well as fleets and garrisons.

"Group_ID", "Group_Name", "Parent_ID", "Nation", "Commander_ID", "Morale", "Rifle_Ammo", "Arty_Ammo", "Provisions", "ForageorCoal", "Inf_Condition", "Cav_Condition", "Gun_Condition", "Battleflag_ID", "Unique_Icon_ID", "Chest_RGB", "Leg_RGB", "Unit_Tier", "Intelligence", "Group_Ranking", "Perk1_ID", "Perk1_Lvl", "Perk1_Exp","Perk2_ID", "Perk2_Lvl", "Perk2_Exp","Perk3_ID", "Perk3_Lvl", "Perk3_Exp","Perk4_ID", "Perk4_Lvl", "Perk4_Exp"


Notes:
Perk4 is not in use, I don't know what happens if you try to change it.
ForageorCoal is dependent on if its Land or Water going

Notable Changes you can make:
  • Changing Unit Level: Simply change Unit_Tier as listed in regiments.dat, with same affects on ranks
  • Changing Perks: See the Perk ID list below, is -1 for no perk

Perks for Armies
  • 0: Siege Train
  • 1: Field Telegraph
  • 2: Balloon Corps
  • 3: Bureau of Military Information
  • 4: Skilled Cartographers
  • 5: Flying Column
  • 6: Foot Cavalry
  • 7: Engineers & Mechanics
  • 8: Ambulance Corps
  • 9: Pontoon Train
  • 10:Sappers and Miners
  • 11:Land Torpedoes
  • 12 :Partisan Brigades
  • 13 :Bushwhackers
  • 14:Embedded Reporters
  • 15:Limelights
  • 16 :Expert Scouts
  • 17:River Expedition

Perks for Fleets
  • 0: Torpedoes
  • 1: Mortar Boats
  • 2: Supply Colliers
  • 3: Balloon Barge
  • 4: Limelights
  • 5: Blockading Squadron
  • 6: Sea Raiders
  • 7: Amphibious Attack
  • 8: Blockade Busters
  • 9: Battery Runner
  • 10: Port Defender
scenario.dat
scenario.dat handles most of the basic metadata of the save, everything from the save name to the player's nation. Slight differences exist between the version found in the Campaign and the version found in the Battle files. In general though, these settings behave the same.

This too is a simple file, with no counters (Huzzah!). Several unknowns exist in this file - contribute to the war effort by finding out what they are!

  • Nation Id - use this to change which country you play as (0 = Union, 1= CSA)
  • Nation Name
  • In Game Date Day
  • In Game Date Month
  • In Game Date Year
  • In Game Hour
  • In Game Minute
  • Save Date Year
  • Save Date Hour
  • Save Date Minute
  • isDeploymentPhase
  • Unknown
  • Campaign Folder Path
  • Battlefield Folder Path - not present for Campaign
  • Continuous VPs - True is on, but you can configure this easily from the settings
  • Unknown
  • Tagline for Save
  • Unknown
  • Campaign Start Day
  • Campaign Start Month
  • Campaign Start Year
  • isTutorial
  • Unknown
  • Unknown
  • Save File Name
  • Battle Name
  • Fog of War - True = on
  • Readiness - False = on
  • Feuds - False = on
  • Order Delays - True = on
  • Unit Tier - for modifying a save between regimental, brigade levels.

Notable moddings:
Changing Nation: As is well known, by changing the Nation Id at the top of the file, you can swap which nation you load in as. Useful for reconfiguring OOBs and similar. However, the AI will remain on unless you tweak the debug setting, and can mess up your carefully arranged organisations.
Battle Name: Ever been annoyed at having a proper Shiloh called the "Battle of the Memphis-Jackson R.R" or some other horribly uninspired name. Simply changing the Battle Name should update the displayed name at the top of the battle and once it's over will be used for the Battle Monument
Tweaking Toggles: With this file, can toggle FoW, readiness, feuds, order delays and Continuous VPs mechanics