Quick Modding Questions Thread

Nothing; in that particular situation I can reproduce it. And I've verified that it's this part of the declareWar() method:
Code:
		for (pLoopDeal = GC.getGameINLINE().firstDeal(&iLoop); pLoopDeal != NULL; pLoopDeal = GC.getGameINLINE().nextDeal(&iLoop))
		{
			if (((GET_PLAYER(pLoopDeal->getFirstPlayer()).getTeam() == getID()) && (GET_PLAYER(pLoopDeal->getSecondPlayer()).getTeam() == eTeam)) ||
					((GET_PLAYER(pLoopDeal->getFirstPlayer()).getTeam() == eTeam) && (GET_PLAYER(pLoopDeal->getSecondPlayer()).getTeam() == getID())))
			{
				pLoopDeal->kill();
			}
		}
So it's definitely the deals between both civs. I've tried to exclude peace deals from the terminated deals, but that doesn't solve it.
 
Not sure what you do, so I tried a small test.
Code:
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList
## Test ##
		if iGameTurn %10 == 8:
			pPlayer = gc.getPlayer(iPlayer)
			if pPlayer.isHuman():
				iTeam = pPlayer.getTeam()
				pTeam = gc.getTeam(iTeam)
				for iTeamX in xrange(gc.getMAX_CIV_TEAMS()):
					pTeamX = gc.getTeam(iTeamX)
					if pTeamX.isAlive() and iTeamX != iTeam:
						pTeam.declareWar(iTeamX, true, -1)
## Test ##

Declare war on everyone every XX9 Turn.
Tried it during first 10 turns of universal peace of advanced start, works.
Tried it during 10 turns of forced peace, works.
Tried both ways, I declare war on everyone, as well as the other way, both work.

Screenshots of one where I declare, and the other where others declare.
Both peace treaties are canceled
 
The problem was that the war was declared in reaction to an onTechAcquired() event that in turn was triggered by a tech received during a tech trade with the civ that ends up to be the target. I hope that is clear :crazyeye:

I've investigated the problem further and I think it's because individual elements of a trade deal are handed over separately, triggering the associated events.

In the save I was working on, I was playing as the Mughals and made a deal with France to give them Economics for Replaceable Parts. Acquiring Economics as a European civ spawns some units in India (to represent European trading companies) and triggers a war with everyone who happens to hold cities there. Because I was the Mughals, that happened to be me. So when the game executed the trade, it first gave Economics to France. This immediately triggered onTechAcquired() and thus the declaration on me before the rest of the trade was executed. But since every trade includes a peace treaty, later on the game tries to establish a peace treaty even though I've set the civs at war via Python. Apparently the game can't handle this for some reason (the situation didn't need to be accounted for since you can't make trades when you're already at war), although I haven't been able to identify the exact source of the problem. Anyway, I've rewritten the deal execution code that it now checks for every item whether you're at war now, and if that's the case, skips all items that contain a peace treaty. At least in my sample save that eliminated the crash.

Thanks for your efforts, nevertheless :)
 
Code:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object

## Test ##
		if iTechType == gc.getInfoTypeForString("TECH_ECOLOGY"):
			pTeam = gc.getTeam(iTeam)
			for iTeamX in xrange(gc.getMAX_CIV_TEAMS()):
				pTeamX = gc.getTeam(iTeamX)
				if pTeamX.isAlive() and iTeamX != iTeam:
					pTeam.declareWar(iTeamX, true, -1)
## Test ##

No idea, still works for me this way

1) The Trade
2) Trade Success
3) War Declared

P.S.
Tech for Tech also no issue, after the war declared screen, I get the new tech screen as well.
 
Is it important in the ArtDefines.xml if the entries for nif and kfm are written exact the same way the files are named? I mean is Cavalry the same as cavalry?
 
is anyone aware of a mod component that requires resources to be within the city radius to be used by that city?
 
Normally in XML I comment out like this:

Code:
		<!--
		<MovieArtInfo>
			<Type>ART_DEF_MOVIE_LEONARDO</Type>
			<Path>Art/Movies/Wonders/Leonardos_Workshop.bik</Path>
		</MovieArtInfo>
		-->

It works well but when I started to work with a debug-dll it seems, that he has problems with this, because on every file I have something like this in, I got this message, while using the debug-dll:
Code:
Assert Failed

File:  CvXMLLoadUtilitySet.cpp
Line:  1364
Expression:  bSuccess
Message:

This refers to:
Code:
	char szLog[256];
	sprintf(szLog, "SetGlobalClassInfo (%s)", szTagName);
	PROFILE(szLog);
	logMsg(szLog);

	// if we successfully locate the tag name in the xml file
	if (gDLL->getXMLIFace()->LocateNode(m_pFXml, szTagName))
	{
		// loop through each tag
		do
		{
			SkipToNextVal();	// skip to the next non-comment node

				T* pClassInfo = new T;

				FAssert(NULL != pClassInfo);
				if (NULL == pClassInfo)
				{
					break;
				}

				bool bSuccess = pClassInfo->read(this);
				[COLOR="Red"]FAssert(bSuccess);[/COLOR]
				if (!bSuccess)
				{
					delete pClassInfo;
					break;
				}


Is there any other/better way to comment out things in xml? Or is it ok like this?
 
is it possible for a unit to have two unit classes i.e. a unit replaces a knight and a mace-man?
 
If you mean that the knight and the maceman should be updated to the same unit, that´s possible, since you make the entry in the unit that will be updated. So you have to do the same entry in the UnitInfo of the knight and the maceman. It should look like this:
Code:
			<UnitClassUpgrades>
				<UnitClassUpgrade>
					<UnitClassUpgradeType>UNITCLASS_CUIRASSIER</UnitClassUpgradeType>
					<bUnitClassUpgrade>1</bUnitClassUpgrade>
				</UnitClassUpgrade>
			</UnitClassUpgrades>
 
Normally in XML I comment out like this:

[...]

Is there any other/better way to comment out things in xml? Or is it ok like this?

That's how a comment should look, but sadly the Civ4 XML parser does not deal very well with the comments. In some files the comments might even break the file.
So I guess this here....er...Firaxis' fault, somehow an improper implementation, I'd guess.
 
i meant a UU replacing both a knight and a maceman
 
is there a cleaner way to do the uu replacing as right now it looks rather sloppy with two identical options of the same unit
 
You can just add the <bGraphical> tag to the UnitInfo and set it to 1 for one of them, so that only one of them show up in the civilopedia.
You will have to edit the schemma for Units to add in that tag I believe.

I did that for buildings so may be doable for units as well.
 
no not in the civilopedia in the build menu
 
Have to use python and activate callback to set one of them untrainable then.

Although I am confused why you have a same UU replacing 2 different units for one civilization.
 
I am attempting to create a mod to add a religion to the game. However, when I load the mod, it either says "Failed to load" or "loadxml call failed" on every piece of XML I created. I used another mod as a template, copying their original files and then replacing the various contents with my contents instead, so I cannot figure out, for the life of me, what is going wrong.

Here is the mod in its current form:
http://www.mediafire.com/?opfsfedhz662hgs

I'm guessing it's something simple, like some kind of minor error that crept into all of the XML files, but...as a novice to modding in general, I'm not really sure what I could be doing wrong.
 
Top Bottom