Quick Modding Questions Thread

Last edited:
You have the right constant: it defines how much production one population point is "worth" when using it to draft a unit. The expended population needs to cover the production cost of the unit, i.e. [unit cost] / CONSCRIPT_POPULATION_PER_COST.

(It should probably be named COST_PER_POPULATION...)
 
If I wanted to make two separate civics options not allowed to be used together [for example, free speech and theocracy], what would I have to do to block one being used w the other?
Edit the dll.
AND2 has such dll changes. If you know what you are doing you can mine it out.

I'm not sure but I think it should also be possible via python.

But if you're looking for some easy XML change than the bad news is that such does not exist.
 
XML does not support implementing this rule, but you can do it in Python. The DLL calls the cannotDoCivic function when checking if you can select a civic. You can implement it in Assets/Python/EntryPoints/CvGameInterface.py. If the function returns true, the civic is not allowed. So you can check whether its counterpart is already in use and disallow the other.

It's possible that you have to also enable something like USE_CANNOT_DO_CIVIC_CALLBACK in the XML defines. I only have a BUG code base on hand where this is required, but it's possible that the base game does not require this setting.
 
I am wanting to double the movement cost of desert; yet in the XML there terraininfos for desert, there is only imovement which seems to be set to 0 or 1. Then, when I check featureinfos, there is only oasis for desert, which is set at 2. How can I apply this to desert, as well?
 
You can just set iMovement to 2 for the terrain as well.
 
Ok; great, thanks for the help with those. One additional thing I'd like is for the random maps to place Iron more often than it currently does. What can I change to increase it on the map, say 25%?
 
I don't know, I am not familiar with the details of map scripts.
 
Ok; great, thanks for the help with those. One additional thing I'd like is for the random maps to place Iron more often than it currently does. What can I change to increase it on the map, say 25%?
I think it can be done in xml by increasing some weight for the bonus, but I can't remember the details.
 
I think it can be done in xml by increasing some weight for the bonus, but I can't remember the details.
The only thing I see, so far, is in Civ4ImprovementInfos; where there are bonus aluminum, coal, copper, gems, gold, iron, silver, uranium --- and the iDiscoverRand is set to 1000 for each. Is this what you're referring to? If so, do you have any suggestions on changing the discoverRand figure of 1000 for iron?
 
The only thing I see, so far, is in Civ4ImprovementInfos; where there are bonus aluminum, coal, copper, gems, gold, iron, silver, uranium --- and the iDiscoverRand is set to 1000 for each. Is this what you're referring to? If so, do you have any suggestions on changing the discoverRand figure of 1000 for iron?
No, that's the chance of an improvement discovering the resources if the tile is worked by a city.
What you need is iConstAppearance
Use the modified for information like this:
 
iDiscoverRand controls the chance for an improvement to randomly discover a resource on their tile, e.g. when you sometimes randomly discover gold on a tile with a mine on it.
 
Question for anyone who may have some thoughts:
.
I think one of the biggest AI deficiencies is lack of air units and failure to have air superiority late in the game.
.
I am considering having Cavalry and infantry have an upgrade path to fighters [in my mod, MMod, I have removed most techs in the modern era -- no SAMs, no helicopters] and so fighters and bombers are essentially the last units to come into the game.
.
Does anyone have any thoughts on how the AI might treat upgrading infantry and Cavalry to fighters [if it matters, I have also made Cavalry upgraded to tanks since no helicopters]
 
A cursory look at the unit upgrade AI tells me that:
  • It's invidually decided for each unit (no player wide optimization of what to upgrade first)
  • An upgrade to a unit is considered if it is available, the player has sufficient gold and it has a higher "unit value" than the current value
  • The unit value is determined using a fairly complex function, it's the same that is used e.g. to decide which unit to build
  • If multiple upgrades satisfy these conditions one is chosen randomly (was a bit shocked to see that)
  • Considerations like switching to a different domain type (e.g. land to air), combat type (e.g. mounted to air) or unit AI type (e.g. attack to intercept) are not relevant in this decision
So my expectation is that it would work as long as the AI considers air units more valuable than cavalry units in the first place.

But also, this really has many places for improvement. I'm sure that Advanced Civ and similar mods are doing a better job than the baseline AI.
 
I assume this is decided in sdk and not python? [I can work w python, I cannot w sdk]
Generally speaking, all AI code is inside the dll file for performance reasons. However it's rarely hardcoded, which means it can be heavily influenced by xml. If you feel like the AI builds too few of some unit or building, usually you can adjust this somewhat by increasing the AI weight in xml of that unit/building. The AI picks on metrics, which is way more complex than just a single number through. For instance it is more likely to build units matching the current strategy, like likelihood of building a city defending unit depends on risk of war and how many such units the city already has. This is on top of the weight from xml.
 
I'm not sure if anyone has any experience modding these numbers or not, but I'll ask for any guidance:

The unitinfos has, iAIWeight, and the Wiki explains this as, "The preference given by the AI to this unit, generally for Unique Units." Review shows that every unit is set to '0' ... if I want the AI to create substantially more air units - fighters and bombers - does anyone know what I should set this at? Does it matter if every unit is set to zero at default? If I set it to 50 am I going to get insane results? I don't have any frame of reference ...
 
Last edited:
You can use debug mode to look up AI unit weights that result from normal AI evaluations:
Spoiler big screenshot :

1754462877300.png


I believe those generally stay double or low triple digits. Since iAIWeight is simply additive to the final result, it is a rather blunt tool, as unless you explicitly forbid those, it might force a square peg into a round hole, making a unit "fit" for a role it wouldn't normally be considered for. I had at some point AI exploring with battering rams. :lol:
 
Back
Top Bottom