You are not always given the choice to change capital?

Joined
Dec 29, 2017
Messages
932
1743989511353.png
 
The requirements seem to be related to size and location - when on island maps if my capital was the only settlement on its island than I got no choices, when I had 2 other settlements on my island they were both options.
 
The requirements seem to be related to size and location - when on island maps if my capital was the only settlement on its island than I got no choices, when I had 2 other settlements on my island they were both options.
I didn't play on an island map, I have lots of huge cities right next to my capital.
 
I believe if your capital loses land connection (in favour of sea/river connection) to other cities, this happens. And it only seems to happen during the transition to Modern.
 
Thank you for all your inputs, I just realize maybe the city connection theory is correct. Although I do have 2 major cities right underneath this city, they are separated by a nav river. In the ancient era, I can change my capital because I build an ancient bridge, but I think I didn't build a med bridge here.
 
I don't know if bridges help. During the times I've seen this happen, the roads between those cities disappeared entirely in the Modern Age. I suspect they are generated at the start of each age and, for some reason, the game can decide that they're not needed because the cities are connected by water.
 
If you play as the Normans, say, and settle cities in the Distant Lands during the Exploration era, then change to America for the Modern era, you're not allowed to move your Capital to one of those new cities, if they're on a different land mass? Am I understanding that correctly?

Is there any other mechanic, other than on era transition, to allow you to move your capital anywhere you want, later?
 
Spoiler Code :


function changeCapitalCards(iPlayer) {
const capitalOptions = 2;
const player = Players.get(iPlayer);
let playerSettlements = player?.Cities?.getCityIds();
let currentPlayerCapitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const currentPlayerCapital = player?.Cities?.getCapital();
if (currentPlayerCapital != null) {
currentPlayerCapitalName = currentPlayerCapital.name;
}
if (player != null && playerSettlements != null) {
playerSettlements = playerSettlements.sort((a, b) => {
const popA = Cities.get(a)?.population;
const popB = Cities.get(b)?.population;
if (popA == null)
return 1;
if (popB == null)
return -1;
return popB - popA;
});
let capitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const civ = GameInfo.Civilizations.lookup(player.civilizationType);
if (civ != null) {
capitalName = civ.CapitalName;
}
let cardsGenerated = 0;
for (let i = 0; i < playerSettlements.length && cardsGenerated < capitalOptions; i++) {
const settlement = Cities.get(playerSettlements[i]);
if (settlement != null) {
if (!settlement.isCapital && settlement.Trade != null && settlement.Trade.isConnectedToOwnersCapitalByLand()) {
let card = {
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
name: "LOC_CARD_AT_CHANGE_CAPITAL",
description: "LOC_CARD_AT_CHANGE_CAPITAL_DESCRIPTION\\" + settlement.name + "\\" + capitalName + "\\" + currentPlayerCapitalName,
tooltip: "",
iconOverride: "",
limitID: "CARD_AT_CHANGE_CAPITAL_0",
individualLimit: 1,
groupLimit: 1,
categorySortOrder: 100,
cost: [
{ category: CardCategories.CARD_CATEGORY_WILDCARD, value: 0 }
],
effects: [{
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
type: "CARD_AT_CHANGE_CAPITAL",
name: "",
description: "",
amount: 1,
special: 0,
metadata: {
Type: DynamicCardTypes.Capital,
SettlementId: settlement.id.id
}
}],
aiModifierLists: []
};
Players.AdvancedStart.get(iPlayer)?.addDynamicAvailableCard(card);
cardsGenerated += 1;
}
}
}
}
}



This is the code for determining what gets chosen as the options for capital.
 
Spoiler Code :


function changeCapitalCards(iPlayer) {
const capitalOptions = 2;
const player = Players.get(iPlayer);
let playerSettlements = player?.Cities?.getCityIds();
let currentPlayerCapitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const currentPlayerCapital = player?.Cities?.getCapital();
if (currentPlayerCapital != null) {
currentPlayerCapitalName = currentPlayerCapital.name;
}
if (player != null && playerSettlements != null) {
playerSettlements = playerSettlements.sort((a, b) => {
const popA = Cities.get(a)?.population;
const popB = Cities.get(b)?.population;
if (popA == null)
return 1;
if (popB == null)
return -1;
return popB - popA;
});
let capitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const civ = GameInfo.Civilizations.lookup(player.civilizationType);
if (civ != null) {
capitalName = civ.CapitalName;
}
let cardsGenerated = 0;
for (let i = 0; i < playerSettlements.length && cardsGenerated < capitalOptions; i++) {
const settlement = Cities.get(playerSettlements[i]);
if (settlement != null) {
if (!settlement.isCapital && settlement.Trade != null && settlement.Trade.isConnectedToOwnersCapitalByLand()) {
let card = {
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
name: "LOC_CARD_AT_CHANGE_CAPITAL",
description: "LOC_CARD_AT_CHANGE_CAPITAL_DESCRIPTION\\" + settlement.name + "\\" + capitalName + "\\" + currentPlayerCapitalName,
tooltip: "",
iconOverride: "",
limitID: "CARD_AT_CHANGE_CAPITAL_0",
individualLimit: 1,
groupLimit: 1,
categorySortOrder: 100,
cost: [
{ category: CardCategories.CARD_CATEGORY_WILDCARD, value: 0 }
],
effects: [{
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
type: "CARD_AT_CHANGE_CAPITAL",
name: "",
description: "",
amount: 1,
special: 0,
metadata: {
Type: DynamicCardTypes.Capital,
SettlementId: settlement.id.id
}
}],
aiModifierLists: []
};
Players.AdvancedStart.get(iPlayer)?.addDynamicAvailableCard(card);
cardsGenerated += 1;
}
}
}
}
}



This is the code for determining what gets chosen as the options for capital.
And the logic of that is not made apparent to the Player anywhere, instead as far as they can tell randomly get some number (including 0) of capital switching options... basically its a bug.
(and the fact that it is partially based on connections makes it even worse since connections are bugged even worse)
 
Spoiler Code :


function changeCapitalCards(iPlayer) {
const capitalOptions = 2;
const player = Players.get(iPlayer);
let playerSettlements = player?.Cities?.getCityIds();
let currentPlayerCapitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const currentPlayerCapital = player?.Cities?.getCapital();
if (currentPlayerCapital != null) {
currentPlayerCapitalName = currentPlayerCapital.name;
}
if (player != null && playerSettlements != null) {
playerSettlements = playerSettlements.sort((a, b) => {
const popA = Cities.get(a)?.population;
const popB = Cities.get(b)?.population;
if (popA == null)
return 1;
if (popB == null)
return -1;
return popB - popA;
});
let capitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const civ = GameInfo.Civilizations.lookup(player.civilizationType);
if (civ != null) {
capitalName = civ.CapitalName;
}
let cardsGenerated = 0;
for (let i = 0; i < playerSettlements.length && cardsGenerated < capitalOptions; i++) {
const settlement = Cities.get(playerSettlements[i]);
if (settlement != null) {
if (!settlement.isCapital && settlement.Trade != null && settlement.Trade.isConnectedToOwnersCapitalByLand()) {
let card = {
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
name: "LOC_CARD_AT_CHANGE_CAPITAL",
description: "LOC_CARD_AT_CHANGE_CAPITAL_DESCRIPTION\\" + settlement.name + "\\" + capitalName + "\\" + currentPlayerCapitalName,
tooltip: "",
iconOverride: "",
limitID: "CARD_AT_CHANGE_CAPITAL_0",
individualLimit: 1,
groupLimit: 1,
categorySortOrder: 100,
cost: [
{ category: CardCategories.CARD_CATEGORY_WILDCARD, value: 0 }
],
effects: [{
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
type: "CARD_AT_CHANGE_CAPITAL",
name: "",
description: "",
amount: 1,
special: 0,
metadata: {
Type: DynamicCardTypes.Capital,
SettlementId: settlement.id.id
}
}],
aiModifierLists: []
};
Players.AdvancedStart.get(iPlayer)?.addDynamicAvailableCard(card);
cardsGenerated += 1;
}
}
}
}
}



This is the code for determining what gets chosen as the options for capital.
Cool. In short it cycles through all settlements ordered by population and picks first 2 which are connected by land with the current capital. Pretty simple.

Also it's good to see those things fully exposed for modding.
 
And the logic of that is not made apparent to the Player anywhere, instead as far as they can tell randomly get some number (including 0) of capital switching options... basically its a bug.
(and the fact that it is partially based on connections makes it even worse since connections are bugged even worse)
Connections are probably bugged, but the rest is not a bug, its incomplete documentation. Other than potential connection issue the code clearly should work as intended.
 
Spoiler Code :


function changeCapitalCards(iPlayer) {
const capitalOptions = 2;
const player = Players.get(iPlayer);
let playerSettlements = player?.Cities?.getCityIds();
let currentPlayerCapitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const currentPlayerCapital = player?.Cities?.getCapital();
if (currentPlayerCapital != null) {
currentPlayerCapitalName = currentPlayerCapital.name;
}
if (player != null && playerSettlements != null) {
playerSettlements = playerSettlements.sort((a, b) => {
const popA = Cities.get(a)?.population;
const popB = Cities.get(b)?.population;
if (popA == null)
return 1;
if (popB == null)
return -1;
return popB - popA;
});
let capitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const civ = GameInfo.Civilizations.lookup(player.civilizationType);
if (civ != null) {
capitalName = civ.CapitalName;
}
let cardsGenerated = 0;
for (let i = 0; i < playerSettlements.length && cardsGenerated < capitalOptions; i++) {
const settlement = Cities.get(playerSettlements[i]);
if (settlement != null) {
if (!settlement.isCapital && settlement.Trade != null && settlement.Trade.isConnectedToOwnersCapitalByLand()) {
let card = {
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
name: "LOC_CARD_AT_CHANGE_CAPITAL",
description: "LOC_CARD_AT_CHANGE_CAPITAL_DESCRIPTION\\" + settlement.name + "\\" + capitalName + "\\" + currentPlayerCapitalName,
tooltip: "",
iconOverride: "",
limitID: "CARD_AT_CHANGE_CAPITAL_0",
individualLimit: 1,
groupLimit: 1,
categorySortOrder: 100,
cost: [
{ category: CardCategories.CARD_CATEGORY_WILDCARD, value: 0 }
],
effects: [{
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
type: "CARD_AT_CHANGE_CAPITAL",
name: "",
description: "",
amount: 1,
special: 0,
metadata: {
Type: DynamicCardTypes.Capital,
SettlementId: settlement.id.id
}
}],
aiModifierLists: []
};
Players.AdvancedStart.get(iPlayer)?.addDynamicAvailableCard(card);
cardsGenerated += 1;
}
}
}
}
}



This is the code for determining what gets chosen as the options for capital.
What language is that?
 
Connections are probably bugged, but the rest is not a bug, its incomplete documentation. Other than potential connection issue the code clearly should work as intended.
I'm also unsure if the Trade pointer is a generic manager (like GetPlayerTechs() ) or if it's a city connection pointer, haven't verified.

Cool. In short it cycles through all settlements ordered by population and picks first 2 which are connected by land with the current capital. Pretty simple.

Also it's good to see those things fully exposed for modding.
Yes, I'm surprised you can change this if you want, it's nice.

What language is that?
I believe it's JavaScript? All UIs and scripts use this, the entire logic for the age transition is now located in a file you can modify.
 
I believe it's JavaScript? All UIs and scripts use this, the entire logic for the age transition is now located in a file you can modify.
Interesting. I thought it was JavaScript myself checked by the AI and it told me the same thing. I myself without the AI couldn't believe it but I guess it is.
 
Interesting. I thought it was JavaScript myself checked by the AI and it told me the same thing. I myself without the AI couldn't believe it but I guess it is.
They dropped Lua for 7, and use JS (at least I think it's JavaScript, I extrapolated that through the js file extension)
 
They dropped Lua for 7, and use JS (at least I think it's JavaScript, I extrapolated that through the js file extension)
That's understandable as there are much more JS programmers than people knowing Lua - this affects both hiring process for the company itself and modding accessibility. However, from performance point of view Lua is better as it's specifically designed to be the scripting language.

I wonder why they didn't choose Python, though. It's more popular than JS and it much better suited to work as embedded scripting language.
 
Back
Top Bottom