Tsentom1 Python Wonders

The standard SDK upgrade formula is in CvUnit::upgradePrice(UnitTypes eUnit) and it calculates the price the following way:

Code:
	iPrice = GC.getDefineINT("BASE_UNIT_UPGRADE_COST");

	iPrice += (std::max(0, (GET_PLAYER(getOwnerINLINE()).getProductionNeeded(eUnit) - GET_PLAYER(getOwnerINLINE()).getProductionNeeded(getUnitType()))) * GC.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"));

	if (!isHuman() && !isBarbarian())
	{
		iPrice *= GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIUnitUpgradePercent();
		iPrice /= 100;

		iPrice *= std::max(0, ((GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIPerEraModifier() * GET_PLAYER(getOwnerINLINE()).getCurrentEra()) + 100));
		iPrice /= 100;
	}

	iPrice -= (iPrice * getUpgradeDiscount()) / 100;

	return iPrice;

You can mimic it in Python like so:
Code:
	def getUpgradePriceOverride(self, argsList):
		iPlayer, iUnitID, iUnitTypeUpgrade = argsList

		pPlayer = gc.getPlayer(iPlayer)
		pUnit = pPlayer.getUnit(iUnitID)

		iPrice = gc.getDefineINT("BASE_UNIT_UPGRADE_COST")
		iPrice += (max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"))

		if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
			pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
			iPrice = iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100
			iPrice = iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100

		iPrice = iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100)

		#Now modify the price with Leonardo's and return it
		
		return -1	# Any value 0 or above will be used
 
Wow, thanks a lot. One of the reasons why I never made it a percent was cause I could never find the formula and not only do you find it but you post python for it!

I'll update everything. Thanks!
 
Updated Leonardo:

Special thanks to Dresden for the python

LeonardoNew.jpg
 
Okay since I was doing some clean-up, I just went and did some more.

I went through all the old modcomps. Cleaned up their code. Tesla and Sydney now function completely different. Golden Gate now gives more culture and no gold. Added a better description for the Ice Hotel. Most of the changes I feel either made them more balanced or gave them a more singular unified bonus instead of a bunch of little bonuses.
 
tsentom1,

Your Python wonders are really amazing. I'm looking at including a couple in my next release of CivFusion.

There was a forum member named GIR who also had some neat Python wonders but he hasn't been around a while to my knowledge. One of them, Petra, had a neat effect where it would give you a 25% chance of receiving a UB of another civ when you built a building. For example, if you built a Stable, you would have 25% chance of receiving a Ger, even if you were playing Spain or England or any other civ. However, there is a bug in the code. Using this example, let's say you are playing Spain and you have the Petra wonder. You build a Stable and are lucky enough to receive a Ger instead. However, you can still build a Stable, which should not happen. If you receive the UB from Petra, you should no longer be able to build the standard building.

Anyways, I was wondering if I posted the code if you wouldn't mind looking at it and seeing if you could fix it. If not, no worries, but I thought I would ask.

Cheers,
ripple01
 
:D

It's a dream come true. I'll be updating my mod now, even if it means I have to abandon this awesome start I got as Elizabeth.

Well, if you've already added the last version. Changing the python to this version wouldn't break a save.
 
tsentom1,

Your Python wonders are really amazing. I'm looking at including a couple in my next release of CivFusion.

There was a forum member named GIR who also had some neat Python wonders but he hasn't been around a while to my knowledge. One of them, Petra, had a neat effect where it would give you a 25% chance of receiving a UB of another civ when you built a building. For example, if you built a Stable, you would have 25% chance of receiving a Ger, even if you were playing Spain or England or any other civ. However, there is a bug in the code. Using this example, let's say you are playing Spain and you have the Petra wonder. You build a Stable and are lucky enough to receive a Ger instead. However, you can still build a Stable, which should not happen. If you receive the UB from Petra, you should no longer be able to build the standard building.

Anyways, I was wondering if I posted the code if you wouldn't mind looking at it and seeing if you could fix it. If not, no worries, but I thought I would ask.

Cheers,
ripple01

I have the Petra mod on my computer. I ripped and used the ability to capture UBs in my Thomas' War mod for a wonder and dropped the rest as it didn't fit into my mod.

I'll look at the rest and see if I can see what's not working correctly.
 
tsentom1,

Your Python wonders are really amazing. I'm looking at including a couple in my next release of CivFusion.

There was a forum member named GIR who also had some neat Python wonders but he hasn't been around a while to my knowledge. One of them, Petra, had a neat effect where it would give you a 25% chance of receiving a UB of another civ when you built a building. For example, if you built a Stable, you would have 25% chance of receiving a Ger, even if you were playing Spain or England or any other civ. However, there is a bug in the code. Using this example, let's say you are playing Spain and you have the Petra wonder. You build a Stable and are lucky enough to receive a Ger instead. However, you can still build a Stable, which should not happen. If you receive the UB from Petra, you should no longer be able to build the standard building.

Anyways, I was wondering if I posted the code if you wouldn't mind looking at it and seeing if you could fix it. If not, no worries, but I thought I would ask.

Cheers,
ripple01

Okay, well it's not so much a bug in the code as simply how the game works. You can however fix it by writing separate code in the GamUtils which is easy to do, just, time-consuming as you need to write an entry for each and every UB.

Now I realize I might have to write it anyway for my Thomas War mod, so I'll write the fix, it'll take some time though.
 
That's what I was thinking but I couldn't figure out how to check for a generic if it has the same class don't build and thus do it one check

I know how to do it for each building class so once for barracks once for granary etc, but some generic get building class of ebuilding i'm not sure.
 
tsentom1,

Your Python wonders are really amazing. I'm looking at including a couple in my next release of CivFusion.

There was a forum member named GIR who also had some neat Python wonders but he hasn't been around a while to my knowledge. One of them, Petra, had a neat effect where it would give you a 25% chance of receiving a UB of another civ when you built a building. For example, if you built a Stable, you would have 25% chance of receiving a Ger, even if you were playing Spain or England or any other civ. However, there is a bug in the code. Using this example, let's say you are playing Spain and you have the Petra wonder. You build a Stable and are lucky enough to receive a Ger instead. However, you can still build a Stable, which should not happen. If you receive the UB from Petra, you should no longer be able to build the standard building.

Anyways, I was wondering if I posted the code if you wouldn't mind looking at it and seeing if you could fix it. If not, no worries, but I thought I would ask.

Cheers,
ripple01


I agree, i really like all of the components made by GIR here is his listing, would be nice to have them all back and updated, thx.

http://forums.civfanatics.com/showpost.php?p=4014630&postcount=6
 
Well actually, Gir's download link still works:

http://www.atomicgamer.com/file.php?id=67261

as does all his python.

Truth be told most of his wonders are slightly too powerful and could use some nerfing.

As for the mods themselves, his Sphinx doesn't use any python (it was simply an early Cristo Redentor) I did my own Sphinx anyway, I released a simpler updated Leonardo already, Templo works fine (I have a version in Thomas' War that's a 50% reduction instead of his 100% so I can rip that and post it if you want), his KGB python works and is balanced so there's no real reason to change it, I made a more updated Via Appia for Thomas' War already so I can post that, the Forbidden Palace was just adding a wonder movie which you can find all over this forum now, Partisans were added to the core game with BTS, Machu Pichu was balanced and worked fine, his Circus Maximus is way too strong (regular bonuses plus every turn a chance to get free experience for any mounted unit) I can tone it down if you want, and his UU and UB wonders I also feel are too strong (I think capturing a UB is fine but a chance to build any was overpowered but to each his own I guess) I'm writing the fix to the 'bug' in that.
 
Well actually, Gir's download link still works:

http://www.atomicgamer.com/file.php?id=67261

as does all his python.

Truth be told most of his wonders are slightly too powerful and could use some nerfing.

As for the mods themselves, his Sphinx doesn't use any python (it was simply an early Cristo Redentor) I did my own Sphinx anyway, I released a simpler updated Leonardo already, Templo works fine (I have a version in Thomas' War that's a 50% reduction instead of his 100% so I can rip that and post it if you want), his KGB python works and is balanced so there's no real reason to change it, I made a more updated Via Appia for Thomas' War already so I can post that, the Forbidden Palace was just adding a wonder movie which you can find all over this forum now, Partisans were added to the core game with BTS, Machu Pichu was balanced and worked fine, his Circus Maximus is way too strong (regular bonuses plus every turn a chance to get free experience for any mounted unit) I can tone it down if you want, and his UU and UB wonders I also feel are too strong (I think capturing a UB is fine but a chance to build any was overpowered but to each his own I guess) I'm writing the fix to the 'bug' in that.

Sounds great if you can fix these, i really like the Via Appia one, and Machu pichu one.
 
Himeji, e-Bank, and Sydney should work in Warlords as should any of them that only use the onBuildingBuilt Python call back (Confucius, Eden, and Mohenjo-daro).

Unfortunately, the Sphinx, Tesla, Djenne, and Leonardo can't be converted to Warlords as the Warlords python doesn't have the building/unit cost modifier, can't declare war, or the Upgrade Price override.

Golden Gate, Public Works, and Ice Hotel would work if you went into the python and deleted the references to any BTS building or civ.

For all the ones whose python is sound you'd still have to convert the XML. Since most don't use any benefit from the XML that basically requires making a 'blank' building that calls the appropriate art and text files and setting a cost/pre-req tech.

I'm not sure about the Copernicus/Cheomseongdae wonders.

The seed vault is really interesting...
 
I always intend to combine them and release a pack, but then I keep adding more. If I was going to I would change it to call python from a custom event manager (which sadly you can't do with all the mods as many make use of the GameUtils). Because all of them together is going to make a mess of python.

I can put them all together, though, if you want, and host it externally.

I have two more that are basically done and an edit of an old one of Girs anyway to post. I was just going to see if I could clean up the code a bit more and probably post them this weekend.
 
Back
Top Bottom