Simple Python Things

Okay, the most things are done.
The mod currently loads a XML file which has this
Spoiler :
PHP:
<SkriptInfo>
		<Event>
			<Attacker>CIVILIZATION_GERMANY</Attacker>
			<Defender>CIVILIZATION_FRANCE</Defender>			
			<Type>WAR</Type>
			<Map>-1</Map>
			<Date>-3920</Date>
			<Turn>-1</Turn>
			<Message>TXT_KEY_GERMANY_DECLARED_WAR</Message>
		</Event>
		<Event>
			<Attacker>CIVILIZATION_ENGLAND</Attacker>
			<Defender>CIVILIZATION_FRANCE</Defender>			
			<Type>PEACE</Type>
			<Map>-1</Map>
			<Date>0</Date>
			<Turn>2</Turn>
			<Message>TXT_KEY_PEACE_WITH_FRANCE</Message>
		</Event>		
</SkriptInfo>

as content.
You can force war or peace between 2 civs at either a specific date (ignored if 0) or at a specific turn (ignored if -1), at specific maps (events with -1 will be applied to the normal game). Both participating civs will get a popup with the mentioned message and will be locked in the current status (means they'll stay in a war if its triggered by such an event).

Are any other things needed? Defense pacts (can't be locked), forming of a team, or other things?
Currently the code will also trigger in the case it's redundant (e.g. war declaration while already at war) and give you a popup. Not sure how to deal with that. The popup doesn't have to trigger in this case, so that just the status is locked, but I'm not sure if it's always the desired thing.
 
Okay, the most things are done.
The mod currently loads a XML file which has this
Spoiler :
PHP:
<SkriptInfo>
		<Event>
			<Attacker>CIVILIZATION_GERMANY</Attacker>
			<Defender>CIVILIZATION_FRANCE</Defender>			
			<Type>WAR</Type>
			<Map>-1</Map>
			<Date>-3920</Date>
			<Turn>-1</Turn>
			<Message>TXT_KEY_GERMANY_DECLARED_WAR</Message>
		</Event>
		<Event>
			<Attacker>CIVILIZATION_ENGLAND</Attacker>
			<Defender>CIVILIZATION_FRANCE</Defender>			
			<Type>PEACE</Type>
			<Map>-1</Map>
			<Date>0</Date>
			<Turn>2</Turn>
			<Message>TXT_KEY_PEACE_WITH_FRANCE</Message>
		</Event>		
</SkriptInfo>

as content.
You can force war or peace between 2 civs at either a specific date (ignored if 0) or at a specific turn (ignored if -1), at specific maps (events with -1 will be applied to the normal game). Both participating civs will get a popup with the mentioned message and will be locked in the current status (means they'll stay in a war if its triggered by such an event).

Are any other things needed? Defense pacts (can't be locked), forming of a team, or other things?
Currently the code will also trigger in the case it's redundant (e.g. war declaration while already at war) and give you a popup. Not sure how to deal with that. The popup doesn't have to trigger in this case, so that just the status is locked, but I'm not sure if it's always the desired thing.
Wow dude this looks great, As for other things needed, I was thinking possibly the same concept but with units. Im doing a WW1 scenario, and at the time there were small revolutions in Brazil, MExico and South Afirca. So possibly have a certain unit pop up in a certain square (X,Y) every certain amout of turns?

A notification is great though, without it it might be confusing. Is there a way to toggle this though? Like an option that turns it on/off that can be asked in the begining of the game?
 
Sounds like you should include Revolutions into your mod :D.

Wow dude this looks great, As for other things needed, I was thinking possibly the same concept but with units. Im doing a WW1 scenario, and at the time there were small revolutions in Brazil, MExico and South Afirca. So possibly have a certain unit pop up in a certain square (X,Y) every certain amout of turns?

That's sure also possible (but no idea when I'll have the time to work on it).

A notification is great though, without it it might be confusing.

Normal text notification (NOT a popup) is possible. At best only for the person who owns the territory.

Is there a way to toggle this though? Like an option that turns it on/off that can be asked in the begining of the game?

Can't be done with only python. At least not persistent :/.
 
Sounds like you should include Revolutions into your mod :D.
I would if I could, can't mod DLL or python, and even if i could theres not really anything out there that is just Revolutions, it always adds other stuff

That's sure also possible (but no idea when I'll have the time to work on it).
Well if you have time that would be great, but isn't to important really, so unless you don't have anything to do i wouldn't suggest spending to much time on it


Can't be done with only python. At least not persistent :/.
It is done within the Road to war, but I would have no idea how to do it, probably requires to much modding. As an alternative I can just make two scenarios, one with it and one without it
 
It is done within the Road to war

RtW has a custom Dll.
The best what can be done with only Python is to ask the question at the beginning of every game (even if you load a save where it's disabled)....wait...maybe not...scriptData can be abused to store it, but also only per game, so it will be reseted if you start a new one.
 
RtW has a custom Dll.
The best what can be done with only Python is to ask the question at the beginning of every game (even if you load a save where it's disabled)....wait...maybe not...scriptData can be abused to store it, but also only per game, so it will be reseted if you start a new one.

seems pretty complicated, two scenarios seems like less work for the both of us:lol:
 
Okay, I've named the component "WarNPeaceScript", you can now download it here.

The download contains:
  • CvEventManager.py. The file has 4 modifications. At 2 places you have to change the path to the XML with the actual script data.
    PHP:
    WarNPeace.loadEvents("Mods/WarNPeaceScript/Assets/XML/CustomXML/WarNPeace.xml")
    WarNPeaceScript is here the name of the mod. If you merge this into your mod, you'll have to change it.
  • WarNPeace.py. You don't have to change anything here, just drop it in the same folder like CvEventManager.py
  • CustomXML\WarNPeace.xml. The data file for the events. It currently contains 3 example events:
    Spoiler :
    PHP:
    <SkriptInfo>
    		<Event>
    			<Attacker>CIVILIZATION_GERMANY</Attacker>
    			<Defender>CIVILIZATION_FRANCE</Defender>			
    			<Type>WAR</Type>
    			<Map>-1</Map>
    			<Date>-3920</Date>
    			<Turn>-1</Turn>
    			<Message>TXT_KEY_GERMANY_DECLARED_WAR</Message>
    		</Event>
    		<Event>
    			<Attacker>CIVILIZATION_ENGLAND</Attacker>
    			<Defender>CIVILIZATION_FRANCE</Defender>			
    			<Type>WAR</Type>
    			<Map>WesternEurope38X48-by-iuvavus</Map>
    			<Date>0</Date>
    			<Turn>2</Turn>
    			<Message>TXT_KEY_WAR_WITH_FRANCE</Message>
    		</Event>
    		<Event>
    			<Attacker>CIVILIZATION_ENGLAND</Attacker>
    			<Defender>CIVILIZATION_FRANCE</Defender>			
    			<Type>PEACE</Type>
    			<Map>WesternEurope38X48-by-iuvavus</Map>
    			<Date>0</Date>
    			<Turn>5</Turn>
    			<Message>TXT_KEY_PEACE_WITH_FRANCE</Message>
    		</Event>		
    </SkriptInfo>
    • Attacker and Defender have to be civs. Event will be ignored if either civ is not present at the start of the game.
    • Type: Either WAR or PEACE. The status will be locked afterwards (means if you put WAR in there, the both civs will not be able to make peace again, if PEACE they'll not be able to declare war again. Other events will override this)
    • Map: Put -1 into Map to apply events for the regular game. Else put there the map name without file extension.
    • Date: For date, put 0 if it should be ignored (turn will be taken instead), else your date (-3920 refers to 3920 B.C., 1990 would refer to 1990 AD, etc).
    • For turn, just put the turn you want it to happen. Will be ignored if set to -1.
    • Message: The text string there will appear as popup for both defender and attacker. The popup will not appear if the event is redundant (means if you script a war, and both civs are already at war, they'll not get a popup)
  • 1 text XML for the mentioned message
  • One map by Iuvavus to demonstrate the map dependency.
 
WarNPeaceScript

This mod component is a simple python mod component which allows players to script war and peace declarations into their game, depending on maps, turns or dates.

The download contains:
  • CvEventManager.py. The file has 4 modifications. At 2 places you have to change the path to the XML with the actual script data.
    PHP:
    WarNPeace.loadEvents("Mods/WarNPeaceScript/Assets/XML/CustomXML/WarNPeace.xml")
    WarNPeaceScript is here the name of the mod. If you merge this into your mod, you'll have to change it.
  • WarNPeace.py. You don't have to change anything here, just drop it in the same folder like CvEventManager.py
  • CustomXML\WarNPeace.xml. The data file for the events. It currently contains 3 example events:
    Spoiler :
    PHP:
    <SkriptInfo>
    		<Event>
    			<Attacker>CIVILIZATION_GERMANY</Attacker>
    			<Defender>CIVILIZATION_FRANCE</Defender>			
    			<Type>WAR</Type>
    			<Map>-1</Map>
    			<Date>-3920</Date>
    			<Turn>-1</Turn>
    			<Message>TXT_KEY_GERMANY_DECLARED_WAR</Message>
    		</Event>
    		<Event>
    			<Attacker>CIVILIZATION_ENGLAND</Attacker>
    			<Defender>CIVILIZATION_FRANCE</Defender>			
    			<Type>WAR</Type>
    			<Map>WesternEurope38X48-by-iuvavus</Map>
    			<Date>0</Date>
    			<Turn>2</Turn>
    			<Message>TXT_KEY_WAR_WITH_FRANCE</Message>
    		</Event>
    		<Event>
    			<Attacker>CIVILIZATION_ENGLAND</Attacker>
    			<Defender>CIVILIZATION_FRANCE</Defender>			
    			<Type>PEACE</Type>
    			<Map>WesternEurope38X48-by-iuvavus</Map>
    			<Date>0</Date>
    			<Turn>5</Turn>
    			<Message>TXT_KEY_PEACE_WITH_FRANCE</Message>
    		</Event>		
    </SkriptInfo>
    • Attacker and Defender have to be civs. Event will be ignored if either civ is not present at the start of the game.
    • Type: Either WAR or PEACE. The status will be locked afterwards (means if you put WAR in there, the both civs will not be able to make peace again, if PEACE they'll not be able to declare war again. Other events will override this)
    • Map: Put -1 into Map to apply events for the regular game. Else put there the map name without file extension.
    • Date: For date, put 0 if it should be ignored (turn will be taken instead), else your date (-3920 refers to 3920 B.C., 1990 would refer to 1990 AD, etc).
    • For turn, just put the turn you want it to happen. Will be ignored if set to -1.
    • Message: The text string there will appear as popup for both defender and attacker. The popup will not appear if the event is redundant (means if you script a war, and both civs are already at war, you'll not get a popup)
  • 1 text XML for the mentioned message
  • One map by Iuvavus to demonstrate the map dependency.


This mod component was requested by dacubz145.



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

Alchemy lab

Spoiler :
alchemylab_6W6.jpg


This mod component ads the wonder "Alchemy laboratory" to the game.

This wonder is cheaper than normal wonders in that time span and has a python effect attached: It will create a random available wonder in the city.
If no wonder is available (if everything is already built), you'll not gain anything.
It might also happen, that a wonder, which you yourself are already building in another city, gets created.
It's a bit gambling ;).


There's 1 change in the Python\CvEventManager.py file. The change is commented with "alchemy lab".
As art this mod component uses the Amethyst College by Psychic_Llamas.
The image for the button was taken from here.
This mod component was partially a request by Spillsandstains.



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

2 row religion advisor

Spoiler :
2row_religions_731.jpg


ATTENTION: Documentation of this screen is extremly poor. It's probably better to use these screens instead.

Title already says it: This screen ads a second row to the religions, so that you can fit more on the screen without making it dynamic/adding a scroll bar.
I've basically copied all the needed stuff and adjusted height + width. I did some things before i really knew what i were doing, so everything in the file itself looks like a mess, there are way to many comments, all the code is wrongly distributed...i'd not really advise anyone to use it, if he wants to make serious changes. I still want to upload it, someone might find it useful.

There are 2 variables in the file, which you can tweak if necessary:
###2 row religions - start
self.X_RELIGION_START = 140
self.DX_RELIGION = 93
###2 row religions - end
first variable determines where the icons begin at the left, the second variable determines the distances between the icons.


This mod component was a partial request by Kathy.
I did NOT make the additional religions in the screen and they are NOT in this download. They are from JARM



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

Project: Renaissance

Spoiler :
renaissance_GWo.jpg


This modcomponent adds the custom project "Renaissance" to the game. Building this project will trigger a golden age (length of GA scales automatically).

This mod component includes:
- 2 XML files: the ProjectInfos.xml for the project entry, and a text XML for the custom text
- 1 Button
- 2 Python files: CvEventManager.py and CvGameUtils.py. There is one change in each python file, and they are labeled with "Renaissance".

ATTENTION: Since there's no real value assigned to python projects, the AI will not build them. Due to that, there's a custom AI part included (the change in CvGameUtils), which will make the AI build the project under the right circumstances. But the AI will not be very smart in its decision. So please carefully monitor the AI if you add this project and adjust values if needed.
Thanks at this point to God-Emperor, who gave me a important hint here.


This mod component was done as request from el_hidalgo.

Button image and text snipped are taken from wikipedia (links are included).



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

Project: Hanseatic League

Spoiler :
hanseaticleague_3t9.jpg


This modcomponent adds the custom project "Hanseatic League" to the game. Building this project will grant a free great merchant and a free galleon with the promotions sentry and navigation 1.

This mod component includes:
- 2 XML files: the ProjectInfos.xml for the project entry, and a text XML for the custom text
- 1 Button
- 2 Python files: CvEventManager.py and CvGameUtils.py. There is one change in the CvEventManager python file and 2 changes in CvGameUtils, and they are labeled with "Hanseatic League".

ATTENTION: Since there's no real value assigned to python projects, the AI will not build them. Due to that, there's a custom AI part included (the change in CvGameUtils), which will make the AI build the project under the right circumstances. But the AI will not be very smart in its decision. So please carefully monitor the AI if you add this project and adjust values if needed.
Thanks at this point to God-Emperor, who gave me a important hint here.


This mod component was done as request from el_hidalgo.

Button image and text snipped are taken from wikipedia (links are included).



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

StartingPopup
StartingPopup: Civ specific



Spoiler :
startingpopup_0oJ.jpg


It has been several times been requested: This is a simple example how to add a popup at the beginning of a mod, directly after the dawn of men screen.

There's one change in CvEventManager.py, search for "starting popup".
One XML file is included for the example text.



Promotion: Barbar hunter
Promotion: Hunter


Spoiler :

barbar_hunter_GZf.jpg


hunter_MCb.jpg


These mod components ad a promotion to the game, which allows units to gain experience through fights against barbarian/animal units, even after they reached the 5XP limit for fight against animals/10XP against barbarians. The promotions will also be used by the AI under certain circumstances.

The download includes besides the PromotionInfos.xml and text XML for the promotion entry the CvEventManager.py with 2 changes (labeled with hunter / barbar hunter) and the promotion button (out of this pack by Rabbit, White).

In the modified sections there are 2 things mentioned which influence the AI: TRAIT_AGGRESSIVE , as well as BUILDINGCLASS_GREAT_WALL for barbar hunter. You have to change these entries if you removed them in your mod.

guidelines for AI decissions:
Spoiler :
AI will pick the promotion if:
- not "no barbarians" is activated
- the current player era still allows animals/barbarians
- the unit is on a plot owned by the AI or on a neutral plot (so no dumb picking during a city siege)
- the unit level is below 8 (so not wasting a possibility for combat V or Blitz)
- and picking the promotion is really valid
Then a dice is rolled, and picking gets more likely if raging barbarians is activated or the player is aggressive. In case of the barbar hunter, it gets less likey if the player has the great wall


These mod components were requested by hrochland.

In case people are interested in similar mod components, they should take a look at Basic Barbarian Great General Experience.
 
:think: :think: :think: phew...
I assume that's possible. Theoretically you can catch when the colony is created via onVassalState (with additional checks), and in case there's at least one slot free, you could then add another player to the game, transfer all the vassal stuff to the new player and kill the original vassal. I already have the transfer code lying around (due to something else), so that should not be a problem. Creating the screens for selection of the new civ/leader and naming them is another thing, because screens (or in general everything which needs custom graphical stuff) are not easy. Also not sure if naming can be done. Might also be that you then first meet the original vassal before you can choose a new one (but that could be explained).

tl;dr version: That's not a 5 minute job. I'll take a look at it, but don't expect anything in the next time (at least not this week).
 
Did a small request in between:

Promotion: Barbar hunter
Promotion: Hunter


Spoiler :

barbar_hunter_GZf.jpg


hunter_MCb.jpg


These mod components ad a promotion to the game, which allows units to gain experience through fights against barbarian/animal units, even after they reached the 5XP limit for fight against animals/10XP against barbarians. The promotions will also be used by the AI under certain circumstances.

The download includes besides the PromotionInfos.xml and text XML for the promotion entry the CvEventManager.py with 2 changes (labeled with hunter / barbar hunter) and the promotion button (out of this pack by Rabbit, White).

In the modified sections there are some things to change.
First, the 5XP animal cap/10XP barb cap can't be read in Python from the globalDefines.xml, so if you changed that in your mod, you'll have to change it here. Also TRAIT_AGGRESSIVE will influence the AI, as well as BUILDINGCLASS_GREAT_WALL for barbar hunter.

guidelines for AI decissions:
Spoiler :
AI will pick the promotion if:
- not "no barbarians" is activated
- the current player era still allows animals/barbarians
- the unit is on a plot owned by the AI or on a neutral plot (so no dumb picking during a city siege)
- the unit level is below 8 (so not wasting a possibility for combat V or Blitz)
- and picking the promotion is really valid
Then a dice is rolled, and picking gets more likely if raging barbarians is activated or the player is aggressive. In case of the barbar hunter, it gets less likey if the player has the great wall


These mod components were requested by hrochland.

In case people are interested in similar mod components, they should take a look at Basic Barbarian Great General Experience.
 
In the modified sections there are some things to change.
First, the 5XP animal cap/10XP barb cap can't be read in Python from the globalDefines.xml, so if you changed that in your mod, you'll have to change it here.

You should be able to get these values using
gc.getDefineINT("ANIMAL_MAX_XP_VALUE")
and
gc.getDefineINT("BARBARIAN_MAX_XP_VALUE")
 
Nice name, barbar hunter :lol:

Although for normal BTS, combining both would be better since animals and barbs are gone pretty fast, using 2 promotions for them seems a waste. However, since it is a request, I guess he has something in mind
 
You're welcome :).

You should be able to get these values using
gc.getDefineINT("ANIMAL_MAX_XP_VALUE")
and
gc.getDefineINT("BARBARIAN_MAX_XP_VALUE")

*facepalm* I knew that was somewhere.
-> Thank you :). Will fix it later.

Nice name, barbar hunter :lol:

Although for normal BTS, combining both would be better since animals and barbs are gone pretty fast, using 2 promotions for them seems a waste. However, since it is a request, I guess he has something in mind

Seems so, from what I can read from the above post.

In general I agree with you, but for someone who merges the stuff in, it should not be a problem to connect both to the same promotion :).
 
You should be able to get these values using
gc.getDefineINT("ANIMAL_MAX_XP_VALUE")
and
gc.getDefineINT("BARBARIAN_MAX_XP_VALUE")

Fixed :).

hey do you think you could make a feature that allows you to name your colony when you create it and maybe choose the civ and leader that will follow?

Spoiler :

attachment.php


attachment.php


attachment.php


attachment.php


attachment.php


Issues:
- You first meet the original vassal
- This doesn't work in MP
- Doesn't work if the vassal is already the last possible Civ

Code is also still a bit buggy and not totally up to date. Haven't looked into naming the vassal yet.

Design things about which we have to think: Should only be civs + leaders available, which are not in the current game? Or should all be available? Unrestricted combinations (like here Bismarck of Babylonia), or only the by the game given combinations?
 

Attachments

  • colonies_original_situation.jpg
    colonies_original_situation.jpg
    99.7 KB · Views: 154
  • colonies_met_alex.jpg
    colonies_met_alex.jpg
    100.3 KB · Views: 175
  • colonies_choosing_civ.jpg
    colonies_choosing_civ.jpg
    129.1 KB · Views: 165
  • colonies_choosing_leader.jpg
    colonies_choosing_leader.jpg
    116.5 KB · Views: 159
  • colonies_situation_afterwards.jpg
    colonies_situation_afterwards.jpg
    103.4 KB · Views: 203
Did a small request in between:

Promotion: Barbar hunter
Promotion: Hunter


Spoiler :

barbar_hunter_GZf.jpg


hunter_MCb.jpg


These mod components ad a promotion to the game, which allows units to gain experience through fights against barbarian/animal units, even after they reached the 5XP limit for fight against animals/10XP against barbarians. The promotions will also be used by the AI under certain circumstances.

The download includes besides the PromotionInfos.xml and text XML for the promotion entry the CvEventManager.py with 2 changes (labeled with hunter / barbar hunter) and the promotion button (out of this pack by Rabbit, White).

In the modified sections there are some things to change.
First, the 5XP animal cap/10XP barb cap can't be read in Python from the globalDefines.xml, so if you changed that in your mod, you'll have to change it here. Also TRAIT_AGGRESSIVE will influence the AI, as well as BUILDINGCLASS_GREAT_WALL for barbar hunter.

guidelines for AI decissions:
Spoiler :
AI will pick the promotion if:
- not "no barbarians" is activated
- the current player era still allows animals/barbarians
- the unit is on a plot owned by the AI or on a neutral plot (so no dumb picking during a city siege)
- the unit level is below 8 (so not wasting a possibility for combat V or Blitz)
- and picking the promotion is really valid
Then a dice is rolled, and picking gets more likely if raging barbarians is activated or the player is aggressive. In case of the barbar hunter, it gets less likey if the player has the great wall


These mod components were requested by hrochland.

In case people are interested in similar mod components, they should take a look at Basic Barbarian Great General Experience.

Into caveman 2 Cosmos these two go, there are animals to hunt even in the Renaissance and later years. And subdued ones are very useful even then.
 
Spoiler :

attachment.php


attachment.php


attachment.php


attachment.php


attachment.php


Issues:
- You first meet the original vassal
- This doesn't work in MP
- Doesn't work if the vassal is already the last possible Civ

Code is also still a bit buggy and not totally up to date. Haven't looked into naming the vassal yet.

Design things about which we have to think: Should only be civs + leaders available, which are not in the current game? Or should all be available? Unrestricted combinations (like here Bismarck of Babylonia), or only the by the game given combinations?

I love this idea, but why when you make contact with it? Why not right away since you wouldnt put a government in charge and then throw it out right away, also what if you vassalize a country? (if thats a word) via war or just regular, could you change it then?

Also anyway you can make it available you can make any group of cities available to become a colony? Sometimes i feel like i want to make a colony but civ wont let me:mad:
 
Because I guess it was defined under FirstContact?
Unlike SDK, there are alot of restrictions to what, when, where, how things can be done in python.

P.S.
I believe Barbarian leader shouldn't be a choice to take over your colony lol
Also, seeing that Alexander is still on the list of choices, does that mean that existing leaders of other civs are still in the list?
 
Into caveman 2 Cosmos these two go, there are animals to hunt even in the Renaissance and later years. And subdued ones are very useful even then.

Wonderful :).

I love this idea, but why when you make contact with it? Why not right away since you wouldnt put a government in charge and then throw it out right away, also what if you vassalize a country? (if thats a word) via war or just regular, could you change it then?

Because I guess it was defined under FirstContact?
Unlike SDK, there are alot of restrictions to what, when, where, how things can be done in python.

Technical restriction :yup: :(.
With Python I can't hook into the code before the vassal is created (which would be needed here), only afterwards, that's why you first see it.

While thinking about it...maybe I can see where the popup to liberate cities is created, and if it allows to influence anything :think:...but I'd not put high hopes into it.
The proper solution here would be a SDK solution, but that's then again not my bussiness :/.

Also anyway you can make it available you can make any group of cities available to become a colony? Sometimes i feel like i want to make a colony but civ wont let me:mad:

That's all in the SDK, AFAIK.
Might be that this can be overridden with a custom button...:think:...but since the restrictions are all the same for every player, it would give the human player an unfair advantage.

P.S.
I believe Barbarian leader shouldn't be a choice to take over your colony lol
Also, seeing that Alexander is still on the list of choices, does that mean that existing leaders of other civs are still in the list?

Currently everything is on the list (on the bottom of the civ list you could also see "barbarian empire"), since I first had problems with the buttons (you can only identify the button which was pressed, not which value it has, so leaving out existing civs caused first a problem, but now I see that I have to kick out the existing civs just twice, at both sides of the function).
But the question is: Allow existing civs/leaders or not (certainly not the mentioned barbarians)?
 
Back
Top Bottom