Simple Python Things

Just to say: Works .
The popup which asks which cities should be liberated is sadly in the .exe, but I can hook in the code before and create such a screen myself. That does already work .

That is great. Don't worry about the naming thing its fine i dont really need it anyways but what you have done is awesome.
 
Updated the "Water" modcomp (wrong art defines of the well; had already been pointed out long ago by stolenrays I think, but forgot to fix it), and the circus (platyping mentioned a bug in the onGameStart function (wrong variable), and also said that it should be better under onLoadGame; the thing still worked, but the old circus was not removed if the game was loaded).

Out of ideas already, the rest of my WIP are basically simple ones waiting for a name, or logic errors waiting to be solved. Keeping one last idea for a Singapore Wonder though :D

Oh, I suspect you're lying and that you have a ton of ideas somewhere stored :D.

That is great. Don't worry about the naming thing its fine i dont really need it anyways but what you have done is awesome.

:)
Just looked into it again, can't see a Python function to name a player, it's probably not exposed :(.

Else it's now working, known leaders and civs are not anymore displayed.

But I'll change the whole thing a bit. As default you'll get only a leader selection screen, and the leader will automatically get the right civ. In case someone activated the "unrestricted leaders" option, I'll also let the civ selection screen appear, and I'll make this also available via a small variable in the script for the normal game (just in case someone likes it better). I'll also add a small option to make every city a colony, not only if there are at least 3 cities on that island (but that only counts for the human, so it's an unfair advantage; will be disabled by default).


Oh, another question, does anyone know which prerequisite is needed to make only 2 cities on an island a colony? I know that this is the case on Archipelago (and already considered), but can there be other circumstances under which it is possible?

And WTH does gc.getDefineString("BARBARIAN_LEADER") result in "None" (should be LEADER_BARBARIAN, it's a text value), but gc.getDefineINT("BARBARIAN_LEADER") results in 0 (which is the correct INT value, but it shouldn't be there :confused:).
:crazyeye: :mad:
 
Download

Description and image:
Spoiler :

This mod component allows you to choose who you want to be the leader of your colonies.
After you hit the liberation button on the popup, you'll get a list of all the civ leaders (besides the ones which you have already met), and can decide who you want to have.
In case that the unrestricted leaders options is activated you'll also be able to choose which civilization your colony should be.
This mod component is only valid for the human player, the AI will NOT get the same options.

Problems:
- Does not work in MP. In MP the normal colony option will be active.
- The +10 attitude for liberating is not available via Python. You'll instead get +10 for past events.

Options:
- In the choosingColonies.py you have the variable bUnrestrictedLeaders. If you set it to True (default is False), you'll always be able to choose additionally the civilization.
- If you set the variable bEverythingColony to True (default is False), you'll also be able to create colonies out of 1 city islands.


There are 4 files in the download:
- A text XML with the custom text
- Python\choosingColonies.py with most of the custom code. Nothing to change here, besides the mentioned variables above. Just drop that file in the Python folder.
- Python\entryPoints\CvScreensInterface.py with 3 changes, all labeled with "choosing colonies"
- Python\Screens\CvDomesticAdvisor with 3 changes, all labeled with "choosing colonies".


colony_chooseleader_7eU.jpg




---------------
Edit, not to 100% related to above:
I had the problem with the random crashes while loading a game after liberating a colony. Some people know that, is probably the same bug like the crash to desktop if you try to go back to the main menu, and loading crashes have already been connected to "too much" custom Python code..
The issue here seems to be that the internal Python garbage collection is too slow/not triggered at the right point. After adding additional lines which trigger the garbage collection the crash problem seems to be gone. I hope this does not interfere with anything else :scared:.
 
I absolutely love this idea, but it did not work to well when placing it into my mod. Only one python thing needs to be "modded" (the rest copy and pasted the whole py doc) so i doubt it was a user error

So first problem i see ( i should mention I made both options true) once you have a city island, if its near another city island they can't be given independence together, not a big problem but still something to thing about

The screens then worked increadibly well, i have idk maybe 100 civs and 300 lh? not sure really but alot and they all fit on the screens

Next i got the python error as you see, and next turn, game crashed

any ideas?? I dont have to much pyuthon, just mostly sevopedia and platypings wonders
 

Attachments

  • Civ4ScreenShot0041.JPG
    Civ4ScreenShot0041.JPG
    155.4 KB · Views: 70
  • Civ4ScreenShot0042.JPG
    Civ4ScreenShot0042.JPG
    138.9 KB · Views: 99
  • Civ4ScreenShot0043.JPG
    Civ4ScreenShot0043.JPG
    108.8 KB · Views: 117
I absolutely love this idea

Thanks :).

@ one tile islands: Combining some together would be not that easy. I'd have to manually think about which might be close or not, and then...how far is close? 2? 10? 20?

@ popup size: Thanks again :D, but the game does this alone, no work from my side.

@error: The error appears at the code part, where the units in the new civs cities are placed. This part uses the best conscriptable unit, which could be the error here. Do you have at that point already units which can be conscribed? Because I haven't added a check if there's no possibility to conscript one, due to the fact that in vanilla BtS you can theoretically conscript warriors (so there's always a conscript unit).

Oh, and :lol: @Bush of the Pakistanies.
 
Thanks :).

@ popup size: Thanks again :D, but the game does this alone, no work from my side.

@error: The error appears at the code part, where the units in the new civs cities are placed. This part uses the best conscriptable unit, which could be the error here. Do you have at that point already units which can be conscribed? Because I haven't added a check if there's no possibility to conscript one, due to the fact that in vanilla BtS you can theoretically conscript warriors (so there's always a conscript unit).

Well there is a rifleman unit, which my civ had
 
mmhh...could you test-wise add another message to the code?
After
PHP:
CyInterface().addMessage(iHumanPlayer,false,50,CyTranslator().getText("TXT_KEY_MISC_EMPIRE_SPLIT",(sName,sVassalCiv,sVassalName)),'',0,"",ColorTypes(gc.getInfoTypeForString("COLOR_CYAN")),loopCity.getX(),loopCity.getY(), True,True)

please add:
PHP:
CyInterface().addMessage(iHumanPlayer,false,50,"conscript type: "+str(loopCity.getConscriptUnit ()),'',0,"",ColorTypes(gc.getInfoTypeForString("COLOR_RED")),loopCity.getX(),loopCity.getY(), True,True)

That should give you ingame another message with the type of the conscript unit. Should be everything besides -1 (hopefully).
 
mmhh...could you test-wise add another message to the code?
After
PHP:
CyInterface().addMessage(iHumanPlayer,false,50,CyTranslator().getText("TXT_KEY_MISC_EMPIRE_SPLIT",(sName,sVassalCiv,sVassalName)),'',0,"",ColorTypes(gc.getInfoTypeForString("COLOR_CYAN")),loopCity.getX(),loopCity.getY(), True,True)

please add:
PHP:
CyInterface().addMessage(iHumanPlayer,false,50,"conscript type: "+str(loopCity.getConscriptUnit ()),'',0,"",ColorTypes(gc.getInfoTypeForString("COLOR_RED")),loopCity.getX(),loopCity.getY(), True,True)

That should give you ingame another message with the type of the conscript unit. Should be everything besides -1 (hopefully).

Alright give me 20 min to do it because i had to take it out since i wanted to update my mod, ill put it back in since i really want this
 
:yup: because the civ can't conscript anything, which causes the error, because the code tries to create the unit with the number -1...which doesn't exist.

-> you should probably take a look at the XML (because at least the warrior should be conscriptable), and I'll see if I can add tomorrow some sort of code which will prevent that unusual situation.
 
:yup: because the civ can't conscript anything, which causes the error, because the code tries to create the unit with the number -1...which doesn't exist.

-> you should probably take a look at the XML (because at least the warrior should be conscriptable), and I'll see if I can add tomorrow some sort of code which will prevent that unusual situation.
So you will just create something in xml that will prevent that? Thanks:goodjob: but if it requiers a change in DLL, edit the one from my mod since i can;t do dll
 
So you will just create something in xml that will prevent that? Thanks:goodjob: but if it requiers a change in DLL, edit the one from my mod since i can;t do dll

I'll add some more Python code to the script.
Just another check, in case that no unit can be conscribed, I'll just let the code iterate over all units to see which one is the best available.
 
I'll add some more Python code to the script.
Just another check, in case that no unit can be conscribed, I'll just let the code iterate over all units to see which one is the best available.

That would make the most sence, I assumed that the new colony did that anyway, but onvoiusly not
 
If this is returning -1, then drafting probably won't work in your mod either (assuming you have a civic that allows it). Neither will the partisans event (that can give a player a few free units if their city is razed, after they get the prereq tech of Nationalism, in regular BtS). I can't think of any, but it may be used for other things too. It will also cause errors in at least one of the BUG domestic advisor screens (which tries to get the current draft unit for each of your cities, but also has no check to make sure it did not return -1 before using the number to try and get the unit info).

In regular BtS, all of the melee units and all of the gunpowder units have iConscription set to something higher than 0.

We ran into this in Final Frontier Plus during the BUG merge because the only units that can be drafted are the 3 generations of the Planetary Defense Ship class units but most civilizations don't start with the tech to build the first generation of those (it is a first tier tech with no prereqs so it doesn't take very many turns before everyone has it). So now the FFP version of the BUG file with the problem (CvCustomizableDomesticAdvisor.py, the calculatePotentialConscriptUnit function; also the one after it could also use the fix but it doesn't cause problems in FFP since by the time you can get the civic that actually allows you to conscript something there is such a unit that you can build) and CvRandomEventInterface.py (probably every function with the word Partisan in its name) actually check first.

By the way, there is a getConscriptUnitType callback to override the usual selection.
 
If this is returning -1, then drafting probably won't work in your mod either (assuming you have a civic that allows it). Neither will the partisans event (that can give a player a few free units if their city is razed, after they get the prereq tech of Nationalism, in regular BtS). I can't think of any, but it may be used for other things too. It will also cause errors in at least one of the BUG domestic advisor screens (which tries to get the current draft unit for each of your cities, but also has no check to make sure it did not return -1 before using the number to try and get the unit info).

In regular BtS, all of the melee units and all of the gunpowder units have iConscription set to something higher than 0.

We ran into this in Final Frontier Plus during the BUG merge because the only units that can be drafted are the 3 generations of the Planetary Defense Ship class units but most civilizations don't start with the tech to build the first generation of those (it is a first tier tech with no prereqs so it doesn't take very many turns before everyone has it). So now the FFP version of the BUG file with the problem (CvCustomizableDomesticAdvisor.py, the calculatePotentialConscriptUnit function; also the one after it could also use the fix but it doesn't cause problems in FFP since by the time you can get the civic that actually allows you to conscript something there is such a unit that you can build) and CvRandomEventInterface.py (probably every function with the word Partisan in its name) actually check first.

By the way, there is a getConscriptUnitType callback to override the usual selection.
So if i change iConscription to 1 will it work?
 
If you do it for some set of units such that there is always at least 1 type available then yes, it would solve that problem.

didn't think it would be that easy but sounds easy enough,
beside that, what does that xml toggle? If I set a unit to 1 does it do anything else?
 
Interesting.

If iConscription is set for the usual units then, for some reason, that new civ can't actually train any unit type that is conscriptable in the city in question. It could be something in the cannotTrain callback. (I'm running out of ideas, especially since I haven't actually looked at the code...)

By the way (general note for every moder reading this): checking the DLL's code for CvCity::getConscriptUnit indicates that the Modiki is wrong. The iConscription value isn't the number of units of that type that can be conscripted, it is the priority of that type. It picks the unit with the highest iConscription value that it can actually build (going with the one that is first in the file if there is a tie).
 
Back
Top Bottom