ESF<->XML converter - Tutorial
What is ESF<->XML converter - main thread: http://www.twcenter.net/forums/showthread.php?t=392712
What is ESF<->XML converter?
It is .esf files editor created by taw, it converterts files such as startpos from .esf to .xml making it more easy to be edited.
How to use ESF<->XML converter?
The easiest way to get it running under Windows is by installing
JRuby single installer with Java Runtime Environment bundled.
Here's the link:
http://jruby.org.s3.amazonaws.com/do...sjre_1_5_3.exe
For Windows JRuby you need prerelease version of Nokogiri (--pre flag).
If you have installed other version before, you must also uninstall it first.
These two commands should do it:
$ jgem uninstall nokogiri
$ jgem install nokogiri –pre
== Usage ==
$ ./esf2xml foo.esf foo_dir
$ ./esf2xml --quiet foo.esf foo_dir
$ ./xml2esf foo_dir foo.esf
esf2xml automatically prints progressbar unless told not to by --quiet option
(xml2esf might get this too later)
To run with specific Ruby version use like:
$ ruby ./esf2xml foo.esf foo_dir
$ jruby --server -J-Xmx2048m ./esf2xml foo.esf foo_dir
You might want to specify higher memory limit like -J-Xmx2048m option,
default JVM max heap size is ridiculously small 500MB, half of it
going to JVM overhead.
Passing --server to jruby speeds it up by about 10%, so do it.
== Unpacked Directory ==
Main file in unpacked directory is always esf.xml
There might be other files as well, xml, bitmap, or anything else.
By: taw
Scripts:
For way too long editing esf was slow and painful process. I remember spending something like two hours just to remove all settlement fortifications.
Then came esf2xml, and it became a 15 minute text editor search and replace job, after a bit of practice.
Now comes the next logical step in esf editing - fully automatic transformations.
XML is just so damn easy to convert with scripts, why even bother with text editors?
And thanks to husserlTW's gui for esf editing soon you won't even need any command line.
How they work
Esf transformation scripts work on xml form, so what you need to do is:
• convert esf to xml
• run all scripts you want one after another
• convert xml to esf back
Scripts modify directory full of unpacked xmls in place.
Available scripts
Available scripts so far (a lot more coming soon):
Faction editing - most commands accept either faction name or "*" to apply to all factions:
• make one faction playable (doesn't fix fog of war bug itself, may crash if you try to play emergent or rebel factions etc. - the usual caveats apply)
• make all vanilla non-emergent campaign minor factions playable
• make one/all faction major
• make faction minor
• change faction's religion
• change faction's capital region (by name obviously, script handles name to id mapping automatically)
• change one/all faction's starting treasury
• give faction one technology (research points is db-dependent, but doesn't seem to matter, so it's just set to status=0, research_points=1000.0), or multiple technologies specified by pattern like military_*
• give faction all possible technologies (awesome fun for starting as tiny faction)
Reporting:
• List all factions
• List id by faction
• List ids and cai ids by region
• List starting (startpos.esf) or current (for save games) treasury by faction
• Draw regions from regions.esf
Others:
• remove all settlement fortifications from whole map - the very thing which made me start esf<->xml converter
• change turns per year
• remove current resistance to foreign occupation (doesn't prevent it in for future conquests)
• reset diplomacy for all factions
By: taw
List of ids
Spoiler for factions ids:
Spoiler for regions ids:
MODIFICATIONS
Index
- Make faction playable
- Change starting treasury
- Make minor faction major
- Make major faction minor
- Change factions capital
- Change victory conditions
- Add victory conditions
- Change type of government
- Change available technologies
- Change a faction religion
- Change amount of religion followers by region
- Change turns/year
- How to active towns/ports
Make faction playable:
Spoiler Alert, click show to read:
Change starting treasury:
Spoiler Alert, click show to read:
Make minor faction major:
Spoiler Alert, click show to read:
Make major faction minor:
Spoiler Alert, click show to read:
Change factions capital:
Spoiler Alert, click show to read:
Change victory conditions:
Spoiler Alert, click show to read:
Add victory conditions:
Spoiler Alert, click show to read:
Change type of government:
Spoiler Alert, click show to read:
Change available technologies:
Spoiler Alert, click show to read:
Change a faction religion:
Spoiler Alert, click show to read:
Change amount of religion followers by region:
Spoiler Alert, click show to read:
Change turns/year:
Spoiler Alert, click show to read:
How to active towns/ports:
Spoiler Alert, click show to read:
Thanks to Taw for the tool
husserlTW for his STARTPOS.ESF analysis and modifications thread
To continue...