Quick notes: Accidentally adding new nations to the game

A few days ago I had half an hour free while burger was messaging me about adding new nations to the game, so I decided to see what error message I would get if I tried to add new nations to the game.

It appears I have failed the task successfully.

As it turns out, although the game keeps most types of things (including units, buildings, rares, techs) in one enormous sequential enum array thing, it seems to keep nations in their own separate array thing. This means that adding new nations does not seem to run into the same problem of needing to realign everything in the enum-array-thing if you want to add, say, one new unit, and you can instead just allocate some extra memory to the array and tell the game to read in one more nation into it than before.

I don’t have the time or mental bandwidth to fully get into exploring or explaining how adding new nations works or fixing up the UI code right now, so this is just a quick and dirty infodump so that if I get run over by a bus before I’m able to do that, the next time somebody tells you adding new nations is impossible you can tell them to shut the fuck up and stop being a lazy closed-minded dipshit. (but probably phrase it more nicely than that)

  • Adding new nations like this does not replace any of the existing 24 nations.
  • New nations will have no nation powers unless you give them some.
    • I see you there in the back, describing changing XML values as “programming”. No, you can’t simply add e.g., AUSTRALIANS_FREE_HORSE into rules.xml and expect it to work. Both the XML strings and the logic powering their effects are hardcoded (so they can be changed, it’s just not as easy).
  • Adding new nations like this does interfere / interact with the random nation choices (including random, offensive, x-pack, etc) because these — by default — use enum values starting after the last nation in the enum (Persians). I.e., Persians are at 0-indexed 23 (0x17) and the random stuff starts at 24 (0x18).
    • Based on quick and dirty testing, this can probably be either resolved or worked around without too much difficulty.
  • This approach is very scuffed.
    • I haven’t extensively tested it.
    • In 6 of the places where I allocate more memory, I don’t even know what the function does because it was just a quick yolo hail mary.
    • In some of the places where I change jump condition values, I don’t even remember what the function is (since I was in a rush, the notes I took were not comprehensive).

Here’s the binary diff (for EE v1.20 with the stupidly-same-versioned June 2024 patch) of adding one new nation in this way:

For simplicity (too long to explain right now), avoid changing the second listed value at 0x001BEEE3 (18 -> 1D), but change the rest as needed.

There are basically two types of values you’re changing:

  • Large, 2-byte values (same values each time) are telling the game to allocate more memory (and stuff related to this). Each new nation appears to need a fixed amount of new memory allocated to it in some kind of array of all nations. Flip the order when inputting updated byte values here because of endianness.
  • Small, 1-byte values (originally 18/19) are related to jump conditions, such as the game cycling through a loop X number of times when populating the probably-nation-array, or when checking if you have the expected number of nations.

In addition to this binary changes, you’ll need to add nations to rules.xml like this where I’ve added ten new nations (I don’t know what the naming restrictions are):

Create / populate the appropriate tribe files with at least some minimal values:

And then you’ll probably want to include text in help.xml for each nation:

The amount of nations that can be added in this way appears to more or less arbitrary, as I seem to be able to add ten new nations without issue (other than the aforementioned UI stuff that I didn’t spend the time figuring out).

Note: doing this stuff will modify the nation prefills saved in your player .dat file to possibly-invalid values if you were to do this and then go back to “normal RoN” afterwards. I doubt it has a notable negative downside (out-of-range values seem to just make the dropbox string go blank and default to being functionally the same as selecting random), but I felt it worth mentioning.

And for the love of god please stop confusing things that are impossible to mod in RoN with things that are impossible for you to mod in RoN because you haven’t bothered learning how to do it. It continues to baffle me how people couldn’t be fucked trying things like this earlier than me.

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept the Privacy Policy

This site uses Akismet to reduce spam. Learn how your comment data is processed.