Quick Modding Questions Thread

Actually, instead of asking 1000 questions, all the answers are pretty much in the Modiki itself.

Tech Cost will obviously be in TechInfos.xml, so just check the Modiki for TechInfo XML tags.

Double Production is tricky.
It is obviously either TraitInfos or BuildingInfos, (Answer is BuildingInfos actually)
 
EDIT: Also, how to change heal rate, for example, make units heal much slower in hostile territory?

Units do heal much slower in hostile territory, especially if no healer is in the stack. If there is a healer then it is only a little slower since the extra healing will overpower the base rate.

The only thing you can easily change is the base amount. That is controlled by the ENEMY_HEAL_RATE setting in GlobalDefines.xml (which is directly in the XML folder, not a sub-folder). Is set to 5 in BtS so healing to full will take 20 turns for a unit that is has 1 HP left, changing the heal rate to 2 would make it take 50 turns. There is no multiplier or other modifier you can apply via XML to healing from a healer type unit without modding the DLL (or doing something fancy in Python, like swapping out the healing promotions depending on whether or not the unit is in hostile territory). So with a unit gives just an extra 10 per turn in the stack it is only a difference of 10+5=15 vs. 10+2=12 if you change it to 2.
 
Is the "stripped mod" what you want?

Units do heal much slower in hostile territory, especially if no healer is in the stack. If there is a healer then it is only a little slower since the extra healing will overpower the base rate.

The only thing you can easily change is the base amount. That is controlled by the ENEMY_HEAL_RATE setting in GlobalDefines.xml (which is directly in the XML folder, not a sub-folder). Is set to 5 in BtS so healing to full will take 20 turns for a unit that is has 1 HP left, changing the heal rate to 2 would make it take 50 turns. There is no multiplier or other modifier you can apply via XML to healing from a healer type unit without modding the DLL (or doing something fancy in Python, like swapping out the healing promotions depending on whether or not the unit is in hostile territory). So with a unit gives just an extra 10 per turn in the stack it is only a difference of 10+5=15 vs. 10+2=12 if you change it to 2.

Yes! Thank you both!
 
I dont know if this is still considered a newbie question...and Im trying to ask less questions to avoid pissing people off. I made some tech changes, building, and upgrade changes without asking :D

1. One big change I'd like to make:

If
-a "dominating" ai or a human controls either directly or through vassals 40+% of the land
or
-Has "dominated" by reaching 85%% of the way towards a culture win
or
-Has "dominated" by reaching 85+% towards a space win

Then
-the other, non vassaled (known from now on as "Free"), Ais have a -2 negative diplomatic penalty towards the dominating civ (human or ai). "close to win penalty"
-the "free" ais are more likely to forgive past negative penalties between each other
-the "free" ais are more likely to ally each other even if they used to have an extreme hatred.
-the "free" ais are more likely to declare war and agree to go to war vs the dominating civ
-the "free" ais are much more likely to tech trade amonst themselves
-If the dominating ai was going for a culture win, the top three culture cities are priority targets
-If the dominating ai is going for a space win, the enemy capital is the priority target.

Other notes:
-As soon as the civ drops below 40% total land controlled (directly or indirectly) the penalties disappear and the diplomatic benefits of the "free" ais disappear.
-As soon as ai stops being 85+% toward a culture win, the penalties and the diplomatic benefits of the "free" ais disappear
-As soon as the ai stops being 85+% toward a space race, the penalties disappear and the diplomatic benefits of the "free" ais disappear.

2. One small change I'd like to make:
I would like the ai to keep at least 4 units in its capital at all times for protection with an extra 2 units per era added on top of that. I would like these ai capital defending units free from support costs as well (could be just a support reduction off the total number of units, it would be the same). Reason: capital sniping, especially along coast lines, is too strong a strategy vs the ai imo.

3. 3rd is a question. Has any modder really found a way to stop the human from abusing this scenario:

I have a ton of city attack cannons/artillery/whatever, I take a city from the ai and I use the final, city winning unit to be a horse unit that can take the city and move back out on the same turn. The ai then scrambles to retake the open city, and I repeat the use the super city attack units to demolish his army again and use a horse unit to retake the city and move back out. Not even sure how "exploitive" this concept is vs the ai.
 
It should remove PROMOTION_B when unit achieves PROMOTION_A (Unit has PROMOTION_B at start). Questions:
1. Why doesn't code work?
2. Is it possible to remove PROMOTION_B when unit achieves random 5th promotion?
Code:
	def onUnitPromoted(self, argsList):
		'Unit Promoted'
		pUnit, iPromotion = argsList
		player = gc.getPlayer(pUnit.getOwner())
## My mod Start ##
		if pUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_A")):
			pUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_B"), false)
## My mod End##
		if (not self.__LOG_UNITPROMOTED):
			return
		CvUtil.pyPrint('Unit Promotion Event: %s - %s' %(player.getCivilizationDescription(0), pUnit.getName(),))
 
3. 3rd is a question. Has any modder really found a way to stop the human from abusing this scenario:

I have a ton of city attack cannons/artillery/whatever, I take a city from the ai and I use the final, city winning unit to be a horse unit that can take the city and move back out on the same turn. The ai then scrambles to retake the open city, and I repeat the use the super city attack units to demolish his army again and use a horse unit to retake the city and move back out. Not even sure how "exploitive" this concept is vs the ai.
Good point here. I've used this strategy to devastating effect myself. The solution could really only be rooted in a very complex AI evaluation I think. Otherwise... eek. I call this the killing field strategy - you're turning the city into a killing field.

Trying to approach it from a game effect limitation ... I've not come upon a concept that would logically make sense to avoid this. However, I'm looking at trying to make some unit lines that are very good at attacking cities also very good at defending them so that making a 'stand' may still be a better option (though you'd still have to counteract the siege weapons being stronger on attack than defense somehow.)
 
Hi Thunderbird,

How about something like...retaking a city with a majority of your culture's people, gives you a free defender? Freedom fighters joining the cause etc etc.

That way the ai would at least get a free full health defender when they retook the city. It might not mean much but might help discourage the above scenario (maybe also give the free defender two free city defender upgrades)?
 
Hi Thunderbird,

How about something like...retaking a city with a majority of your culture's people, gives you a free defender? Freedom fighters joining the cause etc etc.

That way the ai would at least get a free full health defender when they retook the city. It might not mean much but might help discourage the above scenario (maybe also give the free defender two free city defender upgrades)?

It could help I guess. Not enough though I'd think. The Partisan mod I've seen implemented before is interesting and similar - cities taken by the enemy will spawn a number of powerful partisan fighters around the city. It can be a problem but it doesn't stop a good killing field.

What I have not done is run a test as to what would be a good way to go about things on this subject if, say, two human players were attempting to use the same strategy against each other. What would they do to get around the opponent? The fix would really be teaching the ai to USE the strategy as well as how to exploit an opponent trying to use it.

It could certainly wreak havok on war weariness on both ends if war weariness were brought into it a bit stronger, making it a peeing match between both parties which tests how well they've groomed their whole civilization too.
 
I would like for the castle to give protective civs an extra trade route (beyond the base 1 it already gives). So far my attempts have lead to alot of error messages
Heres what I tried (I have NO IDEA why my message cant just be displayed how I type it):

1. <iTradeRoutes>1</iTradeRoutes>
2. <iTradeRoutes> 3. <iTradeRoutesType>TRAIT_Protective</iTradeRoutesType>
4. <iTradeRoutes>2</iTradeRoutes>
5. </iTradeRoutes>

2. Is there anyway to encourage the ai to add great people to their capital city more often than just using them for tech?

3. Can I encourage the ai to use city attack and first strike drill upgrades for seige units and not barrage upgrades (barrage is weaker than drill imo).
 
Is there any way to mod the number of defending units held back in ai cities? There always seems to be about 2 city defenders during a long war, and I'd like to up that number of "minimum ai city defenders" to about 4 or 5. Not sure if its possible to double the minimum for the capital as well (as I asked earlier).

If you guy's dont know, is there more advanced mod help forum? I apologize for asking so many questions, Im just really excited and making alot of changes :D (most of which Im doing myself now).
 
I am fairly certain that would require modifying the SDK to change the ai behaviour, it might be possible with python as well...

but it would require writing new code for itas well as learning to recompile the .dll, which is not that hard if oyu read the tutorials, I mean if I can do it it really can't be that hard!
 
Is there any way to mod the number of defending units held back in ai cities? There always seems to be about 2 city defenders during a long war, and I'd like to up that number of "minimum ai city defenders" to about 4 or 5. Not sure if its possible to double the minimum for the capital as well (as I asked earlier).

If you guy's dont know, is there more advanced mod help forum? I apologize for asking so many questions, Im just really excited and making alot of changes :D (most of which Im doing myself now).

This is calculated in the DLL. In CvCityAI.cpp there is a function CvCityAI::AI_minDefenders() which calculates the basic minimum defender count that it wants in each city.

It is short, so here it is:
Code:
int CvCityAI::AI_minDefenders()
{
	int iDefenders = 1;
	int iEra = GET_PLAYER(getOwnerINLINE()).getCurrentEra();
	if (iEra > 0)
	{
		iDefenders++;
	}
	if (((iEra - GC.getGame().getStartEra() / 2) >= GC.getNumEraInfos() / 2) && isCoastal(GC.getMIN_WATER_SIZE_FOR_OCEAN()))
	{
		iDefenders++;
	}
	
	return iDefenders;
}

As you can see, if you can follow it, the calculated number is 1 with an additional 1 if the current era for the player is after the first era and another +1 if the city is on the coast and the current era (less 1/2 the start era, which is only not 0 if you did an advanced start) is greater than half way through the eras.

So, assuming no advanced start, for each city it is 1 in the first era (ancient) and 2 in every era after that unless it is coastal in which case it is 3 if you are at least in era 3 out of 7 (7/2 = 3 in integer math and the first era is actually era 0, so the 4th era which is numbered 3 is the first one to match the condition, therefore the renaissance or later).

There are other things which can make it want more than the minimum, particularly "danger" (using it's definition, which I won't go into), being the capital, having a wonder, and some other stuff. There are also "floating defenders" which may or may not be in the vicinity at any given time. But that low 1 to 3 value is the base.

Changing this minimum requires changing that function.
 
Thank you,

Yeah I can barely understand the code but I can recognize your instructions well enough. Ive made alot of changes to the xml so far so Im comfortable with making changes without destroying my game with errors.

Ok so Im going to change the first line to......int iDefenders = 4
and probably buff up the ai production a bit in the handicap xml.

1. How can I change the value so that there will be 2 more defenders after the first era? in case I want to fiddle around with the numbers...

2. Is there anything else you would recemmend I change here for more of a challenge vs the ai? (you are much smarter than me)

3. Kmod is the best ai mod Ive run into, has anyone of your level of programming skill have a more advanced one?
 
1. How can I change the value so that there will be 2 more defenders after the first era? in case I want to fiddle around with the numbers...

iDefenders++ means iDefenders = iDefenders + 1

So just change it to +2
 
Except, of course, that just changing the .cpp file won't do anything, You then have to compile the source code into a new DLL...

If you were not aware of that already, there are entire threads devoted to that topic. A tutorial by Asaf should be one of the first topics in down in the Modding Tutorials & Reference sub-forum.

K-mod is the most advanced AI mod available, as far as I know. A few other mods may be it's equal, or close, but they are merged with other features that make them much harder to add to another mod - you pretty much need to mod the mod they go with rather than just using the DLL for something else, or do a lot of work.
 
Hello,

Is there a way to change the maximum number of units allowed in a city? Something similiar to the way 4 default air units are allowed in a city, and then another 4 are allowed in the city once an airport is built?

I was thinking of making a mod something along the lines of:

default land units allowed in a city 0, land units allowed with barracks 10
default sea units allowed in a city 0, sea units allowed with harbor 10
default air units allowed in a city 0, air units allowed with airport 10

This would hopefully make the game a lot more realistic, the buildings very valuable, and also lead to a lot more open field battles.

Thanks
 
Back
Top Bottom