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

Tag <FreeSocialPoliciesPerEra> in civ trait xml is not working. Help.

Discussion in 'Civ5 - Creation & Customization' started by tac_NCVD, Mar 22, 2020.

  1. tac_NCVD

    tac_NCVD Chieftain

    Joined:
    Feb 29, 2020
    Messages:
    14
    Gender:
    Male
    <GameData>
    <Traits>
    <Row>
    <Type>TRAIT_traitname</Type>
    <Description>TXT_KEY_TRAIT_traitname</Description>
    <ShortDescription>TXT_KEY_TRAIT_traitname_SHORT</ShortDescription>
    <FreeSocialPoliciesPerEra>2</FreeSocialPoliciesPerEra>
    <ObsoleteTech>TECH_CIVIL_SERVICE</ObsoleteTech>
    </Row>
    </Traits>
    <Trait_FreePromotionUnitCombats>
    ...
    </Trait_FreePromotionUnitCombats>

    <Language_en_US>
    <Row Tag="TXT_KEY_TRAIT_traitname">
    <Text>Receive 2 free Social Policies when you enter Classical and Medieval era, 4 in total.....
    <Row Tag="TXT_KEY_TRAIT_traitname_SHORT">
    </Language_en_US>
    </GameData>

    The other part of the trait is working fine, but it only gives me 1 free policy per era instead of 2...what should i do?
     
  2. Browd

    Browd Dilettante Administrator

    Joined:
    Aug 5, 2012
    Messages:
    11,711
    Gender:
    Male
    Location:
    Washington, DC
    Moved
     
  3. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,756
    Location:
    Illinois, USA
    I seem to recall you can only ever get one free policy per era. It's been a while since this topic last came up but my memory is that <FreeSocialPoliciesPerEra> is treated as a boolean by the game rather than as an Integer, so any value greater than "0" has the same effect as "1". Even though the definition in table "Traits" says "integer". This is actually quite common in various places in the gametables of Civ5. The XML definition tells the game's database to treat a column one way, but the game's actual executing software treats it in a different way.
     
  4. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,399
    Location:
    Near Portsmouth, UK
    Yep, it's a feature/bug … this tag is a Boolean (due to the following copy-and-paste error in the code)

    Code:
        int iNumFreePolicies = kPlayer.GetPlayerTraits()->GetFreeSocialPoliciesPerEra() > 0;
        if (iNumFreePolicies > 0)
        {
         kPlayer.ChangeNumFreePolicies(iNumFreePolicies);
        }
    
    Just as well it's not the original C Boolean for true, as that was -1
     
  5. tac_NCVD

    tac_NCVD Chieftain

    Joined:
    Feb 29, 2020
    Messages:
    14
    Gender:
    Male
    Do I have to "update" this function or just make a new one in the lua? i am new to game modding...
     
    Last edited: Mar 23, 2020
  6. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,756
    Location:
    Illinois, USA
    William's quoted code is from the game's DLL sourcecode. Unless you can program in C++ and create a new DLL then the answer is no there is nothing you can do to "update" or over-ride the function.

    You can write an lua script that would give an extra second free policy every time the player enters a new Era but in this case you would not be over-writing the game's core executing source-code nor "updating" anything in the game database. But if you are not at a point where you are ready to tackle learning how to code in the lua language then I think the answer is again no there is nothing you can do.
     
  7. tac_NCVD

    tac_NCVD Chieftain

    Joined:
    Feb 29, 2020
    Messages:
    14
    Gender:
    Male
    thx...
     
  8. tac_NCVD

    tac_NCVD Chieftain

    Joined:
    Feb 29, 2020
    Messages:
    14
    Gender:
    Male
    Code:
    void CvTeam::SetCurrentEra(EraTypes eNewValue)
    {
    CvPlot* pLoopPlot;
    int iI;
    if(GetCurrentEra() != eNewValue)
    {
            PlayerTypes ePlayer;
            for(int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++)
            {
                ePlayer = (PlayerTypes) iPlayerLoop;
                CvPlayerAI& kPlayer = GET_PLAYER(ePlayer);
                if(kPlayer.isAlive() && kPlayer.getTeam() == GetID() && !kPlayer.isMinorCiv() && !kPlayer.isBarbarian())
                {
                    int iNumFreePolicies = kPlayer.GetPlayerTraits()->GetFreeSocialPoliciesPerEra() > 0;
                    if (iNumFreePolicies > 0)
                    {
                        kPlayer.ChangeNumFreePolicies(iNumFreePolicies);
                    }
                }
            }
    
    I think this is the source funtion of poland's trait tag. is there any way to "give an extra second free policy every time the player enters a new Era" by using this code?
     
    Last edited: Mar 24, 2020
  9. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,756
    Location:
    Illinois, USA
    That's DLL code. You would have to alter the code in the DLL file, then compile your new DLL file, then set-up your mod so that it adds your new version of the DLL file into the game (and thereby would make your mod incompatible with any other mod that also has a custom DLL).

    It would be essentially using a jackhammer to swat a fly.
     
  10. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,399
    Location:
    Near Portsmouth, UK
    No, that's the C++ source that handles the broken tag (you've just included more that I did - the 14th line you've given is the first one I gave)
     
  11. tac_NCVD

    tac_NCVD Chieftain

    Joined:
    Feb 29, 2020
    Messages:
    14
    Gender:
    Male
    I guest i will have to "add a free building (in this case, oracle) every time the player enters a new Era". I found this solution in the forum. Thanks for your replies!
     

Share This Page