[BtS] JFortZoC: Forts Extending Borders

Update on the port to SDK. It is taking a little longer then I thought. The way I was origionally doing it a Tile had a bool, yes/no, on wheather a tile has a culture border, and that made it kinda hard to remove the border when a Tile could have multiple forts around it.

But I am going to change it to a counter on the plot. So if the counter is above 0 it will get some civ's border, if it's 0 or less it won't.

I'm going to take the night off and accually play some Civ instead of just modding it. :p

I should have the mod out by this weekend. :)
 
i don't know how to edit python, i would just like a fort with one square of culture under it so it can be used fully, if someone would tell me how to do this it would be appreciated.
 
i don't know how to edit python, i would just like a fort with one square of culture under it so it can be used fully, if someone would tell me how to do this it would be appreciated.

I didn't test that, but I suppose it's here :

Open the file "Assets\Python\JFortZoCUtils\CvJFortZoCUtils.py".

Search for "def updatePlotCulture" (line 247 for me, but I changed things in this Mod, so I'm not sure it'll be 247 for you)

In that function, you'll find that :
Code:
(.....)
                iXStart = iX - iRange
                iXStop = iX + iRange + 1
                iYStart = iY - iRange
                iYStop = iY + iRange + 1

		# Create culture around unit
		for iXLoop in range(iXStart, iXStop):
(.....)

I think that iXStart, iXStop, iYStart and iYStop define how many squares are affected by the Culture update.

So, if you write the function "def updatePlotCulture" like this, I suppose, it could run like you want :
Code:
	def updatePlotCulture(self, iPlayer, iUnitID, iX, iY):
                #alert.alert(0, "initFortCulture")
                pPlayer = gc.getPlayer(iPlayer)
                pUnit = pPlayer.getUnit(iUnitID)
                iLevel = pUnit.getLevel()
                iRange = 1

                #Here, I suppress the Loop that updates several squares.

		iActiveX = CyMap().getGridWidth()
		iActiveY = CyMap().getGridHeight()
		pPlotLoop = CyMap().plot(iActiveX, iActiveY)
		if (iActiveX == iX) and (iActiveY == iY):
                        iCulture = iLevel * 2
		else:
                        iCulture = iLevel
		pPlotLoop.changeCulture(iPlayer, int(iCulture), True)

To be verified by a Python-Master !!!
 
Hi Jeckel, or any other Python-Master..., :king:

I tried, when a player kills the commander of an other player, not to destroy the Fort, but to give it to the winner of combat.

I tried several things in the file "Assets\Python\JFortZoCUtils\CvJFortZoCEventManager.py", at the end of the function "onUnitKilled" :hammer2: :
(Edit: below, when I write 'initUnit", it means : create a new unit Commander for iAttacker)
  • I just added a "initUnit" (and suppress the CITY_RUINS improvement) => CRASH !
  • I added, after the CITY_RUINS improvement, a new FORT improvement, and then added a "initUnit" => CRASH !
  • I tried to call your function that updates the culture at end turn, and then added a "initUnit" => CRASH !
  • I suppressed the CITY_RUINS improvement, added a pPlot.setOwner(-1), and then added a "initUnit" => CRASH !
  • Anything without adding a "initUnit" => NO CRASH !

I suppose the reason is that the updating of Culture is done at the end of turn and not when unit is killed....

But, while I'm writing this (I can't test it right now, I'm at work) I think that I didn't test adding, at the end of function, something like that :
Code:
iLoser = pUnit.getOwner()
iLoserCulture = pPlot.getCulture(iLoser)
iSupprCulture = 0 - iLoserCulture
pPlot.changeCulture(iLoser, iSupprCulture, 1)
[I]#Perhaps I could add too : pPlot.changeCulture(iAttacker, iLoserCulture, 1)[/I]
newUnit = create a new Commander for iAttacker (can't remember exact code, right now, I'll find it at home)

Is it the solution ? Is there a solution ?... :confused:
 
I didn't test that, but I suppose it's here :

Open the file "Assets\Python\JFortZoCUtils\CvJFortZoCUtils.py".

Search for "def updatePlotCulture" (line 247 for me, but I changed things in this Mod, so I'm not sure it'll be 247 for you)

In that function, you'll find that :
Code:
(.....)
                iXStart = iX - iRange
                iXStop = iX + iRange + 1
                iYStart = iY - iRange
                iYStop = iY + iRange + 1

		# Create culture around unit
		for iXLoop in range(iXStart, iXStop):
(.....)

I think that iXStart, iXStop, iYStart and iYStop define how many squares are affected by the Culture update.

So, if you write the function "def updatePlotCulture" like this, I suppose, it could run like you want :
Code:
	def updatePlotCulture(self, iPlayer, iUnitID, iX, iY):
                #alert.alert(0, "initFortCulture")
                pPlayer = gc.getPlayer(iPlayer)
                pUnit = pPlayer.getUnit(iUnitID)
                iLevel = pUnit.getLevel()
                iRange = 1

                #Here, I suppress the Loop that updates several squares.

		iActiveX = CyMap().getGridWidth()
		iActiveY = CyMap().getGridHeight()
		pPlotLoop = CyMap().plot(iActiveX, iActiveY)
		if (iActiveX == iX) and (iActiveY == iY):
                        iCulture = iLevel * 2
		else:
                        iCulture = iLevel
		pPlotLoop.changeCulture(iPlayer, int(iCulture), True)

To be verified by a Python-Master !!!


In updatePlotCulture and updateCultureBorders just set iRange = 0 and forts will only have culture on its tile and none of the surronding. :)

EDIT: With iRange set to zero it doesn't acually run any loop, it just does the code for that single plot. So no need to worry about removing the loop.
 
Hi Jeckel, or any other Python-Master..., :king:

I tried, when a player kills the commander of an other player, not to destroy the Fort, but to give it to the winner of combat.

I tried several things in the file "Assets\Python\JFortZoCUtils\CvJFortZoCEventManager.py", at the end of the function "onUnitKilled" :hammer2: :
(Edit: below, when I write 'initUnit", it means : create a new unit Commander for iAttacker)
  • I just added a "initUnit" (and suppress the CITY_RUINS improvement) => CRASH !
  • I added, after the CITY_RUINS improvement, a new FORT improvement, and then added a "initUnit" => CRASH !
  • I tried to call your function that updates the culture at end turn, and then added a "initUnit" => CRASH !
  • I suppressed the CITY_RUINS improvement, added a pPlot.setOwner(-1), and then added a "initUnit" => CRASH !
  • Anything without adding a "initUnit" => NO CRASH !

I suppose the reason is that the updating of Culture is done at the end of turn and not when unit is killed....

But, while I'm writing this (I can't test it right now, I'm at work) I think that I didn't test adding, at the end of function, something like that :
Code:
iLoser = pUnit.getOwner()
iLoserCulture = pPlot.getCulture(iLoser)
iSupprCulture = 0 - iLoserCulture
pPlot.changeCulture(iLoser, iSupprCulture, 1)
[I]#Perhaps I could add too : pPlot.changeCulture(iAttacker, iLoserCulture, 1)[/I]
newUnit = create a new Commander for iAttacker (can't remember exact code, right now, I'll find it at home)

Is it the solution ? Is there a solution ?... :confused:

They added an argument to pPlayer.initUnit() at the end.
CyUnit initUnit (UnitType iIndex, int plotX, int plotY, UnitAIType iIndex, DirectionType iIndex)
CyUnit* initUnit(UnitTypes iIndex, plotX, plotY, UnitAITypes iIndex) - place Unit at X,Y NOTE: Always use UnitAITypes.NO_UNITAI and DirectionTypes.NO_DIRECTION

Do you have Python error messages enabled? If not, then errors can just casue a crash.

But if you want to make forts captureable then I think I have an easyer answer. In the UnitInfos.xml find the commander unit entry and change its <Capture>NONE to <Capture>UNITCLASS_COMMANDER.

Then in the CvJFortZoCEventManager.py file, in the onUnitKilled method, change from this:
Code:
	def onUnitKilled(self, argsList):
		'Unit Killed'
		pUnit, iAttacker = argsList

                # Just for fun destroy the fort when the Commander dies and
                # put city ruins in its place
                # XML Change: Forts no longer able to be pillaged
                # ToDo: Make a Fort Ruins improvement so we can do things with it
		iUnitCommander = gc.getInfoTypeForString("UNIT_COMMANDER")
		if (pUnit.getUnitType() == iUnitCommander):
                        forts.removeFortData(iX, iY)
                        pPlot = pUnit.plot()
                        iImprovementFort = gc.getInfoTypeForString("IMPROVEMENT_FORT")
                        if (pPlot.getImprovementType() == iImprovementFort):
                                pPlot.setImprovementType(gc.getInfoTypeForString("IMPROVEMENT_CITY_RUINS"))
to this:
Code:
	def onUnitKilled(self, argsList):
		'Unit Killed'
		pUnit, iAttacker = argsList

                # Just for fun destroy the fort when the Commander dies and
                # put city ruins in its place
                # XML Change: Forts no longer able to be pillaged
                # ToDo: Make a Fort Ruins improvement so we can do things with it
		iUnitCommander = gc.getInfoTypeForString("UNIT_COMMANDER")
		if (pUnit.getUnitType() == iUnitCommander):
                        [B]forts.removeFortData(iX, iY)[/B]
Note the bolded line must be done or strange things may happen such as the Culture Border may not change ownership.

Hope this helps. :)
 
Alright, for all those interested, I have an SDK version of this mod that extends borders around improvements. I also got the code up to handle the removal of improvements. :band:

I am going to add in some GlobalDefines and clean up a bit of the code, gotta write up a readme, but should have it released under a new name. May get it out tonight, but might be this weekend if I run out of time today. :)
 
I have finished my SDK mod that allows Improvements to spread Culture Points and Culture Borders.

Here is the Mod's Thread.
 
Mind uploading this again (due to the hacking 'incident')?
 
Well, bad news is I lost all my old modding files. However, there is a little hope. A few of my newer mods might still be on my budy's computer since we were using them in our MP games. I will look into it and see if I can find a copy of the zip file.
 
Thanks a ton!
 
Top Bottom