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

[BNW] (CIV V modding) having trouble modding social policies.

Discussion in 'Civ5 - Creation & Customization' started by Pepijn, Apr 14, 2021.

  1. Pepijn

    Pepijn Chieftain

    Joined:
    Apr 1, 2021
    Messages:
    7
    Gender:
    Male
    Hey, I am trying to rebalance the social policies. I have managed to get the UI/text working. When you look at the policy screen all the changes are visible but when you actually play the game and unlock the policies non of the changes work. I have looked at other mods to try and see how they work but I can't find major differences (maybe I am overlooking something). If anyone could help me troubleshoot this that would be awesome!

    The changes I would like to make to Liberty are the following:
    Opener:
    +1 culture in your capital, this stacks with the previous benefit to a total of 2 culture.
    Republic:
    +2 production in every city, -10% building gold maintenance,
    -40% city modifier for policies from (from 10% cost increase per city to 6% cost increase).

    Representation:
    +1 science per city and +1 happiness per city connection to the capital
    Finisher:
    +5% production in every city.

    This is my code (I haven't included the UI/text code because that already works)

    <GameData>
    <Policies>
    <Update>
    <Where Type="POLICY_REPUBLIC"/>
    <Set BuildingGoldMaintenanceMod="-10"/>
    </Update>
    <Update>
    <Where Type="POLICY_CITIZENSHIP"/>
    <Set ExtraHappinessPerLuxury="1"/>
    </Update>
    <Update>
    <Where Type="POLICY_CITIZENSHIP"/>
    <Set NumCitiesPolicyCostDiscount="-40"/>
    </Update>
    </Policies>

    <Policy_BuildingClassProductionModifiers>
    <Update>
    <Where Type="POLICY_CITIZENSHIP"/>
    <Add ProductionModifier="+5"/>
    </Update>
    </Policy_BuildingClassProductionModifiers>
    <Policy_CityYieldChanges>
    <Update>
    <Row>
    <PolicyType>POLICY_MERITOCRACY</PolicyType>
    <YieldType>YIELD_SCIENCE</YieldType>
    <Yield>1</Yield>
    </Row>
    <Row>
    <PolicyType>POLICY_REPUBLIC</PolicyType>
    <YieldType>YIELD_PRODUCTION</YieldType>
    <Yield>1</Yield>
    </Row>
    </Update>
    </Policy_CityYieldChanges>

    <Policy_BuildingClassCultureChanges>
    <Update>
    <Where>
    <PolicyType>POLICY_LIBERTY</PolicyType>
    <BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
    </Where>
    <Set CultureChange="2"/>
    </Update>
    </Policy_BuildingClassCultureChanges>
    </GameData>
     
  2. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,532
    Location:
    Near Portsmouth, UK
    Please attach the actual mod (see link in my sig) as it's far easier to debug what you've actually done than what you think you may have done, eg do you have the correct setting for the files in your mod (also a link in my sig)
     
    Pepijn likes this.
  3. Pepijn

    Pepijn Chieftain

    Joined:
    Apr 1, 2021
    Messages:
    7
    Gender:
    Male
    Thank you for trying to help me. I have provided the files in this reply. I also took a look at the logging of the game but I couldn't find anything weird. (after I looked through your link on how to enable logging.)
     

    Attached Files:

  4. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,532
    Location:
    Near Portsmouth, UK
    There should be somethin in the logs as the following is invalid

    <Policy_CityYieldChanges>
    <Update>
    <Row>

    Update or Row, not one inside the other
     
    Pepijn likes this.
  5. Pepijn

    Pepijn Chieftain

    Joined:
    Apr 1, 2021
    Messages:
    7
    Gender:
    Male
    Thanks! I fixed that but it still won't work. I took another look at the logs and while they are a bit different from the logs you posted in your Logging tutorial they almost do not differ when I play with or without mods.
    With me, Lua has a lot of Map Script: info.
    With me, Xml has: Missing Entry for UNIT_BARBARIAN_HORSEMAN which yours doesn't have.
    With me Database has: the same things as your example has but just a lot more.
    I have provided them in a folder.

    Thanks for helping me!
     

    Attached Files:

  6. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,532
    Location:
    Near Portsmouth, UK
    It's not the differences between mine and yours that matter but the differences between yours with a) no mods and b) only the mod you are developing

    Probably this
    [12873.437] no such column: Type
     
    Last edited: Apr 15, 2021
    Pepijn likes this.
  7. Pepijn

    Pepijn Chieftain

    Joined:
    Apr 1, 2021
    Messages:
    7
    Gender:
    Male
    I looked at the files which had all the mods, the files which had my mod and the files which had no mods to really make sure everything was correct.
    And I finally found an error:
    Database::XMLSerializer (XML/LibertyBalance.xml): <Update> element requires a child <Set> element.

    Maybe it has something to do with how I fixed the error you pointed out earlier.
    I made this:

    <Policy_CityYieldChanges>
    <Update>
    <Row>
    <PolicyType>POLICY_MERITOCRACY</PolicyType>
    <YieldType>YIELD_SCIENCE</YieldType>
    <Yield>1</Yield>
    </Row>
    <Row>
    <PolicyType>POLICY_REPUBLIC</PolicyType>
    <YieldType>YIELD_PRODUCTION</YieldType>
    <Yield>1</Yield>
    </Row>
    </Update>
    </Policy_CityYieldChanges>

    into this:

    <Policy_CityYieldChanges>
    <Update>
    <PolicyType>POLICY_MERITOCRACY</PolicyType>
    <YieldType>YIELD_SCIENCE</YieldType>
    <Yield>1</Yield>
    </Update>
    <Update>
    <PolicyType>POLICY_REPUBLIC</PolicyType>
    <YieldType>YIELD_PRODUCTION</YieldType>
    <Yield>1</Yield>
    </Update>
    </Policy_CityYieldChanges>


    If you found this unreadable I have provided the file and also the log files if you like to take a look.

    I also have another question, do I need to specifically assign the 5% production bonus to each building sort or can I just add the production bonus like I did? In other mods I found that they specifically assigned to all the buildings but I also found the production variable in the XML game files.
    Thanks again for helping me :)
     

    Attached Files:

  8. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,532
    Location:
    Near Portsmouth, UK
    Compare and constrast your two different types of <Update> blocks. Remember that <Update> changes something that's already in the database, whereas <Row> adds a new entry into the database. Do you want to add something new, or change something already there? I'm guessing you've used <Update> where you really meant <Row>, but it's a very long time since I've modded policies so no longer know this stuff off the top of my head!
     
    Pepijn likes this.
  9. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,140
    Location:
    Illinois, USA
    This is a fatal syntax error
    Code:
    	<Policy_BuildingClassProductionModifiers>
    		<Update>
    			<Where Type="POLICY_CITIZENSHIP"/>
    			<Add ProductionModifier="+5"/>
    		</Update>
    	</Policy_BuildingClassProductionModifiers>
    1. Table <Policy_BuildingClassProductionModifiers> from the base game code does not contain any row where POLICY_CITIZENSHIP is listed.
    2. Table <Policy_BuildingClassProductionModifiers> requires column <PolicyType> rather than column <Type>
    3. Command "Add" is invalid
    You would not be updating this table, you would be adding an entire new row to the table, as William pointed out, so you need <Row> syntax and you need to provide arguments for all the columns needed in table <Policy_BuildingClassProductionModifiers>. Your code for that table would need to look like this if you were making Citizenship increase the rate of completing Shrine-Class Buildings:
    Code:
    	<Policy_BuildingClassProductionModifiers>
    		<Row>
    			<PolicyType>POLICY_CITIZENSHIP</PolicyType>
    			<BuildingClassType>BUILDINGCLASS_SHRINE</BuildingClassType>
    			<ProductionModifier>5</ProductionModifier>
    		</Row>
    	</Policy_BuildingClassProductionModifiers>
    • Every class of building you wish to affect by Citizanship will require its own new row in the table
    Table <Policy_CityYieldChanges> already has a row that adds 1 production to all cities when the POLICY_REPUBLIC opener-policy is adopted. This is the pre-existing definition of the table for BNW
    Code:
    	<Policy_CityYieldChanges>
    		<Row>
    			<PolicyType>POLICY_REPUBLIC</PolicyType>
    			<YieldType>YIELD_PRODUCTION</YieldType>
    			<Yield>1</Yield>
    		</Row>
    		<Row>
    			<PolicyType>POLICY_FIVE_YEAR_PLAN</PolicyType>
    			<YieldType>YIELD_PRODUCTION</YieldType>
    			<Yield>2</Yield>
    		</Row>
    		<Row>
    			<PolicyType>POLICY_PARTY_LEADERSHIP</PolicyType>
    			<YieldType>YIELD_FOOD</YieldType>
    			<Yield>1</Yield>
    		</Row>
    		<Row>
    			<PolicyType>POLICY_PARTY_LEADERSHIP</PolicyType>
    			<YieldType>YIELD_PRODUCTION</YieldType>
    			<Yield>1</Yield>
    		</Row>
    		<Row>
    			<PolicyType>POLICY_PARTY_LEADERSHIP</PolicyType>
    			<YieldType>YIELD_SCIENCE</YieldType>
    			<Yield>1</Yield>
    		</Row>
    		<Row>
    			<PolicyType>POLICY_PARTY_LEADERSHIP</PolicyType>
    			<YieldType>YIELD_GOLD</YieldType>
    			<Yield>1</Yield>
    		</Row>
    		<Row>
    			<PolicyType>POLICY_PARTY_LEADERSHIP</PolicyType>
    			<YieldType>YIELD_CULTURE</YieldType>
    			<Yield>1</Yield>
    		</Row>
    	</Policy_CityYieldChanges>
    So not only is this attempt to make an update incorrectly formatted, it would result in no in-game difference even if properly formatted as an update
    Code:
    		<Update>
    			<PolicyType>POLICY_REPUBLIC</PolicyType>
    			<YieldType>YIELD_PRODUCTION</YieldType>
    			<Yield>1</Yield>
    		</Update>
    <Row> syntax in this case would not work properly since there is already an existing row in the game-table for POLICY_REPUBLIC and YIELD_PRODUCTION.

    In order to add a new row to the table for POLICY_MERITOCRACY and YIELD_SCIENCE you need to use <Row> and add a new row to the table. So your code for <Policy_CityYieldChanges> really only needs to be
    Code:
    	<Policy_CityYieldChanges>
    		<Row>
    			<PolicyType>POLICY_MERITOCRACY</PolicyType>
    			<YieldType>YIELD_SCIENCE</YieldType>
    			<Yield>1</Yield>
    		</Row>
    	</Policy_CityYieldChanges>
    When making an update to existing data in a table via XML commands, we cannot concern ourselves directly with what we want to alter the numerical values by, we must only code based on the numerical values we are changing to. So if I want to increase the base-game city-yield of POLICY_REPUBLIC and YIELD_PRODUCTION to a total value of "2" I need to write an update as
    Code:
    	<Policy_CityYieldChanges>
    		<Update>
    			<Where PolicyType="POLICY_REPUBLIC" YieldType="YIELD_PRODUCTION"/>
    			<Set Yield="2"/>
    		</Update>
    	</Policy_CityYieldChanges>
    This update attempt will never be enacted by the game
    Code:
    	<Policy_BuildingClassCultureChanges>
    		<Update>
    			<Where>
    				<PolicyType>POLICY_LIBERTY</PolicyType>
    				<BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
    			</Where>
    			<Set CultureChange="2"/>
    		</Update>
    	</Policy_BuildingClassCultureChanges>
    There is nothing for the game to match the "Where" clause to, similar to the earlier issue. This is the entirety of the table from the base game
    Code:
    	<Policy_BuildingClassCultureChanges>
    		<Row>
    			<PolicyType>POLICY_TRADITION</PolicyType>
    			<BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
    			<CultureChange>3</CultureChange>
    		</Row>
    		<Row>
    			<PolicyType>POLICY_MERCHANT_NAVY</PolicyType>
    			<BuildingClassType>BUILDINGCLASS_NATIONAL_TREASURY</BuildingClassType>
    			<CultureChange>4</CultureChange>
    		</Row>
    	</Policy_BuildingClassCultureChanges>
    You need to add an entirely new row, not attempt an update.

    BTW the reason your text works is because alterations to text in the <Language_en_US> and other language tables like for Spanish, French, Russian, have actually nothing whatever to do with actual gameplay code nor does actual gameplay code affect the text strings or make them self-correct for alterations. I can do this and the game will display the assigned silliness
    Code:
    <GameData>
    	<Language_en_US>
    		<Update>
    			<Where Tag="TXT_KEY_POLICY_BRANCH_LIBERTY_HELP"/>
    			<Set Text="I love Cheeseburgers"/>
    		</Update>
    		<Update>
    			<Where Tag="TXT_KEY_POLICY_REPUBLIC_HELP"/>
    			<Set Text="I love Cheeseburgers more than I love Chocolate Cake"/>
    		</Update>
    		<Update>
    			<Where Tag="TXT_KEY_POLICY_COLLECTIVE_RULE_HELP"/>
    			<Set Text="Anyone who does not love Cheeseburgers must be a Commie!"/>
    		</Update>
    		<Update>
    			<Where Tag="TXT_KEY_POLICY_CITIZENSHIP_HELP"/>
    			<Set Text="More Cheeseburgers"/>
    		</Update>
    		<Update>
    			<Where Tag="TXT_KEY_POLICY_MERITOCRACY_HELP"/>
    			<Set Text="Cheeseburgers Cheeseburgers Everywhere!"/>
    		</Update>
    		<Update>
    			<Where Tag="TXT_KEY_POLICY_REPRESENTATION_HELP"/>
    			<Set Text="A Cheeseburger without Ketchup is like a Beer without Alcohol."/>
    		</Update>
    	</Language_en_US>
    </GameData>
     
    Pepijn likes this.
  10. Pepijn

    Pepijn Chieftain

    Joined:
    Apr 1, 2021
    Messages:
    7
    Gender:
    Male
    I didn't know that... that explains a lot xD
    Thank you so much!
     
  11. Pepijn

    Pepijn Chieftain

    Joined:
    Apr 1, 2021
    Messages:
    7
    Gender:
    Male
    Thanks for taking the time to write this, you are a legend!
    This explains a lot!
     

Share This Page