Setting Initial PoliticalRelationship with Trigger Attachment



  • I am trying to use a foreach loop to set the initial relationship for each nation. When I try this loop, I get an error "Unexpected Exception while setting values for attachment."

      <attachment foreach="$TriggerPlayer$^$TriggerPlayer2$" name="triggerAttachment@TriggerPlayer@@TriggerPlayer2@ToNeutrality" attachTo="@TriggerPlayer@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
          <option name="conditions" value="conditionAttachmentTurn1"/>
          <option name="relationshipChange" value="@TriggerPlayer@:@TriggerPlayer2:any:Neutrality"/>
          <option name="uses" value="1"/>
          <option name="when"  value="before:ABidPlace"/>
    	</attachment>
    
    

    When I try testing a single value, I get no error but no change in relationship

      <attachment name="triggerAttachmentEnglandFranceToNeutrality" attachTo="England" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
          <option name="conditions" value="conditionAttachmentTurn1"/>
          <option name="relationshipChange" value="England:France:any:Neutrality"/>
          <option name="uses" value="1"/>
          <option name="when"  value="before:ABidPlace"/>
    	</attachment>
    
    

    Do I have an error in my code or is there a problem with the way TripleA handles TriggerAttachments when the relationship is "DefaultWarRelation"?

    I know I could use Excel and paste text to relationshipInitialize but I am trying to create a generic set of code elements to allow any scenario to have random initial alliances and I would like to avoid using Excel.



  • @RogerCooper

    If you have the same country in both variableList then you are ending up with a relationship like:

    <attachment name="triggerAttachmentEnglandEnglandToNeutrality" attachTo="England" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
       <option name="conditions" value="conditionAttachmentTurn1"/>
       <option name="relationshipChange" value="England:England:any:Neutrality"/>
       <option name="uses" value="1"/>
       <option name="when"  value="before:ABidPlace"/>
    </attachment>
    

    Which may be the cause of your problem with this type of arrangement.

    Something to look at.

    Cheers...



  • @wc_sumpton I cut back the variable list so the first list is only England, and the second list is only France and I still get the error.

    I suspect that problem is that "defaultWarRelation" is probably just a null value and I can't change a null relationship value with a trigger. Technically this is a bug, but the better solution is the ability to set an explicit default value for politicalrelationship. I will submit a request.



  • @RogerCooper

    Are you saying that you don't have a '<relationshipInitialize>' section? It relationship are not initialize then there is nothing to set. That is why the trigger is falling. I have tried to set a tank unit to transport infantry, but if I didn't set "isLandTransport" then the trigger would fire but nothing would happen. But if I set "isLandTransport" to false then the trigger would change it to true.

    Hope this is helpful.

    Cheers...


Log in to reply