• Civilization 7 has been announced. For more info please check the forum here .

two HROCHland requests

hrochland

Prince
Joined
Apr 9, 2006
Messages
2,414
Location
Czech Kingdom
1/
:help: :please: I have a big request to someone from pythonist. Can Someone
PLEASE
make update demolition man mod for [BtS]? If someone will be make it, will be sufficient these functions:
change land square to water (as in Green mod)
and
raze city
(maybe new function raze building in city, if is it possible)
:help: :please:

2/ Can I someways make settings to my new model angle by concrete side always to the coast?
 
For this I think you just have to assign the building(?) to LSYSTEM_COAST in the artdefines.

Thank you very much, Ploeperpengel.
I never experimented with coastal structures so I didn't know it. Thanks.

If you know to someone, who would help me with my question (request) number one [BtS], write me about, please. Python is for me Terra Incognita :(
Thanks, HROCHland
 
Let me know if it doesn't work. Someone in the FFH forum made the Demolition Mod working with FFH but I don't know if it works with normal BTS too:
http://forums.civfanatics.com/showthread.php?t=248311

Thank you very much, Ploeperpengel. Demolition Mod is very usefull and I will try copy part of code from your forum to the my mod if will it make in clear BtS.

Primarily but I keep in mind Demolition Man from vanila GreenMod by Master Lexx. It is unit I have eminent interest. Master Lexx had code in python for this unit, what allow change land to water and add function for work boat change water to land.
I lack for this function in my BtS mod.
If have someone this function in mod, send me, please, code for it.
Thanks
HROCHland
 
Once more thanks, Ploeperpengel. LSYSTEM_COAST settings works fine.
Thanks.

Have somebody help for me with DemolitionMan for BtS, please?
 
I thought I'd try to pull demo man out of green mod. At first I could only get terraforming to work. I then tried different method to for city razing, and managed to get it work also. But when I put the two together the terraforming no longer works. They only work seperately. :confused:

This is the terraforming code in EventManager:
Code:
	def onImprovementBuilt(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList

		pPlot = CyMap().plot(iX,iY)
		#GreenMod: get city for terraform checks
		if (iImprovement==iWaterland1 or iImprovement==iWaterland2):
			bCityCheck = 0
			for x in [-1,0,1]:
				for y in [-1,0,1]:
					if CyMap().plot(iX +x, iY +y).isCity() == 1:
						iCityX = iX +x
						iCityY = iY +y
						pCity = CyMap().plot(iX +x, iY +y).getPlotCity()
						bCityCheck = 1
		
		#GreenMod: water and land switching, PART1
		if iImprovement==iWaterland1:
			#if built on water (coast), for later upgrade to land
			if pPlot.getTerrainType() == 5:
				#not city near, so delete it
				if not bCityCheck == 1:
					pPlot.setImprovementType(-1)		
			else:
			#if on land and has just been upgraded to, make to water
				pPlot.setImprovementType(-1)
				pPlot.setTerrainType(5, 1, 1)

		#GreenMod: now the other direction, terraform, PART2
		if iImprovement==iWaterland2:
			#if built on land (any), for later upgrade to water
			if not pPlot.getTerrainType() == 5:
				#not city near, so delete it
				if not bCityCheck == 1:
					pPlot.setImprovementType(-1)
			else:
			#if on water and has just been upgraded to, make to land
				pPlot.setImprovementType(-1)
				#city terrain will be terrain of new land
				iNewTerrain = 2
				iNewTerrain = CyMap().plot(iCityX, iCityY).getTerrainType()
				pPlot.setTerrainType(iNewTerrain, 1, 1)				
				#ocean next to new land? becomes coast now
				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)

		#GreenMod: recalculate city graphics after terraform, PART3
		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)
This is the raze city code part 1 and 2 in MainInterface:
Code:
					###### Unit Buttons ######
					pUnit = g_pSelectedUnit
					iUnitType = pUnit.getUnitType()
					pUnitOwner = gc.getPlayer( pUnit.getOwner( ))
					
					if pUnitOwner.isTurnActive( ):
	
						# Demolition Troop
						if iUnitType == CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), "UNIT_DEMOLITIONTROOP") and gc.getMap().plot( g_pSelectedUnit.getX(), g_pSelectedUnit.getY() ).isCity():
							pCity = gc.getMap().plot( g_pSelectedUnit.getX(), g_pSelectedUnit.getY() ).getPlotCity( )
							pPlayer = gc.getPlayer( pCity.getOwner( ) )
							if pCity.getOwner( ) == pUnit.getOwner( ):
								if (not pCity.isCapital()) and (not pCity.isDisorder()):
									iPop = pCity.getPopulation()
									iGold =  pPlayer.getGold()
									if iGold >= iPop * 50:

										
										screen.appendMultiListButton( "BottomButtonContainer", ArtFileMgr.getInterfaceArtInfo("INTERFACE_DEMOLITION").getPath(), 0, WidgetTypes.WIDGET_GENERAL, 665, 665, False )
										screen.show( "BottomButtonContainer" )
										iCount = iCount + 1
Code:
	# Will handle the input for this screen...
	def handleInput (self, inputClass):
		# PROTO
		
		pGodsOfOld=CvEventInterface.getEventManager()
		
		
		# Razes city
		if (inputClass.getNotifyCode() == 11 and inputClass.getData1() == 665 and inputClass.getData2() == 665):
			pPlot = CyMap( ).plot( g_pSelectedUnit.getX( ), g_pSelectedUnit.getY( ) )
			
			iMessageID = pGodsOfOld.m_iNetMessage_DemolitionTroop
			iPlotX = pPlot.getX()
			iPlotY = pPlot.getY()
			iOwner = g_pSelectedUnit.getOwner()
			iUnitID = g_pSelectedUnit.getID()
			
			CyMessageControl( ).sendModNetMessage( iMessageID, iPlotX, iPlotY, iOwner, iUnitID )
		return 0
This is the code for city razing part 3 and 4 in EventManager:
Code:
	def onModNetMessage(self, argsList):
		'Called whenever CyMessageControl().sendModNetMessage() is called - this is all for you modders!'
		
		iData1, iData2, iData3, iData4, iData5 = argsList
		
		print("Modder's net message!")
		
		CvUtil.pyPrint( 'onModNetMessage' )

		iMessageID = iData1
		
		#DemolitionTroop's Effect on a City
		if ( iMessageID == self.m_iNetMessage_DemolitionTroop ):
			
			iPlotX = iData2
			iPlotY = iData3
			iOwner = iData4
			iUnitID = iData5
			
			pPlot = CyMap( ).plot( iPlotX, iPlotY )
			pCity = pPlot.getPlotCity( )
			pPlayer = gc.getPlayer( iOwner )
			pUnit = pPlayer.getUnit( iUnitID )
			
			self.doDemolition( pCity, pUnit )
Code:
	def doDemolition( self, pCity, pUnit ):
		pPlayer = gc.getPlayer( pCity.getOwner( ) )
		
		#GreenMod: here variables
		iRazecity = gc.getInfoTypeForString('BUILDING_RAZECITY')
		iDemotroop = gc.getInfoTypeForString('UNIT_DEMOLITIONTROOP')
		iActivePlayer = CyGame().getActivePlayer()
		pPlayer = gc.getPlayer(pCity.getOwner())
		iOwner = pCity.getOwner()
		iX = pCity.getX()
		iY = pCity.getY()
		pPlot = CyMap().plot(iX,iY)
		
		#GreenMod: razes a city, not capitol, costs 50 gold per pop
		if (not pCity.isCapital()) and (not pCity.isDisorder()):
			iPop = pCity.getPopulation()
			iGold =  pPlayer.getGold()
			iNewGold = iGold - iPop * 50
			pPlayer.setGold(iNewGold)
			pPlayer.raze(pCity)
			pCity.kill()
			
		# Unit expended
		pUnit.kill( 0, -1 )
Any suggestions?

@hrochland
In greenmod demo man builds an improvement, then city works plot to change terrain. Do you like this way or have demo man work plot until it is changed?
 
I thanks you very much, bmarnz, I very lack for this function in my BtS mod.
If I good understand, I paste your code on right places in two python files and xml will be as in greenmod? (two functions for demo man)

As regards Demo man and terrain change. I think, man must build it as improvement and go away because in other way he drown after work :)

I will test it in immediate days. I very need this function in my mod

If you will make BtS code for change land to water too, I please you, write it here for me, please. It was function for work boat. awesome too

I will write here if I manage it
Sorry for my bad English
 
Well the code is not ready yet. I posted it here looking for. At the moment I can:

a) Have demo man change land to water and have workboat change water land.

or

b) Have demo man raze city.

When I put the two together (a + b = :deadhorse:) land-> water / water-> land do not work.

If someone wants to look at what I have so far --> Demolition
 
Well the code is not ready yet. I posted it here looking for. At the moment I can:

a) Have demo man change land to water and have workboat change water land.

or

b) Have demo man raze city.

When I put the two together (a + b = :deadhorse:) land-> water / water-> land do not work.

If someone wants to look at what I have so far --> Demolition

Obvious choice for me. land-> water / water-> land is for me more important .Thanks, bmarnz. I not understand python code, can I use teraform part as it is now for both terraform functions? (land-> water / water-> land // man and work boat)
 
Obvious choice for me. land-> water / water-> land is for me more important .Thanks, bmarnz. I not understand python code, can I use teraform part as it is now for both terraform functions? (land-> water / water-> land // man and work boat)

Here is working code for (land-> water / water-> land // man and work boat) only.

Terraform
 
Hi, bmarnz. Please, I apply your terraform minimod in my mod (two changes made only (no in python) terraform functions I allow for other two units)
In game it take same effect as along applying forest mod.
(http://forums.civfanatics.com/showthread.php?t=250202)
When I press change plot button, game crash...
May be error when I change which unit will be make it?
Thanks for your time :)
HROCHland
 
Yes I know change must be in first square circle near city as in GM. :)
I compose your minimod in my mod. This weekend I try it separately for function verify. :)
I send word if work it
Thanks you
HROCHland
 
Now I finihed test of your minimod. Is here cyclic error. If I start change water to land, in last turn when it id to be finished and water changed to land, script start second change back to water and this way for always round about.
land-> water change makes it in the same way
This proces have not end :(
 
Thanks, bmarnz, I appreciate this, you overtake make your mod and help me too :) I will test new minimod this evening when I come to home
thanks
HROCHland

Well, I just started learning this python stuff. Makes for good learning experience.

Now, if I ever need a building made... ;)
 
Top Bottom