Russian Revolution
-
Are you ready for a small lesson? First comes a variable list:
<diceSides value="6"/> <!-- Variable lists start after diceSides and before map --> <variableList> <variable name="Border5"> <!-- 5 --> <element name="Livonia"/> <element name="Karelia"/> <element name="Belarus"/> <element name="Ukraine"/> <element name="Tatarstan"/> </variable> <variable name="Other4"> <!-- 4 --> <element name="Poland"/> <element name="Sevastopol"/> <element name="Kazakhstan"/> <element name="Finland"/> </variable> <variable name="All10"> <!-- 10 --> <element name="$Border5$"/> <element name="$Other4$"/> <element name="Moscow"/> </variable> </variableList> <!-- The whole list ends prior to map --> <map>
Why, because for me it's easier to create and follow.
For the revolution to complete, certain things have to happen, but because of the nature of these things, they should not all be called to happen within the same trigger. So, a switch is used to govern their actions.<!-- Switch for Russian Revolution --> <attachment name="conditionAttachmentRussianRevolutionSwitch" attachTo="Russians" javaClass="RulesAttachment" type="player"> <option name="switch" value="false"/> </attachment>
Conditions and triggers that loop through all 10 Russian originally owned territories to check their condition.
<!-- I'm using "foeach" to loop through all 10 territories --> <!-- Check for Russian ownership --> <attachment foreach="$All10$" name="conditionAttachmentRTO@All10@" attachTo="Russians" javaClass="RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="@All10@" count="1"/> </attachment> <!-- Check of presence of Russian units, regardless of ownership --> <attachment foreach="$All10$" name="conditionAttachmentRUP@All10@" attachTo="Russians" javaClass="RulesAttachment" type="player"> <option name="directPresenceTerritories" value="@All10@" count="1"/> <option name="unitPresence" value="ANY" count="1"/> </attachment> <!-- Going to add these together with an "OR" --> <attachment foreach="$All10$" name="conditionAttachmentRCT@All10@" attachTo="Russians" javaClass="RulesAttachment" type="player"> <option name="conditions" value="conditionAttachmentRTO@All10@:conditionAttachmentRUP@All10@"/> <option name="conditionType" value="OR"/> <!-- Also check for enemy --> <option name="enemyPresenceTerritories" value="@All10@" count="1"/> <option name="unitPresence" value="ANY" count="1"/> </attachment> <!-- The trigger will check if the territory is considered contested, and give ownership to Neutral_Central. --> <attachment foreach="$All10$" name="tirggerAttachmentRCT@All10@" attachTo="Russians" javaClass="TriggerAttachment" type="player"> <!-- Not only are the conditions set, but also the switch must be checked --> <option name="conditions" value="conditionAttachmentRCT@All10@:conditionAttachmentRussianRevolutionSwitch"/> <!-- We don't who owns the territory --> <option name="changeOwnership" value="@All10@:any:Neutral_Central:false"/> <!-- Because this trigger is not called, we will set "when" to check it --> <option name="when" value="after:germansUserActions"/> <option name="uses" value="1"/> <!-- Again, do only once --> </attachment>
Now to add your do everything trigger. The name needs to change, a condition added, and a when.
<attachment name="triggerAttachmentRussianRevolutionEverythingElse" attachTo="Russians" javaClass="TriggerAttachment" type="player"> <!-- Add a condition to check the switch --> <option name="conditions" value="conditionAttachmentRussianRevolutionSwitch"/> <option name="removeUnits" value="ALL:ALL" count="9999"/> <!-- Removes all Russian units --> <!-- Gives back to original owners --> <option name="changeOwnership" value="Serbia:Russians:Neutral_True:false"/> <option name="changeOwnership" value="Romania:Russians:Neutral_True:false"/> <option name="changeOwnership" value="Prussia:Russians:Germans:false"/> ... ... ... <option name="uses" value="1"/> <!-- And set the "when" --> <!-- We want this to happen after the territories are check, --> <!-- which is after the user action. --> <!-- So, it'll be set before purchase, the next step --> <option name="when" value="before:germansPurchase"/> </attachment>
This new trigger is used to change the switch
<attachment name="triggerAttachmentRussianRevolution" attachTo="Russians" javaClass="TriggerAttachment" type="player"> <!-- This will change the switch to true --> <!-- Which means it can't happen unless invoked --> <!-- Which is already done by your other trigger --> <option name="conditions" value="conditionAttachmentRussianRevolutionSwitch"/> <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachmentRussianRevolutionSwitch"/> <option name="playerProperty" value="switch" count="true"/> <option name="uses" value="1"/> </attachment>
It's a lot, so take your time.
Cheers...
-
This looks very promising, although unfortunately I was unable to get it to work. All territories become controlled by "Contested", but the contested territories don't become controlled by Neutral_Central.
<!-- Switch for Russian Revolution --> <attachment name="conditionAttachmentRussianRevolutionSwitch" attachTo="Russians" javaClass="games.strategy.triplea.attachment.RulesAttachment" type="player"> <option name="switch" value="false"/> </attachment> <!-- Check for Russian ownership --> <attachment foreach="$All10$" name="conditionAttachmentRTO@All10@" attachTo="Russians" javaClass="games.strategy.triplea.attachment.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="@All10@" count="1"/> </attachment> <!-- Check of presence of Russian units, regardless of ownership --> <attachment foreach="$All10$" name="conditionAttachmentRUP@All10@" attachTo="Russians" javaClass="games.strategy.triplea.attachment.RulesAttachment" type="player"> <option name="directPresenceTerritories" value="@All10@" count="1"/> <option name="unitPresence" value="ANY" count="1"/> </attachment> <!-- Going to add these together with an "OR" --> <attachment foreach="$All10$" name="conditionAttachmentRCT@All10@" attachTo="Russians" javaClass="games.strategy.triplea.attachment.RulesAttachment" type="player"> <option name="conditions" value="conditionAttachmentRTO@All10@:conditionAttachmentRUP@All10@"/> <option name="conditionType" value="OR"/> <!-- Also check for enemy --> <option name="enemyPresenceTerritories" value="@All10@" count="1"/> <option name="unitPresence" value="ANY" count="1"/> </attachment> <!-- The trigger will check if the territory is considered contested, and give ownership to Neutral_Central. --> <attachment foreach="$All10$" name="triggerAttachmentRCT@All10@" attachTo="Russians" javaClass="games.strategy.triplea.attachment.TriggerAttachment" type="player"> <!-- Not only are the conditions set, but also the switch must be checked --> <option name="conditions" value="conditionAttachmentRCT@All10@:conditionAttachmentRussianRevolutionSwitch"/> <!-- We don't know who owns the territory --> <option name="changeOwnership" value="@All10@:any:Neutral_Central:false"/> <!-- Because this trigger is not called, we will set "when" to check it --> <option name="uses" value="1"/> <option name="when" value="after:germanUserActions"/> </attachment>
<!-- All those conditions for the RR to trigger -->
<!-- Trigger for revolution --> <attachment name="triggerAttachmentRussianRevolutionEverythingElse" attachTo="Russians" javaClass="games.strategy.triplea.attachment.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentRussianRevolutionSwitch"/> <option name="when" value="before:germansPurchase"/> <!-- Removes all Russian units --> <option name="removeUnits" value="ALL:ALL" count="9999"/> <!-- Gives back to original owners --> <option name="changeOwnership" value="Serbia:Russians:Neutral_True:false"/> <option name="changeOwnership" value="Romania:Russians:Neutral_True:false"/> <option name="changeOwnership" value="Prussia:Russians:Germans:false"/> <option name="changeOwnership" value="Silesia:Russians:Germans:false"/> <option name="changeOwnership" value="Galicia:Russians:AustroHungarians:false"/> <option name="changeOwnership" value="Budapest:Russians:AustroHungarians:false"/> <option name="changeOwnership" value="Trieste:Russians:AustroHungarians:false"/> <option name="changeOwnership" value="Bohemia:Russians:AustroHungarians:false"/> <option name="changeOwnership" value="Vienna:Russians:AustroHungarians:false"/> <option name="changeOwnership" value="Bulgaria:Russians:Ottomans:false"/> <option name="changeOwnership" value="Mesopotamia:Russians:Ottomans:false"/> <option name="changeOwnership" value="Constantinople:Russians:Ottomans:false"/> <option name="changeOwnership" value="Persia:Russians:Neutral_True:false"/> <option name="changeOwnership" value="Afghanistan:Russians:Neutral_True:false"/> <!-- Makes Russian territories impassable --> <option name="changeOwnership" value="ALL:Russians:Contested:false"/> <!-- To make sure shared territories work properly --> <option name="relationshipChange" value="AustroHungarians:Neutral_Central:Friendly_Neutral:Allied"/> <option name="relationshipChange" value="Germans:Neutral_Central:Friendly_Neutral:Allied"/> <option name="relationshipChange" value="Ottomans:Neutral_Central:Friendly_Neutral:Allied"/> <option name="uses" value="1"/> </attachment> <attachment name="triggerAttachmentRussianRevolution" attachTo="Russians" javaClass="games.strategy.triplea.attachment.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentRussianRevolutionSwitch"/> <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachmentRussianRevolutionSwitch"/> <option name="playerProperty" value="switch" count="true"/> <option name="uses" value="1"/> </attachment> <!-- User action --> <attachment name="userActionAttachmentRussianRevolution" attachTo="Germans" javaClass="games.strategy.triplea.attachment.UserActionAttachment" type="player"> <option name="conditions" value="conditionAttachmentRound1:conditionAttachmentControl3Of5:conditionAttachmentControlOrContested1Of4:conditionAttachmentMoscowRussianControlled"/> <option name="conditionType" value="AND"/> <option name="text" value="Russian_Revolution"/> <option name="chance" value="6:6"/> <option name="activateTrigger" value="triggerAttachmentRussianRevolution:1:true:false:false:false"/> </attachment>
-
So the switch is set to true but "triggerAttachmentRCT@All10@" still does not trigger for some reason...
-
So this is what I'm getting in the history:
It is only doing those trigger that match the conditions. I set the map with your earlier picture. Such that both Finland and Karelia were both Russian controlled but held German units to be contested and Tatarstan was German controlled contested by Russia.
Without more information, it hard for me to tell what might be wrong.
@victoryfirst said in Russian Revolution:
So the switch is set to true but "triggerAttachmentRCT@All10@" still does not trigger for some reason...
As can be seen triggerAttachmentRCT@All10@ get converted into its separate pieces.Cheers...
-
-
I think I found it...
Heh heh it was funny because I couldn't spot the mistake so I went to bed and at that moment I realized "germanPurchase" was spelled wrong. I missed it when looking at the screen and realized it when not
-
Well, what can I say... it works perfectly!
Thank you so much! I didn't know you could do all this cool stuff! I have certainly learned a lot just working on this!
So, I now know how you can chain multiple conditions. You can set conditionType to set which of those conditions need to be true. You can use the switch to turn on other triggers that can't be otherwise activated. However I still don't completely understand how "foreach" works. So when in a condition, you provide a list of territories, and it will loop through all those territories and check something for all of them. But what is the result of that condition? Is that also a list with a true/false for each territory?
And what exactly happens here?
<!-- Going to add these together with an "OR" --> <attachment foreach="$All10$" name="conditionAttachmentRCT@All10@" attachTo="Russians" javaClass="games.strategy.triplea.attachment.RulesAttachment" type="player"> <option name="conditions" value="conditionAttachmentRTO@All10@:conditionAttachmentRUP@All10@"/> <option name="conditionType" value="OR"/> <!-- Also check for enemy --> <option name="enemyPresenceTerritories" value="@All10@" count="1"/> <option name="unitPresence" value="ANY" count="1"/> </attachment>
So here you have conditions in conditions?
And this trigger with "foreach", will it check if one of the territories has "true", then loop through the list and change ownership of all the territories that have "true"?
<!-- The trigger will check if the territory is considered contested, and give ownership to Neutral_Central. --> <attachment foreach="$All10$" name="triggerAttachmentRCT@All10@" attachTo="Russians" javaClass="games.strategy.triplea.attachment.TriggerAttachment" type="player"> <!-- Not only are the conditions set, but also the switch must be checked --> <option name="conditions" value="conditionAttachmentRCT@All10@:conditionAttachmentRussianRevolutionSwitch"/> <!-- We don't know who owns the territory --> <option name="changeOwnership" value="@All10@:ANY:Neutral_Central:false"/> <!-- Because this trigger is not called, we will set "when" to check it --> <option name="uses" value="1"/> <option name="when" value="after:germansUserActions"/> </attachment>
-
"foreach" is a writing convention. Instead of writing 10 block of code, write 1 and the engine creates the 10 blocks. To see how this works, first load your map. In the menu in the upper left corner there is Export and under that is Export game.xml File (Bata). After saving open the file and you should see:
<attachment name="conditionAttachmentRTOLivonia" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Livonia"/> </attachment> <attachment name="conditionAttachmentRTOKarelia" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Karelia"/> </attachment> <attachment name="conditionAttachmentRTOBelarus" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Belarus"/> </attachment> <attachment name="conditionAttachmentRTOUkraine" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Ukraine"/> </attachment> <attachment name="conditionAttachmentRTOTatarstan" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Tatarstan"/> </attachment> <attachment name="conditionAttachmentRTOPoland" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Poland"/> </attachment> <attachment name="conditionAttachmentRTOSevastopol" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Sevastopol"/> </attachment> <attachment name="conditionAttachmentRTOKazakhstan" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Kazakhstan"/> </attachment> <attachment name="conditionAttachmentRTOFinland" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Finland"/> </attachment> <attachment name="conditionAttachmentRTOMoscow" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="1:Moscow"/> </attachment>
So, the engine creates the difference condition.
Cheers...