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

Tsentom1 Python Promotions

Discussion in 'Civ4 - Mod Components' started by tsentom1, Jan 24, 2009.

  1. tsentom1

    tsentom1 Bubble Dragon

    Joined:
    Jul 24, 2007
    Messages:
    1,000
    Location:
    New York
    You can also make it fire for two numbers instead of one, instead of making an entirely second throw:

    Code:
    			self.iHealChance = self.getRandomNumber( 3 )
    
    			if self.iHealChance == 0:
    Code:
    			self.iHealChance = self.getRandomNumber( 3 )
    
    			if (self.iHealChance == 0) or (self.iHealChance == 1):
    Makes that from a 25% (1 in 4) to 50% (2 in 4) chance, etc. Which might make some of the more obscure percents easier to make.

    For a 35%, really 33.3% is so close and easy to do comparatively, I would just do the 1 in 3 chance as opposed to making complicated odds.
     
  2. Antilogic

    Antilogic --

    Joined:
    Sep 2, 2006
    Messages:
    15,602
    Yeah, that is a lot easier. Just increase the random number to 25, and you can count by 4s. Or even further, if you have the patience to copy paste that much. You could also do a different comparator statement (less than rather than equivalent to), set the random number to 100, and get any percentage you want.

    Figures I went the most difficult route.
     
  3. tsentom1

    tsentom1 Bubble Dragon

    Joined:
    Jul 24, 2007
    Messages:
    1,000
    Location:
    New York
    Haha, you're right, make it throw a 100 and using less than and equal to is probably the easiest way to get exact percents.
     
  4. Duque d'Caxias

    Duque d'Caxias Great General

    Joined:
    Nov 17, 2006
    Messages:
    102
    Location:
    Brazil
    Now I think i got the idea. It appears a little complicated, but it's not. It's a quite simple, even for an amateur like me[hshshs].
    Thank you very much, people. This code will be really usefull specially for cavalry units. There is no sense in a static horsearcher, for intance, defending a plot to the death. 50% withdrawal capability on attack, 50% on defense. It makes more sense, doesn't it?
     
  5. Antilogic

    Antilogic --

    Joined:
    Sep 2, 2006
    Messages:
    15,602
    Certainly does. Would make fighting mounted armies much more annoying if they could always escape you.
     
  6. snipperrabbit!!

    snipperrabbit!! Deity

    Joined:
    Nov 23, 2006
    Messages:
    3,396
    tsentom, I have an idea for a 'war cry' prom, are you up to do this one ?
    PM me if you have an interest in this idea.
     
  7. tsentom1

    tsentom1 Bubble Dragon

    Joined:
    Jul 24, 2007
    Messages:
    1,000
    Location:
    New York
    It's not so much a matter of interest as a matter of if I'm capable of coding the effect (or if the coding is even possible with just python). If you're looking for something like I think you're looking for with a promotion called 'war cry' (a promotion either one time use or constant that either buffs troops around/in your stack or debuffs enemy troops around you) that's going to be very difficult and it might actually be better to try and adapt code from Fall From Heaven's spell system rather than try and make it an individual promotion.
     
  8. snipperrabbit!!

    snipperrabbit!! Deity

    Joined:
    Nov 23, 2006
    Messages:
    3,396
    well, my plan was for a limited effect within the unit. Basically, it may occurs (or not) during the combat resolution [maybe the hardest part] and give a percentage of recovery (L to 49 where L is the current level of the unit) and must fire only once in a turn.
    While it will be nice to have a greater scale effect I don't want to go that far yet ! Maybe it's left for a warlord attached to unit.
     
  9. notque

    notque Artificially Intelligent

    Joined:
    Nov 13, 2005
    Messages:
    1,657
    Excellent. I have been considering making Pirate ships who die give away a % of their empires gold depending on how much experience they have.

    (More experienced Pirates = More Gold)

    Think that might work with what you have?
     
  10. tsentom1

    tsentom1 Bubble Dragon

    Joined:
    Jul 24, 2007
    Messages:
    1,000
    Location:
    New York
    The code in the download looks at the gold reserves directly. Though, it's not hard to write something to look the ships' experience. pWinner.getExperience would find out how much experience the winning ship has (pLoser would be the losing ship) so you can do something like "if pWinner.getExperience >= 5:" then have the code for one percentage of gold stolen, and then one for the other. So something like this (note this is all just off the top of my head so it's probably filled with syntax errors but it's the basic idea of what you'd have to do for the gold stealing part of the code):

    Code:
    			pPlayer = gc.getPlayer(pWinner.getOwner())
    			iGold = playerY.getGold( )
    			message = 0
    
    		if pWinner.getExperience >= 5: 
    
    			iGoldStolen = ( iGold//25 )
    
    			if iGold >= 500:
    				playerX.changeGold( +20 )
    				playerY.changeGold( -20 )
    				message = 1
    			elif iGold >= 25:
    				playerX.changeGold( +iGoldStolen )
    				playerY.changeGold( -iGoldStolen )
    				message = 2
    			elif (iGold >= 1) and iGold < 25):
    				playerX.changeGold( +1 )
    				playerY.changeGold( -1 )
    				message = 3
    		else: 
    
    			iGoldStolen = ( iGold//50 )
    
    			if iGold >= 1000:
    				playerX.changeGold( +20 )
    				playerY.changeGold( -20 )
    				message = 1
    			elif iGold >= 50:
    				playerX.changeGold( +iGoldStolen )
    				playerY.changeGold( -iGoldStolen )
    				message = 2
    			elif (iGold >= 1) and iGold < 50):
    				playerX.changeGold( +1 )
    				playerY.changeGold( -1 )
    				message = 3
     
  11. notque

    notque Artificially Intelligent

    Joined:
    Nov 13, 2005
    Messages:
    1,657
    Excellent, I'm going to give it a try. I need to add several new traits and promotions for the specific traits, so this thread, and the other one are perfect.

    My intention is to give the promotions to the pirates ships as a negative promotion. So I will flip who gets what in your code. I may do both actually, and have them receive gold for wins, and lose gold for losses.
     
  12. Shqype

    Shqype Shqyptar

    Joined:
    Nov 15, 2005
    Messages:
    2,468
    Location:
    New York + Shqypni
    I love the Skirmisher promotion. Great job!
     
  13. little_cyclone

    little_cyclone Loyal Civ4 & C2C mod player

    Joined:
    Mar 12, 2004
    Messages:
    339
    Gender:
    Male
    Location:
    The Deep South
    Was trawling around the forums looking for something interesting, and lo & behold, here we are! I gotta say, you've come up with some great ideas :)

    Had a question tho, was wondering if it would be possible to create a "Hidden Nationality" Promotion. Was thinking that it would also require 1)either have some high req's (Combat 2 or 3 for example) or 2) some other innate disadvantage (No defensive bonuses or -25% strength on defense or some such) to offset using it. I've tried dinking around with the files but unfortunately as my modding abilities stunted around the time of Civ 3, all I'm doing is causing a variety of interesting and fruitless CTD's :(
     
  14. tsentom1

    tsentom1 Bubble Dragon

    Joined:
    Jul 24, 2007
    Messages:
    1,000
    Location:
    New York
    I know Fall From Heaven has such a promotion, but I think it's done with SDK modding as I don't think it would be possible with just python. I'd have to look through their files.
     
  15. notque

    notque Artificially Intelligent

    Joined:
    Nov 13, 2005
    Messages:
    1,657
    Hidden Nationality causes a lot of issues which need to be addressed all over the SDK.
     
  16. tsentom1

    tsentom1 Bubble Dragon

    Joined:
    Jul 24, 2007
    Messages:
    1,000
    Location:
    New York
    Yeah, for the most part python works if there's a specific event that can trigger the code (like every time a unit dies, or wins in combat). You need SDK for constant effects (like hidden nationality, etc).
     
  17. little_cyclone

    little_cyclone Loyal Civ4 & C2C mod player

    Joined:
    Mar 12, 2004
    Messages:
    339
    Gender:
    Male
    Location:
    The Deep South
    Drat.. Thanks for trying anyways :)
     
  18. Infantry#14

    Infantry#14 Emperor

    Joined:
    Dec 26, 2006
    Messages:
    1,600
    i have a noob question, how do i combine your promotions into a single mod?
     
  19. tsentom1

    tsentom1 Bubble Dragon

    Joined:
    Jul 24, 2007
    Messages:
    1,000
    Location:
    New York
    You have to merge all the files together. Because of this, all the downloads also only include the bare minimum files that need to be merged.

    I tried to be consistent with where the changes are in the files. So all the python changes are labeled (usually searching for the mods name will find the changes, though the exact search 'word' is always listed in the downloads page). For the XML the changes for the most part are at the bottom of the file.

    Regardless, downloading the program called Winmerge can be an enormous help. Since I edited only base BTS files if you open and compare the modcomp's file with the same named file from standard BTS you'll be to see all the changes outright.

    If your mod doesn't use a file in one of my downloads, it's even easier as then you have nothing to merge for that file and can just place it as is in the same file location in your mod.

    As always, if you're just adding them to the base game, and not a mod, it's not recommended to change base game files. Instead combine them with each other to make it one big mod.
     
  20. Infantry#14

    Infantry#14 Emperor

    Joined:
    Dec 26, 2006
    Messages:
    1,600


    Alright, thanks!
     

Share This Page