1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

War Prizes

Discussion in 'Civ4 - Mod Components' started by mechaerik, Aug 23, 2009.

  1. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    You have seen Slavery modcomps before that give you, well Slaves. But have you seen War Prizes?

    This simple Modcomp gives you and the AI a chance to capture Naval Units instead of destroying them upon a combat victory. This means that if your Galley beats someone else's Galley, you might walk away with an extra galley. This works both ways, so they might also get another galley if you lose.

    FEATURES
    Spoiler :
    ~~ Barbarians cannot capture the units. They have no chance to.

    ~~ Only Naval units can capture other naval units. Why add in this line? So ICBMs, TacNukes, and Guided Missiles can't capture units.

    ~~ Privateers cannot capture or be captured.

    ~~ The chance to capture is by default 25%.

    ~~ By default, Captured units start with 50 HP.

    ~~ UUs CAN be captured. This means you can see Russian Carracks and Byzantine East Indiamen!

    ~~ All promotions on the unit captured are removed.


    I've included a README that goes in detail how to mod the code.

    CREDITS
    Base Python Code: Frekk. This ModComp is partially based on his Enslavement Modcomp.
    Concept/Python Work: mechaerik. I reworked most of the code and came up with the concept.
    Help/Python Knowledge: The_J. He pointed me in Frekk's direction and helped write and fix parts of the code



    DOWNLOAD:http://forums.civfanatics.com/downloads.php?do=file&id=13083

    DOWNLOAD WAR PRIZE MODCOMP WITH SIEGE:
    http://forums.civfanatics.com/downloads.php?do=file&id=13088
     
  2. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles






     
  3. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    Version History:

    War Prizes:

    1.2 August 24th (Current Version)
    1.1 August 23rd (taken down to fix odds bug)
    1.0 August 22nd (taken down to squash a bug with Privateers)

    War Prizes with Siege:

    1.2 August 24th (Current Version)
    1.1 August 23rd (taken down to fix odds bug)
    1.0 August 23rd (Taken down to fix parentheses error)
     
  4. The Capo

    The Capo godless Heathen

    Joined:
    Jan 29, 2001
    Messages:
    9,302
    Location:
    Washington, DC
    I wrote this on the DL page, but I think you should allow for the capture of Catapults, Trebuchets and Cannons.
     
  5. cybrxkhan

    cybrxkhan Asian Xwedodah

    Joined:
    Aug 10, 2006
    Messages:
    9,687
    Location:
    The Universe
    This looks like an interesting concept, one I may use somewhere...

    How hard do you think it would be to change this so that any unit, or different units other than naval units, can be captured, such as siege units as The Capo mentioned above?
     
  6. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,480
    I doubt the AI would protect single siege units.
     
  7. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    Very easy. Just change this:
    Code:
    if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
    to this:

    Code:
    if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SIEGE")):
    then add something similar to the line above it, but replace unitY (which is the losing unit) with unitX.




    EDIT: Going through the code made me find a bug that does let privateers capture units. I'll upload the new version right now. I'll also upload one that lets siege be captured.
     
  8. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Okay, I'm trying to merge this with RoM's eventmanager, but I lose my interface (which means I'm not adding it correctly.) I had to make a few changes to it, because RoM uses different UNITCOMBAT's than BTS, but otherwise, it is pretty much the same. Any ideas of what I'm doing wrong? Here's what my code is
    Spoiler :

    Code:
    ## mechaerik War Prize ModComp START##
    		pPlayer = gc.getPlayer(pWinner.getOwner())
    		if not (gc.getPlayer(pWinner.getOwner()).isBarbarian()):
    			if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WOODEN_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_STEAM_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_DIESEL_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NUCLEAR_SHIPS")):
    				if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WOODEN_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_STEAM_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_DIESEL_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NUCLEAR_SHIPS")):
    					if not (unitX.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
    						if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
    							if CyGame().getSorenRandNum(100, "Bob") <= 75:
         							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())
    ## War Prize Modcomp END##
     
  9. seasnake

    seasnake Conquistador

    Joined:
    Apr 21, 2006
    Messages:
    1,875
    Location:
    California, United States
    Great work. Is it possible to limit its effects to Age of Sail vessels? Is it possible to make some vessels more apt to claim another (like ship of the line?).

    Would you just remove the OR tags from steam and nuclear vessels?
     
  10. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    @Aforress Try this:

    Spoiler :
    Code:
    ## mechaerik War Prize ModComp START##
    		pPlayer = gc.getPlayer(pWinner.getOwner())
    		if not (gc.getPlayer(pWinner.getOwner()).isBarbarian()):
    			if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WOODEN_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_STEAM_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_DIESEL_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NUCLEAR_SHIPS")):
    				if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WOODEN_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_STEAM_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_DIESEL_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NUCLEAR_SHIPS")):
    					if not (unitX.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
    						if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
    							if CyGame().getSorenRandNum(100, "Bob") <= 75:
    							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())
    ## War Prize Modcomp END##
     
  11. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    That code doesn't work... Does it have something to do with the parenthesis? Yours was missing some originally, so I added some, but maybe I was wrong to do that.
     
  12. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    !! You are right. I've uploaded a new version which fixes the parentheses error. Perhaps something on my end was wrong, but the ModComp works now, perhaps you should try making it again with the new version.
     
  13. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Thanks, that update fixed my problems. Great Modcomp!
     
  14. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    31,407
    Location:
    DE/NL/FR
    Good to see it in the download database :goodjob:.

    But imho you should also name Frekk as creator (in the database), because of the things you've already mentioned.
     
  15. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    I just tested, you have your capture percentages backward. You mentioned that ships have a 25% chance of capture, but the python you wrote gives a 75% chance of capture. I checked. To test, I set the code to 0:
    Code:
    if CyGame().getSorenRandNum(100, "Bob") <= 0:
    
    and according to your readme, that would give 100% chance of capture, but it didn't. It made it so ships were never captured. I tested this on 20-30 ships.
     
  16. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    Great catch, Afforess. I'll upload a new version tomorrow.
     
  17. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    This modcomp seems a bit similar to the UnitAllegiance-modcomp :)
     
  18. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    What's that?
     
  19. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    A mod by GIR iirc that makes units switch sides after defeat.
     
  20. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    I just looked at that modcomp. It's outdated, correct? Anyways, It seemed interesting, but I would have made changes to it. When your units surrendur (or defect), the enemy should just accept them immediately. I would make them POW. (It's different with ships, you can just kill the crew and take the ship itself.) I know if the enemy defected to me, I wouldn't believe them. After all, if they can defect once, they can defect again. Oh, and the civic "Nationalism" should have made all units 100% loyal.

    But I digress...
     

Share This Page