Simple Python Things

Should it only be buildable in cities with more then 6 religions?
The attitude effect is not difficult, and the other parts are xml, so it's doable. I hope, i'll have some time this week, my RL will get busy from thursday on :(.



-----------------------------------------------------------

Re-uploaded the obsolete corporations modcomp.
- Fixed a bug, which led to the weird effect, that corporations without an obsolete technology directly became obsolete after founding. Thanks to Kathy for finding the bug :).


---------------------------------------------------------

2 ideas came to my mind yesterday, and they were easy done :):

Real OCC

This modcomp will allow you to play a one city challenge, where also all AI civs can only found one city.

If the occ gameoption is activated, then
- the ability to build settlers is disabled
- and the city founding after the first city also
- and it forces auto razing every city




For modders:
There are 2 changes in the CvGameUtils.py, and one change in the CvEventManager, all labeled with "real occ".
If you merge it, don't forget the XML\PythonCallbackDefines.xml, where the CannotTrain callback has to be set to 1.


--------------------------------------------------------

Real Always War

When you activate the "always war" option in this simple modcomp, then really every civ will be at war with every other civ, and not only with the human player, and they will also not be able to sign peace.


For modders:
There's only a small change in CvEventManager, labeled with "real always war. Nothing more.
 
The_J, I have a few other requests for your Circus Hagenbeck wonder. I'm also thinking of using it as a Olympics Wonder, and want it to move around. The only thing is I don't want a set year, as gamespeeds can really mess with what year things happen. I would like the Olympics to appear afters at least 1 player has research Tech X. (X being whatever I choose.) Also, is it possible to make the building appear for 1 turn in a random city, disappear for 2 turns, appear in a new location for 1 turn, disappear, ... repeating (like the Olympics does.)

If you could show me how to do that, I would be grateful.
 
wow the_j, its been a while huh?..

youve done some really really awesome codes here

Thank you :).

The_J, I have a few other requests for your Circus Hagenbeck wonder. I'm also thinking of using it as a Olympics Wonder, and want it to move around. The only thing is I don't want a set year, as gamespeeds can really mess with what year things happen. I would like the Olympics to appear afters at least 1 player has research Tech X. (X being whatever I choose.) Also, is it possible to make the building appear for 1 turn in a random city, disappear for 2 turns, appear in a new location for 1 turn, disappear, ... repeating (like the Olympics does.)

If you could show me how to do that, I would be grateful.

Oh, the Olympics, also great idea.

To be tech-depended, i would create a global bool variable, which is changed to true after researching the tech and check in the movement code for it.

mmmhh, so add "HasResearchedOlympicsTech = False" to the top (under gc = CyGlobalContext(), somewhere there), and after onTechAcquired
PHP:
if iTechType == gc.getInfoTypeForString("TECH_XY"):
    HasResearchedOlympicsTech = True

and in the current movement code instead of (CyGame().getTurnYear(iGameTurn)>=1890) add HasResearchedOlympicsTech.



To make it disappear for some time, the movement code would have to be split up.
You would have to take the part after if self.oldcity <>[-1,-1]: out of the current function, instead add another global variable (err....WonderHasBeenSet = False), set it to True (instead of if self.oldcity <>[-1,-1]: and the following code there), add another check in onBeginGameTurn to check, if WonderHasBeenSet == True, then the self.oldcity <>[-1,-1]: and change WonderHasBeenSet = False.


Erm...i guess, that's not really good understandable. I'll try to code it tomorrow (i hope, i'll find some time).
At the moment i have a generall time problem, i even don't know, when to do the request by hrochland (sorry). I hope, the situation will be better in 2 or 3 weeks :/.
 
Don't be so enthusiastic, it'll probably last some weeks, until i can do it :(. I'm really lacking time :(.


Spawn A Civ

This modcomp allows you to spawn a civ dynamically triggered by technologies during the game :).

Explanation from my readme:

Spoiler :

Parts of the modcomp:
All files in Assets\Python and Assets\XML\CustomXML\CIV4SpawnCivInfos.xml are parts of this modcomp. All other files belong to the huns civ by cool3a2 and are just in here, to show a good example for a special case.

CvEventManager: There are 4 parts, which have to be merged. All are labeled with "spawn a civ".
(all changes in all python files are labeled like this).
In 2 parts you have to change the path to YOUR MODS CustomXML folder.
For example, the current line is MyFile=open("Mods/SpawnACiv/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml").
If i would merge this in my mod "marsjetzt-v03", i would have to change it to
MyFile=open("Mods/marsjetzt-v03/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml").

SpawnCivUtil: You don't have to change anything here!
(only, if you removed TERRAIN_TUNDRA, TERRAIN_SNOW or TERRAN_DESERT from your mod.
These terrains are named to indicate, which plot is crap for a city. If you have
complete other terrain, then just put in your crappy terrain).

Python\Screens:
The scoreboard and the foreign advisors are changed for the special case of a barbarian civ. These civs should not appear on the scoreboard and in the foreign advisor and this had to be changed. This is just esthetical and is not essential. If you have problems with merging it, then just don't do it.

XML\CustomXML\CIV4SpawnCivInfos.xml: This is a self written file, which is manually loaded my a self written simple XML parser. You can put all your information in here.
There's no schema, so i'll explain it.

<Type>CIVILIZATION_HUNS</Type>: The civilization, which should appear.

<Leader>LEADER_HUNS_Attila</Leader>: The leader for the civ.
Note 1: You can put every leader together with every civ and create nonsense combinations like for example LEADER_ASOKA and CIVILIZATION_SPAIN.
Note 2: If you put in -1 instead of LEADER_XY, the algorithm will choose a random leader from the civ. So if you have CIVILIZATION_AMERICA, you'll get randomly Lincoln, Washington or Roosevelt.

<SpawnTech>TECH_CONSTRUCTION</SpawnTech>: The technology, which spawns the civ.
<NumberOfSpawnTech>3</NumberOfSpawnTech>: So many civs must have the SpawnTech.
Note: If NumberOfSpawnTech is smaller then 1, the first tech will trigger the civ.

<IsBarbarianCiv>True</IsBarbarianCiv>: If set to True, the civ will be at war with
everyone, can't do any diplomacy, is blocked from the foreign advisor and the scoreboard.
Issues:
1) The civ appears in the espionage and the military advisor.
2) You'll get diplomacy bonuses to other civs for having war with this civ.
3) You'll get war weariness for fighting this civ. The war weariness is half of the normal ww.

To make it more clear to the player, that this civ is barbarian,
i suggest that you give the "barbarian" leader the skull button from the barbarians and
add a (barbarian) to civ and leader name.

<StartAtCoast>False</StartAtCoast>: If set to True, all cities will be at the coast.

<TotalGold>100</TotalGold>: With how much gold the civ starts.

<DefaultShips>NONE</DefaultShips>: With what ships the civ starts.
<NumberShipsPerCity>0</NumberShipsPerCity>With how many ships of this type the civ starts.
Notes:
1) -1 and NONE in DefaultShips will give you no ship.
2) only cities at the coast will start with ships.
3) A number below 1 will not produce an error, you'll just get no ship.

<NumberOfCities>2</NumberOfCities>: With how many cities the civ starts.
Note: My city placement algorithm is not very good. It will probably spread the cities
over the whole map, so it's better to let the civ start with a small number of cities.
This will have to be fixed in future versions.

<NumWorkerPerCity>1</NumWorkerPerCity>: How many workers should be in the city.
Note: Worker UUs are not considered here, the civ will start with a normal worker.

<DefaultCityDefender>UNIT_HORSE_ARCHER</DefaultCityDefender>: What units should be in the cities?
<NumberCityDefendersPerCity>4</NumberCityDefendersPerCity>: How many of these units?

Notes:
1) NONE in DefaultCityDefender will give you no units.
2) -1 in DefaultCityDefender will give you the best conscriptable unit which is available for the civ.
(attention: There are no units conscriptable between warrior and rifleman, so if you use that, you should
make some other units conscriptable)
3) A number below 1 in NumberCityDefendersPerCity will not produce an error, you'll just get no units.

<DefaultSecondUnit>-1<DefaultSecondUnit>
<NumberSecondUnit>2</NumberSecondUnit>: Same as above.


Other notes:
1) A typo in the XML file will probably directly lead to a crash and will not produce a python exception
(i don't know why :/ ).
2) The new civ starts with all the technologies from the civ, by which it's triggered.





Credits:
cool3a2 for the huns civ, and all the artists who have contributed to the civ:
- Ekmek for the animated LH
- Bakuel for unit art, GeoModder and Walter Hawkwood for citystyle
- strategyonly for the files the flag and the button are based on and for finding that horrible bug
- Aranor for the units the tarkan is based on
- Terror666 for the units' sounds

Also credits go to alpha civ for helping me with some basic and essential python things, and to EmperorFool and davidlallen, who have commented on my approaches for reading the xml file via python (which i didn't use in the end...).



If anybody wonders, how this goes together with my lack of time: This was a WIP for more than a month i guess, and i've fixed only a bug today.
 
^I think that seems like one of your most complicated codes yet. At least in concept. It's like an alternative to Revolution for modders who don't want to bother with the SDK.

So, in other words, good job! :D
 
For some reason, the pioneer tank doesn't quite work for me. Everything seems fine except an actual hill never appears. The tank can't attempt another hill, and when you mouseover, it says, "Create Hill" rather than "Plains" or "Tundra". I've got the Python code precisely as you have it in the "for modders", as well as all the other changes to the XML files. Is there maybe something in 3.19 that broke it?
 
Like always, i forgot to mention some things :blush::
- You need a free civ slot to let a civ appear. There's no built in mechanism to kill a civ at the start, so if you start with 18 civs and don't kill one, you'll see no effect.
- I've added a check for existing civilizations, so that you don't get double civs. CIVILIZATION_RUSSIA will not spawn, if already russia is present in the game.
- The random leader option doesn't work, if the leader is modular.


^I think that seems like one of your most complicated codes yet. At least in concept. It's like an alternative to Revolution for modders who don't want to bother with the SDK.

So, in other words, good job! :D

Thanks :D.
I haven't thought in this direction, but you're right, it can be an alternative, but it can also be used together with revolutions.

Btw: Tholish has done an only python version of barbarian civ ;).

For some reason, the pioneer tank doesn't quite work for me. Everything seems fine except an actual hill never appears. The tank can't attempt another hill, and when you mouseover, it says, "Create Hill" rather than "Plains" or "Tundra". I've got the Python code precisely as you have it in the "for modders", as well as all the other changes to the XML files. Is there maybe something in 3.19 that broke it?

No, 3.19 didn't break anything here, it still works in my own mod.
Are you really sure, that you've merged all the xml files (BuiltInfos, ImprovementInfos and UnitInfos/UnitClassInfos)?
 
Heres the situation:

I started in an different ERA and then changed the civic to Serfdom and if you look at the pic it says i founded a new militia, BUT no militia shows up?? And it worked ok before i changed to this new WB ERA map.

I have pics of the info area thats says i have a militia, also, a pic that says it was in the Serfdom civic.:crazyeye:
 
You have to add it in then. The python defines the militia unit recieved by era:

Code:
                        if (pPlayer.isCivic(serfdom)==True):
                                era = pPlayer.getCurrentEra ()
                                if (era == gc.getInfoTypeForString( "ERA_MEDIEVAL" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_MEDIEVAL' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                elif (era == gc.getInfoTypeForString( "ERA_RENAISSANCE" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_RENAISSANCE' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                elif (era == gc.getInfoTypeForString( "ERA_INDUSTRIAL" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_INDUSTRIAL' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                elif (era == gc.getInfoTypeForString( "ERA_MODERN" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_MODERN' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
 
Hey, I was thinking of using the Circus Hagenbeck code as a basis for the modern Olympics. How much control do you have over the selection of cities that the Circus goes to?
 
Actually, I have a question about the SpawnCiv.

Let's say I make an existing vanilla civilization, say America, spawn with the Democracy tech. If there was already an America civ from the beginning of the game, what will happen? Will there be two America civs now, or will the program crash?

The reason I'm asking this is because I'm thinking maybe it's possible to mimic the civ-spawning in Rhye's and Fall, except this time instead of it being based on a certain turn a civ spawns, its based on technology.
 
I don't think it would spawn. The_J thought of that already, in the other thread.
 
No, 3.19 didn't break anything here, it still works in my own mod.
Are you really sure, that you've merged all the xml files (BuiltInfos, ImprovementInfos and UnitInfos/UnitClassInfos)?

I definitely merged them. However, I merged the python with "next war" using winmerge and am wondering if the code has to happen at a certain time, or can it be inserted anywhere?
 
Hey, I was thinking of using the Circus Hagenbeck code as a basis for the modern Olympics. How much control do you have over the selection of cities that the Circus goes to?

At the moment the selection is completly random, but that can be changed.
Affores has already asked, if it can be restricted by citysize, and that's not the only thing. You could also check for culture, wonders, buildings, happiness, etc.
Off what do you think exactly?

Actually, I have a question about the SpawnCiv.

Let's say I make an existing vanilla civilization, say America, spawn with the Democracy tech. If there was already an America civ from the beginning of the game, what will happen? Will there be two America civs now, or will the program crash?

The reason I'm asking this is because I'm thinking maybe it's possible to mimic the civ-spawning in Rhye's and Fall, except this time instead of it being based on a certain turn a civ spawns, its based on technology.

I don't think it would spawn. The_J thought of that already, in the other thread.

I've also mentioned it in this thread ;).
A civ does not appear, when it's already present in the game, but there is a chance, that it could re-appear after it has been defeated.

But technically it would be no problem to have more than one instance of a civ in the game. Multiple civs of the same type can be done without any problem.


BtW, had the same idea like you cybrxkhan, but not the time to do it.
I also have another WIP here, which would just fit perfect (changing civ leaders, dependend on year), and an idea, which will hopefully also work (but also didn't have the time for it).
But if you want to take it, i'll not be offended ;).

I definitely merged them. However, I merged the python with "next war" using winmerge and am wondering if the code has to happen at a certain time, or can it be inserted anywhere?

WinMerge should have placed it at the right point, and it has to be there.
It seems, that i do not really understand, what exactly the problem is. Could you please post a screenshot?
 
Top Bottom