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

Platyping's Python

Discussion in 'Civ4 - Mod Components' started by platyping, Jan 1, 2012.

  1. Azurian

    Azurian The Azurian

    Joined:
    Apr 10, 2012
    Messages:
    2,092
    Location:
    Florida, USA
    Have you made a Pedia screen for Buildings that shows what buildings a building upgrades from and what it upgrades to? Similiar to the the Technology Pedia screen that shows tech prereqs and what the Tech leads to?
     
  2. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Too easy yet nothing much to show which is why I didn't bother.
    If I can make a tech version, less than 10 mins to make a building version :)
     
  3. Azurian

    Azurian The Azurian

    Joined:
    Apr 10, 2012
    Messages:
    2,092
    Location:
    Florida, USA
    I official request a Building version, you will be a godsend.

    I think you can shrink the Building preview for space.

    Even Leads To us enough. The template modified would be the Caveman 2 Cosmos Building Pediatric Screen.
    All I'm asking is:
    Requires :
    Leads to:

    I think 2 or 3 icons showing is enough lol.
     
  4. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Refer to the other thread... already done lol
     
  5. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,544
    Gender:
    Male
    Location:
    Canberra, Australia
    @MrAzure C2C already has this it is the "Building Upgrade" page of the pedia.
     
  6. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,544
    Gender:
    Male
    Location:
    Canberra, Australia
    If I build the Catacombs of Kom el Shoqafa I am the one that looses units when I attack not the others when they attack me. I better make sure I have merged in the latest one:)
     
  7. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Code:
    ## Catacombs Start ##
    		iPlayer2 = pLoser.getOwner()
    		pPlayer2 = gc.getPlayer(iPlayer2)
    		if pPlayer2.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_CATACOMBS")) == 1:
    			pPlot2 = pLoser.plot()
    			if pPlot2.isCity() and pPlot2.getOwner() == iPlayer2:
    				obsoleteTech = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_CATACOMBS")).getObsoleteTech()
    				pTeam2 = gc.getTeam(pPlayer2.getTeam())
    				if pTeam2.isHasTech(obsoleteTech) == false or obsoleteTech == -1:
    					if pLoser.getUnitCombatType() != -1 and pLoser.getDomainType() == gc.getInfoTypeForString("DOMAIN_LAND"):
    						if CyGame().getSorenRandNum(10, "die together") < int(pWinner.getDamage()/25):
    							pWinner.setDamage(100, False)
    							CyInterface().addMessage(iPlayer2,true,20,CyTranslator().getText("TXT_MASS_BURIAL",(pWinner.getName(),pLoser.getName(),)),'',0,'',-1,-1,-1, true,true)
    							CyInterface().addMessage(pWinner.getOwner(),true,20,CyTranslator().getText("TXT_MASS_BURIAL",(pWinner.getName(),pLoser.getName(),)),'',0,'',-1,-1,-1, true,true)
    ## Catacombs End ##
    Looking at the codes, work as intended.
    1) Checks if the loser has Catacombs, not winner.
    2) Checks if the loser is the one in a city, not winner.
    3) Checks if Catacombs is still active for loser, not winner.
    4) Kills the winner.

    So what is wrong?
     
  8. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,544
    Gender:
    Male
    Location:
    Canberra, Australia
    Every time I attack a barbarian city I loose one unit but none are killed in battle. I do need to track it down better but so far it seems to start after I build that wonder.
     
  9. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    If you meant after merging into C2C, then most likely there are some errors in merging.

    I just did some tests in the Catacombs Standalone.
    Whacking a Barb City full of Mobile Sams with my Modern Armors, while I have the Catacombs did not do anything.

    However, when I removed my Catacombs and assign it to the Barb City, then this may occur.

    Only when you get this message, then the unit is killed due to Catacombs.

    And the above tests proved nothing wrong with the codes.
    Catacombs only work when the unit is killed in a city and the city and unit owner are same guy and he is the one with Catacombs
     

    Attached Files:

  10. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,544
    Gender:
    Male
    Location:
    Canberra, Australia
    The code I had in c2c turns out to be an old version.
     
  11. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Removed the following:

    Petra
    Captures UB
    Bugged beyond Repair

    Tokyo National Museum
    Builds UB
    Bugged beyond Repair

    Gobekli Tepe
    Found Random Religion
    Bugged beyond Repair

    Chauburji
    Doubles Happiness and Health of other buildings
    Bugged beyond Repair

    Meteora
    + Happiness of Monateries
    Bugged beyond Repair

    Columbus Discoveries
    Spawns Natural Wonders
    No longer serves a purpose

    Great Zimbawee
    Cities continue growing while building units with food
    Only wonder that requires CvMainInterface

    Removed Platypedia
    Removed python files from Megapack
    Added Tech Advisor file from Ultrapack for auto adjustment of tech bar

    Removed TeraPack, since the components are outdated and I cannot be bothered to update
     
  12. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,480
    Whats the bug about these?
     
  13. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    1) Building class related
    2) python function itself is spoilt
    3) founding tech issue
     
  14. Alrik2002

    Alrik2002 Warlord

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

    perhaps you remember that I´ve added several wonders to my own mod and almost everything is working fine in our pitboss game. Now I´ve tracked down an OOS to the Code of the Apadana Palace:

    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 [COLOR="Red"]pTeam[/COLOR].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
    With your help I´ve tried to make that wonder work for all the members of a team if one of them has built the Apadana Palace (the change is in red letters).

    Although the problem seems to be the same with your original code.

    The logfiles show me, that the discount works perfectly fine at the computers of all the human players. Only at the pitboss the player with the Apadana Palace doesn´t get the discount. That´s why the pitboss thinks that the owner is still working on one building, while all the others know that it´s already finished thanks to the discount. Any idea how I can fix them?

    Thank you very much for your help.
     
  15. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    No idea. I don't test mp.
    Try other methods of mp and see if it is a problem with the code or pitboss.
    Xyth has something similar in his mod I believe.
     
  16. Alrik2002

    Alrik2002 Warlord

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

    I believe there is an error in the code of The Great Mosque:
    Code:
    ## Great Mosque of Djenne Start ##
    		if bSuccess:
    			pPlayer = gc.getPlayer(pUnit.getOwner())
    			if pPlayer.getBuildingClassCount(gc.getInfoTypeForString([COLOR="Red"]"BUILDING_THE_GREAT_MOSQUE"[/COLOR])):
    				(loopCity, iter) = pPlayer.firstCity(false)
    				while(loopCity):
    					if loopCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_THE_GREAT_MOSQUE")):	
    						pNewUnit = pPlayer.initUnit(pUnit.getUnitType(), loopCity.getX(), loopCity.getY(), UnitAITypes.UNITAI_MISSIONARY, DirectionTypes.NO_DIRECTION)
    						pNewUnit.finishMoves()
    						break
    					(loopCity, iter) = pPlayer.nextCity(iter, false)
    ## Great Mosque of Djenne End ##
    I think the red part has to be:

    "BUILDINGCLASS_THE_GREAT_MOSQUE"
     
  17. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Fixed for both standalone and Gigapack
     
  18. Zlatko

    Zlatko CIW

    Joined:
    Apr 1, 2010
    Messages:
    713
    Location:
    Solar System
    Hi Platy i want to change your AI Entity as more powerful WONDER, i want to hostile Assault Mech apper
    in every city in the world except in Player's cities, if player have AI Entity in city all his cities are
    protected from catastrophe, you understand what i want ?

    Here is your code for AI Entity from CvEventManager:
    Code:
    ## AI Entity Start ##
    		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_AI_ENTITY")) == 1:
    			if CyGame().getSorenRandNum(25, "Rampage") == 0:
    				pPlayer.changeAnarchyTurns(5)
    				if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_GREAT_WALL")) == 0:
    					bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
    					(loopCity, iter) = pPlayer.firstCity(false)
    					while(loopCity):
    						for x in range(loopCity.getX() - 1, loopCity.getX() + 2):
    							for y in range(loopCity.getY() - 1, loopCity.getY() + 2):
    								pPlot = CyMap().plot(x,y)
    								if not pPlot.isWater() and not pPlot.isCity() and not pPlot.isImpassable():
    									if CyGame().getSorenRandNum(3, "Rampage") == 0:
    										for i in range(3):
    											pNewUnit = bPlayer.initUnit(gc.getInfoTypeForString("UNIT_ASSAULT_MECH"), x, y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
    						(loopCity, iter) = pPlayer.nextCity(iter, false)
    				CyInterface().addMessage(iPlayer,true,15,CyTranslator().getText("TXT_AI_RAMPAGE",()),'',0,'',-1,-1,-1, true,true)
    
    How to do that ?
     
  19. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Troublesome.

    In short:

    onEndGameTurn:
    1) Loop through all teams, if one of them has AI Entity, do step 2
    2) Loop through all players, if team has great wall or AI Entity, ignore this team
    3) Else, loop through all cities, spawn barbs.
     
  20. Zlatko

    Zlatko CIW

    Joined:
    Apr 1, 2010
    Messages:
    713
    Location:
    Solar System
    Today i had some free time and i am made this, please look:
    Code:
    ## AI Entity Start ##
    		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_AI_ENTITY")) == 1:
    			if CyGame().getSorenRandNum(2, "Rampage") == 0:
    				for iPlayerX in xrange(gc.getMAX_CIV_PLAYERS()):
    					pPlayerX = gc.getPlayer(iPlayerX)
    					if pPlayerX.isAlive() and iPlayerX != pPlayer:
    						pPlayerX.changeAnarchyTurns(5)
    						if pPlayerX.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_GREAT_WALL")) == 0:
    							bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
    							(loopCity, iter) = pPlayerX.firstCity(false)
    							while(loopCity):
    								for x in range(loopCity.getX() - 1, loopCity.getX() + 2):
    									for y in range(loopCity.getY() - 1, loopCity.getY() + 2):
    										pPlot = CyMap().plot(x,y)
    										if not pPlot.isWater() and not pPlot.isCity() and not pPlot.isImpassable():
    											if CyGame().getSorenRandNum(3, "Rampage") == 0:
    												for i in range(3):
    													pNewUnit = bPlayer.initUnit(gc.getInfoTypeForString("UNIT_ASSAULT_MECH"), x, y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
    								(loopCity, iter) = pPlayerX.nextCity(iter, false)
    				CyInterface().addMessage(iPlayer,true,15,CyTranslator().getText("TXT_AI_RAMPAGE",()),'',0,'',-1,-1,-1, true,true)
    
    This code spawn barbs near every city on the map including player / AI which have this building, i want exception for player / AI which have this building (don't spawn barbs near cities of that player / AI)
     

Share This Page