• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Quick Modding Questions Thread

How can you build improvements inside enemy territory? I'm trying to make an Entrench ability, but it's not really working.
 
How can you build improvements inside enemy territory? I'm trying to make an Entrench ability, but it's not really working.

I'm not sure, but there is some chance that you could do it via Python and the canBuild function in CvGameUtils.py.

If that does work, there is still a very good chance that the AI will never do so, even if it can, without making it do so in the DLL or some Python AI override.
 
I'm trying to make my religion screen wider. I changed self.W_SCREEN = 1024 to a higher number, which makes the screen wider but it is no longer centered. I have tried changing many other values but nothing has worked.
 

Attachments

  • religion screen problem.JPG
    religion screen problem.JPG
    138.1 KB · Views: 60
I changed the Eras in my mod and made 3 new ones instead. I even edited all the appropriate files for the era change (LSystem and whatnot). There's only one small problem. When I load the mod I get one error:
Tag: ERA_ANCIENT in Info class was incorrect.
Current XML file is: xml\GameInfo/Civ4ForceControlInfos.xml
And then the game still loads.

So I went to the file...
Code:
<?xml version="1.0"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Firaxis Games (Firaxis Games) -->
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->
<!-- -->
<!-- ForceControlInfos - This structure describes the name for each multiplayer option. -->
<Civ4ForceControlInfos xmlns="x-schema:CIV4GameInfoSchema.xml">
	<ForceControlInfos>
		<ForceControlInfo>
			<Type>FORCECONTROL_SPEED</Type>
			<Description>TXT_KEY_FORCE_CONTROL_SPEED</Description>
			<Help>TXT_KEY_FORCE_CONTROL_SPEED_HELP</Help>
			<bDefault>0</bDefault>
		</ForceControlInfo>
		<ForceControlInfo>
			<Type>FORCECONTROL_HANDICAP</Type>
			<Description>TXT_KEY_FORCE_CONTROL_HANDICAP</Description>
			<Help>TXT_KEY_FORCE_CONTROL_HANDICAP_HELP</Help>
			<bDefault>0</bDefault>
		</ForceControlInfo>
		<ForceControlInfo>
			<Type>FORCECONTROL_OPTIONS</Type>
			<Description>TXT_KEY_FORCE_CONTROL_OPTIONS</Description>
			<Help>TXT_KEY_FORCE_CONTROL_OPTIONS_HELP</Help>
			<bDefault>0</bDefault>
		</ForceControlInfo>
		<ForceControlInfo>
			<Type>FORCECONTROL_VICTORIES</Type>
			<Description>TXT_KEY_FORCE_CONTROL_VICTORIES</Description>
			<Help>TXT_KEY_FORCE_CONTROL_VICTORIES_HELP</Help>
			<bDefault>0</bDefault>
		</ForceControlInfo>
		<ForceControlInfo>
			<Type>FORCECONTROL_MAX_TURNS</Type>
			<Description>TXT_KEY_FORCE_CONTROL_MAX_TURNS</Description>
			<Help>TXT_KEY_FORCE_CONTROL_MAX_TURNS_HELP</Help>
			<bDefault>0</bDefault>
		</ForceControlInfo>
		<ForceControlInfo>
			<Type>FORCECONTROL_MAX_CITY_ELIMINATION</Type>
			<Description>TXT_KEY_FORCE_CONTROL_MAX_CITY_ELIMINATION</Description>
			<Help>TXT_KEY_FORCE_CONTROL_MAX_CITY_ELIMINATION_HELP</Help>
			<bDefault>0</bDefault>
		</ForceControlInfo>
		<ForceControlInfo>
			<Type>FORCECONTROL_ADVANCED_START</Type>
			<Description>TXT_KEY_FORCE_ADVANCED_START</Description>
			<Help>TXT_KEY_FORCE_ADVANCED_START</Help>
			<bDefault>0</bDefault>
		</ForceControlInfo>
	</ForceControlInfos>
</Civ4ForceControlInfos>
I have a feeling it has to do with the Adv. Start, but does anyone know where I can fix this one small error?
 
Is it possible to change how many cities you must have on a landmass to grant independence to a colony? I want to grant independence to ALL the 1 tile islands.
 
@topsecret: did you delete the ERA_ANCIENT?

xml\GameInfo/Civ4ForceControlInfos.xml is the last xml file to load before the menu so simply the error points to this last file and it is misleading you. There is a big chance that there is nothing wrong with that file, especially if you did not touch it.

I remember having had the same problem with one xml tag. I don't remember exactly but I think I found it in a Python file somewhere, nothing to do with ForceControlInfos.
 
Lib.Spi't was right. It was in the GlobalDefines.xml. Thanks for the help. :hatsoff:

So you mean I was wrong. OK, I'm so sorry that I could not help you... :p
 
Is it possible to change how many cities you must have on a landmass to grant independence to a colony? I want to grant independence to ALL the 1 tile islands.

The section that checks conditions to be met for enabling colonies is in CvPlayer.cpp in your uncompiled DLL folder called CvGameCodeDLL per default.

Here's the function in question:

Code:
bool CvPlayer::canSplitArea(int iAreaId) const
{
	CvArea* pArea = GC.getMapINLINE().getArea(iAreaId);
	CvCity* pCapital = getCapitalCity();

	if (NULL == pCapital)
	{
		return false;
	}

	if (NULL == pArea || pArea == pCapital->area())
	{
		return false;
	}

	if (0 == pArea->getCitiesPerPlayer(getID()))
	{
		return false;
	}

	PlayerTypes ePlayer = getSplitEmpirePlayer(pArea->getID());
	if (NO_PLAYER == ePlayer)
	{
		return false;
	}

	if (!GET_PLAYER(ePlayer).isAlive())
	{
		if (pArea->getCitiesPerPlayer(getID()) <= 1)
		{
			return false;
		}
	}

	return true;
}

I think the last conditional structure "if" checks that one city or less means a colony cannot be sprouted. Just change it to simply: pArea->getCitiesPerPlayer(getID()) <1

Regarding how to compile into a new DLL, there are tutos all over the modding forums. Just don't forget the original .dll file to be saved elsewere before trampling with the new one.

Drop a note if it works. :)
 
And the million dollar question is:
Why did they bother to check getCitiesPerPlayer twice...
 
And the million dollar question is:
Why did they bother to check getCitiesPerPlayer twice...

Thanks to point out my mistake. I fumbled between functions and took the wrong one. Nevertheless, you should point it out in a more direct manner since you are ten times more versed into Civ coding than I am.

@CivDad (if ever still interested)

canSplitArea() is the function that checks if the area (an area is a landmass; an one tile island is an area too) fits the caracteristics to allow a colony, like:

  • No capital (can happen in certain mods) means no possibility to create a colony.
  • If this is not an area (water tiles???) OR the area shares with the capital (same landmass check), then no colony possible.
  • If there is no city in that particular area (landmass), evidently, no colony can be created.
  • If one landmass has already one colony, then getSplitEmpirePlayer() function returns NO_PLAYER, and thus you can't get two colonies on a same landmass. I'm really not sure about getCitiesPerPlayer()<1...a colony controlling a landmass without even a city or a half...not sure what it means.

In the end, it seems the wrong function. Nonetheless, the function above that one in CvPlayer.cpp seems the right one.

Code:
bool [COLOR="Green"][B]CvPlayer::canSplitEmpire()[/B][/COLOR] const
{
	int iLoopArea;

	if (GC.getGameINLINE().isOption(GAMEOPTION_NO_VASSAL_STATES))
	{
		return false;
	}

	if (GET_TEAM(getTeam()).isAVassal())
	{
		return false;
	}

	CivLeaderArray aLeaders;
	if (!getSplitEmpireLeaders(aLeaders))
	{
		return false;
	}

	bool bFoundArea = false;

	for (CvArea* pLoopArea = GC.getMapINLINE().firstArea(&iLoopArea); pLoopArea != NULL; pLoopArea = GC.getMapINLINE().nextArea(&iLoopArea))
	{
		if (canSplitArea(pLoopArea->getID()))
		{
			bFoundArea = true;
			break;
		}
	}

	if (!bFoundArea)
	{
		return false;
	}

	return true;
}

It checks if you can get the colony at all.

  • NO VASSALS OPTION evidently means no colonies.
  • If the list of leaders runs out, then no colonies. Often seen in huge maps.
  • If the player (AI or not) is a vassal, you can't create a colonies (vassals of vassals don't exist in base BTS; PAE mod has it though).
  • At last, it goes through the caracteristics of an area for allowing a colony, thus canSplitArea() is a child function of canSplitEmpire().


And great while writing this, I fumbled even more because I haven't found what was been asked. :confused:

EDIT: Maybe I'm litterally in the wrong file....:dunno:

==

Found this too about the pop-up button. Doesn't seem to correspond to the appearance of the button, but what happens if the button is pressed...

Code:
bool CvDLLButtonPopup::launchFreeColonyPopup(CvPopup* pPopup, CvPopupInfo &info)
{
	int iLoop;
	PlayerTypes ePlayer = GC.getGameINLINE().getActivePlayer();
	if (ePlayer == NO_PLAYER)
	{
		return false;
	}

	gDLL->getInterfaceIFace()->popupSetBodyString(pPopup, gDLL->getText("TXT_KEY_FREE_COLONY"));

	if (GET_PLAYER(ePlayer).canSplitEmpire())
	{
		for(CvArea* pLoopArea = GC.getMapINLINE().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMapINLINE().nextArea(&iLoop))
		{
			if (GET_PLAYER(ePlayer).canSplitArea(pLoopArea->getID()))
			{
				CvWString szCityList;
				int iCityLoop;
				int iNumCities = 0;
				for (CvCity* pLoopCity = GET_PLAYER(ePlayer).firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(ePlayer).nextCity(&iCityLoop))
				{
					if (pLoopCity->area()->getID() == pLoopArea->getID())
					{
						if (!szCityList.empty())
						{
							szCityList += L", ";
						}
						++iNumCities;

						szCityList += pLoopCity->getName();
					}
				}

				CvWString szBuffer = gDLL->getText("TXT_KEY_SPLIT_EMPIRE", szCityList.GetCString());
				gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, szBuffer, ARTFILEMGR.getInterfaceArtInfo("INTERFACE_BUTTONS_CITYSELECTION")->getPath(), pLoopArea->getID(), WIDGET_GENERAL);
			}
		}
	}
 
Actually, your previous post already answered the question.
He wanted to know how to grant independence to even 1 tile islands.
Changing getCitiesPerPlayer for that area will be the solution.
The only question as I mentioned is, why check the same condition twice in the same function.
Firaxis coders are fond of doing things in inefficient and redundant ways.

And P.S.
Water tiles also form an area of their own.
The null check is to check whether the area is valid in the first place.
 
Firaxis coders are fond of doing things in inefficient and redundant ways.

They (or Soren Johnson...?) enrolled students to code their stuff. :p
But it wouldn't make the best Civ of the franchise because Active Enterprises did that and it made the worst game of history. :lol:


And P.S.
Water tiles also form an area of their own.
The null check is to check whether the area is valid in the first place.

I think I've heard about each water mass is also an area.
:crazyeye:

Comments in blue.

Hey, if I have a question, can I ask it to you in a PM? Sometimes, the DLL coding makes me all :eek: and :cry:.
 
Yup, every water tile that is connected belongs to the same area ID.
Similarly every land tile connected belongs to same ID.

Not much point asking me dll questions since I don't mod sdk
 
Is there a comprehensive list of all the XML tags that are unused in current BtS? For example in CivicsInfos there are some tags for faster Great General birth and increased Production for State REligion.
 
Back
Top Bottom