Advertisement
Civilization Fanatics' Center  

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - SDK/Python

Reply
 
Thread Tools
Old Feb 21, 2012, 06:57 PM   #1
OrionVeteran
Deity
 
OrionVeteran's Avatar
 
Join Date: Dec 2003
Location: Newport News VA
Posts: 2,043
Question Prerequisite Era not based upon a tech

I have 7 special buildings (National Wonders), all with different names that coincide with an era. I want to be able to build one of these buildings in each era. I do not want to give any of the the wonders a prerequisite tech. For example, any Tech in the Medieval era meets the prerequisite to build the Medieval version of this building. In SDK, how can I parse the name of a building to get an era? Once I have the building era, I can then compare it to the Player's current era to confirm "canBuild" elligibility. Here is what I have so far. I'd like to make it more efficient.

Spoiler:

Code:
	if (eBuilding == GC.getInfoTypeForString("BUILDING_ANCIENT_MYSTERIES"))
	{
		if ((EraTypes) GET_PLAYER(getOwnerINLINE()).getCurrentEra() != GC.getInfoTypeForString("ERA_ANCIENT"))
		{
			return false;
		}
		else
		{
			if (getNumRealBuilding(eBuilding) > 0)
			{
				return false;
			}
		}
	}
		
	if (eBuilding == GC.getInfoTypeForString("BUILDING_CLASSICAL_MYSTERIES"))
	{
		if ((EraTypes) GET_PLAYER(getOwnerINLINE()).getCurrentEra() != GC.getInfoTypeForString("ERA_CLASSICAL"))
		{
			return false;
		}
		else
		{
			if (getNumRealBuilding(eBuilding) > 0)
			{
				return false;
			}
		}
	}
		
	if (eBuilding == GC.getInfoTypeForString("BUILDING_MEDIEVAL_MYSTERIES"))
	{
		if ((EraTypes) GET_PLAYER(getOwnerINLINE()).getCurrentEra() != GC.getInfoTypeForString("ERA_MEDIEVAL"))
		{
			return false;
		}
		else
		{
			if (getNumRealBuilding(eBuilding) > 0)
			{
				return false;
			}
		}
	}
		
	if (eBuilding == GC.getInfoTypeForString("BUILDING_RENAISSANCE_MYSTERIES"))
	{
		if ((EraTypes) GET_PLAYER(getOwnerINLINE()).getCurrentEra() != GC.getInfoTypeForString("ERA_RENAISSANCE"))
		{
			return false;
		}
		else
		{
			if (getNumRealBuilding(eBuilding) > 0)
			{
				return false;
			}
		}
	}
		
	if (eBuilding == GC.getInfoTypeForString("BUILDING_INDUSTRIAL_MYSTERIES"))
	{
		if ((EraTypes) GET_PLAYER(getOwnerINLINE()).getCurrentEra() != GC.getInfoTypeForString("ERA_INDUSTRIAL"))
		{
			return false;
		}
		else
		{
			if (getNumRealBuilding(eBuilding) > 0)
			{
				return false;
			}
		}
	}
		
	if (eBuilding == GC.getInfoTypeForString("BUILDING_MODERN_MYSTERIES"))
	{
		if ((EraTypes) GET_PLAYER(getOwnerINLINE()).getCurrentEra() != GC.getInfoTypeForString("ERA_MODERN"))
		{
			return false;
		}
		else
		{
			if (getNumRealBuilding(eBuilding) > 0)
			{
				return false;
			}
		}
	}
		
	if (eBuilding == GC.getInfoTypeForString("BUILDING_FUTURE_MYSTERIES"))
	{
		if ((EraTypes) GET_PLAYER(getOwnerINLINE()).getCurrentEra() != GC.getInfoTypeForString("ERA_FUTURE"))
		{
			return false;
		}
		else
		{
			if (getNumRealBuilding(eBuilding) > 0)
			{
				return false;
			}
		}
	}
__________________
Check Out Orion's Grand Inquisitions Mod
http://forums.civfanatics.com/downlo...=file&id=13380

Last edited by OrionVeteran; Feb 21, 2012 at 08:30 PM.
OrionVeteran is offline   Reply With Quote
Old Feb 21, 2012, 10:48 PM   #2
Tholal
Emperor
 
Join Date: May 2009
Posts: 1,423
Unless you want to add in an XML tag that assigns a specific era to buildings, that's pretty much the way to do it.

You can get rid of all those getNumRealBuilding checks, though. That should already be handled if you have the buildings defined as National Wonders.

You could also replace those multiple calls to getCurrentEra with a variable instead.

Code:
EraTypes eCurrentEra = GET_PLAYER(getOwnerINLINE()).getCurrentEra();
and then use that variable for the comparison test. It wont make things any faster but it will make the code a bit cleaner and easier to read.
__________________

More Naval AI (an AI mod for FFH2) - focusing on bugfixes, stability and AI improvement
Tholal is offline   Reply With Quote
Old Feb 22, 2012, 08:17 AM   #3
OrionVeteran
Deity
 
OrionVeteran's Avatar
 
Join Date: Dec 2003
Location: Newport News VA
Posts: 2,043
Quote:
Originally Posted by Tholal View Post
Unless you want to add in an XML tag that assigns a specific era to buildings, that's pretty much the way to do it.

You can get rid of all those getNumRealBuilding checks, though. That should already be handled if you have the buildings defined as National Wonders.

You could also replace those multiple calls to getCurrentEra with a variable instead.

Code:
EraTypes eCurrentEra = GET_PLAYER(getOwnerINLINE()).getCurrentEra();
and then use that variable for the comparison test. It wont make things any faster but it will make the code a bit cleaner and easier to read.
Thanks for the tips.
__________________
Check Out Orion's Grand Inquisitions Mod
http://forums.civfanatics.com/downlo...=file&id=13380
OrionVeteran is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - SDK/Python > [SDK] Prerequisite Era not based upon a tech

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Advertisement

All times are GMT -6. The time now is 12:53 AM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
This site is copyright Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR