Modders Guide to FfH2

I made a function that will dismiss Eidola, Druids and Paladins if the owner is not Evil/Neutral/Good. I did it with these :

in CvEventManager.py
Spoiler :
Code:
		if pPlayer.getAlignment() != gc.getInfoTypeForString('ALIGNMENT_GOOD'):
			cf.doTurnPaladin(iPlayer)
		
		if pPlayer.getAlignment() != gc.getInfoTypeForString('ALIGNMENT_NEUTRAL'):
			cf.doTurnDruid(iPlayer)

		if pPlayer.getAlignment() != gc.getInfoTypeForString('ALIGNMENT_EVIL'):
			cf.doTurnEidolon(iPlayer)

Is there any way to make these more resources friendly? Suppose, is there any command to check whether a civ has just changed alignment? Thus, I can make the code run only after a specific civ changed its alignment, not on every turn.

Thanks.
 
I made a function that will dismiss Eidola, Druids and Paladins if the owner is not Evil/Neutral/Good. I did it with these :

in CvEventManager.py
Spoiler :
Code:
		if pPlayer.getAlignment() != gc.getInfoTypeForString('ALIGNMENT_GOOD'):
			cf.doTurnPaladin(iPlayer)
		
		if pPlayer.getAlignment() != gc.getInfoTypeForString('ALIGNMENT_NEUTRAL'):
			cf.doTurnDruid(iPlayer)

		if pPlayer.getAlignment() != gc.getInfoTypeForString('ALIGNMENT_EVIL'):
			cf.doTurnEidolon(iPlayer)

Is there any way to make these more resources friendly? Suppose, is there any command to check whether a civ has just changed alignment? Thus, I can make the code run only after a specific civ changed its alignment, not on every turn.

Thanks.

They already require an alignment, so just make them bAbandon (like religious heroes); Once you no longer meet their requirements, they will disband.
 
Yes, bAbandon only checks a certain set of prereqs, so without modification to the DLL to include alignment among those checks, it won't work that easily.

Alignment can only change when religion changes in base FfH, so place your check in the python function for changing religion.
 
CvCityAI.cpp and AI_chooseproduction in cvgameutils.py

OK. A couple of more questions.

I'm looking for the section of code where the AI decides the following (preferably in Python as I have no tools or knowledge for dealing with the C++ code):

1) When/where to settle new cities
2) When to go into and out of ConquestMode

Also, in the cvgameutils.py file, I have several variables that I want to access from, the ChooseProduction, ChooseTech and AIUpdate functions. Currently I'm just recreating the variables in each function. Is there one central spot where I can create these variables? And is it a good idea to do so or would it be better to keep them within the functions?
 
How much of a slowdown/burden is it for turn processing to add events that trigger when conditions are met? I assume the event checking will occur every turn until the conditions are met.

For example, the Goblin Waste event gives a -1 food penalty to a plot unless you have Nature Mana. I was thinking of adding a Goblin Waste Continued event that would have the original Goblin Waste -1 food event as a condition. When/if the player gets Nature Mana, the Continued Event would fire and give back the 1 food taken away. I am also thinking of using this similar idea for a few events I am writing.

These events could take many turns or even never fire if the player never gets the Mana of the event. So, would this be a drain on turn processing making it not worth implementing?
 
There is a random check to see if you will get an event for the turn, and if that passes, THEN the events are checked to see which ones are allowed to trigger for you. As I recall, the chance for an event is 5% or lower, so it isn't a hefty overhead. Especially since most checks are pretty quickly determined as not allowed.
 
OK. A couple of more questions.

I'm looking for the section of code where the AI decides the following (preferably in Python as I have no tools or knowledge for dealing with the C++ code):

1) When/where to settle new cities
2) When to go into and out of ConquestMode

Also, in the cvgameutils.py file, I have several variables that I want to access from, the ChooseProduction, ChooseTech and AIUpdate functions. Currently I'm just recreating the variables in each function. Is there one central spot where I can create these variables? And is it a good idea to do so or would it be better to keep them within the functions?

1.) both calculation for which plots to settle and orders for settlers are done in the DLL. In general very difficult to change.
2.) AI will never leave Conquestmode. Code to enter Conquestmode is in techacquired event in CvEventmanager.py

It very difficult to save values in python. What you can do is to create a function CalculateYValue and then have that function return YValue and call the function whenever you need it.
 
try newUnit.setDuration(iTurns)

don't know of a python function that allows you to modify the basemoves, but you could use the same promotion that keeps Acheron in his City.

I'm getting a syntax error using the setDuration code as written above, trying both (iTurns) and (5). Should there be more to that line of code I as a relative Python tyro don't see?

Also, good idea on the Acheron promotion - I don't need the unit to cast spells so it works perfect.
 
1.) both calculation for which plots to settle and orders for settlers are done in the DLL. In general very difficult to change.

Hmmm... is there anything I can change in the python to affect city spots? Mainly, I'm looking to do some tweaks regarding coasts. The AI seems very reluctant to settle on marginal coastline, which really hinders it on Archipelago maps and other times where it gets stuck on an island chain.

2.) AI will never leave Conquestmode. Code to enter Conquestmode is in techacquired event in CvEventmanager.py

I guess I misunderstood what Conquestmode was for. I thought it was to get them to ramp up for war. What effect does being in Conquestmode have on the AI?

It very difficult to save values in python. What you can do is to create a function CalculateYValue and then have that function return YValue and call the function whenever you need it.

Yeah. I realized after I posted that what I was asking for didn't really make sense. Setting the variables within the functions is really what I wanted to do anyway.
 
The AI seems very reluctant to settle on marginal coastline, which really hinders it on Archipelago maps and other times where it gets stuck on an island chain.

I've also noticed numerous times where the AI would ship a settler + troops over to a one-tile island (presumably to found a city and grab the nearby resources), but then once there, no city would be built and the units would stand around indefinitely.
 
An AI in Conquestmode will build a higher standing army. It also might make war plans. SoD act more aggressive.

There is a bug (or at least there was last time I checked) in base FFH that keeps units which can't move (everything on a 1 tile island for example) from doing anything. It's easy to fix but requires DLL modification.

the calculation for good plots to found cities is in the DLL and over 1000 lines long (in CvPlayerAI:: AI_foundvalue or so)

maybe if you increase the yields from coast tiles the AI will build more cities on archipelago maps
 
I am trying (and failing) to acces terain features via python.
In perticular, I want a code that equates to:

If(improvement(x,y) == forest)
do something

Any advice on how to do that?
 
I am trying (and failing) to acces terain features via python.
In perticular, I want a code that equates to:

If(improvement(x,y) == forest)
do something

Any advice on how to do that?

Forests are features, not improvements. Something like this will work (Ripped from Flame Spread code):

Code:
iFeature = pPlot.getFeatureType()
	
if iFeature == -1:
    return

if (iFeature == gc.getInfoTypeForString('FEATURE_FOREST')):
    do Something
 
Thanks, you are a lifesaver.
 
Back
Top Bottom