War Prizes

Code:
		pPlayer = gc.getPlayer(pWinner.getOwner())
		pPlayerLoser = gc.getPlayer(pLoser.getOwner())
		if not ([COLOR="red"]pPlayer[/COLOR].isBarbarian()):
			if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")):
				if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SIEGE")):
					[COLOR="Blue"]if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
						if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):[/COLOR]							if CyGame().getSorenRandNum(100, "Bob") <= 25:
								iUnit = pLoser.getUnitType()
								newUnit = pPlayer.initUnit([COLOR="red"]iUnit[/COLOR], pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
								newUnit.finishMoves()
								newUnit.setDamage(50, [COLOR="Red"]-1[/COLOR])
								[COLOR="Lime"]CyInterface().addMessage(pPlayer.getID(),true,20,CyTranslator().getText("TXT_LALALA",(unitY.getDescription(),)),'',0,'',-1, -1, -1, true,true)[/COLOR]

1) Already defined above, y still do extra work
2) This command allows you to display a message just for that player, winner for this case. You can add a button, adjust the duration, colour of the button etc if you want
3) Why are there 2 lines checking the same condition, whether Unit Y is privateer class?
 
I am guessing, it was meant to be unitX for the other line, to check whether either one is privateer? If you add a button, and add the co-ordinates in the respective areas, the button will show up similar to when you get a great person.

The first -1 controls the colour of the button
The 2nd and 3rd -1 controls the X and Y co-ordinates
 
Code:
		pPlayer = gc.getPlayer(pWinner.getOwner())
		pPlayerLoser = gc.getPlayer(pLoser.getOwner())
		if not ([COLOR="red"]pPlayer[/COLOR].isBarbarian()):
			if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")):
				if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SIEGE")):
					[COLOR="Blue"]if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
						if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):[/COLOR]							if CyGame().getSorenRandNum(100, "Bob") <= 25:
								iUnit = pLoser.getUnitType()
								newUnit = pPlayer.initUnit([COLOR="red"]iUnit[/COLOR], pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
								newUnit.finishMoves()
								newUnit.setDamage(50, [COLOR="Red"]-1[/COLOR])
								[COLOR="Lime"]CyInterface().addMessage(pPlayer.getID(),true,20,CyTranslator().getText("TXT_LALALA",(unitY.getDescription(),)),'',0,'',-1, -1, -1, true,true)[/COLOR]

1) Already defined above, y still do extra work
2) This command allows you to display a message just for that player, winner for this case. You can add a button, adjust the duration, colour of the button etc if you want
3) Why are there 2 lines checking the same condition, whether Unit Y is privateer class?

So could you delete the red and blue parts? What would be the best code, for this plus giving a notification to it? Also it says unitclass_privateer, so doest that mean only the privateer can be taken as a prize?
 
Those in red, already changed for you.
Those in blue, I believe you need to change one of them to unitX to make sense.

Regarding privateer, the codes are checking whether unitY, the defeated unit is NOT a privateer.
If it is not, then convert it to yours.

A message is already displayed telling you, you captured blah blah blah, why you still need another notification

By the way, the 2nd line, pPlayerLoser blah blah blah is redundant.
You declare that variable, but never use it, purpose?
 
Those in red, already changed for you.
Those in blue, I believe you need to change one of them to unitX to make sense.

Regarding privateer, the codes are checking whether unitY, the defeated unit is NOT a privateer.
If it is not, then convert it to yours.

A message is already displayed telling you, you captured blah blah blah, why you still need another notification

By the way, the 2nd line, pPlayerLoser blah blah blah is redundant.
You declare that variable, but never use it, purpose?

I don't get the privateer thing? What do i switch it to?
 
Code:
if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
	if not (unit[COLOR="Red"]X[/COLOR].getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
 
Code:
if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
	if not (unit[COLOR="Red"]X[/COLOR].getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):

haha i dont know python at all, i dont know what unitX and unitY means, what does that exactly do?
 
unitY refers to the defeated unit.
unitX refers to the killing unit.
Checks whether Y is not a privateer
Checks whether X is not a privateer
 
Yes, that is what the OP intended to do
 
mechaeric, I repackaged your mod and adapted it for BUG 4.4.
I added siege weapon capture and barbarian capture. Thanks again for your mod! :)

The final python:
Spoiler :

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())
		iBBonus=10 # 10% chance of capture
## mechaerik War Prize ModComp START##
		pPlayer = gc.getPlayer(pWinner.getOwner())
		pPlayerLoser = gc.getPlayer(pLoser.getOwner())		
		if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
			if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
				if not (unitX.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
					if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
						if playerX.isBarbarian():
							iBBonus=15 # barbarian bonus 15%
						if CyGame().getSorenRandNum(100, "modifieda4") <= iBBonus:
							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())
							if (pPlayer.isHuman()):
								CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("TXT_KEY_MISC_WARPRIZES_SUCCESS",(pLoser.getName(),)),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_BLUE")), pWinner.getX(), pWinner.getY(), True,True)
							elif (pPlayerLoser.isHuman()):
								CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("TXT_KEY_MISC_WARPRIZES_FAILURE",(pLoser.getName(),)),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)  
		if (unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_SIEGE")  or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_RECON") or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_NAVAL") or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_AIR") or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_BIOLOGICAL")):
			if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SIEGE")):
				if (unitY.getUnitClassType() != gc.getInfoTypeForString("UNITCLASS_MACHINE_GUN")):
					if playerX.isBarbarian():
						iBBonus=15 # barbarian bonus 15%
					if CyGame().getSorenRandNum(100, "modifieda4") <= iBBonus:
						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())
						if (pPlayer.isHuman()):
							CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("TXT_KEY_MISC_WARPRIZES_SUCCESS",(pLoser.getName(),)),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_BLUE")), pWinner.getX(), pWinner.getY(), True,True)
						elif (pPlayerLoser.isHuman()):
							CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("TXT_KEY_MISC_WARPRIZES_FAILURE",(pLoser.getName(),)),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)  
## War Prize Modcomp END##
 
Top Bottom