Chance in triggers


  • Donators

    When I add chance to a trigger, not only does it not work, but the other triggers stop working. See below. I am doing something wrong?

    <attachment name="triggerAttachmentUtahBeachInfantry" attachTo="Americans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    <option name="placement" value="Utah Beach:infantry" count="2"/>
    <option name="players" value="Americans"/>
    </attachment>
    <attachment name="triggerAttachmentUtahBeachArtillery" attachTo="Americans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    <option name="placement" value="Utah Beach:artillery" count="1"/>
    <option name="players" value="Americans"/>
    </attachment>
    <attachment name="triggerAttachmentUtahBeachArmor" attachTo="Americans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    <option name="placement" value="Utah Beach:armour" count="1"/>
    <option name="players" value="Americans"/>
    <option name="chance" value="3:6"/>
    </attachment>


  • Admin

    @RogerCooper Have you tried using/adding "when" and "uses"? I don’t know if it will make the triggers work, but its maybe worth a try. Like…
    <option name="when" value="before:AmericansEndTurn"/>
    <option name="chance" value="3:6"/>
    <option name="uses" value="1"/>


  • Donators

    Adding the "when" option didn't help. "uses" is inappropriate as I want the event to keep firing each turn.

    I checked that Grayhawk Wars is working using triggers like:

    		<attachment name="triggerAttachmentIuz_Mercenaries_Grandwood_Forest" attachTo="Iuz" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    				<option name="conditions" value="conditionAttachmentIuz_Mercenaries_Grandwood_Forest"/>
    				<option name="when" value="after:IuzNonCombatMove"/>
    				<option name="chance" value="3:6"/>
    				<option name="chanceIncrementOnFailure" value="1"/>
    				<option name="chanceDecrementOnSuccess" value="1"/>
    				<option name="placement" value="Grandwood Forest:bugbear:sellsword" count="1"/>
    				<option name="notification" value="HeroActionMercenaries"/>
    		</attachment>
    

    Maybe I need to put a condition in, even though the trigger is unconditional.


  • Admin

    @RogerCooper Yes. You always need a condition for triggers otherwise they default to false and never fire. The only exception I think is if you chain triggers together and use activateTrigger on another trigger.

    As @Frostion mentioned, you should pretty much always use 'when' as well.


  • Moderators

    @redrum On this point, I don't believe the default "when" are documented anywhere. They should; tho I would prefer the behaviour being changed to never firing if the when is missing, but this would likely cause map bugs (no idea how widespread). Thoughts?


  • Admin

    @Cernel It would impact a lot of maps as almost all the A&A maps and many of the older maps don't use when. Here is I think the only POS2 explanation which mentions it firing at the 'default' time but not really what that means:

    when		values: this is a value of when the trigger should fire. it is optional, and if left out the trigger will fire at its default time. "before/after:name-of-step" (example: value="after:chineseEndTurn").  'when' can be set multiple times if you want a trigger to fire in multiple spots.
    FYI: if your triggers are displaying odd behavior, MAKE SURE WHEN IS SET. complex triggers can experience unexpected behavior if 'when' is not set.
    

  • Donators

    @Cernel
    when values: this is a value of when the trigger should fire. it is optional, and if left out the trigger will fire at its default time. "before/after:name-of-step" (example: value="after:chineseEndTurn"). 'when' can be set multiple times if you want a trigger to fire in multiple spots.
    FYI: if your triggers are displaying odd behavior, MAKE SURE WHEN IS SET. complex triggers can experience unexpected behavior if 'when' is not set.

    I was able to not use a "condition" or "when", with deterministic triggers.


  • Moderators

    @redrum Yes, what I was saying is that the "default time" should be documented, obviously.

    Moreover, having this default time, missing the when, is quite the dumb liability in the making of activated triggers testing conditions, as those triggers would also fire on their own, so you need to set a "when" that will never happen (like referring to a non-existent phase), that is a huge and mandatory hack. Very bad process here.


  • Admin

    @Cernel Agree on both points. The first we can probably address. The second would require a lot of effort.


  • Moderators

    @redrum If the default when are staying, it would be good to have a way to specify a "never" for the when option. Maybe something like:

    <option name="when" value="null"/>

    That is understood by the program as the trigger never firing (unless activated).


  • Admin

    In that case why not...
    <option name="when" value="activation"/>
    ... instead of "null"? Or maybe "triggered"??
    When making xml code, I think the terms and wording should support understanding and intuition, so cryptic language should be kept to a minimum.


  • Admin

    @Cernel Good suggestion and probably should be a feature request.

    @Frostion Agree that "activation", "activated", or "never" is probably better than "null" as that tends to be a technical term.


  • Donators

    I tried this code:

    <attachment name="conditionAttachmentUtahBeach" attachTo="Americans" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
    <option name="alliedOwnershipTerritories" value="Utah Beach" count="1"/>
    </attachment>
    <attachment name="triggerAttachmentUtahBeachInfantry" attachTo="Americans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    <option name="conditions" value="conditionAttachmentUtahBeach"/>
    <option name="placement" value="Utah Beach:infantry" count="2"/>
    <option name="players" value="Americans"/>
    <option name="when" value="before:AmericansEndTurn"/>
    </attachment>
    <attachment name="triggerAttachmentUtahBeachArtillery" attachTo="Americans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    <option name="conditions" value="conditionAttachmentUtahBeach"/>
    <option name="placement" value="Utah Beach:artillery" count="1"/>
    <option name="players" value="Americans"/>
    <option name="when" value="before:AmericansEndTurn"/>
    </attachment>
    <attachment name="triggerAttachmentUtahBeachArmor" attachTo="Americans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
    <option name="conditions" value="conditionAttachmentUtahBeach"/>
    <option name="placement" value="Utah Beach:armour" count="1"/>
    <option name="players" value="Americans"/>
    <option name="chance" value="3:6"/>
    <option name="when" value="before:AmericansEndTurn"/>
    </attachment>

    Still does not work. Does anyone see what is wrong?


  • Admin

    @RogerCooper What do you mean by doesn't work? You get an error? None of them fire? Only the non-chance ones fire?


  • Donators

    @redrum The triggers do not fire. There is no error message.


  • Moderators

    @RogerCooper Since you say that it does not work and you are receiving no error message, either, first thing I would guess is that the "when" is wrong, as that is not validated.
    Be sure that corresponds exactly to the phase you are looking for.
    Also, probably you should link here to the xml you are working on, or at least tell what game is that, if possible (that way I could have seen myself if this guess of mine is on spot).


  • Donators

    @Cernel Here is the D-Day_3.xml. This is mod of the existing D-Day map.


  • Admin

    @RogerCooper You have the wrong phase name in the "when" condition. Replace the when condition in all the triggers with this:

    <option name="when" value="before:americanEndTurn"/>
    

Log in to reply