sworn enemies/friends per civ

luukjn

Chieftain
Joined
Sep 23, 2009
Messages
9
I have been working on a mod where each civ has a pre-set attitude towards their friends (+10) and enemies (-10).

The first way I got this working was to hard-code it in a world builder scenario file, which is not very neat, since the pre-set relations will not work for the automatic map scripts (aka play now). And I would have to put it in every scenario I create.

So I have been trying to put it in the SDK so I can code the relations in CIV4CivilizationInfos.xml as follows:
Code:
<Enemies>
    <Civilization>
        <CivilizationType>CIVILIZATION_1</CivilizationType>
	<bCivilizationType>1</bCivilizationType>
    </Civilization>
    <Civilization>
	<CivilizationType>CIVILIZATION_2</CivilizationType>
	<bCivilizationType>1</bCivilizationType>
    </Civilization>
</Enemies>
<Friends>
    <Civilization>
	<CivilizationType>CIVILIZATION_3</CivilizationType>
	<bCivilizationType>1</bCivilizationType>
    </Civilization>
    <Civilization>
	<CivilizationType>CIVILIZATION_4</CivilizationType>
	<bCivilizationType>1</bCivilizationType>
    </Civilization>
</Friends>

This would mean that the civilization is the sworn enemy of civilization 1 and 2, while it is best friends with civilization 3 and 4.

This translates to the following XML loading code in the SDK:
Code:
bool CvCivilizationInfo::read(CvXMLLoadUtility* pXML)
{
// ...
    pXML->SetVariableListTagPair(&m_pbEnemies, "Enemies", sizeof(GC.getCivilizationInfo((CivilizationTypes)0)), GC.getNumCivilizationInfos());
    pXML->SetVariableListTagPair(&m_pbFriends, "Friends", sizeof(GC.getCivilizationInfo((CivilizationTypes)0)), GC.getNumCivilizationInfos());
// ...
}
Since I need the tags in civilizationInfos I have put the above code in the CvCivilization class, which creates the obvious problem that I'm trying to load in civilizations in the SDK while they haven't even been loaded yet (the game crashes on this).
The question I have is: how can I access the civilizations before they are loaded, so that my arrays get initialized correctly? Or should I try to put the tags in some other place even though civilizationInfos seems to be the most logical place for the tags to be.
Or am I better off resorting to python for this?
 
Already got this working, I just had to look further then the next method.

I now placed the XML load lines like this:
Code:
bool CvCivilizationInfo::readPass2(CvXMLLoadUtility* pXML)
{
// ...
	pXML->SetVariableListTagPair(&m_pbEnemies, "Enemies", sizeof(GC.getCivilizationInfo((CivilizationTypes)0)), GC.getNumCivilizationInfos());
	pXML->SetVariableListTagPair(&m_pbFriends, "Friends", sizeof(GC.getCivilizationInfo((CivilizationTypes)0)), GC.getNumCivilizationInfos());
// ...
}
And that works fine.
Just putting this out here for other people who might run into the same problem :)
 
Back
Top Bottom