Platyping's Python

I guess you can just take a look at Machu Picchu then.
Too tired to dig out the file to see what it is called.
There is an extra XML file for that.
 
I guess you can just take a look at Machu Picchu then.
Too tired to dig out the file to see what it is called.
There is an extra XML file for that.

:sleep:

What do you mean by activating python callback? which file/function do I have to edit?

Thanks!


See attached This is just an example, but NEVER EVER use the original in any way shape or form of changing it, always make a copy.
 
Tada, that's the name :D
I waited 1 day, nobody replied so I gave him the DIY solution...
Anyway buzy with work, not using modding computer for awhile again, but the file in Machu Picchu will be perfect since there is nothing to edit.

If you use the one from BTS, you still have to open it and activate the corresponding callback.
 
Hi, love the modpack!

I'm having the same issue that was reported a few months ago with the Leaning Tower and Tomb of Khalid:

Hey, I'm back to report another found bug with one of your wonders.

The Catacombs of Kom El Shaqofa's effect is glitched; When you receive a great general, you continually receive them one after another when you have that wonder. Instead of holding over 20% like it is supposed to, it holds over a much larger percentage and gives you hundreds of great generals (337 the first time it happened, I didn't check the exact number the second time).

...

Then I made a new game just to test it right away (Although I was testing in Terapack this time), and it worked as advertised. Bizarre. I'll try testing it a few more times and see if I can divine what is messing it up.

A quick test in a new game gives expected behavior, but either one of these wonders goes nuts during normal play. What's happening is that the relative difference between points required for each great person/general gets smaller and smaller as you get more and more of them. The Tomb, for example, works by adding a (Last Threshold/5) bonus to your combat experience when a general is born. When the thresholds are, say, 75 and 110, this is fine because 75*1.2 = 90, which is way less than 110. But when you get to 165 and 210, it gets dangerous because 165*1.2 = 198, which is much closer and it is entirely possible to immediately overshoot and trigger yet another general, which then triggers another bonus and yet ANOTHER general, etc, etc. The Leaning Tower has a similar problem and will also spawn hundreds of great people when the thresholds get too close to each other.

I think what needs to be done to fix it is make sure that Civ has time to re-zero your score before the bonus is applied.
 
Tried and tested Tomb of Khalid.
Indeed first few GG levels work as intended.
Using standard speed, 30, 60, 90, 120 work as intended, but after that the error came.
Busy nowadays so will look into it later, for now you may wanna disable the wonder by deleting the python codes related to it.

More or less I know why, cos the next level will be 150, but 20% of 150 = 30, 120 + 30 >= 150, so it will keep spawning GGs because the GG has not incremented to the next GG level.
 
I've been trying to hack in my own solution. I thought that applying the effect in the onEndPlayerTurn section might work. I tried this and broke the game. It doesn't work because I don't know any Python and am just guessing, but it's kind of fun experimenting:

Code:
## Tomb of Khalid ibn al-Walid Start ##
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_TOMB_OF_KHALID")) == 1:
			CombatThreshold = pPlayer.greatPeopleThreshold(true) /5
			CombatXp = pPlayer.getCombatExperience()
			if CombatThreshold > CombatXp
				pPlayer.changeCombatExperience(CombatThreshold)

It's the if CombatThreshold > CombatXp line that is killing it, according to the error log. I completely guessed at the syntax for that line, and am not shocked it didn't work. If it matters, I put this in right underneath the Cyrus Cylinder.

Anyways, the idea is to forget about using great person birth as a trigger and instead simply check at the end of the turn to see if your combat experience is below the storage threshold. This would create very nearly the same effect as originally intended, if it worked at all :p

EDIT: Was missing a colon at the end of the if statement. It works! I can't believe I muddled through that and got something that actually works :D
 
when you indent a line a colon always preceeds it

also, I don't like those variable names :( combatThreshold or iCombatThreshold and combatXp or iCombatXp, and in python true should be written True and false False. I'm just picky...

other that that, nice job :D
 
when you indent a line a colon always preceeds it

also, I don't like those variable names :( combatThreshold or iCombatThreshold and combatXp or iCombatXp, and in python true should be written True and false False. I'm just picky...

other that that, nice job :D

I've noticed that in the Python, many (but not all) variable names start with an i. I guess that's more than just decorative?

Also, I found that this works better if you move it the def onCombatResult section. I inserted it in between the Geminina's Tower and Leshn Giant Buddha blocks. This way, the script gets checked after every battle, meaning that the storage happens right away and you don't have to worry about losing points to overkill while waiting for the turn to end.

I made a similar fix for the Leaning Tower, although this one works best if placed in the def EndPlayerTurn section. For people wanting a quick and dirty fix, this is what I did:

Code:
## Leaning Tower Start ##	
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_LEANING_TOWER")) == 1:
			capital = pPlayer.getCapitalCity()
			CombatThreshold2 = pPlayer.greatPeopleThreshold(false) /4
			CombatXp2 = capital.getGreatPeopleProgress()
			if CombatThreshold2 > CombatXp2:
				capital.changeGreatPeopleProgress(CombatThreshold2)

Although you may want to take j_mie6's advice about good coding form ;) And yeah, I lazily copied the variables and just appended a '2' to the end. It also only works if the Leaning Tower is in your capital. That's the case in my current game and that's all I care about :p Plus, figuring out how to do it for real would probably take me a day.

Credit really goes to Platyping, since this was mostly me just copy/pasting bits of his code in different ways like a jigsaw puzzle until I found a combination that worked.
 
read my guide for more info, but when you name variables for follow these conventions:

the variable ALWAYS starts lower case and each subsequent word has a capital, (caps at the start is normally for class names, and it hurts my brain when I see them just lying about). normally a prefix is added to a variable (which is the first letter so is lowercase) which denotes the type of the variable, so a pointer has a p prefix (ie pPlayer) and an integer (whole number) has the i prefix. etc.

then function names are the same "hungarian notation" (the first letter not capitalised) but the prefix is going to be what it does, so a function that sets the value in a pointer starts with set (ie setName()) or if it gets a value then get (ie getGreatPeopleProgess())

So yeah, it does mean something :p some programmers put a _ instead of a capital in a variable name ie: num_cities instead of numCities. and some put a _ at the start of member variables (ones which belong to classes, but you don't need to worry about that unless you seriously plan on taking up python, not that I ever use _ :p)
 
Good job considering your first attempt at python.
However, tomb of Khalid trick will work only in standalone this way, since in BTS, the only way GG will spawn is after combat since that is the only way Combat Experience is gained.

But in Gigapack, there are other ways Combat Experience is gained, Tomb of Cyrus is an example, since it grants CE every turn naturally.

Thus, you may want to shift it back to EndGameTurn.

The unfortunate thing is that EGT will be much more taxing on game performance compared to onCombatResult or onGreatPeopleBorn, since EGT happens every turn for each player, whereas CR is triggered only when land or sea battle is fought, and the GPB is pretty obvious.

@Jamie
true and True both work
 
I know ;). however the only reason true works is because the game developers have a hidden variable:

true = True
false = False

try it outside of civ and you're in for an error :p. good convention to use True even in civ :p
 
lazy to press shift when unnecessary :mischief:
Since they did us a favour, make use of it
 
Platyping, you are so good with python. Have you ever thought of revising the worldbuilder interface or WBDesc.py so you could adjust more things with worldbuilder that you can only currently adjust with notepad/savedgames (Open Borders , memories, etc.).
 
Well, I have only bothered to mess with 2 main files, CvEventManager and CvGameUtils, although I did some alterations to others to alter movies for projects, project help tag etc.

But those are mainly minor adjustments through trial and error.
The_J would probably be the man to know more about all these, but recently he is not in the mood to do all these though...
 
Yeah, sorry, also not doing that.
Had a related idea before, but that was more fixing the WB first, i.e. you know, that GP points in cities are not saved in the WB file, that would one of the first things to do, then what you mentioned, but really, no time, no motivation :/.
 
Well, I did a simple attempt to see what is fun to play in those files.
After some trials and errors, I managed to add some extra functions for Unit Edit and City Edit.

But that's all for now I guess.
The WB is indeed lacking alot of functions such as projects and specialists, but well... those will need more explorations.
Whoever is free, feel free to continue if you like :D

P.S.
The City Defense part is not perfect due to rounding errors because of integer divisions.
 
Been awhile since I post something here :D
Since I am more or less done with World Builder, time to solve the problems.

Bugs Fixed:
1) Apadana Palace
No more production overflow in capital itself.

2) Magellan's Voyage
Changed from +1 Move and Cargo to simply +2 Move.
The cargo is a problem when unit upgrades to new unit type because it is lost.
This problem can be solved if I create a new "Magellan" promotion that grants the +1 Cargo, but I rather simplify it.

3) Tomb of Khalid
Fixed 5454366908927 Great Generals born at high levels.

4) Leaning Tower of Pisa
Fixed 5443465476 Great People born at high levels.

Standalones, Megapack and Gigapack updated.
Will look into Terapack later to see if any additions necessary beside fixing the bugs.
 
Back
Top Bottom