Quick Modding Questions Thread

I don't think you can without moddifying civic .dll code. (Which is not a quick question/answer sort of job!)

I think this is only a vanilla option for state religion.
I just checked the DLL code and the only option I see is the state religion option. It can be done by giving the leader a certain trait. However vanilla doesn't offer the option of adding/removing traits from python, which mean this doesn't help either. The production modifier code for the player has no python callback.

The only option I can find for general production modifier for a civic without modding the dll itself is this:
PHP:
int CvCity::getProductionNeeded(BuildingTypes eBuilding) const
{
	int iProductionNeeded = GET_PLAYER(getOwnerINLINE()).getProductionNeeded(eBuilding);

	// Python cost modifier
	if (GC.getUSE_GET_BUILDING_COST_MOD_CALLBACK())
	{
		CyArgsList argsList;
		argsList.add(getOwnerINLINE());	// Player ID
		argsList.add(getID());	// City ID
		argsList.add(eBuilding);	// Building ID
		long lResult=0;
		gDLL->getPythonIFace()->callFunction(PYGameModule, "getBuildingCostMod", argsList.makeFunctionArgs(), &lResult);

		if (lResult > 1)
		{
			iProductionNeeded *= lResult;
			iProductionNeeded /= 100;
		}
	}

	return iProductionNeeded;
}
Somebody tell how to activate this callback. I prefer never to use them as they are an inferior approach to mod the dll itself and I'm actually not sure how to use it.

From what I can tell, you need this:
  1. A python function called getBuildingCostMod.
  2. Activate GC.getUSE_GET_BUILDING_COST_MOD_CALLBACK (presumably some xml setting somewhere)
  3. Get the player ID from the first argument.
  4. Return 0 if player doesn't exist (shouldn't happen, but it adds to stability and you better be safe than sorry).
  5. Return 75 if the player has the civic
  6. Return 0 in all other cases

75 is because you return what you should pay and 75 = 100 -25. 0 is a special number meaning no change and do not calculate a new value.

It should be noted that the AI will not consider this bonus when figuring out which civic to use. To do that, you would have to mod the DLL. Also there is no GUI code, meaning pedia and such will not show the bonus. That too is intended to be placed in the DLL.
 
So I want to take the bonus that already exists for state religions and modify it so that it exists without, and this requires DLL editing? Please someone tell me why modding Civ IV is considered "easy?"

EDIT: This isn't DLL, but I still have no idea how to get to that line of code.
 
DIT: This isn't DLL, but I still have no idea how to get to that line of code.
To be fair, I copy pasted code from the DLL. However I wrote that it should be able to be triggered from xml/python and being inexperienced in running python from C++ (I prefer going the other way for technical reasons), I asked for somebody to tell how to activate the callback.
 
XML folder: PythonCallbackDefines.xml : USE_GET_BUILDING_COST_MOD_CALLBACK

Python Folder : CvGameUtils.py : def getBuildingCostMod
 
Well, unfortunately I have to contradict you in that it is not the mod to blame, but something you have done as I have just taken it out of the box and it works as advertised.

When the guantlet is thrown down an idiot shall arise, that idiot is me!

Germany and France are now at permanent war... The end of stinky cheese and large sausage is nie... God Help Us All!!!

Chances are you need to put it in the xml folder of your mod, not a customxml folder, and change the appropriate file paths as if you are running blue marble then it is not an unmodified state.

You are either running a mod with blue marble, or have changed the base structure of the game...(Never a good idea!)

if that is still not right, then you will need to start a thread and show your working, because you are clearly doing something that is incorrect, but no one can know what that is unless you show exactly what you are doing, then maybe someone will spot the error that you are making.
I AM NOT TO BLAME! How can I be to blame when:
1.I did not modify the mod, I just unzipped it and placed it RIGHT INTO my mod folder, not modifying anything.
2.I did not modify the base game, I'd bet my life on it
3. Blue Marble does not modify XML or Python files, only graphics
4. All other mod things by platyping work for me, except this one
 
I AM NOT TO BLAME! How can I be to blame when:
1.I did not modify the mod, I just unzipped it and placed it RIGHT INTO my mod folder, not modifying anything.
2.I did not modify the base game, I'd bet my life on it
3. Blue Marble does not modify XML or Python files, only graphics
4. All other mod things by platyping work for me, except this one

This is none of my business, but as former PC tech, I would suggest to work by process of elimination:
Remove the Blue Marble mod, or use a separate install version of the game, and put your new thing there - see if it works by itself, without anything else.
 
PHP:
	def getBuildingCostMod(self, argsList):
	iPlayer, iCityID, iBuilding = argsList
	pPlayer = gc.getPlayer(iPlayer)
	pCity = pPlayer.getCity(iCityID)
	
	iCostMod = -1 # Any value > 0 will be used
	
	# civic cost mod - start
	iCivic = 0
	if pPlayer.isCivic(iCivic):
		return 75
	# civic cost mod - end
	
	return iCostMod
That should do it for the code. Change iCivic to whatever number your civic has in xml. You could use "gc.getDefineINT("civic_type")", but that would slow down the game even more. For once I would recommend just hardcoding the number as I fear for the performance of this change.

I attached the modded file because tabs are essential to get correct in python. Experience tells that copy pasting from the forum causes issues.

Read what isenchine wrote on how to enable.

While this is completely untested, it should do what you ask for. Well sort of. It has -25% production requirements. You could set it to return 80, which would be -20% requirements, which is the same as +25% production if you ignore the rounding errors.
 

Attachments

Remove the Blue Marble mod, or use a separate install version of the game, and put your new thing there - see if it works by itself, without anything else.
But the Blue Marble mod makes everything look better, I think I'd rather have that than a python component that I will probably use for only one mod, if it had worked.
 
You are either running a mod with blue marble, or have changed the base structure of the game...(Never a good idea!)

if that is still not right, then you will need to start a thread and show your working, because you are clearly doing something that is incorrect, but no one can know what that is unless you show exactly what you are doing, then maybe someone will spot the error that you are making.

Not quite correct as there is a third option. If I remember correctly you can run Blue Marble without modifying the mod or the base game. You do it by installing the BM in the My Documents Mods (or is it the Custom Assets?) folder and the mod in the install Mods folder then tell Civ to load any stuff in the My Documents folder at the same time as the Mod. It is that just like me most modders have forgotten about this possibility and that some mods wont work with these "extra assets". I can't remember how to turn loading them off.

edit I really should not be trying to answer stuff when I am not well;) I missed all the posts after the one I answered.
But the Blue Marble mod makes everything look better, I think I'd rather have that than a python component that I will probably use for only one mod, if it had worked.

If I remember correctly there is something somewhere about turning Custom Assets off for a particular mod. That is what you need here. I think we did it in Caveman2Cosmos at one stage to stop people using Blue Marble with C2C since BM has far fewer terrains and so crashes C2C but I can't remember how and I am still waiting for my modding machine to be fixed so I can't look it up. I think it is in one of the ini files. Either the one with the mod or the normal Civilization.ini.
 
IT'S THE UNMODIFIED VERSION! I repeat: the gold shiny hud is because of Blue Marble, which, as far as I'm aware of, modifies no XML or python.

I can't even get it to work by placing the mod straight into my mod folder. I repeat tjhat I'm not the one to blame, because a mod should be working by placing it in the mod folder. And it doesn't work, try to download the mod yourself so you can confirm that it doesn't work or does work.


It works fine for me.
 
Breaking news: The mod DOES work if it's located in the Program Files directory of Civ4:BtS
 
Breaking news: The mod DOES work if it's located in the Program Files directory of Civ4:BtS
It seems to be required if you custom assets or something like that. However I would recommend installing outside of Program Files due to write permission issues. Installing in C:\games works quite well and it allows git to write to the mod directory. This mean assuming you set up the git repository correctly, then you can pull changes directly into the mod and you instantly have updated your mod with changes made by other people.

Granted you can make a symbolic link inside Program Files if you like, but it's more work and most of us likely have to google how to do that each time a new one is needed.
 
Problem solved by putting mod into Program Files directory.

I still have another problem: in my Ancient Middle East mod, all religions are present at the start of the game, with the exception of Buddhism and Christianity. I recently added a tech called Theology to my mod, but Christianity gets autofounded a few turns regardless of its required technology, is there some fix for this? Or a way to circumvent this, as I'd really rather have Christianity or Buddhism not be present in 2900 BC.

This is quite game-breaking, as it's not supposed to be founded until 30 AD.
EDIT:This also happens to Buddhism, which requires Meditation, a midgame tech.
 
PHP:
	def getBuildingCostMod(self, argsList):
	iPlayer, iCityID, iBuilding = argsList
	pPlayer = gc.getPlayer(iPlayer)
	pCity = pPlayer.getCity(iCityID)
	
	iCostMod = -1 # Any value > 0 will be used
	
	# civic cost mod - start
	iCivic = 0
	if pPlayer.isCivic(iCivic):
		return 75
	# civic cost mod - end
	
	return iCostMod
That should do it for the code. Change iCivic to whatever number your civic has in xml. You could use "gc.getDefineINT("civic_type")", but that would slow down the game even more. For once I would recommend just hardcoding the number as I fear for the performance of this change.

I attached the modded file because tabs are essential to get correct in python. Experience tells that copy pasting from the forum causes issues.

Read what isenchine wrote on how to enable.

While this is completely untested, it should do what you ask for. Well sort of. It has -25% production requirements. You could set it to return 80, which would be -20% requirements, which is the same as +25% production if you ignore the rounding errors.

I'll use this if I have to, but I don't understand why it isn't simpler to adapt a mechanic that already exists in the game, and only needs the state religion requirement removed. Even if I could only have one or the other, it's not as if I have any plans for the original mechanic.
 
So I want to take the bonus that already exists for state religions and modify it so that it exists without, and this requires DLL editing? Please someone tell me why modding Civ IV is considered "easy?"

EDIT: This isn't DLL, but I still have no idea how to get to that line of code.
I'll use this if I have to, but I don't understand why it isn't simpler to adapt a mechanic that already exists in the game, and only needs the state religion requirement removed. Even if I could only have one or the other, it's not as if I have any plans for the original mechanic.
Because the original mechanic is coded in the DLL obviously. If you want to adapt and modify it that means you have to edit the DLL.

Civ4 modding is considered easy because everything is made available for you to edit as source code in a widely known programming language. It does not mean that you don't need to know anything about programming, are excused from doing research or putting in any effort of your own.
 
I'll use this if I have to, but I don't understand why it isn't simpler to adapt a mechanic that already exists in the game, and only needs the state religion requirement removed. Even if I could only have one or the other, it's not as if I have any plans for the original mechanic.
What you are asking for is altering the existing feature to skip the religion check. Sure it's doable and it would likely be the best solution. However the change would have to be in the DLL itself. The DLL requires people to install and use a compiler and it seems most users really, REALLY want to avoid doing that, which is the reason for the python+xml solution.

I have said it multiple times that I would prefer everybody to use git and set up the compiler. That makes it much easier and faster to just go ahead and write code for people and everybody will be happy. It seems that close to 0 people listen to what I say about this though :cry:
 
@Archid, @Nightinggale:
Thank you for answer, i must say that Archid is software engineer which have more than 15 years of experience in IT (sorry if i miss or said some wrong info), that is man which really know what he does. I will accept your tips and agree with you. I just must said that my idea is really bad, and can't be resolved on way which i asked, but that just was a idea. I know what is object and what is thread, i was asked this because i don't have vision how that all works, lots of units and buildings with lots of orders and their attributes (health, speed, supplies, type, building time and etc), and because i was think maybe they use threads as help or synchronization for all that entire actions. I will search for some engine on web, thank you for answer again.

@Nightinggale:
The ideal solution would be to have one barbarian for each city as that would create complete anarchy with everybody attacking everybody, like the civil war in China 1800 years ago (the romance of the 3 kingdom event)
Yes, that will be great, maybe to add 2, max 3 INDEPENDENTS which will be at war with everyone, but they will be on global level, if my capital fall they will be revolt, and if neighbor capital fall they will revolt too, and if rebels are from same INDEPENDENTS they build some like global empire of rebels.

@platyping:
Just set them as minor civs. Minor civs behave like barbs, at war with all and no diplomacy, but are not barbs.
If i do that it will spawn a new civilization in game and that will take one slot for player, for example if i have 2 of 50 (2/50) players in game there will be 3/50 in game, but what if i have 50/50 players in game, this option is than not acceptable, there will not be more slots for any players. Your idea is good i can use this, but if i have 50/50 i will than must to use barbarians. Thank you Platy! But i will first try to add several new BARBARIAN PLAYERS, 50 + 1 barb = 51, i will try 50 + 3 barb = 53.
 
Back
Top Bottom