Python API changes from v1.52 to v1.61

Locutus

King of the Collective
Joined
Oct 30, 2001
Messages
365
Location
Hengelo/Enschede, the Netherlands
For the Python coders, here's a list of changes to the Python API from v152 to v1.61 (many thanks to Solver; without his help this list would not have been possible):

In CvGameText:
- added int getNumLanguages()

In CvProjectInfo:
- added int getAnyoneProjectPrereq()

In CvTechInfo:
- added int getFeatureProductionModifier()

In CyCamera:
- added void ReleaseLockedCamera()

In CyCity:
- added void addProductionExperience(CyUnit, bool)
- modified bool canContinueProduction(Orderdata): added OrderData argument
- modified void chooseProduction(UnitType, BuildingType, ProjectType, bool, bool): added bool argument (bFront)
- added int conscriptMinCityPopulation()
- added int findPopulationRank()
- added int flatConscriptAngerLength()
- added ArtStyleType getArtStyleType()
- added CitySizeType getCitySizeType()
- added int getConscriptPopulation()
- added int getCurrAirlift()
- added int getDomainFreeExperience(Domaintype)
- added int getDomainProductionModifier(Domaintype)
- added int getExtraProductionDifference(int)
- added int getFeatureBadHappiness()
- added int getFeatureGoodHappiness()
- added int getFoodKept()
- added int getFreePromotionCount(PromotionType)
- added int getLargestHappiness()
- added int getMaxAirLift()
- added int getMaxFoodKeptPercent()
- added int getNumBuildings()
- added int getNumNationalWonders()
- added int getNumTeamWonders()
- added int getNumWorldWonders()
- modified int getProduction(): now returns int (was bool)
- added int getProductionExperience(UnitType)
- added CyPlot getRallyPlot()
- added int getTotalGreatPeopleRateModifier()
- added getUnitCombatFreeExperience(UnitCombatType)
- removed int getVisibleDefenseModifier()
- added bool isAirliftTargeted()
- bool isBuildingsMaxed()
- added bool isDrafted()
- added bool isEverOwned()
- added bool isFreePromotion(PromotionType)
- added bool isNationalWondersMaxed()
- added bool isProductionLimited()
- added bool isSpecialistForced()
- added bool isTeamWondersMaxed()
- added bool isWorldWondersMaxed()
- added void setAirliftTargeted(int)
- added void setBombarded(int)
- added void setDrafted(int)
- added void setFood(int)
- added void setNeverLost(int)

In CyGame:
- renamed bool GetWorldBuilderMode() from GetWorldBuilder2Mode()
- added int calculateOptionsChecksum()
- added bool canTrainNukes()
- added void cityPushOrder(CyCity, OrderType, int, bool, bool, bool)
- added int countHumanPlayersAlive()
- added int countHumanPlayersEverAlive()
- added int countTotalCivPower()
- added int countTotalNukeUnits()
- added void cycleCities(bool, bool)
- added bool cyclePlotUnits(CyPlot, bool, bool, int)
- added void cycleSelectionGroups(bool, bool, bool)
- added int getForceCivicCount(CivicType)
- added GameStateType getGameState()
- added int getImprovementUpgradeTime(ImprovementType)
- added int getNumDeals()
- added int getPitbossTurnTime()
- added int getPlayerVote(PlayerType)
- added int getProductionPerPopulation(HurryType)
- added int getProjectCreatedCount(ProjectType)
- added int getVoteOutcome(VoteType)
- added int goldenAgeLength()
- added bool hasSkippedSaveChecksum()
- added bool isForceCivic(CivicType)
- added bool isFOrceCivicOption(CivicOptionType)
- added bool isHotSeat()
- added bool isPbem()
- added bool isPitboss()
- added bool isProjectMaxedOut(ProjectType)
- added bool isSpecialBuildingValid(SpecialBuildingType)
- added bool isVoteTriggered(VoteType)
- added void makeSpecialBuildingValid(SpecialBuildingType)
- added void reviveActivePlayer()
- added void saveReplay(int)
- added void selectedCitiesGameNetMessage(int, int, int, int, bool, bool, bool, bool)
- added void selectionlistMove(CyPlot, bool, bool, bool)
- added void selectionlistMove(CyPlot, bool, bool, bool)

In Cyinterface:
- added void clearSelectionlist()
- added void insertintoSelectionlist(CyUnit, bool, bool, bool, bool)
- removed bool noMovies()
- added void removeFromSelectionUnit(CyUnit)
- removed void removeSelectedCity(CyCity)
- added int selectionHotKeyUnit(int)

In CyMap:
- added void resetPathDistance()

In CyMessageControl:
- removed void sendEmphasize(list, list, list, int)

In CyPlayer:
- added int calculateResearchModifier(TechType)
- modified void chooseTech(int, string, bool): added bool argument (bFront)
- added int getBuildingClassCountPlusMaking(BuildingClassType)
- added int getCapitalCommerceRateModifier(CommerceType)
- added int getFeatureHappiness(FeatureType)
- added int getFeatureProductionModifier()
- added int getGoldPerTurnByPlayer(PlayerType)
- added int getImprovementUpgradeRateModifier()
- added int getLargestCityHappiness()
- added int getMilitaryProductionModifier()
- added string getNewCityName()
- removed CivicType getNextCivics(CivicOptionType)
- added int getNumNukeUnits()
- added int getPersonalityType()
- added int getSingleCivicUpkeep(CivicType, bool)
- added int getSpecialBuildingNotRequiredCount(SpecialBuildingType)
- added int getStateReligionFreeExperience()
- added int getTotalLandScored()
- added int getUnitClassCountPlusMaking(UnitClassType)
- added int getWinsVsBarbs()
- added bool isCurrentResearchOption()
- added bool isExtendedGame()
- added bool isLateEra()
- added bool isNoForeignTrade()
- added bool isNonStateReligionSpread()
- added bool isNoResearchAvailable()
- added bool isSpecialBuildingNotRequired(SpecialBuildingType)
- added bool isSpecialistValid(SpecialistType)
- added void popResearch(TechType)
- added void setPersonalityType(LeaderHeadType)

In CyPlot:
- modified int calculateImprovementYieldChange(ImprovementType, YieldType, PlayerType, bool): PlayerType was TeamType
- added int calculateTeamCulturePercent(TeamType)
- added int calculateYield(YieldType, bool)
- added bool canHavePotentialIrrigation()
- added void changeForceUnownedTimer(int)
- added int changeImprovementDuration(int)
- added int changeOwnershipDuration(int)
- modified int defenseModifier(bool, bool): added bool argument (bHelp)
- added int getCityRadiusCOunt()
- added int getForceUnownedTimer()
- added int getImprovementDuration()
- added int getNonObsoleteBonusType(TeamType)
- added int getOwnershipDuration()
- added int getPlayerCityRadiusCount(PlayerType)
- added int getStolenVisibilityCount(TeamType)
- added int getUpgradeTimeLeft(ImprovementType, PlayerType
- added bool isActiveVisible(bool)
- added bool isBestAdjacentFound(PlayerType)
- added int isCityRadius()
- added bool isFlagDirty()
- added int isForceUnowned()
- added int isOwnershipScore()
- added bool isPlayerCityRadius(PlayerType)
- added bool isPotentialCityWork()
- added bool isRiverConnection(DirectionType)
- added bool isWithinteamCityRadius(TeamType, PlayerType)
- added void nukeExplosion(int, CyUnit)
- added void setFlagDirty(bool)
- added void setForceUnowned(int)
- added int setImprovementDuration(int)
- added int setOwnershipDuration(int)

In CySelectionGroup:
- added bool alwaysInvisible()
- added bool canDointerfaceMod(interfaceModeType, CyPlot)
- added bool canEnterTerritory(TeamType, bool)
- modified ActivityType getActivityType(): was int getActivityType(ActivityType)
- modified AutomateType getAutomateType(): was int getAutomateType(AutomateType)
- added bool hasCargo()
- added bool isAmphibPlot(CyPlot)
- added bool isFull()
- added bool isWaiting()
- added void setActivityType(ActivityType)

In CyTeam:
- added int countEnemyDangerByArea(CyArea)
- added int countEnemyPowerByArea(CyArea)
- added int countNumAIUnitsByArea(CyArea, UnitAIType)
- added int countNumUnitsByArea(CyArea)
- added int countTotalPopulationByArea(CyArea)
- added int getBuildingClassCountPlusMaking(BuildingClassType)
- added int getChosenWarCount(bool)
- added int getDefensivePactCount()
- added int getDefensivePower()
- added int getHasReligionCount(ReligionType)
- added int getNumNukeUnits()
- added int getResearchLeft(TechType)
- added int getSecretaryID(PlayerType)
- added int getUnitClassCountPlusMaking(UnitClassTypes)
- added int getWarPlanCount(WarPlanType, bool)

In CyTranslator:
- added string stripHTML(string)

In CyUnit:
- added int airBombBaseRate()
- added int airBombardCurrRate()
- added int airCombatDamage(CyUnit)
- added int airCombatLimit()
- added FLOAT airCurrCombatStrFloat()
- added FLOAT airMaxCombatStrFloat()
- added int animalCombatModifier()
- added CyUnit bestinterceptor(CyPlot)
- added bool canAirBomb()
- added bool canAirBombAt(CyPlot, int, int)
- added bool canAirlift(CyPlot)
- added bool canAirliftAt(CyPlot, int, int)
- added bool canBuildRoute()
- added bool canCargoAllMove()
- added bool canDefend(CyPlot)
- modified bool canHeal(CyPlot): added CyPlot argument
- added bool
- modified bool canPatrol(CyPlot): added CyPlot argument
- added bool canRecon()
- added bool canReconAt(CyPlot, int, int)
- modified bool canSentry(CyPlot): added CyPlot argument
- added bool canSiege(TeamType)
- added bool canStealPlans(CyPlot, bool)
- added int cityAttackModifier()
- added int cityDefenseModifier
- added int collateralDamageMaxUnits()
- added void convert(CyUnit)
- added int currFirepower(CyPlot, CyUnit)
- added int domainModifier(Domaintype)
- added int featureDefenseModifier(FeatureType)
- added bool generatePath(CyPlot, int, bool, int)
- added int getDiscoverResearch(TechType)
- added int getExtraCityAttackPercent()
- added int getExtraCityDefensePercent()
- added int getExtraCombatPercent()
- added int getExtraDomainModifier()
- added int getExtraFeatureDefensePercent()
- added int getExtraHillsDefensePercent()
- added int getExtraTerrainDefensePercent()
- added int getExtraUnitCombatModifier()
- added int getGameTurnCreated()
- added int getMaxHurryPopulation(CyCity)
- added CyPlot getPathEndTurnPlot()
- added int hillsDefenseModifier()
- added bool ignoreTerrainCost()
- added bool isAttacking()
- added bool isAutomated()
- added bool isCombat()
- added bool isDefending()
- added bool isFighting()
- added bool isFortifyable()
- added bool isFound()
- added bool isInvestigate()
- added bool isMadeinterception()
- added bool isNeverInvisble()
- added bool isNukeVictim(CyPlot, TeamType)
- added void setMadeinterception
- added int stealPlanCost(CyPlot)
- added int stealPlanProb(CyPlot, ProbabilityType)
- added int terrainDefenseModifier(Terraintype)
- added int unitClassAttackModifier(UnitClassType)
- added int unitClassDefenseModifier(UnitClassType)
- added int unitCombatModifier(UnitCombatType)

In PBGameSetupData:
- added bool getVictory(int)
- added int iCityElimination
- added int iMaxTurns
- added int iNumVictories

In PBPlayerAdminData:
- added bool bTurnActive</ul>

Disclaimer: this list may not be 100% complete, specifically there may be some functions which in v1.52 were not documented that have had their arguments changed. If you suddenly get any 'Python argument types in {x} did not match C++ signature: {y}' on any of your pre-v1.61 scripts, you probably found a function of which the arguments changed ;)

The Python API reference on this site will be updated later today or tomorrow, I need to get some other paperwork done first.
 
In Cyinterface:
- added void clearSelectionlist()
- added void insertintoSelectionlist(CyUnit, bool, bool, bool, bool)
- added void removeFromSelectionUnit(CyUnit)

This will make my plot list enhancements waaaaaay more simple :) :)
 
These sound particularly interesting to me. Let me know if I'm off on my assumptions about their use:

- added void reviveActivePlayer()
==Will this "revive" a "dead" civ, or allow a civ to have 2 turns in one round (instead of all other players having their turn, the civ gets to "move" again)?

- added void setPersonalityType(LeaderHeadType)
==It seems this will allow us to change leaders in-game...
 
The Great Apple said:
Hmmm, CyUnit.convert(CyUnit) - I wonder what this will do.

It's called when a unit is upgraded or gifted away. Basically, it copies some data (damage, promotions, experience, name) from the unit in parentheses to the one that is converted and then kills the unit in parentheses. Or in other words:

newunit.convert(oldunit)

newunit receives the data from oldunit, then oldunit is killed.

(I just added a line to the code that also copies all information stored by sdtoolkit, hope it works :))
 
Teg_Navanis said:
It's called when a unit is upgraded or gifted away. Basically, it copies some data (damage, promotions, experience, name) from the unit in parentheses to the one that is converted and then kills the unit in parentheses. Or in other words:

newunit.convert(oldunit)

newunit receives the data from oldunit, then oldunit is killed.

(I just added a line to the code that also copies all information stored by sdtoolkit, hope it works :))
Good point - I should have just looked it up... I love the SDK.
 
The Great Apple said:
Hmmm, CyUnit.convert(CyUnit) - I wonder what this will do.

It copies all properties (promotions, experience, damage, move points, etc) from the unit in the argument to the current unit and then kills the unit in the argument.

Shqype said:
- added void reviveActivePlayer()
==Will this "revive" a "dead" civ, or allow a civ to have 2 turns in one round (instead of all other players having their turn, the civ gets to "move" again)?

The former.

With the SDK, you can look this stuff up real easily yourself ;)

Edit: crosspost.
 
Locutus said:
It copies all properties (promotions, experience, damage, move points, etc) from the unit in the argument to the current unit and then kills the unit in the argument.

Does the new unit keep the ID from the old unit or does a new ID get generated for it?
 
Back
Top Bottom