Open a Dialog Box when event triggers?
-
@Jason-Green-Lowe said in Open a Dialog Box when event triggers?:
More importantly, no dialog box is popping up at all -- so it's not just that there is no effect when the user chooses option A, it's also that the user is not even being presented with a choice to make.
Do you have the dialog in notifications.properties as well ?
-
Yes, I've got the dialog in notifications.properties.
-
Just guessing here but one of the problems might be in when the 'userActionAttachment' trigger are fires. The 'germanUserActions' delegate should be just before 'germanEndTurn' because the endTurn delegate might be clearing the 'battle' flag.
Also if German, Italian relationship changes is set to 'Allied' with 'givesBackOriginalTerritories' equals 'true' then German never control Rome because once the territory is liberated, Italy will assume control of the territory.
How to test what is happening. Run you map, and give Rome control to an enemy of Italy. On Germany's turn stage the battle so that German will win. If the color changes to Italy then condition 'German have 'directOwnershipTerritories' of Rome' will be false and the userAction will not fire.
Hope this explains what is happening, and give you some ideas on how you might fix them.
Cheers...
-
@wc_sumpton I think you've identified a key part of the problem; Italy returns to Italian control immediately before the userAction has a chance to trigger. My UserActions delegate is in a good place, but it's never true that Germans have direct ownership of Rome, so the condition is never passed.
I've re-written the condition to be based on the presence of units during the combatMove, but I'm getting an error message and I'm not sure why.
<attachment name="conditionAttachment_Rome_Occupied_By_Enemy" attachTo="Germans" javaClass='RulesAttachment' type='player'> <option name="alliedOwnershipTerritories" value="Rome" count="1"/> <option name="invert" value="true"/> </attachment> <attachment name="conditionAttachment_Germans_Liberate_Rome" attachTo="Germans" javaClass='RulesAttachment' type='player'> <option name="conditions" value="conditionAttachment_Rome_Occupied_By_Enemy"/> <option name="directPresenceTerritories" value="Rome"/> <option name="unitPresence" value="infantry:commando:artillery:tank:jeep:halftrack:flak"/> </attachment> <attachment name="conditionAttachment_Germans_Keep_Italian_Territories" attachTo="Germans" javaClass='RulesAttachment' type='player'> <option name='switch' value='true'/> </attachment> <attachment name='triggerAttachment_Germans_Keep_Italian_Territories' attachTo='Germans' javaClass='TriggerAttachment' type='player'> <option name='conditions' value='conditionAttachment_Germans_Liberate_Rome'/> <option name='relationshipChange' value='Germans:Italians:any:Stingy'/> <option name="when" value="after:germanBattle"/> </attachment> <attachment name='userActionAttachment_Germans_Get_Choice_About_Rome' attachTo='Germans' javaClass='UserActionAttachment' type='player'> <option name='conditions' value='conditionAttachment_Germans_Liberate_Rome'/> <option name='activateTrigger' value='triggerAttachment_Germans_Keep_Italian_Territories:1:false:false:false:false'/> <option name='text' value='LIBERATE_ROME'/> <option name='actionAccept' value='Germans'/> </attachment>GameParseException: map name: 'file:/C:/Users/jason/triplea/downloadedMaps/argo/games/argo1939.xml', game name: 'argo1939', Unexpected Exception while setting values for attachment: RulesAttachment attached to: PlayerId named:Germans with name: conditionAttachment_Germans_Liberate_Rome
-
It hard to find the error with the information posted. I'm thinking that you don't have the console turn on. To show the console select 'Engine Preferences' from the main menu. Then the 'Game' tab.
As to you idea, once Rome is liberated, Italy will gain control of that territory. And since that is the Capital for the Italian player, all liberated territories will return to the Italian player.
The way I read this, the change of relationship happens after so 'givesBackOriginalTerritories' will have no effect until the next time Rome is captured. For this to work I think you are going to have to set the relationship to 'stingy' at the beginning of the game, then check if Germany wants to give back control of the liberated territories.
Hope this is helpful.
Cheers...
-
OK, I reworked the conditions as you suggested so that players on the same team start with the 'stingy' relationship and the trigger changes that to an 'allied' relationship, but I'm still not seeing any dialog box -- nothing seems to be triggering at all. I turned on the console as you suggested, and enabled verbose logging (debug mode), and got no messages at all.
I respectfully suggest that the problem here isn't the specific way I'm defining the liberation event -- I'm failing to invoke the idea of a dialog box at all. Can anyone help me with an example of code where they've successfully generated a dialog box in the middle of a game?
-
Here is the new code I was working with, and I'm also attaching the entire XML file in case anyone wants to review that.
<!--Liberation Conditions and Triggers--> <attachment name="conditionAttachment_Germans_Liberate_Rome" attachTo="Germans" javaClass='RulesAttachment' type='player'> <option name="directOwnershipTerritories" value="Rome"/> <option name="players" value="British:French:Russians:Chinese:Americans"/> <option name="battle" value="Germans:any:any:currentRound:Rome"/> </attachment> <attachment name="conditionAttachment_Germans_Keep_Italian_Territories" attachTo="Germans" javaClass='RulesAttachment' type='player'> <option name='switch' value='true'/> </attachment> <attachment name='triggerAttachment_Germans_Keep_Italian_Territories' attachTo='Germans' javaClass='TriggerAttachment' type='player'> <option name='conditions' value='conditionAttachment_Germans_Liberate_Rome'/> <option name='relationshipChange' value='Germans:Italians:any:Allied'/> <option name="when" value="after:germanBattle"/> </attachment> <attachment name='userActionAttachment_Germans_Get_Choice_About_Rome' attachTo='Germans' javaClass='UserActionAttachment' type='player'> <option name='conditions' value='conditionAttachment_Germans_Liberate_Rome'/> <option name='activateTrigger' value='triggerAttachment_Germans_Keep_Italian_Territories:1:false:false:false:false'/> <option name='text' value='LIBERATE_ROME'/> <option name='actionAccept' value='Germans'/> </attachment> -
Sorry for the amount of time it has taken me to reply. Using conditions that test for 'battle', the presents of Italian troops and the presents of enemy troops. I have been able to trigger messages using both 'politics' and 'userActions'. But I have been unable to get Germany to retain control of Rome.
This maybe a bug. Sorry I was unable to help.
Cheers...
-
Thank you. I think it's not so much a bug as just a hardwired behavior that has unfortunate consequences for some games.
Like, the choice seems to be:
givesBackOriginalTerrritories = True: territories will always return to the original owner at the end of each politics step
givesBackOriginalTerritories = False: territories will only return to the original owner when the original owner's capital is liberatedWhat I want is an option that says "territories will never return to the original owner," but there doesn't seem to be a way to do that right now.
I'm not sure what my second-best option is. I could just make most of the territories non-original, but then it feels awkward if you liberate an ally's territory while they're still alive and kicking and you keep it. Right, like if on turn 1 Germany captures Normandy, and on turn 2 Britain liberates Normandy, and the French still own Paris, Marseilles, Algeria, etc., and the British wind up with control of Normandy that seems really weird; that's not what would happen.
So how do I make it so that you give back territories before a capital falls, but keep territories after a capital falls? I could maybe try to alter the status of the territories so they lose their 'original territory' status after the capital falls, but what do I alter the status to? Is there a clean way to set the originalTerritory value to "none"?
-
Actually, one option I might consider is allowing players to build a special 'flag' unit that permanently annexes the territory by setting the original owner to the player building the flag. Can I do that with triggers and territory attachments? Anything to watch out for?
-
'<originalOwner' can not be set to 'None' unless you create a player as 'None'. But it can set it to 'Natural'. So that is something to think about.

Cheers...
-
@Jason-Green-Lowe You can use a "changeOwnership" trigger with suitable conditions to change territories as you see fit.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login