How to make a civic needed for creation of an unit?

Gurra09

Emperor
Joined
Jan 1, 2008
Messages
1,302
Location
Sweden
I'm going to create a Slave unit that is a supercheap Worker who destroys it self after completing a work like the work boat.

I think that the Slave unit would only be able to build if you have the Slavery civic. Otherwise not. But how can I make a civic needed for unit creation? I can't find any tag for that in CIV4_UnitInfos.xml.


Gurra09
 
This can be done in Python. Look for the Inquisitor mod component, which has a rule that Inquisitors cannot be built unless you have Theocracy or Organized Religion (IIRC).
 
I think I have a python snippet that does this, if not I'll post one. let me check...



Yup I do follow the link in my sig. ;)
 
Are your python snippet for that compatible for BTS? Because the code you said was in unmodded game was different in my original BTS Python files and when I used the snippet the civilopedia didn't worked and when I played a game I couldn't see menus or anything except for the main map.

This is my Python Code:

Code:
def cannotTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
		civic = "CIVIC_SLAVERY"        ## The Civic
        unit = "UNIT_SLAVE"        ## The Unit

        ## If The Civ Doesn't Have The Correct Civic Tell the SDK Not To Allow The Player To Train This Unit
        if eUnit == gc.getInfoTypeForString(unit):
            if not gc.getPlayer(pCity.getOwner()).isCivic(gc.getInfoTypeForString(civic)):
                return True
		return False



Gurra09
 
Spacing is absolutely critical in Python. One thing I am noticing is the location of the 'return False'. As it is currently placed, it is a part of the 2nd if, and will never be called. So, the function doesn't terminate. Plus, that will cause problems with everything that comes after it in the file.

Everything you added from 'unit =' down to 'return True' should have 8 more spaces put in front of them.
 
I've got everything to work now except for self-destroying of the unit. I can't find any tag in unit infos...


Gurra09
 
Back
Top Bottom