Questions on how to realise my ideas in a mod.

progressregress

Chieftain
Joined
Jul 5, 2010
Messages
12
Location
England
There are a few things that I am not sure how to implement, and would like a brief explanation or a link to a guide to follow, I have tried flicking through the pages of the guides etc. forum and have not found anything that looks right so far.

I think that these things are controlled by python, but I have only so far, after a quick peruse found an entry that relates to 2. (the starbase), which I am not sure how I can use it to translate into what I would like to do. I suspect I could implement 4. with a stealth/invisibility class like submarines, but I would like to see if there are other options first.

1. A blockade mission that blocks both land and sea tiles that land units can carry out (certain combat classes if possible).

2. [SOLVED] A city building to spawn a certain unit every x turns (like the king richard's crusade in RoM mod, or similar to the starbase in Final Frontier).

3. [SOLVED] Units to be spawned on discovery of tech (not only the first to discover).

4. A combat class that can only be attacked by certain combat classes, but will not impede city-capture or assaults on other combat classes on the tile, a bit like water units except without being destroyed if that tile is taken.

Thank you kindly in advance.
 
A short example would be great if its not too much trouble, thanks for the download link too, its much easier to find the right info when its not amidst the messy clutter of a huge mod like RoM.
 
Merging python is not that much more complicated than XML.
In the XML files, normally the new entries are at the end, not so in python, because there the place is important, it has to go at the same place again.
The new code is normally labeled with "#mod name", so you can in most times just search for the name of the mod component in the python files.

One of the most important things: The white spaces in python files really matter! You have to copy them over, else it will probably not work!
One help here is to activate python exceptions in the civilization4.ini file, which you can find in your BtS folder.

So, and after i wrote this, i realize that you've asked for an example :D.
Okay, so, in Python\CvEventManager.py, you can find this:
Spoiler :

PHP:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not gc.getGame().isNetworkMultiPlayer()) and (iPlayer == gc.getGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
				
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d' 
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))

this is the normal python code, which is triggered after a player has researched a new tech.

So, here an example how to change it:
Spoiler :

PHP:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
###new test code - spawning a unit start
		if iTechType == gc.getInfoTypeForString("TECH_HUNTING"):
                        if iPlayer>-1:
                                pPlayer = gc.getPlayer(iPlayer)
                                pCapital = pPlayer.getCapitalCity()
                                if not pCapital.isNone():
                                        newUnit = pPlayer.initUnit(gc.getInfoTypeForString("UNIT_SCOUT"), pCapital.getX(),pCapital.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
###new test code - spawning a unit end		
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not gc.getGame().isNetworkMultiPlayer()) and (iPlayer == gc.getGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
				
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d' 
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))

You have to copy the parts between new test code start an end.
In this example, every player will get a scout in his capital after researching hunting.
Just change the technology and the units to whatever you want.
 
Thank you very much, most importantly it all made sense. Hopefully this should open up as many options as discovering switch triggers in the Starcraft editor did, lol ;)
 
by number 4 im guessing you mean something similiar to final frontier stealth ships how majority of the games units can't attack them so id have a route around in that mod to find out if you do can you let me know as im also looking to find out its secrets :P but the not being destroyed could be accomplished by making the unit capturable maybe ?
 
Back
Top Bottom