Aussie_Lurker
Deity
I think I know where I went wrong. I went straight in and modified the GameCore, wheras-judging from your Tutorial-I should have added the new attributes to the XML file first.
Aussie_Lurker.
Aussie_Lurker.
Raumohir said:Sorry if this is a stupid question or if it doesn't really belong in this thread. Can we read in new XML values through Python too or do we have to go through the SDK? If we can do it in Python, do we use DOM or SAX (which I've heard of but don't know much about), or is there something better already set up for us?
Thanks a lot for any help you can provide.
python::class_<CvCivilizationInfo, python::bases<CvInfoBase> >("CvCivilizationInfo")
.def("getDefaultPlayerColor", &CvCivilizationInfo::getDefaultPlayerColor, "int ()")
.def("getArtStyleType", &CvCivilizationInfo::getArtStyleType, "int ()")
.def("getNumCityNames", &CvCivilizationInfo::getNumCityNames, "int ()")
.def("getNumLeaders", &CvCivilizationInfo::getNumLeaders, "int ()")
gc.getCivilizationInfo(iNum).getNumLeaders()
gc.getCivilizationInfo(iNum).yourFunctionHere()
<UnitClassUpgrades>
<UnitClassUpgrade>
<UnitClassUpgradeType>UNITCLASS_KNIGHT</UnitClassUpgradeType>
<bUnitClassUpgrade>1</bUnitClassUpgrade>
</UnitClassUpgrade>
</UnitClassUpgrades>
int CvPlayerAI::AI_getHighCompassionAttitude(PlayerTypes ePlayer)
{
int iAttitude;
iAttitude = 0;
if (GET_PLAYER(ePlayer).getCivics((CivicOptionTypes)GC.getInfoTypeForString("CIVICOPTION_COMPASSION")) == (CivicOptionTypes)GC.getInfoTypeForString("CIVIC_PUBLIC_HEALERS") ||
GET_PLAYER(ePlayer).getCivics((CivicOptionTypes)GC.getInfoTypeForString("CIVICOPTION_COMPASSION")) == (CivicOptionTypes)GC.getInfoTypeForString("CIVIC_PROTECT_THE_MEET"))
{
iAttitude += GC.getLeaderHeadInfo(getPersonalityType()).getHighCompassionAttitudeChange();
}
return iAttitude;
}
int CvPlayerAI::AI_get[b]Peacekeeping[/b]Attitude(PlayerTypes ePlayer)
{
int iAttitude;
iAttitude = 0;
if (GET_PLAYER(ePlayer).getCivics((CivicOptionTypes)GC.getInfoTypeForString("CIVICOPTION_[b]WARFARE[/b]")) == (CivicOptionTypes)GC.getInfoTypeForString("CIVIC_[b]PEACEKEEPING[/b]") ||
GET_PLAYER(ePlayer).getCivics((CivicOptionTypes)GC.getInfoTypeForString("CIVICOPTION_[b]WARFARE[/b]")) == (CivicOptionTypes)GC.getInfoTypeForString("CIVIC_[b]PEACKEEPING[/b]"))
{
iAttitude += GC.getLeaderHeadInfo(getPersonalityType()).getHighCompassionAttitudeChange();
}
return iAttitude;
}
zulu9812 said:Kael, thanks for the wonderful tutorial. I was able to follow it and successfully add a function that gave the player a diplomatic bonus when using the Peacekeeping civic (see this thread). However, I am getting the bonus twice: the left-hand side of the diplpmacy screen (where it lsits bonuses and penalties) shows "+4 You help with peacekeeping operations" AND "+1 you help with peacekeeping operations", where I only wanted the +4 bonus.
I suspect that this is because of this peace of code:
int CvPlayerAI::AI_get[b]Peacekeeping[/b]Attitude(PlayerTypes ePlayer)
{
int iAttitude;
iAttitude = 0;
if (GET_PLAYER(ePlayer).getCivics((CivicOptionTypes)GC.getInfoTypeForString("CIVICOPTION_[b]WARFARE[/b]")) == (CivicOptionTypes)GC.getInfoTypeForString("CIVIC_[b]PEACEKEEPING[/b]"))
{
iAttitude += GC.getLeaderHeadInfo(getPersonalityType()).getHighCompassionAttitudeChange();
}
return iAttitude;
}
Lord Olleus said:How do you add multiple lines tag in XML. By that I mean something like:
Code:<UnitClassUpgrades> <UnitClassUpgrade> <UnitClassUpgradeType>UNITCLASS_KNIGHT</UnitClassUpgradeType> <bUnitClassUpgrade>1</bUnitClassUpgrade> </UnitClassUpgrade> </UnitClassUpgrades>
pXML->SetVariableListTagPair(&m_pbUpgradeUnitClass, "UnitClassUpgrades", GC.getUnitClassInfo(), sizeof(GC.getUnitClassInfo((UnitClassTypes)0)), GC.getNumUnitClassInfos());
Impaler[WrG] said:90% of what you might want to do can be stolen from existing code with a copy/paste and change of variable names.
Be aware that the order inwhich files are loaded on the XMLloadutility.cpp will put limits on what can reference what, for example Techs cant referance many things because their loaded very early.
Its possible to create new and unusual nested elements that have no equivilent to copy from but you have to have a good understanding of how the XML read functions and XML tree navigation functions work. I managed to create a triple nesteded element containing 2 building references at the bottom for a building modifying mod and though it was tricky I did get it working. (unfortunatly I abandoned that mod for an even more ambitious version, darn feature creep )
I'm next going to try to create a whole new XML document and see if I can get it loaded.
Kael said:But I dont think that is your problem. Can you attach your CvPlayerAI.cpp file?
Kael said:Your code looks right to me. From what you are describing the +1 isn't coming from your new attitude variable. Is it possible it is coming from the AI_getPeaceAttitude value?
Kael said:What is the TXT_KEY_MISC_ATTITUDE_PEACE set to in your mod?
int CvPlayerAI::AI_getPeacekeepingAttitude(PlayerTypes ePlayer)
{
int iAttitude;
iAttitude = 0;
if (GET_PLAYER(ePlayer).getCivics((CivicOptionTypes)GC.getInfoTypeForString("CIVICOPTION_WARFARE")) == (CivicOptionTypes)GC.getInfoTypeForString("CIVIC_PEACEKEEPING"))
{
iAttitude += GC.getLeaderHeadInfo(getPersonalityType()).getPeacekeepingAttitudeChange();
}
return iAttitude;
}
Kael said:I woudl still recommend cleaning up your AI_getPeacekeepingAttitude as follows:
zulu9812 said:Thanks for your help. I did that, but it made no difference. The "+1 You help with peacekeeping operations" only appears when I have the Peacekeeping civic enacted, which makes me think that it is an issue with the SDK code, rather than being related to the AI_getPeaceAttitude value
Kael said:Oh, does the other civ have it as his favorite civic?