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

OOS with getBuildingCostMod

Discussion in 'Civ4 - SDK/Python' started by Alrik2002, Feb 8, 2014.

  1. Alrik2002

    Alrik2002 Warlord

    Joined:
    May 24, 2012
    Messages:
    214
    Location:
    Berlin, Germany
    Hi,

    I have added one of Platypings wonders to my mod. It works fine but in a pitboss game, I´ve the problem that the pitboss doesn´t use the discount. Every Player in the game has the same gamestats only the pitboss differs.

    I´ve no idea how to fix this. Here is the code:

    Code:
    	def getBuildingCostMod(self, argsList):
    		iPlayer, iCityID, iBuilding = argsList
    		pPlayer = gc.getPlayer(iPlayer)
    		pCity = pPlayer.getCity(iCityID)
    		pTeam = gc.getTeam(pPlayer.getTeam())
    		iCostMod = -1 # Any value > 0 will be used
    
    		Discount = 0
    ## Apadana Palace Start ##
    		if pTeam.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_APADANA_PALACE")) == 1:
    			obsoleteTech = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_APADANA_PALACE")).getObsoleteTech()
    			if gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1:
    				capital = pPlayer.getCapitalCity()
    				if capital.getNumActiveBuilding(iBuilding) == 1 and not pCity.isCapital():
    					return 80
    ## Platyping Wonders End ##
    		return iCostMod
    Thank you very much for your help.

    EDIT: I´ve tested the code on standard BtS with only this change. There it works fine even in pitboss games. Since I use K-Mod which is based on BUG it seems, that the changes BUG made with the gameUtils are causing my problems. I testes the code in SP and MP DirectIP (without pitboss). Even there it works perfect. Only the pitboss seems to have the problems.
     
  2. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,428
    Problems with Pitboss usually indicate that some piece of code can't deal with a player ID of -1 which the Pitboss himself has and passes to some calls.
     
  3. OrionVeteran

    OrionVeteran Deity

    Joined:
    Dec 25, 2003
    Messages:
    2,443
    Location:
    Newport News VA
    In such a case, I would suggest adding the following line to the beginning of the function:

    Code:
    if not (iPlayer == PlayerTypes.NO_PLAYER):
    
     

Share This Page