Modders Guide to FfH2

Ok, but how would I make the fields how up for the second improvement?

I'm afraid you just have to copy everything in Lsystem with the word "improvement_farm" in it, and change in the copied lines "farm" to "farm_grigori" or whatever the code is for your improvement.
 
While merging my modmod with patch K, I run into a bug.

Playtesting as Malakim, I could not grow cottage. Mouse-tip stated '15 turns become Hamlet' but the number of turns never recede. After 50+ turns, I finally conclude that there is something wrong :D.

Play several more games and it turned out that this bug affects human-player improvement's growth-rate. I was also unable to grow Bedouin Sits or Dwarven Mines. AIs in my games were just fine; they were able to grow their cottages, Dwarven mines etc.

My modmod was based on FfH 40z. Mostly add spells, units, promotions and graphics. What files/functions did I mess up when merging with patch K? Any help, please?

Thanks.
 
While merging my modmod with patch K, I run into a bug....it turned out that this bug affects human-player improvement's growth-rate.

I think I found the culprit. This tag in CIV4CivicInfos.xml made human-player improvements stagnate.

Code:
<iImprovementUpgradeRateModifier>25</iImprovementUpgradeRateModifier>
and 
<iImprovementUpgradeRateModifier>-10</iImprovementUpgradeRateModifier>

It is strange, IMO. I tinkered with this code since 40z and everything was fine. Does patch K did something with this tag?

Oh well... going to merge with patch L now... :crazyeye:
 
I have a problem I am trying to fix for two days now...

I want to add a tag to feature infos to limit a feature for one civ only (it is the upgrade of standard jungle, I want it to upgrade in lizard civilization territory only - the civ stems from FF but the tag I started with is standard FfH code)

So, I copied all instances of PrereqStateReligion related to features, and currently have:

CvInfos.cpp
Code:
17872: m_iCivilizationNeeded(NO_CIVILIZATION),
17998: int CvFeatureInfo::getCivilizationNeeded() const
18000: 	return m_iCivilizationNeeded;
18215: 	pXML->GetChildXmlValByName(szTextVal, "CivilizationNeeded");
18216: 	m_iCivilizationNeeded = GC.getInfoTypeForString(szTextVal);
CvInfos.h
Code:
4426: 	int getCivilizationNeeded() const;
4495: 	int m_iCivilizationNeeded;
CvPlot.cpp (inside if regarding features requiring state religion)
Code:
9857:             	if ([COLOR="Red"]GC.getFeatureInfo((FeatureTypes)GC.getFeatureInfo(getFeatureType()).getFeatureUpgrade()).getCivilizationNeeded() == NO_CIVILIZATION[/COLOR]
9858:               	|| isOwned() && GC.getFeatureInfo((FeatureTypes)GC.getFeatureInfo(getFeatureType()).getFeatureUpgrade()).getCivilizationNeeded() == GET_PLAYER(getOwnerINLINE()).getCivilizationType())
Also:
CIV4FeatureInfos.xml
Code:
820:             <CivilizationNeeded>CIVILIZATION_TLACATL</CivilizationNeeded>
CIV4TerrainSchema.xml
Code:
130: 	<ElementType name="CivilizationNeeded" content="textOnly"/>
168: 		<element type="CivilizationNeeded" minOccurs="0"/>

It compiles fine. Game works fine, but somehow the requirement is ignored - the jungle upgrades to deep jungle everywhere. I think the line marked in red is responsible - tried to change it to (false) and jungle stopped upgrading at all. It is like the requirement of CIVILIZATION_TLACATL is overwritten by NO_CIVILIZATION (or not loaded at all)

I am out of ideas... Anyone has any?
I will post the files if needed.
 
you need to use readpass3. defaultunit in unitclassinfos is an example of a tag that uses readpass3. When you load your variable via readpass1, the game hasn't loaded information about civilizations yet, so it assumes CIVILIZATION_TLACATL is NO_CIVILIZATION.
 
Thanks for the quick reply - and a one that is exactly what I needed.

I have already modified the code, but have to wait till I am back from work to test it.
Looks like I have learned something new today :)
 
Yeah if you look at CvXMLLoadUtilitySet.cpp you'll see the load order of XML files.

In comparison to readPass3, readPass2 is used for a second run at the same file, and is used for example when an entry have a requirement from the same file.

To enable readPass2, if it's not enabled, you need to change a false to a true in that file on that files LoadGlobalClassInfo function.

To enable a readPass3 you need to add a loop like you see in that file.
 
Thanks for the explanation Grey Fox, I would probably have missed it.

I have adjusted the code and now it works flawlessly :)
 
It's a good idea to always open up CvXMLLoadUtilitySet.cpp whenever you are adding a new tag which references out of file, the only time I don't is if the other file is already referenced in this file, in which case I am cloning that other reference so automatically wind up in pass1 or 3 as needed.
 
It's a kinda important file :P (especially if you want to add your own xml files, which you have done so you HAVE been in that file :P)
 
I'm trying to write it so that Infernal Pact is a ritual that will summon the Infernals under a a random Demon Lord (from Lord of the Balors), where the ritual has a world limit of 7 but each team can only use it once. I've done this before about 2 years ago, but I did not move that code to my new computer and have deleted everything from my old one.


Could someone remind me how to check to see is a leader has ever been present in a game?
 
I'm trying to write it so that Infernal Pact is a ritual that will summon the Infernals under a a random Demon Lord (from Lord of the Balors), where the ritual has a world limit of 7 but each team can only use it once. I've done this before about 2 years ago, but I did not move that code to my new computer and have deleted everything from my old one.


Could someone remind me how to check to see is a leader has ever been present in a game?

Something like this, I believe:

Code:
for i in range(CyGame().countCivPlayersEverAlive()):
	pPlayer = gc.getPlayer(i)
	iLeaderType = pPlayer.getLeaderType()
	if iLeaderType == gc.getInfoTypeForString('LEADER_HYBOREM'):
		#Do something
 
That looks more complicated than I remember it, and would be really complex for me to add 7 demon lords to a list iff they had not been in the game before.



Edit: Ah, I just searched my old post and found that I had shared my code here a little over a year ago.

It seems I may just use if not CyGame().isLeaderEverActive(gc.getInfoTypeForString('LEADER_HYBOREM')):
, and similar for each leader.
 
Alright, I'm trying to modify my leash code so that I can have a leash of 0 (Basically held, but leash ranges stack so it can be expanded). The code for that is working. Problem is the promotion tag is refusing to default to the correct value....

Basically, if I allow a valid input of 0, I can't simply move it to -1; Negative values are valid, as you can shrink the leash. I tried defaults of -100, -99, and 100; All of them are ignored and it defaults to 0. Why is it doing this? Any ideas?
 
Where are you setting the default?

m_iLeash(0),

early in the file is useless.

pXML->LoadData("iLeashLength", m_iLeash);

This line needs to change (note, the actual load command is not right, I don't remember what they are as I just cut/paste them so never memorized it)

pXML->LoadData("iLeashLength", m_iLeash, -100);

Now it will have a default of -100 instead of 0. There is an implied 0 in this call and if the tag isn't found, the default value is loaded.
 
Well, I feel intelligent. I'd completely forgotten that I needed to change the default on that line too....

I'd actually already gotten it working by adding a new bool, but this is better. :lol:

Thanks! :goodjob:

Adding a LeashChance atm, by the way... Adds a rand from 0 to the LeashChance of the promotion to the unit's range when the promo is gained. ;)
 
Back
Top Bottom