New factions/alliances

Duc Beauregard

Chieftain
Joined
Apr 1, 2012
Messages
13
Hello,
I have recently been playing the TTT - Modern Alliances mod, and I thought up a neat idea, but I am not quite sure how to implement it. Basically, the idea is about adding a couple of pre-determined faction groups which you can join and leave. For example, in Modern Alliances, there could the Axis and Allies factions.
I am thinking that it might work best if you could replace the United Nations with the factions, but I don't know if that is possible. I am thinking that the factions screen could fit in the space where the United Nations tab is. You know, where you can see the members of the UN, and who the president is?

A couple of ideas for what the factions actually do would be:
Increased relations between members (and negative relations between enemy factions)
Increased trade (between members?)
Military experience for new units
Increased espionage
Increased research depending on the research points by the members (like 5%)

I also thought that these factions could hold their own elections for the leader, and resolutions (like declaring war and embargoing players, or factions). Also, I think it could really be cool if a member could be kicked out of the faction by the other members if they don't like the player, or that they could leave somehow (maybe a small fee).

I had already started to try to do some of this through the civics, but I think that a lot of the details are already in use by the United Nations and global elections, and that jumping into this type of modding would probably be incredibly stupid without some foresight from better modders. Any advice or knowledge on how to do this would be greatly appreciated!
 
It is possible to apply the UN/Apostolic Palace concept to different factions by modding the XML only but without additional SDK/Python coding, you won't have more than what the UN/AP currently do (like no to Military experience for new units or Increased espionage). Plus you will need to have some art available.

You will also have to think what differentiate your factions and how it applies to certain Civs. Who can build the Palace? How do you enter? For example, I have added into my mod an Islamic "Palace" but it's based on religion and it's easy to adapt.

XML files of reference are CIV4VoteInfo.xml and CIV4VoteSourceInfos.xml.
 
Thanks for the info, isenchine. This is a great start in the right direction for me.
I would probably create a HQ (palace) for the factions, which could be founded by the civs. Very similar to how the United Nations (the building) works. I have successfully worked with the art files before, so that shouldn't be a problem. I am still not quite sure how a few game mechanics would work, though.

Would anyone know of an effective way to leave the faction? Moreover, is there a way to leave the United Nations that could work for this use?
I am thinking that it might work if there would be an option to leave the faction when the voting pops up, but like isenchine said, that would require a change in the Python code. If anyone has any advice on adding or modifying the resolutions, I would really like to hear it, as that might be the only way if no one has any other ideas. I think that it would be very neat to add a "kick" resolution to the list, and I think Python would be the only way to do it? By adding a new function to the python script that would dictate what the resolution, and then creating a new entry in the VoteInfo.xml with the new command?

Alternatively, what about it having civics for memberships for the factions? That way, you could choose the correct membership for the faction, and automatically be accepted into the faction. And that way, you could try to bribe another nation with money or tech to join your faction? Would this require any new Python code?
TTT - Modern Alliances already has 5 (or 6?) types of civics, the extra type being language. If I added another type of civic, would the civics screen accommodate them automatically?
 
Civic might be the right way as there is a tag for it in the CIV4VoteSourceInfos.xml file (but then it's only for voting for the Secretary General). I never tested that, neither changing the resolutions.

Would the screen automatically accomodate other civics? No, but some people on this site have already proposed their version of an extended screen.
 
I believe modern alliances has the civics screen that should allow a new type of civics option

Creating this via XML is not possible if you want to go the UN route. Theres no way to allow only certain members into the alliance and not others. You can't code it with python very well either, so unless you get lucky and have someone with extensive c++ abilities(very hard to find) it can't work well

Civics is by far the best way to go, and I've considered it. It allows people to easily choose which alliance to belong to. This works very well for human players, but outside of setting a favorite civic for a leader, its hard to influence how AI will handle it. I believe theres a python code to disallow the ability to change civics for certain civs/civics so that is an option

Its also possible to create a code stating that the people with the same alliance automatically get a relationship boost

But voting for a leader, creating a hq, voting for war would require an imense amount of Python coding, so youd have to talk to a python expert such as platyping on that

You seem to have pretty good ideas, and we are also in the middle of creating a ww1 mod (seperarw from MA so it runs faster/more accuratw) so you should come visit us at the ttt forum
 
Yes, MA does allow new civic types, dacubz145. Very handy, so kudos to whomever designed that feature.

After digging through the XML files, I found that what you said is true. I was able to get the civics working in-game, but I could not find a way to limit the civics to specific circumstances (like having to construct a building, or unit). I found a tag that supposedly made a civic specific to a religion, but I don't think that wasn't quite what I needed. In theory, I guess it might work that you could make a faction religion specific (like having the "Bishop Lords" available only to nations with Christianity, Judaism, or Catholicism), and so if I really wanted to, I could try to tie certain religions to certain factions? I guess it is a possibility if you could do that, since in each game each religion is founded in a different nation, thereby allowing for different gameplay, and the ability to try to recruit your fellow neighbors by the spread of religion. I will look into it, as that would seem to create a region-locked faction, which I thought would be an interesting feature, by having to deal with your enemies even though you are part of the same union.

Oops, after checking it seems that that religion tag was not available in MA, but it was available in Fall from Heaven, which I had opened to see if I could try to implement any of the functions into MA; and I got confused. My bad.

About the voting aspect, though, it seems that it might work to make it available to a certain civic. I haven't tested it yet, so I am not quite sure what it is for or what it does.
In the VoteSourceInfos.xml, there is a tag for "civic" (which is valued at "none"). I assumed it meant that it could require a specific civic to run, but since I couldn't find a way to make my faction civics require the construction of a building (which could start the UN voting), I didn't test it.

On a side note, I found a tag in BuildingInfos.xml called "CivicOption". Does anyone know what this does? I believe I tried putting in the name of a civic, and it threw back an error, which I believe was the "incorrect value" error, like when it is a 0 or 1 tag, and you put a 10 in it.

So, I guess I will look into trying to get that Fall from Heaven feature into MA, but I think all the functions for civics like prerequisites are not in python, but are in the files written in C++ (the CvGameCoreDLL file?), which you can not simply copy and paste in. That requires unpacking, and repacking, right?

Also, I will look forward to the new WW1 mod, then!
 
Ya I hate to say it but it isn't possible via xml, for what you want to do.

Civic in voteinfos means that you vote for everyone to not have a choice but to have that civic

CivicOption is what the Great pyramids do, you type in the option, such as government, and it unlocks all the government civics

Seriously come comment in some TTT threads with some new ideas, the more ideas the better:goodjob:
 
Thanks for the info, dacubz145. I guess I have my answer then, and I will probably not be able implement this concept. At least not until I spend the time necessary to be fluent in the two programming languages, which could take a long time because I don't really have experience in that type of programming.
Perhaps I shall become a lobbyist and simply lobby to get someone else to implement this in a mod that could use religious factions, :lol:
 
As Jarlaxe Baenre said: use special Technologies limited to certain Civs and allowing the use of a specific civic and the construction of the HQ at the same time. That's what I'm doing in my mod with religions, to control who can have the religion and who can build the Apostolic or Islamic Palace.
 
You mean, in a WWI scenario, if France teams up with Germany, we're screwed. Yes, sort of ! :D
 
Right, but it depends if we are talking in general or about TTT - Modern Alliances mod. Yes there is a problem if players decide to have a team with France & Germany in a WWI or WWII scenario.

Reading again the thread, a note to dacubz: I was talking about the tag Civic in VoteSourceInfos, not in VoteInfo. However, I haven't tested it.

Alternatively, you can use a Python Callback and allow the building of the HQ only if you are running a specific Civic. Also, in CvGameUtils.py, you have two other functions that use a Callback: canDoCivic or cannotDoCivic. Not tested.

Platyping, do you have any experience with these two functions?

And yes, again, if France teams up with Germany and cannot run 'Axis', it won't be able to build the HQ or to vote for the SG of the Axis faction.
 
Of course I do.
It is where you are supposed to do this properly :D
 
:( It does not seem to work at all with Civics, test failed. :(

Whatever Civic chosen, everybody is part of the Axis and of the Allies and vote for the two factions. The tag Civic in VoteSourceInfos only determines if you are a valid candidate or not for the leadership position in either faction.

It works with religions though!
 
Of course I do.
It is where you are supposed to do this properly :D

It's only now that I see your post! :crazyeye:

But how can you use it if whether you are a voter or not is not determined by your civic choice (but well by your religion)?

The civic choice only applies to the elligibility (and is done in xml).
 
I did not mention anything about voting.
Those 2 python callbacks will allow/disallow players from switching to certain civics in the proper way, without using other ways like dummy techs or buildings.
 
I've searched high and low for an XML + Python only solution but it seems that the functions are not sufficiently exposed to Python. There are several boolean ones (isVotingMember, isFullMember) and even a setLoyalMember but it is insufficient to produce anything valid with just that. Any opinion on this?

Then I've looked for a dll solution. Here of course, everything is possible and Kael already created something like factions in 2007 for Fall from Heaven 2. It is actually simple to have the Civic influencing who is a voting member or not. I found that it was in just one file, CvPlayer.cpp in two functions:

1) CvPlayer::getVotes
Spoiler :
Code:
int CvPlayer::getVotes(VoteTypes eVote, VoteSourceTypes eVoteSource) const
{
	int iVotes = 0;

	ReligionTypes eReligion = GC.getGameINLINE().getVoteSourceReligion(eVoteSource);

//FfH: Added by Kael 11/15/2007
	if (GC.getVoteSourceInfo(eVoteSource).getCivic() != NO_CIVIC)
	{
		if (!isCivic((CivicTypes)GC.getVoteSourceInfo(eVoteSource).getCivic()))
		{
			return 0;
		}
	}
//FfH: End Add
	if (NO_VOTE == eVote)
...etc...
2) CvPlayer::isVotingMember
Spoiler :
Code:
bool CvPlayer::isVotingMember(VoteSourceTypes eVoteSource) const
{
//FfH: Added by Kael 11/15/2007
	if (GC.getVoteSourceInfo(eVoteSource).getCivic() != NO_CIVIC)
	{
		if (!isCivic((CivicTypes)GC.getVoteSourceInfo(eVoteSource).getCivic()))
		{
			return false;
		}
	}
//FfH: End Add
	return (getVotes(NO_VOTE, eVoteSource) > 0);
}
Both codes check the Civic required in the XML file VoteSourceInfos.

It works: now you have to be a member of a faction (by choosing a specific Civic) to be able to vote! How it is in FfH2: you have a specific Civic category (like membership or something), with Civic of faction1, Civic of faction2 and a neutral no choice.

To make the Civic unavailable for a Civ, the Python solution can work like this in the Python file CvGameUtils:
Spoiler :
Code:
	def cannotDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]

		pPlayer 	= gc.getPlayer(ePlayer)
		
		listFactionAllies = [
			gc.getInfoTypeForString("CIVILIZATION_ENGLAND"),
			gc.getInfoTypeForString("CIVILIZATION_FRANCE"),
			gc.getInfoTypeForString("CIVILIZATION_AMERICA")]
		
		listFactionAxis = [
			gc.getInfoTypeForString("CIVILIZATION_GERMANY"),
			gc.getInfoTypeForString("CIVILIZATION_ROME"),
			gc.getInfoTypeForString("CIVILIZATION_JAPAN")]

		if pPlayer.getCivilizationType() in listFactionAxis:
			if eCivic == gc.getInfoTypeForString("CIVIC_REPRESENTATION"):
				return True
		elif pPlayer.getCivilizationType() in listFactionAllies:
			if eCivic == gc.getInfoTypeForString("CIVIC_POLICE_STATE"):
				return True
		
		return False
Note that this requires a Python Callback for it to work (USE_CANNOT_DO_CIVIC_CALLBACK in this case). You could do it also with XML only, nothing wrong with that. After all, most Civics are enabled by Technologies, you would have to disable some for certain Civs. The mechanism works fine, except perhaps for teams.

The next thing is what you can do with this! I'm still testing it. Note that if you add your faction votes to the UN Votes in VoteInfo.xml, the UN resolution would still be applied to everybody, not taking into consideration if you are in the faction or not (like a Civic forced, for example).

To be continued?...

Any idea, comment or suggestion most welcome.
 
Back
Top Bottom