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

Quick Modding Questions Thread

Discussion in 'Civ4 - Creation & Customization' started by kiwitt, Jan 27, 2010.

  1. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    Thanks for the instruct guys :) I have made the changes so hopefully we are all good now :D

    that python error was starting to get irratating :D

    Doh... New error

    NameError: global name 'Immigration' is not defined

    Spoiler :
    Code:
    		iOwner = pCity.getOwner()
    		pPlayer = gc.getPlayer(iOwner)
    		UnitType = unit.getUnitType()
    		iImmigrant = gc.getInfoTypeForString("UNIT_IMMIGRANT")
    		intCity = Immigration.getLeastPopulatedCity(iOwner) [COLOR="Red"]<--this line[/COLOR]
    		
    		if UnitType == iImmigrant:
    			#CyInterface().addImmediateMessage("B", "")
    			if pPlayer.isAlive() and not pPlayer.isBarbarian():
    				ReducedCityPopulation = pCity.getPopulation() - 2
    				pCity.setPopulation(ReducedCityPopulation)				
    				if intCity != -1:
    					MigrationCity = pPlayer.getCity(intCity)
    					Immigration.doImmigrantPlacementAI(unit, MigrationCity)		


    Now there is also a python file called immigration which is in my mod, so I am not sure if the 2 things are linked or not.. (or if they somehow need to be and they are not properly..)
     
  2. God-Emperor

    God-Emperor Deity

    Joined:
    Jul 18, 2009
    Messages:
    3,551
    Location:
    Texas
    You probably need to import the Immigration file so you can use the functions in it. Up near the beginning of the file, around where the other similar statements are in there already, add a line that just says "import Immigration".

    Odds are good that this will fix this problem. Then it is on to the next problem... (Well, with a quick look through the code again it actually like like there won't be another. Besides which, you are running out of lines in the function that have not had a problem fixed already.)
     
  3. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    Ah yes that was the problem, I had imported that in one file, but not this one :)

    Haha don't worry I am sure I will find away to break something else soon enough :D
     
  4. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    hey guys, how hard is it to add a new unitcombat like archer mounted gunpowder etc.

    I was under the impression that it required SDK work? but one of my team says it is easy so I find myself confused!

    Once again I climb the mountain to gain knowledge from the fount of wisdom oh wise modders!
     
  5. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,970
    Location:
    DE/NL/FR
    Doesn't require SDK, as long as it's simply a new one.
     
  6. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
  7. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    Hey guys, was the ability to set a prereq tech for upgradable improvements (like cottage-town, developed in a mod?) I just tried to do it with the existing code but it does not seem to work..
     
  8. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    419
    Gender:
    Male
    Location:
    USA
    If that already exists it must have been in a mod. You can put prereq techs on the BuildInfos to prevent workers from building an improvement without a tech. AFAIK with XML you can't have a prereq tech for upgrading. This sounds like a good thing to add into Super Forts. ;)
     
  9. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    DOOOOO IIIIIT!

    Yeah I think I have seen it in RoM and AND on things like the shaft mine.

    Yeah I tried setting it through the build info with a build time of -1, but it didn't work :D
     
  10. Zlatko

    Zlatko CIW

    Joined:
    Apr 1, 2010
    Messages:
    713
    Location:
    Solar System
    I have one new problem.

    I work with map scripts and i am put some new map scripts.

    You can see "AlphaCentauri"(this is map script from Future Mod), sometimes work, sometimes don't work. I put all terrain and all feature in game, which i see in "AlphaCentauri" map script and i am converted .xml and .py files in .txt because forum don't give to upload this two types of files.

    When i am in game, i choose "AlphaCentauri" map script, sometimes work normal, but sometimes i get this:



    I really don't know why.

    This is my version of Rise from Erebus.

    You can see my attached files. I am attach my terrain and feature infos.

    Please see and help, i can upload some another map script (for example some map script which work correctly, from "Rise from Erebus").
     

    Attached Files:

  11. maurcus

    maurcus Warlord

    Joined:
    May 24, 2012
    Messages:
    245
    this is an odd question but do samurai and gallic swordsman require py. modding to be able to get the crossover promotions?
     
  12. God-Emperor

    God-Emperor Deity

    Joined:
    Jul 18, 2009
    Messages:
    3,551
    Location:
    Texas
    No.

    Any unit will start with any promotion it is given for free in the Unit XML regardless of normal requirements.

    Combine that with the promotion unitcombat requirements and you see how it is done. For example, Drill 1 does not list the melee type so melee units can't take it. But Drill 2 and higher do list melee as being able to take them. So if a melee unit manages to get Drill 1 (like getting it for free in the unitinfo XML, as the Samurai does) it can continue to get the later drill promotions.
     
  13. srpt

    srpt Deist

    Joined:
    May 10, 2010
    Messages:
    2,038
    Location:
    Toronto
    some civs in my mod are building excessive numbers of workers even when their land is already improved.

    I have tried to influence their decision based on the number of workers they already have vs how many cities, but my C++ modding is trial and error and so far, though it compiles and runs fine, they are still building just as many workers.

    I have tried this:

    Spoiler :

    in
    Code:
    UnitTypes CvCityAI::AI_bestUnit(bool bAsync, AdvisorTypes eIgnoreAdvisor, UnitAITypes* peBestUnitAI)
    I added

    Code:
    // srpt start attempt to curb AI worker spam
    	if (kPlayer.AI_getNumAIUnits(UNITAI_WORKER) >= (std::max(kPlayer.getNumCities() / 3, 4)))
    	{
    		aiUnitAIVal[UNITAI_WORKER] = 0;
    	}
    	// srpt end


    it seemed to have no effect. am I in the wrong place?
     
  14. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,231
    Location:
    Czech Kingdom
    Hi everyone. I'm not a programmer. I tried to make this code from three parts work of The_J . Code but does not work. Can someone try to find a bug, please?

    Spoiler :
    PHP:
        def onImprovementBuilt(selfargsList):
            
    'Improvement Built'
            
    iImprovementiXiY argsList
    ## Ritual Start ## 
            
    if iImprovement == gc.getInfoTypeForString("IMPROVEMENT_RITUAL"): 
                
    iX pPlot.getX() 
                
    iY pPlot.getY() 

                for 
    iXLoop in range(iX 1iX 2):
                    for 
    iYLoop in range(iY 1iY 2): 
                        
    pPlot CyMap().plot(iXLoopiYLoop
                        if 
    pPlot.isWater():
                            
    iBonus pPlot.getBonusType(-1)                                                
                            
    pPlot.setPlotType(PlotTypes.PLOT_LANDTrueTrue
                            
    pPlot.setImprovementType(-1
                            
    pPlot.setTerrainType(gc.getInfoTypeForString"TERRAIN_GRASS" ), 11)                                                              
                            if 
    iBonus ==gc.getInfoTypeForString("BONUS_FISH"):                                                                         
                                
    iNewBonus gc.getInfoTypeForString("BONUS_COW")
                            
    elif iBonus ==gc.getInfoTypeForString("BONUS_CLAM"): 
                                
    iNewBonus gc.getInfoTypeForString("BONUS_PIG"
                            
    elif iBonus ==gc.getInfoTypeForString("BONUS_CRAB"): 
                                
    iNewBonus gc.getInfoTypeForString("BONUS_SHEEP"
                            
    elif iBonus ==gc.getInfoTypeForString("BONUS_OIL"): 
                                
    iNewBonus gc.getInfoTypeForString("BONUS_OIL")                                                     
                            
    elif iBonus ==gc.getInfoTypeForString("BONUS_WHALE"): 
                                
    iNewBonus gc.getInfoTypeForString("BONUS_DEER"
                            else:
                                
    iNewBonus = -1
                            pPlot
    .setBonusType(iNewBonus
    ## Ritual End ##
     
  15. God-Emperor

    God-Emperor Deity

    Joined:
    Jul 18, 2009
    Messages:
    3,551
    Location:
    Texas
    According to the 3rd line, which is unpacking the argsList into separate variables, you already have an iX and iY as they are passed via the argsList. You do not have a pPlot defined anywhere before the loops. So the 6th and 7th lines are a problem and should just be removed.

    There may be some other problem, but nothing leapt out at me like that issue.
     
  16. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,231
    Location:
    Czech Kingdom
    I did as you said. It does not work . I'm confused :confused:
     
  17. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,970
    Location:
    DE/NL/FR
    Are Python exceptions enabled?
     
  18. The_guy

    The_guy Elephantary School.

    Joined:
    Nov 23, 2010
    Messages:
    64
    Location:
    Holland.
    I stole the idea from Voykah, but is there a modcomp that allows me to speed up certain technologies for certain civilizations?
     
  19. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,231
    Location:
    Czech Kingdom
    Are long . But let 's even rechecked . :)
     
  20. isenchine

    isenchine Empress

    Joined:
    Oct 18, 2010
    Messages:
    1,774
    Location:
    Brussels, Belgium
    Divide the Technology in two (Pre-Tech and Tech) and give Pre-Tech to the Civ for free! Silly, isn't it?
     

Share This Page