View Full Version : Snaitf's Unit Allegiance Mod


Snaitf
Dec 11, 2005, 12:06 AM
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...

JohnSearle
Dec 11, 2005, 02:20 AM
Very interesting idea! Your on quite the roll... :)

Snaitf
Dec 11, 2005, 10:33 AM
Very interesting idea! Your on quite the roll... :)

......................:smug:

Aussie_Lurker
Dec 11, 2005, 07:00 PM
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
Dec 13, 2005, 08:59 AM
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.

MattJek
Dec 13, 2005, 09:03 AM
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!

LittleRedPoint
Dec 13, 2005, 11:40 AM
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:

Snaitf
Dec 13, 2005, 09:42 PM
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...

Exavier
Dec 13, 2005, 10:40 PM
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:

LittleRedPoint
Dec 14, 2005, 12:24 AM
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.

LittleRedPoint
Dec 17, 2005, 08:42 AM
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:

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!

lordroy
Dec 28, 2005, 05:53 AM
Im gonna try this out, looks like a useful possible mod add in...


-=R=-

Exavier
Dec 28, 2005, 06:02 AM
does this work with patch 1.52?

lordroy
Dec 29, 2005, 01:17 AM
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
Dec 31, 2005, 04:19 PM
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=-

lordroy
Jan 29, 2006, 10:38 PM
OK, I kinda liked the way this worked, so I wanted to add it to: [MOD] Sevo's Civ Fanatics Fusion 2.0 (http://forums.civfanatics.com/showthread.php?t=151611).

I cut the following code from this mod:


#############################
## Start Modifaction Block ##
#############################
import random
#############################
## End Modifaction Block ##
#############################

and

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=-

stgelven
Feb 01, 2006, 04:15 AM
when i see that kind of work, i know that i done well when i bought civ4!
:goodjob:

Jeckel
Apr 15, 2006, 09:27 PM
Anyone know if this is compatable with v1.61?

zxc0vbn
Apr 21, 2006, 07:05 PM
It's a great mod, but i have never made it work aright! wuwu.

casey1966
Apr 21, 2006, 10:29 PM
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:

TheLopez
May 02, 2006, 08:23 AM
Do people still want this mod updated to be v1.61 compatible?

Caesium
May 02, 2006, 09:28 AM
If you feel able to do this, we would be thankful, I think.

Amra
May 02, 2006, 07:36 PM
Do people still want this mod updated to be v1.61 compatible?

That would be great. I have it in my modpack but only due to Rabbit, White's kindness. It appears to be working but I'm not sure if it just worked as is or if Rabbit had to do any serious tweaking. It was part of his Rabbit's Essentials mod

Los Tirano
May 02, 2006, 08:35 PM
This has been added to the Total Realism mod and it helps to make it very nice indeed. It is especially interesting when unique units are captured, or units slightly above your level of technology.

For example playing a small map lots of civs and some vey powerful barbarians cities. Gave the barbarians teutonic knights for defence (see Total realism) but France managed to take one off the barbarians in a border conflict and after healing it, it was used to spearhead a sneaky french attack against me. The teuton was finally killed in a large battle outside one of my cities, 9 warchariots and one nubian archer vs one teuton and seven axemen.

So yes, this mod is neat when combined with others.