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

Complicated Production Problem

Discussion in 'Mod Creation Help' started by SocialMechanic, Oct 18, 2019.

  1. SocialMechanic

    SocialMechanic Chieftain

    Joined:
    May 11, 2019
    Messages:
    67
    Here is the code:
    Code:
    <GameInfo>
        <Types>
            <Row Type="SM_CITY_CENTER_PRODUCTION" Kind="KIND_MODIFIER"/>
        </Types>
        <DynamicModifiers>
            <Row>
                <ModifierType>SM_CITY_CENTER_PRODUCTION</ModifierType>
                <CollectionType>COLLECTION_OWNER</CollectionType>
                <EffectType>EFFECT_ADJUST_CITY_YIELD_PER_POPULATION</EffectType>
            </Row>
        </DynamicModifiers>
        <RequirementSets>
            <Row RequirementSetId="SM_REQUIREMENT_CITY_HAS_POP01ERA1" RequirementSetType="REQUIREMENTSET_TEST_ALL" />
            <Row RequirementSetId="SM_REQUIREMENT_CITY_HAS_POP02ERA1" RequirementSetType="REQUIREMENTSET_TEST_ALL" />
            <Row RequirementSetId="SM_REQUIREMENT_CITY_HAS_POP03ERA1" RequirementSetType="REQUIREMENTSET_TEST_ALL" />
        </RequirementSets>
        <RequirementSetRequirements>
            <Row RequirementSetId="SM_REQUIREMENT_CITY_HAS_POP01ERA1" RequirementId="SM_REQUIRES_CITY_HAS_01_POP" />
            <Row RequirementSetId="SM_REQUIREMENT_CITY_HAS_POP02ERA1" RequirementId="SM_REQUIRES_CITY_HAS_02_POP" />
            <Row RequirementSetId="SM_REQUIREMENT_CITY_HAS_POP03ERA1" RequirementId="SM_REQUIRES_CITY_HAS_03_POP" />
    
            <Row RequirementSetId="SM_REQUIREMENT_CITY_HAS_POP01ERA1" RequirementId="SM_REQUIRES_ERA_IS_1" />
            <Row RequirementSetId="SM_REQUIREMENT_CITY_HAS_POP02ERA1" RequirementId="SM_REQUIRES_ERA_IS_1" />
            <Row RequirementSetId="SM_REQUIREMENT_CITY_HAS_POP03ERA1" RequirementId="SM_REQUIRES_ERA_IS_1" />
        </RequirementSetRequirements>
        <Requirements>
            <Row RequirementId="SM_REQUIRES_CITY_HAS_01_POP" RequirementType="REQUIREMENT_CITY_HAS_X_POPULATION" />
            <Row RequirementId="SM_REQUIRES_CITY_HAS_02_POP" RequirementType="REQUIREMENT_CITY_HAS_X_POPULATION" />
            <Row RequirementId="SM_REQUIRES_CITY_HAS_03_POP" RequirementType="REQUIREMENT_CITY_HAS_X_POPULATION" />
    
            <Row RequirementId="SM_REQUIRES_ERA_IS_1" RequirementType="REQUIREMENT_GAME_ERA_IS" />
        </Requirements>
        <RequirementArguments>
            <Row RequirementId="SM_REQUIRES_CITY_HAS_01_POP" Name="Amount" Value="1" />
            <Row RequirementId="SM_REQUIRES_CITY_HAS_02_POP" Name="Amount" Value="2" />
            <Row RequirementId="SM_REQUIRES_CITY_HAS_03_POP" Name="Amount" Value="3" />
    
            <Row RequirementId="SM_REQUIRES_ERA_IS_1" Name="EraType" Value="ERA_ANCIENT" />
        </RequirementArguments>
        <Modifiers>
            <Row ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP01ERA1" ModifierType="SM_CITY_CENTER_PRODUCTION" SubjectRequirementSetId="SM_REQUIREMENT_CITY_HAS_POP01ERA1" />
            <Row ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP02ERA1" ModifierType="SM_CITY_CENTER_PRODUCTION" SubjectRequirementSetId="SM_REQUIREMENT_CITY_HAS_POP02ERA1" />
            <Row ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP03ERA1" ModifierType="SM_CITY_CENTER_PRODUCTION" SubjectRequirementSetId="SM_REQUIREMENT_CITY_HAS_POP03ERA1" />
        </Modifiers>
        <ModifierArguments>
            <Row ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP01ERA1" Name="YieldType" Value="YIELD_PRODUCTION" />
            <Row ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP02ERA1" Name="YieldType" Value="YIELD_PRODUCTION" />
            <Row ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP03ERA1" Name="YieldType" Value="YIELD_PRODUCTION" />
    
            <Row ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP01ERA1" Name="Amount" Value="0.5" />
            <Row ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP02ERA1" Name="Amount" Value="1.1" />
            <Row ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP03ERA1" Name="Amount" Value="1.7" />
        </ModifierArguments>
        <DistrictModifiers>
            <Row DistrictType="DISTRICT_CITY_CENTER" ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP01ERA1" />
            <Row DistrictType="DISTRICT_CITY_CENTER" ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP02ERA1" />
            <Row DistrictType="DISTRICT_CITY_CENTER" ModifierId="SM_CITY_CENTER_PRODUCTION_FROM_POP03ERA1" />
        </DistrictModifiers>
    </GameInfo>
    If it isn't obvious, I'm trying to add production to the city center based on a city's pop and the era.
    The code above only includes the first 3 pop during the ancient era, which is only the first 3 lines out of the 270 per section (for all 9 eras up to 30 pop), because they are the ones I'm dealing with at first.

    The problem is this: At pop one, it works just fine. But at pop two, it applies the pop 1 and pop 2 bonuses TWICE EACH, providing a bonus of 3.2 production (rather than the 1.1 I wanted). Then, if the city is at pop 3, it applies the pop 1, 2, and 3 bonus THRICE EACH, providing a bonus of 9.9 production (rather than the 1.7 I was hoping for).
    I tried applies SubjectStackLimit and tried OwnerStackLimit (not at the same time) in the Modifiers table and theyseem to do nothing.

    Edit: now, I realize that the 1 pop requirement is going to count at higher pops because it is a "at least" requirement rather than a "exact pop size" requirement. That's okay though, because the values can be easily adjusted (in the above code, the pop 2 and 3 values would be turned into 0.6). But the fact that its happening multiple times is just freaking stupid.

    Edit: I just tested to see what happens when the era flips over. It appears that, if the city was settled before the era flipped, it gets the bonuses of both the Ancient era and Classical... I don't know what to do.
     
    Last edited: Oct 18, 2019
  2. Laurana Kanan

    Laurana Kanan Don’t underestimate who I am.

    Joined:
    Apr 10, 2014
    Messages:
    1,817
    Gender:
    Female
    Location:
    Near the Greatest Snow on Earth
    Looks like you want to do something the same/similar to p0kiehl's Production from Population mod. I'd look at that code for inspiration.
     
  3. SocialMechanic

    SocialMechanic Chieftain

    Joined:
    May 11, 2019
    Messages:
    67
    I did but it is SQL. Though, I'm basically coding it like they did and it still isn't working. They don't use a stack limit but somehow it works. I'm wanting an actual curve though.
     

Share This Page