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

Civic as requirement for promotion???

Discussion in 'Civ4 - SDK/Python' started by Monaldinio, Mar 30, 2012.

  1. Monaldinio

    Monaldinio Prince

    Joined:
    Jan 6, 2010
    Messages:
    415
    Location:
    Rostock
    Can some one help me with the Code?!?!:confused:
     
  2. CaptainMidnight

    CaptainMidnight Warlord

    Joined:
    Apr 16, 2006
    Messages:
    141
    Code:
    def onUnitBuilt(self, argsList):
    		'Unit Completed'
    		city = argsList[0]
    		unit = argsList[1]
    		player = PyPlayer(city.getOwner())
    
    ## Hereditary Spy Bonus ##
    
    		pPlayer = gc.getPlayer(pUnit.getOwner())
    
    		iGovernmentCivicOption = CvUtil.findInfoTypeNum(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_GOVERNMENT')
    		iHereditary = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_HEREDITARY_RULE')
    		
    		iGovernmentCivic = pPlayer.getCivics(iGovernmentCivicOption)
    			
    		if (iGovernmentCivic == iHereditary):
    			if unit.getUnitType() == gc.getInfoTypeForString('UNIT_KNIGHT'):
    				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MORALE'), True)
    
    			if unit.getUnitType() == gc.getInfoTypeForString('UNIT_SPY'):
    				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MORALE'), True)
    					
    ## Hereditary Spy Bonus ##
    This is how I do it (copied from Thomas' War Mod pretty much). This will give units a free promotion (Morale) under a civic (hereditary rule). The units will, however, retain the promotion after you switch from the civic. If you want the civic to disappear when you switch from the civic you can use this SDK mod:

    TLOTags v0.40
     
  3. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    I don't think that's what he wants. He asked for a promotion requiring a civic, not a promotion free with a civic.

    This would be easiest to do most correctly done in SDK. You would add a new XML tag, and modify a CvUnit method, and all done. I might actually do it.
     
  4. CaptainMidnight

    CaptainMidnight Warlord

    Joined:
    Apr 16, 2006
    Messages:
    141
    @Voyhkah, Good point. I totally agree with you on modding the SDK for that one.

    @Monaldinio The working SDK code is in the TLOTags v0.40 which adds Prereq civic tag to the promotioninfos. If (like me) you are a somewhat limited programmer you should just copy the parts you need from the source code Be sure to check the threads as there is a bugfix I made written there for this XMLtag.
     
  5. Monaldinio

    Monaldinio Prince

    Joined:
    Jan 6, 2010
    Messages:
    415
    Location:
    Rostock
    :crazyeye::goodjob::crazyeye:

    Óh my God, thank you!!!! i have never intended that someone answered!!!!

    Tahnk you Thank you Thank you!!!!!:goodjob:
     

Share This Page