Afforess
The White Wizard
Wait... Should iInquisitor = eUnit, or something like that? Otherwise, you just assigned iInquisitor a true value.
for j in range(gc.getNumUnitInfos()):
eUnit = gc.getUnitType(j)
if gc.getUnitInfo(eUnit).isInquisitor():
iInquisitor = gc.getUnitInfo(eUnit)
iInquisitor = CvUtil.findInfoTypeNum( gc.getUnitInfo, gc.getNumUnitInfos(), "UNIT_INQUISITOR" )
for j in range(gc.getNumUnitInfos()):
eUnit = gc.getUnitInfo(j)
if eUnit.isInquisitor():
iInquisitor = j
for j in range(gc.getNumUnitInfos()):
eUnit = gc.getUnitInfo(j)
if eUnit.isInquisitor():
iInquisitor = eUnit.getID()
iInquisitor = CvUtil.findInfoTypeNum( gc.getUnitInfo, gc.getNumUnitInfos(), "UNIT_INQUISITOR" )
for j in range(gc.getNumUnitInfos()):
eUnit = gc.getUnitInfo(j)
if eUnit.isInquisitor():
iInquisitor = CvUtil.findInfoTypeNum( gc.getUnitInfo, gc.getNumUnitInfos(), eUnit.getType() )
edit: also add a break
Firaxis used them in 3.19, so if you can find the 3.17 source, compare it with 3.19 to see how they pulled it off.
The specific bits of code would be:
Code:uint uiFlag=0; pStream->Read(&uiFlag); // flags for expansion
and
Code:uint uiFlag=2; pStream->Write(uiFlag); // flag for expansion
In the initial release, all fllags were 0, this example is from my CvUnit, but I think from a code set where I haven't modified it. Anyway, one place it was used is:
Code:if (uiFlag > 0) { pStream->Read(&m_bAirCombat); }
Which states that in initial release, there was no m_bAirCombat variable in CvUnit, so only people who have a save from after the first patch will try to load that boolean.
lUnits = []
for ...
if ...
lUnits.append(...)
if pCity.canTrain(iInquisitor, 0, 0):
...
if pPlayer.getUnit( lUnits[ iUnit ].getID( ) ).getUnitType( ) == iInquisitor:
...
if not pPlayer.isUnitClassMaxedOut(iInquisitorClass, -1):
if utils.getRandomNumber(100/buildOdds) == 0:
gc.getMap( ).plot( pCity.getX( ), pCity.getY( ) ).getPlotCity( ).pushOrder( OrderTypes.ORDER_TRAIN, iInquisitor, -1, False, False, False, True )
return True
iInquisitorUnits = []
for j in range(gc.getNumUnitInfos()):
eUnit = gc.getUnitInfo(j)
if eUnit.isInquisitor():
iInquisitorUnits.append(j)
for k in range(iInquisitorUnits):
if pCity.canTrain(k, 0, 0):
iInquisitor = k
for k in iInquisitorUnits:
...
iInquisitorUnits = []
for j in range(gc.getNumUnitInfos()):
eUnit = gc.getUnitInfo(j)
if eUnit.isInquisitor():
iInquisitorUnits.append(j)
iInquisitorCityTrainableUnits = []
for k in range(iInquisitorUnits):
if pCity.canTrain(k, 0, 0):
iInquisitorCityTrainableUnits.append(k)
if (len(iInquisitorCityTrainableUnits) == 1):
iInquisitor = max(iInquisitorCityTrainableUnits)
elif (len(iInquisitorCityTrainableUnits) > 1):
for l in range(iInquisitorCityTrainableUnits):
eUnit = gc.getUnitInfo(l)
iCost = eUnit.getProductionCost()
iInquisitorUnits = []
for eUnit in range(gc.getNumUnitInfos()):
info = gc.getUnitInfo(eUnit)
if info.isInquisitor() and pCity.canTrain(eUnit, False, False):
iInquisitorUnits.append((info.getProductionCost(), j)
if len(iInquisitorUnits) > 0:
sort(iInquisitorUnits)
eBestInquisitor = iInquisitorUnits[0][1]
else:
eBestInquisitor = None
iInquisitorUnits = []
#Running the loop for the unitInfo number in the range of all units in UnitInfos
for eUnit in range(gc.getNumUnitInfos()):
info = gc.getUnitInfo(eUnit)
#Checking if the unit is an inquisitor and if the city can train it (what are the false arguments BTW?)
if info.isInquisitor() and pCity.canTrain(eUnit, False, False):
#It looks like you're making a list that pairs values (like a coordinate system), but how is this working, and where did j come from (if j is supposed to be eUnit it would make alot more sense to me --but I can't assume that because I'm not sure about the code here)?
iInquisitorUnits.append((info.getProductionCost(), j)
#checking the length of the list and if over 1 unit do stuff
if len(iInquisitorUnits) > 0:
#what does the command sort do?
sort(iInquisitorUnits)
#I have no idea what iInquisitorUnits[0][1] is doing...
eBestInquisitor = iInquisitorUnits[0][1]
else:
eBestInquisitor = None
<!-- Unit Schema -->
<!-- INQUISITION 10/12/2007 MRGENIE -->
<ElementType name="PrereqCivic" content="textOnly"/>
<!-- INQUISITION END MRGENIE -->
<!-- INQUISITION 10/12/2007 MRGENIE -->
<ElementType name="bRemoveNonStateReligion" content="textOnly" dt:type="boolean"/>
<!-- INQUISITION END MRGENIE -->
<!-- INQUISITION 10/12/2007 MRGENIE -->
<element type="PrereqCivic" minOccurs="0"/>
<!-- INQUISITION END MRGENIE -->
<!-- INQUISITION 10/12/2007 MRGENIE -->
<element type="bRemoveNonStateReligion" minOccurs="0"/>
<!-- INQUISITION END MRGENIE -->
You guys already probably know this, but the WoC has/had an inquisition unit already coded in the SDK with AI. It might help to see some things from it. I place it in the RevDCM Rapture test merge I did. Mr Genie did the code. If you want to look at it. It is commented with "INQUISITION"
http://forums.civfanatics.com/downloads.php?do=file&id=14028
These are the tags that were added, and you have to add the new mission to the base xml of course. It will allow multiple inquisitor units.
Well if you already knew sorry for wasting your time.Code:<!-- Unit Schema --> <!-- INQUISITION 10/12/2007 MRGENIE --> <ElementType name="PrereqCivic" content="textOnly"/> <!-- INQUISITION END MRGENIE --> <!-- INQUISITION 10/12/2007 MRGENIE --> <ElementType name="bRemoveNonStateReligion" content="textOnly" dt:type="boolean"/> <!-- INQUISITION END MRGENIE --> <!-- INQUISITION 10/12/2007 MRGENIE --> <element type="PrereqCivic" minOccurs="0"/> <!-- INQUISITION END MRGENIE --> <!-- INQUISITION 10/12/2007 MRGENIE --> <element type="bRemoveNonStateReligion" minOccurs="0"/> <!-- INQUISITION END MRGENIE -->