Modder's Guide to A New Dawn

gc.getGameSpeedInfo()
Can anyone tell me what the methods for this are and how they work?
I am apparently too dumb to find where this is defined.
 
gc.getGameSpeedInfo()
Can anyone tell me what the methods for this are and how they work?
I am apparently too dumb to find where this is defined.

First, you need gc.getGame().getGameSpeedType() to get the current game speed. Then, you need to follow it up with the information that you want to pull from Civ4GameSpeedInfo.xml. For example:

Code:
Xspeed = gc.getGame().getGameSpeedType()
gameSpeedMod = gc.getGameSpeedInfo(Xspeed).getGrowthPercent()
gets the GrowthPercent variable for the current gamespeed from the XML and assigns it to the variable gameSpeedMod. Now you can use gameSpeedMod in a calculation.

Are you getting stuck somewhere?
 
Only in that I dont know what the Growth Percent variable is, so I dont know how or when it would be appropriate to use it or any of the other methods.
 
Last edited:
I asked it in the Quick Modding Questions but try it here too:
Anyone knows how to make a unit give a free promotion when attached to an other one?
For example I create a Fart Frog (oops.... :lol: ) Dart Frog, set the <LeaderPromotion> to PROMOTION_POISON_ARROWS. The pedia text displays what happens when attached to a unit but there is no icon to attach it to any unit. :confused:
Any ideas?
 
I asked it in the Quick Modding Questions but try it here too:

I think you may need an <iLeaderExperience> value greater than 0. Try that and see what happens. You could also try <bGreatGeneral> set to 1, but I think that only works for creating units.

The other thing that might work instead of a <LeaderPromotion> is a Mission. I think from reading the schema that a mission can grant a promotion. You'd need to define the mission and the outcome and then edit the unit file to give the mission to the unit. I have not tried it myself.
 
I think you may need an <iLeaderExperience> value greater than 0. Try that and see what happens. You could also try <bGreatGeneral> set to 1, but I think that only works for creating units.
I tried all of those but nothing :c5unhappy:

The other thing that might work instead of a <LeaderPromotion> is a Mission. I think from reading the schema that a mission can grant a promotion. You'd need to define the mission and the outcome and then edit the unit file to give the mission to the unit. I have not tried it myself.
THX! I'll try it :c5happy:
 
@Vokarya
Is there a tutorial somewhere for the new Mission mechanics? As I see, much of it are coming from some mod, right?

The Mission/Outcome system is all from C2C. I got the syntax for the hunting mechanics from an old version. I don't have a current version of that mod, and I'm not going to install a new one. If you want to see what they've done lately, you are welcome to, but make sure that the tags they used are also in AND, since I don't know how much of the DLL and schemas are shared.

The Missions themselves aren't anything new. It's the Outcomes and interfacing that with the units that are new. Most of the work is actually done in the units XML file.
 
The Missions themselves aren't anything new. It's the Outcomes and interfacing that with the units that are new. Most of the work is actually done in the units XML file.
I knew that just had no idea how the "convert unit into promotion" thing could be done. Now looking into the CIV4OutcomeInfos I think I start to understand it a bit more.
THX anyway :goodjob:
 
Here's an other thing I asked in QMQ but no reply:

So here's something I tried to do:

I made a barbarian UU 'Tribe', a Settler replacement. It cannot found cities; all it can do is to build a Goody Hut by consuming the unit. I have set up Buildinfos and Improvementinfos properly, so I can turn the unit into a Goody Hut; that part works. The problem is that I don't know hove to "encourage" the AI to use the unit as I want that is: when spawned in some empty area it creates more Goody Huts.
I tried both UnitAI_Settle and UnitAI_Worker but no deference.
I also tried to give Goody Hut a +10% defense bonus and place a barbarian military unit to the same tile but still nothing.

Any idea ho to make it work purely with XML modifications? (It's a modular modmod so I don't want to touch any python files or else)
 
Hey guys! I just want to personally thank the whole team for all the years of dedication. I've been playing this mod since Rise of Mankind and it's been great seeing this mod evolve.

On another note, I'm looking to add to the dynamicCivname. I don't really understand how the conditions work for the civic as they use different conditions that I think relate to the revolutions mod.

In the DynamicCivname python
# Main naming conditions
if( RevUtils.isCommunism(iPlayer) ) :
if( self.LOG_DEBUG and bVerbose) : CivUtil.pyPrint ("Names - player is communist")
if( RevUtils.isCanDoElections(iPlayer) and not bNoRealElections) :

I couldn't find the civic related parts in RevUtils.

Again thanks for all the support!
 
Look at RevCivicsUtils.py. RevUtils imports a lot of other utility functions from the other Python files in the Revolution folder and that allows the other Python files to just call RevUtils.
 
I'm in the file and still can't find the specifics.
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.
 
Last edited:
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.

I think you should probably start a new thread to discuss this, because the section of code that applies these tests is almost 400 lines long and we would have to work through all of the logic to figure out where to put the code.
 
Wow thank you very much for the detailed response. I asked my brother too and he said it was very complicated( he knows his prog).
I have been looking at the civics xml to figure out the names of the civics.
I really hope we can get people on board!

As a side note, I've been playing the paradox games and would say that this mod is on par with all those games. It's incredible all the work put into this mod.
 
I want to disable the 2 "buggy" events causing global food shortages but not shore if I've found the right ones:
Are they the EVENTTRIGGER_METEOR_STRIKE and EVENTTRIGGER_VOLCANO ?
These don't seem to be global events to me :confused:
 
I want to disable the 2 "buggy" events causing global food shortages but not shore if I've found the right ones:
Are they the EVENTTRIGGER_METEOR_STRIKE and EVENTTRIGGER_VOLCANO ?
These don't seem to be global events to me :confused:

The events themselves aren't global, but the Python effects they trigger are. You could either disable the events completely or comment out the Python code that triggers the Dark Age. You could remove the Python triggers (<PythonCallback>) but the events don't have any other effects apart from the Python code, so if you remove the Python triggers, you may as well just disable the events themselves.
 
Back
Top Bottom