gc.getGameSpeedInfo()
Can anyone tell me what the methods for this are and how they work?
I am apparently too dumb to find where this is defined.
Xspeed = gc.getGame().getGameSpeedType()
gameSpeedMod = gc.getGameSpeedInfo(Xspeed).getGrowthPercent()
Anyone knows how to make a unit give a free promotion when attached to an other one?
For example I create aFart Frog(oops....) Dart Frog, set the <LeaderPromotion> to PROMOTION_POISON_ARROWS. The pedia text displays what happens when attached to a unit but there is no icon to attach it to any unit.
Any ideas?
I asked it in the Quick Modding Questions but try it here too:
I tried all of those but nothingI think you may need an <iLeaderExperience> value greater than 0. Try that and see what happens. You could also try <bGreatGeneral> set to 1, but I think that only works for creating units.
THX! I'll try itThe other thing that might work instead of a <LeaderPromotion> is a Mission. I think from reading the schema that a mission can grant a promotion. You'd need to define the mission and the outcome and then edit the unit file to give the mission to the unit. I have not tried it myself.
@Vokarya
Is there a tutorial somewhere for the new Mission mechanics? As I see, much of it are coming from some mod, right?
I knew that just had no idea how the "convert unit into promotion" thing could be done. Now looking into the CIV4OutcomeInfos I think I start to understand it a bit more.The Missions themselves aren't anything new. It's the Outcomes and interfacing that with the units that are new. Most of the work is actually done in the units XML file.
So here's something I tried to do:
I made a barbarian UU 'Tribe', a Settler replacement. It cannot found cities; all it can do is to build a Goody Hut by consuming the unit. I have set up Buildinfos and Improvementinfos properly, so I can turn the unit into a Goody Hut; that part works. The problem is that I don't know hove to "encourage" the AI to use the unit as I want that is: when spawned in some empty area it creates more Goody Huts.
I tried both UnitAI_Settle and UnitAI_Worker but no deference.
I also tried to give Goody Hut a +10% defense bonus and place a barbarian military unit to the same tile but still nothing.
Any idea ho to make it work purely with XML modifications? (It's a modular modmod so I don't want to touch any python files or else)
# Assigns a new name to a player based on their civics choices
pPlayer = gc.getPlayer(iPlayer)
capital = pPlayer.getCapitalCity()
playerEra = pPlayer.getCurrentEra()
pTeam = gc.getTeam(pPlayer.getTeam())
cityString = None
if( not capital == None and not capital.isNone() ) :
try :
# Silly game to force ascii encoding now
cityString = pPlayer.getCivilizationDescription(0)
cityString += "&" + CvUtil.convertToStr(capital.getName())
cityString = cityString.split('&',1)[-1]
except :
pass
curDesc = pPlayer.getCivilizationDescription(0)
curShort = pPlayer.getCivilizationShortDescription(0)
curAdj = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getAdjective(0)
curAdj1 = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getAdjective(1)
curAdj2 = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getAdjective(2)
curAdj3 = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getAdjective(3)
origDesc = ""
if (pPlayer.getCivilizationType() >= 0):
civInfo = gc.getCivilizationInfo(pPlayer.getCivilizationType())
origDesc = civInfo.getDescription()
eLeader = pPlayer.getLeaderType()
bFemaleLeader = self.isFemaleLeader(eLeader)
iLanguage = gc.getGame().getCurrentLanguage()
bFrench = iLanguage == 1 #0 - English, 1 - French, 2 - German, 3 - Italian, 4 - Spanish
eGovCivic = pPlayer.getCivics(gc.getInfoTypeForString("CIVICOPTION_GOVERNMENT"))
ePowerCivic = pPlayer.getCivics(gc.getInfoTypeForString("CIVICOPTION_POWER"))
bNoRealElections = (gc.getInfoTypeForString("CIVIC_HEREDITARY_RULE") == eGovCivic or gc.getInfoTypeForString("CIVIC_HEREDITARY_RULE") == eGovCivic or gc.getInfoTypeForString("CIVIC_DESPOTISM") == eGovCivic)
bFederal = (gc.getInfoTypeForString("CIVIC_FEDERAL") == eGovCivic and (ePowerCivic == gc.getInfoTypeForString("CIVIC_SENATE") or ePowerCivic == gc.getInfoTypeForString("CIVIC_PARLIAMENT") or ePowerCivic == gc.getInfoTypeForString("CIVIC_PRESIDENT")))
bConfederation = (not bFederal and (gc.getInfoTypeForString("CIVIC_FEDERAL") == eGovCivic))
bPacifist = (pPlayer.getCivics(gc.getInfoTypeForString("CIVICOPTION_MILITARY")) == gc.getInfoTypeForString("CIVIC_PACIFISM"))
if( not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV) ) :
if( pPlayer.getLeaderType() in LeaderCivNames.LeaderCivNames.keys() ) :
[curDesc,curShort,curAdj] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()]
newName = curDesc
if( SDTK.sdObjectExists( "Revolution", pPlayer ) ) :
revTurn = SDTK.sdObjectGetVal( "Revolution", pPlayer, 'RevolutionTurn' )
else :
revTurn = None
if( SDTK.sdObjectExists( "BarbarianCiv", pPlayer ) ) :
barbTurn = SDTK.sdObjectGetVal( "BarbarianCiv", pPlayer, 'SpawnTurn' )
else :
barbTurn = None
if( not pPlayer.isAlive() ) :
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is not alive")
if (bFrench):
newName = localText.getText("TXT_KEY_MOD_DCN_REFUGEES", ())%(curAdj2)
else:
newName = localText.getText("TXT_KEY_MOD_DCN_REFUGEES", ())%(curAdj)
return [newName, curShort, curAdj]
if( pPlayer.isRebel() ) :
# Maintain name of rebels from Revolution Mod
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is rebel, keeping current name")
if( bForceUpdate ) :
return self.nameForNewPlayer(iPlayer)
else :
return [curDesc, curShort, curAdj]
elif( pPlayer.isMinorCiv() and not barbTurn == None ) :
# Maintain minor civ name
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is Minor Barb Civ, keeping current name")
if( bForceUpdate ) :
return self.nameForNewPlayer(iPlayer)
else :
return [curDesc, curShort, curAdj]
elif( not barbTurn == None and game.getGameTurn() - barbTurn < 20 and pPlayer.getNumCities() < 4 ) :
# Main naming conditions
if( RevUtils.isCommunism(iPlayer) ) :
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is communist")
if( RevUtils.isCanDoElections(iPlayer) and not bNoRealElections) :
if( not bForceUpdate and (sSocRep in curDesc or sPeoplesRep in curDesc) ) :
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - keeping prior name")
newName = curDesc
elif( 50 > game.getSorenRandNum(100,'Rev: Naming4') ) :
if (bFrench):
newName = localText.getText("TXT_KEY_MOD_DCN_SOC_REP", ())%(curAdj1)
else:
newName = localText.getText("TXT_KEY_MOD_DCN_SOC_REP", ())%(curShort)
else :
if (bFrench):
newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ())%(curAdj2)
else:
newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ())%(curShort)
elif( RevUtils.getDemocracyLevel(iPlayer)[0] == -8 ) :
if( localText.getText("TXT_KEY_MOD_DCN_RUSSIAN_MATCH", ()) in curAdj ) :
curAdj = localText.getText("TXT_KEY_MOD_DCN_SOVIET", ())
newName = localText.getText("TXT_KEY_MOD_DCN_UNION", ())%(curAdj)
else :
if (bFrench):
newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ())%(curAdj2)
else:
newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ())%(curShort)
elif( RevUtils.isCanDoElections(iPlayer) and not bNoRealElections) :
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player can do elections")
sRepOf = localText.getText("TXT_KEY_MOD_DCN_REPUBLIC_OF", ()).replace('%s','').strip()
sRepublic = localText.getText("TXT_KEY_MOD_DCN_REPUBLIC", ())
def canDoCommunism( iPlayer ) :
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() ) :
return [False,None]
for i in range(0,gc.getNumCivicInfos()) :
kCivic = gc.getCivicInfo(i)
if( kCivic.isCommunism() and pPlayer.canDoCivics(i) ) :
if( not pPlayer.isCivic(i) ) :
return [True,i]
return [False,None]
def isCommunism( iPlayer ) :
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() ) :
return False
for i in range(0,gc.getNumCivicInfos()) :
kCivic = gc.getCivicInfo(i)
if( kCivic.isCommunism() and pPlayer.isCivic(i) ) :
return True
return False
def canDoFreeSpeech( iPlayer ) :
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() ) :
return [False,None]
for i in range(0,gc.getNumCivicInfos()) :
kCivic = gc.getCivicInfo(i)
if( kCivic.isFreeSpeech() and pPlayer.canDoCivics(i) ) :
if( not pPlayer.isCivic(i) ) :
return [True,i]
return [False,None]
def isFreeSpeech( iPlayer ) :
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() ) :
return False
for i in range(0,gc.getNumCivicInfos()) :
kCivic = gc.getCivicInfo(i)
if( kCivic.isFreeSpeech() and pPlayer.isCivic(i) ) :
return True
return False
def isCanDoElections( iPlayer ) :
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() or pPlayer.isBarbarian() ) :
return False
for i in range(0,gc.getNumCivicOptionInfos()) :
iCivic = pPlayer.getCivics(i)
if( iCivic >= 0 ) :
kCivic = gc.getCivicInfo(iCivic)
if( kCivic.isCanDoElection() ) :
return True
return False
def getReligiousFreedom( iPlayer ) :
# Returns [freedom level, option type]
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() ) :
return [0,None]
for i in range(0,gc.getNumCivicOptionInfos()) :
iCivic = pPlayer.getCivics(i)
if( iCivic >= 0 ) :
kCivic = gc.getCivicInfo(iCivic)
if( not kCivic.getRevReligiousFreedom() == 0 ) :
return [kCivic.getRevReligiousFreedom(),i]
return [0,None]
def getBestReligiousFreedom( iPlayer, relOptionType ) :
# Returns [best level, civic type]
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() or relOptionType == None ) :
return [0,None]
bestFreedom = -11
bestCivic = None
for i in civicsList[relOptionType] :
kCivic = gc.getCivicInfo(i)
civicFreedom = kCivic.getRevReligiousFreedom()
if( pPlayer.canDoCivics(i) and not civicFreedom == 0 ) :
if( kCivic.getRevReligiousFreedom() > bestFreedom ) :
bestFreedom = civicFreedom
bestCivic = i
return [bestFreedom, bestCivic]
def getDemocracyLevel( iPlayer ) :
# Returns [level, option type]
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() ) :
return [0,None]
for i in range(0,gc.getNumCivicOptionInfos()) :
iCivic = pPlayer.getCivics(i)
if( iCivic >= 0 ) :
kCivic = gc.getCivicInfo(iCivic)
if( not kCivic.getRevDemocracyLevel() == 0 ) :
return [kCivic.getRevDemocracyLevel(),i]
return [0,None]
def getBestDemocracyLevel( iPlayer, optionType ) :
# Returns [best level, civic type]
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() or optionType == None ) :
return [0,None]
bestLevel = -11
bestCivic = None
for i in civicsList[optionType] :
kCivic = gc.getCivicInfo(i)
civicLevel = kCivic.getRevDemocracyLevel()
if( pPlayer.canDoCivics(i) and not civicLevel == 0 ) :
if( civicLevel > bestLevel ) :
bestLevel = civicLevel
bestCivic = i
return [bestLevel, bestCivic]
def getLaborFreedom( iPlayer ) :
# Returns [level, option type]
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() ) :
return [0,None]
for i in range(0,gc.getNumCivicOptionInfos()) :
iCivic = pPlayer.getCivics(i)
if( iCivic >= 0 ) :
kCivic = gc.getCivicInfo(iCivic)
if( not kCivic.getRevLaborFreedom() == 0 ) :
return [kCivic.getRevLaborFreedom(),i]
return [0,None]
def getBestLaborFreedom( iPlayer, optionType ) :
# Returns [best level, civic type]
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() or optionType == None ) :
return [0,None]
bestLevel = -11
bestCivic = None
for i in civicsList[optionType] :
kCivic = gc.getCivicInfo(i)
civicLevel = kCivic.getRevLaborFreedom()
if( pPlayer.canDoCivics(i) and not civicLevel == 0 ) :
if( civicLevel > bestLevel ) :
bestLevel = civicLevel
bestCivic = i
return [bestLevel, bestCivic]
def getEnvironmentalProtection( iPlayer ) :
# Returns [level, option type]
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() ) :
return [0,None]
for i in range(0,gc.getNumCivicOptionInfos()) :
iCivic = pPlayer.getCivics(i)
if( iCivic >= 0 ) :
kCivic = gc.getCivicInfo(iCivic)
if( not kCivic.getRevEnvironmentalProtection() == 0 ) :
return [kCivic.getRevEnvironmentalProtection(),i]
return [0,None]
def getBestEnvironmentalProtection( iPlayer, optionType ) :
# Returns [best level, civic type]
pPlayer = gc.getPlayer(iPlayer)
if( pPlayer.isNone() or not pPlayer.isAlive() or optionType == None ) :
return [0,None]
bestLevel = -11
bestCivic = None
for i in civicsList[optionType] :
kCivic = gc.getCivicInfo(i)
civicLevel = kCivic.getRevEnvironmentalProtection()
if( pPlayer.canDoCivics(i) and not civicLevel == 0 ) :
if( civicLevel > bestLevel ) :
bestLevel = civicLevel
bestCivic = i
return [bestLevel, bestCivic]
I want to disable the 2 "buggy" events causing global food shortages but not shore if I've found the right ones:
Are they the EVENTTRIGGER_METEOR_STRIKE and EVENTTRIGGER_VOLCANO ?
These don't seem to be global events to me![]()