Capture Slaves

Ok, here's the updated version. From CvEventManager onCombatResult()
Code:
#mod#
		if (pWinner.isMadeAttack()):
			iAttacker = pWinner.getOwner()
			attacker = PyPlayer(iAttacker)
			if gc.getPlayer(iAttacker).isCivic(CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SLAVERY')):
				if ((pLoser.plot()).isCity() == 0):
					if (pLoser.isAnimal() == 0):
						if (pLoser.getDomainType() == gc.getInfoTypeForString('DOMAIN_LAND') and pWinner.getDomainType() == gc.getInfoTypeForString('DOMAIN_LAND')):
							if (pLoser.getCaptureUnitType((gc.getPlayer(pLoser.getOwner())).getCivilizationType()) == -1):
								# you can change the chance of getting slaves with this between 0-100, 0 means 0% and 100 100%
								iChance = 40

								iRandNum = CyGame().getSorenRandNum(99, "Slave")
								if iChance > iRandNum:
									attacker.initUnit(gc.getCivilizationInfo(gc.getPlayer(iAttacker).getCivilizationType()).getCivilizationUnits(CvUtil.findInfoTypeNum(gc.getUnitClassInfo, gc.getNumUnitClassInfos(), 'UNITCLASS_SLAVE')), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI)
#mod#
I tested it, and now it should work.
 
UNITAI_SLAVE causes errors because worldbuilder doesn't recognize it!

I am currently using it in two different mods, and i have no errors?

Are you talking about this error?

Spoiler :
Code:
Traceback (most recent call last):

  File "CvWBInterface", line 230, in writeDesc

  File "CvWBDesc", line 1545, in write

  File "CvWBDesc", line 1193, in write

  File "CvWBDesc", line 827, in write

AttributeError: 'NoneType' object has no attribute 'getType'
ERR: Python function writeDesc failed, module CvWBInterface

All i can say then is change it to something else, like UNITAI_WORKER in the UnitInfo, i dont know for sure if that will work, just try it out.
 
In the last game I played it appears that the AI does not know what to do with these units. They capture a slave and then just leave it standing there for the rest of the game. No one even bothers to attack them.
 
In the last game I played it appears that the AI does not know what to do with these units. They capture a slave and then just leave it standing there for the rest of the game. No one even bothers to attack them.

Could you write a code for the AI then?:blush:
 
In the last game I played it appears that the AI does not know what to do with these units. They capture a slave and then just leave it standing there for the rest of the game. No one even bothers to attack them.

What is the slave's UNITAI in the version you're using? The UNITAI_SLAVE was incorrect so AI couldn't understand what to do to them.
 
There is an error in the promotions XML in the download. It is missing the start bit that identifies the schema.
Code:
<!-- Promotion Infos -->
<Civ4PromotionInfos xmlns="x-schema:CIV4UnitSchema.xml">

Ignore this it just did not have the line breaks!
 
I am going to add this in to the slave unit to see if the AI uses them closer to what you want.
Code:
			<UnitAIs>
				<UnitAI>
					<UnitAIType>UNITAI_ENGINEER</UnitAIType>
					<bUnitAI>1</bUnitAI>
				</UnitAI>
				<UnitAI>
					<UnitAIType>UNITAI_MERCHANT</UnitAIType>
					<bUnitAI>1</bUnitAI>
				</UnitAI>
				<!--UnitAI>
					<UnitAIType>UNITAI_SLAVE</UnitAIType>
					<bUnitAI>1</bUnitAI>
				</UnitAI-->
			</UnitAIs>
From what I understand the AI will use the default AI method but it may use this list as well. So it should some times use it to provide hammers or cash with these in there.
 
That mod looks great! :goodjob: Would it be possible to make it modular?

And what code do I have to add (and where) if I want to have all slaves disbanded when the player/AI leaves the slavery civic?

Thanks in advance
CellKu
 
That mod looks great! :goodjob: Would it be possible to make it modular?

And what code do I have to add (and where) if I want to have all slaves disbanded when the player/AI leaves the slavery civic?

Thanks in advance
CellKu

I am testing a WoC/BUG modular version now. It uses Python code so it can't be straight Civ modular.
 
Top Bottom