Civ3like Airports?

Tholish

Emperor
Joined
Jul 5, 2002
Messages
1,344
Location
Japan
Is there a way to make a building connect resources like airports used to in Civ 3? What I mean is if you have an airport in City A and another one in City B, and City A has Iron, then City B also has iron, even if there is no land or sea connection between them.

I could have sworn this used to work in Civ 4, all you needed was to make sure airlift was 1. But lately it doesn't work.
 
Oh, there is a way. You almost assuredly need to do this in the SDK, possibly you could hack it in with python, but i doubt it.

I'm not sure how to do it, I would just ask in the SDK forums. Thinking on it for a bit, I bet it would be pretty simple really, just need to set up a boolean XML tag for BuildingInfos and have a true result connect the city to the capitol (trade network). Unfortunately I don't know what Source Code file controls trade network. Like I said though, the Python/SDK forum is where you'd need to go to implement this.
 
Roger, thanks. I guess my two semesters of C++ and that Python book I kind of looked over will now get some exercise because I need this. I know there's a tutorial on adding tags, and could probably follow it, but the SDK is kind of complex, even if you understand the principles. I'll go there.

PS. But first I need to gather my notes.

cvCity has a function like this.

bool CvCity::isConnectedTo(CvCity* pCity)
{
return plot()->isConnectedTo(pCity);
}

and another one for connection to capitol. It just returns wether a plot is connected ao a particular city yes or no. It doesn't SET a variable, it checks for it--I guess its a data getting function. I don't know what I'm talking about. Let me go look some more.
 
Actually looks like I was wrong, Python would probably be the easiest way. Looking over the PythonAPI have this call in CyCity:
BOOL isConnectedToCapital (PlayerType ePlayer)

So all you need to do is set it up so that if a building (in this case you'll define as the airport) is in pCity, this boolean is set to true. I think you set something like this up in CvEventManager.py. I could be wrong though, but that sounds about right.

Edit: Actually, I think this call would be more useful: isConnectedTo (CyCity pCity)
Just off the top of my head something like

Code:
pCapital = pPlayer.getCapitalCity()
iAirport = gc.getTypeForString("BUILDING_AIRPORT")
if( pCity.getNumRealBuilding(iAirport) > 0 ) :
    pCity.isConnectedTo(pCapital) = true

Anyway, not sure if that code exactly will work, but it'll be close, and I'm nearly certain it would go somewhere in CvEventManager.py

I'd look over one of Tstentom's Python Wonders for a reference, try it, and if it fails ask in the SDK/Python forums to see what's ammater with my code.
 
I tried this

def onBuildingBuilt(self, argsList):
pCity, iBuildingType = argsList
if iBuildingType == gc.getInfoTypeForString ('BUILDING_SPACEPORT'):
pCity.isConnectedTo(pCapitol)=true

and got a bunch of exceptions basically ending in "can't assign to function call"
So, pCity.isConnectedTo is a function that returns a boolean, but you can't assign its value from outside (oops).
So, I have to find out what it variable it returns the boolean to (anything that wants to use it to see if there's a connection) and
give it something inside its own terms that can reset it. Unless there's something else.
 
Strange, post this in the SDK and Python forums. I'm sure EF will know how to fix it.

Also pCapital isn't defined, you must define it, it's why I included that in my example code above.
 
Ah, so pCapitol isn't another function, its a variable that you are creating right there and setting it equal to a function called getCapitolCity (the Player version). I'll try doing it right then follow your instructions...
 
Yeah. pCapitol isn't a function recognized by the dll, you need to define it, hence the pPlayer.getCapitolCity() call.
Also I've never seen this way of determining if a building is present in a city either:
pCity, iBuildingType = argsList
if iBuildingType == gc.getInfoTypeForString ('BUILDING_NAMEOFBUILDING'):

Always determined if a city had a building using this method:
iBuilding = gc.getTypeForString("BUILDING_NAMEOFBUILDING")
if( pCity.getNumRealBuilding(iBuilding) > 0 ) :
...

Not to say it wol't work, I just don't know. Getting coding advice from me is a little bit like the blind leading the blind, lol.
 
Did this:

def onBuildingBuilt(self, argsList):
'Building Completed'
pCity, iBuildingType = argsList
game = gc.getGame()
#Phungus's Snippet
pCapitol=pPlayer.getCapitolCity()
iAirport=gc.getTypeForString("BUILDING_SPACEPORT")
if(pCity.getNumRealBuilding(iAirport)>0):
pCity.isConnectedTo(pCapitol)=true
#End Phungus's Snippet

and got the same string of exceptions. Seeking help from higher. Thanks.

PS, how did you post that blue block with the indents showing?
 
It's the code tags [/code]
Code:
Yeah, just post what you have and what you've tried in the SDK/Python forums, Emperor Fool & Xienowolf and others have always been most helpful to me.  So far every function I've needed to do, they've helped me get it working.
 
Back
Top Bottom