phungus420
Deity
- Joined
- Mar 1, 2003
- Messages
- 6,296
I have this code:
Now this is the first code I've ever written. It's pretty messy, and also it's functionality isn't very expandible. It's stuck inside XML definitions, I'd like to improve it so that it can be applied to other mods, and also simplify it.
Basically instead of checking a city for various Buildings, and Checking the Civ for various techs I'd rather create a new variable: CivCommBonus which will check, and get bigger based on functions. For instance, the Minor tribes code doesn't call for the Tech Writing, it calls to see if the Civ has the ability to sign open borders, this is what I mean. The actual math and applying the new variable in a balanced way is yet to be determined, but that's not an issue. I'm good at math, hell finished derivitive Calc in way back in my high school softmore year, so I'm not worried about that part of the code.
What I need to know is how to make these specific calls:
-pCity getting +1 food on water tiles
-pCity getting %bonus to trade routes (what is the %bonus)
-pPlayer can build terrrain movement modifier feature (roads railroads): Determine that modifier
-pCity can Airlift
-pPlayer can trade over Ocean
-pCity has Culture% bonus (what is the % bonus)
As for determining the modifiers once I know the calls (terrain movement, %trade bonus, %culture) I think I can do this myself, or at lease figure it out. Mainly I need to know how to make the original call, that such things actually exist for pCity/pPlayer.
That's it, anyone know these calls? I'm pretty sure I can write the code myself no problem once I know how to make these 6 calls.
Spoiler :
Code:
# Distance to capital City Distance modified by communication techs and structures
cityDistModifier = ( plotDistance( pCity.getX(), pCity.getY(), capital.getX(), capital.getY()) )*0.4
if( not pCity.isConnectedTo(capital) ) :
cityDistModifier = (cityDistModifier + 1)*4
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLAirport)) > 0 ) :
if( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iJetTech) ) :
cityDistModifier = (cityDistModifier - 6)*0.4
else:
cityDistModifier = (cityDistModifier - 5)*0.6
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 - 4)*0.7
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLCothon)) > 0 ) :
cityDistModifier = (cityDistModifier - 4)*0.7
else:
cityDistModifier = (cityDistModifier - 3)*1.2
elif( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iAstronomyTech) ) :
if( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLHarbor)) > 0 ) :
cityDistModifier = (cityDistModifier - 3)*1.2
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLCothon)) > 0 ) :
cityDistModifier = (cityDistModifier - 3)*1.2
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLDLighthouse)) > 0 ) :
cityDistModifier = (cityDistModifier - 2)*1.7
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLTradePost)) > 0 ) :
cityDistModifier = (cityDistModifier - 2)*1.7
else:
cityDistModifier = (cityDistModifier - 2)*2.2
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)*2.2
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLCothon)) > 0 ) :
cityDistModifier = (cityDistModifier - 2)*2.2
else:
cityDistModifier = (cityDistModifier - 1)*2.5
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLHarbor)) > 0 ) :
cityDistModifier = (cityDistModifier - 1)*2.5
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLCothon)) > 0 ) :
cityDistModifier = (cityDistModifier - 1)*2.5
elif( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iWheelTech) ) :
if( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLDLighthouse)) > 0 ) :
cityDistModifier = (cityDistModifier - 1)*3
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLTradePost)) > 0 ) :
cityDistModifier = (cityDistModifier - 1)*3
else:
cityDistModifier = cityDistModifier*3
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLDLighthouse)) > 0 ) :
cityDistModifier = cityDistModifier*3
elif( pCity.getNumRealBuilding(gc.getInfoTypeForString(RevDefs.sXMLTradePost)) > 0 ) :
cityDistModifier = cityDistModifier*3
else:
cityDistModifier = cityDistModifier*3.6
#cityDistModifier = adjusted for map size and normalized
cityDistModifier = cityDistModifier - 1
cityDistModifier = cityDistModifier/((( CyMap().getGridWidth()**2 + CyMap().getGridHeight()**2 )**0.5)*0.013)
Now this is the first code I've ever written. It's pretty messy, and also it's functionality isn't very expandible. It's stuck inside XML definitions, I'd like to improve it so that it can be applied to other mods, and also simplify it.
Basically instead of checking a city for various Buildings, and Checking the Civ for various techs I'd rather create a new variable: CivCommBonus which will check, and get bigger based on functions. For instance, the Minor tribes code doesn't call for the Tech Writing, it calls to see if the Civ has the ability to sign open borders, this is what I mean. The actual math and applying the new variable in a balanced way is yet to be determined, but that's not an issue. I'm good at math, hell finished derivitive Calc in way back in my high school softmore year, so I'm not worried about that part of the code.
What I need to know is how to make these specific calls:
-pCity getting +1 food on water tiles
-pCity getting %bonus to trade routes (what is the %bonus)
-pPlayer can build terrrain movement modifier feature (roads railroads): Determine that modifier
-pCity can Airlift
-pPlayer can trade over Ocean
-pCity has Culture% bonus (what is the % bonus)
As for determining the modifiers once I know the calls (terrain movement, %trade bonus, %culture) I think I can do this myself, or at lease figure it out. Mainly I need to know how to make the original call, that such things actually exist for pCity/pPlayer.
That's it, anyone know these calls? I'm pretty sure I can write the code myself no problem once I know how to make these 6 calls.