dood100125
Chieftain
I saw this option in the star trek mod. The option allows you to build unique units of the other civilizations city's if you capture them. Is there a way I can implement this into my mod?
It should be possible to do this in Python by enabling the canTrain callback found in CvGameUtils. Firstly you need to compare the city's current owner with its original owner with CyCity.getOwner() and CyCity.getOriginalOwner() respectively. If they don't match up, then you need to figure out if the current unit type is available to the original owner.I saw this option in the star trek mod. The option allows you to build unique units of the other civilizations city's if you capture them. Is there a way I can implement this into my mod?
Its the assimilation mod
http://forums.civfanatics.com/showthread.php?t=281289
It may be in RevDCM, but im not sure.
It occurred to me that it probably would be prudent to also check if the player who is building the foreign unique unit can build the unit's domestic counterpart. So the script would include more code. With a standard BtS v3.19 setup, this is what would be added to CvGameUtils.py:It should be possible to do this in Python by enabling the canTrain callback found in CvGameUtils. Firstly you need to compare the city's current owner with its original owner with CyCity.getOwner() and CyCity.getOriginalOwner() respectively. If they don't match up, then you need to figure out if the current unit type is available to the original owner.
Firstly you need to get the CyPlayer instance of the original owner with CyGlobalContext.getPlayer() and then you need to invoke CyPlayer.canTrain() on that object. If this check clears you make the CvGameUtils.canTrain() method return a True value.
def canTrain(self,argsList):
pCity = argsList[0]
eUnit = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
bIgnoreCost = argsList[4]
bIgnoreUpgrades = argsList[5]
[B] eOwner = pCity.getOwner()
eFounder = pCity.getOriginalOwner()
if eOwner != eFounder:
pUnitInfo = gc.getUnitInfo(eUnit)
eUnitClass = pUnitInfo.getUnitClassType()
pPlayer = gc.getPlayer(eOwner)
eCivilization = pPlayer.getCivilizationType()
pCivInfo = gc.getCivilizationInfo(eCivilization)
eUnit = pCivInfo.getCivilizationUnits(eUnitClass)
return pPlayer.canTrain(eUnit, False, False)[/B]
return False
It occurred to me that it probably would be prudent to also check if the player who is building the foreign unique unit can build the unit's domestic counterpart.
It should be possible to do this in Python by enabling the canTrain callback found in CvGameUtils.
I'm not checking whether or not the city can build the unit, but the player. So I guess CyPlayer.canTrain() only takes Techs into account?Why? When I'm a civ that can build a type of swordsman with iron and the UU of the conquered city civ is a swordman that can be build without iron why should I check for my unit? The allowed lack of iron may be the major advantage of the UU.
Aha, the callback never even gets made for a UU? In that case it wouldn't work...Sadly not, because the UU restriction gets checked before the unit variable gets passed to the callback (...er...i think it might even be a unit class variable).
I'm not checking whether or not the city can build the unit, but the player. So I guess CyPlayer.canTrain() only takes Techs into account?![]()
Aha, the callback never even gets made for a UU? In that case it wouldn't work...![]()
Does your mod have SDK changes? if it does thats the answer, you need to merge the two and compile your own dll.