My way to simulate the city frontiers

LordViriato

Chieftain
Joined
Apr 26, 2011
Messages
9
Hi everybody,

I have been thinking the way to simulate the city frontier and I think I have found one (I like this).

You have to follow the next steps:

1. You have to save the file AreaBorder.dds attached here into "Caveman2Cosmos\Assets\art\Terrain\PlotTextures". The difference with the original file is that I delete the hatched area (When you select the city in the game you will see the border only. You won't see the hatched area anymore).

2. Add the next code into the file RoMEventManager.py:

Code:
	def onBeginPlayerTurn(self, argsList):
		#Start City frontiers
		color = 1
		layer = 8
		for layerparaborrar in range(8, 500):
			CyEngine().clearAreaBorderPlots (layerparaborrar)
		layer = 8
		for numero in range(0,gc.getMAX_CIV_PLAYERS()) :
			pPlayer2 = gc.getPlayer(numero)
			for iCity in range(pPlayer2.getNumCities()):
				pCity2 = pPlayer2.getCity(iCity)
				#CvUtil.pyPrint('Display Ciudad: %s' %(pCity2.getName()))
				pPlot = CyMap( ).plot( pCity2.getX( ), pCity2.getY( ) )
				eTeam = pPlayer2.getTeam()
				layer = layer + 1
				if pCity2.getName() != "":
					for i in range(gc.getNUM_CITY_PLOTS()):
						#self.dirty = False
						pPlot2 = pCity2.getCityIndexPlot(i)
						#if pPlot2.isActiveVisible(True) and (pPlot2.isWater() == False or pPlot2.isLake() == True) and (pPlot2.getWorkingCity().getName() == pPlot.getWorkingCity().getName() or pPlot2.getWorkingCity().getName() == None):
						if (pPlot2.isWater() == False or pPlot2.isLake() == True) and (pPlot2.getWorkingCity().getName() == pPlot.getWorkingCity().getName() or pPlot2.getWorkingCity().getName() == ""):
							if pPlot2.getOwner() == pCity2.getOwner():
								#CyEngine().fillAreaBorderPlot(pPlot2.getX( ), pPlot2.getY( ), NiColorA(float(0.00), float(1.00), float(0.00), 0.30), layer)
								CyEngine().fillAreaBorderPlotAlt(pPlot2.getX( ), pPlot2.getY( ), layer, "COLOR_BLACK", 0.50)
		#End City frontiers

provincias0000.JPG

View attachment AreaBorder.7z

Bye!!!
 
Great. Thanks for this :)

We need someone with your python skills to implement specialist count mod comp by platyping to c2c.
Plese respond if you want to improve c2c i will give you needed info.
 
for iCity in range(pPlayer2.getNumCities()):

Failed.
Bugged when cities are captured.
 
I sorry, but I afraid I haven't much free time and I think I have only basic knowledge in phyton. For the moment, I can't help you, although you can feel free to use and improve this code.

I think, the code can be used into others "def", for example: into "def onCityBuilt(self, argsList)". So that when you build one city, you can replay this effect.

I attached "RoMEventManager.py" file with the code.

For the moment, it not failed me, but I'm going to investigate more...

When you capture another city? or When another civ captures our cities?

Thank you :)
 

Attachments

  • RoMEventManager.7z
    4.4 KB · Views: 60
Bleh, explained this more than 5 times :D

There are 3 main methods to let something affect all cities of a player.

A) The outdated and inaccurate method above
When you have X cities and 1 is captured, you now have X -1 cities.
However, city IDs remain so there is a gap in between, unless it is the last one.
Therefore your loop will miss out the last city.

B) The double counting inefficient pyHelper method
Most commonly used in most mods.
Why, because most people just copied from others since it is working.

C) Use the while loop directly within the pyHelper.
Why loop twice when you can just loop once...

Anyway, there are lots of improvements to the code above, this is just one of them.
 
I can be counted as a complete nitwit in terms of understanding the Coding behind Civ 4 but one thing i've picked up from a lot of you guys pushing and defining the limits of Civ 4

Anything Vanilla can be done 1000% more efficient ;) :p
 
Top Bottom