Wow, lots of posts while I was typing that. I like Sto's lists better than mine![]()
# make a dict of buildings ,improvement ,ring check
dictInfo = {
"BUILDING_A" : {
"imprs" : ["IMPROVEMENT_A"] ,
"rings" : [1]
} ,
"BUILDING_B" : {
"imprs" : ["IMPROVEMENT_B"] ,
"rings" : [2]
} ,
"BUILDING_C" : {
"imprs" : ["IMPROVEMENT_C1", "IMPROVEMENT_C2"] ,
"rings" : [1, 2]
}
}
buildingType = gc.getBuildingInfo(eBuilding).getType()
# Then, break out of this check if we don't need to be here
if not buildingType in dictInfo.keys():
return False
# first check if the city argument is valid
if pCity.isNone() :
return True
#Get the city plot, and check the surrounding plots for the required improvement.
iX = pCity.getX()
iY = pCity.getY()
iCityOwner = pCity.getOwner()
bCantBuild = True
improvementsToCheck = [gc.getInfoTypeForString(item) for item in dictInfo[buildingType]["imprs"]]
playerCityRing1 = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]
playerCityRing2 = [(-2,-1),(-2,0),(-2,1),(2,-1),(2,0),(2,1),(-1,2),(0,2),(1,2),(-1,-2),(0,-2),(1,-2)]
plotsToCheck = []
if 1 in dictInfo[buildingType]["rings"] : plotsToCheck += playerCityRing1
if 2 in dictInfo[buildingType]["rings"] : plotsToCheck += playerCityRing2
for dX, dY in plotsToCheck:
pPlot = CyMap().plot(iX+dX, iY+dY)
# check if the plot is valid if you are at the border of the map.
if pPlot.isNone() :
continue
elif not pCity.canWork(pPlot):
continue
if pPlot.getOwner() == iCityOwner:
if pPlot.getImprovementType() in improvementsToCheck:
bCantBuild = False
break
return bCantBuild
def cannotConstruct(self,argsList):
pCity = argsList[0]
eBuilding = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
bIgnoreCost = argsList[4]
### MachuPicchu Mod begins ###
###########################################################################################
if ( eBuilding == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):
### find peaks within the city radius controlled by your team ###
pPlayer = gc.getPlayer(pCity.plot().getOwner())
iPID = pPlayer.getID()
iTID = pPlayer.getTeam()
iX = pCity.getX()
iY = pCity.getY()
for iXLoop in range(iX - 2, iX + 3, 1):
for iYLoop in range(iY - 2, iY + 3, 1):
pPlot = CyMap().plot(iXLoop, iYLoop)
if ( pPlot.isPlayerCityRadius(iPID)==true ):
if ( pPlot.getTeam()==iTID ):
if ( pPlot.isPeak()==true ):
return False
return True
###########################################################################################
### MachuPicchu Mod ends ###
# make a dict of buildings ,improvement ,ring check
dictInfo = {
"BUILDING_A" : {
"imprs" : ["IMPROVEMENT_EXPLORETEMPLE"] ,
"rings" : [1]
} ,
"BUILDING_B" : {
"imprs" : ["IMPROVEMENT_SKLARNA"] ,
"rings" : [2]
} ,
"BUILDING_C" : {
"imprs" : ["IMPROVEMENT_BOJKLASTER", "IMPROVEMENT_BOJKLASTER"] ,
"rings" : [1, 2]
}
}
buildingType = gc.getBuildingInfo(eBuilding).getType()
# Then, break out of this check if we don't need to be here
if not buildingType in dictInfo.keys():
return False
# first check if the city argument is valid
if pCity.isNone() :
return True
#Get the city plot, and check the surrounding plots for the required improvement.
iX = pCity.getX()
iY = pCity.getY()
iCityOwner = pCity.getOwner()
bCantBuild = True
improvementsToCheck = [gc.getInfoTypeForString(item) for item in dictInfo[buildingType]["imprs"]]
playerCityRing1 = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]
playerCityRing2 = [(-2,-1),(-2,0),(-2,1),(2,-1),(2,0),(2,1),(-1,2),(0,2),(1,2),(-1,-2),(0,-2),(1,-2)]
plotsToCheck = []
if 1 in dictInfo[buildingType]["rings"] : plotsToCheck += playerCityRing1
if 2 in dictInfo[buildingType]["rings"] : plotsToCheck += playerCityRing2
for dX, dY in plotsToCheck:
pPlot = CyMap().plot(iX+dX, iY+dY)
# check if the plot is valid if you are at the border of the map.
if pPlot.isNone() :
continue
elif not pCity.canWork(pPlot):
continue
if pPlot.getOwner() == iCityOwner:
if pPlot.getImprovementType() in improvementsToCheck:
bCantBuild = False
break
return bCantBuild
return False
def canCreate(self,argsList):
# Then, break out of this check if we don't need to be here
if not buildingType in dictInfo.keys():
return False
Python I have installed. Only not know how make with it these stuffs![]()
![]()
I have installed python for Blender functioning. I´m 3D modeler, not coder![]()
Hrochland, you can also click with RMB and choose Edit with IDLE in the contextual window. That's faster.
# in CvGameUtils :
# put the dict after the list of import at the beginning
dictInfo = {
"BUILDING_A" : {
"imprs" : ["IMPROVEMENT_A"] ,
"rings" : [1]
} ,
"BUILDING_B" : {
"imprs" : ["IMPROVEMENT_B"] ,
"rings" : [2]
} ,
"BUILDING_C" : {
"imprs" : ["IMPROVEMENT_C1", "IMPROVEMENT_C2"] ,
"rings" : [1, 2]
}
}
# you can delete dictInfo in cannotConstruct
#change the doCulture function
def doCulture(self,argsList):
pCity = argsList[0]
if pCity.isNone() : return False
if pCity.isDisorder() : return False
if pCity.isOccupation() : return False
iCX = pCity.getX()
iCY = pCity.getY()
iCityOwner = pCity.getOwner()
playerCityRing1 = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]
playerCityRing2 = [(-2,-1),(-2,0),(-2,1),(2,-1),(2,0),(2,1),(-1,2),(0,2),(1,2),(-1,-2),(0,-2),(1,-2)]
for buildingType in dictInfo.keys() :
iBuilding = gc.getInfoTypeForString(buildingType)
if pCity.getNumRealBuilding(iBuilding) > 0 :
plotToCheck = []
if 1 in dictInfo[buildingType]["rings"] : plotToCheck += [item for item in playerCityRing1]
if 2 in dictInfo[buildingType]["rings"] : plotToCheck += [item for item in playerCityRing2]
improvementsToCheck = [gc.getInfoTypeForString(item) for item in dictInfo[buildingType]["imprs"]]
bFoundOne = False
for dCX, dCY in plotToCheck :
pLoopPlot = CyMap().plot(iCX+dCX, iCY+dCY)
if pLoopPlot.isNone() : continue
elif not pCity.canWork(pLoopPlot): continue
if pLoopPlot.getOwner() == iCityOwner :
if pLoopPlot.getImprovementType() in improvementsToCheck :
bFoundOne = True
break
if not bFoundOne :
pCity.setNumRealBuilding(iBuilding, 0)
return False
def doCulture(self,argsList):
pCity = argsList[0]
if pCity.isNone() : return False
if pCity.isDisorder() : return False
if pCity.isOccupation() : return False
iCX = pCity.getX()
iCY = pCity.getY()
iCityOwner = pCity.getOwner()
playerCityRing1 = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]
playerCityRing2 = [(-2,-1),(-2,0),(-2,1),(2,-1),(2,0),(2,1),(-1,2),(0,2),(1,2),(-1,-2),(0,-2),(1,-2)]
for buildingType in dictInfo.keys() :
iBuilding = gc.getInfoTypeForString(buildingType)
if pCity.getNumRealBuilding(iBuilding) > 0 :
plotToCheck = []
ringsToCheck = dictInfo[buildingType]["rings"]
if 1 in ringsToCheck : plotToCheck += [item for item in playerCityRing1]
if 2 in ringsToCheck : plotToCheck += [item for item in playerCityRing2]
improvementsToCheck = [gc.getInfoTypeForString(item) for item in dictInfo[buildingType]["imprs"]]
bFoundOne = False
for dCX, dCY in plotToCheck :
pLoopPlot = CyMap().plot(iCX+dCX, iCY+dCY)
if pLoopPlot.isNone() : continue
elif not pCity.canWork(pLoopPlot): continue
if pLoopPlot.getOwner() == iCityOwner :
if pLoopPlot.getImprovementType() in improvementsToCheck :
bFoundOne = True
break
if not bFoundOne :
pCity.setNumRealBuilding(iBuilding, 0)
sBuilding = gc.getBuildingInfo(iBuilding).getDescription()
sCity = pCity.getName()
sImprovement = ", ".join(gc.getImprovementInfo(iImprovement).getDescription() for iImprovement in improvementsToCheck)
if ringsToCheck == [1] : sTxtTag = "TXT_KEY_BUILDING_LOST_IMPROVEMENT_MISSING_RING1"
elif ringsToCheck == [2] : sTxtTag = "TXT_KEY_BUILDING_LOST_IMPROVEMENT_MISSING_RING2"
else : sTxtTag = "TXT_KEY_BUILDING_LOST_IMPROVEMENT_MISSING"
CyInterface().addMessage(iCityOwner, False , gc.getEVENT_MESSAGE_TIME(), CyTranslator().getText(sTxtTag,(sBuilding, sCity, sImprovement)), "AS2D_BOMBARDED", InterfaceMessageTypes.MESSAGE_TYPE_INFO, gc.getBuildingInfo(iBuilding).getButton(), gc.getInfoTypeForString("COLOR_RED"), iCX, iCY, True, True)
return False
<TEXT>
<Tag>TXT_KEY_BUILDING_LOST_IMPROVEMENT_MISSING</Tag>
<English>%s1_building in %s2_CityName is destroyed (No more %s3 in the city radius)</English>
<French>%s1_building in %s2_CityName is destroyed (No more %s3 in the city radius)</French>
<German>%s1_building in %s2_CityName is destroyed (No more %s3 in the city radius)</German>
<Italian>%s1_building in %s2_CityName is destroyed (No more %s3 in the city radius)</Italian>
<Spanish>%s1_building in %s2_CityName is destroyed (No more %s3 in the city radius)</Spanish>
</TEXT>
<TEXT>
<Tag>TXT_KEY_BUILDING_LOST_IMPROVEMENT_MISSING_RING1</Tag>
<English>%s1_building in %s2_CityName is destroyed (No more %s3 in the first ring of the city radius)</English>
<French>%s1_building in %s2_CityName is destroyed (No more %s3 in the first ring of the city radius)</French>
<German>%s1_building in %s2_CityName is destroyed (No more %s3 in the first ring of the city radius)</German>
<Italian>%s1_building in %s2_CityName is destroyed (No more %s3 in the first ring of the city radius)</Italian>
<Spanish>%s1_building in %s2_CityName is destroyed (No more %s3 in the first ring of the city radius)</Spanish>
</TEXT>
<TEXT>
<Tag>TXT_KEY_BUILDING_LOST_IMPROVEMENT_MISSING_RING2</Tag>
<English>%s1_building in %s2_CityName is destroyed (No more %s3 in the second ring of the city radius)</English>
<French>%s1_building in %s2_CityName is destroyed (No more %s3 in the second ring of the city radius)</French>
<German>%s1_building in %s2_CityName is destroyed (No more %s3 in the second ring of the city radius)</German>
<Italian>%s1_building in %s2_CityName is destroyed (No more %s3 in the second ring of the city radius)</Italian>
<Spanish>%s1_building in %s2_CityName is destroyed (No more %s3 in the second ring of the city radius)</Spanish>
</TEXT>