• 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

And the million dollar question is:
Why did they bother to check getCitiesPerPlayer twice...

Sometimes it is better to check something twice rather than making code which is not easily to understand. It also makes it easier to test and maintain. In the case shown all the code for an call to the function at an inappropriate (or invalid) game state are caught first. This is good practice for error handling for function based coding. Not so much for object oriented coding.

Although I agree, in the bit of code shown, doing one test would not have made the code difficult to understand.
 
The first test checks if number of cities is 0 while the second test checks if the same value is less than or equal to one.
Obviously the second test is enough since it covers the first test as well.

Writing redundant codes just leads to more chance of errors, inefficient waste of performance and a waste of time for other coders to read the same thing twice.

Of course, if it is just once in a blue moon, you may argue that it won't affect performance much, but if I can spot it in just a randomly pasted chunk of codes, I doubt this kind of redundancy is once in a blue moon.

Anyway, if a non sdk modder like me can understand, I doubt it will be confusing to a real sdk modder to remove this kind of useless codes
 
Three questions For the Pros :D :
(unit and building xml)

1.If I set a high ai weight and ai assets rating for unique land units in the xml will that lead to fewer naval invasions or are land and naval units figured differently? The other half of the coin, If I set high ai weight/asset to naval units will that cause a deficit of land units?

2. Dry Docks are set to "production flavor", does that mean that the Ai does not count Naval units as "military" or should I add the military flavor tag to Dry Docks as well for greater ai efficiency?

3. Im running kmod and Im not sure whether the Ai can use great generals to make military academies efficiently so I made them buildable at a huge hammer cost. It is listed as "military flavor" in the xml, would adding production flavor as well to the xml flavors list make the ai more effective?
 
Two questions For the Pros :D :

1.If I set a high ai weight and ai assets rating for unique land units in the xml will that lead to fewer naval invasions or are land and naval units figured differently?

2. Dry Docks are set to "production flavor", does that mean that the Ai does not count Naval units as "military" or should I add the military flavor tag to Dry Docks as well for greater ai efficiency?

Trying to understand a special diplo action from K-mod? ;)
 
I have an issue I want to put out there and see if anyone has any ideas what the problem may be.

It is regarding adding civs to the BetterBatAI mod.

I have downloaded Canada civ by Duminos, and I attempted to put it into the BetterBatAI mod using the "custom_civilizations" folder under assets/modules directory.
The new civ appears in the game, and is selectable as playable.
The game starts and units (settler and scout) are on the map. You can move either unit, discover huts, explore, but when I give the command to "found city" to the settler, the settler turns into a city, the name option comes up, you select the name, and then the game crashes. It seems to me that going to the city screen is what crashes the game, but it is possible that it is unrelated to the crash.

Anyone ever encounter a similar problem?:confused:
 
Is there a way to disable the occasional popup that says that such and such a city can be given to another Civ? Has anyone ever selected yes - I can't see why I'd ever want to do that - and if I did I could just go into the Diplo menu and gift it to him.

About two months after the question was asked, I saw that it was done in the file CvAdvisorUtils.py in the def cityAdvise function. Looks easy enough to disable the popup or to reduce its occurence if you know a little bit of Python.
 
I have <iRazeCityProb> set to zero for all the leaders in my mod, but cities still get razed. does anyone know why this is?

nevermind I found the code
 
I have <iRazeCityProb> set to zero for all the leaders in my mod, but cities still get razed. does anyone know why this is?

nevermind I found the code

:( Oh. I was about to write about it. Ok never mind. Was it in CvPlayerAI.cpp?
 
yes. but also CvCity::isAutoRaze. this where cities which have never grown past size 1 are autorazed and also something about MaxCityElimination being greater than zero.
 
yes. but also CvCity::isAutoRaze. this where cities which have never grown past size 1 are autorazed and also something about MaxCityElimination being greater than zero.

Yeah, but I thought you meant the AI decision onto razing cities, not razing independent of their will.

IIRC of MaxCityElimination, it was about scenarios if you lose a certain number of cities, the rest are razed. Like CivIII with the king units....? Anyways, I vaguely remember situations where the AI lost a num of cities and then the rest was razed...I don't recall how it worked. Of course, this thing doesn't really exist in typical games of civ.
 
If I modify religions so that later ones (e.g. Christianity and Islam) spread faster than earlier ones (e.g. Buddhism and Hinduism), if I enable Choose Religions, will religions founded earlier or later than they are normally founded, would religions have the same spread rates as they are normally, or of the religion usually founded with that tech? For example, if Christianity spreads at 400, and Hinduism founds at 100, would Christianity spread at 100 if I found it with Polytheism with the Choose Religions options on, or would it just spread at 400?
 
As far as i know the spread rate is the one in the XML and is not affected by Choose religions. Also the default BtS mechanism only affects the religion that will appear in new cities or cities without a religion in them.
 
Is there a way I can give selective promotion bonuses? I want drill 3 and drill 4 to provide +5% interception chance for machine guns only.
 
Is there a way I can give selective promotion bonuses? I want drill 3 and drill 4 to provide +5% interception chance for machine guns only.

You'd have to make a tag for that.

Interesting idea though. hmm... I've had a few experiences so far where if I'd thought about it enough I might've realized this would be a good way to address it.

Of course, with C2C multiple Subcombats on units, I'd prefer to use wider categories than unit types to define these selective promotion bonuses.

The unfortunate thing would be that you'd need a tag for EACH type of bonus you wanted. So I suppose it would probably be better to have a tag that added a free add-on promo when that promo is owned by a particular unit type or unitcombat. Then you could use the free add-on to address any of the given promotion tags.

Come to think of it... in C2C I could do this by making the promo grant another combat class to the unit and the combat class could carry those modifiers! So in a sense... in C2C we DO have this ability.
 
Right, so I'm not a modder by any stretch of the imagination, although I have done some very simple XML editing from time to time. I've been trying to change the available starting era of some Wonders- specifically, I want to play a Modern- or Future-era game but still be able to build all my NWs. So I changed the MaxStartEra on National Epic from "ERA_RENAISSANCE" to "NONE". Real easy change... it just doesn't work. I still can't build NE, and the Civilopedia still says "Can only be built on Renaissance and earlier starts".

I had a similar problem in a previous game, being unable to change the obsolete tech of a couple of things. I've been able to change the XML to alter leader traits, UU/UBs, that sort of thing. I have no idea why this change isn't working. Anybody know? Thanks.
 
Right, so I'm not a modder by any stretch of the imagination, although I have done some very simple XML editing from time to time. I've been trying to change the available starting era of some Wonders- specifically, I want to play a Modern- or Future-era game but still be able to build all my NWs. So I changed the MaxStartEra on National Epic from "ERA_RENAISSANCE" to "NONE". Real easy change... it just doesn't work. I still can't build NE, and the Civilopedia still says "Can only be built on Renaissance and earlier starts".

I had a similar problem in a previous game, being unable to change the obsolete tech of a couple of things. I've been able to change the XML to alter leader traits, UU/UBs, that sort of thing. I have no idea why this change isn't working. Anybody know? Thanks.

Yeah, I remember you had da same problums. Hope true modders will help ya here compared to Beginner's Question thread. :blush:
 
Back
Top Bottom