Snaitf's Unit Allegiance Mod

Status
Not open for further replies.

Snaitf

Chieftain
Joined
Nov 28, 2005
Messages
76
Please visit this thread for v1.61 compatible version of the mod: http://forums.civfanatics.com/showthread.php?t=169738

Saw a request for something kinda like this:

Whenever a living human land-based unit is defeated by another land-based unit, there is a 5% chance that the unit about to be defeated switches allegiance and joins the victors. They keep all promotions, exp, and levels, lose 1/2 hp, and can't be moved until next turn.

enjoy...
 

Attachments

Yep, I have to concur. You, Requies and Mylon are turning out to be genuine Mod 'genuises' :)! I look forward to seeing more of your stuff in the coming year, and desperately hope that Firaxis are smart enough to make at least some of your mods 'Official'!

Yours,
Aussie_Lurker.
 
Anima Croatorum said:
Very interesting. I have another idea closely related. Ships and aircraft. I was thinking when you capture a city with naval and air units you should be given 50% chance to capture them in port/airfield.

Great Idea!
 
Snaitf said:
Saw a request for something kinda like this:

Whenever a living human land-based unit is defeated by another land-based unit, there is a 5% chance that the unit about to be defeated switches allegiance and joins the victors. They keep all promotions, exp, and levels, lose 1/2 hp, and can't be moved until next turn.

enjoy...

Snaif is it possible to make it so that if you win thare is a chance to get a slave? 10% maybe? if you have civic slavery?

Its cool mod! :goodjob:
 
LittleRedPoint said:
Snaif is it possible to make it so that if you win thare is a chance to get a slave? 10% maybe? if you have civic slavery?

Its cool mod! :goodjob:

actually, yes, that's doable. Maybe just another check in the py file to see if you have slavery enabled, and if so, there's a 10% chance to get a 'slave worker' (new unit w' -50% efficiency) and if you ever switch to emancipation you loose all your 'slave workers', not a bad idea, I might have to work this one out...
 
Snaitf said:
actually, yes, that's doable. Maybe just another check in the py file to see if you have slavery enabled, and if so, there's a 10% chance to get a 'slave worker' (new unit w' -50% efficiency) and if you ever switch to emancipation you loose all your 'slave workers', not a bad idea, I might have to work this one out...

If you do that maybe give them the Hurry Building ability that Great Engineers have but with a reduced hammer amount (I think Great Engineers give 1000+ hammers when they do this). So you can actually sacrifice the slave on the end of a wip to hurry a building.

Just a thought :P
And no I am not a sadistic person... oh wait maybe I am :crazyeye:
 
Snaitf said:
actually, yes, that's doable. Maybe just another check in the py file to see if you have slavery enabled, and if so, there's a 10% chance to get a 'slave worker' (new unit w' -50% efficiency) and if you ever switch to emancipation you loose all your 'slave workers', not a bad idea, I might have to work this one out...

It would be great ;)

I made slave skin. I mod worker skin to look like it is a slave. It is useful then. You can't build slave, but you can have it if you win a battle :D
Historically slaves were prisoners of war

Next step from there is slave camp in city - add 1 or 2 free slave specialist.
+1 food, +1 prod. But building causes 1 unhappiness. if you get emanciapation then this building is going to be obsolete. (+10 slave birth rate? :crazyeye: )

I use my slave unit to rush buildings (+30 prod), an i can sell it others (+30 gold) and i can sacrifice it (+15 culture). The problem is that these images what i currently use for these actions should be diferent.
 
Well i messed with your code and i get what i wanted. Snaitf you are genius!!

:D I found answer to my question. To get sertain units like slave as a combat result you just mod your code:

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())
		#############################
		## Start Modifaction Block ##
		#############################
		xType = unitX.getUnitCombatType()
		yType = unitY.getUnitCombatType()	
		if (yType != gc.getInfoTypeForString("UNITCOMBAT_SIEGE") and yType != gc.getInfoTypeForString("UNITCOMBAT_ARMOR") and yType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and yType != gc.getInfoTypeForString("UNITCOMBAT_NAVAL") and yType != gc.getInfoTypeForString("NONE")):
			if (xType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and xType != gc.getInfoTypeForString("NONE")):
				iRand = random.randint(1, 100)
				if (iRand <= 5):
					newUnit = playerX.player.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)

##End Snaitf code and start LittleRedPoint slavery code :) code#################################################

		player = gc.getActivePlayer()	
		xType = unitX.getUnitCombatType()
		yType = unitY.getUnitCombatType()
		unitSlave = gc.getInfoTypeForString("UNIT_SLAVE")
		if (player.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY"))):
			if (yType != gc.getInfoTypeForString("UNITCOMBAT_SIEGE") and yType != gc.getInfoTypeForString("UNITCOMBAT_ARMOR") and yType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and yType != gc.getInfoTypeForString("UNITCOMBAT_NAVAL") and yType != gc.getInfoTypeForString("NONE")):
				if (xType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and xType != gc.getInfoTypeForString("NONE")):
					iRand = random.randint(1, 100)					
					if (iRand >= 80):
						newUnit = playerX.player.initUnit(unitSlave, pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI)
						newUnit.finishMoves()
		#############################
		##  End Modifaction Block  ##
		#############################

So now it is possible to make event to combat that you have chance to get some units what you like. This has a condition that active player must have civic slavery then you have cance 20% to get slave as combat result. First you must add slave to your Civ4UnitInfos.xml

I keep your code in game and i put this new code under yours code. The random condition must be changed to "if (iRand >= 80):" that you can't get both. Now itis possible to get slave or unit.
But you have 25% overall chance to get something from battle if your civic is slavery.

Snaitf you are my hero!
 
Exavier said:
does this work with patch 1.52?


Yes, I have been playing it for the past 2 days with 1.52. Works great.


There is a couple of things that I have noticed tho...

1) Could you have the computer make some sort of sound or animation (like the worker surrender animation) when you capture a unit? I have played and not even realized that I have gotten or lost a unit.

2) I could be mistaken, but I think after you capture a unit, it gets experience? I will have to check this again and report back, but I seem to recall getting a promotion more than once when I have a captured unit. I am not sure if it was because the unit had gotten some (while the computer controlled it) during that turn and or whatnot...

-=R=-
 
lordroy said:
Yes, I have been playing it for the past 2 days with 1.52. Works great.


There is a couple of things that I have noticed tho...

1) Could you have the computer make some sort of sound or animation (like the worker surrender animation) when you capture a unit? I have played and not even realized that I have gotten or lost a unit.

2) I could be mistaken, but I think after you capture a unit, it gets experience? I will have to check this again and report back, but I seem to recall getting a promotion more than once when I have a captured unit. I am not sure if it was because the unit had gotten some (while the computer controlled it) during that turn and or whatnot...

-=R=-


1) Ya, some sort of note that you had won a new unit would be nice.
2) I was mistaken, the units that got promotion were due to the computer winning a round before.


-=R=-
 
OK, I kinda liked the way this worked, so I wanted to add it to: Moderator Action: Sevo's Civ Fanatics Fusion 2.0
Please read the forum rules:
http://forums.civfanatics.com/showthread.php?t=422889Moderator Action: .

I cut the following code from this mod:

Code:
#############################
## Start Modifaction Block ##
#############################
import random
#############################
##  End Modifaction Block  ##
#############################
and
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())

		#############################
		## Start Modifaction Block ##
		#############################
		xType = unitX.getUnitCombatType()
		yType = unitY.getUnitCombatType()
		if (yType != gc.getInfoTypeForString("UNITCOMBAT_SIEGE") and yType != gc.getInfoTypeForString("UNITCOMBAT_ARMOR") and yType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and yType != gc.getInfoTypeForString("UNITCOMBAT_NAVAL") and yType != gc.getInfoTypeForString("NONE")):
			if (xType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and xType != gc.getInfoTypeForString("NONE")):
				iRand = random.randint(1, 100)
				if (iRand <= 5):
					newUnit = playerX.player.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)
		#############################
		##  End Modifaction Block  ##
		#############################

		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()))

into his "CvSevoEventManager.py" file.

I sent a coupla e-mails out trying to get to the bottom of this, any help would be appreciated.


Is there something else I am missing?

-=R=-

Please read the forum rules: http://forums.civfanatics.com/showthread.php?t=422889
 
Hey,if someone would be kind enough to update Snaitf's mods so evreything works correctly with patch 1.61....I can get the XML fixed but I'd like the new combat fixed correctly. I tried to fix his Great Generals but could'nt. Don't know Python at all. I love the new combat system.

If someone could come on here & tell me how much time it would take to make the mod compatible with 1.61 that would be great.

Considering he's not around anymore & all the great mods he put out it would be a kind gesture. Hell, if I knew how I would. :)

I guess I'm gonna try again...:crazyeye:
 
Status
Not open for further replies.
Back
Top Bottom