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

Increasing Missionary (National Unit) Limit Issue

Discussion in 'Civ4 - SDK/Python' started by cybrxkhan, Feb 12, 2010.

  1. cybrxkhan

    cybrxkhan Asian Xwedodah

    Joined:
    Aug 10, 2006
    Messages:
    9,687
    Location:
    The Universe
    Hello all. Me and The Capo have been attempting to add a wonder into our mods, the Bamyan Buddha Statues - ideally what it's supposed to do is to increase the buildable limit of missionaries from 3 to 5 (so you can have 5 Islamic Missionaries running around, instead of 3, for example). However, the coding doesn't seem to work.

    What happens is that even though the wonder does allow you to start building a 4th missionary, after one turn, a message comes up saying that the missionary cannot be built and some gold is given to you as "compensation" (like what happens if you can't finish a wonder).

    The J did most of the work here, but he's stumped as well. We based the coding off Tsentsom's HERC Factory Wonder. The coding from the HERC Factory Wonder is below:

    Spoiler :


    Code:
    
    ## HERC Factory Start ##
    
    		iAssault = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ASSAULT_MECH')
    		iHerc = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HERC_FACTORY')
    		obsoleteTech = gc.getBuildingInfo(iHerc).getObsoleteTech()
    
    		pPlayer = gc.getPlayer(pCity.getOwner())
    
    		if eUnit == iAssault:
    
    			if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
    				for iCity in range(pPlayer.getNumCities()):
    					ppCity = pPlayer.getCity(iCity)
    					if ppCity.getNumActiveBuilding(iHerc) == true:
    
    						return True
    
    ## HERC Factory End ##
    
    



    And the code from the Bamyan Buddha Statues is below:



    Spoiler :

    Code:
    
    ## BAMYAN BUDDHA STATUES Start ##
                    iMissionary = []
                    iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_JEWISH_MISSIONARY'))
    		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CHRISTIAN_MISSIONARY'))
    		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ISLAMIC_MISSIONARY'))
    		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_HINDU_MISSIONARY'))
    		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_BUDDHIST_MISSIONARY')    )
    		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CONFUCIAN_MISSIONARY'))
    		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TAOIST_MISSIONARY'))
    		iMoreMissionariesWonder = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_BAMYAN')
    		obsoleteTech = gc.getBuildingInfo(iMoreMissionariesWonder).getObsoleteTech()
    
    		pPlayer = gc.getPlayer(pCity.getOwner())
    		NumReligions = 7
    		for i in range (NumReligions):
                            if eUnit == iMissionary[i]:
                                    if pCity.isHasReligion(i):
                                            pUnit = gc.getUnitInfo (eUnit)
                                            Class = pUnit.getUnitClassType ()
                                            MissionaryCount = pPlayer.getUnitClassCount(Class)
                                            if MissionaryCount <5:
                                                    if (gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
                                                            for iCity in range(pPlayer.getNumCities()):
                                                                    ppCity = pPlayer.getCity(iCity)
                                                                    if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) == true:
                                                                            return True
    
    ## BAMYAN BUDDHA STATUES End ##
    






    If anybody can help us, that'd be really great! Thanks in advance.
     
  2. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    First off, you have some syntax issues , particularly, this line:

    Code:
    if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) == true:
    getNumActiveBuilding returns an integer, not true or false. It should be:

    Code:
    if ( ppCity.getNumActiveBuilding(iMoreMissionariesWonder) > 0 ):

    But this would not cause the error you guys are getting. I would test to see if Tsentom's wonder even works, if not, then you know why you have an issue...
     
  3. EmperorFool

    EmperorFool Deity

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    The problem is the DLL.

    CvCity::doCheckProduction() enforces the national unit class limit, and it's called every turn from CvCity::doTurn(). You'll need to modify CvPlayer::isProductionMaxedUnitClass() to take your wonder into consideration. Of course, if you're going to modify the DLL, you may as well put that Python function in there as well.

    I don't see a way around this.
     
  4. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    31,765
    Location:
    DE/NL/FR
    Um, really? F***.
    Has that maybe changed from 3.17 to 3.19?
    Because i'm sure, that i've testet it some time ago (under 3.17), and it worked there.
     
  5. cybrxkhan

    cybrxkhan Asian Xwedodah

    Joined:
    Aug 10, 2006
    Messages:
    9,687
    Location:
    The Universe
    Oh darn. That's a bummer then. :(
     
  6. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    You could always make the wonder spawn a free missionary for your state religion every X turns, that's pretty close to what you wanted.
     
  7. EmperorFool

    EmperorFool Deity

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    Not that I'm aware of, but I never investigated it under 3.17. I can't imagine them removing the modability of this feature.
     
  8. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    Can you define a second unit -- not a UU, a separate unit -- which also acts as a missionary for the religion? Then the second unit could have a national limit of 2, and the second unit could require the wonder building as a prereq. So you have your extra missionaries once you build the wonder, but they are a different unit.
     
  9. cybrxkhan

    cybrxkhan Asian Xwedodah

    Joined:
    Aug 10, 2006
    Messages:
    9,687
    Location:
    The Universe
    That would work, I suppose, but I'd think that that'd be too much of a... hassle, for lack of better wording. I guess the best solution is to figure out a similar bonus for the wonder.

    Even though I guess the code won't work as I wanted it to, thanks anyways for all the help, guys; I really appreciate it!
     
  10. God-Emperor

    God-Emperor Deity

    Joined:
    Jul 18, 2009
    Messages:
    3,551
    Location:
    Texas
    My suggestion for an interesting effect that is somewhat related to whay you were tyring: an additional unit that costs about 3 times as much as a regular missionary with a build limit of 1. When sacrificed in a city without your state religion religion it adds the religion and builds a monastery for that religion, if sacrificed in a city with the religion but no monastery it just builds the monastery (you could add some small additional effect, like +1 happy for 10 turns or some small culture point bonus). This would speed things along in new cities (instant culture and research point boost due to the "free" monastery) and give you a way to build monasteries after the tech that makes them unbuildable so you can then build regular missionaries in those cities (and get 2 extra culture, too).
     

Share This Page