Tsentom1 Python Promotions

To anwer the second part of your question, it is a lot more difficult to make a non-fractional (as in, not 1 / integer) chance happen. The easiest way I can think of is to conduct two checks that add up to the desired percentage, and if either passes you return a true.

As in, if you want 40%, you could hack it together with two 20% throws, which is a 1/5 shot. Not perfect, but better than nothing.

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

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.
 
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?
 
Certainly does. Would make fighting mounted armies much more annoying if they could always escape you.
 
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.

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

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
 
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.
 
I love the Skirmisher promotion. Great job!
 
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 :(
 
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 :(

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.
 
Hidden Nationality causes a lot of issues which need to be addressed all over the SDK.
 
Hidden Nationality causes a lot of issues which need to be addressed all over the SDK.

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).
 
Drat.. Thanks for trying anyways :)
 
i have a noob question, how do i combine your promotions into a single mod?
 
i have a noob question, how do i combine your promotions into a single mod?

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



Alright, thanks!
 
Back
Top Bottom