Making a "Mostly Gutted Mod": removing most elements for a complete rebuild

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
UPDATE: THIS IS NOW A DONE DEAL. Lemmy101 solved the key obstacle; Ahwaric put it all together:
It seems that I might have succeded with the gutted mod.
Check it here:http://forums.civfanatics.com/showthread.php?p=9865954#post9865954

It will probably have to be improved, but works so far.
--------------------------------------------------------

Some mods involve entirely (or almost entirely) new tech trees, civs, buildings, units, etc. from base civ5. I've decided after some thought that the best approach would be to build a "Mostly Gutted Mod" -- basically civ5 missing most elements -- first, then start adding my own techs, buildings, units, and so forth. So I'm building up a mod (with parallel structure to Assets/XML/) that has files that each delete all elements (and then re-adds one or a couple civ5 elements just so I can test). So, for example, I have a guttedCivilizations.xml file that has:

Code:
<GameData>
     <Civilizations>
          < delete />
          [I]base civ pasted here that I will change later[/I]
          [I]base civ pasted here that I will change later[/I]
     </Civilizations>
     [I]similar delete here for additional tables in this file (but without "add backs")[/I]
</GameData>

However, removing elements wholesale is far from trivial due to all of the interdependencies (as Kael discusses in his guide). Has anyone succeeded in stripping out large parts of the game like this yet? If so, you might want to think about posting your gutted mod for others (like me) to use.

Or just wait for me to do it, although it might be a while. It was pretty easy to gut civs (putting back 2) and all units (putting back warriors and settlers). So now I have a "working" mod with only 2 civs and 2 buildable units. But I'm currently struggling with buildings (although I think I've identified all of the building references from other files) and techs (which have many, many files that refer to them). My plan is to entirely gut civs, leaders, units, buildings, techs and policies; partially gut resources, improvements, and promotions (just modern ones); but leave terrains, features and related items alone for the most part.

If anyone has anything like this, please do post it (or I will if no one beats me to it). Or if you have any suggestions or think I'm going about it the wrong way, let me know.
 
Excellent idea, especially for building TCs. I remember trying to gut CiV pre BTS for a Babylon 5 mod. It was a headache. When I abandoned that project I though it would of been more easy to write blank or minimal files from scratch. That might also be the case here.
 
Once you strip it bare and its still functional please post it. I would have killed for a CIV4 reference like this.

~ Zill
 
I'm in the process of stripping Vanilla Civ5 and make an almost empty skeleton, for The Ancient Mediterranean mod. I'm having difficulties removing resources. The game crashes on loading a game, even a scenario, wich was made in WorldBuilder with TAM mod. The fact that the worldbuilder generate maps that don't contain uranium, aluminum, or coal (the 3 resources I want out) makes me think that the XMLs are all right.

I tried removing the references to those resources (RESOURCE_XXXXX) in AssignStartingPlots.lua, but it didn't work, so I then tried to remove all function refering to the resources, still doesnt work. My LUA knowledge is next to null, so I might have done something wrong.

It is said in the AssignStartingPlot.lua file that everything taking place in the file is local, so I don't understand why the mod would crash when launching trough a scenario file, since a scenario obviously doesnt need to calculate initial starts for civs.

so:

1- Anyone has successfully achieve to remove a resource?
2- I know nothing of LUA, as I said, but does it require some kind of "check" for it to work? ie.: if AssignStartingPlot.lua is messed up, but unrequired for a precise game, will it still check it for integrity and then crash the game if it isn't right?

Once this is figured out, a huge chunk of Vanilla could be removed.
 
I'm in the process of stripping Vanilla Civ5 and make an almost empty skeleton, for The Ancient Mediterranean mod. I'm having difficulties removing resources. The game crashes on loading a game, even a scenario, wich was made in WorldBuilder with TAM mod. The fact that the worldbuilder generate maps that don't contain uranium, aluminum, or coal (the 3 resources I want out) makes me think that the XMLs are all right.

I tried removing the references to those resources (RESOURCE_XXXXX) in AssignStartingPlots.lua, but it didn't work, so I then tried to remove all function refering to the resources, still doesnt work. My LUA knowledge is next to null, so I might have done something wrong.

It is said in the AssignStartingPlot.lua file that everything takign place in the file is local, so I don't understand why the mod would crash when launching trough a scenario file, since a scenario obviously doesnt need to calculate initial starts for civs.

so:

1- Anyone has successfully achieve to remove a resource?
2- I not nothing of LUA, as I said, but does it require some kind of "check" for it to work? ie.: if AssignStartingPlot.lua is messed up, but unrequired for a precise game, will it still check it for integrity and then crash the game if it isn't right?

Once this is figured out, a huge chunk of Vanilla could be removed.

try to check or pm dale or post the issue at weplayciv. he has the most resource experience with his hardwood mod.
 
Kael's guide only covers XML parts of removing horses, I followed his guide toroughly, and still it crashes. I'll go download his mod though, to see if he indeed modified some LUAs
 
I'm going at this two ways: 1) all at once, 2) one piece at a time. For the one-piece-at-a-time, I've gotten as far as removal of all leaders, civs, and units (then replacing a couple of each to make a functioning game). Buildings should be the next thing because there aren't that many references to them, but so far I haven't succeeded in gutting them.

For the all-at-once approach, I've built my mod that has fully eviscerated civs, leaders, units, buildings, techs, policies, policy branches, and any elements in any other files that reference these things (I think), then replaced a few of each in a very stripped down form (3 civs without traits, etc.). But it's not working yet.

Really, the all-at-once would be the best approach except that there isn't any feedback at all about where reference errors are occurring. The Logfiles are not functioning, as I learned in another thread. I'll keep trying but it's just pure luck whether I can spot the specific errors. It's like having to write a big program and have it work without any "syntax error at line ____"s to help.
 
The problem I think is the foreign key refs to the unit etc you are trying to delete. This is to preserve data integrity. Either you have to delete all the entries that use the unit first or tell the DB to do it.

I think you are going to have to use SQL.
XML is really only there for simple changes but I do not think it can alter DB schema.

Try something like this...

Say you have Unit_UniqueNames.

It was created my the XML transformed into the SQL:
CREATE TABLE Unit_UniqueNames ('UnitType' text , 'UniqueName' text not null , foreign key (UnitType) references Units(Type), foreign key (UniqueName) references Language_en_US(Tag))

First I think you will have to alter the table with:

ALTER TABLE Unit_UniqueNames ('UnitType' text , 'UniqueName' text not null , foreign key (UnitType) references Units(Type) ON DELETE CASCADE, foreign key (UniqueName) references Language_en_US(Tag))

Then when you Delete the unit from the table Units it will cascade to any table that has a foreign key that specifies ON DELETE CASCADE. So long as there is no table in the system that has a non cascading foreign key to it it should work.

This will not be easy mind you.
You will have to find every single table that has a foreign key to the table you want to delete entries from.

For units this list is:

<Table name="Building_FreeUnits">
<Table name="Civilization_UnitClassOverrides">
<Table name="Unit_AITypes">
<Table name="Unit_Buildings">
<Table name="Unit_BuildingClassRequireds">
<Table name="Unit_ProductionModifierBuildings">
<Table name="Unit_Builds">
<Table name="Unit_ClassUpgrades">
<Table name="Unit_FreePromotions">
<Table name="Unit_Flavors">
<Table name="Unit_GreatPersons">
<Table name="Unit_ResourceQuantityRequirements">
<Table name="Unit_UniqueNames">
<Table name="Unit_NotAITypes">
<Table name="Unit_ProductionTraits">
<Table name="Unit_TechTypes">
<Table name="UnitGameplay2DScripts">

Once this is done it will attempt to CASCADE delete everything that uses the unit you are tying to delete... but that might not work since some of those may be foreign keys to entries in yet other tables.

The DB is clearly not set up with wholesale deletions in mind.
 
The problem I think is the foreign key refs to the unit etc you are trying to delete. This is to preserve data integrity. Either you have to delete all the entries that use the unit first or tell the DB to do it.

I think you are going to have to use SQL.
XML is really only there for simple changes but I do not think it can alter DB schema.

Try something like this...

Say you have Unit_UniqueNames.

It was created my the XML transformed into the SQL:
CREATE TABLE Unit_UniqueNames ('UnitType' text , 'UniqueName' text not null , foreign key (UnitType) references Units(Type), foreign key (UniqueName) references Language_en_US(Tag))

First I think you will have to alter the table with:

ALTER TABLE Unit_UniqueNames ('UnitType' text , 'UniqueName' text not null , foreign key (UnitType) references Units(Type) ON DELETE CASCADE, foreign key (UniqueName) references Language_en_US(Tag))

Then when you Delete the unit from the table Units it will cascade to any table that has a foreign key that specifies ON DELETE CASCADE. So long as there is no table in the system that has a non cascading foreign key to it it should work.

This will not be easy mind you.
You will have to find every single table that has a foreign key to the table you want to delete entries from.

For units this list is:

<Table name="Building_FreeUnits">
<Table name="Civilization_UnitClassOverrides">
<Table name="Unit_AITypes">
<Table name="Unit_Buildings">
<Table name="Unit_BuildingClassRequireds">
<Table name="Unit_ProductionModifierBuildings">
<Table name="Unit_Builds">
<Table name="Unit_ClassUpgrades">
<Table name="Unit_FreePromotions">
<Table name="Unit_Flavors">
<Table name="Unit_GreatPersons">
<Table name="Unit_ResourceQuantityRequirements">
<Table name="Unit_UniqueNames">
<Table name="Unit_NotAITypes">
<Table name="Unit_ProductionTraits">
<Table name="Unit_TechTypes">
<Table name="UnitGameplay2DScripts">

Once this is done it will attempt to CASCADE delete everything that uses the unit you are tying to delete... but that might not work since some of those may be foreign keys to entries in yet other tables.

The DB is clearly not set up with wholesale deletions in mind.

But you know once you have done this you can use SQL to
DELETE FROM Units
and that one line will remove the whole table.

So I think it will take you less time to learn SQL and write the SQL to do what you want than to do the tedious work you are doing to remove things one at a time.


Hmmm... ok really meant to hit edit not quote... Is there no way to delete a post?
 
The notes given indicate that the system DOES NOT cascade deletes; instead, once the tables are all loaded and finalised, it checks referential integrity and barfs if it fails, falling back to before it tried to apply the mod.
 
First you have to set your quoted post to ON DELETE CASCADE.
lol... nice

The notes given indicate that the system DOES NOT cascade deletes; instead, once the tables are all loaded and finalised, it checks referential integrity and barfs if it fails, falling back to before it tried to apply the mod.

I absolutely agree. The tables created do not have ON DELETE CASCADE on any foreign keys [that I have seen] But if ALTER TABLE can be performed on the tables that can be remedied no?

Not that I have tried it. Just suggesting if you want to mod out all units its the fastest way to go about it.
 
Kael's guide only covers XML parts of removing horses, I followed his guide toroughly, and still it crashes. I'll go download his mod though, to see if he indeed modified some LUAs

OH I REMEMBER NOW!!!!!

In addition to the PM I sent you, there is one golden rule:

Thou shalt not delete iron!

Iron is the only resource that MUST be in the game.
 
Bah! I'm sure there are different ways to go about this, but the fatal flaw in any approach is that there is absolutely no feedback on where the reference errors are occurring (or if the error is something else entirely). I don't see how doing sql directly (vs. sql commands from xml) helps with this problem. Conceptually, I can deconstruction the whole thing with sql direct or sql via xml (I like the later because it puts the deconstruction info right above the new elements that I will add). I have the whole thing built and I'm sure from experience that I probably made 5 errors here and there (typos and maybe a fundamental misunderstanding somewhere). I could proceed with troubleshooting if I got any feedback information when it craps out. It's really hopeless without that.

I simply don't have time to delete one unit, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game, delete one tech, test game, delete one policy, test game, delete one promotion, test game.</rant>
 
Hmmm.... unfortunately I have just discovered that:
Bah.... from:
http://www.sqlite.org/lang_altertable.html

SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table. It is not possible to rename a column, remove a column, or add or remove constraints from a table.

So you cannot change [aka remove/add] the FK ref do have the option ON DELETE CASCADE.

So I have decided to get you started...
DELETE FROM Building_FreeUnits WHERE UnitType IS NOT NULL;
DELETE FROM Civilization_UnitClassOverrides WHERE UnitType IS NOT NULL;
DELETE FROM Unit_AITypes WHERE UnitType IS NOT NULL;
DELETE FROM Unit_Buildings WHERE UnitType IS NOT NULL;
DELETE FROM Unit_BuildingClassRequireds WHERE UnitType IS NOT NULL;
DELETE FROM Unit_ProductionModifierBuildings WHERE UnitType IS NOT NULL;
DELETE FROM Unit_Builds WHERE UnitType IS NOT NULL;
DELETE FROM Unit_ClassUpgrades WHERE UnitType IS NOT NULL;
DELETE FROM Unit_FreePromotions WHERE UnitType IS NOT NULL;
DELETE FROM Unit_Flavors WHERE UnitType IS NOT NULL;
DELETE FROM Unit_GreatPersons WHERE UnitType IS NOT NULL;
DELETE FROM Unit_ResourceQuantityRequirements WHERE UnitType IS NOT NULL;
DELETE FROM Unit_UniqueNames WHERE UnitType IS NOT NULL;
DELETE FROM Unit_NotAITypes WHERE UnitType IS NOT NULL;
DELETE FROM Unit_ProductionTraits WHERE UnitType IS NOT NULL;
DELETE FROM Unit_TechTypes WHERE UnitType IS NOT NULL;
DELETE FROM UnitGameplay2DScripts WHERE UnitType IS NOT NULL;
DELETE FROM Units;

These commands above will blow away all Units.

How did I build this? Using FireFox SQLite Manager plugin you can execute
SELECT name,sql FROM sqlite_master WHERE sql LIKE 'CREATE TABLE%references Units(Type)%'
to get a list of all the tables with FK refs to Units(Type):

SELECT name,sql FROM sqlite_master WHERE sql LIKE 'CREATE TABLE%references Technologies(Type)%'
for example will give a list of all FKs to Technologies(Type) and the create statement used.
such as:
"AICityStrategies" "CREATE TABLE AICityStrategies ('ID' integer primary key autoincrement , 'Type' text not null unique , 'CheckTriggerTurnCount' integer , 'MinimumNumTurnsExecuted' integer , 'WeightThreshold' integer default 0 , 'NoMinorCivs' boolean default 0 , 'Permanent' boolean default 0 , 'TechPrereq' text default NULL , 'TechObsolete' text default NULL , 'Advisor' text , 'AdvisorCounsel' text , 'AdvisorCounselImportance' integer default 1 , foreign key (TechPrereq) references Technologies(Type), foreign key (TechObsolete) references Technologies(Type))"
Spoiler :
"AIEconomicStrategies" "CREATE TABLE AIEconomicStrategies ('ID' integer primary key autoincrement , 'Type' text not null unique , 'DontUpdateCityFlavors' boolean default 0 , 'NoMinorCivs' boolean default 0 , 'CheckTriggerTurnCount' integer default 0 , 'MinimumNumTurnsExecuted' integer default 0 , 'WeightThreshold' integer default 0 , 'FirstTurnExecuted' integer default 0 , 'TechPrereq' text default NULL , 'TechObsolete' text default NULL , 'Advisor' text , 'AdvisorCounsel' text , 'AdvisorCounselImportance' integer default 1 , foreign key (TechPrereq) references Technologies(Type), foreign key (TechObsolete) references Technologies(Type))"
"AIMilitaryStrategies" "CREATE TABLE AIMilitaryStrategies ('ID' integer primary key autoincrement , 'Type' text not null unique , 'DontUpdateCityFlavors' boolean default 0 , 'NoMinorCivs' boolean default 0 , 'OnlyMinorCivs' boolean default 0 , 'UpdateCitySpecializations' boolean default 0 , 'CheckTriggerTurnCount' integer default 0 , 'FirstTurnExecuted' integer default 0 , 'MinimumNumTurnsExecuted' integer default 0 , 'WeightThreshold' integer default 0 , 'TechObsolete' text default NULL , 'TechPrereq' text default NULL , 'Advisor' text , 'AdvisorCounsel' text , 'AdvisorCounselImportance' integer default 1 , foreign key (TechObsolete) references Technologies(Type), foreign key (TechPrereq) references Technologies(Type))"
"Buildings" "CREATE TABLE Buildings ('ID' integer primary key autoincrement , 'Type' text not null unique , 'Description' text , 'Civilopedia' text , 'Strategy' text , 'Help' text , 'Quote' text , 'GoldMaintenance' integer default 0 , 'MutuallyExclusiveGroup' integer default '-1' , 'TeamShare' boolean default 0 , 'Water' boolean default 0 , 'River' boolean default 0 , 'FreshWater' boolean default 0 , 'Mountain' boolean default 0 , 'NearbyMountainRequired' boolean default 0 , 'Hill' boolean default 0 , 'Flat' boolean default 0 , 'FoundsReligion' boolean default 0 , 'IsReligious' boolean default 0 , 'BorderObstacle' boolean default 0 , 'Capital' boolean default 0 , 'GoldenAge' boolean default 0 , 'MapCentering' boolean default 0 , 'NeverCapture' boolean default 0 , 'NukeImmune' boolean default 0 , 'AllowsWaterRoutes' boolean default 0 , 'ExtraLuxuries' boolean default 0 , 'DiplomaticVoting' boolean default 0 , 'Cost' integer default 0 , 'NumCityCostMod' integer default 0 , 'HurryCostModifier' integer default 0 , 'MinAreaSize' integer default 0 , 'ConquestProb' integer default 0 , 'CitiesPrereq' integer default 0 , 'LevelPrereq' integer default 0 , 'Culture' integer default 0 , 'CultureRateModifier' integer default 0 , 'GlobalCultureRateModifier' integer default 0 , 'GreatPeopleRateModifier' integer default 0 , 'GlobalGreatPeopleRateModifier' integer default 0 , 'GreatGeneralRateModifier' integer default 0 , 'GoldenAgeModifier' integer default 0 , 'UnitUpgradeCostMod' integer default 0 , 'Experience' integer default 0 , 'GlobalExperience' integer default 0 , 'FoodKept' integer default 0 , 'Airlift' integer default 0 , 'AirModifier' integer default 0 , 'NukeModifier' integer default 0 , 'NukeExplosionRand' integer default 0 , 'HealRateChange' integer default 0 , 'Happiness' integer default 0 , 'HappinessPerCity' integer default 0 , 'CityCountUnhappinessMod' integer default 0 , 'NoOccupiedUnhappiness' boolean default 0 , 'WorkerSpeedModifier' integer default 0 , 'MilitaryProductionModifier' integer default 0 , 'SpaceProductionModifier' integer default 0 , 'BuildingProductionModifier' integer default 0 , 'WonderProductionModifier' integer default 0 , 'TradeRouteModifier' integer default 0 , 'CapturePlunderModifier' integer default 0 , 'PolicyCostModifier' integer default 0 , 'PlotCultureCostModifier' integer default 0 , 'GlobalPopulationChange' integer default 0 , 'TechShare' integer default 0 , 'FreeTechs' integer default 0 , 'FreePolicies' integer default 0 , 'Gold' integer default 0 , 'AllowsRangeStrike' boolean default 0 , 'Defense' integer default 0 , 'GlobalDefenseMod' integer default 0 , 'MinorFriendshipChange' integer default 0 , 'VictoryPoints' integer default 0 , 'BuildingClass' text default NULL , 'ArtDefineTag' text default NULL , 'NearbyTerrainRequired' text default NULL , 'VictoryPrereq' text default NULL , 'FreeStartEra' text default NULL , 'MaxStartEra' text default NULL , 'ObsoleteTech' text default NULL , 'EnhancedYieldTech' text default NULL , 'FreeBuilding' text default NULL , 'FreePromotion' text default NULL , 'TrainedFreePromotion' text default NULL , 'ReplacementBuildingClass' text default NULL , 'PrereqTech' text default NULL , 'SpecialistType' text default NULL , 'SpecialistCount' integer default 0 , 'SpecialistExtraCulture' integer default 0 , 'GreatPeopleRateChange' integer default 0 , 'CityWall' boolean default 0 , 'DisplayPosition' integer default 0 , 'PortraitIndex' integer default '-1' , 'WonderSplashImage' text default NULL , 'WonderSplashAnchor' text default 'R,T' , 'WonderSplashAudio' text , 'IconAtlas' text default NULL , 'ArtInfoCulturalVariation' boolean default 0 , 'ArtInfoEraVariation' boolean default 0 , 'ArtInfoRandomVariation' boolean default 0 , foreign key (Description) references Language_en_US(Tag), foreign key (Civilopedia) references Language_en_US(Tag), foreign key (Strategy) references Language_en_US(Tag), foreign key (Help) references Language_en_US(Tag), foreign key (Quote) references Language_en_US(Tag), foreign key (BuildingClass) references BuildingClasses(Type), foreign key (NearbyTerrainRequired) references Terrains(Type), foreign key (VictoryPrereq) references Victories(Type), foreign key (FreeStartEra) references Eras(Type), foreign key (MaxStartEra) references Eras(Type), foreign key (ObsoleteTech) references Technologies(Type), foreign key (EnhancedYieldTech) references Technologies(Type), foreign key (FreeBuilding) references BuildingClasses(Type), foreign key (FreePromotion) references UnitPromotions(Type), foreign key (TrainedFreePromotion) references UnitPromotions(Type), foreign key (ReplacementBuildingClass) references BuildingClasses(Type), foreign key (PrereqTech) references Technologies(Type), foreign key (SpecialistType) references Specialists(Type), foreign key (IconAtlas) references IconTextureAtlases(Atlas))"
"Building_TechAndPrereqs" "CREATE TABLE Building_TechAndPrereqs ('BuildingType' text , 'TechType' text , foreign key (BuildingType) references Buildings(Type), foreign key (TechType) references Technologies(Type))"
"Civilization_DisableTechs" "CREATE TABLE Civilization_DisableTechs ('CivilizationType' text , 'TechType' text , foreign key (CivilizationType) references Civilizations(Type), foreign key (TechType) references Technologies(Type))"
"Civilization_FreeTechs" "CREATE TABLE Civilization_FreeTechs ('CivilizationType' text , 'TechType' text , foreign key (CivilizationType) references Civilizations(Type), foreign key (TechType) references Technologies(Type))"
"Traits" "CREATE TABLE Traits ('ID' integer primary key autoincrement , 'Type' text not null unique , 'Description' text , 'ShortDescription' text , 'LevelExperienceModifier' integer default 0 , 'GreatPeopleRateModifier' integer default 0 , 'GreatScientistRateModifier' integer default 0 , 'GreatGeneralRateModifier' integer default 0 , 'GreatGeneralExtraBonus' integer default 0 , 'MaxGlobalBuildingProductionModifier' integer default 0 , 'MaxTeamBuildingProductionModifier' integer default 0 , 'MaxPlayerBuildingProductionModifier' integer default 0 , 'CityUnhappinessModifier' integer default 0 , 'PopulationUnhappinessModifier' integer default 0 , 'CityStateBonusModifier' integer default 0 , 'CityStateFriendshipModifier' integer default 0 , 'CityStateCombatModifier' integer default 0 , 'LandBarbarianConversionPercent' integer default 0 , 'SeaBarbarianConversionPercent' integer default 0 , 'CapitalBuildingModifier' integer default 0 , 'PlotBuyCostModifier' integer default 0 , 'PlotCultureCostModifier' integer default 0 , 'CultureFromKills' integer default 0 , 'CityCultureBonus' integer default 0 , 'PolicyCostModifier' integer default 0 , 'TradeRouteChange' integer default 0 , 'WonderProductionModifier' integer default 0 , 'PlunderModifier' integer default 0 , 'GoldenAgeDurationModifier' integer default 0 , 'GoldenAgeMoveChange' integer default 0 , 'GoldenAgeCombatModifier' integer default 0 , 'ExtraEmbarkMoves' integer default 0 , 'FightWellDamaged' boolean default 0 , 'MoveFriendlyWoodsAsRoad' boolean default 0 , 'FasterAlongRiver' boolean default 0 , 'EmbarkedNotCivilian' boolean default 0 , 'FreeUnit' text default NULL , 'FreeUnitPrereqTech' text default NULL , 'ObsoleteTech' text default NULL , foreign key (FreeUnit) references UnitClasses(Type), foreign key (FreeUnitPrereqTech) references Technologies(Type), foreign key (ObsoleteTech) references Technologies(Type))"
"HandicapInfo_FreeTechs" "CREATE TABLE HandicapInfo_FreeTechs ('HandicapType' text , 'TechType' text , foreign key (HandicapType) references HandicapInfos(Type), foreign key (TechType) references Technologies(Type))"
"HandicapInfo_AIFreeTechs" "CREATE TABLE HandicapInfo_AIFreeTechs ('HandicapType' text , 'TechType' text , foreign key (HandicapType) references HandicapInfos(Type), foreign key (TechType) references Technologies(Type))"
"Policies" "CREATE TABLE Policies ('ID' integer primary key autoincrement , 'Type' text not null unique , 'Description' text default 'write a bug on this' , 'Civilopedia' text , 'Strategy' text , 'Help' text , 'PolicyBranchType' text default NULL , 'NumExtraBranches' integer default 0 , 'CultureCost' integer default 0 , 'GridX' integer default 0 , 'GridY' integer default 0 , 'PolicyCostModifier' integer default 0 , 'CulturePerCity' integer default 0 , 'CulturePerWonder' integer default 0 , 'CultureWonderMultiplier' integer default 0 , 'CulturePerTechResearched' integer default 0 , 'AttackBonusTurns' integer default 0 , 'GoldenAgeTurns' integer default 0 , 'GoldenAgeMeterMod' integer default 0 , 'NumFreeTechs' integer default 0 , 'NumFreePolicies' integer default 0 , 'StrategicResourceMod' integer default 0 , 'ReligionProductionModifier' integer default 0 , 'WonderProductionModifier' integer default 0 , 'BuildingProductionModifier' integer default 0 , 'GreatPeopleRateModifier' integer default 0 , 'GreatGeneralRateModifier' integer default 0 , 'DomesticGreatGeneralRateModifier' integer default 0 , 'ExtraHappiness' integer default 0 , 'ExtraHappinessPerCity' integer default 0 , 'UnhappinessMod' integer default 0 , 'CityCountUnhappinessMod' integer default 0 , 'OccupiedPopulationUnhappinessMod' integer default 0 , 'CapitalUnhappinessMod' integer default 0 , 'FreeExperience' integer default 0 , 'WorkerSpeedModifier' integer default 0 , 'AllFeatureProduction' integer default 0 , 'ImprovementCostModifier' integer default 0 , 'ImprovementUpgradeRateModifier' integer default 0 , 'SpecialistProductionModifier' integer default 0 , 'SpecialistUpgradeModifier' integer default 0 , 'MilitaryProductionModifier' integer default 0 , 'BaseFreeUnits' integer default 0 , 'BaseFreeMilitaryUnits' integer default 0 , 'FreeUnitsPopulationPercent' integer default 0 , 'FreeMilitaryUnitsPopulationPercent' integer default 0 , 'HappinessPerGarrisonedUnit' integer default 0 , 'HappinessPerTradeRoute' integer default 0 , 'ExtraHappinessPerLuxury' integer default 0 , 'UnhappinessFromUnitsMod' integer default 0 , 'NumExtraBuilders' integer default 0 , 'PlotGoldCostMod' integer default 0 , 'PlotCultureCostModifier' integer default 0 , 'UnitPurchaseCostModifier' integer default 0 , 'TradeRouteGoldModifier' integer default 0 , 'GoldPerUnit' integer default 0 , 'GoldPerMilitaryUnit' integer default 0 , 'RouteGoldMaintenanceMod' integer default 0 , 'BuildingGoldMaintenanceMod' integer default 0 , 'UnitGoldMaintenanceMod' integer default 0 , 'UnitSupplyMod' integer default 0 , 'UnitUpgradeCostMod' integer default 0 , 'CityStrengthMod' integer default 0 , 'CityGrowthMod' integer default 0 , 'CapitalGrowthMod' integer default 0 , 'SettlerProductionModifier' integer default 0 , 'NewCityExtraPopulation' integer default 0 , 'FreeFoodBox' integer default 0 , 'HappyPerMilitaryUnit' integer default 0 , 'MilitaryFoodProduction' boolean default 0 , 'HappinessToCulture' integer default 0 , 'HappinessToScience' integer default 0 , 'HalfSpecialistUnhappiness' boolean default 0 , 'HalfSpecialistFood' boolean default 0 , 'MaxConscript' integer default 0 , 'UnitSightRangeChange' integer default 0 , 'WoundedUnitDamageMod' integer default 0 , 'BarbarianCombatBonus' integer default 0 , 'AlwaysSeeBarbCamps' boolean default 0 , 'RevealAllCapitals' boolean default 0 , 'FreeSpecialist' integer default 0 , 'ExpModifier' integer default 0 , 'ExpInBorderModifier' integer default 0 , 'MinorQuestFriendshipMod' integer default 0 , 'MinorGoldFriendshipMod' integer default 0 , 'MinorFriendshipMinimum' integer default 0 , 'MinorFriendshipDecayMod' integer default 0 , 'OtherPlayersMinorFriendshipDecayMod' integer default 0 , 'MinorGreatPeopleAllies' boolean default 0 , 'MinorScienceAllies' boolean default 0 , 'MinorResourceBonus' boolean default 0 , 'OneShot' boolean default 0 , 'WeLoveTheKing' text default NULL , 'TechPrereq' text default NULL , 'PortraitIndex' integer default 0 , 'IconAtlas' text default NULL , 'IconAtlasAchieved' text default NULL , foreign key (Description) references Language_en_US(Tag), foreign key (Civilopedia) references Language_en_US(Tag), foreign key (Strategy) references Language_en_US(Tag), foreign key (Help) references Language_en_US(Tag), foreign key (PolicyBranchType) references PolicyBranchTypes(Type), foreign key (TechPrereq) references Technologies(Type), foreign key (IconAtlas) references IconTextureAtlases(Atlas), foreign key (IconAtlasAchieved) references IconTextureAtlases(Atlas))"
"Processes" "CREATE TABLE Processes ('ID' integer primary key autoincrement , 'Type' text not null unique , 'Description' text , 'Help' text , 'Strategy' text , 'TechPrereq' text , 'PortraitIndex' integer default '-1' , 'IconAtlas' text default NULL , foreign key (TechPrereq) references Technologies(Type), foreign key (IconAtlas) references IconTextureAtlases(Atlas))"
"Route_TechMovementChanges" "CREATE TABLE Route_TechMovementChanges ('RouteType' text , 'TechType' text , 'MovementChange' integer not null , foreign key (RouteType) references Routes(Type), foreign key (TechType) references Technologies(Type))"
"Technology_DomainExtraMoves" "CREATE TABLE Technology_DomainExtraMoves ('TechType' text , 'DomainType' text , 'Moves' integer , foreign key (TechType) references Technologies(Type), foreign key (DomainType) references Domains(Type))"
"Technology_Flavors" "CREATE TABLE Technology_Flavors ('TechType' text , 'FlavorType' text , 'Flavor' integer , foreign key (TechType) references Technologies(Type), foreign key (FlavorType) references Flavors(Type))"
"Technology_ORPrereqTechs" "CREATE TABLE Technology_ORPrereqTechs ('TechType' text , 'PrereqTech' text , foreign key (TechType) references Technologies(Type), foreign key (PrereqTech) references Technologies(Type))"
"Technology_PrereqTechs" "CREATE TABLE Technology_PrereqTechs ('TechType' text , 'PrereqTech' text , foreign key (TechType) references Technologies(Type), foreign key (PrereqTech) references Technologies(Type))"
"Improvement_TechYieldChanges" "CREATE TABLE Improvement_TechYieldChanges ('ImprovementType' text , 'TechType' text , 'YieldType' text , 'Yield' integer , foreign key (ImprovementType) references Improvements(Type), foreign key (TechType) references Technologies(Type), foreign key (YieldType) references Yields(Type))"
"Improvement_TechNoFreshWaterYieldChanges" "CREATE TABLE Improvement_TechNoFreshWaterYieldChanges ('ImprovementType' text , 'TechType' text , 'YieldType' text , 'Yield' integer , foreign key (ImprovementType) references Improvements(Type), foreign key (TechType) references Technologies(Type), foreign key (YieldType) references Yields(Type))"
"Improvement_TechFreshWaterYieldChanges" "CREATE TABLE Improvement_TechFreshWaterYieldChanges ('ImprovementType' text , 'TechType' text , 'YieldType' text , 'Yield' integer , foreign key (ImprovementType) references Improvements(Type), foreign key (TechType) references Technologies(Type), foreign key (YieldType) references Yields(Type))"
"Units" "CREATE TABLE Units ('ID' integer primary key autoincrement , 'Type' text not null unique , 'Description' text , 'Civilopedia' text , 'Strategy' text , 'Help' text , 'Requirements' text , 'Combat' integer default 0 , 'RangedCombat' integer default 0 , 'Cost' integer default 0 , 'Moves' integer default 0 , 'Immobile' boolean default 0 , 'Range' integer default 0 , 'BaseSightRange' integer default 2 , 'Class' text default NULL , 'Special' text default NULL , 'Capture' text default NULL , 'CombatClass' text default NULL , 'Domain' text default NULL , 'DefaultUnitAI' text default NULL , 'Food' boolean default 0 , 'NoBadGoodies' boolean default 0 , 'RivalTerritory' boolean default 0 , 'MilitarySupport' boolean default 0 , 'MilitaryProduction' boolean default 0 , 'Pillage' boolean default 0 , 'Found' boolean default 0 , 'CultureBombRadius' integer default 0 , 'GoldenAgeTurns' integer default 0 , 'IgnoreBuildingDefense' boolean default 0 , 'PrereqResources' boolean default 0 , 'Mechanized' boolean default 0 , 'Suicide' boolean default 0 , 'PrereqTech' text default NULL , 'ObsoleteTech' text default NULL , 'GoodyHutUpgradeUnitClass' text default NULL , 'HurryCostModifier' integer default 0 , 'AdvancedStartCost' integer default 0 , 'MinAreaSize' integer default '-1' , 'AirUnitCap' integer default 0 , 'NukeDamageLevel' integer default '-1' , 'WorkRate' integer default 0 , 'NumFreeTechs' integer default 0 , 'RushBuilding' boolean default 0 , 'BaseHurry' integer default 0 , 'HurryMultiplier' integer default 0 , 'BaseGold' integer default 0 , 'NumGoldPerEra' integer default 0 , 'SpreadReligion' boolean default 0 , 'IsReligious' boolean default 0 , 'CombatLimit' integer default 100 , 'RangeAttackOnlyInDomain' boolean default 0 , 'RangeAttackIgnoreLOS' boolean default 0 , 'RangedCombatLimit' integer default 0 , 'XPValueAttack' integer default 0 , 'XPValueDefense' integer default 0 , 'SpecialCargo' text default NULL , 'DomainCargo' text default NULL , 'Conscription' integer default 0 , 'ExtraMaintenanceCost' integer default 0 , 'NoMaintenance' boolean default 0 , 'Unhappiness' integer default 0 , 'UnitArtInfo' text default NULL , 'UnitArtInfoCulturalVariation' boolean default 0 , 'UnitArtInfoEraVariation' boolean default 0 , 'ProjectPrereq' text default NULL , 'SpaceshipProject' text default NULL , 'LeaderPromotion' text default NULL , 'LeaderExperience' integer default 0 , 'ShowInPedia' boolean default 1 , 'MoveRate' text default 'BIPED' , 'UnitFlagIconOffset' integer default 0 , 'PortraitIndex' integer default '-1' , 'IconAtlas' text default NULL , 'UnitFlagAtlas' text default 'UNIT_FLAG_ATLAS' , foreign key (Description) references Language_en_US(Tag), foreign key (Civilopedia) references Language_en_US(Tag), foreign key (Strategy) references Language_en_US(Tag), foreign key (Help) references Language_en_US(Tag), foreign key (Class) references UnitClasses(Type), foreign key (Special) references SpecialUnits(Type), foreign key (Capture) references UnitClasses(Type), foreign key (CombatClass) references UnitCombatInfos(Type), foreign key (Domain) references Domains(Type), foreign key (DefaultUnitAI) references UnitAIInfos(Type), foreign key (PrereqTech) references Technologies(Type), foreign key (ObsoleteTech) references Technologies(Type), foreign key (GoodyHutUpgradeUnitClass) references UnitClasses(Type), foreign key (SpecialCargo) references SpecialUnits(Type), foreign key (DomainCargo) references Domains(Type), foreign key (ProjectPrereq) references Projects(Type), foreign key (SpaceshipProject) references Projects(Type), foreign key (LeaderPromotion) references UnitPromotions(Type), foreign key (MoveRate) references MovementRates(Type), foreign key (IconAtlas) references IconTextureAtlases(Atlas), foreign key (UnitFlagAtlas) references IconTextureAtlases(Atlas))"
"Unit_TechTypes" "CREATE TABLE Unit_TechTypes ('UnitType' text , 'TechType' text , foreign key (UnitType) references Units(Type), foreign key (TechType) references Technologies(Type))"
"UnitPromotions" "CREATE TABLE UnitPromotions ('ID' integer primary key autoincrement , 'Type' text not null unique , 'Description' text , 'Help' text , 'DisabledHelp' text , 'Button' text , 'PortraitIndex' integer default 9 , 'IconAtlas' text default 'ABILITY_ATLAS' , 'HotKey' text , 'HotKeyAlt' text , 'HotKeyPriority' integer default 0 , 'HotKeyPriorityAlt' integer default 0 , 'OrderPriority' integer default 0 , 'AltDown' boolean default 0 , 'AltDownAlt' boolean default 0 , 'ShiftDown' boolean default 0 , 'ShiftDownAlt' boolean default 0 , 'CtrlDown' boolean default 0 , 'CtrlDownAlt' boolean default 0 , 'Sound' text , 'CannotBeChosen' boolean default 0 , 'LostWithUpgrade' boolean default 0 , 'InstaHeal' boolean default 0 , 'Leader' boolean default 0 , 'Blitz' boolean default 0 , 'Amphib' boolean default 0 , 'River' boolean default 0 , 'EnemyRoute' boolean default 0 , 'RivalTerritory' boolean default 0 , 'MustSetUpToRangedAttack' boolean default 0 , 'RangedSupportFire' boolean default 0 , 'CanMoveAfterAttacking' boolean default 0 , 'AlwaysHeal' boolean default 0 , 'HealOutsideFriendly' boolean default 0 , 'HillsDoubleMove' boolean default 0 , 'RoughTerrainEndsTurn' boolean default 0 , 'IgnoreTerrainCost' boolean default 0 , 'HoveringUnit' boolean default 0 , 'FlatMovementCost' boolean default 0 , 'CanMoveImpassable' boolean default 0 , 'NoCapture' boolean default 0 , 'OnlyDefensive' boolean default 0 , 'NoDefensiveBonus' boolean default 0 , 'NukeImmune' boolean default 0 , 'HiddenNationality' boolean default 0 , 'AlwaysHostile' boolean default 0 , 'NoRevealMap' boolean default 0 , 'Recon' boolean default 0 , 'CanMoveAllTerrain' boolean default 0 , 'FreePillageMoves' boolean default 0 , 'AirSweepCapable' boolean default 0 , 'AllowsEmbarkation' boolean default 0 , 'HealIfDestroyExcludesBarbarians' boolean default 0 , 'RangeAttackIgnoreLOS' boolean default 0 , 'RangedAttackModifier' integer default 0 , 'InterceptionCombatModifier' integer default 0 , 'InterceptionDefenseDamageModifier' integer default 0 , 'AirSweepCombatModifier' integer default 0 , 'ExtraAttacks' integer default 0 , 'ExtraNavalMovement' integer default 0 , 'VisibilityChange' integer default 0 , 'MovesChange' integer default 0 , 'MoveDiscountChange' integer default 0 , 'RangeChange' integer default 0 , 'InterceptChanceChange' integer default 0 , 'NumInterceptionChange' integer default 0 , 'EvasionChange' integer default 0 , 'CargoChange' integer default 0 , 'EnemyHealChange' integer default 0 , 'NeutralHealChange' integer default 0 , 'FriendlyHealChange' integer default 0 , 'SameTileHealChange' integer default 0 , 'AdjacentTileHealChange' integer default 0 , 'CombatPercent' integer default 0 , 'CityAttack' integer default 0 , 'CityDefense' integer default 0 , 'RangedDefenseMod' integer default 0 , 'HillsAttack' integer default 0 , 'HillsDefense' integer default 0 , 'OpenAttack' integer default 0 , 'OpenRangedAttackMod' integer default 0 , 'OpenDefense' integer default 0 , 'RoughAttack' integer default 0 , 'RoughRangedAttackMod' integer default 0 , 'RoughDefense' integer default 0 , 'AttackFortifiedMod' integer default 0 , 'AttackWoundedMod' integer default 0 , 'UpgradeDiscount' integer default 0 , 'ExperiencePercent' integer default 0 , 'AdjacentMod' integer default 0 , 'AttackMod' integer default 0 , 'DefenseMod' integer default 0 , 'DropRange' integer default 0 , 'GreatGeneral' boolean default 0 , 'GreatGeneralModifier' integer default 0 , 'FriendlyLandsModifier' integer default 0 , 'FriendlyLandsAttackModifier' integer default 0 , 'OutsideFriendlyLandsModifier' integer default 0 , 'HPHealedIfDestroyEnemy' integer default 0 , 'LayerAnimationPath' text default NULL , 'TechPrereq' text default NULL , 'Invisible' text default NULL , 'SeeInvisible' text default NULL , 'PromotionPrereq' text default NULL , 'PromotionPrereqOr1' text default NULL , 'PromotionPrereqOr2' text default NULL , 'PromotionPrereqOr3' text default NULL , 'PromotionPrereqOr4' text default NULL , 'PediaType' text , 'PediaEntry' text , foreign key (Description) references Language_en_US(Tag), foreign key (Help) references Language_en_US(Tag), foreign key (IconAtlas) references IconTextureAtlases(Atlas), foreign key (TechPrereq) references Technologies(Type), foreign key (Invisible) references InvisibleInfos(Type), foreign key (SeeInvisible) references InvisibleInfos(Type), foreign key (PromotionPrereq) references UnitPromotions(Type), foreign key (PromotionPrereqOr1) references UnitPromotions(Type), foreign key (PromotionPrereqOr2) references UnitPromotions(Type), foreign key (PromotionPrereqOr3) references UnitPromotions(Type), foreign key (PromotionPrereqOr4) references UnitPromotions(Type), foreign key (PediaEntry) references Language_en_US(Tag))"
"UnitPromotions_Terrains" "CREATE TABLE UnitPromotions_Terrains ('PromotionType' text , 'TerrainType' text , 'Attack' integer default 0 , 'Defense' integer default 0 , 'DoubleMove' boolean default 0 , 'Impassable' boolean default 0 , 'PassableTech' text , 'PediaType' text , foreign key (PromotionType) references UnitPromotions(Type), foreign key (TerrainType) references Terrains(Type), foreign key (PassableTech) references Technologies(Type))"
"UnitPromotions_Features" "CREATE TABLE UnitPromotions_Features ('PromotionType' text , 'FeatureType' text , 'Attack' integer default 0 , 'Defense' integer default 0 , 'DoubleMove' boolean default 0 , 'Impassable' boolean default 0 , 'PassableTech' text , 'PediaType' text , foreign key (PromotionType) references UnitPromotions(Type), foreign key (FeatureType) references Features(Type), foreign key (PassableTech) references Technologies(Type))"


Take for example the first entry in that list:
AICityStrategies it has a FKs of: foreign key (TechPrereq) references Technologies(Type), foreign key (TechObsolete) references Technologies(Type)
So then you must first
DELETE FROM AICityStrategies WHERE TechPrereq IS NOT NULL OR TechObsolete IS NOT NULL;

Once you have done this for every table that refs the techs you can nuke all the techs with
DELETE FROM Technologies


This will be way faster to write than using XML too.
It will also I bet execute a good deal faster.

Personally I think mods would load much faster if there was no XML.
Each alteration via XML is likely transformed into its own SQL under the scenes and then executed one at a time. I predict changes via XML will become the bane of large mods or using many mods.
 
Gedrin,

That looks like a great way to do it. One question: How to you make sure your sql code runs before any XML files that re-add these elements? Is it just the order of OnModActivated list? That would make sense but I have no real confidence that it works that way.

I'll try some of this over the weekend. It's pretty slow going for me due to lack of error feedback and silent errors (where the game runs but didn't load file due to error -- this is far worse than a crash for troubleshooting). Both problems are plaguing me for XML modding. I'm guessing that SQL modding doesn't get around these particular problems either (or does it?).
 
Another approach would be to leave most of the stuff in, but just to disable it and turn it invisible as well.

For example disabling all techs and making them disappear would look that way:

<Technologies>

<Update>
<Set Disable="True" />
</Update>

<Update>
<Set GridX="-1" />
</Update>

<Update>
<Set GridY="-1" />
</Update>

</Technologies>

It's a pretty quick adjustment though not really elegant (because of lot of clutter) from the database perspective

EDIT: ...thinking about it: with that approach we could hit some hardcoded limits, we're not yet aware of, easily. For example I've read that the maximum number of normal working promotions is about 60!!! (http://wiki.2kgames.com/civ5/index.php/Known_Issues) ... oh well >_>
 
Back
Top Bottom