• 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

The difference is that the BuildingClassInfo has two buildings types: the 'normal' one and the 'specific' one.

There are different xml solutions to this:

Create a generic Pyramid Building not buildable at all (cost = -1) and make a Pyramid_Egypt building only buildable by Egypt in the CivilizationInfos file

OR

Make the Building_Pyramid with a Prereq Tech Nation_Egypt, disabled, only available to Egypt (eventually, this Tech could be conquered (as in certain mods) or acquired by any other xml means).

Tricks, tricks, tricks...
 
Yeah I've seen the moving backgrounds... I thought it was a static background with animations "on top of" or "in front of" it. No?

sorry I can't recall. It feels like 100 years since I made a leaderhead.
 
With the unique building, the way you did it sounded like the right way, you must have done something not quite right...

Can you post the xml section from the infos file?

It should look something like this:

Spoiler :
Code:
[COLOR="Red"]Egypt:[/COLOR]
			<Buildings>
				<Building>
					<BuildingClassType>BUILDINGCLASS_GIANT_USELESS_TRIANGLES</BuildingClassType>
					<BuildingType>BUILDING_GIANT_USELESS_TRIANGLES</BuildingType>
				</Building>
</Buildings>
[COLOR="Red"]Not Egypt:[/COLOR]
			<Buildings>
				<Building>
					<BuildingClassType>BUILDINGCLASS_GIANT_USELESS_TRIANGLES</BuildingClassType>
					<BuildingType>NONE</BuildingType>
				</Building>
</Buildings>

Although isenchines -1 build cost way is actually less work!
 
Thanks for your response isenchine (and your response on my other thread which I haven't replied to yet). I'm glad to hear there are several ways to do it.

About option 1 you suggested: Are you saying that because the great pyramids is classified as both normal and specific, it can never be truly specific without directing its "normal" tag to an alternate building? I think I can understand this. If that is the case, I will probably go this route.

About option 2 you suggested: I've never made a nation specific tech. What tag makes a nation specific tech and does it appear only on that nation's tech tree?

Thanks again!
---

mourndraken, that's ok. Thanks again!
 
With the unique building, the way you did it sounded like the right way, you must have done something not quite right...

Can you post the xml section from the infos file?

It should look something like this:

Spoiler :
Code:
[COLOR="Red"]Egypt:[/COLOR]
			<Buildings>
				<Building>
					<BuildingClassType>BUILDINGCLASS_GIANT_USELESS_TRIANGLES</BuildingClassType>
					<BuildingType>BUILDING_GIANT_USELESS_TRIANGLES</BuildingType>
				</Building>
</Buildings>
[COLOR="Red"]Not Egypt:[/COLOR]
			<Buildings>
				<Building>
					<BuildingClassType>BUILDINGCLASS_GIANT_USELESS_TRIANGLES</BuildingClassType>
					<BuildingType>NONE</BuildingType>
				</Building>
</Buildings>

Although isenchines -1 build cost way is actually less work!

Here's the code:
Spoiler :
</Cities>
<Buildings>
<Building>
<BuildingClassType>BUILDINGCLASS_PYRAMID</BuildingClassType>
<BuildingType>BUILDING_PYRAMID</BuildingType>
</Building>
</Buildings>
<Units>


Are you suggesting putting a NONE in for all other civs?
 
I think the way you make this kind of tech, is make the tech and give it cost -1 (this should make it unresearchable by anyone) then put it in the free tech section in egypts civ info

Spoiler :
Code:
			<FreeTechs>
				<FreeTech>
					<TechType>TECH_EGYPT</TechType>
					<bFreeTech>1</bFreeTech>
				</FreeTech>
				<FreeTech>
					<TechType>TECH_BAND_TOGETHER</TechType>
					<bFreeTech>1</bFreeTech>
				</FreeTech>
			</FreeTechs>

If the cost -1 option doesn't work, you can put it into all other nations <DisableTechs/> tag to make it unavailable to everyone but egypt (although I do not know the syntax for this one!)
 
yes, that is your issue, there is nothing to tell the game that this building is unique, because as you said above, everyone can build the default buildingclass building version.

So yeah after sleepily confusing the issue what you need to do is make the default version unbuildable (like isen said) then give the unique egypt version (which is the norma onel) to the egyptians.

So in buildinginfos copy paste any building (doesn't matter as no one will use it) give it BUILDINGCLASS_PYRAMID, then BUILDING_NOPYRAMID(or whatever you feel like) and give it an icost of -1(unbuildable)

then change the buildingclassinfo file entry to

Spoiler :
Code:
		<BuildingClassInfo>
			<Type>BUILDINGCLASS_PYRAMID</Type>
			<Description>TXT_KEY_PYRAMID</Description>
			<iMaxGlobalInstances>-1</iMaxGlobalInstances>
			<iMaxTeamInstances>-1</iMaxTeamInstances>
			<iMaxPlayerInstances>-1</iMaxPlayerInstances>
			<iExtraPlayerInstances>0</iExtraPlayerInstances>
			<bNoLimit>0</bNoLimit>
			<bMonument>0</bMonument>
			<DefaultBuilding>BUILDING_[COLOR="Red"]NOPYRAMID[/COLOR]</DefaultBuilding>
			<VictoryThresholds/>
		</BuildingClassInfo>

then it will work with what you have in the civinfo file.

Thinking about it, this is something I need to do myself for my Unique units, so that they display for civs in the 'chooser' info..
 
I too have a building question.

I want to change world wonders so every country can build one of their own if they want to. for example, every country will be able to build the pyramids once, for themselves. Now I know national wonders (NW) are already like that, and to make WWs like NWs I would only need to change their code in BuildingClassInfos to match that of a NW.
Code:
<iMaxGlobalInstances>-1</iMaxGlobalInstances>
<iMaxPlayerInstances>1</iMaxPlayerInstances>
However, the problem with NWs is that if you capture an enemy city that has a NW then NW will be destroyed. However I need the building to stay, like WWs stay after their city is captured.

you might ask "why would I want that"? The reason is, I want to make things like "The Great Dam" such that each nation would be able to make one (it would make sense), but it doesn't make sense for it to disappear as soon as the city is captured!!!

In other words, I need the building to have unlimited globalmax, as well as unlimited playermax, however the option for building a new one should only be available if the player doesn't have any yet or one isn't being built already by the player at the moment.

So that's how I think it should be done; but I don't know how. Any of you guys got any suggestions?
 
I think the short answer is not easily...

I think it would require sdk or python work...

I can't off the top of my head think of an xml trick to pull it off..

you would need something like cannot build in python.

Like if civ has building X, cannot build building X..

this may well still allow you to run multiple builds of it at the same time, but once you have one all the other build queues would get cancelled (like when someone finishs a WW).

what the code would look like though... :dunno:
 
I think my other option is to create 18 different WW which are identical and then associate each one with 1 civ so only that civ can build that one (PS. How do I do that??). but then If I wanna have 20 wonders I'd have to create 360 actual building entries, which is nuts! and I don't like.


Civ gods, help please.
 
Yes that would be 1 xml only way.

The way you would do that I think would be to make it like a unique building.

So pick your world wonder.

Then in building infos just copy paste the world wonder multiple times, (which wouldn't take too long if you copy paste, highlight both, copy paste, highlight all 4, copy paste, etc.)

Then just give each one a new BUILDING_NAME_FACTION entry in <type> for each faction

Then add the unique building entry into civilizationinfos like a few posts back and I think you are done, unless you also want unique text and art too.

it would certainly be long winded, but it wouldn't take THAT long, especially if you did a few wonders, did a different job, did a few wonders.

With copy paste all the hard stuff is done with a push of a few buttons..

hmm actually I am not sure that would work... as it would still read the building class as only allowing 1 in the world.

yeah this will get very long winded, you would need to add an entry for each in buildingclassinfos and change the <BuildingClass> and <Type> in the buildinginfos and add the NONE entry in civinfos like I showed a few posts back..

it's certainly not technically dificult to do, it would just take a while..

Otherwise you would need python or sdk work I think.
 
Creating multiple unique buildings within the same class wouldn't work because the building instance numbers are limited by class. I'd have to create 18 different classes. Not much different though, just even more copy pasting.

I'm wondering if there is a simpler way to do it through python. I don't wanna go SDK, it would be too complicated to find the logic path in SDK, too many jumps.
 
@Cyrus: something like this:

in CvGameUtils.py:

Spoiler :
Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		pPlayer = gc.getPlayer(pCity.getOwner())
		# iBuildingClass = gc.getBuildingInfo(eBuilding).getBuildingClassType()

		iKi = gc.getInfoTypeForString('BUILDING_KI_SHRINE')
		iEnki = gc.getInfoTypeForString('BUILDING_ENKI_SHRINE')
		iEnlil = gc.getInfoTypeForString('BUILDING_ENLIL_SHRINE')
		iInanna = gc.getInfoTypeForString('BUILDING_INANNA_SHRINE')
		iNanna = gc.getInfoTypeForString('BUILDING_NANNA_SHRINE')
		iUtu = gc.getInfoTypeForString('BUILDING_UTU_SHRINE')
		iAn = gc.getInfoTypeForString('BUILDING_AN_SHRINE')
		
		lShrines = [iKi, iEnki, iEnlil, iInanna, iNanna, iUtu, iAn]
		if eBuilding in lShrines:
			if eBuilding == iKi:
				if pPlayer.countNumBuildings(iKi) > 0:
					return True
			if eBuilding == iEnki:
				if pPlayer.countNumBuildings(iEnki) > 0:
					return True
			if eBuilding == iEnlil:
				if pPlayer.countNumBuildings(iEnlil) > 0:
					return True
			if eBuilding == iInanna:
				if pPlayer.countNumBuildings(iInanna) > 0:
					return True
			if eBuilding == iNanna:
				if pPlayer.countNumBuildings(iNanna) > 0:
					return True
			if eBuilding == iUtu:
				if pPlayer.countNumBuildings(iUtu) > 0:
					return True
			if eBuilding == iAn:
				if pPlayer.countNumBuildings(iAn) > 0:
					return True

		return False

It implies the 'CANNOT_CONSTRUCT' Python Callback to be set to 1. I'm talking about PythonCallbackDefines.xml directly under the xml folder.

The buildings can then be -1 in both instances. and 100 as iConquestProb. Unfortunately, the game will not consider them as wonders any more.

This code is a bit heavy for the game. Up to you.

PS: not tested. Strange as it seems, this code does not come from Gods of Old...

PS 2: you will not get any help text, just the button for the building should not appear on your list of buildable items if you have already one somewhere in your cities.
 
Does it matter how civilizations or anything else for that matter are listed in the xml? In civilizations, the civilizations are sorted alphabetically organized, if I reorder them into cultural groups, will that make a difference of any kind?
 
Does it matter how civilizations or anything else for that matter are listed in the xml? In civilizations, the civilizations are sorted alphabetically organized, if I reorder them into cultural groups, will that make a difference of any kind?

As long as you keep them in all the file without deleting, they should be fine. I don't think the order matters one bit on civilizations (Not sure about Barbarians though...).

Order does matter for terrain though. You can't just reorder it, because it makes grassland look like water if you put it after coast. :crazyeye:
 
What is the trigger for spawning human barbs?

It's handled in the dll - not sure if there's any xml global values established to manipulate these but there may be...
 
As long as you keep them in all the file without deleting, they should be fine. I don't think the order matters one bit on civilizations (Not sure about Barbarians though...).

Order does matter for terrain though. You can't just reorder it, because it makes grassland look like water if you put it after coast. :crazyeye:

Thanks!
 
What is the trigger for spawning human barbs?

You get either animals or barbs spawning in a turn. The default is barbs, but it is changed to animals in some cases.

If any of these checks is true it is set to the animals instead of the barbs:
  • the era the game is in (the average of the player eras, rounded down) has bNoBarbUnits set to 1 in CIV4EraInfos.xml
  • the total number of cities is less than the number of players currently alive * 3/2, rounded down, and is is not a Once City Challenge game
  • the number of turns played is less than the value of iBarbarianCreationTurnsElapsed as specified for your selected difficulty in the CIV4HandicapInfo.xml file multiplied by the value of your current game speed's iBarbPercent as specified in CIV4GameSpeedInfo.xml, divided by 100

That is it. If none of those are true it will do barbs. Well, it won't do either barbs or animals if you have the "No Barbarians" game option set since that is checked for first.

Note that you can get nothing instead of animals due to some other checks it does after picking animals. Specifically, it checks these 4 things and if any are true it does not attempt to do the spawning that turn:
  • the era the game is in has bNoAnimals set in CIV4EraInfos.xml
  • the game difficulty has iUnownedTilesPerGameAnimal set to 0 or less in CIV4HandicapInfo.xml
  • the total number of cities is less than the number of players that are currently alive in the game
  • the number of elapsed turns is less than 5

That pretty much covers it.

The first checks (and actual barb spawning, if it is not changed to animals) are in CvGame::createBarbarianUnits() and the animal checks (and spawning) are in CvGame::createAnimals(), which is run if it turns out that animals are the thing to try to spawn.
 
Nice one emperor, it looks like i have checked all of those except the gamespeed one, so I will give that a go and see what happens!

One other think, I used a bit of Kael code to make sure that animals are not killed when humans are spawning, would this cause any problems for spawning human barbs (sych as maybe barbs on map limit reached or some such?)

I also changed this bit to:

the total number of cities is less than the number of players currently alive * 3/2,

if (getNumCivCities() < ((countCivPlayersAlive()))

to try and get it happening sooner.. it didn't give any errors so I assume it will work?

EDIT:

Ok so don't know what I did, but I now have human barbs... fair enough :D thanks peeps!
 
Back
Top Bottom