1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

XML Generator for modmods of M:C

Discussion in 'Civ4Col - Medieval: Conquests' started by orlanth, Mar 12, 2014.

  1. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    For Lib Spi't and others considering making a new total conversion modmod based on M:C ; if you're finding it hard to generate all the needed XML files and cross-referenced XML tags by hand, you can feel free to try this XML generator script which is designed to generate a complete set of cross-referenced XML files in M:C compatible format.

    https://github.com/Nightinggale/Medieval_Tech/blob/colonization2071/scripts/xmlgen.pl

    This was set up just for use in 2071, but if you want to try using it to generate the XMLs for your own mod and have a little programming knowledge (this can be *very* little like I have :crazyeye:) you could try editing the arrays in this script (starting with @) to generate the content you want. For example in the code chunks below, it's setting up arrays listing the Cargo Yields (@cargoyields), Abstract Yields (@abstractyields), Buildable Improvements (@builds), Goody-Hut Improvements (@goody), professions producing yields on map plots (@plotprofs), and professions producing yields in buildings (@cityprofs).

    Spoiler :
    # arrays of yields
    @cargoyields = ("Nutrients" , "Biopolymers" , "Silicates" , "Base Metals" , "Actinides" , "Isotopes" , "Rare Earths" , "Crystalloids" , "Nucleic Acids" , "Amino Acids" , "Tissue Samples" , "Microbes" , "Datacores" , "Progenitor Artifacts" , "Alien Specimens" , "Precious Metals" , "Opiates" , "Xenotoxins" , "Botanicals" , "Hydrocarbons" , "Clathrates" , "Core Samples" , "Machine Tools" , "Robotics" , "Munitions" , "Photonics" , "Plasteel" , "Duralloy" , "Crystalloy" , "Nucleonics" , "Fusion Cores" , "Semiconductors" , "Plasmids" , "Enzymes" , "Stem Cells" , "State Secrets" , "Progenitor Tech" , "Alien Relics" , "Narcotics" , "Bioweapons" , "Pharmaceuticals" , "Petrochemicals" , "Colloids" , "Catalysts", "Hard Currency", "Earth Goods", "Contraband", "Earthling Specimens");
    # array of abstract yields
    @abstractyields = ("Industry", "Media", "Liberty", "Research", "Education", "Influence", "Energy", "Pollutants", "Credits");
    @allyields = (@cargoyields,@abstractyields);

    # improvements, goodyhuts and improvement builds
    @builds = ('Farm','Mill','Quarry','Mine','Facility','Lab','Plantation','Rig');
    @goody = ('Alien Menhir','Abduction Site','Land Worked','Water Worked','City Ruins');
    @improvements = (@builds,@goody);

    # arrays of professions: 1st item = description, 2nd item = yield produced, rest of items = yield inputs
    # professions producing yields on map plots
    @plotprofs = (
    ['Agriculture','NUTRIENTS'],
    ['Biopolymer Harvesting','BIOPOLYMERS'],
    ['Base Metals Mining','BASE_METALS'],
    ['Silicate Mining','SILICATES'],
    ['Precious Metals Excavation','PRECIOUS_METALS'],
    ['Actinide Extraction','ACTINIDES'],
    ['Isotope Extraction','ISOTOPES'],
    ['Rare Earths Extraction','RARE_EARTHS'],
    ['Crystalloid Extraction','CRYSTALLOIDS'],
    ['Nucleic Acid Culture','NUCLEIC_ACIDS'],
    ['Amino Acid Culture','AMINO_ACIDS'],
    ['Tissue Sample Culture','TISSUE_SAMPLES'],
    ['Microbial Culture','MICROBES'],
    ['Datacore Excavation','DATACORES'],
    ['Artifact Excavation','PROGENITOR_ARTIFACTS'],
    ['Alien Specimen Excavation','ALIEN_SPECIMENS'],
    ['Opiates Cultivation','OPIATES'],
    ['Xenotoxin Cultivation','XENOTOXINS'],
    ['Botanical Cultivation','BOTANICALS'],
    ['Hydrocarbon Drilling','HYDROCARBONS'],
    ['Clathrate Drilling','CLATHRATES'],
    ['Core Sample Drilling','CORE_SAMPLES']
    );
    # professions producing yields in buildings
    @cityprofs = (
    ['Machine Tool Casting','MACHINE_TOOLS','BASE_METALS'],
    ['Robotics Manufacturing','ROBOTICS','MACHINE_TOOLS'],
    ['Munitions Manufacturing','MUNITIONS','MACHINE_TOOLS'],
    ['Photonics Manufacturing','PHOTONICS','CRYSTALLOIDS'],
    ['Plasteel Smelting','PLASTEEL','BASE_METALS','BIOPOLYMERS'],
    ['Duralloy Smelting','DURALLOY','BASE_METALS','SILICATES'],
    ['Crystalloy Smelting','CRYSTALLOY','PRECIOUS_METALS','CRYSTALLOIDS'],
    ['Fusion Core Enrichment','FUSION_CORES','ACTINIDES'],
    ['Nucleonics Enrichment','NUCLEONICS','ISOTOPES'],
    ['Semiconductor Fabrication','SEMICONDUCTORS','RARE_EARTHS'],
    ['Plasmid Biosynthesis','PLASMIDS','NUCLEIC_ACIDS'],
    ['Enzyme Biosynthesis','ENZYMES','AMINO_ACIDS'],
    ['Stem Cell Dissection','STEM_CELLS','TISSUE_SAMPLES'],
    ['Datacore Analysis','STATE_SECRETS','DATACORES'],
    ['Artifact Analysis','PROGENITOR_TECH','PROGENITOR_ARTIFACTS'],
    ['Alien Specimen Dissection','ALIEN_RELICS','ALIEN_SPECIMENS'],
    ['Narcotics Distillation','NARCOTICS','OPIATES'],
    ['Bioweapons Distillation','BIOWEAPONS','XENOTOXINS'],
    ['Pharmaceuticals Distillation','PHARMACEUTICALS','BOTANICALS'],
    ['Petrochemical Refining','PETROCHEMICALS','HYDROCARBONS'],
    ['Colloids Refining','COLLOIDS','CLATHRATES'],
    ['Catalyst Refining','CATALYSTS','CORE_SAMPLES'],
    ['Investment Banking','HARD_CURRENCY','PRECIOUS_METALS'],
    ['Construction','INDUSTRY'],
    ['Mass Media','MEDIA'],
    ['Administration','LIBERTY'],
    ['Education','EDUCATION'],
    ['Applied Research','RESEARCH']
    );
    If you were to edit all the arrays in the script to use the content for your mod, you can then execute the script using Perl (eg http://strawberryperl.com) and it will spit out a big set of XML files using that content, which you can then edit manually as you like.

    The script will need modification to use for your own mods, and you'll still need to edit the resulting XML files to adjust the unit/building stats and other content the way you want; so I'm not sure whether people will want to use this script or just make all their XML by hand the old fashioned way. But IMHO this can cut down on the long and painful process of manually generating every XML file for a total conversion mod, while keeping all the necessary cross-references between your Professions, Units, Features, Buildings, ArtDefs, and Text XML files intact. :crazyeye:
     
  2. Trade Winds

    Trade Winds Warlord

    Joined:
    Nov 21, 2013
    Messages:
    235
    Very good tip.
    I want to code Lib.Spi't's tech tree for the WHM. So do you think it will worth it listing all the professions, yields etc with this syntax for future use? As you know a tech tree mixes it all together, so this is why I feel a bit reluctant. I don't know if that would save me or anyone from much coding.
    In your examples I didn't see array lists for Technologies, but I think it could also be done. Should I?
     
  3. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    LOL I know how you feel Trade Winds; it can be really hard to generate lots of XML by hand, but if tech content is very mixed and not standardized it's likely not possible to use a script in that case.

    The full script does have a section with functions that can create the XML for lines of techs (maketechlineraw for a line of techs unlocking production of raw map yields, and maketechlinecity creating a line of techs for buildings/professions of city yields).

    This can be a good setup for designing mods where sets of yields and techs are relatively standardized and set up to be precisely balanced using a formula, but if you're making a big tree where every single tech is totally different it'll need so much manual editing that you might just have to do it all by hand. :sad: However, you could use this to generate an XML grid of techs and then edit manually as needed if you feel that would help your process.

    Spoiler :
    #tag,description,category,xcoord,ycoord,requiredinvention,allowyield,allowbldg,allowprof

    sub maketechlineraw {
    my $yield = shift;
    my $desc = shift;
    # my $cat = shift;
    my $cat = 'MEDIEVAL_TRADE_TECH';
    $x=1;
    #allow yield
    &maketech('TECH_'.$yield.'1',$desc.' Analysis',$cat,$x,$y,'',$yield,'','','SILICATES');
    $x++;
    #allow prof
    &maketech('TECH_'.$yield.'2','Basic '.$desc.' Extraction',$cat,$x,$y,'TECH_'.$yield.'1','','',$yield,$yield);
    $x++;
    #production boost
    &maketech('TECH_'.$yield.'3','Advanced '.$desc.' Extraction',$cat,$x,$y,'TECH_'.$yield.'2','','','',$yield);
    $y=$y+2;
    }

    sub maketechlineraw1 {
    my $yield = shift;
    my $desc = shift;
    # my $cat = shift;
    my $cat = 'MEDIEVAL_TRADE_TECH';
    $x=1;
    #allow yield
    # &maketech('TECH_'.$yield.'1',$desc.' Analysis',$cat,$x,$y,'',$yield,'','','SILICATES');
    # $x++;
    #allow prof
    &maketech('TECH_'.$yield.'2','Basic '.$desc.' Extraction',$cat,$x,$y,'','','',$yield,$yield);
    $x++;
    #production boost
    &maketech('TECH_'.$yield.'3','Advanced '.$desc.' Extraction',$cat,$x,$y,'TECH_'.$yield.'2','','','',$yield);
    $y=$y+2;
    }

    sub maketechlinecity {
    my $yield = shift;
    my $desc = shift;
    # my $cat = shift;
    my $cat = 'MEDIEVAL_TRADE_TECH';
    $x=1;
    #allow yield
    &maketech('TECH_'.$yield.'1',$desc.' Analysis',$cat,$x,$y,'',$yield,'','','MACHINE_TOOLS');
    $x++;
    #allow prof + bldg 1
    &maketech('TECH_'.$yield.'2','Basic '.$desc.' Production',$cat,$x,$y,'TECH_'.$yield.'1','',$yield.'1',$yield,$yield);
    $x++;
    #building 2
    &maketech('TECH_'.$yield.'3','Advanced '.$desc.' Production',$cat,$x,$y,'TECH_'.$yield.'2','',$yield.'2','',$yield);
    $x++;
    #building 3
    &maketech('TECH_'.$yield.'4','Intensive '.$desc.' Production',$cat,$x,$y,'TECH_'.$yield.'3','',$yield.'3','',$yield);
    $y=$y+2;
    }

    &maketechlineraw1('NUCLEIC_ACIDS','Nucleic Acid','TECH_CATEGORY_GENETICS');
    &maketechlinecity('PLASMIDS','Plasmid','TECH_CATEGORY_GENETICS');
    &maketechlineraw('AMINO_ACIDS','Amino Acid','TECH_CATEGORY_GENETICS');
    &maketechlinecity('ENZYMES','Enzyme','TECH_CATEGORY_GENETICS');
    &maketechlineraw('TISSUE_SAMPLES','Tissue','TECH_CATEGORY_GENETICS');
    &maketechlinecity('STEM_CELLS','Stem Cell','TECH_CATEGORY_GENETICS');

    &maketechlineraw('MICROBES','Microbial','TECH_CATEGORY_GENETICS');

    &maketechlineraw1('OPIATES','Nucleic Acid','TECH_CATEGORY_XENOBOTANY');
    &maketechlinecity('NARCOTICS','Narcotic','TECH_CATEGORY_XENOBOTANY');
    &maketechlineraw('XENOTOXINS','Amino Acid','TECH_CATEGORY_XENOBOTANY');
    &maketechlinecity('BIOWEAPONS','Bioweapon','TECH_CATEGORY_XENOBOTANY');
    &maketechlineraw('BOTANICALS','Tissue','TECH_CATEGORY_XENOBOTANY');
    &maketechlinecity('PHARMACEUTICALS','Pharmaceuticals','TECH_CATEGORY_XENOBOTANY');

    &maketechlineraw1('DATACORES','Datacore','TECH_CATEGORY_ARCHAEOLOGY');
    &maketechlinecity('STATE_SECRETS','State Secrets','TECH_CATEGORY_ARCHAEOLOGY');
    &maketechlineraw('PROGENITOR_ARTIFACTS','Artifact','TECH_CATEGORY_ARCHAEOLOGY');
    &maketechlinecity('PROGENITOR_TECH','Progenitor Tech','TECH_CATEGORY_ARCHAEOLOGY');
    &maketechlineraw('ALIEN_SPECIMENS','Alien Specimen','TECH_CATEGORY_ARCHAEOLOGY');
    &maketechlinecity('ALIEN_RELICS','Relic','TECH_CATEGORY_ARCHAEOLOGY');

    &maketechlineraw1('HYDROCARBONS','Hydrocarbons','TECH_CATEGORY_CHEMISTRY');
    &maketechlinecity('PETROCHEMICALS','State Secrets','TECH_CATEGORY_CHEMISTRY');
    &maketechlineraw('CLATHRATES','Clathrate','TECH_CATEGORY_CHEMISTRY');
    &maketechlinecity('COLLOIDS','Colloidal','TECH_CATEGORY_CHEMISTRY');
    &maketechlineraw('CORE_SAMPLES','Core Samples','TECH_CATEGORY_CHEMISTRY');
    &maketechlinecity('CATALYSTS','Catalyst','TECH_CATEGORY_CHEMISTRY');

    &maketechlineraw('PRECIOUS_METALS','Precious Metals','TECH_CATEGORY_CHEMISTRY');

    &maketechlineraw1('ACTINIDES','Actinide','TECH_CATEGORY_PHYSICS');
    &maketechlinecity('FUSION_CORES','Fusion Core','TECH_CATEGORY_PHYSICS');
    &maketechlineraw('ISOTOPES','Isotope','TECH_CATEGORY_PHYSICS');
    &maketechlinecity('NUCLEONICS','Nucleonic','TECH_CATEGORY_PHYSICS');
    &maketechlineraw('RARE_EARTHS','Rare Earth','TECH_CATEGORY_PHYSICS');
    &maketechlinecity('SEMICONDUCTORS','Semiconductor','TECH_CATEGORY_PHYSICS');

    &maketechlineraw('CRYSTALLOIDS','Crystalloid','TECH_CATEGORY_PHYSICS');
     
  4. Trade Winds

    Trade Winds Warlord

    Joined:
    Nov 21, 2013
    Messages:
    235
    Well, let’s do it little by little. I want to think that this little-qualified handmade work converts us the lowest specialized number-changing modders into mod artisans.
     
  5. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,354
    Speaking of scripts, there are quite a lot of them now and we keep adding them. It would likely be a good idea to look inside the scripts directory and read the top where it tells what it does.

    Also feel free to say what new scripts should do. It's not like they are that difficult to code.
     
  6. Trade Winds

    Trade Winds Warlord

    Joined:
    Nov 21, 2013
    Messages:
    235
    Well my working plan is as follows:

    Working with spreadsheet
    1-Learn how to extract Lib.Spi't comentaries out to cells
    Done. By means of a Built in Visual basic Function.
    2-Create Chunks of texts relating together techs+dependent tech+features it unlocks (idea from orlanth)
    Todo

    Working with notepad
    3-modding these chunks of text surrounding them into the XML shape
    Todo
    I plan doing this with find and replace. A script could help here.
    Only if I got too stuck here, I could ask some help.
    4-Fine tuning of XML techs and including Nightinggale xy coordinates variable.
    Todo

    I think this aproach could be ok to save me from some typing chores.
     
  7. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,354
    You really should use notepad++ instead of notepad.
     
  8. Trade Winds

    Trade Winds Warlord

    Joined:
    Nov 21, 2013
    Messages:
    235
    Yes, I tried it before. I think I need to reinstal it if I can. I'll do when needed.
     
  9. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
  10. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,707
    Location:
    UK
    wow this could be really useful I think.. if I understand it! (no promises!!)

    So does this script generate an entire xml entry

    like everything in a <yieldinfo> and then changes certain bits within, like YIELD_MONKEYS

    then you go through and just filled with the bits not specified, and it just fills those in with like a 1 or some other generic (syntax fitting) input?

    This really could be awesome for doing the all the buildings and professions etc. As I can just right out them out as a list and then copy paste that in and boop! I have them all ready to do the fiddley bits but no more need for copy paste who reference blocks (it took me about 5 hours to do the yields!)

    Also where does it spit out the files to?
     
  11. Trade Winds

    Trade Winds Warlord

    Joined:
    Nov 21, 2013
    Messages:
    235
    I got stacked with the "lingua EN inflect" Perl Package. I need your help to the best possible solution:

    1- If you know a site where I can download the package
    2- Which code should I remove from the xmlgen to ignore my lack of package
    3- I just can include the arrays into the xmlgen, but I won't be able to test whether that would work. (I'll be doing this unless told something else.)
     
  12. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
  13. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,707
    Location:
    UK
    This probably doesn't help... but this is where I downloaded perl from, maybe this version will be what you need, maybe not... sorry this is above my pay grade :D

    perl

    edit
    oh good orlanth beat me to it :D
     
  14. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,354
  15. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,707
    Location:
    UK
    wait I just realised, does this mean you have filled in the xmlgen with everything?

    If so I would love to see your file! :D
     
  16. Trade Winds

    Trade Winds Warlord

    Joined:
    Nov 21, 2013
    Messages:
    235
    Thank you for your help.:) I'll check all the options.

    No way. I'm way far from finishing.
     

Share This Page