davidlallen
Deity
A few weeks back I posted a problem where national limits on buildings had a funny result, see this thread. In that case I was able to trace the code and find a solution, but now I have a similar problem for national units and I cannot find the problem in the code.
I have attached a tiny mod in which axemen have a national limit of 3 units, and they have a cost of 1 and AIWeight of 200. This should make the AI tremendously interested in building them.
In the python of the tiny mod, I have created a logfile (c:\stats.csv) which lists when axemen are created and killed. It seems that the national limit is not respected at all by the AI. That is, with a national limit of 3, I see messages that a civ has built 4, without any being killed.
For buildings, there is a place where if the game detects too many national buildings, it randomly deletes one. So the effect is correct, but the hammers spent building the extra illegal building are wasted. For units, it seems that the game is also deleting them; that is, when I scan around, I cannot find all four of the axemen that were built.
Can anybody point me to the code which is deleting a unit, when the national lmit is exceeded? If I can find the code, I can perform a fix similar to what I did for national buildings.
The underlying reason may be that the AI does not respect the national limit when constructing units. Finding and fixing that place would be even better, since when the game silently deletes the unit the hammers are wasted.
This is a problem for Dune Wars, because there is a new unit "Mentat" I am trying to introduce with a national limit of three. It has a complex script which fires in onUnitBuilt that has side effects lasting until a matching onUnitKilled, expecting that only three of these side effects will ever happen at a time for a given civ. But I am seeing dozens of these effects happening at once for a given civ. I can see the onUnitBuilt script called dozens of times, but only a small number of Mentat units are visible on the map, and onUnitKilled is not called enough to explain the difference. So my assumption is that the AI is building too many, and the game is silently deleting them without calling onUnitKilled.
I have attached a tiny mod in which axemen have a national limit of 3 units, and they have a cost of 1 and AIWeight of 200. This should make the AI tremendously interested in building them.
In the python of the tiny mod, I have created a logfile (c:\stats.csv) which lists when axemen are created and killed. It seems that the national limit is not respected at all by the AI. That is, with a national limit of 3, I see messages that a civ has built 4, without any being killed.
For buildings, there is a place where if the game detects too many national buildings, it randomly deletes one. So the effect is correct, but the hammers spent building the extra illegal building are wasted. For units, it seems that the game is also deleting them; that is, when I scan around, I cannot find all four of the axemen that were built.
Can anybody point me to the code which is deleting a unit, when the national lmit is exceeded? If I can find the code, I can perform a fix similar to what I did for national buildings.
The underlying reason may be that the AI does not respect the national limit when constructing units. Finding and fixing that place would be even better, since when the game silently deletes the unit the hammers are wasted.
This is a problem for Dune Wars, because there is a new unit "Mentat" I am trying to introduce with a national limit of three. It has a complex script which fires in onUnitBuilt that has side effects lasting until a matching onUnitKilled, expecting that only three of these side effects will ever happen at a time for a given civ. But I am seeing dozens of these effects happening at once for a given civ. I can see the onUnitBuilt script called dozens of times, but only a small number of Mentat units are visible on the map, and onUnitKilled is not called enough to explain the difference. So my assumption is that the AI is building too many, and the game is silently deleting them without calling onUnitKilled.