Activate support attachment by trigger?

  • Admin

    On my World of War Heroes map I have a unit named “Arthur” who is supposed to get a support attachment (Devotion-Aura) activated when he is level 8 (costs 800 XP)

    So I want this support attachment…

        <attachment name="supportAttachmentDevotion-Aura" attachTo="Arthur" javaClass="games.strategy.triplea.attachments.UnitSupportAttachment" type="unitType">
            <option name="faction" value="allied"/>
            <option name="side" value="defence"/>
            <option name="dice" value="strength"/>
            <option name="bonus" value="1"/>
            <option name="number" value="4"/>
            <option name="unitType" value="$AllLandUnits$:$AllAirUnits$"/>
            <option name="bonusType" value="Devotion Aura"/>
            <option name="players" value="$AllPlayers$"/>

    To be activated by this 800 XP costing condition / trigger…
    (Humans-Level-7 is a unit on map that indicated that "Arthur" is level 7 and can purchase level 8 if he got the XP)

        <attachment name="conditionAttachment_Humans_can_buy_level_8" attachTo="Humans" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
            <option name="directPresenceTerritories" value="map" count="1"/>
            <option name="unitPresence" value="Humans-Level-7" count="1"/>
        <attachment name="triggerAttachment_Arthur_has_reached_level_8_A" attachTo="Humans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
            <option name="support" value="supportAttachmentDevotion-Aura"/>
            <option name="when" value="before:HumansPurchase"/>
            <option name="uses" value="1"/>
        <attachment name="triggerAttachment_Arthur_has_reached_level_8_B" attachTo="Humans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
            <option name="removeUnits" value="Arthur Levels:Humans-Level-7" count="1"/>
            <option name="placement" value="Arthur Levels:Humans-Level-8" count="1"/>
            <option name="uses" value="1"/>
        <attachment name="triggerAttachment_Arthur_has_reached_level_8_C" attachTo="Humans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
            <option name="notification" value="levelup"/>
            <option name="players" value="$AllPlayers$"/>
            <option name="uses" value="1"/>
        <attachment name="userActionAttachment_Humans_buy_level_8" attachTo="Humans" javaClass="games.strategy.triplea.attachments.UserActionAttachment" type="player">
            <option name="conditions" value="conditionAttachment_Humans_can_buy_level_8"/>
            <option name="activateTrigger" value="triggerAttachment_Arthur_has_reached_level_8_A:1:false:false:false:false"/>
            <option name="activateTrigger" value="triggerAttachment_Arthur_has_reached_level_8_B:1:false:false:false:false"/>
            <option name="activateTrigger" value="triggerAttachment_Arthur_has_reached_level_8_C:1:false:false:false:false"/>
            <option name="text" value="Arthur_Level_8"/>
            <option name="costResources" value="800:XP"/>
            <option name="attemptsPerTurn" value="1"/>

    Why is the support attachment active on Arthur from game start round 1?

    The trigger is not supposed to fire/activate before a before "userActionAttachment_Humans_buy_level_8" activates the support attachment. First after this Arthur is supposed to have the support.


  • Moderators

    @Frostion I think this is well explained in pos2, actually:

    support values: name of support attachment, adds specified player to the list of players a supportAttachment supports.

    Assuming "$AllPlayers$" comprises "Humans", there you are either doing nothing or adding a second occurrence of "Humans" (not sure how it works), for the "players" option of the specified support attachment.

    Long story short: assuming that is for Arthur only, and Arthur is for Humans only, just remove the "players" option (all the line) from your support attachment, and it should work as you wish.

  • @Frostion at frist glance the three assignment triggers don't have a 'conditions' option, and so they might be firing at the start of the game giving Arthur the supportAttachment.

    Just a quick read...


  • Admin

    @Cernel I changed “$AllPlayers$” to “Humans”. Arthur still has the support from start of game, level 1 not level 8. So noting really changed.

    @wc_sumpton As I understand, if there is no conditions, then it should not fire before triggered by something like "activateTrigger". Is this not right?

    I tried moving “userActionAttachment_Humans_buy_level_8” up and before the three triggers, but then there is an error during map loading that prevent the map from starting.

  • Moderators

    @Frostion said in Activate support attachment by trigger?:

    @Cernel I changed “$AllPlayers$” to “Humans”. Arthur still has the support from start of game, level 1 not level 8. So noting really changed.

    Well, maybe I'm not very good at explaining things. What that trigger is doing is adding "Humans" to the players for that support attachment. So, it should work as you wish as long as "Humans" is not one of the players already assigned. Just delete this line completely:
    <option name="players" value="Humans"/>
    Meaning you will have a support attachment assigned to no players.

  • Admin

    Problem fixed (before I have seen @Cernels post)
    I removed the line with option name="players" completely from supportAttachment, and then it works fine. I guess it is not needed anyway as only humans have Arthur unit.
    Thx @Cernel and @wc_sumpton

Log in to reply