mcwill123
Pretender to the Throne
Slightly off topic, but could you recommend a good python book?
Slightly off topic, but could you recommend a good python book?
if gc.getPlayer(iPlayer).isHuman():
Message = "TXT_KEY_QUOTE_%s" %(pUnit.getNameNoDesc(),)
cf.addPopup(CyTranslator().getText(str(Message),()), 'Art/GreatPeople/Simple/'+str(gc.getUnitInfo(pUnit.getUnitType()).getType())+'/'+str(pUnit.getNameNoDesc())+'.dds')
Slightly off topic, but could you recommend a good python book?
Honestly, I think it's best to remain in the DLL. Less python makes it easier for modders to add new events.
But would it? I'm not a python expert, but I do some coding in my day job. I know each event has a unique number called by the python code. If we were to name the event image the same as the number, like 144.dds, then one section of code in python could call up the matching image for that event without having to state it for each event in the XML. It would be something like Art/EventImages/ (python function getting event number that the code already called previously).dds. One line of code, this way covering all events in one shot, added to the python section that already calls up the event and puts it into the event window. All a modder would have to do is find his event number and name his image the same.
Is this doable, or would it still require the DLL to even allow images to appear in the event window in the first place?
Is this doable, or would it still require the DLL to even allow images to appear in the event window in the first place?
I am coding the recruit mercenary spell to work a little bit differently. I have made a new buildingclass that allows the spell instead of the guild of nine. But i want to make it so it is only castable once every turn in each city with that building. How can i do that?
def spellRecruit(caster):
pPlot = caster.plot()
pCity = pPlot.getPlotCity()
[COLOR="Red"]pCity.setScriptData("Mercenaries")[/COLOR]
def canRecruit(caster):
pPlot = caster.plot()
pCity = pPlot.getPlotCity()
if pCity.getScriptData() != "Mercenaries":
return true
return false
if pCity.getScriptData() == "Mercenaries":
pCity.setScriptData("")
if iBuildingType == gc.getInfoTypeForString('BUILDING_GAMBLING_HOUSE'):
CyInterface().addImmediateMessage('Gambling house built!', "AS2D_NEW_ERA")
iNewPlayer = cf.getOpenPlayer()
iTeam = pPlayer.getTeam()
pPlot2 = cf.findClearPlot(-1, pCity.plot())
if (iNewPlayer != -1 and pPlot2 != -1):
for i in range(pPlot.getNumUnits(), -1, -1):
pUnit = pPlot.getUnit(i)
pUnit.setXY(pPlot2.getX(), pPlot2.getY(), true, true, true)
#End mercurian gate code. ENTER THE BARB CIV CODE!
CyInterface().addImmediateMessage('Starting new civ code...', "AS2D_NEW_ERA")
newLeaderIdx=1
newCivIdx=1
iDemon = CvUtil.findInfoTypeNum(gc.getCivilizationInfo,gc.getNumCivilizationInfos(),'CIVILIZATION_DEMON')
iAnimal = CvUtil.findInfoTypeNum(gc.getCivilizationInfo,gc.getNumCivilizationInfos(),'CIVILIZATION_ANIMAL')
iOrc = CvUtil.findInfoTypeNum(gc.getCivilizationInfo,gc.getNumCivilizationInfos(),'CIVILIZATION_ORC')
availableCivs = list()
taken = True
for civType in range(0,gc.getNumCivilizationInfos()) :
if( not ((civType == iAnimal) or (civType == iOrc) or (civType == iDemon))):
taken = False
CyInterface().addImmediateMessage('The program understands tautologies, yay.', "AS2D_NEW_ERA")
for i in range(0,gc.getMAX_CIV_PLAYERS()) :
if( civType == gc.getPlayer(i).getCivilizationType() ) :
if( gc.getPlayer(i).isAlive() or gc.getPlayer(i).isFoundedFirstCity() or gc.getPlayer(i).getCitiesLost() > 0 ) :
taken = True
break
if( not taken ) :
availableCivs.append(civType)
if( len(availableCivs) < 1 ) :
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" BC - ERROR: Unexpected lack of unused civ types")
newCivIdx = availableCivs[game.getSorenRandNum(len(availableCivs),'New civ: pick unused civ type')]
leaderList = list()
for leaderType in range(0,gc.getNumLeaderHeadInfos()) :
if( gc.getCivilizationInfo(newCivIdx).isLeaders(leaderType) ) :
leaderList.append(leaderType)
if( len(leaderList) < 1 ) :
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" BC - ERROR: Unexpected lack of possible leaders")
newLeaderIdx = leaderList[game.getSorenRandNum(len(leaderList),'New Civ: pick leader')]
CyInterface().addImmediateMessage('End Barb Civ Code', "AS2D_NEW_ERA")
CyGame().addPlayerAdvanced(iNewPlayer, iTeam, newLeaderIdx, newCivIdx)
gc.getPlayer(iNewPlayer).initUnit(gc.getInfoTypeForString('UNIT_ARCHER'), pPlot.getX(), pPlot.getY(), UnitAITypes.UNITAI_CITY_DEFENSE, DirectionTypes.DIRECTION_NORTH)
gc.getPlayer(iNewPlayer).initUnit(gc.getInfoTypeForString('UNIT_SETTLER'), pPlot.getX(), pPlot.getY(), UnitAITypes.UNITAI_SETTLE, DirectionTypes.DIRECTION_NORTH)
gc.getPlayer(iNewPlayer).initUnit(gc.getInfoTypeForString('UNIT_ARCHER'), pPlot.getX(), pPlot.getY(), UnitAITypes.UNITAI_EXPLORE, DirectionTypes.DIRECTION_NORTH)
gc.getPlayer(iNewPlayer).initUnit(gc.getInfoTypeForString('UNIT_ARCHER'), pPlot.getX(), pPlot.getY(), UnitAITypes.UNITAI_EXPLORE, DirectionTypes.DIRECTION_NORTH)
gc.getPlayer(iNewPlayer).initUnit(gc.getInfoTypeForString('UNIT_ARCHER'), pPlot.getX(), pPlot.getY(), UnitAITypes.UNITAI_CITY_DEFENSE, DirectionTypes.DIRECTION_NORTH)
pNewPlayer = gc.getPlayer(iNewPlayer)
pNewPlayer.acquireCity(pCity, False, False)
pCity = pPlot.getPlotCity()
pCity.changeCulture(iNewPlayer, 100, True)
[/SPOILER]
1.) I think the change is permanent. See CvCity::applyEvent
2.) you need to modify
<BuildingClass>NONE</BuildingClass>
<iBuildingChange>0</iBuildingChange>
set Buildingclass to the one from aquae sucellus and leave change to 0 (this will work only in FFH, not in BTS)