canals and man-made islands

ocedius

C++ induced baldness
Joined
Jun 27, 2003
Messages
617
Location
TX and proud of it!
I am trying to add the option to create canals and man-made islands via modded sevo-mod/green mode combo. So far, the land units work on the improvement and then, nothing. The sea units work on it and disappear.


CIV4ImprovementInfos.xml

<ImprovementInfo>
<Type>IMPROVEMENT_WATERLAND1</Type>
<Description>TXT_KEY_IMPROVEMENT_WATERLAND1</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_WATERLAND1_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_WATERLAND1</ArtDefineTag>
<YieldChanges>
<iYieldChange>-2</iYieldChange>
<iYieldChange>-2</iYieldChange>
<iYieldChange>-2</iYieldChange>
</YieldChanges>
<bHillsMakesValid>0</bHillsMakesValid>
<bFreshWaterMakesValid>0</bFreshWaterMakesValid>
<bRiverSideMakesValid>0</bRiverSideMakesValid>
<bNoFreshWater>0</bNoFreshWater>
<bRequiresFlatlands>0</bRequiresFlatlands>
<bRequiresRiverSide>0</bRequiresRiverSide>
<bRequiresIrrigation>0</bRequiresIrrigation>
<bCarriesIrrigation>0</bCarriesIrrigation>
<bRequiresFeature>0</bRequiresFeature>
<bWater>1</bWater>
<bGoody>0</bGoody>
<bPermanent>0</bPermanent>
<bUseLSystem>0</bUseLSystem>
<iTilesPerGoody>0</iTilesPerGoody>
<iGoodyRange>0</iGoodyRange>
<iUpgradeTime>0</iUpgradeTime>
<iAirBombDefense>-1</iAirBombDefense>
<iDefenseModifier>0</iDefenseModifier>
<iPillageGold>0</iPillageGold>
<TerrainMakesValids>
<TerrainMakesValid>
<TerrainType>TERRAIN_COAST</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_OCEAN</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
</TerrainMakesValids>
<FeatureMakesValids/>
<ImprovementPillage/>
<ImprovementUpgrade>IMPROVEMENT_WATERLAND2</ImprovementUpgrade>
<TechYieldChanges/>
<RouteYieldChanges/>
<bGraphicalOnly>0</bGraphicalOnly>
</ImprovementInfo>
<ImprovementInfo>
<Type>IMPROVEMENT_WATERLAND2</Type>
<Description>TXT_KEY_IMPROVEMENT_WATERLAND2</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_WATERLAND2_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_WATERLAND2</ArtDefineTag>
<YieldChanges>
<iYieldChange>-2</iYieldChange>
<iYieldChange>-2</iYieldChange>
<iYieldChange>-2</iYieldChange>
</YieldChanges>
<bHillsMakesValid>0</bHillsMakesValid>
<bFreshWaterMakesValid>0</bFreshWaterMakesValid>
<bRiverSideMakesValid>0</bRiverSideMakesValid>
<bNoFreshWater>0</bNoFreshWater>
<bRequiresFlatlands>0</bRequiresFlatlands>
<bRequiresRiverSide>0</bRequiresRiverSide>
<bRequiresIrrigation>0</bRequiresIrrigation>
<bCarriesIrrigation>0</bCarriesIrrigation>
<bRequiresFeature>0</bRequiresFeature>
<bWater>0</bWater>
<bGoody>0</bGoody>
<bPermanent>0</bPermanent>
<bUseLSystem>0</bUseLSystem>
<iTilesPerGoody>0</iTilesPerGoody>
<iGoodyRange>0</iGoodyRange>
<iUpgradeTime>0</iUpgradeTime>
<iAirBombDefense>-1</iAirBombDefense>
<iDefenseModifier>0</iDefenseModifier>
<iPillageGold>0</iPillageGold>
<TerrainMakesValids>
<TerrainMakesValid>
<TerrainType>TERRAIN_SNOW</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_DESERT</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_TUNDRA</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_PLAINS</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_GRASS</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
</TerrainMakesValids>
<FeatureMakesValids/>
<ImprovementPillage/>
<ImprovementUpgrade>IMPROVEMENT_WATERLAND1</ImprovementUpgrade>
<TechYieldChanges/>
<RouteYieldChanges/>
<bGraphicalOnly>0</bGraphicalOnly>
</ImprovementInfo>

Modded python script:

if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_WATERLAND1')):
# if pPlot.getTerrainType() == 5:
pPlot.setImprovementType(-1)
pPlot.setTerrainType(5, 1, 1)
elif(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_WATERLAND2')):
# if not pPlot.getTerrainType() == 5:
pPlot.setImprovementType(-1)
nutile = CyGame().getSorenRandNum(4)
pPlot.setTerrainType(nutile, 1, 1)
# new tile terrain is randomly chosen
for x in [-1,0,1]:
for y in [-1,0,1]:
if CyMap().plot(iX +x, iY +y).getTerrainType() == 6: CyMap().plot(iX +x, iY +y).setTerrainType(5, 1, 1)

if (iImprovement==iWaterland1 or iImprovement==iWaterland2):
bCoastNear = 0
for x in [-1,0,1]:
for y in [-1,0,1]:
iTerrain = CyMap().plot(iCityX +x, iCityY +y).getTerrainType()
if (iTerrain == 5 or iTerrain == 6):
bCoastNear = 1
#reset or remove harbor and drydock if no coast near
if bCoastNear == 1:
if pCity.isHasRealBuilding(14):
pCity.setHasRealBuilding(14, false)
pCity.setHasRealBuilding(14, true)
else:
pCity.setHasRealBuilding(14, true)
pCity.setHasRealBuilding(14, false)
else:
pCity.setHasRealBuilding(13, false)
pCity.setHasRealBuilding(14, false)

Could some one tell me what I am doing wrong?
 
Code:
		if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_NEW_WATER')):
                                # initializes variable for all units on the plot being terraformed
				numberofunits = pPlot.getNumUnits()
				while(numberofunits > 0):
					pPlot.getUnit(0).jumpToNearestValidPlot()
					numberofunits = pPlot.getNumUnits()
                                # all units jump to nearest available plot , i.e. from the land-soon-to-be-water plot to a valid land plot
				pPlot.setPlotType(PlotTypes.PLOT_OCEAN, true, true)
                                # plot is turned to ocean

				pPlot.setTerrainType(gc.getInfoTypeForString("TERRAIN_COAST"), 2)
				pPlot.setImprovementType(-1)
                                # plot is turned to coast and improvements set to -1

				CyInterface().addImmediateMessage("A new area was inundated by your unit!","")
                                # message still won't appear

		if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_NEW_LAND')):
				numberofunits = pPlot.getNumUnits()
				while(numberofunits > 0):
					pPlot.getUnit(0).jumpToNearestValidPlot()
					numberofunits = pPlot.getNumUnits()
				pPlot.setPlotType(PlotTypes.PLOT_LAND, true, true)
				if(pPlot.getTerrainType()==gc.getInfoTypeForString("TERRAIN_DESERT") and pPlot.isRiver()):
					pPlot.setFeatureType(gc.getInfoTypeForString("FEATURE_FLOOD_PLAINS"), 0)
					pPlot.setImprovementType(-1)
					CyInterface().addImmediateMessage("A new flood-plain has been created!","")

This is the canibalized code I am using now and it seems to work ok. Still, I can;t get the new terrain to auto refresh until after I reload the game, so all my cannals/lakes appear kinda oceanic and without all the moving wave effects.

Still needs a lotta work, and the only good thing about this is that I can create canals and islands independent of the city's radius of influence. still on occassion, units disappear. If I try to terraform two adjacent coast plots to land, half the time, both work boats vanish.
 
Top Bottom