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

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

Discussion in 'Civ5 - Creation & Customization' started by kaspergm, Dec 1, 2012.

  1. kaspergm

    kaspergm Deity

    Joined:
    Aug 19, 2012
    Messages:
    4,604
    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?
     
  2. kaspergm

    kaspergm Deity

    Joined:
    Aug 19, 2012
    Messages:
    4,604
    Bumping this - nobody knows how to do this, or knows that it is impossible?
     
  3. Horem

    Horem Emperor

    Joined:
    Apr 1, 2010
    Messages:
    1,718
    Location:
    Wales, UK
    Add a TechPrereq to the policy....if it works since no policy uses it atm it might well be left over from Civ IV.
     
  4. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,382
    Location:
    Near Portsmouth, UK
    It's tested for in the CPP code, so it should work :)
     
  5. Drawmeus

    Drawmeus Emperor

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    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.
     
  6. kaspergm

    kaspergm Deity

    Joined:
    Aug 19, 2012
    Messages:
    4,604
    Ok, so ... does anybody know how to do it, i.e. what code I need to write?
     
  7. Horem

    Horem Emperor

    Joined:
    Apr 1, 2010
    Messages:
    1,718
    Location:
    Wales, UK
    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.
     
  8. kaspergm

    kaspergm Deity

    Joined:
    Aug 19, 2012
    Messages:
    4,604
    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?
     
  9. Horem

    Horem Emperor

    Joined:
    Apr 1, 2010
    Messages:
    1,718
    Location:
    Wales, UK
    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.
     
  10. kaspergm

    kaspergm Deity

    Joined:
    Aug 19, 2012
    Messages:
    4,604
    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.
     
  11. Drawmeus

    Drawmeus Emperor

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    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.
     
  12. Spatzimaus

    Spatzimaus Mad Scientist

    Joined:
    Sep 21, 2005
    Messages:
    3,063
    Location:
    Los Angeles, CA
    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.
     
  13. kaspergm

    kaspergm Deity

    Joined:
    Aug 19, 2012
    Messages:
    4,604
    Ok, thanx for the feedback, it still sounds like something that's out of my league, for now at least.
     
  14. Dryhad

    Dryhad Prince

    Joined:
    Feb 23, 2006
    Messages:
    451
    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.
     

Share This Page