Change Civ leader in-game?

Sadly, something doesn't exist in the normal .dll.

But i've seen a command today, which is used in hotseat, so maybe there's also a way for the human.

This is an extremely interesting Mod if you can pull it off. There really isn't a balanced way to play the game through all the Eras with one leader type and few traits as the game has now changed from the initial "Get in your tanks and beat them up" sort of game that Civ 1 & 2 used to be.

[...]

I hope you're succesfull here and I'll follow your progress with great interest. Well done for attempting it. :)

I've alreay done it, but i have several problems.
Open borders, defensive pacts, resource trades and espionage points are not applied after the leader change, and i have no idea why :(.

A version is attached at this post. For testing, Ashoka will change in 3800 BC to Gandhi, and you'll see the problems :(.
 
In some respects, not carrying over diplomacy makes sense though. If you have an agreement with Bismark for trade and open borders but Hitler comes to power, do you really expect the same deals to carry over? It's a different regime, and you need to start over with diplomacy, maybe even with contact. After all, if you met Qin Shi Huang during a voyage of exploration, then didn't visit China for hundreds of years, would you expect to start out on the same foot when you sail back and find Mao in control?

Espionage is the only part that makes this really problematic I think, because not allowing that to carry over basically cripples its usability. You (and the AI) would need to plan to use up all espionage points at every turning point to avoid wasting them; it would be a huge hassle for the human to keep track of and probably impossible for the AI.
 
Yes, you're right, loosing all the diplomacy changes is realistic, but for gameplay, i think it s****.
You've invested a big effort into having good relations to your neighbours, and then after one single event all is gone?
And after some "revolutions" the re-establishing of all trades would imho become a bit annyoing.

:think: i'll maybe put it in the database without all diplomacy modifiers.
 
Hi, I've downloaded your code in the extension and I can't see Asoka changes, maybe I've done something wrong. But I'll try it again when there is some more time from Real World work.

However, I did study your code and comments as to what works and what doesn't. Please do not be offended by someone who does not code in these languages. If you lok at my profile I am a strategic scenario consultant. As such I've had huge esperiences with algorithm logic in Industrial workflow applications.

One of the conclusions of my work is that when a batch of problems appear, look for an underlying common denominator even if superficially there is no correlation.

Here from your reporting and the coding that I could read, it seems that there is no problem in direct one way assignement of certain situations i.e. A==>B. Vassalage etc. works. 1 way assignation. But... there is in simultaneous situations i.e. A<==>B.

When a two way assignation is tried, there is a problem. I see that there is a loop in your coding but I can't fathom if you're SIMULATANEOUSLY assigning the values to the new Leaderhead and the old opponents or not.

From the game it seems that the AI only accepts certain assignements simulataneously as when signing agreements or executing commercial (bonus) exchanges. Maybe that's what the problem is?

Sorry if what I'm saying here has already been thought of and I'm drawing your attention to something irrelevant but I thought of this and giving you what I can. :blush:
 
Hi, I've downloaded your code in the extension and I can't see Asoka changes, maybe I've done something wrong. But I'll try it again when there is some more time from Real World work.

You can't see anything :confused:?
That's strange.
What where your starting conditions?
A change can't happen, then there's no free civ slot (in standard civ that means, when you start with 18, there can't happen a change).

I'm not finished with this yet, i've become sidetracked by spawning some civs :D.

However, I did study your code and comments as to what works and what doesn't. Please do not be offended by someone who does not code in these languages. If you lok at my profile I am a strategic scenario consultant. As such I've had huge esperiences with algorithm logic in Industrial workflow applications.

I don't feel offend (i know, that i'm a horrible coder :D), and i'm happy about every thought :), especially when there's a good background.

Here from your reporting and the coding that I could read, it seems that there is no problem in direct one way assignement of certain situations i.e. A==>B. Vassalage etc. works. 1 way assignation. But... there is in simultaneous situations i.e. A<==>B.

:think: good point.

When a two way assignation is tried, there is a problem. I see that there is a loop in your coding but I can't fathom if you're SIMULATANEOUSLY assigning the values to the new Leaderhead and the old opponents or not.

Nothing of that.
The first loop just stores the values.
After that, the old player is killed, and the second loop assigns the new values.

Interesting thing here: I also have to kill all the old deals, because it seems, that if i don't do that, these deals are canceled at the end of the round, and re-signing with the new partner doesn't override that (that means: Vassalage etc. also didn't work before that).

From the game it seems that the AI only accepts certain assignements simulataneously as when signing agreements or executing commercial (bonus) exchanges. Maybe that's what the problem is?

:think: can't really be.
Because in other cases i can force defensive pacts, etc.

Sorry if what I'm saying here has already been thought of and I'm drawing your attention to something irrelevant but I thought of this and giving you what I can. :blush:

No, i need some thoughts, because i'm a bit stuck with that.
 
This sounds very similar to an idea i had for leaders to be changable mid game in a similar way to civic and religion changes. I have minimal coding knowledge so i have never even tried to implement it yet.
 
I actually think it does make sense, to carry across diplomacy... After all, (Here I don't know anything about the War of Independence but it's the best example I can think of) even after the death of King George, with a new leader in power, or the death of Washington with a new leader in power of the United States, I doubt their relationship was not coloured by years of cultural dislike... I'm sure that the second President didn't feel all that cheerful to the British for razing cities even though it didn't happen under his command... eventually the AI will forget these things anyway...

And as for trade deals... if a new leader came into power in Germany tomorrow, I wouldn't expect all trade between Britain and Germany to stop until we organise new trade deals... I would assume the status quo would continue...

I think it would be interesting to see years of war with Monty, affect my future chances of peace with a new leader :) Especially those Civs with an agressive leader in the ancient era but a charismatic financial in the second era :)
 
I actually think it does make sense, to carry across diplomacy... After all, (Here I don't know anything about the War of Independence but it's the best example I can think of) even after the death of King George, with a new leader in power, or the death of Washington with a new leader in power of the United States, I doubt their relationship was not coloured by years of cultural dislike... I'm sure that the second President didn't feel all that cheerful to the British for razing cities even though it didn't happen under his command... eventually the AI will forget these things anyway...

And as for trade deals... if a new leader came into power in Germany tomorrow, I wouldn't expect all trade between Britain and Germany to stop until we organise new trade deals... I would assume the status quo would continue...

I think it would be interesting to see years of war with Monty, affect my future chances of peace with a new leader :) Especially those Civs with an agressive leader in the ancient era but a charismatic financial in the second era :)

I agree. Losing the diplomatic relations and the commercial treaties would make sense in a change of regime, but not in a change of leader per se. For example, if you have Henry VIII being replaced by Elizabeth I as the English leader, it would make little sense to lose the diplomatic relations and treaties, as she is a continuation of the dynasty.
 
Sorry to raise an old thread, but has there been any progress on this mod? I like very much the idea of changing leader during the game (maintaining control of the same civ of course); in case it works (works for human players too?) would it be possible to choose the leader or would the choice be completely random?
 
I've fixed some bugs, but some parts are still missing and it doesn't work for the human, still :(.
Seems, that the standard civ core just doesn't support it.


If it would work, selecting the leader would be no problem, but it doesn't :(.
 
I've fixed some bugs, but some parts are still missing and it doesn't work for the human, still :(.
Seems, that the standard civ core just doesn't support it.


If it would work, selecting the leader would be no problem, but it doesn't :(.

Hmm, I did this for Civ4Col and it works seemingly flawlessly (I change leaders depending on the date). Here are the relevant parts of the code (it should work the same for regular Civ4):

In CvPlayer.cpp:

Code:
//Androrc Change Leader
void CvPlayer::setLeaderType(LeaderHeadTypes eLeader)
{
	for (int iI = 0; iI < GC.getNumTraitInfos(); iI++)
		{
			if (GC.getLeaderHeadInfo(getLeaderType()).hasTrait(iI))
			{
				processTrait((TraitTypes) iI, -1);
			}
		}
	GC.getInitCore().setLeader(getID(), eLeader);
	GC.getInitCore().setLeaderName(getID(), GC.getLeaderHeadInfo(getLeaderType()).getDescription());
	setPersonalityType(eLeader);
	for (int iI = 0; iI < GC.getNumTraitInfos(); iI++)
		{
			if (GC.getLeaderHeadInfo(getLeaderType()).hasTrait(iI))
			{
				processTrait((TraitTypes) iI, 1);
			}
		}
}
//Androrc End

And in the CvPlayer::doTurn function:

Code:
	//do leaders
	//if the current leader's death date has passed, check for new leaders
	if (GC.getGameINLINE().getGameTurnYear() > GC.getLeaderHeadInfo(getLeaderType()).getDeathYear())
	{
		for (int iI = 0; iI < GC.getNumLeaderHeadInfos(); iI++)
		{
			LeaderHeadTypes eLeader = (LeaderHeadTypes) iI;

			//checks to see if leader is included in the civilization
			if (GC.getCivilizationInfo(getCivilizationType()).isLeaders(iI))
			{
				//if the leader's date has arrived, and the death date hasn't passed yet, set him as the leader
				if (getLeaderType() != eLeader && GC.getGameINLINE().getGameTurnYear() >= GC.getLeaderHeadInfo(eLeader).getYear() && GC.getGameINLINE().getGameTurnYear() <= GC.getLeaderHeadInfo(eLeader).getDeathYear())
				{
					//notify the player
					CvWString szBuffer = gDLL->getText("TXT_KEY_NEW_LEADER", GC.getLeaderHeadInfo(getLeaderType()).getDescription(),  GC.getLeaderHeadInfo(eLeader).getDescription(),  GC.getCivilizationInfo(getCivilizationType()).getShortDescriptionKey());
					gDLL->getInterfaceIFace()->addMessage(getID(), true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE", MESSAGE_TYPE_MAJOR_EVENT, GC.getLeaderHeadInfo(eLeader).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"));

					//set the leader
					setLeaderType(eLeader);
				}
			}
		}
	}

In CvPlayer.h:

Code:
	void setLeaderType(LeaderHeadTypes eLeader);

You should just need to add in Infos.cpp and Infos.h the necessary parts for including the <Year> and <DeathYear> fields in CIV4LeaderHeadInfos.xml.

You also need TXT_KEY_NEW_LEADER text entry, I used this one:

Code:
	<TEXT>
		<Tag>TXT_KEY_NEW_LEADER</Tag>
		<English>[COLOR_HIGHLIGHT_TEXT]%s1[COLOR_REVERT] has died! [COLOR_HIGHLIGHT_TEXT]%s2[COLOR_REVERT] shall now rule %s3.</English>
		<French>[COLOR_HIGHLIGHT_TEXT]%s1[COLOR_REVERT] has died! [COLOR_HIGHLIGHT_TEXT]%s2[COLOR_REVERT] shall now rule %s3.</French>
		<German>[COLOR_HIGHLIGHT_TEXT]%s1[COLOR_REVERT] has died! [COLOR_HIGHLIGHT_TEXT]%s2[COLOR_REVERT] shall now rule %s3.</German>
		<Italian>[COLOR_HIGHLIGHT_TEXT]%s1[COLOR_REVERT] has died! [COLOR_HIGHLIGHT_TEXT]%s2[COLOR_REVERT] shall now rule %s3.</Italian>
		<Spanish>[COLOR_HIGHLIGHT_TEXT]%s1[COLOR_REVERT] has died! [COLOR_HIGHLIGHT_TEXT]%s2[COLOR_REVERT] shall now rule %s3.</Spanish>
	</TEXT>

This should be all; if you have any doubts let me know.

I helped Tholish do a similar thing, but based on which civic the civilization is using, rather than the date:
http://forums.civfanatics.com/showthread.php?t=354369
 
If I can give a suggestion, it would be nice to be able to change leader when you choose to do so, kind of changing civic; or it could be ok to change leader when beginning a new era or depending on the date but what about civs that have only 2 or 3 leaders? I suppose new leaders should be introduced in the game?
 
If you can compile

Didn't register my copy of VS, so no :/.

and tell me when/how you want the leaders to change, I can write the code for you (if you are interested).

Interested...yes...no...the coding itself in python i were interested in, to let it be done by someone else...i don't know :D :/.
Originally i wanted to combine something like this with my realistic starting positions mod and my SpawnACiv modcomp, so that you have a real dynamic world (america appears with the tech constitution, will spawn at the eastcoast of america, and washington will later on change to lincoln, etc), and i'm still interested in it, even with someone else in the team, but i have 2 projects myself pausing at the moment, so it might be later an option.

45°38'N-13°47'E;9202056 said:
If I can give a suggestion, it would be nice to be able to change leader when you choose to do so, kind of changing civic; or it could be ok to change leader when beginning a new era or depending on the date but what about civs that have only 2 or 3 leaders? I suppose new leaders should be introduced in the game?

Nice idea, but way to far at the moment ;).
 
Interested...yes...no...the coding itself in python i were interested in, to let it be done by someone else...i don't know :D :/.
Originally i wanted to combine something like this with my realistic starting positions mod and my SpawnACiv modcomp, so that you have a real dynamic world (america appears with the tech constitution, will spawn at the eastcoast of america, and washington will later on change to lincoln, etc), and i'm still interested in it, even with someone else in the team, but i have 2 projects myself pausing at the moment, so it might be later an option.

Oh, it's entirely possible to make it work through python. All I would have to do is add the "setLeaderType" command in C++ and then expose it to python and you would be able to use it through python.
 
Back
Top Bottom