phungus420
Deity
- Joined
- Mar 1, 2003
- Messages
- 6,296
Jdog I've been tinkering with the CityDistModifier code. I'm getting it to half work, here is what I have:
Now it's close to working. It functions fine for the techs, and scales with the map size nicely. Problem is it's not recognizing the buildings. It simply gives the tech based modifier. I've defined the sXMLHarbor and sXMLAirport in the RevDefs.py file. Originally I tried to call it directly from the XML using that getTypeForString code. Same thing though, it doesn't break it, it just ignored the buildings. I was hoping setting it up in the RevDefs.py file would make it recognize the building, but no such luck.
How can I get the function to see if the city has a buildingtype?
Code:
# Distance to capital City Distance modified by communication techs and structures
cityDistModifier = ( plotDistance( pCity.getX(), pCity.getY(), capital.getX(), capital.getY()) )*0.37
if( not pCity.isConnectedTo(capital) ) :
cityDistModifier = (cityDistModifier + 1)*3.7
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLAirport)) > 0 ) :
if( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iJetTech) ) :
cityDistModifier = (cityDistModifier - 6)*0.5
else:
cityDistModifier = (cityDistModifier - 5)*0.7
elif( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iRadioTech) ) :
cityDistModifier = (cityDistModifier - 4)*0.7
elif( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iRailRoadTech) ) :
if( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLHarbor)) > 0 ) :
cityDistModifier = (cityDistModifier - 3)
else:
cityDistModifier = (cityDistModifier - 3)*1.4
elif( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iAstronomyTech) ) :
if( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLHarbor)) > 0 ) :
cityDistModifier = (cityDistModifier - 3)*1.4
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLLighthouse)) > 0 ) :
cityDistModifier = (cityDistModifier - 2)*1.7
else:
cityDistModifier = (cityDistModifier - 2)*1.9
elif( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iEngineeringTech) and gc.getTeam(pPlayer.getTeam()).isHasTech(self.iHorsebackTech) ) :
if( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLHarbor)) > 0 ) :
cityDistModifier = (cityDistModifier - 2)*1.9
else:
cityDistModifier = (cityDistModifier - 1)*2.2
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLHarbor)) > 0 ) :
cityDistModifier = (cityDistModifier - 1)*2.5
elif( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iWheelTech) ) :
if( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLLighthouse)) > 0 ) :
cityDistModifier = (cityDistModifier - 1)*2.5
else:
cityDistModifier = cityDistModifier*2.8
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLLighthouse)) > 0 ) :
cityDistModifier = cityDistModifier*2.8
else:
cityDistModifier = cityDistModifier*3.3
#cityDistModifier = adjusted for map size and normalized
cityDistModifier = cityDistModifier - 2
cityDistModifier = cityDistModifier/((( CyMap().getGridWidth()**2 + CyMap().getGridHeight()**2 )**0.5)*0.013)
distMod = 1.0 + RevUtils.getCivicsDistanceMod( iPlayer )
Now it's close to working. It functions fine for the techs, and scales with the map size nicely. Problem is it's not recognizing the buildings. It simply gives the tech based modifier. I've defined the sXMLHarbor and sXMLAirport in the RevDefs.py file. Originally I tried to call it directly from the XML using that getTypeForString code. Same thing though, it doesn't break it, it just ignored the buildings. I was hoping setting it up in the RevDefs.py file would make it recognize the building, but no such luck.
How can I get the function to see if the city has a buildingtype?