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

Tips for Total Conversions

Discussion in 'Civ5 - Modding Tutorials & Reference' started by bane_, Mar 11, 2016.

  1. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    So I hit a wall tonight: I simply can't start the total conversion in regards to the game's basic concepts.

    I'm trying to mod the tech tree for hours and have hit a lot of errors, which then I identified in logging and proceeded to fix it just to find yet more errors.
    At one point I thought it would be easier to just use DELETE FROM for everything (Techs, Units, Buildings, etc), but then... nothing. Still can't get the tech tree to show and still got a humongous amount of errors in the log.

    I need any guidance you can provide me, but there is some good soul out there with a working clean slate for me to working from, even better.



    TIPS FROM THIS TOPIC​

    #1 If replacing the standard civs, you will need (at least) 10 new ones - whoward69

    #2 When deleting the content of an entire table that has IDs, and then filling it with new content, you need to make sure that the new content has the proper sequence of IDs. There are several ways to do it, I use the following method:

    Code:
    DELETE FROM Technologies;
    DELETE FROM Technology_Flavors;
    DELETE FROM Technology_PrereqTechs;
    DELETE FROM Technology_TradeRouteDomainExtraRange;
    
    [B]UPDATE sqlite_sequence
    SET seq = 0
    WHERE name = 'Technologies';[/B]
    You still need to set the ID to 0 for the first tech you add, like it's done in the standard XML file (CIV5Technologies.xml) for Agriculture. The same method can be used for all the other tables that have IDs.
    - PawelS

    #3 Deleting things from Technologies, Units or Buildings will cause errors unless you also delete every entry in every other table that references it (and there may be a lot of them). But there are ways you can make content unavailable without deleting anything. - HandyVac

    #4 Setting a Unit or Building as Cost="-1" will make it unbuildable, and stop it showing up in the city production list. - HandyVac

    #5 Setting a Technology as Disable="true" will make it impossible to research. You can then adjust it's gridX and gridY to hide it in an out-of-the-way corner of the techtree, and delete mentions of it in the Technology_PrereqTechs table to remove the lines linking it to and from other techs. - HandyVac

    #6 You'll also want to assign your unwanted techs to the final era in your techtree, since even disabled techs will be auto-granted if the player starts the game in an era after them. - HandyVac

    #7 Unless you are well versed with UI elements, forget {about flipping scrolling direction in the tech tree}! If I was trying to do this for real (ie not as a demo), I'd look for other options first! - whoward69

    #8 Don't delete the Missionary. IIRC, this is a cause for CTD. - JFD

    #9 There are tons of references for defines that don't control for zero. They'll cause lots of fun if you don't manage these global defines properly. - Gazebo

    #10 Changing era Types will almost certainly mess with any Early/Mid/Late unit reskins achieve via the ART_ tags - whoward69

    #11 Pazyryk have a tutorial thread on how to check through Lua whether any of your SQL failed to load[.] - Civitar & - whoward69


    CLEAN SLATE
    (by whoward69)​

    About as clean as I can get it (from a database point of view, the SQL could use some tidying up!) ... I present the most yawn inducing "Total Conversion" mod ever ... "TC - Minimal" (attached at bottom of post)

    Spoiler :

    Civilizations, Leaders and Traits
    • All standard majors removed
    • Ten custom (minimal) majors added
    • Minors and Barbarians pared back
    Units and UnitPromotions
    • Settler, Worker, Work Boat
    • Great people (GS, GM, GE, GG, GA, GP, GArt, GMus, GWri) (nine)
    • Space ship parts (four)
    • Warrior (and barbarian variant)
    • Religious (Missionary and Inquisitor)
    • Ten UUs (based on Warrior)
    • Twenty basic promotions
    Buildings
    • Palace and Monument
    • Ten UBs (based on Monument)
    Projects
    • Apollo program plus four space ship parts (required for science victory)
    Processes
    • Wealth (others removed)
    Improvements, Routes and Builds
    • City Ruins, Barb Camps and Goody Huts
    • Roads (railroad removed)
    • Farm, Mine and Fishing Boats
    • Repair
    • Remove forest, jungle, marsh and route
    Goody Huts
    • One giving gold
    Techs and Eras
    • Three eras (Ancient, Industrial and Modern)
    • Agriculture, Future Tech plus two techs per era (eight techs total)
    Policies
    • Trees (policy branches) unchanged (due to hard-coded UI/DLL)
    • One (minimal) policy per branch
    Ideologies and Tenets
    • Ideologies unchanged
    • All tenets removed
    Religions & Beliefs
    • pantheon plus two religions
    • 10 pantheon, 2 founder, 4 follower and 2 enhancer beliefs
    Leagues and Resolutions
    • Two leagues (initial and UN)
    • Four resolutions (required for voting) plus Change Host and World Leader (six resolutions total)
    Terrains, Features and Resources
    • Unchanged (except for civ specific resources, which have been removed)
    Notes


    Civilizations, Leaders and Traits
    You need a minimum of 10 civs, any less and you have to remove two from the default number of the map size you are playing (so standard map you can only play 6 civs on and small map you can only play 4 civs on - this appears to be hard-coded within the .exe file as that's where the CTD happens if you don't follow the rules!)

    The Minors and Barbarians define a lot of city names, I stripped those back to 5 each (the minimum required)

    Units and UnitPromotions
    Left the Warrior in as the UUs are based on it, but you could remove that as well, provided you add some other default unit
    The Work Boat can be removed if you don't want to improve sea resources
    The settler can possibly be removed, provided you add something else that can found cities, the Worker is a bad idea to remove as demanding a work unit from a CS is hard-coded to give a Worker.
    The nine standard great people are all hard-coded within the DLL (mostly in the buy GP with faith code after completing a policy tree - note the DLL hard-codes GP to specific trees, and the Mayan trait)
    If you take the spaceship parts out, you'll also need to remove the associated projects and mod the victory progress UI
    Missionary and Inquisitor are hard-coded in the DLL. If you disabled faith generation, you could remove them (but then you'll need to mod the Natural Wonders and AssignStartingPlots.lus)

    The promotions that are left are either some basic ones (insta-heal, embark, drill 1 and 2 and shock 1 and 2) for the Warrior (which could be removed if some others are added back in) and a few that are referenced from Features (altitude training) or referenced directly from the DLL (via the PostDefines table - remove these at your own risk!)

    Buildings
    Every capital needs a palace, if you remove this you MUST add a building with the palace flag set.
    The Monument could be removed, but you need at least one default building for the UBs to be based on

    Projects
    Removing all projects will cause an XML validation error. I left Apollo as without it you'll need to mod the Victory Progress UI. Unless adding in a modded project, best to leave it in and not hook it up to a tech.

    Processes
    Removing all processes will cause an XML validation error. Pick either research or wealth to leave in, you don't need to hook it up to a tech.

    Improvements, Routes and Builds
    Huts and camps are required by the map scripts, ruins are required by the DLL (on razing a city)
    You need something for the workers to do (or the AI auto-improve land code sulks), so I left in Farm and Mine - these could be removed if adding something else
    If you leave workboats in, you'll need to leave in fishing boats - but you could remove both
    The railroad build has been removed, and you could remove the road build as well - just do NOT delete them from the Routes table. The path-finding and city connection code in the DLL will not work properly if you do!
    IMPORTANT: Take great care with the Builds table, as the DLL hard-codes references to some of them by ID (not Type) - fortunately this table doesn't need to have contiguous IDs.

    Goody Huts
    Unless modding the map scripts to remove goody hut improvements, you'll need to leave in something for the hut to produce. If you use the Shoshone UUs ability, you MUST have at least three different goody hut rewards

    Techs and Eras
    The DLL expects to find ERA_ANCIENT, ERA_INDUSTRIAL and ERA_MODERN (industrial via hard-coding, the other two via the PostDefines table) - but you can rename them as anything eg "Early", "Middle" and "Late", but don't change their Types.

    The UI code expects to find Eras in ascending order in the database and the pedia expects them to have ascending TXT_KEYs (which I didn't do for this example ) - see the initial discussion in this thread
    Agriculture and Future Tech could be removed, but you'll need to add (at least) one initial tech to give to each civ and have one that repeats

    Policies
    If you want to change the number of policy trees (branches) you'll need to mod the UI.
    It's also not a good idea to change the Types (POLICY_HONOR, POLICY_LIBERTY, etc) as those are hard-coded in the DLL

    Ideologies and Tenets
    The three ideologies are hard-coded in the DLL - there must be three ... not two or four. If you don't want ideologies, just don't have any buildings that enable them!
    You can change the display name of the ideologies, but the Types are hard-coded in the DLL
    If you want to change the number of tenets per level you'll need to mod the UI. To change the number of tiers (level) requires DLL mods (as the AI pushes for a level 3 tenet)

    Religions & Beliefs
    Not sure how the AI will handle only a single religion - as there is code in the DLL to try to found an opposing religion
    You need at least one pantheon belief per civ (so ten), and one founder, two follower and one enhancer beliefs per religion (assuming you don't enable the trait that gives bonus beliefs or the policy to grant reformation beliefs)

    Leagues and Resolutions
    You could probably get away with a single league session. If you don't want the League, it's probably best to leave the minimum entries in the database and just not set the enabler on any tech.

    Terrains, Features and Resources
    Changes to terrains, features and resources (other than civ specific ones) will require major edits to AssignStartingPlots.lua and other map scripts.
    Note also that some features have hard-coded references in the DLL, and others have "well-known" IDs in the GUI drawing code.

    Mod Structure
    The database actions fall into three sections
    1. Delete what we don't want
    2. Add stuff back in
    3. Renumber everything

    Add stuff back in is split into four sections - Civs (including leaders, traits and uniques), Techs, Policies and AI.
    The AI file patches the AI's strategies - read the comments!

    The delete and renumber could be done in single files, but I've split them out into eight sub-files
    • Buildings
    • Civilizations
    • Improvements
    • Leagues
    • Policies
    • Religions
    • Technologies
    • Units
    If you want to keep all the standard buildings (say) just remove/disable the two buildings files

    The sql files are in two parts split by a
    Code:
    -- TIDY UP
    line. Above the line, everything we want to delete, below the line, everything we need to do to fix up the database. You should only need to edit the sql above the line if you want to make changes to what is deleted.

    The SQL statements to delete everything as described from the database (ie every non-comment line above the -- TIDY UP lines) are
    Code:
    DELETE FROM Civilizations WHERE Type NOT IN ('CIVILIZATION_MINOR', 'CIVILIZATION_BARBARIAN');
    
    DELETE FROM Units WHERE (Combat > 0 OR RangedCombat > 0) AND Type NOT IN ('UNIT_WARRIOR', 'UNIT_BARBARIAN_WARRIOR');
    DELETE FROM Unit_ClassUpgrades WHERE UnitType IN ('UNIT_WARRIOR', 'UNIT_BARBARIAN_WARRIOR'); -- Remove the upgrade paths (this is probably unnecessary)
    DELETE FROM Units WHERE Type IN ('UNIT_ARCHAEOLOGIST', 'UNIT_CARAVAN', 'UNIT_CARGO_SHIP');
    DELETE FROM UnitPromotions_UnitCombats WHERE PromotionType NOT IN ('PROMOTION_INSTA_HEAL', 'PROMOTION_EMBARKATION', 'PROMOTION_SHOCK_1', 'PROMOTION_SHOCK_2', 'PROMOTION_DRILL_1', 'PROMOTION_DRILL_2');
    
    DELETE FROM Buildings WHERE Type NOT IN ('BUILDING_PALACE', 'BUILDING_MONUMENT');
    DELETE FROM Projects WHERE Type NOT IN ('PROJECT_APOLLO_PROGRAM', 'PROJECT_SS_BOOSTER', 'PROJECT_SS_COCKPIT', 'PROJECT_SS_ENGINE', 'PROJECT_SS_STASIS_CHAMBER');
    
    DELETE FROM Improvements WHERE Type IN ('IMPROVEMENT_ARCHAEOLOGICAL_DIG', 'IMPROVEMENT_LANDMARK');
    DELETE FROM Improvements WHERE Type IN (SELECT ImprovementType FROM Builds WHERE ImprovementType NOT IN ('IMPROVEMENT_FARM', 'IMPROVEMENT_MINE', 'IMPROVEMENT_FISHING_BOATS'));
    DELETE FROM Builds WHERE Type IN ('BUILD_SCRUB_FALLOUT', 'BUILD_RAILROAD');
    DELETE FROM GoodyHuts WHERE TYPE NOT IN ('GOODY_GOLD');
    
    DELETE FROM Technologies WHERE Type NOT IN ('TECH_AGRICULTURE', 'TECH_FUTURE_TECH');
    DELETE FROM Processes WHERE Type NOT IN ('PROCESS_WEALTH');
    DELETE FROM Eras WHERE Type NOT IN ('ERA_ANCIENT', 'ERA_INDUSTRIAL', 'ERA_MODERN');
    
    DELETE FROM Policies WHERE Level=0; -- Policies
    DELETE FROM Policies WHERE Level>0; -- Tenets
    
    DELETE FROM Religions WHERE ID>2;
    UPDATE Worlds SET MaxActiveReligions=2;
    DELETE FROM Beliefs WHERE Pantheon=1 AND Type NOT IN (SELECT Type FROM Beliefs WHERE Pantheon=1 LIMIT 10);  -- One per civ
    DELETE FROM Beliefs WHERE Founder=1 AND Type NOT IN (SELECT Type FROM Beliefs WHERE Founder=1 LIMIT 2); -- One per religion
    DELETE FROM Beliefs WHERE Follower=1 AND Type NOT IN (SELECT Type FROM Beliefs WHERE Follower=1 LIMIT 4); -- Two per religion
    DELETE FROM Beliefs WHERE Enhancer=1 AND Type NOT IN (SELECT Type FROM Beliefs WHERE Enhancer=1 LIMIT 2); -- One per religion
    DELETE FROM Beliefs WHERE Reformation=1;
    
    DELETE FROM LeagueSpecialSessions WHERE Type NOT IN ('LEAGUE_SPECIAL_SESSION_START_WORLD_CONGRESS', 'LEAGUE_SPECIAL_SESSION_START_UNITED_NATIONS');
    UPDATE LeagueSpecialSessions SET EraTrigger='ERA_INDUSTRIAL' WHERE Type='LEAGUE_SPECIAL_SESSION_START_WORLD_CONGRESS';
    UPDATE LeagueSpecialSessions SET EraTrigger='ERA_MODERN' WHERE Type='LEAGUE_SPECIAL_SESSION_START_UNITED_NATIONS';
    DELETE FROM Resolutions WHERE Type IN ('RESOLUTION_ALL_CITY_STATES_EMBARGO', 'RESOLUTION_PLAYER_EMBARGO', 'RESOLUTION_BAN_LUXURY_HAPPINESS', 'RESOLUTION_STANDING_ARMY_TAX', 'RESOLUTION_MEMBER_DISCOVERED_TECH_DISCOUNT');
    DELETE FROM Resolutions WHERE Type IN ('RESOLUTION_NUCLEAR_NON_PROLIFERATION', 'RESOLUTION_WORLD_RELIGION', 'RESOLUTION_WORLD_IDEOLOGY', 'RESOLUTION_HISTORICAL_LANDMARKS');
    DELETE FROM LeagueProjects;
    
    The SQL to tidy everything up is significantly longer![/QUOTE]
     

    Attached Files:

  2. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,295
    Location:
    Near Portsmouth, UK
    "Tips for Total Conversions"

    1) If replacing the standard civs, you will need (at least) 10 new ones
     
  3. PawelS

    PawelS Ancient Druid

    Joined:
    Dec 11, 2003
    Messages:
    2,803
    Location:
    Poland
    2) When deleting the content of an entire table that has IDs, and then filling it with new content, you need to make sure that the new content has the proper sequence of IDs. There are several ways to do it, I use the following method:

    Code:
    DELETE FROM Technologies;
    DELETE FROM Technology_Flavors;
    DELETE FROM Technology_PrereqTechs;
    DELETE FROM Technology_TradeRouteDomainExtraRange;
    
    [b]UPDATE sqlite_sequence
    SET seq = 0
    WHERE name = 'Technologies';[/b]
    
    You still need to set the ID to 0 for the first tech you add, like it's done in the standard XML file (CIV5Technologies.xml) for Agriculture. The same method can be used for all the other tables that have IDs.
     
  4. HandyVac

    HandyVac Gentleman

    Joined:
    Apr 24, 2014
    Messages:
    270
    Gender:
    Male
    Location:
    The shire where the oxen cross the river. UK.
    Deleting things from Technologies, Units or Buildings will cause errors unless you also delete every entry in every other table that references it (and there may be a lot of them). But there are ways you can make content unavailable without deleting anything.

    Setting a Unit or Building as Cost="-1" will make it unbuildable, and stop it showing up in the city production list.

    Setting a Technology as Disable="true" will make it impossible to research. You can then adjust it's gridX and gridY to hide it in an out-of-the-way corner of the techtree, and delete mentions of it in the Technology_PrereqTechs table to remove the lines linking it to and from other techs.

    You'll also want to assign your unwanted techs to the final era in your techtree, since even disabled techs will be auto-granted if the player starts the game in an era after them.
     
  5. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    Cool! I'm going to make a list in the OP with those tips.
    But I'm more looking for stuff like Pawel's, because the errors in the log weren't very telling.

    My SQL looks like this:

    Code:
    DELETE FROM Technologies;
    DELETE FROM Technology_DomainExtraMoves;
    DELETE FROM Technology_Flavors;
    DELETE FROM Technology_ORPrereqTechs;
    DELETE FROM Technology_PrereqTechs;
    DELETE FROM Technology_TradeRouteDomainExtraRange;
    DELETE FROM Civilization_FreeTechs;
    DELETE FROM HandicapInfo_AIFreeTechs;
    DELETE FROM Processes;
    DELETE FROM Improvement_TechYieldChanges;
    DELETE FROM Improvement_TechFreshWaterYieldChanges;
    
    
    INSERT INTO Technologies	(TYPE,							Cost,		GridX, 		GridY,		IconAtlas,			PortraitIndex)	VALUES
    							--GENERIC UPGRADES
    							---Tier 1
    							('TECH_BREWING',				20,			5,			1,			'TECH_ATLAS_1',		0),
    							('TECH_LORE',					20,			5,			3,			'TECH_ATLAS_1',		0),
    							('TECH_RUNES',					20,			5,			5,			'TECH_ATLAS_1',		0),
    							('TECH_MINERATION',				20,			5,			7,			'TECH_ATLAS_1',		0),
    							---Tier 2
    							('TECH_TRAINING',				20,			6,			1,			'TECH_ATLAS_1',		0),
    							('TECH_MAPPING',				20,			6,			3,			'TECH_ATLAS_1',		0),
    							('TECH_ADMINISTRATION',			20,			6,			5,			'TECH_ATLAS_1',		0),
    							('TECH_WEAPONSMITH',			20,			6,			7,			'TECH_ATLAS_1',		0),
    							---Tier 3
    							('TECH_FLETCHER',				20,			7,			1,			'TECH_ATLAS_1',		0),
    							('TECH_DATATION',				20,			7,			3,			'TECH_ATLAS_1',		0),
    							('TECH_COUNCILS',				20,			7,			5,			'TECH_ATLAS_1',		0),							
    							('TECH_MERCENARISM',			20,			7,			7,			'TECH_ATLAS_1',		0),
    							---Tier 4
    							('TECH_MILITARY_TRAINING',		20,			8,			1,			'TECH_ATLAS_1',		0),
    							('TECH_LOGISTICS',				20,			8,			3,			'TECH_ATLAS_1',		0),
    							('TECH_LAWS',					20,			8,			5,			'TECH_ATLAS_1',		0),
    							('TECH_TACTICS',				20,			8,			7,			'TECH_ATLAS_1',		0),
    							---Tier 5
    							('TECH_BOWYER',					20,			9,			1,			'TECH_ATLAS_1',		0),
    							('TECH_GUILDING',				20,			9,			3,			'TECH_ATLAS_1',		0),
    							('TECH_DYNASTY',				20,			9,			5,			'TECH_ATLAS_1',		0),
    							('TECH_ARMY_ORGANIZATION',		20,			9,			7,			'TECH_ATLAS_1',		0),
    							---Tier 6
    							('TECH_DRACONIC_BINDING',		20,			10,			4,			'TECH_ATLAS_1',		0),
    							--SEAL AND DIVINITY
    							('TECH_ASTROLOGY',				20,			12,			3,			'TECH_ATLAS_1',		0);
    
    
    
    
    --Automators by Civitar
    ---id fixinator for TECHS
    CREATE TABLE IDRemapper ( id INTEGER PRIMARY KEY AUTOINCREMENT, TYPE TEXT );
    INSERT INTO IDRemapper (TYPE) SELECT TYPE FROM Technologies ORDER BY ID;
    UPDATE Technologies SET ID =   ( SELECT IDRemapper.id-1 FROM IDRemapper WHERE Technologies.TYPE = IDRemapper.TYPE);
    DROP TABLE IDRemapper;
    ---autogenerating repetitive columns (didn't realize I could do this for unitclasses - aaaaargh!!!!)
    UPDATE Technologies SET Description = 'TXT_KEY_WBC_' || TYPE;
    UPDATE Technologies SET Help = Description || '_HELP', Quote = Description || '_QUOTE', Civilopedia = Description || '_PEDIA';
    UPDATE Technologies SET Trade = 0,
    						GoodyTech = 0,
    						ScenarioTechButton = 0
    WHERE ERA IN ('ERA_ANCIENT');
    
    Yet, the tech tree appears empty. When looking at the CivPedia, I can see the Eras (defined elsewhere) but no techs at all, so something is making the code not run, apparently.
     
  6. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,085
    Location:
    Illinois, USA
  7. PawelS

    PawelS Ancient Druid

    Joined:
    Dec 11, 2003
    Messages:
    2,803
    Location:
    Poland
    The "id fixinator" that you use is another way of doing the same thing as my code. So it's probably the lack of Eras, as LeeS noticed, that makes the tech tree fail for you. It won't work without Eras assigned to techs.
     
  8. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    Hell yeaaaah!
    That was the problem. I've added the Eras and it's all good!

    EDIT:
    Ok. So, new question: does anyone know how to enlarge the Y-axis of the tech tree? Paz's Éa enlarged it, but I believe he is on vacation on the isle next to Janbouruta's.

    EDIT2:
    It seems Éa inverted the scrolling from horizontal to vertical, maybe that was Paz's way to circumvent some kind of the tech tree's limitation.
     
  9. Civitar

    Civitar Adventurer

    Joined:
    Mar 23, 2014
    Messages:
    1,507
    Gender:
    Male
    Location:
    Switzerland
    IIRC Éa had both horizontal and vertical scrolling. He probably had to mod the UI code for the tech window to do it if that doesn't happen automatically.
     
  10. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,295
    Location:
    Near Portsmouth, UK
    The UI does not handle bi-directional scrolling well. You cannot place both scroll bars on a single box (window) so you have to revert to placing a box that scrolls one way, inside a box that scrolls the other.

    Even if you do that, you run into issues where the clipping of scrollable boxes inside scrollable boxes does not work correctly.

    There are a couple of (long) threads on the subject on these forums (probably 18 to 24 months ago now) and I wrote an example mod showing the clipping issues (although I can't find any of them at the moment)

    TL;DR; Unless you are well versed with UI elements, forget it! If I was trying to do this for real (ie not as a demo), I'd look for other options first!
     
  11. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    Thanks Howard.
    I have issues when making simple info popups, so I'm in the other end of the 'well versed' spectrum.

    (OP updated with tips so far)
     
  12. JFD

    JFD Kathigitarkh

    Joined:
    Oct 19, 2010
    Messages:
    9,078
    Location:
    The Kingdom of New Zealand
  13. PawelS

    PawelS Ancient Druid

    Joined:
    Dec 11, 2003
    Messages:
    2,803
    Location:
    Poland
    That's good to know, I did it so now I expect trouble :( Indeed, there are references to the Missionary and Inquisitor in the DLL code. What's the best way to disable them without causing crashes? Setting their faith cost to a very high number, or just making them "unpurchasable" by setting it to 0?

    Also, will the AI purchase for faith units other than Missionaries, Inquisitors or Great People? I can't find anything about that in the source code...
     
  14. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
  15. Klisz

    Klisz Chieftain

    Joined:
    Aug 18, 2014
    Messages:
    805
    It's a Pokémon.
     
  16. Civitar

    Civitar Adventurer

    Joined:
    Mar 23, 2014
    Messages:
    1,507
    Gender:
    Male
    Location:
    Switzerland
    I'd like to know this as well.
     
  17. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,295
    Location:
    Near Portsmouth, UK
    From looking at the code, setting the cost to 0 should work for both human and AI players

    The AI has a very prescriptive order that it spends faith (see CvReligionAI:: DoFaithPurchases()) - prophets to found/enhance religion, missionaries, buildings, missionaries, missionaries, great people, and eventually inquisitors. It never considers buying combat units with faith.

    Not sure how setting the cost of a missionary to 0 will affect that, it may get into a situation where it says "buy a missionary ... I can't" and never spend it's faith. It certainly won't look at other faith units to buy them with faith - as that's just not in the code.

    So probably best just to add any required logic in Lua at the start of the AI turns.
     
  18. PawelS

    PawelS Ancient Druid

    Joined:
    Dec 11, 2003
    Messages:
    2,803
    Location:
    Poland
    That's what I was afraid of :( Buying combat unit with faith (which represents summoning) is an important aspect of my mod, so I need to force the AI to do it using Lua.
     
  19. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,295
    Location:
    Near Portsmouth, UK
    About as clean as I can get it (from a database point of view, the SQL could use some tidying up!) ... I present the most yawn inducing "Total Conversion" mod ever ... "TC - Minimal" (attached in first post)

    Civilizations, Leaders and Traits
    • All standard majors removed
    • Ten custom (minimal) majors added
    • Minors and Barbarians pared back
    Units and UnitPromotions
    • Settler, Worker, Work Boat
    • Great people (GS, GM, GE, GG, GA, GP, GArt, GMus, GWri) (nine)
    • Space ship parts (four)
    • Warrior (and barbarian variant)
    • Religious (Missionary and Inquisitor)
    • Ten UUs (based on Warrior)
    • Twenty basic promotions
    Buildings
    • Palace and Monument
    • Ten UBs (based on Monument)
    Projects
    • Apollo program plus four space ship parts (required for science victory)
    Processes
    • Wealth (others removed)
    Improvements, Routes and Builds
    • City Ruins, Barb Camps and Goody Huts
    • Roads (railroad removed)
    • Farm, Mine and Fishing Boats
    • Repair
    • Remove forest, jungle, marsh and route
    Goody Huts
    • One giving gold
    Techs and Eras
    • Three eras (Ancient, Industrial and Modern)
    • Agriculture, Future Tech plus two techs per era (eight techs total)
    Policies
    • Trees (policy branches) unchanged (due to hard-coded UI/DLL)
    • One (minimal) policy per branch
    Ideologies and Tenets
    • Ideologies unchanged
    • All tenets removed
    Religions & Beliefs
    • pantheon plus two religions
    • 10 pantheon, 2 founder, 4 follower and 2 enhancer beliefs
    Leagues and Resolutions
    • Two leagues (initial and UN)
    • Four resolutions (required for voting) plus Change Host and World Leader (six resolutions total)
    Terrains, Features and Resources
    • Unchanged (except for civ specific resources, which have been removed)
    Notes

    (continued in next post ...)
     
  20. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,295
    Location:
    Near Portsmouth, UK
    (... continued from previous post)

    Civilizations, Leaders and Traits
    You need a minimum of 10 civs, any less and you have to remove two from the default number of the map size you are playing (so standard map you can only play 6 civs on and small map you can only play 4 civs on - this appears to be hard-coded within the .exe file as that's where the CTD happens if you don't follow the rules!)

    The Minors and Barbarians define a lot of city names, I stripped those back to 5 each (the minimum required)

    Units and UnitPromotions
    Left the Warrior in as the UUs are based on it, but you could remove that as well, provided you add some other default unit
    The Work Boat can be removed if you don't want to improve sea resources
    The settler can possibly be removed, provided you add something else that can found cities, the Worker is a bad idea to remove as demanding a work unit from a CS is hard-coded to give a Worker.
    The nine standard great people are all hard-coded within the DLL (mostly in the buy GP with faith code after completing a policy tree - note the DLL hard-codes GP to specific trees, and the Mayan trait)
    If you take the spaceship parts out, you'll also need to remove the associated projects and mod the victory progress UI
    Missionary and Inquisitor are hard-coded in the DLL. If you disabled faith generation, you could remove them (but then you'll need to mod the Natural Wonders and AssignStartingPlots.lus)

    The promotions that are left are either some basic ones (insta-heal, embark, drill 1 and 2 and shock 1 and 2) for the Warrior (which could be removed if some others are added back in) and a few that are referenced from Features (altitude training) or referenced directly from the DLL (via the PostDefines table - remove these at your own risk!)

    Buildings
    Every capital needs a palace, if you remove this you MUST add a building with the palace flag set.
    The Monument could be removed, but you need at least one default building for the UBs to be based on

    Projects
    Removing all projects will cause an XML validation error. I left Apollo as without it you'll need to mod the Victory Progress UI. Unless adding in a modded project, best to leave it in and not hook it up to a tech.

    Processes
    Removing all processes will cause an XML validation error. Pick either research or wealth to leave in, you don't need to hook it up to a tech.

    Improvements, Routes and Builds
    Huts and camps are required by the map scripts, ruins are required by the DLL (on razing a city)
    You need something for the workers to do (or the AI auto-improve land code sulks), so I left in Farm and Mine - these could be removed if adding something else
    If you leave workboats in, you'll need to leave in fishing boats - but you could remove both
    The railroad build has been removed, and you could remove the road build as well - just do NOT delete them from the Routes table. The path-finding and city connection code in the DLL will not work properly if you do!
    IMPORTANT: Take great care with the Builds table, as the DLL hard-codes references to some of them by ID (not Type) - fortunately this table doesn't need to have contiguous IDs.

    Goody Huts
    Unless modding the map scripts to remove goody hut improvements, you'll need to leave in something for the hut to produce. If you use the Shoshone UUs ability, you MUST have at least three different goody hut rewards

    Techs and Eras
    The DLL expects to find ERA_ANCIENT, ERA_INDUSTRIAL and ERA_MODERN (industrial via hard-coding, the other two via the PostDefines table) - but you can rename them as anything eg "Early", "Middle" and "Late", but don't change their Types.

    The UI code expects to find Eras in ascending order in the database and the pedia expects them to have ascending TXT_KEYs (which I didn't do for this example ) - see the initial discussion in this thread
    Agriculture and Future Tech could be removed, but you'll need to add (at least) one initial tech to give to each civ and have one that repeats

    Policies
    If you want to change the number of policy trees (branches) you'll need to mod the UI.
    It's also not a good idea to change the Types (POLICY_HONOR, POLICY_LIBERTY, etc) as those are hard-coded in the DLL

    Ideologies and Tenets
    The three ideologies are hard-coded in the DLL - there must be three ... not two or four. If you don't want ideologies, just don't have any buildings that enable them!
    You can change the display name of the ideologies, but the Types are hard-coded in the DLL
    If you want to change the number of tenets per level you'll need to mod the UI. To change the number of tiers (level) requires DLL mods (as the AI pushes for a level 3 tenet)

    Religions & Beliefs
    Not sure how the AI will handle only a single religion - as there is code in the DLL to try to found an opposing religion
    You need at least one pantheon belief per civ (so ten), and one founder, two follower and one enhancer beliefs per religion (assuming you don't enable the trait that gives bonus beliefs or the policy to grant reformation beliefs)

    Leagues and Resolutions
    You could probably get away with a single league session. If you don't want the League, it's probably best to leave the minimum entries in the database and just not set the enabler on any tech.

    Terrains, Features and Resources
    Changes to terrains, features and resources (other than civ specific ones) will require major edits to AssignStartingPlots.lua and other map scripts.
    Note also that some features have hard-coded references in the DLL, and others have "well-known" IDs in the GUI drawing code.

    Mod Structure
    The database actions fall into three sections
    1. Delete what we don't want
    2. Add stuff back in
    3. Renumber everything

    Add stuff back in is split into four sections - Civs (including leaders, traits and uniques), Techs, Policies and AI.
    The AI file patches the AI's strategies - read the comments!

    The delete and renumber could be done in single files, but I've split them out into eight sub-files
    • Buildings
    • Civilizations
    • Improvements
    • Leagues
    • Policies
    • Religions
    • Technologies
    • Units
    If you want to keep all the standard buildings (say) just remove/disable the two buildings files

    The sql files are in two parts split by a
    Code:
    -- TIDY UP
    line. Above the line, everything we want to delete, below the line, everything we need to do to fix up the database. You should only need to edit the sql above the line if you want to make changes to what is deleted.

    The SQL statements to delete everything as described from the database (ie every non-comment line above the -- TIDY UP lines) are
    Code:
    DELETE FROM Civilizations WHERE Type NOT IN ('CIVILIZATION_MINOR', 'CIVILIZATION_BARBARIAN');
    
    DELETE FROM Units WHERE (Combat > 0 OR RangedCombat > 0) AND Type NOT IN ('UNIT_WARRIOR', 'UNIT_BARBARIAN_WARRIOR');
    DELETE FROM Unit_ClassUpgrades WHERE UnitType IN ('UNIT_WARRIOR', 'UNIT_BARBARIAN_WARRIOR'); -- Remove the upgrade paths (this is probably unnecessary)
    DELETE FROM Units WHERE Type IN ('UNIT_ARCHAEOLOGIST', 'UNIT_CARAVAN', 'UNIT_CARGO_SHIP');
    DELETE FROM UnitPromotions_UnitCombats WHERE PromotionType NOT IN ('PROMOTION_INSTA_HEAL', 'PROMOTION_EMBARKATION', 'PROMOTION_SHOCK_1', 'PROMOTION_SHOCK_2', 'PROMOTION_DRILL_1', 'PROMOTION_DRILL_2');
    
    DELETE FROM Buildings WHERE Type NOT IN ('BUILDING_PALACE', 'BUILDING_MONUMENT');
    DELETE FROM Projects WHERE Type NOT IN ('PROJECT_APOLLO_PROGRAM', 'PROJECT_SS_BOOSTER', 'PROJECT_SS_COCKPIT', 'PROJECT_SS_ENGINE', 'PROJECT_SS_STASIS_CHAMBER');
    
    DELETE FROM Improvements WHERE Type IN ('IMPROVEMENT_ARCHAEOLOGICAL_DIG', 'IMPROVEMENT_LANDMARK');
    DELETE FROM Improvements WHERE Type IN (SELECT ImprovementType FROM Builds WHERE ImprovementType NOT IN ('IMPROVEMENT_FARM', 'IMPROVEMENT_MINE', 'IMPROVEMENT_FISHING_BOATS'));
    DELETE FROM Builds WHERE Type IN ('BUILD_SCRUB_FALLOUT', 'BUILD_RAILROAD');
    DELETE FROM GoodyHuts WHERE TYPE NOT IN ('GOODY_GOLD');
    
    DELETE FROM Technologies WHERE Type NOT IN ('TECH_AGRICULTURE', 'TECH_FUTURE_TECH');
    DELETE FROM Processes WHERE Type NOT IN ('PROCESS_WEALTH');
    DELETE FROM Eras WHERE Type NOT IN ('ERA_ANCIENT', 'ERA_INDUSTRIAL', 'ERA_MODERN');
    
    DELETE FROM Policies WHERE Level=0; -- Policies
    DELETE FROM Policies WHERE Level>0; -- Tenets
    
    DELETE FROM Religions WHERE ID>2;
    UPDATE Worlds SET MaxActiveReligions=2;
    DELETE FROM Beliefs WHERE Pantheon=1 AND Type NOT IN (SELECT Type FROM Beliefs WHERE Pantheon=1 LIMIT 10);  -- One per civ
    DELETE FROM Beliefs WHERE Founder=1 AND Type NOT IN (SELECT Type FROM Beliefs WHERE Founder=1 LIMIT 2); -- One per religion
    DELETE FROM Beliefs WHERE Follower=1 AND Type NOT IN (SELECT Type FROM Beliefs WHERE Follower=1 LIMIT 4); -- Two per religion
    DELETE FROM Beliefs WHERE Enhancer=1 AND Type NOT IN (SELECT Type FROM Beliefs WHERE Enhancer=1 LIMIT 2); -- One per religion
    DELETE FROM Beliefs WHERE Reformation=1;
    
    DELETE FROM LeagueSpecialSessions WHERE Type NOT IN ('LEAGUE_SPECIAL_SESSION_START_WORLD_CONGRESS', 'LEAGUE_SPECIAL_SESSION_START_UNITED_NATIONS');
    UPDATE LeagueSpecialSessions SET EraTrigger='ERA_INDUSTRIAL' WHERE Type='LEAGUE_SPECIAL_SESSION_START_WORLD_CONGRESS';
    UPDATE LeagueSpecialSessions SET EraTrigger='ERA_MODERN' WHERE Type='LEAGUE_SPECIAL_SESSION_START_UNITED_NATIONS';
    DELETE FROM Resolutions WHERE Type IN ('RESOLUTION_ALL_CITY_STATES_EMBARGO', 'RESOLUTION_PLAYER_EMBARGO', 'RESOLUTION_BAN_LUXURY_HAPPINESS', 'RESOLUTION_STANDING_ARMY_TAX', 'RESOLUTION_MEMBER_DISCOVERED_TECH_DISCOUNT');
    DELETE FROM Resolutions WHERE Type IN ('RESOLUTION_NUCLEAR_NON_PROLIFERATION', 'RESOLUTION_WORLD_RELIGION', 'RESOLUTION_WORLD_IDEOLOGY', 'RESOLUTION_HISTORICAL_LANDMARKS');
    DELETE FROM LeagueProjects;
    
    The SQL to tidy everything up is significantly longer!
     

Share This Page