How to make a building that increases a yield based on population of that city?

You talking about the amount of pop that is actively working the building?

I'm presuming you're talking about how districts work, that can with extra buildings fit 1-3 pop, and give more output per pop?
 
No, he's talking about the way Libraries worked in Civ 5. 2 pop = 1 science.
 
Might be an idea to check how libraries are coded in civ 5.
Firaxis provided a specific game-table in the database for this effect as an inherent part of Civ5, which is not available in Civ6. So the method used for the Civ5 Library will not apply to Civ6.
 
This is based on my industrial mod, except I am pretending that it's a library.

Code:
<GameData>
    <BuildingModifiers>
        <Row>
            <BuildingType>BUILDING_LIBRARY</BuildingType>
            <ModifierId>BUILDING_LIBRARY_SCIENCE_PER_POP_1</ModifierId>
        </Row>
    </BuildingModifiers>
    <Modifiers>
        <Row>
            <ModifierId>BUILDING_LIBRARY_SCIENCE_PER_POP_1</ModifierId>
            <ModifierType>MODIFIER_BUILDING_YIELD_CHANGE</ModifierType>
            <SubjectRequirementSetId>LIBRARY_SCIENCE_PER_POP_COUNT_1</SubjectRequirementSetId>
            <RunOnce>false</RunOnce>
            <Permanent>false</Permanent>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>BUILDING_LIBRARY_SCIENCE_PER_POP_1</ModifierId>
            <Name>BuildingType</Name>
            <Value>BUILDING_LIBRARY</Value>
        </Row>
        <Row>
            <ModifierId>BUILDING_LIBRARY_SCIENCE_PER_POP_1</ModifierId>
            <Name>Amount</Name>
            <Value>0.5</Value>
        </Row>
        <Row>
            <ModifierId>BUILDING_LIBRARY_SCIENCE_PER_POP_1</ModifierId>
            <Name>YieldType</Name>
            <Value>YIELD_SCIENCE</Value>
        </Row>
    </ModifierArguments>
    <RequirementSets>
        <Row>
            <RequirementSetId>LIBRARY_SCIENCE_PER_POP_COUNT_1</RequirementSetId>
            <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
        </Row>
    </RequirementSets>
    <RequirementSetRequirements>
        <Row>
            <RequirementSetId>LIBRARY_SCIENCE_PER_POP_COUNT_1</RequirementSetId>
            <RequirementId>COUNT_POP_1</RequirementId>
        </Row>
    </RequirementSetRequirements>
    <Requirements>
        <Row>
            <RequirementId>COUNT_POP_1</RequirementId>
            <RequirementType>REQUIREMENT_COLLECTION_COUNT_ATLEAST</RequirementType>
        </Row>
    </Requirements>
    <RequirementArguments>
        <Row>
            <RequirementId>COUNT_POP_1</RequirementId>
            <Name>CollectionType</Name>
            <Value>COLLECTION_CITY_PLOT_YIELDS</Value>
        </Row>
        <Row>
            <RequirementId>COUNT_POP_1</RequirementId>
            <Name>Count</Name>
            <Value>1</Value>
        </Row>
    </RequirementArguments>
</GameData>

That code should add 0.5 science to any city that has 1 population once a library has been built in that city. If you copy/paste that code, replace anywhere that has "1" with 2, you should then create code that will add 0.5 science to any city with a library that has 1 population AND another 0.5 science to any city with a library that has 2 population. You have to keep copy/pasting code (Next time replacing the 2s with 3s etc) until you reach a population amount high enough you don't think anyone will get to. In my industrial mod (Powerplant adds +1 production per 8 population regionally, or more accurately +0.125 production per 1 population), I went all the way to 30. It's labour intensive but it works.
 
Back
Top Bottom