Paradox Interactive Forums  

Go Back   Paradox Interactive Forums > Historical Games > Europa Universalis III > EU3 - User Modifications

Reply
 
Thread Tools
Old 16-01-2008, 02:53   #1
Autonomous
Steamlord
 
Autonomous's Avatar
EU3 OwnerNapoleonic MarshalDeus Vult!Victoria: RevolutionsEuropa Universalis III: In Nomine
Hearts of Iron IIIMajesty 2Heir to the Throne200k ClubMount & Blade: Warband
Victoria 2
 
Join Date: Aug 2007
Location: Scotland
Posts: 1,028
ATAGE Integration Utility

So, I stumbled across ATAGE this morning. Very cool, I thought. And it even came with a .jar that automatically changed nation's governments. Awesome, I thought. It'll end up breaking an event pool or fifty, but I could integrate it into the mod I'm currently working on and get something playable in an hour or two.

Bah. It's now a good sixteen hours later and I've only just managed to reach that stage. The reason? The .jar doesn't actually work. At least for me.

My response? Write one myself.

And so here we are. (.zip, 3KiB)

To use this, you will have to aquire country_government_prefix.txt from Kaigon's original ATAGE 2007-02-18 distribution (and, obviously, the actual constituent parts of ATAGE; this utility only requires country_government_prefix.txt to do its job). I would love to distribute them together, but I haven't asked Kaigon for permission, so...

Then;
  • BACKUP YOUR <mod>/history/countries FOLDER, FOR THE LOVE OF GOD
  • Take ATAGEInc.jar (my file) and country_government_prefix.txt and place them in the root directory of your mod (or EUIII's root, if you want to alter vanilla directly :?)
  • Open country_goverment_prefix.txt in a text editor- preferably a no frills one like Notepad.
  • Replace
    Code:
    PAP;papacy
    with
    Code:
    PAP;papacy;null
  • Add entries for any new nations you have added, in the form
    Code:
    <tag>;<type>;-<regional variation>_<level>
  • If you don't understand what I mean by
    Code:
    <type>;-<regional variation>_<level>
    , then examine the other entries in the file.
  • If you still don't understand, go to the ATAGE thread for a basic grounding in the ATAGE government system.
  • Modify any other entries to reflect changes you have made to those nations governments
  • Save country_government_prefix.txt and run the .jar

I TAKE NO RESPONSABILITY FOR ANY DESTRUCTION/CORRUPTION/ETC. OF YOUR /history/countries FILES.

There are (I've tested it and there's no logical reason there should be) no dangers resulting from running the program multiple times, and it should run perfectly well (albeit incompletely, unless you add the relevant entries to country_government_prefix.txt) on NAx.

On that note, remember that this was designed and tested for 1.3 and ATAGE proper was designed and tested for (probably) 1.1.

Incidently, if anyone does want to update ATAGE for NAx, you can get a list of what nations were successfully modified and which failed (usually due to lack of an entry- i.e., new) by running this from the command line with
Code:
java -jar ATAGEInc.jar -v > log.txt
and then reading the new log.txt file.

Tested on

Windows XP SP 2
AMD Athlon 64 X2 (Dual Core) @ 2.4GiHz
2GiB RAM
nVidia 8800GTX with 768 MiB RAM
163.95GiB free HDD capacity.
Java 1.6.0_02 (6.0 update 2)

Please report any bugs.

Full source code to follow, for peer review, constructive criticism and feel-good open source hippie shennanigans.
Autonomous is offline   Reply With Quote
Old 16-01-2008, 02:54   #2
Autonomous
Steamlord
 
Autonomous's Avatar
EU3 OwnerNapoleonic MarshalDeus Vult!Victoria: RevolutionsEuropa Universalis III: In Nomine
Hearts of Iron IIIMajesty 2Heir to the Throne200k ClubMount & Blade: Warband
Victoria 2
 
Join Date: Aug 2007
Location: Scotland
Posts: 1,028
Code:
package atageinc;

import java.util.*;
import java.util.regex.*;
import java.io.*;
 /**
 *
 * @author Autonomous Monster
 */
public class Main {
    
    public static HashMap<String, String> dictionary;

    public static void initDict(boolean verbose) {
        try {
            if(verbose) { System.out.println("-Attempting to open lookup list..."); }
            File raw = new File("./country_government_prefix.txt");
            Scanner oup = new Scanner(raw);
            if(verbose) { System.out.println("-Done!"); }
            
            if(verbose) { System.out.println("-Parsing lookup list..."); }
            Vector<String> roughWork = new Vector<String>();
            while(oup.hasNextLine()) {
                roughWork.add(oup.nextLine());
            }
            oup.close();
            String[][] markUp = new String[roughWork.size()][3];
            for(int n = 0; n < roughWork.size(); n++) { markUp[n] = roughWork.get(n).split(";"); } 
            
            if(verbose) { System.out.println("--Populating internal lookup table"); }
            dictionary = new HashMap<String, String>(markUp.length);
            int n = 0;
            for(; n < markUp.length; n++) {
                if(!markUp[n][2].equals("null")) {
                    dictionary.put(markUp[n][0].trim().toUpperCase(),
                        markUp[n][1].trim().concat(markUp[n][2].trim()));
                    if(verbose) { 
                        System.out.println("--Added "+markUp[n][0].trim().toUpperCase()+" with value "
                            +markUp[n][1].trim().concat(markUp[n][2].trim())+" to lookup table"); 
                    }
                } else {
                    dictionary.put(markUp[n][0].trim().toUpperCase(),
                        markUp[n][1].concat(markUp[n][2].trim()));
                    if(verbose) { 
                        System.out.println("--Added "+markUp[n][0].trim().toUpperCase()+" with value "
                            +markUp[n][1].trim()+" to lookup table"); 
                    }
                }
            } if(verbose) { 
                System.out.println("--Added "+n+" entries to table"); 
                System.out.println("-Done!"); 
            }
            
        } catch(IOException ioe) {
            System.out.println("Failed to open country_government_prefix.txt. Bailing.");
            System.exit(-1);
        }
    }
    
    public static void pedantry(File workplace, boolean verbose) {
        Scanner pedant;
        FileWriter revisionist;
        System.out.println("-Getting file list...");
        String[] files = workplace.list();
        System.out.println("-Done!");
        
        for(int n = 0; n < files.length; n++) {
            String current = "";
            try {
                if(dictionary.containsKey(files[n].trim().substring(0, 3).toUpperCase())) {
                    System.out.println("-Correcting "+files[n]);
                    pedant = new Scanner(new File("./history/countries/"+files[n]));
                    while(pedant.hasNextLine()) {
                        current = current.concat(pedant.nextLine()+"\r\n");
                    }
                    pedant.close();
                    
                    current = Pattern.compile("government = \\w*", 0).matcher(
                            current).replaceAll(Matcher.quoteReplacement(
                            "government = "+dictionary.get(files[n].trim().substring(0, 3).toUpperCase())));
                    revisionist = new FileWriter("./history/countries/"+files[n], false);
                    revisionist.write(current);
                    revisionist.close();
                    
                } else { System.out.println("-"+files[n]+" Has no entry in dictionary. Moving on."); }
            } catch(IOException ioe) {
                System.out.println("-Failed to open "+files[n]+". Moving on.");
            }
        }
    }
    
    public static void main(String[] args) {
        boolean verbose = false;
        for(int n = 0; n < args.length; n++) { 
            if(args[n].equals("-v")) { 
                verbose = true;
                System.out.println("Verbose mode on!"); 
            }
        }
        System.out.println("Initialising...");
        initDict(verbose);
        System.out.println("Done!");
        System.out.println("Beginning work...");
        pedantry(new File("./history/countries"), verbose);
        System.out.println("Done!");
    }

}
Autonomous is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT +1. The time now is 09:05.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© Copyright 2001-2009 Paradox Interactive