Force War on Contact

ruff_hi

Live 4ever! Or die trying
Joined
Oct 24, 2005
Messages
9,135
Location
an Aussie in Boston
I am trying to create a mod that is always war between all civs. I can set 'always war' but that is every civ against the human. I can set 'perpetual war or peace' (or something with a similar name) but that is a flag that continues the current state (ie always in war if started at war, always in peace if started at peace).

What I would like is to set the civs to always war, but only on contact between the civs. I can get close to this by selecting the 'always war / peace' flag, starting the game and change the status to WAR in WB. The downside of this is that you get automatic contact with all the other civs.

Does any one have a suggestion? I would prefer a 100% python method.
 
you can use the onFirstContact method in the CvEventManager class. It should look like:
Code:
	def onFirstContact(self, argsList):
		'Contact'
		iTeamX,iHasMetTeamY = argsList

		objTeam = gc.getTeam(iTeamX)
		objTeam.declareWar(iHasMetTeamY, false)
 
Wow - that seems easy - thx. Searched for 'declarewar' and also found this in 'CvDiplomacy.py' ...
PHP:
def handleUserResponse(self, eComment, iData1, iData2):
	diploScreen = CyDiplomacy()
	# If we choose war
	elif (self.isComment(eComment, "USER_DIPLOCOMMENT_WAR")):
			diploScreen.declareWar()
			#diploScreen.closeScreen()
I'm going to try 'CyDiplomacy().declareWar()' as a command in the 'onFirstContact' and see what happens.
 
ruff_hi said:
Wow - that seems easy - thx. Searched for 'declarewar' and also found this in 'CvDiplomacy.py' ...
PHP:
def handleUserResponse(self, eComment, iData1, iData2):
	diploScreen = CyDiplomacy()
	# If we choose war
	elif (self.isComment(eComment, "USER_DIPLOCOMMENT_WAR")):
			diploScreen.declareWar()
			#diploScreen.closeScreen()
I'm going to try 'CyDiplomacy().declareWar()' as a command in the 'onFirstContact' and see what happens.
I can already tell you that it won't work, there are internal settings in the CvDiplomacy.py file that aren't going to be in the CvEventManager.py file.
 
Ok, just this ...
Code:
	def onFirstContact(self, argsList):
		'Contact'
		iTeamX,iHasMetTeamY = argsList

		objTeam = gc.getTeam(iTeamX)
		objTeam.declareWar(iHasMetTeamY, false)
... and it didn't work. I tried it with 'always war or peace' both checked and unchecked. I was thinking of tweeking the XML attitude items - I might try that.
 
ruff_hi said:
... and it didn't work.

Did the civs declare war and later make peace? TheLopez' code doesn't prevent the AI from making peace, maybe that's why.
 
Teg_Navanis said:
Did the civs declare war and later make peace? TheLopez' code doesn't prevent the AI from making peace, maybe that's why.
Contact deemed no different from normal. They didn't declare war.
 
I can offer you an SDK change, but I dunno if you know how to do this:

CvTeam.cpp, lines 2641-2650

Code:
		if (GC.getGameINLINE().isOption(GAMEOPTION_ALWAYS_WAR))
		{
			if (isHuman())
			{
				if (getID() != eIndex)
				{
					declareWar(eIndex, false);
				}
			}
		}

to

Code:
		if (GC.getGameINLINE().isOption(GAMEOPTION_ALWAYS_WAR))
		{
				if (getID() != eIndex)
				{
					declareWar(eIndex, false);
				}
		}
 
I haven't looked at the SDK. Seems like a fairly easy change. I'm assuming this gives you a differrent DLL and that you stick it somewhere for it to 'take'?
 
You have to edit the source file, compile it to get a DLL (there is a tutorial here) and put that DLL either in your CustomAssets directory or the Assets directory of a mod.

I don't know if the AI civs will be able to contact each other and make peace. If they do, I can tell you what else to change to prevent them from doing so.
 
Teg_Navanis said:
You have to edit the source file, compile it to get a DLL (there is a tutorial here) and put that DLL either in your CustomAssets directory or the Assets directory of a mod.

I don't know if the AI civs will be able to contact each other and make peace. If they do, I can tell you what else to change to prevent them from doing so.
Thanks - I will give it a try. Re making peace - I was going to change the 'don't talk for x turns' part in the XML to 9999 - I think that should do it.
 
Teg_Navanis said:
You have to edit the source file, compile it to get a DLL (there is a tutorial here) and put that DLL either in your CustomAssets directory or the Assets directory of a mod.
Thx Teg for your help. I just installed all the free software and managed to comment out the code suggested. I compiled it all (file size is 4.780k - does that sound right) and played a small sample game. Meet the chinese on round 2 and the greek on round 7. Checked the diplomatic screen and the chinese were at war with the greek (seems to be working!). I had changed the 'don't talk due to war' to 9999 and neither of them are talking to me.

Guess I can now play an ALL WAR game where everyone is at war.
 
Yes, the file size sounds about right. After seeing how little had to be changed, I wonder why Firaxis didn't think of adding that option... it couldn't have been too much work :)
 
Teg_Navanis said:
Yes, the file size sounds about right. After seeing how little had to be changed, I wonder why Firaxis didn't think of adding that option... it couldn't have been too much work :)
You can't have too many options else the game gets cluttered.
 
The Great Apple said:
You can't have too many options else the game gets cluttered.

That's certainly true, so let me rephrase it: when I choose "always war" as an option, I expect the AI civs to be at war with each other too. Hence, I don't understand why the conditional was added in the first place... well, I do have a guess. It may turn out that the AI can't handle "always war" and that the AI civs will cripple each other, leaving you mostly unaffected if you concentrate on defending.
 
Teg_Navanis said:
That's certainly true, so let me rephrase it: when I choose "always war" as an option, I expect the AI civs to be at war with each other too. Hence, I don't understand why the conditional was added in the first place... well, I do have a guess. It may turn out that the AI can't handle "always war" and that the AI civs will cripple each other, leaving you mostly unaffected if you concentrate on defending.
I see what you mean.

I this it's like this because that is how the OCC / AW games of Civ 3 worked - the human would try to defeat the AI while being restricted to only ever having one city, and/or always being at war with the AIs.
 
I tested this on my machine (included a mod that involved changes to XML) and it worked perfectly. I've subsequently uploaded the modified dll and changed xml. One of the testers reports the following issues ...
  1. invalid windows image CvGameCoreDLL.dll
  2. failed to find sibling civ4gametextinfos.xml (getting this one twice)
    Fixed: slopping coding of XML file by me :hammer2:
Any suggestions on what the issue(s) is/are?
 
ruff_hi said:
I tested this on my machine (included a mod that involved changes to XML) and it worked perfectly. I've subsequently uploaded the modified dll and changed xml. One of the testers reports the following issues ...
  1. invalid windows image CvGameCoreDLL.dll
  2. failed to find sibling civ4gametextinfos.xml (getting this one twice)
    Fixed: slopping coding of XML file by me :hammer2:
Any suggestions on what the issue(s) is/are?

Where did you upload the file? Which XML file contains the # of turns that the AI won't talk?

Roger Bacon
 
RogerBacon said:
Where did you upload the file? Which XML file contains the # of turns that the AI won't talk?

Roger Bacon
The xml files are uploaded here and the dll is in the next (or previous) post. The 'CIV4LeaderHeadInfos.xml' file contains the # of turns.
 
Thanks. I looked at the XML file and I don't like changing that can't talk value because it would affect games that are not always war also. I think I have found another way to do it.

In CvPlayer.cpp, line 3001 there is this: (comment mine)

Code:
if (isHuman() || GET_PLAYER(ePlayer).isHuman()) // Remove this for AI to stay at war with each other as well. RogerBacon AlwaysWar Mod
		{
			if (GC.getGameINLINE().isOption(GAMEOPTION_ALWAYS_WAR))
			{
				return false;
			}
		}

I will probably test this this weekend but I'm pretty sure it will work. It might also be a good idea to reduce the war weariness so the AI doesn't fall apart after 100+ turns of war.

Roger Bacon
 
Back
Top Bottom