Transfer of Leader

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
Hopefully this is just a quick answer. I want to transfer a Great General from one unit to another. Is the promotion "PROMOTION_LEADER" the only thing I need to consider or is there something else I have missed? If it is just the one promotion for the transfer, then my task is easy. Have I missed anything?
 
There is a CyUnit.getLeaderUnitType() function. If this is not NO_UNIT (i.e. -1) then it is being led and it tells you what the type of unit that was attached is (in case you have more than one type that can do so). There is also, of course, a setLeaderUnitType too. You should probably set the new unit to ahve the same leader type as the old unit and set the old one to NO_UNIT. This may, or may not, transfer the PROMOTION_LEADER - I'm guessing that it is "not".
 
OK This is how I got it to work:

Code:
iGreatGeneral = gc.getInfoTypeForString("UNIT_GREAT_GENERAL")

# Loop through promotions
for iProm in range(gc.getNumPromotionInfos()):
	# Does the unit have this promotion
	if pUnitZ.isHasPromotion(iProm):				
		# Army unit must not already have this promotion
		if not MyNewArmyUnit.isHasPromotion(iProm):
			# Transfer promotion to the New Army Unit
			MyNewArmyUnit.setHasPromotion(iProm, True)					
			# Get the Leader Type
			pUnitZLeaderType = pUnitZ.getLeaderUnitType()
			# Does the unit have a leader?
			if pUnitZLeaderType != -1:
				# Get the Leader Name
				pUnitzName = pUnitZ.getNameNoDesc()
				#CyInterface().addImmediateMessage(str(pUnitzName), "")
				# Get the Leader Type for Army Unit
				MyNewArmyUnitLeaderType = MyNewArmyUnit.getLeaderUnitType()
				# Make sure the Army unit does not already have a leader
				if MyNewArmyUnitLeaderType == -1:
					MyNewArmyUnit.setLeaderUnitType(iGreatGeneral)
					MyNewArmyUnit.setName(pUnitzName)

Thanks to all for your help.
 
Back
Top Bottom