Problem Modding Social Policies

loppnessmonsta

Chieftain
Joined
Nov 27, 2013
Messages
19
I've been working on this mod for weeks now and I'm stuck. My tooltips update fine, but the actual changes don't work.

This is my PolicyUpdates file:
Spoiler :
<GameData>
<Policies>
<Update>
<Where PolicyType="POLICY_HONOR"/>
<Set CultureFromKills="100"/>
</Update>
<!--<Update>
<Where PolicyType="POLICY_HONOR"/>
<Set CultureFromBarbarianKills="200"/>
</Update>-->
<Update>
<Where PolicyType="POLICY_CULTURAL_CENTERS"/>
<Set GreatWriterRateModifier="25"/>
</Update>
<Update>
<Where PolicyType="POLICY_CULTURAL_CENTERS"/>
<Set GreatArtistRateModifier="25"/>
</Update>
<Update>
<Where PolicyType="POLICY_CULTURAL_CENTERS"/>
<Set GreatMusicianRateModifier="25"/>
</Update>
<Update>
<Where PolicyType="POLICY_AESTHETICS"/>
<Set GreatWriterRateModifier="0"/>
</Update>
<Update>
<Where PolicyType="POLICY_AESTHETICS"/>
<Set GreatArtistRateModifier="0"/>
</Update>
<Update>
<Where PolicyType="POLICY_AESTHETICS"/>
<Set GreatMusicianRateModifier="0"/>
</Update>
</Policies>
<Policy_BuildingClassProductionModifiers>
<Update>
<Where PolicyType="POLICY_HONOR"/>
<Set BuildingClassType="BUILDINGCLASS_BARRACKS" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_HONOR"/>
<Set BuildingClassType="BUILDINGCLASS_ARMORY" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_HONOR"/>
<Set BuildingClassType="BUILDINGCLASS_MILITARY_ACADEMY" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_PROFESSIONAL_ARMY"/>
<Set BuildingClassType="BUILDINGCLASS_CONSTABLE" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_PROFESSIONAL_ARMY"/>
<Set BuildingClassType="BUILDINGCLASS_POLICE_STATION" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_AESTHETICS"/>
<Set BuildingClassType="BUILDINGCLASS_MONUMENT" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_AESTHETICS"/>
<Set BuildingClassType="BUILDINGCLASS_AMPHITHEATER" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_AESTHETICS"/>
<Set BuildingClassType="BUILDINGCLASS_OPERA_HOUSE" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_AESTHETICS"/>
<Set BuildingClassType="BUILDINGCLASS_MUSEUM" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_AESTHETICS"/>
<Set BuildingClassType="BUILDINGCLASS_BROADCAST_TOWER" ProductionModifier="50"/>
</Update>
<Update>
<Where PolicyType="POLICY_PROFESSIONAL_ARMY"/>
<Set BuildingClassType="BUILDINGCLASS_BARRACKS" ProductionModifier="0"/>
</Update>
<Update>
<Where PolicyType="POLICY_PROFESSIONAL_ARMY"/>
<Set BuildingClassType="BUILDINGCLASS_ARMORY" ProductionModifier="0"/>
</Update>
<Update>
<Where PolicyType="POLICY_PROFESSIONAL_ARMY"/>
<Set BuildingClassType="BUILDINGCLASS_MILITARY_ACADEMY" ProductionModifier="0"/>
</Update>
<Update>
<Where PolicyType="POLICY_CULTURAL_CENTERS"/>
<Set BuildingClassType="BUILDINGCLASS_MONUMENT" ProductionModifier="0"/>
</Update>
<Update>
<Where PolicyType="POLICY_CULTURAL_CENTERS"/>
<Set BuildingClassType="BUILDINGCLASS_AMPHITHEATER" ProductionModifier="0"/>
</Update>
<Update>
<Where PolicyType="POLICY_CULTURAL_CENTERS"/>
<Set BuildingClassType="BUILDINGCLASS_OPERA_HOUSE" ProductionModifier="0"/>
</Update>
<Update>
<Where PolicyType="POLICY_CULTURAL_CENTERS"/>
<Set BuildingClassType="BUILDINGCLASS_MUSEUM" ProductionModifier="0"/>
</Update>
<Update>
<Where PolicyType="POLICY_CULTURAL_CENTERS"/>
<Set BuildingClassType="BUILDINGCLASS_BROADCAST_TOWER" ProductionModifier="0"/>
</Update>
</Policy_BuildingClassProductionModifiers>
<Policy_BuildingClassHappiness>
<Update>
<Where PolicyType="POLICY_PROFESSIONAL_ARMY"/>
<Set BuildingClassType="BUILDINGCLASS_CONSTABLE" Happiness="1"/>
</Update>
<Update>
<Where PolicyType="POLICY_PROFESSIONAL_ARMY"/>
<Set BuildingClassType="BUILDINGCLASS_POLICE_STATION" Happiness="1"/>
</Update>
</Policy_BuildingClassHappiness>
</GameData>


The mod has other files, but doesn't throw any visible errors and most of it works. The only problem is that the changes from my Update files don't take effect. In particular, the CultureFromKills (easiest to test). I checked the database log and found nothing related to this.

From this I can only surmise that I have done something wrong in my syntax that causes the file to just not load, but for the life of me I can't figure out what. I've had the BuildingClassType in the WHERE line, but that didn't work either, though I guess I may have had other errors at the time that may have broken it. I dunno. Could use some fresh eyes.
 
1. There is no PolicyType column in Policies table, it's just Type. So you need to change PolicyType to Type in all places where you update the Policies table.

2. The way you're making changes to Policy_BuildingClassProductionModifiers and Policy_BuildingClassHappiness tables is not right. Things you're trying to change don't exist, so you need to add new rows instead of updating existing ones. So instead of

Code:
<Update>
<Where PolicyType="POLICY_HONOR"/>
<Set BuildingClassType="BUILDINGCLASS_BARRACKS" ProductionModifier="50"/>
</Update>

It should be:
Code:
<Row>
<PolicyType>POLICY_HONOR</PolicyType>
<BuildingClassType>BUILDINGCLASS_BARRACKS</BuildingClassType>
<ProductionModifier>50</ProductionModifier>
</Row>
 
Ah, I see. Also, I had it as Type before but was looking through the files and saw it use PolicyType in a few spots, so thought that might be it. Obviously not.

Thanks!
 
Secondary question: is there a way to give each opener a bonus that only activates in combination with another opener? like faithfromkills if you adopt honor and piety, etc.
 
You can do that through lua. Something like this would work:

Code:
function BranchCombinations(playerID, policyBranchTypeID)
	local iPlayer = Players[playerID]
	if policyBranchTypeID == GameInfoTypes["POLICY_BRANCH_TRADITION"] then
		if iPlayer:HasPolicy(GameInfoTypes["POLICY_LIBERTY_OPENER"]) then
			--Do stuff for Tradition + Liberty
		elseif iPlayer:HasPolicy(GameInfoTypes["POLICY_PIETY_OPENER"]) then
			--Do stuff for Tradition + Piety
		--etc.
		end
	elseif policyBranchTypeID == GameInfoTypes["POLICY_BRANCH_LIBERTY"] then
		if iPlayer:HasPolicy(GameInfoTypes["POLICY_PIETY_OPENER"]) then
			--Do stuff for Liberty + Piety
		--etc.
		end
	--etc.
	end
end
GameEvents.PlayerAdoptPolicyBranch.Add(BranchCombinations)

I'm not sure about achieving the FaithfromKills effect you want, but there are plenty of things you could come up with that would work.
 
Hmm. I don't know much about LUA so I think that's beyond me. I thought of something else I could do, though, but I'm not sure it will work. There's no FaithFromKills column in the Policy table, that I can see. Is there a way to add it to the table?
 
Also, is there a way to give city-states the StarAlongOcean bias? I tried this:

<Table name="MinorCiv_Start_Along_Ocean">
<Column name="MinorCivType" type="text" reference="MinorCivilizations(Type)"/>
<Column name="MinorStartAlongOcean" type="boolean" default="false"/>
</Table>
<MinorCivTraits>
<Row>
<Type>MINOR_TRAIT_MARITIME</Type>
<MinorStartAlongOcean>True</MinorStartAlongOcean>
</Row>
</MinorCivTraits>

but I get
[1453789.073] table MinorCivTraits has no column named MinorStartAlongOcean
[1453789.073] In Query - insert into MinorCivTraits('Type', 'MinorStartAlongOcean') values (?, ?);
[1453789.073] In XMLSerializer while updating table MinorCivTraits from file XML/Updates/CivUpdates.xml.
[1453789.182] columns Language, Tag are not unique

as an error so i guess it comes back to learning how to add stuff to tables, if possible.
 
You can't just add columns to tables and hope they work. If you add columns you have to write the code which DOES something with the column as well (which means lua or c++ code).


As for the error, it's caused by incorrect XML.
<Table name="MinorCiv_Start_Along_Ocean">
Here you are making a new table.

<MinorCivTraits>
...
<MinorStartAlongOcean>True</MinorStartAlongOcean>
Here you are setting MinorStartAlongOcean for a different table than the one you just added. The MinorCivTraits table does not have a column called that. The MinorCiv_Start_Along_Ocean table does.
 
Top Bottom