1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Snaitf's Unit Allegiance Mod

Discussion in 'Civ4 - Mod Components' started by Snaitf, Dec 11, 2005.

Thread Status:
Not open for further replies.
  1. Snaitf

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

    Attached Files:

  2. JohnSearle

    JohnSearle Chieftain

    Joined:
    Nov 21, 2005
    Messages:
    88
    Very interesting idea! Your on quite the roll... :)
     
  3. Snaitf

    Snaitf Chieftain

    Joined:
    Nov 28, 2005
    Messages:
    76
  4. Aussie_Lurker

    Aussie_Lurker Chieftain

    Joined:
    Jul 21, 2003
    Messages:
    6,956
    Location:
    Adelaide, South Australia
    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.
     
  5. Anima Croatorum

    Anima Croatorum Chieftain

    Joined:
    Oct 24, 2005
    Messages:
    413
    Location:
    Vukojebina, Croatia
    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.
     
  6. MattJek

    MattJek Chieftain

    Joined:
    Oct 21, 2005
    Messages:
    951
    Location:
    Legoland
    Great Idea!
     
  7. LittleRedPoint

    LittleRedPoint Slaver

    Joined:
    Dec 13, 2004
    Messages:
    155
    Location:
    Estonia (EU)
    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:
     
  8. Snaitf

    Snaitf Chieftain

    Joined:
    Nov 28, 2005
    Messages:
    76
    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...
     
  9. Exavier

    Exavier Destroyer of Worlds

    Joined:
    Nov 14, 2005
    Messages:
    906
    Location:
    Phoenix, Arizona, USA
    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:
     
  10. LittleRedPoint

    LittleRedPoint Slaver

    Joined:
    Dec 13, 2004
    Messages:
    155
    Location:
    Estonia (EU)
    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.
     
  11. LittleRedPoint

    LittleRedPoint Slaver

    Joined:
    Dec 13, 2004
    Messages:
    155
    Location:
    Estonia (EU)
    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!
     
  12. lordroy

    lordroy God

    Joined:
    Nov 28, 2001
    Messages:
    148
    Im gonna try this out, looks like a useful possible mod add in...


    -=R=-
     
  13. Exavier

    Exavier Destroyer of Worlds

    Joined:
    Nov 14, 2005
    Messages:
    906
    Location:
    Phoenix, Arizona, USA
    does this work with patch 1.52?
     
  14. lordroy

    lordroy God

    Joined:
    Nov 28, 2001
    Messages:
    148

    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=-
     
  15. lordroy

    lordroy God

    Joined:
    Nov 28, 2001
    Messages:
    148

    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=-
     
  16. lordroy

    lordroy God

    Joined:
    Nov 28, 2001
    Messages:
    148
    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
     
  17. stgelven

    stgelven Chieftain

    Joined:
    Apr 22, 2003
    Messages:
    398
    Location:
    pays de loire - france
    when i see that kind of work, i know that i done well when i bought civ4!
    :goodjob:
     
  18. Jeckel

    Jeckel Great Reverend

    Joined:
    Nov 16, 2005
    Messages:
    1,637
    Location:
    Peoria, IL
    Anyone know if this is compatable with v1.61?
     
  19. zxc0vbn

    zxc0vbn Chieftain

    Joined:
    Dec 8, 2005
    Messages:
    3
    It's a great mod, but i have never made it work aright! wuwu.
     
  20. casey1966

    casey1966 Chieftain

    Joined:
    Feb 5, 2005
    Messages:
    152
    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:
     
Thread Status:
Not open for further replies.

Share This Page