Need help with a custom victory condition...

Aurelia

Chieftain
Joined
Jan 28, 2007
Messages
13
The resources on this site have been incredibly helpful as I build my first mod. Thanks to everyone for their contributions!

I can't seem to find the answer to one pesky problem:

My goal is a mod that has three "good" players and three "evil" players, with a bunch of players in between. The goal of the game is for all "good" or "evil" players to be wiped out.

Ideally, the good and evil players would jockey for allies among the players in between, and the players who are neither good nor evil would be forced to eventually choose sides.

Is this possible? I'm great with XML, but Python is out of my league, so if it is possible to do this as an XML mod, I'd really prefer that method.

Thanks!
 
tbh - I think you would need to have a bit of python to achieve this, maybe find a python coder with a bit of spare time to write the code for you (I'll look into it, but I am still very new to coding myself, and have some other large projects I am currently working on).
Edit:I am assuming two things here, that you have warlords, and that you have an IMB Version, or that Mac Version is the same as IBM version in reguards to Python... I might have something good to go in a day or more - really depends on how problematic I find this...
2nd Edit:I have found out that you might also need to edit the SDK, if you can get this to compile yourself at least, I think I can tell you exactly what you will need to do (not sure yet, I am in the middle of compiling what I just done right now).
In short the way I have gone about this is by adding a new tag to the civ4civilizationinfos.xml called <iFaction>0</iFaction> and another tag to the civ4victoryinfo.xml called <bFaction>0</bFaction> which is either 0 for no faction victory, or 1 for a faction victory, which you can then enter in a new victory conditon in the civ4victoryinfo.xml file that represents your faction win.
To do this I had to do some very simple editing of the SDK to make Civ IV actually load the values, and to export them to Python, which will then check to see if there has been a faction win.
I might be making this post early, since I havn't tested the theory yet, nor written the Python code to actually detect the win, just made the custom tags is all.(it just finished compiling so I am going to check and make sure I don't get any errors in the actual game now - bbl)
Well it smurfed, so I'll try and figure out why, but if I don't manage it I think you will find the above method is the way you'll have to do it - maybe someone with a bit more exp in the SDK dept. might be able to suggest better...

Here's a start of the edits I made that actually don't glitch the game, but also don't do anything yet except add a tag to the Civ4VictoryInfo.xml file....

The files that are being edited are
XML
CIV4VictoryInfo.xml
CIV4GameInfoSchea.xml
C++ SDK
CvInfos.cpp
CvInfos.h

Find this code in CvInfos.h...
Code:
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//  class : CvVictoryInfo
//
//  DESC:   
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...just below there is a section which looks like this without the edit in it, add the edit...
Code:
public:

	DllExport CvVictoryInfo();
	DllExport virtual ~CvVictoryInfo();

	DllExport int getPopulationPercentLead() const;				// Exposed to Python
	DllExport int getLandPercent() const;				// Exposed to Python
	DllExport int getMinLandPercent() const;				// Exposed to Python
	DllExport int getReligionPercent() const;				// Exposed to Python
	DllExport int getCityCulture() const;				// Exposed to Python
	DllExport int getNumCultureCities() const;				// Exposed to Python
	DllExport int getTotalCultureRatio() const;				// Exposed to Python

	DllExport bool isFaction() const;					// Exposed to Python ** EDITED by TRN2
	DllExport bool isTargetScore() const;				// Exposed to Python
	DllExport bool isEndScore() const;					// Exposed to Python
	DllExport bool isConquest() const;					// Exposed to Python
	DllExport bool isDiploVote() const;					// Exposed to Python
	DllExport bool isPermanent() const;					// Exposed to Python

	DllExport const char* getMovie() const;

	DllExport bool read(CvXMLLoadUtility* pXML);
...straight after that is this next section which you have to add a line as well...
Code:
protected:

	int m_iPopulationPercentLead;
	int m_iLandPercent;
	int m_iMinLandPercent;
	int m_iReligionPercent;
	int m_iCityCulture;
	int m_iNumCultureCities;
	int m_iTotalCultureRatio;

	bool m_bFaction;              //EDITED by TRN2
	bool m_bTargetScore;
	bool m_bEndScore;
	bool m_bConquest;
	bool m_bDiploVote;
	bool m_bPermanent;

	CvString m_szMovie;
Save that, then go to the file called CvInfos.cpp and look for...
Code:
//------------------------------------------------------------------------------------------------------
//
//  FUNCTION:   CvVictoryInfo()
//
//  PURPOSE :   Default constructor
//
//------------------------------------------------------------------------------------------------------
...below that is the following, add my edit to it...
Code:
CvVictoryInfo::CvVictoryInfo() :
m_iPopulationPercentLead(0),
m_iLandPercent(0),
m_iMinLandPercent(0),
m_iReligionPercent(0),
m_iCityCulture(0),
m_iNumCultureCities(0),
m_iTotalCultureRatio(0),
m_bFaction(false),					//EDITED by TRN2
m_bTargetScore(false),
m_bEndScore(false),
m_bConquest(false),
m_bDiploVote(false),
m_bPermanent(false)
{
}
...A tiny bit down from there you will see the following less the edit, add it...
Code:
int CvVictoryInfo::getNumCultureCities() const		
{
	return m_iNumCultureCities;
}

int CvVictoryInfo::getTotalCultureRatio() const		
{
	return m_iTotalCultureRatio;
}

bool CvVictoryInfo::isFaction() const					//BEGIN EDIT by TRN2
{
	return m_bFaction;
}														//END EDIT by TRN2

bool CvVictoryInfo::isTargetScore() const
{
	return m_bTargetScore;
}

bool CvVictoryInfo::isEndScore() const
{
	return m_bEndScore;
}
...in the next section directly below that add my next edit...
Code:
bool CvVictoryInfo::read(CvXMLLoadUtility* pXML)
{
	CvString szTextVal;
	if (!CvInfoBase::read(pXML))
	{
		return false;
	}

	pXML->GetChildXmlValByName(&m_bFaction, "bFaction");			//EDITED by TRN2
	pXML->GetChildXmlValByName(&m_bTargetScore, "bTargetScore");
	pXML->GetChildXmlValByName(&m_bEndScore, "bEndScore");
	pXML->GetChildXmlValByName(&m_bConquest, "bConquest");
	pXML->GetChildXmlValByName(&m_bDiploVote, "bDiploVote");
	pXML->GetChildXmlValByName(&m_bPermanent, "bPermanent");
...you can then edit the following XML files...
CIV4GameInfoSchema.xml here...
Code:
	<ElementType name="HandicapInfos" content="eltOnly">
		<element type="HandicapInfo" maxOccurs="*"/>
	</ElementType>
	<ElementType name="bFaction" content="textOnly" dt:type="boolean"/>     <!-- EDITED HERE -->
	<ElementType name="bTargetScore" content="textOnly" dt:type="boolean"/>
	<ElementType name="bEndScore" content="textOnly" dt:type="boolean"/>
	<ElementType name="bConquest" content="textOnly" dt:type="boolean"/>
	<ElementType name="bDiploVote" content="textOnly" dt:type="boolean"/>
	<ElementType name="bPermanent" content="textOnly" dt:type="boolean"/>
	<ElementType name="iPopulationPercentLead" content="textOnly" dt:type="int"/>
...and here...
Code:
	<ElementType name="VictoryInfo" content="eltOnly">
		<element type="Type"/>
		<element type="Description"/>
		<element type="Civilopedia"/>
		<element type="bFaction" minOccurs="0"/>              <!--EDITED HERE-->
		<element type="bTargetScore"/>
		<element type="bEndScore"/>
		<element type="bConquest"/>
		<element type="bDiploVote"/>
		<element type="bPermanent"/>
		<element type="iPopulationPercentLead"/>
		<element type="iLandPercent"/>
		<element type="iMinLandPercent"/>
		<element type="iReligionPercent"/>
		<element type="CityCulture"/>
		<element type="iNumCultureCities"/>
		<element type="iTotalCultureRatio"/>
		<element type="VictoryMovie"/>
	</ElementType>
...and then in CIV4VictoryInfo change every entry to include the tag <bFaction>0/1</bFaction> like this example...
Code:
		<VictoryInfo>
			<Type>VICTORY_FACTION</Type>
			<Description>TXT_KEY_VICTORY_FACTION</Description>
			<Civilopedia>TXT_KEY_VICTORY_FACTION_PEDIA</Civilopedia>
			<bFaction>1</bFaction>          <!--The New TAG Goes Here-->
			<bTargetScore>0</bTargetScore>
			<bEndScore>0</bEndScore>
			<bConquest>0</bConquest>
			<bDiploVote>0</bDiploVote>
			<bPermanent>0</bPermanent>
			<iPopulationPercentLead>0</iPopulationPercentLead>
			<iLandPercent>0</iLandPercent>
			<iMinLandPercent>0</iMinLandPercent>
			<iReligionPercent>0</iReligionPercent>
			<CityCulture>NONE</CityCulture>
			<iNumCultureCities>0</iNumCultureCities>
			<iTotalCultureRatio>0</iTotalCultureRatio>
			<VictoryMovie></VictoryMovie>
		</VictoryInfo>
I will also let you know that if <bFaction>1</bFaction> is set to 0 the victory will NOT fire with a faction victory, and that if it is set to 1, then this victory will fire with a faction victory, but I still need to write the python code to do this, and this might not be until after my next sleep.
Another thing you might do that I have not done is add a TXT_KEY entry or two into the Text subfolder for this victory condition, bbl with the CIV4Civilizations.XML when I have finished it, and got it to work without smurfing ;)
 
Same two files from the SDK....
CvInfos.cpp
CvInfos.h

the edits that I am making are listed here...
CvInfos.h
Code:
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//  class : CvLeaderHeadInfo
//
//  DESC:
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class CvArtInfoLeaderhead;
class CvLeaderHeadInfo :
	public CvInfoBase
{
	//---------------------------------------PUBLIC INTERFACE---------------------------------
public:

	DllExport CvLeaderHeadInfo();
	DllExport virtual ~CvLeaderHeadInfo();

[B][I][U]	DllExport int getFaction() const;		//Faction Mod by TRN2&Impaler[/U][/I][/B]	DllExport int getWonderConstructRand() const;				// Exposed to Python
	DllExport int getBaseAttitude() const;				// Exposed to Python
	DllExport int getBasePeaceWeight() const;				// Exposed to Python
	DllExport int getPeaceWeightRand() const;				// Exposed to Python
	DllExport int getWarmongerRespect() const;				// Exposed to Python
	DllExport int getRefuseToTalkWarThreshold() const;				// Exposed to Python
	DllExport int getNoTechTradeThreshold() const;				// Exposed to Python
	DllExport int getTechTradeKnownPercent() const;				// Exposed to Python
	DllExport int getMaxGoldTradePercent() const;				// Exposed to Python
	DllExport int getMaxGoldPerTurnTradePercent() const;				// Exposed to Python
	DllExport int getMaxWarRand() const;				// Exposed to Python
	DllExport int getMaxWarNearbyPowerRatio() const;				// Exposed to Python
	DllExport int getMaxWarDistantPowerRatio() const;				// Exposed to Python
	DllExport int getMaxWarMinAdjacentLandPercent() const;				// Exposed to Python
	DllExport int getLimitedWarRand() const;				// Exposed to Python
	DllExport int getLimitedWarPowerRatio() const;				// Exposed to Python
	DllExport int getDogpileWarRand() const;				// Exposed to Python
	DllExport int getMakePeaceRand() const;				// Exposed to Python
	DllExport int getDeclareWarTradeRand() const;				// Exposed to Python
	DllExport int getDemandRebukedSneakProb() const;				// Exposed to Python
	DllExport int getDemandRebukedWarProb() const;				// Exposed to Python
	DllExport int getRazeCityProb() const;				// Exposed to Python
	DllExport int getBuildUnitProb() const;				// Exposed to Python
	DllExport int getBaseAttackOddsChange() const;				// Exposed to Python
	DllExport int getAttackOddsChangeRand() const;				// Exposed to Python
	DllExport int getWorseRankDifferenceAttitudeChange() const;				// Exposed to Python
	DllExport int getBetterRankDifferenceAttitudeChange() const;				// Exposed to Python
	DllExport int getCloseBordersAttitudeChange() const;				// Exposed to Python
	DllExport int getLostWarAttitudeChange() const;				// Exposed to Python
	DllExport int getAtWarAttitudeDivisor() const;				// Exposed to Python
	DllExport int getAtWarAttitudeChangeLimit() const;				// Exposed to Python
	DllExport int getAtPeaceAttitudeDivisor() const;				// Exposed to Python
	DllExport int getAtPeaceAttitudeChangeLimit() const;				// Exposed to Python
	DllExport int getSameReligionAttitudeChange() const;				// Exposed to Python
	DllExport int getSameReligionAttitudeDivisor() const;				// Exposed to Python
	DllExport int getSameReligionAttitudeChangeLimit() const;				// Exposed to Python
	DllExport int getDifferentReligionAttitudeChange() const;				// Exposed to Python
	DllExport int getDifferentReligionAttitudeDivisor() const;				// Exposed to Python
	DllExport int getDifferentReligionAttitudeChangeLimit() const;				// Exposed to Python
	DllExport int getBonusTradeAttitudeDivisor() const;				// Exposed to Python
	DllExport int getBonusTradeAttitudeChangeLimit() const;				// Exposed to Python
	DllExport int getOpenBordersAttitudeDivisor() const;				// Exposed to Python
	DllExport int getOpenBordersAttitudeChangeLimit() const;				// Exposed to Python
	DllExport int getDefensivePactAttitudeDivisor() const;				// Exposed to Python
	DllExport int getDefensivePactAttitudeChangeLimit() const;				// Exposed to Python
	DllExport int getShareWarAttitudeChange() const;				// Exposed to Python
	DllExport int getShareWarAttitudeDivisor() const;				// Exposed to Python
	DllExport int getShareWarAttitudeChangeLimit() const;				// Exposed to Python
	DllExport int getFavoriteCivicAttitudeChange() const;				// Exposed to Python
	DllExport int getFavoriteCivicAttitudeDivisor() const;				// Exposed to Python
	DllExport int getFavoriteCivicAttitudeChangeLimit() const;				// Exposed to Python
	DllExport int getDemandTributeAttitudeThreshold() const;				// Exposed to Python
	DllExport int getNoGiveHelpAttitudeThreshold() const;				// Exposed to Python
	DllExport int getTechRefuseAttitudeThreshold() const;				// Exposed to Python
	DllExport int getStrategicBonusRefuseAttitudeThreshold() const;				// Exposed to Python
	DllExport int getHappinessBonusRefuseAttitudeThreshold() const;				// Exposed to Python
	DllExport int getHealthBonusRefuseAttitudeThreshold() const;					// Exposed to Python
	DllExport int getMapRefuseAttitudeThreshold() const;									// Exposed to Python
	DllExport int getDeclareWarRefuseAttitudeThreshold() const;						// Exposed to Python
	DllExport int getDeclareWarThemRefuseAttitudeThreshold() const;				// Exposed to Python
	DllExport int getStopTradingRefuseAttitudeThreshold() const;					// Exposed to Python
	DllExport int getStopTradingThemRefuseAttitudeThreshold() const;			// Exposed to Python
	DllExport int getAdoptCivicRefuseAttitudeThreshold() const;						// Exposed to Python
	DllExport int getConvertReligionRefuseAttitudeThreshold() const;			// Exposed to Python
	DllExport int getOpenBordersRefuseAttitudeThreshold() const;					// Exposed to Python
	DllExport int getDefensivePactRefuseAttitudeThreshold() const;				// Exposed to Python
	DllExport int getPermanentAllianceRefuseAttitudeThreshold() const;		// Exposed to Python
	DllExport int getVassalRefuseAttitudeThreshold() const;				// Exposed to Python
	DllExport int getVassalPowerModifier() const;				// Exposed to Python
	DllExport int getFavoriteCivic() const;																// Exposed to Python

	DllExport const TCHAR* getArtDefineTag() const;				// Exposed to Python
	DllExport void setArtDefineTag(const TCHAR* szVal);

	// Arrays

	DllExport bool hasTrait(int i) const;				// Exposed to Python

	DllExport int getFlavorValue(int i) const;				// Exposed to Python
	DllExport int getContactRand(int i) const;				// Exposed to Python
	DllExport int getContactDelay(int i) const;				// Exposed to Python
	DllExport int getMemoryDecayRand(int i) const;				// Exposed to Python
	DllExport int getMemoryAttitudePercent(int i) const;				// Exposed to Python
	DllExport int getNoWarAttitudeProb(int i) const;				// Exposed to Python
	DllExport int getUnitAIWeightModifier(int i) const;				// Exposed to Python
	DllExport int getImprovementWeightModifier(int i) const;				// Exposed to Python
	DllExport int getDiploPeaceIntroMusicScriptIds(int i) const;
	DllExport int getDiploPeaceMusicScriptIds(int i) const;
	DllExport int getDiploWarIntroMusicScriptIds(int i) const;
	DllExport int getDiploWarMusicScriptIds(int i) const;

	// Other

	DllExport const CvArtInfoLeaderhead* getArtInfo() const;
	DllExport const TCHAR* getLeaderHead() const;
	DllExport const TCHAR* getButton() const;

	DllExport void write(FDataStreamBase* stream);
	DllExport void read(FDataStreamBase* stream);
	DllExport bool read(CvXMLLoadUtility* pXML);

	//---------------------------------------PROTECTED MEMBER VARIABLES---------------------------------
protected:

[B][I][U]	int m_iFaction;				//Faction Mod by TRN2 & Impaler[/U][/I][/B]	int m_iWonderConstructRand;
	int m_iBaseAttitude;
	int m_iBasePeaceWeight;
	int m_iPeaceWeightRand;
	int m_iWarmongerRespect;
	int m_iRefuseToTalkWarThreshold;
	int m_iNoTechTradeThreshold;
	int m_iTechTradeKnownPercent;
	int m_iMaxGoldTradePercent;
	int m_iMaxGoldPerTurnTradePercent;
	int m_iMaxWarRand;
	int m_iMaxWarNearbyPowerRatio;
	int m_iMaxWarDistantPowerRatio;
	int m_iMaxWarMinAdjacentLandPercent;
	int m_iLimitedWarRand;
	int m_iLimitedWarPowerRatio;
	int m_iDogpileWarRand;
	int m_iMakePeaceRand;
	int m_iDeclareWarTradeRand;
	int m_iDemandRebukedSneakProb;
	int m_iDemandRebukedWarProb;
	int m_iRazeCityProb;
	int m_iBuildUnitProb;
	int m_iBaseAttackOddsChange;
	int m_iAttackOddsChangeRand;
	int m_iWorseRankDifferenceAttitudeChange;
	int m_iBetterRankDifferenceAttitudeChange;
	int m_iCloseBordersAttitudeChange;
	int m_iLostWarAttitudeChange;
	int m_iAtWarAttitudeDivisor;
	int m_iAtWarAttitudeChangeLimit;
	int m_iAtPeaceAttitudeDivisor;
	int m_iAtPeaceAttitudeChangeLimit;
	int m_iSameReligionAttitudeChange;
	int m_iSameReligionAttitudeDivisor;
	int m_iSameReligionAttitudeChangeLimit;
	int m_iDifferentReligionAttitudeChange;
	int m_iDifferentReligionAttitudeDivisor;
	int m_iDifferentReligionAttitudeChangeLimit;
	int m_iBonusTradeAttitudeDivisor;
	int m_iBonusTradeAttitudeChangeLimit;
	int m_iOpenBordersAttitudeDivisor;
	int m_iOpenBordersAttitudeChangeLimit;
	int m_iDefensivePactAttitudeDivisor;
	int m_iDefensivePactAttitudeChangeLimit;
	int m_iShareWarAttitudeChange;
	int m_iShareWarAttitudeDivisor;
	int m_iShareWarAttitudeChangeLimit;
	int m_iFavoriteCivicAttitudeChange;
	int m_iFavoriteCivicAttitudeDivisor;
	int m_iFavoriteCivicAttitudeChangeLimit;
	int m_iDemandTributeAttitudeThreshold;
	int m_iNoGiveHelpAttitudeThreshold;
	int m_iTechRefuseAttitudeThreshold;
	int m_iStrategicBonusRefuseAttitudeThreshold;
	int m_iHappinessBonusRefuseAttitudeThreshold;
	int m_iHealthBonusRefuseAttitudeThreshold;
	int m_iMapRefuseAttitudeThreshold;
	int m_iDeclareWarRefuseAttitudeThreshold;
	int m_iDeclareWarThemRefuseAttitudeThreshold;
	int m_iStopTradingRefuseAttitudeThreshold;
	int m_iStopTradingThemRefuseAttitudeThreshold;
	int m_iAdoptCivicRefuseAttitudeThreshold;
	int m_iConvertReligionRefuseAttitudeThreshold;
	int m_iOpenBordersRefuseAttitudeThreshold;
	int m_iDefensivePactRefuseAttitudeThreshold;
	int m_iPermanentAllianceRefuseAttitudeThreshold;
	int m_iVassalRefuseAttitudeThreshold;
	int m_iVassalPowerModifier;
	int m_iFavoriteCivic;

	CvString m_szArtDefineTag;

	// Arrays

	bool* m_pbTraits;

	int* m_piFlavorValue;
	int* m_piContactRand;
	int* m_piContactDelay;
	int* m_piMemoryDecayRand;
	int* m_piMemoryAttitudePercent;
	int* m_piNoWarAttitudeProb;
	int* m_piUnitAIWeightModifier;
	int* m_piImprovementWeightModifier;
	int* m_piDiploPeaceIntroMusicScriptIds;
	int* m_piDiploPeaceMusicScriptIds;
	int* m_piDiploWarIntroMusicScriptIds;
	int* m_piDiploWarMusicScriptIds;

};
...and CvInfos.cpp gets the following...
Code:
//======================================================================================================
//					CvLeaderHeadInfo
//======================================================================================================

//------------------------------------------------------------------------------------------------------
//
//  FUNCTION:   CvLeaderHeadInfo()
//
//  PURPOSE :   Default constructor
//
//------------------------------------------------------------------------------------------------------
CvLeaderHeadInfo::CvLeaderHeadInfo() :
m_iWonderConstructRand(0),
m_iBaseAttitude(0),
m_iBasePeaceWeight(0),
m_iPeaceWeightRand(0),
m_iWarmongerRespect(0),
m_iRefuseToTalkWarThreshold(0),
m_iNoTechTradeThreshold(0),
m_iTechTradeKnownPercent(0),
m_iMaxGoldTradePercent(0),
m_iMaxGoldPerTurnTradePercent(0),
m_iMaxWarRand(0),
m_iMaxWarNearbyPowerRatio(0),
m_iMaxWarDistantPowerRatio(0),
m_iMaxWarMinAdjacentLandPercent(0),
m_iLimitedWarRand(0),
m_iLimitedWarPowerRatio(0),
m_iDogpileWarRand(0),
m_iMakePeaceRand(0),
m_iDeclareWarTradeRand(0),
m_iDemandRebukedSneakProb(0),
m_iDemandRebukedWarProb(0),
m_iRazeCityProb(0),
m_iBuildUnitProb(0),
m_iBaseAttackOddsChange(0),
m_iAttackOddsChangeRand(0),
m_iWorseRankDifferenceAttitudeChange(0),
m_iBetterRankDifferenceAttitudeChange(0),
m_iCloseBordersAttitudeChange(0),
m_iLostWarAttitudeChange(0),
m_iAtWarAttitudeDivisor(0),
m_iAtWarAttitudeChangeLimit(0),
m_iAtPeaceAttitudeDivisor(0),
m_iAtPeaceAttitudeChangeLimit(0),
m_iSameReligionAttitudeChange(0),
m_iSameReligionAttitudeDivisor(0),
m_iSameReligionAttitudeChangeLimit(0),
m_iDifferentReligionAttitudeChange(0),
m_iDifferentReligionAttitudeDivisor(0),
m_iDifferentReligionAttitudeChangeLimit(0),
m_iBonusTradeAttitudeDivisor(0),
m_iBonusTradeAttitudeChangeLimit(0),
m_iOpenBordersAttitudeDivisor(0),
m_iOpenBordersAttitudeChangeLimit(0),
m_iDefensivePactAttitudeDivisor(0),
m_iDefensivePactAttitudeChangeLimit(0),
m_iShareWarAttitudeChange(0),
m_iShareWarAttitudeDivisor(0),
m_iShareWarAttitudeChangeLimit(0),
m_iFavoriteCivicAttitudeChange(0),
m_iFavoriteCivicAttitudeDivisor(0),
m_iFavoriteCivicAttitudeChangeLimit(0),
m_iDemandTributeAttitudeThreshold(NO_ATTITUDE),
m_iNoGiveHelpAttitudeThreshold(NO_ATTITUDE),
m_iTechRefuseAttitudeThreshold(NO_ATTITUDE),
m_iStrategicBonusRefuseAttitudeThreshold(NO_ATTITUDE),
m_iHappinessBonusRefuseAttitudeThreshold(NO_ATTITUDE),
m_iHealthBonusRefuseAttitudeThreshold(NO_ATTITUDE),
m_iMapRefuseAttitudeThreshold(NO_ATTITUDE),
m_iDeclareWarRefuseAttitudeThreshold(NO_ATTITUDE),
m_iDeclareWarThemRefuseAttitudeThreshold(NO_ATTITUDE),
m_iStopTradingRefuseAttitudeThreshold(NO_ATTITUDE),
m_iStopTradingThemRefuseAttitudeThreshold(NO_ATTITUDE),
m_iAdoptCivicRefuseAttitudeThreshold(NO_ATTITUDE),
m_iConvertReligionRefuseAttitudeThreshold(NO_ATTITUDE),
m_iOpenBordersRefuseAttitudeThreshold(NO_ATTITUDE),
m_iDefensivePactRefuseAttitudeThreshold(NO_ATTITUDE),
m_iPermanentAllianceRefuseAttitudeThreshold(NO_ATTITUDE),
m_iVassalRefuseAttitudeThreshold(NO_ATTITUDE),
m_iVassalPowerModifier(0),
m_iFavoriteCivic(NO_CIVIC),
m_pbTraits(NULL),
m_piFlavorValue(NULL),
m_piContactRand(NULL),
m_piContactDelay(NULL),
m_piMemoryDecayRand(NULL),
m_piMemoryAttitudePercent(NULL),
m_piNoWarAttitudeProb(NULL),
m_piUnitAIWeightModifier(NULL),
m_piImprovementWeightModifier(NULL),
m_piDiploPeaceIntroMusicScriptIds(NULL),
m_piDiploPeaceMusicScriptIds(NULL),
m_piDiploWarIntroMusicScriptIds(NULL),
m_piDiploWarMusicScriptIds(NULL),
[B][I][U]m_iFaction(-1)							//Faction Mod by TRN2 & Impaler[/U][/I][/B]{
}
... go down a bit futher and add the getFaction function...
Code:
void CvLeaderHeadInfo::setArtDefineTag(const TCHAR* szVal)
{
	m_szArtDefineTag = szVal;
}

[B][I][U]int CvLeaderHeadInfo::getFaction() const					//Faction Mod by TRN2 & Impaler
{
	return m_iFaction;
}[/U][/I][/B]
// Arrays

bool CvLeaderHeadInfo::hasTrait(int i) const
{
	FAssertMsg(i < GC.getNumTraitInfos(), "Index out of bounds");
	FAssertMsg(i > -1, "Index out of bounds");
	return m_pbTraits ? m_pbTraits[i] : false;
}

int CvLeaderHeadInfo::getFlavorValue(int i) const
{
	FAssertMsg(i < GC.getNumFlavorTypes(), "Index out of bounds");
	FAssertMsg(i > -1, "Index out of bounds");
	return m_piFlavorValue ? m_piFlavorValue[i] : -1;
}
At the top of the cache read function I have added one line also...
Code:
void CvLeaderHeadInfo::read(FDataStreamBase* stream)
{
	CvInfoBase::read(stream);

	uint uiFlag=0;
	stream->Read(&uiFlag);		// flag for expansion

[B][I][U]	stream->Read(&m_iFaction);					//Faction Mod by TRN2 & Impaler[/U][/I][/B]	stream->Read(&m_iWonderConstructRand);
	stream->Read(&m_iBaseAttitude);
	stream->Read(&m_iBasePeaceWeight);
	stream->Read(&m_iPeaceWeightRand);
	stream->Read(&m_iWarmongerRespect);
	stream->Read(&m_iRefuseToTalkWarThreshold);
	stream->Read(&m_iNoTechTradeThreshold);
Same in the cache read...
Code:
void CvLeaderHeadInfo::write(FDataStreamBase* stream)
{
	CvInfoBase::write(stream);

	uint uiFlag=0;
	stream->Write(uiFlag);		// flag for expansion

[B][I][U]	stream->Write(m_iFaction);  //Faction Mod by TRN2 & Impaler[/U][/I][/B]	stream->Write(m_iWonderConstructRand);
	stream->Write(m_iBaseAttitude);
	stream->Write(m_iBasePeaceWeight);
	stream->Write(m_iPeaceWeightRand);
	stream->Write(m_iWarmongerRespect);
	stream->Write(m_iRefuseToTalkWarThreshold);
and the last edit goes in the XML read function a bit futher down...
Code:
bool CvLeaderHeadInfo::read(CvXMLLoadUtility* pXML)
{
	CvString szTextVal;
	if (!CvInfoBase::read(pXML))
	{
		return false;
	}

	pXML->GetChildXmlValByName(szTextVal, "ArtDefineTag");
	setArtDefineTag(szTextVal);

	pXML->GetChildXmlValByName(&m_iFaction,"iFaction");		//Faction Mod by TRN2 & Impaler
	pXML->GetChildXmlValByName(&m_iWonderConstructRand, "iWonderConstructRand");
	pXML->GetChildXmlValByName(&m_iBaseAttitude, "iBaseAttitude");
	pXML->GetChildXmlValByName(&m_iBasePeaceWeight, "iBasePeaceWeight");
	pXML->GetChildXmlValByName(&m_iPeaceWeightRand, "iPeaceWeightRand");
	pXML->GetChildXmlValByName(&m_iWarmongerRespect, "iWarmongerRespect");
	pXML->GetChildXmlValByName(&m_iRefuseToTalkWarThreshold, "iRefuseToTalkWarThreshold");
	pXML->GetChildXmlValByName(&m_iNoTechTradeThreshold, "iNoTechTradeThreshold");
	pXML->GetChildXmlValByName(&m_iTechTradeKnownPercent, "iTechTradeKnownPercent");
	pXML->GetChildXmlValByName(&m_iMaxGoldTradePercent, "iMaxGoldTradePercent");
Almost forgot to tell you that you will also need to edit the Schema for the Leaderheads, this is found in Assets\XML\Civilizations\CIV4CivilizationsSchema.xml about mid way through the file add the following 2 lines...
Code:
	<ElementType name="DiplomacyMusicWar" content="eltOnly">
		<element type="DiploMusicWarEra" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="DiplomacyIntroMusicWar" content="eltOnly">
		<element type="DiploMusicWarEra" minOccurs="0" maxOccurs="*"/>
	</ElementType>
[B][I][U]	<ElementType name="iFaction" content="textOnly" dt:type="int"/>	[/U][/I][/B]	<ElementType name="LeaderHeadInfo" content="eltOnly">
		<element type="Type"/>
		<element type="Description"/>
		<element type="Civilopedia"/>
		<element type="ArtDefineTag"/>
[B][I][U]		<element type="iFaction" minOccurs="0"/>[/U][/I][/B]
		<element type="iWonderConstructRand"/>
		<element type="iBaseAttitude"/>
		<element type="iBasePeaceWeight"/>
		<element type="iPeaceWeightRand"/>
		<element type="iWarmongerRespect"/>
		<element type="iRefuseToTalkWarThreshold"/>
		<element type="iNoTechTradeThreshold"/>

This should now add the ability to assign a custom faction to each of the leaders in the CIV4LeaderHeadInfos.xml file.
 
Reserved for Part 3: The Python
Since I am still a Civ IV nublette - I was wondering - could I get directions to where the victory conditions are calculated in the game, I have tried using windows search feature, and I think the files are encoded diffferently or something - cause it don't work, and eclipse - which is what I am using to edit my Python files won't search all files - this is drastically slowing me down trying to find where to hook my new victory condition code :(
 
WOW! I can't believe you did all this stuff! I hope my little scenario will be worth all the work you're putting into this.

Since you're doing so much, I'll let you know exactly what it is you're building:

My scenario is called "Aurelia." It is set in an imaginary world that is ringed by mountains, with an inland sea in the middle. At the center of the sea is the island nation of Aurelia, which was the cradle of civilization. Over the years, settlers migrated to the lands beyond the sea and new civilizations were formed. One of these civilizations, Baltharia, was home to a great wizard who created a staff with the power to radically transorm the planet's landscape. With a wave of the staff, mountains would rise or seas would form. The landlocked, mountain-dwelling Baltharians used this awesome power to create channels to the inland sea. Having no experience with naval combat, the Baltharians then created a massive nautical maze of impassable mountains that jutted above the sea to protect their new harbors.

Word of this amazing staff spread throughout the world, and the Baltharians made a thriving business of shaping the lands of distant civilizations. Over time, much of the world became a nearly impassable maze of mountains, with civilizations constantly adding to their rocky defenses. Some of these civilizations were eventually so cut off from the world that they became paranoid about their neighbors' intentions.

Gradually, their paranoia drove them mad and they became bent on controlling the entire world. They formed an evil alliance and mounted an attack on the unsuspecting civilization of Baltharia. Their plan was to seize the wizard and his magical staff, then use its power to destroy any foe that stood in their way.

As their armies approached, the wizard had no doubt of their intentions. No matter how many mountains he conjured, he knew that their massive armies would eventually prevail. He could think of only one way to save his beloved Baltharia.

With his staff in one hand and his sword in the other, he set out to face the raging horde. When he reached their camp, he held the staff above his head and called out to Calixius, the leader of the evil alliance. Just as Calixius emerged from his camp, and the wizard was certain he was watching, he snapped the magical staff in two and threw the useless pieces of wood to the ground.

"Seize him!" Calixius barked to his soldiers.

The wizard knew that if he was captured, the enemy would find a way to force him to make another staff. Without a moment's hesitation, he drew his sword and thrust it into his own chest.

Without the lure of the staff, the alliance called off the attack on Baltharia, but the news of their aborted plan soon reached the palace of Aurelia, now ruled by the young king, Aurelius. He called on his closest allies and formed a pact to protect civilization from this new, terrible threat.

And this is where the game begins. There are 17 civilations to choose from: 3 evil, 3 good, and 10 that are somewhere in the middle. The goal of the game is for good or evil to triumph - one can play either side they choose. There are more Civs that are diplomatically inclined to side with the good guys, but this is because beating the bad guys will be nearly impossible without a lot of help. The evil alliance's cities are protected by long, winding mazes of mountains, each with different challenges. Playing the maze cities should be a lot of fun, too, since there are so many ways to set up your defenses, with lots of places to hide an army that would be outside the opponents' field of view.

Anyway, that's the scenario. It would be really good if there were a way to force Civs to eventually choose one of the two alliances. Otherwise, they would be technologically left in the dust competing against two teams of three.

Any ideas, suggestions or further help would be greatly appreciated. :)
 
I would also suggest that you look at Kael's Thread on http://forums.civfanatics.com/showthread.php?t=166935, it doesn't contain victory conditions, but with his permission, I might incorporate that, and touch up a few ideas of my own on factions, and make a proper mod out of this, since there seems to be a fair amount of interest for it.
 
I am assuming two things here, that you have warlords, and that you have an IMB Version, or that Mac Version is the same as IBM version in reguards to Python...

Yes, I have Warlords, but I am on a Mac. I would assume that since the Mac version comes with all the modding tools and the ability to load mods that it would play well with PC mods - but I could be wrong.

Thanks again for all that you've done - this is way, way more than I was expecting when I started this thread.
 
I would just add a python check that would look for the presense of your good and bad guys each turn and run the following if you want to award victory to either side:

Code:
	gc.getGame().setWinner(iPlayer, CvUtil.findInfoTypeNum(gc.getHandicapInfo,gc.getNumHandicapInfos(),"VICTORY_CONQUEST"))

As for the attitude stuff, you can use the code posted in the other thread or you could just push all good civs onto the same team and all evil civs onto the same team. Essentially isnt that how you would want the Ai to act?
 
tbh- I hadn't made it that far, I was going to do this code (simply because I have had a few people already comment on it) to do factions, this way you could have good and evil, or good, evil and nuetral, or a slew of different factions, that I was then going to push into teams, I do see what you are saying though, that I could eliminate the CIV4VictoryInfos.XML, but it was included for the learning process, and also because I wanted the extra flag on the game options screen so that the mod could be disabled in the case of the player not wanting to use it.
One quick last question...

Code:
	gc.getGame().setWinner(iPlayer, CvUtil.findInfoTypeNum(gc.getHandicapInfo,gc.getNumHandicapInfos(),"VICTORY_CONQUEST"))

I looked through heaps of Python earlier tonight, I am not certain which file to add the code to, I would need a file that is called every turn, and I was not convinved that I found one :( also it is 6AM atm and I am off to bed - nite
 
As for the attitude stuff, you can use the code posted in the other thread or you could just push all good civs onto the same team and all evil civs onto the same team. Essentially isnt that how you would want the Ai to act?

I thought about just lumping the civs who are inclined to be good into the good guys' team, and doing the same for the bad - it would certainly be easy to do - I wouldn't even need a special victory condition.

Ultimately, though, I decided against it because I thought it would be more fun to have a handful of "fence-sitters." These would be civs with no strong ties to either side that have slightly better than average relations with civs on both sides of the aisle. If the scenario forced them to eventually choose a side, it would add a diplomatic challenge to what would otherwise be a routine conquest victory.

On a side note, I've never had more than one Permanent Alliance in an unmodified single player game. I almost always play with that option off.

Will the AI join a permanent alliance that already exists between two or more civs?

If so, what variables does it use to make the decision? Is it merely the attitude toward the civ that asks them to join, or does it include the attitude toward all members of the alliance?

What Leaderhead variables would I need to alter to virtually guarantee that they'll eventually join an alliance (without making their allegiance too easy to get)?
 
tbh- I hadn't made it that far, I was going to do this code (simply because I have had a few people already comment on it) to do factions, this way you could have good and evil, or good, evil and nuetral, or a slew of different factions, that I was then going to push into teams, I do see what you are saying though, that I could eliminate the CIV4VictoryInfos.XML, but it was included for the learning process, and also because I wanted the extra flag on the game options screen so that the mod could be disabled in the case of the player not wanting to use it.
One quick last question...

I looked through heaps of Python earlier tonight, I am not certain which file to add the code to, I would need a file that is called every turn, and I was not convinved that I found one :( also it is 6AM atm and I am off to bed - nite

CvEventManager.py has a onBeginGameTurn() furnction.

But if you could also put the check in the onSetPlayerAlive() function in the same file. That way you check for the victory condition each time a civ dies.
 
ty so much - I am looking forward to knowing these *.py, *.cpp and *.h files much better over the next few weeks/months ;)

Will the AI join a permanent alliance that already exists between two or more civs?

By Permanent Alliance I am assuming you mean the Permanent Alliance in Civ IV and by Already Exists I am guessing you mean the teams that you have chosen, but since I am still a Civ IV noob I really can't answer this question, my guess is that they would, unless there has been put in place a redundancy check in the code somewhere.

would be more fun to have a handful of "fence-sitters."
this was also the impression I got from a few people that they were seeking such a mod
what variables does it use to make the decision?
I'm not sure of all of them but there are a few obvious ones in the leaderheads file.
These would be civs with no strong ties to either side that have slightly better than average relations with civs on both sides of the aisle.
I oculd possibly swing this mod a bit differently, but I will need to think about how to implement this idea, and if it is not already to some point done with the WorldBuilder Tool in the diplomacy section - I am assuming though you would want this to be in your mod, and not in a mere map, else you could generate the map, go to the world-builder and then just alter the diplomacy

EDIT:Why am I so unsleepy:(
 
I thought about just lumping the civs who are inclined to be good into the good guys' team, and doing the same for the bad - it would certainly be easy to do - I wouldn't even need a special victory condition.

Ultimately, though, I decided against it because I thought it would be more fun to have a handful of "fence-sitters." These would be civs with no strong ties to either side that have slightly better than average relations with civs on both sides of the aisle. If the scenario forced them to eventually choose a side, it would add a diplomatic challenge to what would otherwise be a routine conquest victory.

On a side note, I've never had more than one Permanent Alliance in an unmodified single player game. I almost always play with that option off.

Will the AI join a permanent alliance that already exists between two or more civs?

If so, what variables does it use to make the decision? Is it merely the attitude toward the civ that asks them to join, or does it include the attitude toward all members of the alliance?

What Leaderhead variables would I need to alter to virtually guarantee that they'll eventually join an alliance (without making their allegiance too easy to get)?

No, i believe permanent alliances implies that others cant join them.

I like your idea for having middle neutral civs. I would probably recommend a python script that checks the attitude of the neutral players each turn and pushed them to either of the two teams if their attitude is high enough (and removes them if it goes down).

I guess the big question is, what is it that you want to decide if the neutral civs join a team or not? Attitude is good, you may want to consider other aspects. Maybe 2 neutral civs hate each other so you can only ever get one of them. Maybe one civ requires some payment for its service? Maybe a civ will join anyone who performs a task for them?

Have fun with it.
 
I guess the big question is, what is it that you want to decide if the neutral civs join a team or not? Attitude is good, you may want to consider other aspects. Maybe 2 neutral civs hate each other so you can only ever get one of them. Maybe one civ requires some payment for its service? Maybe a civ will join anyone who performs a task for them?

Have fun with it.

That's a really great idea. I didn't know you could get that detailed. Each of my leaders has a "character." It would be great if I could create a list of things that would win each of them over (based on their character), but the game would randomly choose which one was active at the start of the scenario. That way, you wouldn't necessarily know how to win them, which would keep it from being so easy.

I also like the idea that if you don't keep them happy, they'll switch sides.
 
I am still stuck on the second part of my code, I've been pulling out hair, chewing my toe-nails, etc.. but to no avail, if someone could go over the third reply to this and find the bug I would be grateful, I got a hunch that I've left something out.
And if it is not that, then
Code:
 	pXML->GetChildXmlValByName(&m_iFaction, "iFaction");
I am still getting used to C++ Syntax, and am not sure exactly what I am doing here - is this the correct way to read an Int from the XML file??
 
Kael, your suggestion has really added a new dimension to the game. I like it a lot.

I'm going to brainstorm my ideas for the "fence-sitter" civs here in case anybody has other brilliant ideas. :)

The Fence-Sitter Civs:

Spoiler :
Philomena:

Description: She's out to win and doesn't mind playing dirty. She has no favorites and will side with whomever gives her the advantage.

Alliance Requirement: Perhaps she will simply side with whichever team captures the first city. If the other team gets a net gain of 5 cities, she'll switch as soon as peace is declared.

Lazario:

Description: He's a bit of an isolationist and is wary of other civs, but if you can win his trust, he's a loyal ally.

Alliance Requirement: Maybe he stays neutral until someone declares war on him or someone he has a Friendly attitude toward.

Drago:

Description: He loves nothing more than money and luxuries. He's a bit of a sleazebag and cannot be trusted. His Civ is the smallest in the game (he gets only 3 cities) but he is only accessible by sea and his land is completely covered with bonuses. This makes his land a very attractive target, and he knows it.

Alliance Requirement: Once he has a certain number of trade deals (a pretty high number), he'll side with whichever team he has the most deals with. If the trade situation changes by a specified target (other team has +3 more trades than existing team), he'll switch sides. Also, if he loses a city, he will switch as soon as peace is declared.

Musa:

Description: He is very friendly and will always seek a partner in trade or try to spread his favorite civic. He is also quite religious.

Alliance Requirement: Maybe he allies against the first team to declare war on a civ that has either his religion or his favorite civic.


I may make a couple other Civs into fence-sitters, but these are definites. If you have any suggestions, please share them. Thanks again for all the help and great ideas.
 
You should really wrap all that in a spoiler tag ;)
 
Another little twist:
Spoiler :

One of the evil allies is a witch named Ursula. Her capital city is the Holy City for the religion of Sorcery. Maybe if any Civ has Sorcery as their state religion for more than a certain number of turns, they become brainwashed and switch permanently to the evil side. This way, you'd have to manage all of your allies' religion levels to protect against the threat, which might be a tall order in the early game.
 
From another thread re: Mac Compatibility:

It does look to me that the changes that are going on in that thread are not going to work on a mac. You can change the .py files since those are python, but the .cpp files get compiled using the SDK and make a custom .dll file which is useless on a mac.

Can the things we're talking about be done with just Python and xml?
 
From another thread re: Mac Compatibility:

Can the things we're talking about be done with just Python and xml?

The stuff I recommended is all python, should work on both macs and pcs.
 
Back
Top Bottom