Part 10
Events - basic with details


Please take a look at the file attached.
It is best to open it in notepad++, then different sections should be in different colors.

Below I'll try to explain every line or section of this event.
Wish me luck.

This is a comment line, which is not visible by the game engine. Usually I'm using those as a short description of what is happening in the section of the event.

Code:
<event eventID="19001"
This is event ID, in every scenario each event needs to have it's own ID, it is suggested to create own events list and write ID's already used.

Code:
countryID="1"
This one describes for which country the event will be triggered, in other words who will make a choice or click 'OK' button. I used '1' because this event is for Poland.

Code:
visibleByPlayer="0"
This one is connected with the previous one. This option is used to hide events which are for AI and some technical events. Because this event is not visible, it won't popup at the end of the turn and player will don't have to hit OK, or whatever.

Code:
oneTimeChecking="1">
The event engine works like this: It loads event #1 and check are the all conditions meet, if no then it follows to event #2, again if not, then it follows to event #3, and if for an example in event #3 conditions are meet, then he starts from the beginning. So if in this entry we will type 0, then it might be checked many times for a turn, if we put 1 (BTW 0 is for false and 1 is for true in terms of logic), then this event will be checked only one time in a turn.

Code:
<title>ZID_19001_title</title>
This is event's title, in this example there is a tag which can be found in text database which is unaccesible for modders, but it can be written in plain text directly in the file. The game should use all kind of fonts (including Arabic and Chinese.)

Code:
<description>ZID_19001_desc</description>
This is description of the event. Again in the example is a tag, but you can use text.

Code:
<beginDate day="1" month="1" year="1946"/>
This is one of the event's conditions. The event will be ignored if the ingame date is earlier than this.

Code:
<condition>
This one opens conditions section, below all prerequisites will be entered that must be fulfilled. For example something like controlling specific hex, having a war with specific country, owning enough amount of Production Points. Detailed list of them can be found in /data/events/ folder in EVENT_ENGINE_MANUAL.txt file.

Code:
<and>
This one is a logical operator and determines that all conditions inside must be meet. If something is missed, the event won't activate.

Code:
<expression>
	<leftOperand method="Country.IsActive" param0="1"/>
	<operator value="equals"/>
	<rightOperand constValue="1"/>
</expression>
As you can see there is a comment which describes what this condition exactly responsible for.
Inside leftOperand, you are choosing, about what to ask the game. So in this case we will ask is the country active, in other words is it still in the game. Parameter 0 (param0) specified which country is it, in this case it is country with ID equal to 1 and this one is for Poland (taken from countries.csv file).
operator tells us on what kind of value this activity should be, in this example it should be equal to the value in rightOperand, it can be also higher or lower, but as for country activity we are not using real values, but a logic false/true, equality will be enough.
rightOperand tells us how high should be the value that we are asking about. In this case is this equal to 1, which states for truth.
If we would like to translate this condition to English it should be something like that:
Check is the country with ID 1 still not eliminated from the game.

Code:
<expression>
<leftOperand method="Country.GetAlliance"  param0="1"/>
 <operator value="equals"/>
 <rightOperand constValue="3"/>
</expression>
Previous explanation was pretty long so I'll try to write this one only in English:
Check is the country with ID 1 a member of alliance equal to 3, which means commitern.

Code:
<expression>
<leftOperand method="Hex.ControlledByAliance" param0="153" param1="81" param2="3"/>
<operator value="equals"/>
<rightOperand constValue="1"/>
</expression>
This one is a little bit more complicated as there are three parameters, fortunately you can check meaning of every of them in already mentioned EVENT_ENGINE_MANUAL.txt file (please check it now)
In English it would be something like that (this time let's try to read it backwards)
Is it true (<rightOperand constValue="1"/>) that Commitern (param2="3") controlling (leftOperand method="Hex.ControlledByAliance")HEX 153|81 (param0="153" param1="81")?
It might be worth to try and write condition that will check is Munchen not controlled by Axis.

Code:
<expression>
<leftOperand method="Country.HasWarWithCountry" param0="1" param1="3"/>
<operator value="equals"/>
<rightOperand constValue="0"/>
</expression>
By reading a comment you can see that we have got negation this time, so lets try to translate this:
Is it not true (<rightOperand constValue="0"/>) that countries with ID 1 and ID 3 (param0="1" param1="3") are at war (method="Country.HasWarWithCountry")?
Those this whole thing starts to make a sense?

Code:
<expression>
<leftOperand method="Country.GetProductionPoints" param0="1"/>
<operator value="greater"/>
<rightOperand constValue="20"/>
</expression>
This is something new as we will check some values in the game. Exactly amount of production points. Translating this one backwards will be little difficult so lets start from the beginning. Check is the country's with ID 1 (param0="1") Production Points poll )<leftOperand method="Country.GetProductionPoints") larger (<operator value="greater"/>) than 20 (<rightOperand constValue="20"/>).

Code:
</and>
This one is closing logical operator that we have opened before. Everything between them must be confirmed.

Code:
</condition>
This one is closing conditions section of the event, which has been opened above, everything between them must be checked.

Code:
<options>
We can assume that all conditions are meet and the event fires and pops up at the screen. Now player can perform some actions which are called options. Number of options is theoretically unlimited for event but usually there is one or two (very rare more than four).

Code:
<option optionID="1" chanceAI="100">
This one tells us what is the number of option this event and how great is the chance that AI will choose this one. In this specific case, as we have only one option AI has 100% chances to choose this one. Please note that sum of chanceAI in all options for one event MUST be equal to 100.

Code:
<description>ZID_19001_op1</description>
This is a name for option, again this one uses tag from database, but any text can be typed.

Code:
<tooltip>ZID_19001_desc1</tooltip>
This one is used to hint player what will happen if he choose this option. Plain text can be typed.

Code:
<effects>
This one opens effect section. In other words it tells what will happen if player choose such option

Code:
<effect method="Country.ChangeProductionPoints" param0="1" param1="-15" />
This comment pretty well explains what is happening, but let's check how. Meaning of parameters can be found also in EVENT_ENGINE_MANUAL.txt file, below conditions.
So this one is telling the game that is should change amount of production points (method="Country.ChangeProductionPoints"), for country with ID 1 (param0="1") by -15 (param1="-15"), in other words: reduce PP pool of Poland by 15.


Code:
<effect method="Country.ChangeProductionPoints" param0="3" param1="15" />
This one is doing opposite thing by adding 15 PP for USSR.

Code:
</effects>
This one is closing effects for option

Code:
</option>
This one means that everything with the option is done.

Code:
</options>
This one is closing options section, doesn't matter how many of them there is, they must be scripted above.

Code:
</event>
This one is informing the game that the event is finished and new one can be checked.