Number of Players

kirkham7

Warlord
Joined
Dec 22, 2012
Messages
288
Location
Hayward, CA
I was wondering if it is possible to change the number of civilizations after you have started a game?
Just thinking that it would make an interesting game to bring in more civilizations at certain intervals, kind of like a battle royal..
 
I was wondering if it is possible to change the number of civilizations after you have started a game?
Just thinking that it would make an interesting game to bring in more civilizations at certain intervals, kind of like a battle royal..

By default no, if you are like Dark Panda a super hex modifier, it should be possible to trigger a settler of a new civilization.
Think about it when you play and you kill out for example France early in the game, then Germany (the other blue) will show up somewhere with a settler, if you can modify that to happen in a save game file it should be possible.

So no but yes :)
 
Well, if you think about it, when CIV loads a saved game, it cannot decide by itself whether to re-spawn a destroyed Civ: if you kill the Germans right after loading your save, should it re-spawn the French or not? In other words, were the French already destroyed in the past, before the saved game?

In order to know that, there has to be something in the SVE that helps CIV determines whether a certain Civ color was already destroyed once in the past.

Combining that with other data that control the active Civs and the number of opponents, I have a strong suspicion that what kirkham7 wants is achievable by SVE manipulation alone...

Now, let's dive in the EXE code to figure it out ;)
 
That would be awesome.
Thinking about it more, it would make for an interesting game if civs keep respawning even after you defeat both of that color group.. Something to think about later after my first question has been answered.
Darkpanda, you are amazing, keep up the great work! :)
 
So here is the thing: CIV.EXE contains a routine dedicated to spawning a Civ, whose main task of this routine is setting up a Civ's various initial data (tax/science rates, diplomatic status, unit counts, city counts, map visibility, etc.)

In particular, this routine also determines the Civ's starting position and, more importantly, whether a Civ should be re-spawned at all.

The algorithm to determine the starting position is as follows, incrementing a loop counter while trying to find the position (initially 0):
  1. Choose a map square (X,Y) randomly
  2. If loopCounter = 2000, terminate loop in failure: no suitable starting position found...
  3. Else if it's an ocean square, loop back to 1.
  4. Else if the selected square's current land value is smaller than (12 - loopCounter/32), loop back to 1.; current land value includes the 'city shrouds' that cancels land values around existing cities
  5. Else if the distance to the closest enemy city (or settler for turn 0) is smaller than (10 - loopCounter/64), loop back to 1.
  6. Else if the square's continent's buildable squares are fewer than (32 - gameTurn/16), loop back to 1.
  7. Else if the square's continent already contains cities, and current year is after 0, loop back to 1.
  8. Else if the square contains a tribal hut, loop back to 1.
  9. Else: yay a suitable starting position was found!

There is plenty to say about the algorithm above, but for our current concern the most important fact is that if no starting position was found after 2000 attempts, then the Civ will simply not be spawned at all.

Why is this important? Because in the code after this loop, there is more code that will arbitrarily set the loop counter to 2000, even if a suitable starting position was found: if the value of Civ Identity / Leader Graphics matches the Civs identify flag then set loopCounter to 2000; here, "match" means that the Civ ID value is below 8 and the Civ ID flag is 0, or the Civ ID value is above 8 and the flag is 1
[/list]

Finally, the routine ends up checking whether the current game turn is greater than 350-(50*difficulty) or loopCounter = 2000, in which case it does NOT re-spawn the Civ and sets its Active Flag to 0.

Conclusion: while it is possible to enable Civ re-spawn more than 1 time by just playing with the SVE data elements Civ Identity / Leader Graphics, Civs identify flag and Active Flag, the above conditions show that it does not guarantee that a Civ will be able to re-spawn.

Also, it must be noted that this routine is called only from a limited number of places, most notably whenever a City is destroyed (famine, capture, attack, etc.). In other words, this trick cannot re-spawn Civs from the dead, it must edited into the SVE before a Civ is actually destroyed, so that CIV will go through the re-spawn check immediately.

Here is the procedure: after a Civ is destroyed and respawned once, toggle its identity flag, which conveniently enough, happens to be stored in the last short of the SVE data (first byte only):
  • White Civs:
    • If Romans were destroyed and Russians were respawned: flag = flag + 2 (0x2) to have Romans respawn again
    • If Russians were destroyed and Romans were respawned: flag = flag - 2 (0x2) to have Russians respawn again
  • Green Civs:
    • If Babylonians were destroyed and Zulus were respawned: flag = flag + 4 (0x4) to have Babylonians respawn again
    • If Zulus were destroyed and Babylonians were respawned: flag = flag - 4 (0x4) to have Zulus respawn again
  • Blue Civs:
    • If German were destroyed and French were respawned: flag = flag + 8 (0x8) to have German respawn again
    • If French were destroyed and German were respawned: flag = flag - 8 (0x8) to have French respawn again
  • Yellow Civs:
    • If Egyptians were destroyed and Aztecs were respawned: flag = flag + 16 (0x10) to have Egyptians respawn again
    • If Aztecs were destroyed and Egyptians were respawned: flag = flag - 16 (0x10) to have Aztecs respawn again
  • Cyan Civs:
    • If Americans were destroyed and Chinese were respawned: flag = flag + 32 (0x20) to have Americans respawn again
    • If Chinese were destroyed and Americans were respawned: flag = flag - 32 (0x20) to have Chinese respawn again
  • Pink Civs:
    • If Greek were destroyed and English were respawned: flag = flag + 64 (0x40) to have Greek respawn again
    • If English were destroyed and Greek were respawned: flag = flag - 64 (0x40) to have English respawn again
  • Gray Civs:
    • If Indians were destroyed and Mongols were respawned: flag = flag + 128 (0x80) to have Indians respawn again
    • If Mongols were destroyed and Indians were respawned: flag = flag - 128 (0x80) to have Mongols respawn again

Now, all the above is just theory, and needs to be tested. Also, as everyone can see, there is plenty of room for patching the CIV.EXE code above to make re-spawns more frequent... This is really distracting me from what I should be doing in JCivED right now :)
 
That would be awesome.
Thinking about it more, it would make for an interesting game if civs keep respawning even after you defeat both of that color group.. Something to think about later after my first question has been answered.
Darkpanda, you are amazing, keep up the great work! :)

I couldn't help release a patch to do just that: Modding Civ I - Unlimited Civ re-spawn

It also makes it much easier than the SVE patching from the previous thread, which requires you to hack the SVE after every Civ destruction...
 
I always wondered why respawning wasn't 100% early game. I also wondered why it was only sometimes civs spawned after year 0. Good info.
 
I know it's been almost 3 years, so forgive me for necromancing.
I'm implementing this into CivOne and it's not entirely clear to me: Is the loop counter global, or does it reset per player?

Another question: What makes a tile (square) buildable?
 
Top Bottom