View Full Version : I need some python...


The Navy Seal
Jul 13, 2007, 02:11 PM
I need some python read here.

Zebra 9
Jul 13, 2007, 02:16 PM
I'm on it.

Zebra 9
Jul 16, 2007, 11:49 AM
Put this code in the onBeginGameTurn event (CvEventManager.py): for i in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
if pPlot.getTeam() >= 0 and pPlot.getBonusType(-1) < 0:
impType = pPlot.getImprovementType()
if impType is gc.getInfoTypeForString("IMPROVEMENT_FARM"):
iBonus = gc.getInfoTypeForString("BONUS_CORN")
if gc.getTeam(pPlot.getTeam()).isHasTech(gc.getBonusI nfo(iBonus).getTechReveal()):
if CyGame().getSorenRandNum(1000, "Placing Bonus") == 0:
pPlot.setBonusType(iBonus)
pCity = CyMap().findCity(pPlot.getX(), pPlot.getY(), pPlot.getOwner(), pPlot.getTeam(), False, False, -1, -1, CyCity())
CyInterface().addMessage(pPlot.getOwner(), False, gc.getDefineINT("EVENT_MESSAGE_TIME"), 'Corn has been discovered near %s' %(pCity.getName()), "AS2D_DISCOVERBONUS", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, gc.getBonusInfo(iBonus).getButton(), gc.getInfoTypeForString("COLOR_WHITE"), pPlot.getX(), pPlot.getY(), True, True)Duplicate the italic code to add other improvements that give resources. Any bold text can be changed to any value you want. The bold 1000 is the chance that the resources is placed, if set to 1000 there is a 1 in a 1000 chance of it being placed (it happens:thumbsup:). Now in the message (I have it underlined) you will notice a %s this tells civ to display the name of the nearest city (only because I have told it that that %s means that, so don't start putting %s everywhere expecting the name of the nearest city).

Wow, my 800th post!!!!!! :party:

The Navy Seal
Jul 16, 2007, 11:56 AM
Thanks. :goodjob:

The Navy Seal
Jul 17, 2007, 09:33 AM
? How do I make it so it can do it for multipile resources?

Zebra 9
Jul 17, 2007, 10:02 AM
Try this: for i in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
if pPlot.getTeam() >= 0 and pPlot.getBonusType(-1) < 0:
impType = pPlot.getImprovementType()
if impType is gc.getInfoTypeForString("IMPROVEMENT_FARM"):
iBonus = gc.getInfoTypeForString("BONUS_CORN")
if gc.getTeam(pPlot.getTeam()).isHasTech(gc.getBonusI nfo(iBonus).getTechReveal()):
if CyGame().getSorenRandNum(1000, "Placing Bonus") == 0 and gc.getPlayer(pPlot.getOwner()).getNumAvailableBonu ses(gc.getInfoTypeForString("BONUS_CORN")) > 0:
pPlot.setBonusType(iBonus)
pCity = CyMap().findCity(pPlot.getX(), pPlot.getY(), pPlot.getOwner(), pPlot.getTeam(), False, False, -1, -1, CyCity())
CyInterface().addMessage(pPlot.getOwner(), False, gc.getDefineINT("EVENT_MESSAGE_TIME"), 'Corn has been discovered near %s' %(pCity.getName()), "AS2D_DISCOVERBONUS", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, gc.getBonusInfo(iBonus).getButton(), gc.getInfoTypeForString("COLOR_WHITE"), pPlot.getX(), pPlot.getY(), True, True)

The Navy Seal
Jul 17, 2007, 10:14 AM
Thanks I hope.:lol: