Afforess
The White Wizard
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%.
Any help would be appreciated.
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.