Problem With Social Policy

Joined
Jan 7, 2009
Messages
620
Hi all,

I'm trying to make a policy like Meritocracy that gives a free great person. In game, I get the icon for the GP, but when I click it nothing happens. This results in a deadlocked game as I can't progress until I select my GP. Here is the code:

Spoiler :
Code:
		<Row>
			<ID>64</ID>
			<Type>POLICY_MIXED_GOVERNMENT</Type>
			<Description>TXT_KEY_NEWPOLICY_MIXED_GOVERNMENT</Description>
			<Civilopedia>TXT_KEY_NEWPOLICY_MIXED_GOVERNMENT_TEXT</Civilopedia>
			<Help>TXT_KEY_NEWPOLICY_MIXED_GOVERNMENT_HELP</Help>
			<PolicyBranchType>POLICY_BRANCH_REPUBLIC</PolicyBranchType>
			<CultureCost>10</CultureCost>
			<GridX>3</GridX>
			<GridY>3</GridY>
			<NumFreeGreatPeople>1</NumFreeGreatPeople>
			<IncludesOneShotFreeUnits>true</IncludesOneShotFreeUnits>
			<PortraitIndex>55</PortraitIndex>
			<IconAtlas>POLICY_ATLAS</IconAtlas>
			<IconAtlasAchieved>POLICY_A_ATLAS</IconAtlasAchieved>
		</Row>
Please let me know what I need to adjust. Also, I have another policy that gives 2 GP:
Spoiler :
Code:
		<Row>
			<ID>99</ID>
			<Type>POLICY_RADICAL_TRANSPARENCY</Type>
			<Description>TXT_KEY_NEWPOLICY_RADICAL_TRANSPARENCY</Description>
			<Civilopedia>TXT_KEY_NEWPOLICY_RADICAL_TRANSPARENCY_TEXT</Civilopedia>
			<Help>TXT_KEY_NEWPOLICY_RADICAL_TRANSPARENCY_HELP</Help>
			<PolicyBranchType>POLICY_BRANCH_VIRTUALDEMOCRACY</PolicyBranchType>
			<CultureCost>10</CultureCost>
			<GridX>2</GridX>
			<GridY>3</GridY>
			<GreatPeopleRateModifier>25</GreatPeopleRateModifier>
			<NumFreeGreatPeople>2</NumFreeGreatPeople>
			<IncludesOneShotFreeUnits>true</IncludesOneShotFreeUnits>
			<PortraitIndex>55</PortraitIndex>
			<IconAtlas>POLICY_ATLAS</IconAtlas>
			<IconAtlasAchieved>POLICY_A_ATLAS</IconAtlasAchieved>
		</Row>
It doesn't work either. Thansk.
 
Well, for one thing, why are you hard-setting the ID? That's bound to cause problems. Just let it auto-index.

As for the rest, does your mod have Lua that could be conflicting? Say, a custom notification logic that overrides the left-click and right-click actions on notifications? I haven't tried actually running this XML stub myself, but I'm assuming that that side of things works correctly given that Meritocracy works.
So to test this: DOES Meritocracy work for you, where it's only these new policies that fail?
 
Yeah Meritocracy works. It's probably something in Lua. Smh, I was hoping it would just be an xml fix. Thanks
 
Yeah Meritocracy works. It's probably something in Lua.

If Meritocracy works, then I was implying that it's probably NOT Lua, because a lua bug would presumably break meritocracy as well. It's possible that there's something hard-coded deep within the engine to only do this logic for that one specific policy, but I don't think that's likely. But we can check that.

So first, remove the ID declarations. That'll leave your policy as a near-duplicate of Meritocracy, other than the happiness difference and the fact that it's in a new branch. I don't know that this'll fix the problem, but there's really no reason to hard-set the ID and a lot of reasons not to do so. (Also, your numbers are 64 and 99. I'm assuming you have policies 65-98 doing other things, because you really shouldn't skip numbers.) Assuming that they still break, we continue to test.

Now, the fact that it's in a custom branch might be causing problems; a lot of the UI elements are hard-coded to handle 10 branches, so if you're adding new ones then it could be breaking things. So to test this, do an Update to an existing policy, give it the great person effect, and see if it works as well as Meritocracy did. If it works, then it's something about your specific branches/policies, if it doesn't then something must be hard-coded to only work for Meritocracy.
 
It seems as though it's hardcoded. I put this in but still had the same problem; I got the icon but clicking it does nothing.
Code:
 	<Policies>
		<Update>
			<Where Type="POLICY_TRADITION" />
			<Set NumFreeGreatPeople="1" IncludesOneShotFreeUnits="true" />
		</Update>
	</Policies>
And why is it bad to put specific IDs?
 
And why is it bad to put specific IDs?

Two reasons:
1> It can create gaps in the ID list. Quite a few things in the UI can't handle gaps in IDs; the functions will loop over the available IDs and pull up the item's appropriate entries, with no checks to see if that ID is actually being used. This was the problem with the Delete function in Civ5 when we first started modding; deleting a unit would create a gap in the IDs, and the game would then crash. (They fixed it in a patch, I believe in December, although I won't guarantee they got all of the places this happened.) This is easily apparent if you look at how the UI Lua functions operate, and presumably the internal engine is structured similarly.

2> It's automatically incompatible with other mods. There are 60 policies in the existing game. I make a mod that adds 10 more. You make a mod that adds a few more, but you hard-set the ID of your new policies to be 60, 61, 62, and so on.
If the game loads my mod first, then it'll give MY policies the numbers 60, 61, 62, and so on down the line; then it'll get to your mod, and try to assign your new policies the ID codes that it had already given to mine. At best this'll overwrite my policies with yours; at worst, it'll crash (depending on how the defaults in the table in question are set up).
If it loads yours first then there won't be a conflict, but A) We have no control over load order, and B) If I did the same in my own mod then there'd be no way they could ever be compatible.

And there's almost no benefit to setting the ID codes explicitly. The only thing it ever has helped is that ID determines the order in which buildings and units are listed in the build lists, but that's a minor benefit and doesn't apply to policies.
 
Awesome. Thanks for the help and insight :)
 
Nope, that didn't work for me either. That is an interesting "trick" (flaw) though.
 
Interesting, use the mods below and Tradition will correctly grant a free Great Person, while Liberty will "lock-up" (you get the end-of-turn button, but cannot click it)

Code:
<Policies>
	<Update>
		<Where Type="POLICY_TRADITION"/>
		<Set IncludesOneShotFreeUnits="true"/>
	</Update>
	<Update>
		<Where Type="POLICY_TRADITION"/>
		<Set NumFreeGreatPeople="1"/>
	</Update>
</Policies>

<Policies>
	<Update>
		<Where Type="POLICY_LIBERTY"/>
		<Set IncludesOneShotFreeUnits="true" NumFreeGreatPeople="1"/>
	</Update>
</Policies>

There is definately something "odd" going on with updates to boolean fields via XML
 
I suspect it's more with how you are setting up the whole new branch(es) as opposed to problems with the policy per-se, as the following mod works as expected

Code:
<Policies>
  <Delete Type="POLICY_COLLECTIVE_RULE"/>
</Policies>

<Policies>
  <Row>
    <ID>1</ID>
    <Type>POLICY_COLLECTIVE_RULE</Type>
    <Description>TXT_KEY_POLICY_DISCIPLINE</Description>
    <Civilopedia>TXT_KEY_POLICY_DISCIPLINE_TEXT</Civilopedia>
    <Help>TXT_KEY_POLICY_DISCIPLINE_HELP</Help>
    <PolicyBranchType>POLICY_BRANCH_LIBERTY</PolicyBranchType>
    <CultureCost>10</CultureCost>
    <GridX>1</GridX>
    <GridY>1</GridY>
    <NumFreeGreatPeople>1</NumFreeGreatPeople>
    <IncludesOneShotFreeUnits>true</IncludesOneShotFreeUnits>
    <PortraitIndex>55</PortraitIndex>
    <IconAtlas>POLICY_ATLAS</IconAtlas>
    <IconAtlasAchieved>POLICY_A_ATLAS</IconAtlasAchieved>
  </Row>
</Policies>

HOWEVER, if you leave the <ID> tag out (and therefore create a "hole" in the list of policies), every policy tree breaks.

If you're replacing a policy, it would definately be worth using the same ID's as the ones you're discarding, or keep the core of the policies and just use SQL to update them

HTH

W
 
Wow that is interesting. So I'm going to try deleting all of the IDs to see if that helps any. You know, I'm starting to see why people don't like modding on Civ 5; this is just xml and yet there are all kinds of tricks/workarounds one must use. I can't imagine how it is for lua...
 
Wow that is interesting. So I'm going to try deleting all of the IDs to see if that helps any. You know, I'm starting to see why people don't like modding on Civ 5; this is just xml and yet there are all kinds of tricks/workarounds one must use. I can't imagine how it is for lua...

If you're replacing every policy check out how it's done in the Polynesia DLC scenario, lots of tips/tricks in there
 
Back
Top Bottom