What is the best way to remake or replace some of the main tables?

OuroborosOrder

Warlord
Joined
Apr 3, 2016
Messages
124
Location
Alabama
Hi my name is OuroborosOrder, I'm new here. Trying my hand at a total conversion mod, and I am new to modding Civ5, but not new to programming and modding in general.

My question is what is the best way to go about say replacing the policies table completely with my own? Should I just delete the whole table with SQL and then add a new table with the same name and then re sequence (read a few other threads on this topic). Will this cause me significant problems?

Also, what would be the best way to add a completely new game concept type of table? I know C++ quite well and have already modified the DLL in a few ways while working on this, so that is not really a problem for me. My questions are really just specific to Civ, and the database stuff. I am slightly inexperienced in SQL, but know C++ and XML quite well. I am learning LUA as I go as well, does not seem hard to me.
 
Also, what would be the best way to add a completely new game concept type of table?

Follow the pattern of the existing Firaxis ones in the C++ code. See the DLL Tutorials link in my sig, one of them does just this.
 
So, I looked at some more threads on the topic. The problem I see is that the Policy Branches seem to be hard coded in the DLL, just based on some rudimentary searching through the source.

This is a major bummer to me, because I was hoping to make a completely new policy tree for the beginning version of my mod. Is there anyway to still go about this safely or is what I want to do pretty much impossible without altering hundreds of lines of DLL code?

Any help would be greatly appreciated. Also, thanks so much for the responses and the excellent tutorials you guys have shown me here.
 
I was hoping to make a completely new policy tree for the beginning version of my mod. Is there anyway to still go about this safely or is what I want to do pretty much impossible without altering hundreds of lines of DLL code?
Depends what you want to do. If you're trying to alter the number of policy trees (9 + 3 ideology), you're also going to have to heavily mod the UI (as that's all hard-coded as well).

If you remove/add policy trees, you'll also have to make sure that any references to them in the DLL (typically for granting free great people via the finishers and for the AI decision making process of what policy to open) are also changed.

The UI would be the biggest head-ache, as a) someone has already done the finisher GP code and b) the AI decision is just a case of either keeping with the standard policy tree type names and changing their descriptive text, or a search-and-replace throughout the C++ code and the associated global defines database table entries.

W
 
Thanks Whoward! :)

Yep, this is what I was thinking actually after looking at it closer, according to Visual Studio there are actually only about 11 specific references to actually policy branch names. This is much more manageable than I thought.

I have no qualms about the necessity of remaking parts of the UI, I was going to do that anyways. I'm also an amateur graphics artist, so I may end up making my own art assets. *Yay computer science major*

As far as the coding part of the UI, I've created my own popup windows in game already through the LUA scripting system, would this be the easiest way to go about remaking the UI regarding policies screen?

Another question, do I have this right as far as the SQL to delete specific tables?

Code:
DELETE FROM PolicyBranchTypes;
DELETE FROM Policies;

UPDATE sqlite_sequence
SET seq = 0
WHERE name = 'Policies';

-- Where "..." is place holder for individual values.

INSERT INTO PolicyBranchTypes(ID, Type, Description, Civilopedia, Strategy, Help, Title, EraPrereq, FreePolicy, FreeFinishingPolicy, FirstAdopterFreePolicies, SecondAdopterFreePolicies, PurchaseByLevel, LockedWithoutReligion, AIMutuallyExclusive, AIDelayNoReligion, AIDelayNoCulture, AIDelayNoCityStates, AIDelayNoScience, MyTableColumn1, MyTableColumn2, MyTableColumn3, AndSoForth),
(..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ...),
(..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ...),
(..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ...),
(..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ...));

-- Reiterate above table creation for Policies table here.

Lastly, would it be better to remake this table via SQL or XML or does it matter?
 
Code:
DELETE FROM PolicyBranchTypes;
DELETE FROM Policies;
Here be demons!

What about all the secondary tables (Policy_Xyz) that reference these tables???

Suggest you take a very close look at the "TC - Minimal" mod attached at the end of the link given by bane_ above

Edit: XML or SQL - doesn't matter, XML is more verbose, but some find it easier to follow - whatever you're comfortable with
 
Ah I've read through and I believe I understand how to completely clear the policies section of the database:

Spoiler :
Code:
<!-- Delete the PolicyBranchTypes table and all corresponding tables.
DELETE FROM PolicyBranchTypes;
DELETE FROM PolicyBranch_Disables;

<!-- Delete the Policies table and all corresponding tables. -->
DELETE FROM Policies;
DELETE FROM Policy_CityYieldChanges;
DELETE FROM Policy_CoastalCityYieldChanges;
DELETE FROM Policy_CapitalYieldChanges;
DELETE FROM Policy_CapitalYieldPerPopChanges;
DELETE FROM Policy_CapitalYieldModifiers;
DELETE FROM Policy_Disables;
DELETE FROM Policy_Flavors;
DELETE FROM Policy_GreatWorkYieldChanges;
DELETE FROM Policy_HurryModifiers;
DELETE FROM Policy_PrereqPolicies;
DELETE FROM Policy_PrereqORPolicies;
DELETE FROM Policy_SpecialistExtraYields;
DELETE FROM Policy_BuildingClassYieldModifiers;
DELETE FROM Policy_BuildingClassYieldChanges;
DELETE FROM Policy_BuildingClassCultureChanges; 
DELETE FROM Policy_BuildingClassProductionModifiers;
DELETE FROM Policy_BuildingClassTourismModifiers;
DELETE FROM Policy_BuildingClassHappiness;
DELETE FROM Policy_ImprovementYieldChanges;
DELETE FROM Policy_ImprovementCultureChanges;
DELETE FROM Policy_ValidSpecialists;
DELETE FROM Policy_YieldModifiers;
DELETE FROM Policy_FreePromotions;
DELETE FROM Policy_UnitCombatFreeExperiences;
DELETE FROM Policy_FreePromotionUnitCombats;
DELETE FROM Policy_UnitCombatProductionModifiers;
DELETE FROM Policy_FreeUnitClasses;
DELETE FROM Policy_TourismOnUnitCreation;
DELETE FROM Policy_FreeItems;

Then I would have to fill in the table again with my own data and make sure that any references to any of the tags I don't want are removed from or changed in the DLL. Do I have this right?

To remake the table I would first have to do something like:
Spoiler :
Code:
<!-- This should set the Policies table starting ID to 0 which is what it is in the Firaxis tables. -->
UPDATE Policies SET ID=0;

and then...

<!-- If I have this right, this orders the data by the rowid, numbering it in the table in ascending order. -->
INSERT INTO Policies (...data goes here...) ORDER BY rowid ASC;

Also I came across this doing some searches for what I might have to change:

Spoiler :
Code:
	const char* ms_V0PolicyTags[60] =
	{
		"POLICY_LIBERTY",
		"POLICY_COLLECTIVE_RULE",
		"POLICY_CITIZENSHIP",
		"POLICY_REPUBLIC",
		"POLICY_REPRESENTATION",
		"POLICY_MERITOCRACY",
		"POLICY_TRADITION",
		"POLICY_ARISTOCRACY",
		"POLICY_OLIGARCHY",
		"POLICY_LEGALISM",
		"POLICY_LANDED_ELITE",
		"POLICY_MONARCHY",
		"POLICY_HONOR",
		"POLICY_WARRIOR_CODE",
		"POLICY_DISCIPLINE",
		"POLICY_MILITARY_TRADITION",
		"POLICY_MILITARY_CASTE",
		"POLICY_PROFESSIONAL_ARMY",
		"POLICY_PIETY",
		"POLICY_ORGANIZED_RELIGION",
		"POLICY_MANDATE_OF_HEAVEN",
		"POLICY_THEOCRACY",
		"POLICY_REFORMATION",
		"POLICY_FREE_RELIGION",
		"POLICY_PATRONAGE",
		"POLICY_PHILANTHROPY",
		"POLICY_AESTHETICS",
		"POLICY_SCHOLASTICISM",
		"POLICY_CULTURAL_DIPLOMACY",
		"POLICY_EDUCATED_ELITE",
		"POLICY_COMMERCE",
		"POLICY_TRADE_UNIONS",
		"POLICY_NAVAL_TRADITION",
		"POLICY_MERCANTILISM",
		"POLICY_MERCHANT_NAVY",
		"POLICY_PROTECTIONISM",
		"POLICY_RATIONALISM",
		"POLICY_SECULARISM",
		"POLICY_HUMANISM",
		"POLICY_FREE_THOUGHT",
		"POLICY_SOVEREIGNTY",
		"POLICY_SCIENTIFIC_REVOLUTION",
		"POLICY_FREEDOM",
		"POLICY_CONSTITUTION",
		"POLICY_UNIVERSAL_SUFFRAGE",
		"POLICY_CIVIL_SOCIETY",
		"POLICY_FREE_SPEECH",
		"POLICY_DEMOCRACY",
		"POLICY_ORDER",
		"POLICY_UNITED_FRONT",
		"POLICY_SOCIALISM",
		"POLICY_NATIONALISM",
		"POLICY_PLANNED_ECONOMY",
		"POLICY_COMMUNISM",
		"POLICY_AUTOCRACY",
		"POLICY_POPULISM",
		"POLICY_MILITARISM",
		"POLICY_FASCISM",
		"POLICY_POLICE_STATE",
		"POLICY_TOTAL_WAR"
	};

	const char* ms_V0PolicyBranchTags[10] =
	{
		"POLICY_BRANCH_TRADITION",
		"POLICY_BRANCH_LIBERTY",
		"POLICY_BRANCH_HONOR",
		"POLICY_BRANCH_PIETY",
		"POLICY_BRANCH_PATRONAGE",
		"POLICY_BRANCH_COMMERCE",
		"POLICY_BRANCH_RATIONALISM",
		"POLICY_BRANCH_FREEDOM",
		"POLICY_BRANCH_ORDER",
		"POLICY_BRANCH_AUTOCRACY"
	};

This seems to have something to do with their data serialization process. Not being as familiar with their specific setup here (as I am new to modding this), I was hoping one of you might be able to give me some insight about this?
 
After much playing around to learn exactly what I'm doing via a SQLite database viewer. I have come up with the following sql file for my project's policies rework:

Spoiler :
Code:
-- Wipe all Data from the main policies table!
DELETE FROM Policies;

-- Wipe all the Data from the intermediate tables.
DELETE FROM Policy_CityYieldChanges;
DELETE FROM Policy_CoastalCityYieldChanges;
DELETE FROM Policy_CapitalYieldChanges;
DELETE FROM Policy_CapitalYieldPerPopChanges;
DELETE FROM Policy_CapitalYieldModifiers;
DELETE FROM Policy_Disables;
DELETE FROM Policy_Flavors;
DELETE FROM Policy_GreatWorkYieldChanges;
DELETE FROM Policy_HurryModifiers;
DELETE FROM Policy_PrereqPolicies;
DELETE FROM Policy_PrereqORPolicies;
DELETE FROM Policy_SpecialistExtraYields;
DELETE FROM Policy_BuildingClassYieldModifiers;
DELETE FROM Policy_BuildingClassYieldChanges;
DELETE FROM Policy_BuildingClassCultureChanges; 
DELETE FROM Policy_BuildingClassProductionModifiers;
DELETE FROM Policy_BuildingClassTourismModifiers;
DELETE FROM Policy_BuildingClassHappiness;
DELETE FROM Policy_ImprovementYieldChanges;
DELETE FROM Policy_ImprovementCultureChanges;
DELETE FROM Policy_ValidSpecialists;
DELETE FROM Policy_YieldModifiers;
DELETE FROM Policy_FreePromotions;
DELETE FROM Policy_UnitCombatFreeExperiences;
DELETE FROM Policy_FreePromotionUnitCombats;
DELETE FROM Policy_UnitCombatProductionModifiers;
DELETE FROM Policy_FreeUnitClasses;
DELETE FROM Policy_TourismOnUnitCreation;
DELETE FROM Policy_FreeItems;

-- Set the sequence for the policies table to 0 so that when we start adding entries they start at 0.
UPDATE sqlite_sequence SET seq=0 WHERE name='Policies';


-- Repeat for PolicyBranchTypes.
DELETE FROM PolicyBranchTypes;
DELETE FROM PolicyBranch_Disables;
UPDATE sqlite_sequence SET seq=0 WHERE name='PolicyBranchTypes';

--------------------------------------------------------------------------------------------------
-- SPACE RESERVED FOR FUTURE COLUMN ADDITIONS!
---------------------------------------------------------------------------------------------------

-- Now we go to xml and insert our new policies there (I find it easier to keep track of and look at).

And the working copy of my new xml file for policybranchtypes:
Spoiler :
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
	<PolicyBranchTypes>
		<!-- Policy branch type count = 6 -->
		<!-- Many policy branches from BNW will be combined and improved. -->
		<Row>
			<ID>0</ID>
			<Type>POLICYBRANCH_TYPE_COMMUNITY</Type>
			<Description>TXT_KEY_POLICY_BRANCH_COMMUNITY</Description>
			<Help>TXT_KEY_POLICY_BRANCH_COMMUNITY_HELP</Help>
			<Title>TXT_KEY_COMMUNITY_TITLE</Title>
			<FreePolicy>POLICY_COMMUNITY</FreePolicy>
			<FreeFinishingPolicy>POLICY_COMMUNITY_FINISHER</FreeFinishingPolicy>
		</Row>
		<Row>
			<Type>POLICYBRANCH_TYPE_PHILOSOPHY</Type>
			<Description>TXT_KEY_POLICY_BRANCH_PHILOSOPHY</Description>
			<Help>TXT_KEY_POLICY_BRANCH_PHILOSOPHY_HELP</Help>
			<Title>TXT_KEY_PHILOSOPHY_TITLE</Title>
			<FreePolicy>POLICY_PHILOSOPHY</FreePolicy>
			<FreeFinishingPolicy>POLICY_PHILOSOPHY_FINISHER</FreeFinishingPolicy>
		</Row>
		<Row>
			<Type>POLICYBRANCH_TYPE_SOVEREIGNTY</Type>
			<Description>TXT_KEY_POLICY_BRANCH_SOVEREIGNTY</Description>
			<Help>TXT_KEY_POLICY_BRANCH_SOVEREIGNTY_HELP</Help>
			<Title>TXT_KEY_SOVEREIGNTY_TITLE</Title>
			<FreePolicy>POLICY_SOVEREIGNTY</FreePolicy>
			<FreeFinishingPolicy>POLICY_SOVEREIGNTY_FINISHER</FreeFinishingPolicy>
		</Row>
		<Row>
			<Type>POLICYBRANCH_TYPE_ECONOMY</Type>
			<Description>TXT_KEY_POLICY_BRANCH_ECONOMY</Description>
			<Help>TXT_KEY_POLICY_BRANCH_ECONOMY_HELP</Help>
			<Title>TXT_KEY_ECONOMY_TITLE</Title>
			<FreePolicy>POLICY_ECONOMOY</FreePolicy>
			<FreeFinishingPolicy>POLICY_ECONOMY_FINISHER</FreeFinishingPolicy>
		</Row>
		<Row>
			<Type>POLICYBRANCH_TYPE_DISCOVERY</Type>
			<Description>TXT_KEY_POLICY_BRANCH_DISCOVERY</Description>
			<Help>TXT_KEY_POLICY_BRANCH_DISCOVERY_HELP</Help>
			<Title>TXT_KEY_DISCOVERY_TITLE</Title>
			<FreePolicy>POLICY_DISCOVERY</FreePolicy>
			<FreeFinishingPolicy>POLICY_DISCOVERY_FINISHER</FreeFinishingPolicy>
		</Row>
		<Row>
			<Type>POLICYBRANCH_TYPE_INDUSTRY</Type>
			<Description>TXT_KEY_POLICY_BRANCH_INDUSTRY</Description>
			<Help>TXT_KEY_POLICY_BRANCH_INDUSTRY_HELP</Help>
			<Title>TXT_KEY_INDUSTRY_TITLE</Title>
			<FreePolicy>POLICY_INDUSTRYY</FreePolicy>
			<FreeFinishingPolicy>POLICY_INDUSTRY_FINISHER</FreeFinishingPolicy>
		</Row>
	</PolicyBranchTypes>
</GameData>
 
Status: Solved.

I can now import new Policy Branches and Policies into the database. I will be modifying the DLL shortly to create new Policy modifier values as well and AI actions regarding policies.

I will be creating a information/tutorial thread for Policies as I did for religion soon.

I will also be releasing the first version of "Civfinity" the tentative name I am picking for my mod. :)
 
Top Bottom