need SDK help.

Watiggi

Deity
Joined
Feb 27, 2006
Messages
2,107
I want to be able to cycle through the cities buildings and get information about whether it's an economic building, research building or a production building (excluding the military academy and hero epic). I also want to be able to know how many specialist slots are in each of these buildings.

I for the life of me cannot find this type of information. The only way I seem to be able to confirm whether a building is for example an economic type is by seeing if it has a commerce modifier or not.

I also can't seem to figure out how to identify whether a shrine is in the city or how much gold the shrine is producing.

Anyone have any ideas/suggestions?
 
I want to be able to cycle through the cities buildings and get information about whether it's an economic building, research building or a production building (excluding the military academy and hero epic). I also want to be able to know how many specialist slots are in each of these buildings.

(Warning: I just wrote this all in the browser, no tested code here.)

Are you talking about advisor types? In that case, to determine the advisor type, you would do...


Code:
GC.getBuildingInfo(eBuilding).getAdvisorType()

That's advisor with an "o", some people use an "e", but it's "o" in Civ4.

So, for example...

Code:
if (ADVISOR_MILITARY == GC.getBuildingInfo(eBuilding).getAdvisorType())
{
...
}




I also can't seem to figure out how to identify whether a shrine is in the city or how much gold the shrine is producing.

Anyone have any ideas/suggestions?

The CvCity can own a building one of two ways: it can build it or it can get it for free (from wonders, leaders, whatever). In the CvCity object, this is stored in two seperate arrays, but the easiest way to determine if the city has a building is using the hasBuilding function.

if (pCity->hasBuilding(eBuilding))
{
...
}
 
Thanks for that Gerikes :)

I still haven't figured out how to get the number of specialist slots in each building, but I don't need to know anymore. With the hasBuilding() method, I was kind of hoping for a hasShrine() and/or a hasWonder() method. It felt a little too weird using hard constant values when searching for the shrine wonders, but anyway.

Thanks for that.
 
Thanks for that Gerikes :)

I still haven't figured out how to get the number of specialist slots in each building, but I don't need to know anymore. With the hasBuilding() method, I was kind of hoping for a hasShrine() and/or a hasWonder() method. It felt a little too weird using hard constant values when searching for the shrine wonders, but anyway.

Thanks for that.

Whenever you want info on anything, go do the CvInfos.h file. In this case, you want to know about buildings. So, find the CvBuildingInfo class. All those functions there tell you everything there is to know about a building, which typical line up directly with the layout of the XML files. If you want to find out about specialists in a building, you need to use the info file and the functions related to what you want to know about specialists.

Also, I can't remember what a shrine does, but it makes the city a holy city, right? The SDK has a isHolyCity function, which works a bit different. Rather than going through all the buildings, it just looks at the CvGame class and gets the city that is the holy city for a religion, and if that city turns out to be itself, it returns true:

Code:
bool CvCity::isHolyCity(ReligionTypes eIndex)
{
	return (GC.getGameINLINE().getHolyCity(eIndex) == this);
}


bool CvCity::isHolyCity()
{
	int iI;

	for (iI = 0; iI < GC.getNumReligionInfos(); iI++)
	{
		if (isHolyCity((ReligionTypes)iI))
		{
			return true;
		}
	}

	return false;
}
 
If you want to find out about specialists in a building, you need to use the info file and the functions related to what you want to know about specialists.
That I didn't think of. Thanks, I'll look into it.

Also, I can't remember what a shrine does, but it makes the city a holy city, right?
isHolyCity() will let me know if the city is a holy city but it wont tell me if there is a shrine there. A shrine is the wonder that lets the holy city get 1 gold per turn for every city with that religion in. The only way I can figure out how to detect a shrine is by checking to see if it's a holy city first and then do a switch statement looking for the Church of Nativity, The Kashi Wishwanath, The Mahabodhi, etc. It works, but I dunno, it feels a little unusually inflexible for how the SDK is set up. It allmost feels as though there was meant to be a isShrined() or hasHolyWonder() or something. But I cannot find one. Can't even make sense of the commerce algorithms that ultimately factor in the Shrine's gold as of yet so I cannot figure out how to detect it that way either (which I was hoping could be done). Not to worry. Thanks again.
 
Maybe they'll fix this in "Beyond the Sword".

I don't think so. It's not really "wrong" that the function isn't there, it's by design that they don't have it. A "shrine" is just one type of building, but there isn't a tag that makes one thing a shrine and another not (that I know of), but rather each shrine has similar XML changes (currency rates, etc.). The idea of a "shrine" is something we as players have come accustomed to describing a set of buildings, but I don't think the game differentiates between them aside from the XMLers putting similar entries into their XML and having the names indicate that they're shrines. They didn't make a way to distinguish if a city has a shrine because in the vanilla rules, a building being a shrine or not doesn't really mean anything, as all the shrine-related changes are already done-up in the XML.

The purpose is to allow all the changes to be controlled by the XML in multiple tags that can be used for different purposes rather than having one XML tag such as "bShrine" that does all the things that shrines do. This makes things a bit harder for the SDK programmer, but much easier for the XMLer. If you want to do something specific for buildings that are considered shrines, the "correct path" would be to have someone make a new building XML tag called "bShrine" and have them use that tag to do what you would want of the shrine.

BTW, I never really dealt with shrines much so I could be wrong here, but I've never seen anything in the SDK in my travels that sounds like what you're looking for.
 
If you want to do something specific for buildings that are considered shrines, the "correct path" would be to have someone make a new building XML tag called "bShrine" and have them use that tag to do what you would want of the shrine.
I would love to learn how to make tags and know how, when and where to insert the code into the SDK. I read a tut by Kael about adding custom tags but it got a little complicated. Hmmm. I've learned a bit since then so I might go explore it again.

Allthough I am still a novice in the SDK department, I have had ideas of turning more and more of the parrameters into tags so that more of the game can be customised using tags. It would be cool to say create the pop rushing ability to be able to pop different bonuses (like pop gold or pop research or what not) and do this solely from within XML by creating different XML tags that modify the existing function.
 
Back
Top Bottom