View Full Version : Pirates Cove


Kasdar
Jun 27, 2007, 03:37 PM
I was wondering which file I would need to change and where at in the file the information telling Pirate coves can't be built within 3 tiles of each other is. I would like to change the number of tiles apart they can be built.

snarko
Jun 27, 2007, 03:54 PM
FFHSpells.py, the function reqPirateCove.

Kasdar
Jun 27, 2007, 04:02 PM
FFHSpells.py, the function reqPirateCove.

Thanx Snarko what do I need to change here? to make it; 0 tiles? 5 tiles?

def reqPirateCove(caster):
if caster.getUnitClassType() != gc.getInfoTypeForString('UNITCLASS_WORKER'):
return False
if not canCast(caster):
return False
pPlayer = gc.getPlayer(caster.getOwner())
if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_LANUN'):
return False
if pPlayer.isHuman() == False:
return False
iX = caster.getX()
iY = caster.getY()
pPlot = caster.plot()
if pPlot.isWater():
return False
if pPlot.area().getNumTiles() == 1:
return False
if pPlot.getNumUnits() > 1:
return False
if pPlot.isCity():
return False
if (pPlot.isOwned() and pPlot.getOwner() != caster.getOwner()):
return False
if pPlot.getImprovementType() != -1:
return False
bValid = False
for iiX in range(iX-1, iX+2, 1):
for iiY in range(iY-1, iY+2, 1):
pPlot = CyMap().plot(iiX,iiY)
if pPlot.isWater():
bValid = True
if bValid == False:
return False
for iiX in range(iX-2, iX+3, 1):
for iiY in range(iY-2, iY+3, 1):
pPlot = CyMap().plot(iiX,iiY)
if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_PIRATE_COVE') :
return False
return True

def spellPirateCove(caster):
doCast(caster)
pPlayer = gc.getPlayer(caster.getOwner())
pPlot = caster.plot()
caster.setXY(pPlayer.getCapitalCity().getX(), pPlayer.getCapitalCity().getY())
pPlot.setBonusType(-1)
pPlot.setFeatureType(-1, -1)
pPlot.setPlotType(PlotTypes.PLOT_OCEAN, True, True)
pPlot.setTerrainType(gc.getInfoTypeForString('TERR AIN_COAST'),True,True)
pPlot.setImprovementType(gc.getInfoTypeForString(' IMPROVEMENT_PIRATE_COVE'))
caster.setHasPromotion(gc.getInfoTypeForString('PR OMOTION_GOLEM'), True)
caster.kill(True, 0)
CyMap().recalculateAreas()

snarko
Jun 27, 2007, 04:48 PM
This part

for iiX in range(iX-2, iX+3, 1):
for iiY in range(iY-2, iY+3, 1):
pPlot = CyMap().plot(iiX,iiY)
if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_PIRATE_COVE') :
return False


If you want the range to be 0 you can just comment out that part, starting each line with ##. Otherwise change iX-2, iX+3 and iY-2, iY+3 to the numbers you want. The subtraction should be one less than the addition because range start at the lowest value and end at the value below the highest.

Kasdar
Jun 27, 2007, 05:12 PM
That didn't work they still are built 3 tiles apart even after commenting out those lines..

Also tried


def reqPirateCove(caster):
if caster.getUnitClassType() != gc.getInfoTypeForString('UNITCLASS_WORKER'):
return False
if not canCast(caster):
return False
pPlayer = gc.getPlayer(caster.getOwner())
if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_LANUN'):
return False
if pPlayer.isHuman() == False:
return False
iX = caster.getX()
iY = caster.getY()
pPlot = caster.plot()
if pPlot.isWater():
return False
if pPlot.area().getNumTiles() == 1:
return False
if pPlot.getNumUnits() > 1:
return False
if pPlot.isCity():
return False
if (pPlot.isOwned() and pPlot.getOwner() != caster.getOwner()):
return False
if pPlot.getImprovementType() != -1:
return False
bValid = False
## for iiX in range(iX-1, iX+2, 1):
## for iiY in range(iY-1, iY+2, 1):
## pPlot = CyMap().plot(iiX,iiY)
## if pPlot.isWater():
## bValid = True
## if bValid == False:
## return False
## for iiX in range(iX-2, iX+3, 1):
## for iiY in range(iY-2, iY+3, 1):
## pPlot = CyMap().plot(iiX,iiY)
## if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_PIRATE_COVE') :
## return False
return True

salaminizer
Jun 27, 2007, 05:23 PM
it seems to me that you need to set bValid to true...

Kael
Jun 27, 2007, 05:23 PM
That code keeps them from being build from within 3 tiles of each other. If you comment it out they will be able to be built within 3 tiles.

If you want to increase the distance between them change the second loop from:


for iiY in range(iY-2, iY+3, 1):


to:


for iiY in range(iY-4, iY+5, 1):


The above code ups it so that coves can't be built within 5 tiles of each other.

Kasdar
Jun 27, 2007, 05:26 PM
it seems to me that you need to set bValid to true...

that didnt work either.

snarko
Jun 27, 2007, 05:27 PM
You should not comment out the first loop, that checks if there's water nearby. Commenting out the second loop will work. I just did so and then built three piratecoves next to eachother.

Kasdar
Jun 27, 2007, 06:19 PM
You should not comment out the first loop, that checks if there's water nearby. Commenting out the second loop will work. I just did so and then built three piratecoves next to eachother.

I tried that but it wouldnt let me. Do I need to start a new game or do something else?

snarko
Jun 28, 2007, 04:09 AM
No you do not need to start a new game. You can even make the python changes while playing. That's what I did. (But if you do make the changes while in the game you'll need to move the worker for the option to show up)

Jean Elcard
Jun 28, 2007, 04:34 AM
No you do not need to start a new game. You can even make the python changes while playing. That's what I did. (But if you do make the changes while in the game you'll need to move the worker for the option to show up)

You can do that? Great! Never thought of trying to change something while running the game. Does it work with XML changes as well? Probably not, because it's all read in when starting the game, but it can't hurt to ask.

snarko
Jun 28, 2007, 06:46 AM
You can do that? Great! Never thought of trying to change something while running the game. Does it work with XML changes as well? Probably not, because it's all read in when starting the game, but it can't hurt to ask.

It does not work for XML or SDK changes. Only python. But it will break PLE causing all sorts of problems. Loading a save or going back to the main menu will fix it.

Kasdar
Jun 28, 2007, 08:21 AM
Thanx everyone I got it working.