[Python] Enslavement

Afforess

The White Wizard
Joined
Jul 31, 2007
Messages
12,239
Location
Austin, Texas
I'm trying to create a modcomp that will have a chance (15%) of creating a slave after combat is finished with the enemy. I have the unit created, and I'm basing my python loosely off of the War Prizes code. The game doesn't throw any exceptions when loading, so I'm stumped to as what I'm doing wrong. For testing purposes, I've set the chance of generating a slave at 100%.

Code:
## Afforess Enslavement ModComp START##
        pPlayer = gc.getPlayer(pWinner.getOwner())
        pPlayerLoser = gc.getPlayer(pLoser.getOwner())
        if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SETTLER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WORKER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_RECON")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")):
            if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SETTLER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WORKER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_RECON")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")):
                if CyGame().getSorenRandNum(100, "Bob") <= 100:
                    newUnit = pPlayer.initUnit(gc.getUnitClassType == gc.getInfoTypeForString("UNITCLASS_SLAVE"), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
                    newUnit.finishMoves()
                    CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("We've enslaved the enemy!",()),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pWinner.getX(), pWinner.getY(), True,True)
                    CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("One of our units has been enslaved!",()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)  
## Afforess Enslavement Modcomp END##

Any help would be appreciated.
 
Heres some OLD OLD stuff i used to have:

Code:
## If you are running slavery there is a 25% that you will capture any unit except UNITCOMBAT_DEMON, UNITCOMBAT_NAVAL, or UNITCOMBAT_ANIMAL
		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) == gc.getInfoTypeForString('CIVIC_SLAVERY'):
			if (pLoser.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_DEMON') and pLoser.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_NAVAL') and pLoser.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_ANIMAL') and pLoser.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_FIRE') and pLoser.getUnitCombatType() != gc.getInfoTypeForString('NONE')):
				iRnd = CyGame().getSorenRandNum(100, "Bob")
				if iRnd <= 25:
					CyInterface().addMessage(pWinner.getOwner(),True,25,'Slave captured.','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Units/Slave.dds',ColorTypes(8),pWinner.getX(),pWinner.getY(),True,True)
					newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_SLAVE'), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI)

and:
Code:
## If the loser is a UNITCOMBAT_MELEE or UNITCOMBAT_ARCHER or UNITCOMBAT_RECON or UNITCOMDAT_MOUNTED there is a 50% chance that the winner will enslave the loser
		if pWinner.isHasPromotion(gc.getInfoTypeForString('PROMOTION_COMMAND')):
			yType = pLoser.getUnitCombatType()
			if (yType == gc.getInfoTypeForString("UNITCOMBAT_MELEE") or yType == gc.getInfoTypeForString("UNITCOMBAT_ARCHER") or yType == gc.getInfoTypeForString("UNITCOMBAT_RECON") or yType == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")):
				iRnd = CyGame().getSorenRandNum(100, "Bob")
				if (iRnd <= 50):
					newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI)
					newUnit.finishMoves()
					newUnit.setDamage(50, False)
					newUnit.setExperience(pLoser.getExperience(), -1)
					newUnit.setLevel(pLoser.getLevel())
					for iCount in range(gc.getNumPromotionInfos()):
						if (pLoser.isHasPromotion(iCount)):
							newUnit.setHasPromotion(iCount, True)

and:

Code:
if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) == gc.getInfoTypeForString('CIVIC_SLAVERY'):
			if (pLoser.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_DEMON') and pLoser.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_NAVAL') and pLoser.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_ANIMAL') and pLoser.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_FIRE') and pLoser.getUnitCombatType() != gc.getInfoTypeForString('NONE')):
				iRnd = CyGame().getSorenRandNum(100, "Bob")
				if iRnd <= 25:
					CyInterface().addMessage(pWinner.getOwner(),True,25,'Slave captured.','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Units/Slave.dds',ColorTypes(8),pWinner.getX(),pWinner.getY(),True,True)
					newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_SLAVE'), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI)

Just remember its all old stuff.
 
You should definitely get an exception on this line:

Code:
newUnit = pPlayer.initUnit([B]gc.getUnitClassType == gc.getInfoTypeForString("UNITCLASS_SLAVE")[/B], UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)

The bold part is testing if the function to acquire a CvUnitClassInfo is equal to the integer representing a slave unit class which is probably False since functions don't equal integers. ;)

You also must specify X and Y coordinates for initUnit(). Try this:

Code:
newUnit = pPlayer.initUnit([B]gc.getInfoTypeForString("UNITCLASS_SLAVE")[/B], [B]unitY.getX(), unitY.getY(),[/B] UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
 
You should definitely get an exception on this line:

Code:
newUnit = pPlayer.initUnit([B]gc.getUnitClassType == gc.getInfoTypeForString("UNITCLASS_SLAVE")[/B], UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
The bold part is testing if the function to acquire a CvUnitClassInfo is equal to the integer representing a slave unit class which is probably False since functions don't equal integers. ;)

heh, I looked at my logs, and I do have some exceptions...
You also must specify X and Y coordinates for initUnit(). Try this:

Code:
newUnit = pPlayer.initUnit([B]gc.getInfoTypeForString("UNITCLASS_SLAVE")[/B], [B]unitY.getX(), unitY.getY(),[/B] UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)

That doesn't work, but maybe that's because I've got a new exception:
Code:
File "CvEventManager", line 749
    if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SETTLER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WORKER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_RECON")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")):
    ^
 
You didn't paste in the actual exception, just its location. :(

BTW, that code you're posting uses spaces for indentation whereas all the Firaxis code uses tabs. This can cause nightmares if you're not careful. I highly recommend sticking with tabs for indentation at all times.
 
You know, you could have asked me to modify the code.

Anyways, there are several enslavement modcomps. In fact, War Prizes was based off of an Enslavement modcomp, one by Frekk.
 
Here is another slave part of a different mod i had:

Code:
if gc.getPlayer(iAttacker).isCivic(CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SLAVERY')):
					for loop in range(unit.getLevel()):
						attacker.initUnit(gc.getCivilizationInfo(gc.getPlayer(iAttacker).getCivilizationType()).getCivilizationUnits(CvUtil.findInfoTypeNum(gc.getUnitClassInfo, gc.getNumUnitClassInfos(), 'UNITCLASS_SLAVE')), unit.getX(), unit.getY(), UnitAITypes.NO_UNITAI)
				elif gc.getPlayer(iAttacker).isCivic(CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SERFDOM')):
					for loop in range(1):
						attacker.initUnit(gc.getCivilizationInfo(gc.getPlayer(iAttacker).getCivilizationType()).getCivilizationUnits(CvUtil.findInfoTypeNum(gc.getUnitClassInfo, gc.getNumUnitClassInfos(), 'UNITCLASS_SLAVE')), unit.getX(), unit.getY(), UnitAITypes.NO_UNITAI)

Plus:
Code:
if gc.getPlayer(iAttacker).isCivic(CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SLAVERY')):
					attacker.initUnit(gc.getCivilizationInfo(gc.getPlayer(iAttacker).getCivilizationType()).getCivilizationUnits(CvUtil.findInfoTypeNum(gc.getUnitClassInfo, gc.getNumUnitClassInfos(), 'UNITCLASS_SLAVE')), unit.getX(), unit.getY(), UnitAITypes.NO_UNITAI)
		#mod#
		CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d' 
			%(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))

Plus:
Code:
if gc.getPlayer(iPlayer).isCivic(CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SLAVERY')):
			for loop in range(city.getPopulation()*2):
				PyPlayer( city.getOwner() ).initUnit(gc.getCivilizationInfo(gc.getPlayer(city.getOwner()).getCivilizationType()).getCivilizationUnits(CvUtil.findInfoTypeNum(gc.getUnitClassInfo, gc.getNumUnitClassInfos(), 'UNITCLASS_SLAVE')), city.getX(), city.getY(), UnitAITypes.NO_UNITAI)
		elif gc.getPlayer(iPlayer).isCivic(CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SERFDOM')):
			for loop in range(city.getPopulation()):
				PyPlayer( city.getOwner() ).initUnit(gc.getCivilizationInfo(gc.getPlayer(city.getOwner()).getCivilizationType()).getCivilizationUnits(CvUtil.findInfoTypeNum(gc.getUnitClassInfo, gc.getNumUnitClassInfos(), 'UNITCLASS_SLAVE')), city.getX(), city.getY(), UnitAITypes.NO_UNITAI)

Plus:
Code:
if (popupReturn.getButtonClicked() == 9):
				for loop in range(AmountChange):
					PyPlayer( playerID ).initUnit(CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(),"UNIT_SLAVE"), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI)

Dont know if these will help or not, but at least they are something.:confused:
 
You didn't paste in the actual exception, just its location. :(

BTW, that code you're posting uses spaces for indentation whereas all the Firaxis code uses tabs. This can cause nightmares if you're not careful. I highly recommend sticking with tabs for indentation at all times.

I'm using tabs. I have no idea why it got reformated to spaces when I pasted it in here. At least, in notepad++, they look like tabs.

You know, you could have asked me to modify the code.

Anyways, there are several enslavement modcomps. In fact, War Prizes was based off of an Enslavement modcomp, one by Frekk.

But that's a good idea, and no fun. Anyways, maybe you can still help me.

Here's my latest code, which gives two exceptions:

Code:
## Afforess Enslavement ModComp START##
        pPlayer = gc.getPlayer(pWinner.getOwner())
        pPlayerLoser = gc.getPlayer(pLoser.getOwner())
        if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) == gc.getInfoTypeForString('CIVIC_SLAVERY'):
            if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SETTLER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WORKER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_RECON")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")):
                if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SETTLER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WORKER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_RECON")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")):
                    if CyGame().getSorenRandNum(100, "Bob") <= 100:
                        iUnit = pLoser.getUnitType()
                        newUnit = pPlayer.initUnit(gc.getInfoTypeForString("UNITCLASS_SLAVE"), unitY.getX(), unitY.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
                        newUnit.finishMoves()
                        CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("We've enslaved the enemy!",()),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pWinner.getX(), pWinner.getY(), True,True)
                        CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("One of our units has been enslaved!",()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)  
## Afforess Enslavement Modcomp END##

Traceback (most recent call last):

File "CvEventInterface", line 30, in onEvent

File "BugEventManager", line 298, in handleEvent

File "BugEventManager", line 303, in _dispatchEvent

File "BugEventManager", line 315, in _handleDefaultEvent

File "CvEventManager", line 754, in onCombatResult

AttributeError: UnitInfo instance has no attribute 'getX'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 30, in onEvent

File "BugEventManager", line 298, in handleEvent

File "BugEventManager", line 303, in _dispatchEvent

File "BugEventManager", line 315, in _handleDefaultEvent

File "CvEventManager", line 754, in onCombatResult

AttributeError: UnitInfo instance has no attribute 'getX'
ERR: Python function onEvent failed, module CvEventInterface
 
Make SURE they are tabs and not spaces. Could cause some problems, primarily interface.

Frekk's original code (the one War Prizes is based on) is this:

Code:
		pPlayer = gc.getPlayer(pWinner.getOwner())
		if pWinner.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SLAVER')):
			if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) == gc.getInfoTypeForString('CIVIC_SLAVERY'):
				if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")):
					if CyGame().getSorenRandNum(100, "Bob") <= 60:
						iUnit = pLoser.getUnitType()
						newUnit = pPlayer.initUnit(gc.getInfoTypeForString( 'UNIT_SLAVE' ), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
						newUnit.finishMoves()
						CyInterface().addMessage(pWinner.getOwner(),False,15,CyTranslator().getText("TXT_KEY_SLAVER",()),'',0,'Art/Interface/Buttons/Units/slave.dds',ColorTypes(44), pWinner.getX(), pWinner.getY(), True,True)
 
For the error:
Replace
PHP:
unitY.getX(), unitY.getY()
with

PHP:
pLoser.getX(), pLoser.getY()

Okay, I replaced that, and I don't get any python errors. Instead, when I capture attack a unit, while running slavery, I get a free "ManO' War" ship. :lol: I'm not sure why though, Man O' War's are UNITCLASS_MANOWAR, not UNITCLASS_SLAVE
 
When you call initUnit(), you must pass in a Unit Type, but you are passing in a Unit Class. You need to use the player's civilization to look up the correct Unit Type for the SLAVE Unit Class.

You can find code in CvMainInterface to do this where it draws the unit build order buttons.
 
When you call initUnit(), you must pass in a Unit Type, but you are passing in a Unit Class. You need to use the player's civilization to look up the correct Unit Type for the SLAVE Unit Class.

You can find code in CvMainInterface to do this where it draws the unit build order buttons.

Or... I could be lazy and change UNITCLASS_SLAVE to UNIT_SLAVE.

It works now. But I still have a bug, when I win a battle, I get two slaves, one where the enemy unit was and one where my unit was.
 
Is there anywhere maybe some lost code from your work?
Can't really see, how this could happen.

I don't think so. This is all there is.

Code:
## Afforess Enslavement ModComp START##
        pPlayer = gc.getPlayer(pWinner.getOwner())
        pPlayerLoser = gc.getPlayer(pLoser.getOwner())
        if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) == gc.getInfoTypeForString('CIVIC_SLAVERY'):
            if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SETTLER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WORKER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_RECON")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")):
                if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SETTLER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WORKER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_RECON")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")):
                    if CyGame().getSorenRandNum(100, "Bob") <= 100:
                        iUnit = pLoser.getUnitType()
                        newUnit = pPlayer.initUnit(gc.getInfoTypeForString("UNIT_SLAVE"), pLoser.getX(), pLoser.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
                        newUnit.finishMoves()
                        CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("We've enslaved the enemy!",()),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pWinner.getX(), pWinner.getY(), True,True)
                        CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("One of our units has been enslaved!",()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)  
## Afforess Enslavement Modcomp END##
 
Where exactly is that code?

Here's the function it's in.
Code:
def onCombatResult(self, argsList):
        'Combat Result'
        pWinner,pLoser = argsList
        playerX = PyPlayer(pWinner.getOwner())
        unitX = PyInfo.UnitInfo(pWinner.getUnitType())
        playerY = PyPlayer(pLoser.getOwner())
        unitY = PyInfo.UnitInfo(pLoser.getUnitType())
## mechaerik War Prize ModComp START##
        pPlayer = gc.getPlayer(pWinner.getOwner())
        pPlayerLoser = gc.getPlayer(pLoser.getOwner())
        if not (gc.getPlayer(pWinner.getOwner()).isBarbarian()):
            if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WOODEN_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_STEAM_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_DIESEL_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NUCLEAR_SHIPS")):
                if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WOODEN_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_STEAM_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_DIESEL_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NUCLEAR_SHIPS")):
                    if not (unitX.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
                        if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
                            if CyGame().getSorenRandNum(100, "Bob") <= 15:
                                iUnit = pLoser.getUnitType()
                                newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
                                newUnit.finishMoves()
                                newUnit.setDamage(50, pWinner.getOwner())
                                CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("We've taken an enemy ship as a prize!",()),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_BLUE")), pWinner.getX(), pWinner.getY(), True,True)
                                CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("One of our ships has been taken as a prize!",()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)  
## War Prize Modcomp END##

## Afforess Enslavement ModComp START##
        pPlayer = gc.getPlayer(pWinner.getOwner())
        pPlayerLoser = gc.getPlayer(pLoser.getOwner())
        if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) == gc.getInfoTypeForString('CIVIC_SLAVERY'):
            if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SETTLER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WORKER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_RECON")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")):
                if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SETTLER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WORKER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_RECON")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")):
                    if CyGame().getSorenRandNum(100, "Bob") <= 100:
                        iUnit = pLoser.getUnitType()
                        newUnit = pPlayer.initUnit(gc.getInfoTypeForString("UNIT_SLAVE"), pLoser.getX(), pLoser.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
                        newUnit.finishMoves()
                        CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("We've enslaved the enemy!",()),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pWinner.getX(), pWinner.getY(), True,True)
                        CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("One of our units has been enslaved!",()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)  
## Afforess Enslavement Modcomp END##

        if (not self.__LOG_COMBAT):
            return
        if playerX and playerX and unitX and playerY:
            CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s' 
                %(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(), 
                playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))
 
Back
Top Bottom