[help] Is it possible to make a policy effect depend on specific tech?

kaspergm

Deity
Joined
Aug 19, 2012
Messages
5,577
I would like to know if it's possible to create a mod that adds to a policy the effect of giving a yield to a building after a certain tech is discovered. Specifically, what I want to do is make it so that the policy Honor opener provides a +1 Science bonus on Barracks, Armory and Military Academy after Military Science has been researched.

My own progress:
I found in the Civ5Buildings.xml file the following tag (modified from the Mughal Fort tech-dependant Gold yield):

Code:
<Building_TechEnhancedYieldChanges>
	<Row>
		<BuildingType>BUILDING_BARRACKS</BuildingType>
		<YieldType>YIELD_SCIENCE</YieldType>
		<Yield>1</Yield>
	</Row>
</Building_TechEnhancedYieldChanges>

Which obviously specifies a science-dependant yield, and combined with this tag:

Code:
<Buildings>
	<EnhancedYieldTech>TECH_MILITARY_SCIENCE</EnhancedYieldTech>
</Buildings>

can be used to create the effect I want.

I also know that from the policies files, I can use the following code (modified from Organized Religion's Faith yield):

Code:
<Policy_BuildingClassYieldChanges>
	<Row>
		<PolicyType>POLICY_HONOR</PolicyType>
		<BuildingClassType>BUILDINGCLASS_BARRACKS</BuildingClassType>
		<YieldType>YIELD_SCIENCE</YieldType>
		<YieldChange>1</YieldChange>
	</Row>
</Policy_BuildingClassYieldChanges>

to add the yield to the building once the Policy is adopted.

What I need help with:
Is it possible to link these two pieces of code, so that the bonus BOTH becomes tied with the policy AND with the tech? And if so, how do I do it?
 
Bumping this - nobody knows how to do this, or knows that it is impossible?
 
Add a TechPrereq to the policy....if it works since no policy uses it atm it might well be left over from Civ IV.
 
Add a TechPrereq to the policy....if it works since no policy uses it atm it might well be left over from Civ IV.

It's tested for in the CPP code, so it should work :)
 
Add a TechPrereq to the policy....if it works since no policy uses it atm it might well be left over from Civ IV.

One of the nice things about working with policies is you get no legacy code from civ 4, since they literally did not exist in civ 4 in any form.

On the flip side, there's still no guarantee that things were hooked up in the first place.
 
Ok, so ... does anybody know how to do it, i.e. what code I need to write?
 
Ok, so ... does anybody know how to do it, i.e. what code I need to write?
the same way you have done it in the OP but with policies...confused tbh.

<Policies>
<TechPrereq>TECH_MILITARY_SCIENCE</TechPrereq>
</Policies>

^^ You need to specify what policy your going to tie that into, in Update tags or just add it into a new policy if you are creatign a new one.
 
the same way you have done it in the OP but with policies...confused tbh.

<Policies>
<TechPrereq>TECH_MILITARY_SCIENCE</TechPrereq>
</Policies>

^^ You need to specify what policy your going to tie that into, in Update tags or just add it into a new policy if you are creatign a new one.
I'm not sure I understand you?

As I see it, the <TechPrereq> tag needs to be put under the Baracks entry, since it's the (extra) yield of Baracks I want to depend on the Tech, not chosing the Policy (the policy should be available from start, it just adds this effect after researching Military Science), so I don't think this would work?
 
So you want +1 science from barracks after researching Military Science which you can do with the code in OP, then you wish to add another +1science added to the Barracks from a Policy also with Military Science? Only way your currently going to do that with only XML/SQL is by sticking a TechPrereq onto the policy.

You can add a TechPrereq column to the Policy_BuildingClassYieldChanges table easy enough but then you would either need to edit the dll or lua so the game understnds what this new column does.
 
Actually, I only want the latter: I want to add to the Honor opener the effect that after Military Science, you gain +1 Science from Barracks, Armories and Military Academies.

The idea was that I want something to give a late-game use of Honor opener, because the Barbarian thing obviously loses importance in late game, making this policy pretty much useless if you don't adopt it early game.

In the end, I'll probably just add the bonus as a fixed bonus that works from start if I can't get the other thing to work (in a relatively simple matter), it would just be a cool coupling to Military Science I thought. I thought perhaps there was some way to include an "if" condition that would allow me to make a trigger condition.
 
I'm betting TechPrereq is not an option then - it will probably prevent you from even starting down the Honor tree, rather than just render it nonfunctional. And it would apply to everything in the Honor opener, not just this piece.

I don't think there's a good way to do what you want, may be a .dll fix.
 
You'll need Lua for that. Or DLL modding, obviously.

The simplest way to do it would be to create a hidden building adding +1 Science. At the start of each turn, check to see if the player has the right Policy, and if so, add a certain number of those Science buildings to each city depending on which buildings it already has. You'd want to do a little UI modding to keep those buildings hidden, but it's not difficult.
 
Ok, thanx for the feedback, it still sounds like something that's out of my league, for now at least.
 
One of the nice things about working with policies is you get no legacy code from civ 4, since they literally did not exist in civ 4 in any form.

On the flip side, there's still no guarantee that things were hooked up in the first place.
Perhaps I'm misunderstanding your meaning, but from what I can see the Policies were adapted directly from Civics, and there are plenty of (mostly nonfunctional) leftovers to show it.
 
Top Bottom