Modders Guide to FfH2

Any chance that the xml schema changes I requested in the .31 change log will be added?

1. add a civic prereq tag to CIV4SpellInfos.xml

2. add a prereq alignment tag to CIV4SpellInfos.xml

3. add a block alignment tag to CIV4SpellInfos.xml

4. add a block alignment tag to CIV4UnitInfos.xml

5. add a <PyPerTurn tag> to CIV4UnitInfos.xml (working just like the tag in CIV4PromotionInfos.xml)

6. add more python tags to CIV4UnitInfos.xml and CIV4PromotionInfos.xml, which would be called when the unit is created, killed, is un-summoned, fights a battle, kills a unit, captures a unit, when a promotion wears off, when a unit gains a level, when a unit is upgraded, when a unit moves, etc.

7. allow many of the tags in the CIV4SpellInfos.xml file to take a python function that returns a number (or maybe even returns boolean, a promotion, unitcombat, unit class, unit, etc., depending on the tag) instead of just taking a number (or boolean, etc). (I was wanting to determine how long a spell immobilizes a unit using a python define. I can just have the whole spell work though python, but this way would be more efficient I think)

8. Allow python calls in CIV4SpellInfos.xml to take a list of valid targets (determined by the various tags like bAlilve, bImmuneTeam, bRange, etc) instead of just pCaster. I think this could make many spells much more efficient, since the python calls wouldn't need to cycle through tiles and every unit on the tiles to find valid targets. That process could be handled in C++ instead.

I'm also still hoping that buildings can grant any amount of any number of resources (instead of the same number of no more than 3), that civics grant xp based on unitcombat, and all the other xml suggestions I mad in the past. My most recent requests do seem like they would be simpler ways to make modmoding easier though.
 
Probably not. Every check I add slows down the game so unless we are going to use it I don't want to put it in. Remember you don't just want a schema change, you want a change to the source code to make the check work.

So, for example, if I added block alignment to the spell definition then it would be called thousands of time per turn. Every unit evaluates every spell every turn, so in a game with 300 units (which is a pretty low number) they each check to see if they should use each of the 200 spells. Which is 60,000 checks against the block alignment each turn.

Thats a pretty big simplification, a lot can be done with the ordering of the checks to try to optomize. But it gives a good feeling for why we don't add checks unless we really think we can use them. It slows everyone down.
 
I am not a modder at all, but I tried to change the trait of a leader.
I found an xml what contained the leader names and the traits, but even if i changed any of it, in the game it remained the original. (sorry i cant remember the xml name, i was looking for it 30 min and forgot it in one day:))
i only wanted to change the trait not add one, and i copied the trait string from another leader, so it was set up well.

i used total commander for browsing the mod, it was able to extract the xml and copy back after the modification, if it counts.

my question is, how may file i need to modifiy for this simple change and what are they?

Thank you for any of your answer in advance.
 
Probably not. Every check I add slows down the game so unless we are going to use it I don't want to put it in. Remember you don't just want a schema change, you want a change to the source code to make the check work.

So, for example, if I added block alignment to the spell definition then it would be called thousands of time per turn. Every unit evaluates every spell every turn, so in a game with 300 units (which is a pretty low number) they each check to see if they should use each of the 200 spells. Which is 60,000 checks against the block alignment each turn.

Thats a pretty big simplification, a lot can be done with the ordering of the checks to try to optomize. But it gives a good feeling for why we don't add checks unless we really think we can use them. It slows everyone down.

:( too bad. I guess I'll just have to keep copying and pasting the same little snippets of python code then.

Still, some of my other requests don't involve so many checks, do they? For instance, whats the problem with the way I suggested making buildings provide resources:
Code:
<FreeBonuses>
    <FreeBonus>
        <FreeBonusType>BONUS_MANA_SPIRIT</FreeBonusType>
        <iNumBonus>2</iNumBonus>
    </FreeBonus>
    <FreeBonus>
        <FreeBonusType>BONUS_MANA_LIFE</FreeBonusType>
        <iNumBonus>1</iNumBonus>
    </FreeBonus>
    <FreeBonus>
        <FreeBonusType>BONUS_MANA_WATER</FreeBonusType>
        <iNumBonus>1</iNumBonus>
    </FreeBonus>
</FreeBonuses>

or, a little less importantly, adding:
Code:
<UnitCombatFreeExperiences>
    <UnitCombatFreeExperience>
        <UnitCombatType>UNITCOMBAT_MELEE</UnitCombatType>
        <iExperience>2</iExperience>
    </UnitCombatFreeExperience>
    <UnitCombatFreeExperience>
        <UnitCombatType>UNITCOMBAT_MOUNTED</UnitCombatType>
        <iExperience>2</iExperience>
    </UnitCombatFreeExperience>
</UnitCombatFreeExperiences>
to CIV4CivicInfos.xml and maybe CIV4SpecialistInfos.xml.



Also, I think that adding prerequisite techs to the code that applies the weapons promotions is really necessary, even if it does add an extra check per unit per turn. (And even though I'm thinking about just setting WEAPON_PROMOTION_TIER1, WEAPON_PROMOTION_TIER2, and WEAPON_PROMOTION_TIER3 to none and instead granting the weapons through spells that require techs, resources, buildings and gold, maybe even making these weapons "quasi-equipment" with different strengths and weaknesses. In that case my modmod need this change, but I still think it is needed in the main mod)


Edit: one simple change that I would find very helpful is to allow a promotion to grant a bonus vs multiple promotions, like:
Code:
<PromotionCombats>
    <PromotionCombat>
        <PromotionCombatType>PROMOTION_DARK_ELF</PromotionCombatType>
        <iPromotionCombatMod>50</iPromotionCombatMod>
    </PromotionCombat>
    <PromotionCombat>
        <PromotionCombatType>PROMOTION_ELF</PromotionCombatType>
        <iPromotionCombatMod>50</iPromotionCombatMod>
    </PromotionCombat>
</PromotionCombats>

And I think that civics and maybe specialists should have a <iCrime></iCrime> tag, and that possibly buildings and civics should be able to alter the crime rate from specialists (ex, smugglers ports and gambling houses give +1 crime from merchants, temples of order/empyrean/runes/leaves give -1 crime from priests, temples of overlords/ashen veil +1 from priests, theology -1 from priests/great prophets, sacrifice the weak +1 from sages, guardian of nature -1 from bards, etc)
 
I had a free one I liked (well, didn't dislike) on my computer before my hard drive broke; I don't remember what it was called. I've downloaded 2 xml compare tools in the past 2 hours, but don't like them as much.

I too would like advice on what to use.

Edit: one that can also compare python files would be ideal.
 
The various ___Schema.xml files set how the tags works and what types of values won't give error messages, but the actual functionality written in C++ in the .dll; changing the schema without changing the code that reads them (which requires more advanced coding skills than I have) won't work.
 
So how come when I tried to merge patch G with your mod I got an error saying something about the tag <iplotradius> being incorrect and magic resistance being expected instead? I put in the new dll and building schemas and merged the different building infos and building class infos.
 
I use a combination of Notepad2, and WinMerge, both are free. A bit busy now, but if you need help finding them, post something tomorrow and I should be able to search around for you. Though honestly I'll just search Altavista or Cnet.downloads.com for those two precise words, I know I got the spelling right :)

WinMerge seems like it can automate things, and is overall REALLY nice, but I haven't felt like learning all of the features just yet, so for now I am sticking with Notepad2. But come to think of it... not sure if I have used Notepad2 to Merge anything.... Probably haven't.

Anyway, WinMerge works for both Python and XML (as does Notepad2, if you are just editing. Beats Notepad because it color codes things automatically, and you can customize precisely how it does that. I think WinMerge also does that though...)

My laptop's in the shop right now fixing the keyboard, so I can't play with them and be more accurate than that. If I install too much on my wife's laptop she'll kill me ;)
 
xienwolf said:
I use a combination of Notepad2, and WinMerge, both are free. A bit busy now, but if you need help finding them, post something tomorrow and I should be able to search around for you. Though honestly I'll just search Altavista or Cnet.downloads.com for those two precise words, I know I got the spelling right
Thanks:) I'll have to try both of them out tomorrow.
 
So how come when I tried to merge patch G with your mod I got an error saying something about the tag <iplotradius> being incorrect and magic resistance being expected instead? I put in the new dll and building schemas and merged the different building infos and building class infos.

Kael added the City of a thousand Slums wonder in this mod, and added a new tag for buildings that increase a cities radius too. I suspect that he may have changed the way the extra radius is applied (hopefully in such a was as to allow even larger radii :)) This new tag was placed just before <iResistMagic>, so the new schema tells make it expect to see <iPlotRadius> before <iResistMagic>. You need to add this tag to every building in the file. New tags is one reason why I'm not reusing the old files, but starting fresh (or with a compare tool). That, and it means it will be better documented.



I mostly use notepad2 for the coding and Winmerge was the compare tool that I used before loosing everything on my harddrive. I couldn't remember what it was called, and while looking for it I first tried 2 other programs that I didn't like as much. I just downloaded Winmerge and am about to uninstall the other 2. Thanks for reminding what it was called, xienwolf!

Winmerge still isn't perfect though. When you have made lots of changes between the documents (especially new spells, buildings, or units) then the two sides don't line up very well. Also, the grey spaces sometimes make it easy to remove half a tag. the .bak's it generates can be a little annoying too, but having backups is a god thing I guess.

I typically look the come over in Notepad2 after merging, and if its Python I bug check it in IDLE for VPython (thats the program we used last semester in Physics when we were modelling subatomic particles in visual python. It has a decent bug checker (which Notepad2 lacks), but it lacks some basics like an easy way to differentiate between spaces and tabs (very important in Python). Also, you can't scroll left or right (you can use left/right arrows to move in the text, but not select a position or see how far over you are), and text that is too far right often is invisible. Following its advice for fixing a file almost always messes it up more (its suggested solution to mixing tabs and spaces: automatically turn everything to spaces, and require going through every line whole document by hand to change them back), so I use it to find the line with the bug and then change the cone in Notepad2.
 
Crosspost!

I wanted to make a rework in mounted line. Horsemen would upgrade to either light or heavy cavalry, and heavy and light to either knights or horse archers, respectively. Chariots would exist only as Ratha or as Unique units (Dwarven etc.)

I added 2 new unitclasses - Light Cavalry and Heavy Cavalry, but when I click EXPORT I get bunch of errors. If I don't add unitclasses it all works fine.

Solution?
 
Unitclasses must be added to the CIV4UnitClassInfos.xml file, you cannot just reference an undefined unitclass in CIV4UnitInfos.xml.

Since you mentioned exporting, I assume you you are using the excel based editor, not modifying the xml directly; the editor doesn't have a tab whose macros change CIV4UnitClassInfos.xml, so you will have to make this change manually.
 
Unitclasses must be added to the CIV4UnitClassInfos.xml file, you cannot just reference an undefined unitclass in CIV4UnitInfos.xml.

Since you mentioned exporting, I assume you you are using the excel based editor, not modifying the xml directly; the editor doesn't have a tab whose macros change CIV4UnitClassInfos.xml, so you will have to make this change manually.

Still not working. I probably haven't mentioned that I don't get errors on civ4 startup but when I export stuff. When I click export I get error in excel, and it never gets exported. With message : 'Compile Error: can't find project or library' and then debug window opens up.


EDIT: Reinstalled the patch, so I have correct files, and then tried to export units 'as-is' and I still have the same error. Other sheets work fine (events, etc)
 
Just wondering what some tags are being used for in FfH's Unit Info:

UnitInfos.XML said:
<bSpy>0</bSpy>
<bSabotage>1</bSabotage>
<bDestroy>1</bDestroy>
<bStealPlans>1</bStealPlans>
<bInvestigate>1</bInvestigate>
<bCounterSpy>1</bCounterSpy>

Does having the BSpy set to 0 invalidate being able to perform spy missions, or just being found by Counter Spy? Is there any point in Counter Spy (Is that what is used to see Hidden units?)? And why bother setting the mission values to 1? Are they stand-in flags for future use?
 
bSpy is for BtS espionage missions, which no unit in FfH can do (plus there are no active missions in BtS's espionage defines). Units with bSpy are sometimes randomly discovered and destroyed (I found this out the hard way a while back when I had added BtS espionage to .25 and let a few units act as spies; I lost Loki and a few shadows)

bCounterSpy does not let you see hidden/invisible units. I know it helps against bSpy, and am not sure about against the other spy mission tags.

The mission tags refer to vanilla type espionage, which still work in FfH and are not used in BtS.
 
@Kael:
Any chance you'll be making the source code for patch 'g' available for download anytime soon?
 
Top Bottom