United nations and Apostilic palace without Diplomatic victory condition

sahbaz

Chieftain
Joined
Jun 6, 2021
Messages
18
Hello,

I have one question related to this feature:

"The United Nations and Apostilic Palace can still be built even when diplomatic victory is not enabled. Players will be able to hold UN elections but can not win by becoming the secretary general"

Is there anyone who knows from technical side how this is implemented, my first assumption is that some things had to be changed in BuildingInfos.xml, for example under:

BUILDINGCLASS_UNITED_NATIONS

I guess we have to change
<PrereqVictory>VICTORY_DIPLOMATIC</PrereqVictory>
to
<PrereqVictory>NONE</PrereqVictory>

Also I am wondering what about this:

<DiploVoteType>DIPLOVOTE_UN</DiploVoteType> -> should this be NONE
<bForceTeamVoteEligible>1</bForceTeamVoteEligible> -> what about this ?

I would appreciate if someone could elaborate this, I am asking this question here, because I only seen this cool feature in this mod :)
 
Last edited:
None of the XML is changed. It is all done at the DLL level. This is the code from CvGame.cpp.

Code:
    if (isOption(GAMEOPTION_UNITED_NATIONS))
    {
        //Find the diplomatic victory
        BuildingTypes eUnitedNations = NO_BUILDING;
        for (iI = 0; iI < GC.getNumBuildingInfos(); iI++)
        {
            if (GC.getBuildingInfo((BuildingTypes)iI).getVictoryPrereq() != NO_VICTORY)
            {
                if (GC.getBuildingInfo((BuildingTypes)iI).getVoteSourceType() != NO_VOTESOURCE)
                {
                    eUnitedNations = (BuildingTypes)iI;
                    break;
                }
            }
        }
        if (eUnitedNations != NO_BUILDING)
        {
            m_bDiploVictoryEnabled = isVictoryValid((VictoryTypes)GC.getBuildingInfo(eUnitedNations).getVictoryPrereq());
            setVictoryValid((VictoryTypes)GC.getBuildingInfo(eUnitedNations).getVictoryPrereq(), true);
        }
    }
What it does is bypass the victory prerequisite check on any building that both requires a victory type and provides votes. The only current buildings that provide votes are the Apostolic Palace and the United Nations, but if anyone were to add another such building, it would also be affected.
 
None of the XML is changed. It is all done at the DLL level. This is the code from CvGame.cpp.

Code:
    if (isOption(GAMEOPTION_UNITED_NATIONS))
    {
        //Find the diplomatic victory
        BuildingTypes eUnitedNations = NO_BUILDING;
        for (iI = 0; iI < GC.getNumBuildingInfos(); iI++)
        {
            if (GC.getBuildingInfo((BuildingTypes)iI).getVictoryPrereq() != NO_VICTORY)
            {
                if (GC.getBuildingInfo((BuildingTypes)iI).getVoteSourceType() != NO_VOTESOURCE)
                {
                    eUnitedNations = (BuildingTypes)iI;
                    break;
                }
            }
        }
        if (eUnitedNations != NO_BUILDING)
        {
            m_bDiploVictoryEnabled = isVictoryValid((VictoryTypes)GC.getBuildingInfo(eUnitedNations).getVictoryPrereq());
            setVictoryValid((VictoryTypes)GC.getBuildingInfo(eUnitedNations).getVictoryPrereq(), true);
        }
    }
What it does is bypass the victory prerequisite check on any building that both requires a victory type and provides votes. The only current buildings that provide votes are the Apostolic Palace and the United Nations, but if anyone were to add another such building, it would also be affected.


Thank you very much for explanation!

I don't know in detail what exactly means DLL level, but I guess you have to recompile some things after making that change?

The way how I handled that for needs of games I play with my friends is:

I simply removed 2 things from Civ4VoteInfo.xml

I removed option to vote for victory, so basically that means I removed 2 blocks from that file:


Code:
        <!-- <VoteInfo>
            <Type>VOTE_VICTORY</Type>
            <Description>TXT_KEY_VOTE_VICTORY</Description>
            <iPopulationThreshold>62</iPopulationThreshold>
            <bCityVoting>0</bCityVoting>
            <bCivVoting>0</bCivVoting>
            <iMinVoters>3</iMinVoters>
            <iStateReligionVotePercent>0</iStateReligionVotePercent>
            <iTradeRoutes>0</iTradeRoutes>
            <bSecretaryGeneral>0</bSecretaryGeneral>
            <bVictory>1</bVictory>
            <bFreeTrade>0</bFreeTrade>
            <bNoNukes>0</bNoNukes>
            <bDefensivePact>0</bDefensivePact>
            <bOpenBorders>0</bOpenBorders>
            <bForcePeace>0</bForcePeace>
            <bForceNoTrade>0</bForceNoTrade>
            <bForceWar>0</bForceWar>
            <bAssignCity>0</bAssignCity>
            <ForceCivics/>
            <DiploVotes>
                <DiploVote>
                    <DiploVoteType>DIPLOVOTE_UN</DiploVoteType>
                    <bValid>1</bValid>
                </DiploVote>
            </DiploVotes>
        </VoteInfo> -->



        <!-- <VoteInfo>
            <Type>VOTE_RELIGIOUS_VICTORY</Type>
            <Description>TXT_KEY_VOTE_RELIGIOUS_VICTORY</Description>
            <iPopulationThreshold>75</iPopulationThreshold>
            <bCityVoting>0</bCityVoting>
            <bCivVoting>0</bCivVoting>
            <iMinVoters>3</iMinVoters>
            <iStateReligionVotePercent>100</iStateReligionVotePercent>
            <iTradeRoutes>0</iTradeRoutes>
            <bSecretaryGeneral>0</bSecretaryGeneral>
            <bVictory>1</bVictory>
            <bFreeTrade>0</bFreeTrade>
            <bNoNukes>0</bNoNukes>
            <bDefensivePact>0</bDefensivePact>
            <bOpenBorders>0</bOpenBorders>
            <bForcePeace>0</bForcePeace>
            <bForceNoTrade>0</bForceNoTrade>
            <bForceWar>0</bForceWar>
            <bAssignCity>0</bAssignCity>
            <ForceCivics/>
            <DiploVotes>
                <DiploVote>
                    <DiploVoteType>DIPLOVOTE_POPE</DiploVoteType>
                    <bValid>1</bValid>
                </DiploVote>
            </DiploVotes>
        </VoteInfo> -->


So as you can see, those 2 options are commented out, and with this I can simply chose victory condition Diplomatic and we wont be able to vote for victory and we will have all other features Diplomatic victory condition provides.
 
Thank you very much for explanation!

I don't know in detail what exactly means DLL level, but I guess you have to recompile some things after making that change?

Basically, there are 3 levels of modding complexity:
  • First is XML modding, which is what you are doing. XML modding lets you do only things that are allowed by the game's DLL. It's like working from a checklist.
  • Second is Python modding. This is more powerful but doesn't work well with anything that needs to be applied consistently. It's better for things that happen once and then the game doesn't need to check for them again. It gets used a lot for complex results from events and for World Wonders.
  • Third is DLL modding, where you edit the source files and recompile the DLL. I haven't tried to do this myself. I can read the source files but I've never tried actually editing them.

So as you can see, those 2 options are commented out, and with this I can simply chose victory condition Diplomatic and we wont be able to vote for victory and we will have all other features Diplomatic victory condition provides.

This works as well. The only drawback is that you would have to re-edit the XML in order to restore the Diplomatic Victory function. Putting into the DLL allows it to be an option that can be turned off or on within the game.
 
Top Bottom