Mario W
Chieftain
- Joined
- Mar 28, 2024
- Messages
- 41
What does this method do?
CyPlayer().countCityFeatures (FeatureType eFeature)
CyPlayer().countCityFeatures (FeatureType eFeature)
def doCityCaptureGold(self, argsList):
"controls the gold result of capturing a city"
pOldCity = argsList[0]
iCaptureGold = 0
iPlayer = gc.getGame().getActivePlayer()
pPlayer = gc.getPlayer(iPlayer)
if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_PETRA")) == 1:
return 9999
HideMinSpecWarning = 1
in My Games\Beyond the Sword\CivilizationIV.ini
. I've never had that problem myself, but I've read that Civ will automatically lower the player's graphical settings when displaying that warning; so you may want to also check the options menu and restore your settings if necessary.Hmm, that's true. And you can't just return 0 and call CyPlayer.changeGold yourself later in cityAcquired because the DLL will show the amount returned by doCityCaptureGold in a popup. Also, by the time cityAcquired gets called, the population decrease from conquest will already have been applied, and the (BtS) capture gold formula is supposed to be based on the population prior to conquest. I guess the extra gold from the new owner's special ability could be treated as a separate source of income, i.e. you could add another e.g. 200 gold and tell the players about it in a separate on-screen message. If the extra gold is supposed to be based on the original capture gold, then you could store that amount in some global variable when doCityCaptureGold gets called and access it in cityAcquired.p.s. The new owner of the city and even the movement of the unit occurs AFTER the calculation of the gold received.
pOldPlot = plot();
if (pOldPlot != NULL)
{
// Unit removed from old plot
pOldPlot->removeUnit(this, bUpdate && !hasCargo());
[... a lot of cache updates concerning the old position of the unit ...]
// Unit's coordinates get set to the new plot
if (pNewPlot != NULL)
{
m_iX = pNewPlot->getX_INLINE();
m_iY = pNewPlot->getY_INLINE();
}
// [...]
if (pNewPlot != NULL)
{
pNewCity = pNewPlot->getPlotCity();
if (pNewCity != NULL)
{
if (isEnemy(pNewCity->getTeam()) && !canCoexistWithEnemyUnit(pNewCity->getTeam()) && canFight())
{
// Handle city conquest: effect on war weariness
GET_TEAM(getTeam()).changeWarWeariness(pNewCity->getTeam(), *pNewPlot, GC.getDefineINT("WW_CAPTURED_CITY"));
GET_TEAM(getTeam()).AI_changeWarSuccess(pNewCity->getTeam(), GC.getDefineINT("WAR_SUCCESS_CITY_CAPTURING"));
// Further complication: The owner of the unit does not always
// become the conquering player. If a vassal of the unit owner
// has previously owned the city, then that vassal may become
// the conquering player.
PlayerTypes eNewOwner = GET_PLAYER(getOwnerINLINE()).pickConqueredCityOwner(*pNewCity);
if (NO_PLAYER != eNewOwner)
{
// acquireCity gets called, which will call doCityCaptureGold.
GET_PLAYER(eNewOwner).acquireCity(pNewCity, true, false, true); // will delete the pointer
pNewCity = NULL;
}
}
}
// [...]
// Unit gets placed in its new plot
pNewPlot->addUnit(this, bUpdate && !hasCargo());
[...]
// Python learns about the unit move
CvEventReporter::getInstance().unitSetXY(pNewPlot, this);
at
function only checks the unit's coordinates:bool CvUnit::at(int iX, int iY) const
{
return((getX_INLINE() == iX) && (getY_INLINE() == iY));
}
PlayerTypes CvPlayer::pickConqueredCityOwner(const CvCity& kCity) const
{
PlayerTypes eBestPlayer = kCity.getLiberationPlayer(true);
if (NO_PLAYER != eBestPlayer)
{
if (GET_TEAM(getTeam()).isVassal(GET_PLAYER(eBestPlayer).getTeam()))
{
return eBestPlayer;
}
}
return getID();
}
iMostRecentCaptureGold = -1
near the top of that file and then refer to that variable as CvUtil.iMostRecentCaptureGold in the event handler functions. To write to the variable, it may have to be declared as "global" beforehand, e.g.
global CvUtil.iMostRecentCaptureGold
CvUtil.iMostRecentCaptureGold = iCaptureGold
def getDiplomacyComment (self, eComment):
"Function to get the user String"
debugString = "CvDiplomacy.getDiplomacyComment: %s" %(eComment,)
eComment = int(eComment)
if DebugLogging:
print debugString, eComment
szString = ""
szFailString = "Error***: No string found for eComment: %s"
if ( gc.getDiplomacyInfo(eComment) ):
DiplomacyTextInfo = gc.getDiplomacyInfo(eComment)
if ( not DiplomacyTextInfo ):
print "%s IS AN INVALID DIPLOCOMMENT" %(eComment,)
CvUtil.pyAssert(True, "CvDiplomacy.getDiplomacyComment: %s does not have a DiplomacyTextInfo" %(eComment,))
return szFailString %(eComment,)
szString = self.filterUserResponse(DiplomacyTextInfo)
if ( gc.getDiplomacyInfo(eComment) ):
eComment
is valid. So that would seem like an issue with the BtS error handling. But the bigger problem, likely caused by your mod, is that eComment does apparently not correspond to a CvDiplomacyInfo object in the DLL. Maybe an addition to XML\GameInfo\Civ4DiplomacyInfos.xml is needed. To narrow the problem down, I would suggest temporarily setting DebugLogging = True
at the start of CvDiplomacy.py and consulting PythonDbg.log (with LoggingEnabled=1 in CivilizationIV.ini) for the last CvDiplomacy.getDiplomacyComment
message before the crash. Replacing if ( gc.getDiplomacyInfo(eComment) ):
with
if eComment >= gc.getNumDiplomacyInfos() or eComment < 0:
if not (eComment...)