New Dynamic CIV names

What do you think of the suggested names?

  • Needs improvement.

    Votes: 0 0.0%

  • Total voters
    2

R3ZPU13LIK4

Chieftain
Joined
Mar 21, 2018
Messages
7
Hey everyone! I'm here looking to update the Dynamic CIV names mod as the update 1068 added a lot of new civics and it was based off of the old Rise of Mankind civics, I believe.
I'm not a programmer so I'm not sure exactly what I'm doing

I'm try to add this

If civic_democracy and (civic_single_party or civic_junta) then 50% CIVADJ People's Republic or 50% People's Rep. Of CIVNAME
if civic_junta and not civic_democracy then Revolutionary CIVNAME
if (civic_autocracy or civic_single_party) and civic_nationalist and not civic_monarchy then National Socialist CIVNAME
if civic_democracy then 50% CIVADJ Dem. Rep. or 50% Dem. Rep. CIVNAME
if civic_hive then CIVADJ Hive
if civic_corporations then CIVNAME Incorporated
if civic_planned and not(civic_federal or civic_democracy) then 50% CIVADJ Soc. Rep. or 50% Soc. Rep. Of CIVNAME
If civic_planned and civic_federal than 50% CIVADJ SSR or 50% SSR of CIVNAME

Thank you for the help.

I did some more digging and found this in the dynamicCivname python:

Code:
 # Assigns a new name to a player based on their civics choices

    pPlayer = gc.getPlayer(iPlayer)
    capital = pPlayer.getCapitalCity()
    playerEra = pPlayer.getCurrentEra()
    pTeam = gc.getTeam(pPlayer.getTeam())
   
    cityString = None
    if( not capital == None and not capital.isNone() ) :
      try :
        # Silly game to force ascii encoding now
        cityString =  pPlayer.getCivilizationDescription(0)
        cityString += "&" + CvUtil.convertToStr(capital.getName())
        cityString =  cityString.split('&',1)[-1]
      except :
        pass

    curDesc  = pPlayer.getCivilizationDescription(0)
    curShort = pPlayer.getCivilizationShortDescription(0)
    curAdj   = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getAdjective(0)
    curAdj1 = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getAdjective(1)
    curAdj2 = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getAdjective(2)
    curAdj3 = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getAdjective(3)

    origDesc  = ""
    if (pPlayer.getCivilizationType() >= 0):
      civInfo = gc.getCivilizationInfo(pPlayer.getCivilizationType())
      origDesc  = civInfo.getDescription()
   
    eLeader = pPlayer.getLeaderType()
   
    bFemaleLeader = self.isFemaleLeader(eLeader)

    iLanguage = gc.getGame().getCurrentLanguage()
    bFrench = iLanguage == 1 #0 - English, 1 - French, 2 - German, 3 - Italian, 4 - Spanish

    eGovCivic = pPlayer.getCivics(gc.getInfoTypeForString("CIVICOPTION_GOVERNMENT"))
    ePowerCivic = pPlayer.getCivics(gc.getInfoTypeForString("CIVICOPTION_POWER"))
    bNoRealElections = (gc.getInfoTypeForString("CIVIC_HEREDITARY_RULE") == eGovCivic or gc.getInfoTypeForString("CIVIC_HEREDITARY_RULE") == eGovCivic or gc.getInfoTypeForString("CIVIC_DESPOTISM") == eGovCivic)
   
    bFederal = (gc.getInfoTypeForString("CIVIC_FEDERAL") == eGovCivic and (ePowerCivic == gc.getInfoTypeForString("CIVIC_SENATE") or ePowerCivic == gc.getInfoTypeForString("CIVIC_PARLIAMENT") or ePowerCivic == gc.getInfoTypeForString("CIVIC_PRESIDENT")))
    bConfederation = (not bFederal and (gc.getInfoTypeForString("CIVIC_FEDERAL") == eGovCivic))
   
    bPacifist = (pPlayer.getCivics(gc.getInfoTypeForString("CIVICOPTION_MILITARY")) == gc.getInfoTypeForString("CIVIC_PACIFISM"))
   
    if( not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV) ) :
      if( pPlayer.getLeaderType() in LeaderCivNames.LeaderCivNames.keys() ) :
        [curDesc,curShort,curAdj] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()]

    newName = curDesc
    if( SDTK.sdObjectExists( "Revolution", pPlayer ) ) :
      revTurn = SDTK.sdObjectGetVal( "Revolution", pPlayer, 'RevolutionTurn' )
    else :
      revTurn = None

    if( SDTK.sdObjectExists( "BarbarianCiv", pPlayer ) ) :
      barbTurn = SDTK.sdObjectGetVal( "BarbarianCiv", pPlayer, 'SpawnTurn' )
    else :
      barbTurn = None

    if( not pPlayer.isAlive() ) :
      if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is not alive")
      if (bFrench):
          newName = localText.getText("TXT_KEY_MOD_DCN_REFUGEES", ())%(curAdj2)
      else:
          newName = localText.getText("TXT_KEY_MOD_DCN_REFUGEES", ())%(curAdj)
      return [newName, curShort, curAdj]
   
    if( pPlayer.isRebel() ) :
      # Maintain name of rebels from Revolution Mod
      if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is rebel, keeping current name")
      if( bForceUpdate ) :
        return self.nameForNewPlayer(iPlayer)
      else :
        return [curDesc, curShort, curAdj]
    elif( pPlayer.isMinorCiv() and not barbTurn == None ) :
      # Maintain minor civ name
      if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is Minor Barb Civ, keeping current name")
      if( bForceUpdate ) :
        return self.nameForNewPlayer(iPlayer)
      else :
        return [curDesc, curShort, curAdj]
    elif( not barbTurn == None and game.getGameTurn() - barbTurn < 20 and pPlayer.getNumCities() < 4 ) :

Plus this:


Code:
# Main naming conditions
    if( RevUtils.isCommunism(iPlayer) ) :
      if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is communist")
      if( RevUtils.isCanDoElections(iPlayer) and not bNoRealElections) :
        if( not bForceUpdate and (sSocRep in curDesc or sPeoplesRep in curDesc) ) :
          if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - keeping prior name")
          newName = curDesc
        elif( 50 > game.getSorenRandNum(100,'Rev: Naming4') ) :
          if (bFrench):
            newName = localText.getText("TXT_KEY_MOD_DCN_SOC_REP", ())%(curAdj1)
          else:
            newName = localText.getText("TXT_KEY_MOD_DCN_SOC_REP", ())%(curShort)
        else :
          if (bFrench):
            newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ())%(curAdj2)
          else:
            newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ())%(curShort)
      elif( RevUtils.getDemocracyLevel(iPlayer)[0] == -8 ) :
        if( localText.getText("TXT_KEY_MOD_DCN_RUSSIAN_MATCH", ()) in curAdj ) :
          curAdj = localText.getText("TXT_KEY_MOD_DCN_SOVIET", ())
        newName = localText.getText("TXT_KEY_MOD_DCN_UNION", ())%(curAdj)
      else :
        if (bFrench):
            newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ())%(curAdj2)
        else:
            newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ())%(curShort)
    elif( RevUtils.isCanDoElections(iPlayer) and not bNoRealElections) :
      if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player can do elections")
      sRepOf = localText.getText("TXT_KEY_MOD_DCN_REPUBLIC_OF", ()).replace('%s','').strip()
      sRepublic = localText.getText("TXT_KEY_MOD_DCN_REPUBLIC", ())

Aswell as this in the RevUtils:


Code:
def canDoCommunism( iPlayer ) :
    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() ) :
        return [False,None]

    for i in range(0,gc.getNumCivicInfos()) :
        kCivic = gc.getCivicInfo(i)
        if( kCivic.isCommunism() and pPlayer.canDoCivics(i) ) :
            if( not pPlayer.isCivic(i) ) :
                return [True,i]

    return [False,None]

def isCommunism( iPlayer ) :
    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() ) :
        return False

    for i in range(0,gc.getNumCivicInfos()) :
        kCivic = gc.getCivicInfo(i)
        if( kCivic.isCommunism() and pPlayer.isCivic(i) ) :
                return True

    return False

def canDoFreeSpeech( iPlayer ) :
    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() ) :
        return [False,None]

    for i in range(0,gc.getNumCivicInfos()) :
        kCivic = gc.getCivicInfo(i)
        if( kCivic.isFreeSpeech() and pPlayer.canDoCivics(i) ) :
            if( not pPlayer.isCivic(i) ) :
                return [True,i]

    return [False,None]

def isFreeSpeech( iPlayer ) :
    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() ) :
        return False

    for i in range(0,gc.getNumCivicInfos()) :
        kCivic = gc.getCivicInfo(i)
        if( kCivic.isFreeSpeech() and pPlayer.isCivic(i) ) :
                return True

    return False

def isCanDoElections( iPlayer ) :
    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() or pPlayer.isBarbarian() ) :
        return False

    for i in range(0,gc.getNumCivicOptionInfos()) :
        iCivic = pPlayer.getCivics(i)
        if( iCivic >= 0 ) :
            kCivic = gc.getCivicInfo(iCivic)
            if( kCivic.isCanDoElection() ) :
                return True


    return False

def getReligiousFreedom( iPlayer ) :
    # Returns [freedom level, option type]

    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() ) :
        return [0,None]

    for i in range(0,gc.getNumCivicOptionInfos()) :
        iCivic = pPlayer.getCivics(i)
        if( iCivic >= 0 ) :
            kCivic = gc.getCivicInfo(iCivic)
            if( not kCivic.getRevReligiousFreedom() == 0 ) :
                return [kCivic.getRevReligiousFreedom(),i]

    return [0,None]


def getBestReligiousFreedom( iPlayer, relOptionType ) :
    # Returns [best level, civic type]

    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() or relOptionType == None ) :
        return [0,None]

    bestFreedom = -11
    bestCivic = None

    for i in civicsList[relOptionType] :
        kCivic = gc.getCivicInfo(i)
        civicFreedom = kCivic.getRevReligiousFreedom()
        if( pPlayer.canDoCivics(i) and not civicFreedom == 0 ) :
            if( kCivic.getRevReligiousFreedom() > bestFreedom ) :
                bestFreedom = civicFreedom
                bestCivic = i

    return [bestFreedom, bestCivic]

def getDemocracyLevel( iPlayer ) :
    # Returns [level, option type]

    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() ) :
        return [0,None]

    for i in range(0,gc.getNumCivicOptionInfos()) :
        iCivic = pPlayer.getCivics(i)
        if( iCivic >= 0 ) :
            kCivic = gc.getCivicInfo(iCivic)
            if( not kCivic.getRevDemocracyLevel() == 0 ) :
                return [kCivic.getRevDemocracyLevel(),i]

    return [0,None]


def getBestDemocracyLevel( iPlayer, optionType ) :
    # Returns [best level, civic type]

    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() or optionType == None ) :
        return [0,None]

    bestLevel = -11
    bestCivic = None

    for i in civicsList[optionType] :
        kCivic = gc.getCivicInfo(i)
        civicLevel = kCivic.getRevDemocracyLevel()
        if( pPlayer.canDoCivics(i) and not civicLevel == 0 ) :
            if( civicLevel > bestLevel ) :
                bestLevel = civicLevel
                bestCivic = i

    return [bestLevel, bestCivic]

def getLaborFreedom( iPlayer ) :
    # Returns [level, option type]

    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() ) :
        return [0,None]

    for i in range(0,gc.getNumCivicOptionInfos()) :
        iCivic = pPlayer.getCivics(i)
        if( iCivic >= 0 ) :
            kCivic = gc.getCivicInfo(iCivic)
            if( not kCivic.getRevLaborFreedom() == 0 ) :
                return [kCivic.getRevLaborFreedom(),i]

    return [0,None]


def getBestLaborFreedom( iPlayer, optionType ) :
    # Returns [best level, civic type]

    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() or optionType == None ) :
        return [0,None]

    bestLevel = -11
    bestCivic = None

    for i in civicsList[optionType] :
        kCivic = gc.getCivicInfo(i)
        civicLevel = kCivic.getRevLaborFreedom()
        if( pPlayer.canDoCivics(i) and not civicLevel == 0 ) :
            if( civicLevel > bestLevel ) :
                bestLevel = civicLevel
                bestCivic = i

    return [bestLevel, bestCivic]

def getEnvironmentalProtection( iPlayer ) :
    # Returns [level, option type]

    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() ) :
        return [0,None]

    for i in range(0,gc.getNumCivicOptionInfos()) :
        iCivic = pPlayer.getCivics(i)
        if( iCivic >= 0 ) :
            kCivic = gc.getCivicInfo(iCivic)
            if( not kCivic.getRevEnvironmentalProtection() == 0 ) :
                return [kCivic.getRevEnvironmentalProtection(),i]

    return [0,None]


def getBestEnvironmentalProtection( iPlayer, optionType ) :
    # Returns [best level, civic type]

    pPlayer = gc.getPlayer(iPlayer)

    if( pPlayer.isNone() or not pPlayer.isAlive() or optionType == None ) :
        return [0,None]

    bestLevel = -11
    bestCivic = None

    for i in civicsList[optionType] :
        kCivic = gc.getCivicInfo(i)
        civicLevel = kCivic.getRevEnvironmentalProtection()
        if( pPlayer.canDoCivics(i) and not civicLevel == 0 ) :
            if( civicLevel > bestLevel ) :
                bestLevel = civicLevel
                bestCivic = i

    return [bestLevel, bestCivic]

I'm still confused as to where I need to make changes and how to do it properly.
Thanks for the support.
 
This is going to be complicated. The first thing is do not try and edit RevUtils.py. These are utility functions. You use them to ask a question about a particular civic. For example, isCommunism is used to ask if the player is in a communistic government, as determined by the <bCommunism> tag. Currently, this applies to the Single Party and Regulated civics. Incidentally, this seems like a horrible mistake; Planned should be the communist economy civic, not Regulated.

The second thing is to test for a particular civic being run, use if pPlayer.isCivic(gc.getInfoTypeforString("CIVIC_XXX")) where the XXX is the name of the civic you are testing for. You'll have to read the XML because it's not always the same as the in-game name. For example, Monarchy is CIVIC_HEREDITARY_RULE because it's still using the base Civ4 XML.
 
The first question is are we going to keep the current system as well, and implement these changes inside it? I'm guessing the answer is yes, so we need to break down the logic of the code and decide where to implement these changes.

The first thing to pay attention to is to ignore any line that starts with if( self.LOG_DEBUG and bVerbose ). These are for debugging.
 
I've already found two interesting things reading through the Dynamic Civ Names code.

One is there is a flag for "No Real Elections". This is currently set to True if you are running Despotism or Monarchy. I think this flag should be set if you are also running Autocracy (you can't run it with Democracy or Federation, but you can with Republic, so Republic + Autocracy is a sham republic) or Junta or Single Party. I still haven't seen everything this flag does.

Two is that there is a way to create a "Something Union" name -- it's "Soviet Union" if you are Russia, and your adjective Union for any other civ. But to trigger it, you have to have a Communist civic (Single Party or Planned), either a No Real Elections civic (as I mentioned above) or no Can Do Elections civic (Republic/Democracy/Federation/Senate/Parliament/President), and a Democracy Level of exactly -8. We can't do this right now because there is no civic with a Democracy Level of -8. (Original Revolutions for BTS had this for Police State.)

Democracy Level is also used for certain checks to push you to a more democratic government. What I want to do here is go back and change the "Union" check to -10. That way if you are Despotism (or for some reason Chiefdom) you will trigger the Union name.
 
So basically you have to make a new civic and add that flag to the commy civics.

Does it interfere with other flags?
 
I don't need to make a new civic, just adjust the check for whether a government is sufficiently repressive enough to count. With the democracy level check at -10 and playing as Russia, adopting Despotism and Planned is sufficient.

Civ4ScreenShot0007.JPG
 
I wonder why the term "Union" should be associated with something "bad" as Soviet Union or other repressive governments. What about European Union?
Agree. Union should require Federation civic instead of democracy check.
 
Top Bottom