Python Query for B5 FF Mod

PsiCorps

FF: Babylon 5 mod team
Joined
Dec 30, 2007
Messages
1,425
Location
Britain
Hi All I need a little help with some Python coding and it's all to do with Barbarians/Pirates. There is a file that contains some of the information i need to use which is CvFinalFrontierEvents.py. I Can see what i need to do to change what units appear but what i want to do requires a little more information than i have or can find. We need some new units for this to work. So for the moment assume we have the units as as shown below.
Spoiler :
First Unit - Pirate Construction Ship - Has 0 movement and can only build a Pirate Base.

Second Unit - Pirate Base - Similar to a Starbase, costs 0 to build and consumes Construction Ship when built. Pirate Base builds a Pirate Fighter or Pirate Bomber every 6 turns. Base would be weaker than a Starbase and only be able to hold 3 or 4 units

Third Unit - Pirate Fighter - Slightly weaker than a Starfury or maybe less range but same strength?

Fourth Unit - Pirate Bomber - As above.

Fifth Unit - Pirate Carrier - Should be weaker than other carriers, but not by much, and able to carry less units, say 4 or 5.

Hopefully the AI would automatically use the Fighters/Bombers transfering them to Carriers to go out raiding.

This would give a lot more B5 flavour especially especially once we get rid of the Battleships, Cruisers, Destroyers, etc that are currently used.

I've been told that the AI doesn't use Carriers very well/at all but again maybe a (small) change to Python will change that:D.
Is what i've proposed possible and if so what besides the change in order of Pirate ship appearances would i need to do?
 
Hi man!,

About the pirate starbase, It would be actually easier to just spawn the starbase.

For what I have seen changing the class of pirate ships its easy, tho I can't recall ever seeing an AI using an Aircraft carrier... and for what I know, AI isn't coded in python, but rather in C++.

For starters, try worldbuilding an aircraft carrier with fighters in standard Civ, if the AI uses it succesfully, then we can talk...
 
Gave this a go last night. Pirate Starbase used fighters and bombers for defence but used it's own attack to damage the unit i place 3 spaces away. My own bombers attacked and were intercepted by the defending units. The Pirate Carrier did the same thing, using its fighters and bombers to defend it. AI doesn't seem to like using the bombers for attacking at all. Having looked at the units in the CIV4UnitInfos fighters default AI is UNITAI_DEFENSE_AIR and bombers default AI is UNITAI_ATTACK_AIR. So i don't know why the bombers didn't get used for attack. I'll have another look at this tonight and see if putting the carrier near a planet instead of a ship changes things.:D

Whilst we're on Python i would like the Terraforming tech to add 2 to the max pop of all planets in a similar manner to the green economy benefit.
Spoiler :
iMaxPop = aiDefaultPopulationPlanetSizeTypes[self.getPlanetSize()]

for iBuildingLoop in range(gc.getNumBuildingInfos()):
if (self.isHasBuilding(iBuildingLoop)):
if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
iMaxPop += g_aiBuildingPopCapIncrease[iBuildingLoop]

if (iOwner > -1):

# Green Economy Civic mod to food
iEconomyCivicOption = CvUtil.findInfoTypeNum(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_ECONOMY')
iGreenEconomy = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_GREEN_ECONOMY')

pPlayer = gc.getPlayer(iOwner)

if (pPlayer.getCivics(iEconomyCivicOption) == iGreenEconomy):
iMaxPop += 1

return iMaxPop


I Just don't know how to tell Python exactly what to look for. Can anyone help?:confused:
 
This is all theoretical and not tested, but I think it might work after looking through and finding the methods in the API.

Code:
if (iOwner > -1):
			
			iTerraforming = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_TERRAFORMING')
			
			pPlayer = gc.getPlayer(iOwner)
			pTeam = pPlayer.getTeam()
			
			if (pTeam.isHasTech(iTerraforming)):
				iMaxPop += 2
 
Actually, it looks like tech checking has to be in a different form:
Code:
if gc.getTeam(player.getTeam()).isHasTech(iTech):
I have no idea how that's any different from what I gave, but that works in the random event I tested it in and it's similar to how Firaxis uses it in the barbarian events.
 
Spoiler :
if (iOwner > -1):

iTerraforming = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_TERRAFORMING')

pPlayer = gc.getPlayer(iOwner)
pTeam = pPlayer.getTeam()

if gc.getTeam(player.getTeam()).isHasTech(iTech):
iMaxPop += 2

OK, this time around i used the formula above, the City window opened OK but the planet selection on the right hand side showed 8 identical planets and the buildings auto constructed on the first turn for the first planet weren't built.:confused:

EDIT- there is no gap between the c and h in tech as it shows in the spoiler but it wouldn't save without the gap(edited this 3 times to try and fix it.:lol:
 
I Tried this
if (iOwner > -1):

iTerraforming = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_B5_TERRAFORMING')

pPlayer = gc.getPlayer(iOwner)
pTeam = pPlayer.getTeam()

if gc.getTeam(player.getTeam()).isHasTech('TECH_B5_TERRAFORMING'):
iMaxPop += 2
and removed it immeadiately as no suns or planets were showing anywhere on the map.:(:sad: really can't see why it would do that when there's no real difference to what green economy does.
 
Perhaps it would be better to have a terraformer building enabled at that tech that raises the max pop by 2? It's difficult to explain it, but look for the area in CvSolarSystem that deals with the habitation center. You need to create a similar array (the number is the number of the building, where 0 is the first building, 5 is habitation center in FF; the other number is the amount the max pop is raised by, 1 for habitation center) and make sure that you have code relating to that array each time it's mentioned (make it identical except for the array name).
 
@PsiCorps - Please use [ code ] ... [ /code ] tags to post your code so it retains the formatting. Given that Python's whitespace is significant, it's hard to tell if you have indentation problems or not.

Also, it would be very helpful if you could post the contents of "Logs/PythongErr.log" (not "...2.log"). This will tell us the Python error and where it is. You may have to turn this on in you CivilizationIV.ini file; search for "logging".
 
Top Bottom