Author Topic: Tarkalak's How to add the NEW countries to older saves.  (Read 2981 times)

Offline tarkalak

  • Commander
  • *****
  • Posts: 1460
    • View Profile
Tarkalak's How to add the NEW countries to older saves.
« on: May 26, 2019, 11:41:03 am »
Tarkalak's How to add the 0.9.9b countries to older saves.
EDIT: Same procedure works for 2.5 countries.


Note: I have not played till end of month so the below might break up something. Use at your own peril. It's fine.
Note2: There is ranomization in the initial funding that you get. You can use the coefficients that I have put below or If you want to be more precise you can recalculate the coefficients yourself. Thanks to karnaugh_map for finding that.

The saves can be found in %OpenXCOM_directory%/OpenXcom_XFiles/user/xcom1
In order to backup your save you need to copy paste it, then rename it, then open it with a text editor (Notepad, Notepad++, gedit, whatever you prefer) and change the name

name: %your_save's_name% <- change this or it will have the same name in game as the original file.

Step 1. Make a backup of your save. Actually make second one just to be sure.
Step 2. Start a new game, save it and exit.
Step 3. Open the new game save and your current game save. Copy paste the new countries' entries from the new game save into the old save.
Fortunatelly they are at the end of the list, except of Poland which is mixed with the old countries. I am sure that Solaris being Polish is a coincidence.  ;) Using a compare tool like Meld or WinMerge helps. The country entry looks like this:

NEW Game:
  - type: STR_USA
    funding:
      - 132000
    activityXcom:
      - 0
    activityAlien:
      - 0

The old game ones will likely have several lines in funding, activityXcom and activityAlien.

Result: Hurray!!! :)

Also note how many  rows there are in funding. Add " - 0" values above the last one to have them all to the same number.


Find the entry "graphCountryToggles:" and change it to:

graphCountryToggles: 0000000000000000000000000000000000

NOTE from 2022: Just copy the above line from your newly made save, since OpenXcom developers might have added more countries. The actual values 0s or 1s show which graph is shown and which isn't, it is only important to have enough digits for all countries.


Each 0 represents whether its corresponding country is displayed on the Graph or not.

You must do the stuff explained in the below spoiler or the Graphs will crash for countries.

Spoiler:
I have 11 values below funding, activityXcom and activityAlien that correspond to the 11 months of the game I played.
In order to fix the Graphs each new country should have the same number of entries below funding, activityXcom and activityAlien.

  - type: STR_CANADA
    funding:
      - 83000
      - 83000
      - 97000
      - 97000
      - 116000
      - 116000
      - 121000
      - 143000
      - 170000
      - 181000
      - 207000
    activityXcom:
      - 0
      - 55
      - 0
      - 40
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
    activityAlien:
      - 0
      - 1
      - 1
      - 2
      - 28
      - 0
      - 0
      - 0
      - 2
      - 0
      - 0

Now all new countries look like that:

  - type: STR_IRAN
    funding:
      - 51000
    activityXcom:
      - 0
    activityAlien:
      - 0

You must add " - 0" after funding:, activityXcom: and activityAlien: or the Graphs will crash. The new IRAN will look like:
  - type: STR_IRAN
    funding:
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 51000
    activityXcom:
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
    activityAlien:
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0
      - 0



New countries added. The only problem is that we have more $$$$ than we should do. Just check the funding of your backup and the modified save. Note the difference between them. I have $453000 more and I will use X for that value here.

We can get rid of the extra income in two ways:
Step 4a. Remove the same amount of money from the old countries. Decrease the spending until you *waste* the X amount of money.

Did any country refused to pay enough for protection during the game? I look at you USA.

In order to change the current funding go to the funding part of the country article and change the last value accordingly:

  - type: STR_USA
    funding:
      - 110000
      - 110000
      - 110000
      - 110000
      - 110000
      - 128000
      - 138000
      - 154000
      - 164000
      - 186000
      - 204000 <- Change this one to whatever your heart desires

NOTE from 2022: A few posts below there is an excel sheet that automates (and improves a little) all the following instructions. So use it instead, but then you are not allowed to do Step 5. Link:https://openxcom.org/forum/index.php/topic,7161.msg146109.html#msg146109


ATTENTION !!! ATTENTION !!! HIGH SCHOOL MATHEMATICS DETECTED !!! ALL AGENTS TO LEAVE THE FACILITY IMMEDIATELY !!! SCIENCE PERSONNEL TO DON LAB COATS AND PULL OUT THEIR PENS !!! ATTENTION !!!

If you do not want to make some (ok, a lot of) arithmetics with a calculator skip the rest of this post

Step 4b. Alternatively, and only for the brave, who fear no math (and calculators), we could change the money spending proportionally to how each country's spending was changed in 0.9.9b.

Step 4bI. For the Old countries.

We need to calculate a coefficient for each country and multiply their current funding with it.

How I calculate the coefficient:
Spoiler:
This is done by dividing the country's new starting funding with the country's old starting funding which gives us the coefficient of change. We then multiply this coefficient with the newest funding to obtain the new money.

Example: USA started with 110000 in the old game and with 132000 in the new one. her coefficient is 132000/110000 = 1,2. Then we multiply the current funding 204000 * 1,2 = 244800, but we remove the values below 1000 so it becomes &244000. I have put down all the coefficients below.

My coefficients of change are below:
Multiply each contry's current funding with the value below and change the last 3 digits of the result to 0.
STR_USA = 1,2
STR_RUSSIA = 1,1814
STR_UK = 0,3125
STR_FRANCE = 0,479
STR_GERMANY = 0,7065
STR_ITALY = 0,5932
STR_SPAIN = 0,1837
STR_CHINA = 0,9242
STR_JAPAN = 0,7875
STR_INDIA = 0,4318
STR_BRAZIL = 0,7273
STR_AUSTRALIA = 0,4128
STR_NIGERIA = 0,5357
STR_SOUTH_AFRICA = 0,372
STR_EGYPT = 0,2955
STR_CANADA = 0,9639

Example: In my game STR_UK is paying 177000 "protection" money. In order to adjust the value we do:
177000*0,3125 = 55312,5 ~= 55000
  - type: STR_UK
    funding:
      - 80000
      - 80000
      - 80000
      - 80000
      - 93000
      - 106000
      - 114000
      - 114000
      - 127000
      - 152000
      - 177000 <- change this to 55000

Do that for the rest of the countries

Step 4bII. New countries. We should calculate the money that new countries should give.

After doing the above changes open your modified game and note the total funding, then open the backup save. Calculate the difference and add X (X is the sum of money that the new countries give at startup):
original backup funding - modified funding + X = money that the new countries should give.

Each new country has a coefficient that should be multiplied with the total calculated above.

Spoiler:
The coeffiecient is calculated by deviding the starting money of that country by X. In my case X = 453000.
At start all new countries pay 453000 and Poland gives 32000. So Poland's coefficient is:
32000 / 453000 ~= 0,0706
I have put my coefficients below:
STR_POLAND = 0,0706
STR_CUBA = 0,0662
STR_MONGOLIA = 0,0287
STR_NEW_ZEALAND = 0,0132
STR_ICELAND = 0,0199
STR_PORTUGAL = 0 <- this is a special case because they start at 0
STR_MEXICO = 0,022
STR_INDONESIA = 0,0243
STR_IRELAND = 0,011
STR_UKRAINE = 0,1037
STR_TURKEY = 0,181
STR_ISRAEL = 0,0971
STR_ARGENTINA = 0,0751
STR_IRAN = 0,053
STR_FINLAND = 0,0684
STR_LIBIA = 0,0155
STR_SOUTH_KOREA = 0,106

Example:
I had originally $2 782 000 and after adjusting the Old countries I got $2 263 000. So:
2 782 000 - 2 263 000 + 453 000 = 972000
The new countries should in total give $972000 money.

Of these money Poland will get cough up 972000 * 0,706 = 68623,2 ~= 68000
In the STR_POLAND we change:
  - type: STR_POLAND
    funding:
      - 32000 <- this becomes 68000

Step 4bIII. Adjusting spare change.

Open your modified game and see the total funding and compare it with the backup funding. The difference is due to rounding errors because we round at 1000. Add the difference to some countries.

Example:
In the backup I have 2782000 and after all the changes I got 2750000.
I had Portugal with 0 at start so I gave them 32000

Step 5. Pat yourself on the back and reconsider becoming a Mathematics Major at the nearest (or elitest) University.
« Last Edit: May 15, 2022, 07:56:29 pm by tarkalak »

Offline karnaugh_map

  • Sergeant
  • **
  • Posts: 37
    • View Profile
Re: Tarkalak's How to add the 0.9.9b countries to older saves.
« Reply #1 on: May 26, 2019, 08:09:44 pm »
This is exactly the kind of thing I was wanting to do for my save.

Offline karnaugh_map

  • Sergeant
  • **
  • Posts: 37
    • View Profile
Re: Tarkalak's How to add the 0.9.9b countries to older saves.
« Reply #2 on: May 26, 2019, 08:40:10 pm »
Not that initial funding has a random element to it. In my new game Portugal starts with 15k funding.

Offline tarkalak

  • Commander
  • *****
  • Posts: 1460
    • View Profile
Re: Tarkalak's How to add the 0.9.9b countries to older saves.
« Reply #3 on: May 26, 2019, 09:20:07 pm »
In that case you need too look into how I calculated the coefficients and do it yourself. It is in the Spoiler parts.

Also replace the harcoded $453000 value with the sum of all new countries' incomes.

Then the spare change money in step 5 can be added to many countries.

But overall, if you end up with the same value as before tweaking the funding you should be fine.

EDIT: I changed the text a little to note that there is randomization. Honestly, an excel sheet would be great, but I don't feel like doing all the math again.
« Last Edit: May 26, 2019, 09:32:39 pm by tarkalak »

Offline karnaugh_map

  • Sergeant
  • **
  • Posts: 37
    • View Profile
Re: Tarkalak's How to add the 0.9.9b countries to older saves.
« Reply #4 on: May 26, 2019, 11:05:18 pm »
I did the modifications and started a new month without any issues.

Offline tarkalak

  • Commander
  • *****
  • Posts: 1460
    • View Profile
Re: Tarkalak's How to add the 0.9.9b countries to older saves.
« Reply #5 on: May 27, 2019, 04:10:18 pm »
I am glad that the above was useful. :)

Offline tarkalak

  • Commander
  • *****
  • Posts: 1460
    • View Profile
Shameless necromancy on this post. I noticed that the list of X-COM funding countries have been increased recently and this post was about how to add the new countries to an old file by doing ... ***ghasp*** Mathematics. *faints*

So I went down and wrote an excel sheet to calculate it for me.

It took only 2 hours. Yesterday I did it all with google calculator and a txt file for about 6 hours. Then found out I am an idiot and used a wrong sum at the beginning.
 ¯\_(ツ)_/¯

For your own use:
You still need to follow steps 1, 2 and 3 from above, but the excel sheet replaces the calculations in Step 4b. Usage instructions:

Step 4b.1. Delete numbers in green and red squares or use the blank .xls
Step 4b.2. Fill in Red square with data. Old countries data goes in first 3 cells, new in the 4th cell. Unused cells should be left blank.
Observe that sums are calculated in the upper left corner and for each country.

Step 4b.3. Look at what is the leftover value (upper left corner last value, this is the amount lost due to rounding down on 1000s) and add it to whatever country you think deserves it the most. I give it to the ones who rolled a 0 starting funding.
Note that the amount in step 3 isn't added to the calculations anywhere, so you need to add it by hand to whichever country may need it.

I wrote it in Libre Office Calc, which for some reason demands the use of ';' in formulas instead of ','. If Microsoft Excel struggles with the file for some bizaire reason, you may try installing Libre Office Calc (it is free) and running it with it. I do not have a windows machine handy to try.

If WHEN even more countries are added, I am afraid someone should extend the formulas down. It might even be me from the future.
« Last Edit: May 15, 2022, 07:58:51 pm by tarkalak »