Simple Trigger Help



  • @Name said in Simple Trigger Help:

    Btw trying to test the things discussed above I think I found a bug.

    Corinth (Territory) belongs to Achaia, but has some of (Allied) Macedon's units starting there. When I have the following option enabled for the Allied relationshipTypeAttachment

    <option name='canTakeOverOwnedTerritory' value='true'/>

    and I move ALL of Macedon's troops to invade a neighbouring territory, Corinth ownership changes to Macedon.

    I guess I need two allied types to fix this, one for true alliance and one for capturable vassals, but it still seems unintended/strange anyway.

    This sound right to me. If 'canTakeOverOwnedTerritory' is set 'true'. Then the Macedon's starting units have 'ownership' of Corinth, even though Corinth 'originalOwner' is set to Achaia. (PoS2 'By setting true, you can take over territories of an ally'). Since the Macedon's units were placed there at game start, it is my guess that the change didn't happen until after they moved, I don't think that attacking of another territory made the change, just the movement out of Corinth.

    @Cernel Blitzing has nothing to do with this, since Achaia and Macedon are allies, and my guess is that 'canMoveLandUnitsOverOwnedLand' is set 'true' or 'default', so passage over Corinth is freely given.

    Hope this is helpful.

    Cheers...


  • Admin

    @Name Can you try removing alliancesCanChainTogether from Vassal. I think you can only have 1 relationship type that has that set to true.


  • Moderators Admin

    @wc_sumpton said in Simple Trigger Help:

    @Cernel Blitzing has nothing to do with this, since Achaia and Macedon are allies, and my guess is that 'canMoveLandUnitsOverOwnedLand' is set 'true' or 'default', so passage over Corinth is freely given.

    Hope this is helpful.

    Cheers...

    Well, that's, of course, because in any original rulesets you can conquer only territories that are owned by enemies of yours. But in the moment you assign "canTakeOverOwnedTerritory" true to an ally, the matter becomes questionable, and what I would say, if asked to expand the ruleset to cover the case, is that if you cannot blitz, then you should not be able to take over more than one territory with the same unit (thus not taking over upon exiting, either (you should take over during Conduct Combat, if you don't move out)). However, you might also argue that if this is representing a peaceful annexation, then you should be able to move through such allies freely, not requiring blitzing, despite the fact that you are conquering their territories. However, from my point of view, that would rather need a totally additional rule, allowing you to do that during Non Combat Move (how can any combat movements be peaceful?), and, on top of that, a strong argument against this can be provided by the fact that in Global you even cannot blitz through friendly neutrals, you take over (and, currently, a neutral territory that allows you to entering behaves just like an allied territory, as a matter of entering and exiting it (see the Allied and Open Borders relationsips of Napoleonic Empires FFA)).
    https://github.com/triplea-game/triplea/issues/4685

    My take is that in case of an ally with a "canTakeOverOwnedTerritory" true, the units owned by such player should be threated as friendly, of course, while the territories owned by such player should be fully threated as hostile, exactly just like regular enemy territories (except that their own units won't defend against you). I also believe you should take over all infrastructures (surely in case of factories, arguably, depending on rulesets, in case of aa guns, but TripleA doesn't currently support such a distinction), in such "allied" territories you capture: does that happen?

    One way or another, I really wish all such cases would be indagated, sorted out, and documented in pos2. TripleA should really decide and document (in pos2) all behaviours that are not covered by the original rules, but may happen because of what the program actually allows. Just leaving them to what the engine happens to do is not great, as it requires the mapmaker going through a lot of testing to know what they need to know, and for getting a behaviour that is very unreliable (for example, if a developer addresses the bug I linked, maybe some behaviours that are related will change too, especially since that one is exactly about taking over the territory of a player that is not hostile).



  • @redrum said in Simple Trigger Help:

    @Name Can you try removing alliancesCanChainTogether from Vassal. I think you can only have 1 relationship type that has that set to true.

    Doing that forces the Vassal (Macedonian_Allies) into Allied with Macedon at game start, since both are Allied with Achaia. Then, once the trigger runs, same result as before, since once again they are all in a chained relationship.

    Round: 1
    Politics
    Social War: Changing Relationship for Achaia and Macedon from Allied to War
    Macedon and Achaia are joined together in an Allied treaty

    It works fine if I start with Achaia and Macedonian_Allies at Peace. Which I wouldn't mind much, since Vassals are ment as enhancements for the main playable (stronger/somewhat balanced) players and a way to add more political background without going for 40-50 players (might actually help me reduce the planned ~30). They wouldn't move troops to assist Achaia, only defend themselves, purchase and get captured by Macedon. But there are other occasions that more than 2 players will be in a real alliance. Unless I'm not getting something I'll have to relly on a little more complex triggers.

    @Cernel @wc_sumpton I mainly thought it could be a bug since it only happed when I moved all the troops out. I get that you should capture allied territory under that rule. But wouldn't it be better to just capture it at start, without any movement. I don't know if it's hard to code, but visually it makes more sense.



  • @Name I have been working on a system for randomizing alliances (and giving bonuses and penalties based upon your allies & enemies). Alliances can chain together can work, but make sure that you start from neutrality. You can ally with 2 powers that always hostile or create dummy powers which just work to ally with.



  • @RogerCooper
    Do you mean start with all factions at neutral, then set alliances with triggers?
    Dummy powers you mean "empty" players, always at war with each other?

    Edit:
    How would I have a condition & trigger like the following fire only once? But not cancelled as effect. Nor as condition, since the condition might be used for other triggers as well.

    <attachment name="Lyttian_War_Condition" attachTo="Macedon" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
    	<option name='alliedPresenceTerritories' value='Carpathian Sea:Cretan Sea' count='1'/> 
    	<option name='unitPresence' value='Pirate_Fleet:Fleet' count='2'/>		
    </attachment>	
    
    <attachment name="Lyttian_War" attachTo="Rhodos" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    	<option name="conditions" value="Lyttian_War_Condition"/>
    	<option name="relationshipChange" value="Rhodos:Macedon:any:War"/>
    	<option name='notification' value='Social_War'/>			
    	<option name="chance" value="6:6"/>
     </attachment>


  • @Name
    Not sure if I am understanding your question. You want the condition and trigger to fire only once, even if the 'chance' fails ('6:6' should not fail). Then you could add:

       <option name="uses" value="1"/>
    

    to the trigger.

    If you mean to not fire 'Lyttian_War' after a successful 'chance' (even though 'chance' value might change). Then have the trigger set a 'switch' condition:

    <attachment name="Lyttian_War_Switch" attachTo="Rhodos" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
    	<option name="switch" value="true"/>		
    </attachment>
    
    <attachment name="Lyttian_War" attachTo="Rhodos" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    	<option name="conditions" value="Lyttian_War_Condition:Lyttian_War_Switch"/>
    	<option name="relationshipChange" value="Rhodos:Macedon:any:War"/>
    	<option name='notification' value='Social_War'/>			
    	<option name="chance" value="6:6"/>
            <option name="players" value="Rhodos"/>
            <option name="playerAttachmentName" value="RulesAttachment" count="Lyttian_War_Switch"/>
            <option name="playerProperty" value="switch" count="false"/>
    </attachment>
    

    If you want the 'Lyttian_War_Condition' to always remain 'true' even if one or both of the Pirate_Fleet get removed, the set the switch/trigger on the condition.

    Hope this helps.

    Cheers...
    P.S. I think you should consider adding a 'when' option to the triggers, to control when you want them to fire.



  • @Cernel
    I am sorry, I misunderstood what you were saying. I believe the problem is with 'canMoveLandUnitsOverOwnedLand', it should not stop the entering of a territory, just continued movement over/through territories.

    Cheers...



  • @wc_sumpton
    What I mean is I wanted the trigger to fire just once, but the condition to stay for potential use for other triggers.

    From what I've understood reading XOB, 1 use makes the trigger fire once per turn, not what I'm looking for.
    I'm confused on switch.

        <option name="playerProperty" value="switch" count="false"/>
    

    Means no more rolls after succcess?

    and

    <option name="switch" value="true"/>	
    

    Means condition always true after the first time it was valid?

    Since the triggers I'm using so far deal with relationship changes, I found a workaround, setting the condition to work depending on current relationship, besides other things.

    Another question on triggers with chances. If the condition remains active, but the trigger isn't successful yet, will it fire 2 times on the next turn?

    Say we've got this:

        <attachment name="Lyttian_War_Condition" attachTo="Macedon" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
           <option name='alliedPresenceTerritories' value='Carpathian Sea:Cretan Sea' count='1'/> 
           <option name='unitPresence' value='Pirate_Fleet:Fleet' count='2'/>		
     </attachment>	
    
         <attachment name="Lyttian_War" attachTo="Rhodos" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    	<option name="conditions" value="Lyttian_War_Condition"/>
    	<option name="relationshipChange" value="Rhodos:Macedon:any:War"/>
    	<option name='notification' value='Social_War'/>			
    	<option name="chance" value="1:6"/>
     </attachment>
    

    If the Fleets are present on the next turn, and the trigger didn't succeed on the first, how many times will the trigger roll? Same scenario but the fleets not there anymore?

    If we use switch on the condition, how many rolls when the trigger fires?


  • Admin

    @Name Interesting. You may have found a bug then in alliancesCanChainTogether. As if Macedon, Achaia, and Macedonian_Allies are all allied and then Achaia declares war on Macedon, it should also declare war on Macedonian_Allies. At this point, I would have to do some tests as not the many maps use this property.

    I'll look to set up this scenario with alliancesCanChainTogether and see if I see the same behavior you do:

    1. Player A, B, C are all Allied
    2. Player A declares War on Player B
    3. Result should be that Player A is then at War with Player B & C and Player B & C are still Allied


  • @Name
    'uses' is the number of time a condition/trigger can be called.

       <option name="uses" value="4"/>
    

    Means that the condition/trigger can only be call 4 times, it can be call 4 times in 1 turn, or take all game to make the 4 calls. After the 4th call, then the trigger can not be used any more for the rest of the game.

    The 'switch' is a condition option. In my above example I created a condition called 'Lyttian_War_Switch' which contained '<option name="switch" value="true"/>'. So this condition is always true for any condition/trigger that uses it.

    Then I changed the 'conditions' for Lyttian_War trigger and add a check for Lyttian_War_Switch:

       <option name="conditions" value="Lyttian_War_Condition:Lyttian_War_Switch"/>
    

    So the trigger will only fire when both conditions are true. With a chance of 6 or less out of 6 (always true, you will always get a 6 or less, when the highest value is 6) then the relationship between Rhodos and Mecedon will change to war. Then I changed the Lyttian_War_Switch condition to false. The next three lines are taken together:

            <option name="players" value="Rhodos"/> <!-- not needed because the trigger is attached to this player -->
            <option name="playerAttachmentName" value="RulesAttachment" count="Lyttian_War_Switch"/> <!-- changing a player RulesAttachment name 'Lyttian_War_Switch' -->
            <option name="playerProperty" value="switch" count="false"/> <!-- changing the 'switch' value from true to false for what uses this condition -->
    

    Hopes this helps what I was trying to say.

    @Name said in Simple Trigger Help:

    If we use switch on the condition, how many rolls when the trigger fires?

    Again it is hard to understand what you are asking, the trigger will only roll once every time it fires. How may times will this trigger fire per turn is hard to say with out a 'when'.

    Cheers...



  • @redrum
    Could it be cause I have used this isDefaultWarPosition (without really being sure what it does 😛 )?
    If true, any players that reach an alliance chaining relationship, will have their enemies who are not yet at war with, set to this relationship.

    @wc_sumpton I'll study what you said and open a specific thread with any remaining related questions soon.



  • @Name
    I am still trying to understand what you are asking. Let me breakdown what I think so far.

    <!-- You are creating a condition and attaching it to player Macedon -->
    <attachment name="Lyttian_War_Condition" attachTo="Macedon" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
       <!-- Now check for something in the Carpathian Sea or Cretan Sea. -->
       <!-- OR so only one territory has to contain something. -->
           <option name='alliedPresenceTerritories' value='Carpathian Sea:Cretan Sea' count='1'/> 
       <!-- Checking for Pirate_Fleet OR Fleet, and there must be 2 or more of them in a single territory.-->
       <!-- If there is 1 in each territory then this will return 'false' -->
           <option name='unitPresence' value='Pirate_Fleet:Fleet' count='2'/>		
    </attachment>	
    
    <!-- A trigger to check condition Lyttian_War attached to player Rhodos -->
    <attachment name="Lyttian_War" attachTo="Rhodos" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
       <!-- There must be 2 or more Pirate_Fleet or Fleet units in a single Carpathian Sea or Cretan Sea territory, --> 
    	<option name="conditions" value="Lyttian_War_Condition"/>
       <!-- Change Rhodos and Macedon to be at war with each other. -->
    	<option name="relationshipChange" value="Rhodos:Macedon:any:War"/>
       <!-- Show this notification to the Rhodos player. -->
    	<option name='notification' value='Social_War'/>
       <!-- There will be a 1 in 6 chance every time this trigger is called -->			
    	<option name="chance" value="1:6"/>
       <!-- Add to fire only after Macedon NCM -->
            <option name="when" value="after:MacedonNonCombatMove"/>
     </attachment>
    

    @Name said in Simple Trigger Help:

    If the Fleets are present on the next turn, and the trigger didn't succeed on the first, how many times will the trigger roll? Same scenario but the fleets not there anymore?

    Yes this trigger will fire every time there are fleets there. Even if Rhodos and Macedon are at War, if the fleets are there this trigger will fire. If the fleets leave, then the trigger will not fire. If the fleets return the trigger will fire again.

    How may times will this trigger roll/fire? Not sure, I think it should fire at the end of the Macedon NCM. But it could be many times per game turn.

    Hope this is helpful.

    Cheers...



  • @wc_sumpton

    Ok I think I get most of it.
    switch = always true.
    Setting switch to false for a condition will disable it.
    uses 1 = 1 time in total that the trigger can fire.

    Those triggers seem to all fire during the politics phase. I'll keep it that way without "when" for now, until the gameplay is more settled on and I know when I want them.

    Question:
    Can I have a notification display to all or a number of players?

    My confusing question rephrased, and probably answered:
    Does a trigger run again on it's own during the next turn if it failed it's roll? Probably not. What I was asking for about "rolls" (chances) is if it could roll two times next turn. One because it triggered again and one because it keeps checking from the previous turn. This chanceIncrementOnFailure made me think that possibly a trigger could auto-retry with increased chances next turn. Probably not.



  • @Name said in Simple Trigger Help:

    Question:
    Can I have a notification display to all or a number of players?

    Yes add <option name="players" value="Rhodos:Macedon"/>. Just list the players, separated with a colon.

    @Name said in Simple Trigger Help:

    My confusing question rephrased, and probably answered:
    Does a trigger run again on it's own during the next turn if it failed it's roll?

    Yes, if the condition, the fleets are still there. No if the fleets are not there. Chance has nothing to do with the trigger firing, only the 'conditions' value.

    Turn 1: two Fleet units in Cretan Sea so trigger Lyttian_War fires and chance 1:6 fails.

    Turn 2: one Fleet still in Cretan Sea with the other in Carpathian Sea with a Pirate_Fleet so trigger will fire. If you added:

       <option name="chanceIncrementOnFailure" value="1"/>
    

    Now the chance is 2 or less out of 6, but fails again.

    Turn 3 the Fleet as left Carpathian Sea leaving the Pirate_Fleet with a Fleet in Cretan Sea. The trigger 'Lyttian_War' will not fire.

    Turn 4 the Pirate_Fleet moved to Cretan Sea with the Fleet and the trigger will fire again, this time at 3:6. Success and Rhodos and Macedon are at war!

    Turn 5 the Pirate_Fleet and Fleet are still in Cretan Sea. Trigger 'Lyttian_War' fires at 3:6 failure but Rhodos and Macedon are still at war.

    Turns 6-9 the Fleet has left Cretan Sea for Carpathian Sea so Trigger 'Lyttian_War' does not fire

    Turns 10-15 the Pirate_Fleet has joined the Fleet at Carpathian Sea so Trigger 'Lyttian_War' will fire. Some fail, some success. With every failure the chance will increase by 1 until it matches 6, then the chance will not fail. With every success Rhodos and Macedon will be set to War, even if they are already at war, and everyone listed in the 'players' value will get notified.

    So yes the trigger will fire again and again, as long as 2 units are in 1 of the listed territories, the trigger will fire.

    And yes on every failure with 'chanceIncrementOnFailure' value of 1 will increase the chance of success until it reaches state of always true (6:6).

    Hope this helps...

    Cheers...


  • Admin

    @Name Anything is possible and I'd need to take a closer look at the code and do some testing but I'm 99% sure that isDefaultWarPosition would only ever cause chaining war and cause additional war declarations which doesn't appear to be the issue you're seeing 🙂


  • Moderators

    @redrum said in Simple Trigger Help:

    @Name Anything is possible ...

    👍



  • I've made a thread for the map showcasing some of it's planned features.
    https://forums.triplea-game.org/topic/1726/ancient-empires-222-bc

    @wc_sumpton
    Thanks, everything seems clear now 🙂



  • @Name
    Sure, no problem. Have fun and welcome to TripleA xml scripting.

    Cheers...


  • Admin

    @Name So I looked a bit closer and the reason alliancesCanChainTogether isn't working as we would think is that it only happens during the politics phase not during triggered relationship changes. So if you'd say declare war using a politics action instead of the trigger then you would see the effect I described. This could probably be enhanced and either way a bit better documentation in POS2 would be helpful.


Log in to reply