Simple Trigger Help



  • Hi there! I'd like some help. For some reason I can't even get the most basic function of my trigger to work.

    The plan, in short, is to have citizen units consumed by soldiers. Since the AI won't buy units with "consumesUnits" but can place them, I plan to switch off the unitAttachment (before:Purchase) and on (before:Place) for each player turn. Would that work?

    Trying to test this I've used various triggers with or without conditions and none of them seem to load in game.

    This won't make infantry consume citizens (consumesUnits is not added to them yet):

    <attachment name="triggerAttachment_Spartacitizens" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
        <option name="unitType" value="infantry"/>
        <option name="unitProperty" value="consumesUnits" count="1:citizens"/>		
        <option name="when" value="before:SpartaPurchase"/>
    </attachment>
    

    This won't increase transportCost from 1 to 2.

    <attachment name="triggerAttachment_Spartacitizens" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
        <option name="unitType" value="infantry"/>
        <option name='unitProperty' value='transportCost' count='2'/>		
        <option name="when" value="before:SpartaPurchase"/>
    </attachment>
    

    Any variation with conditions and/or -reset-, like the following, won't work either.

    <attachment name="conditionAttachment_Spartacitizens" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
        <option name="directPresenceTerritories" value="map" count="1"/>
        <option name="unitPresence" value="city" count="1"/>
    </attachment>
    <attachment name="triggerAttachment_Spartacitizens" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
        <option name="conditions" value="conditionAttachment_Spartacitizens"/>
        <option name="unitType" value="infantry"/>
        <option name='unitProperty' value='transportCost' count='-reset-:2'/>		
        <option name="when" value="before:SpartaPurchase"/>
    </attachment>


  • @Name lets try this one step at a time, first starting with the 'infantry'. You want the infantry to be placed only where there is a citizens and consume/remove that citizens. But in the purchasing of infantry you don't want to have this requirement because the player maybe AI.

    First, I would place the 'consumesUnit' in the unitAttachment. I have found that sometimes if the option is not listed, then triggers that try to change that option fail.

    <attachment name="unitAttachment" attachTo="infantry" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
    …
       <option name="transportCost" value="1"/>
       <option name="consumesUnits" value="1:citizens"/>
    …
    </attachment>
    

    Now lets change it. You want these next triggers to always fire, so I would make a 'AlwayTrue' condition.

    <attachment name="conditionAttachment_AlwaysTrue" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
       <option name="switch" value="true"/>
    </attachment>
    

    You should use '-reset-' in these next triggers, and add every player that need this to the triggers.

    Before Purchase trigger:

    <attachment name="triggerAttachment_Infantry_BeforePurchase" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
       <option name="conditions" value="conditionAttachment_AlwaysTrue"/>
       <option name="unitType" value="infantry"/>
       // POS2 says this is not needed but I always add it */
       <option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
       <option name="unitProperty" value="consumesUnits" count="-reset-"/>
       // Now add a list of players, if not only Sparta */
       <option name="players" value="Sparta:OtherPlayers"/>
       <option name="when" value="before:SpartaPurchase"/>
       <option name="when" value="before:OtherPlayersPurchase"/>
    </attachment>
    

    Before Place trigger. Note no ':' after the '-reset-'

    <attachment name="triggerAttachment_Spartacitizens" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
       <option name="conditions" value="conditionAttachment_AlwaysTrue"/>
       <option name="unitType" value="infantry"/>
       <option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
       // No ':' after '-reset-' */
       <option name="unitProperty" value="consumesUnits" count="-reset-1:citizens"/>
       // Now add a list of players, if not only Sparta */
       <option name="players" value="Sparta:OtherPlayers"/>
       <option name="when" value="before:SpartaPlace"/>
       <option name="when" value="before:OtherPlayersPlace"/>
    </attachment>
    

    So lets talk now about the 'transportCost'.

    Before purchase:

    <attachment name="triggerAttachment_Infantry_TransportCost_to_2" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
       <option name="conditions" value="conditionAttachment_AlwaysTrue"/>
       <option name="unitType" value="infantry"/>
       <option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
       <option name="unitProperty" value="transportCost" count="2"/>
       // Now add a list of players, if not only Sparta */
       <option name="players" value="Sparta:OtherPlayers"/>
       <option name="when" value="before:SpartaPurchase"/>
       <option name="when" value="before:OtherPlayersPurchase"/>
    </attachment>
    

    When to change it back to 1 depends on how many players need the cost set at '2'.

    <attachment name="triggerAttachment_Infantry_TransportCost_to_1" attachTo="AnyPlayer or Sparta" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
       <option name="conditions" value="conditionAttachment_AlwaysTrue"/>
       <option name="unitType" value="infantry"/>
       <option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
       <option name="unitProperty" value="transportCost" count="1"/>
       // Now add a list of players that have a transportCost of 1 */
       <option name="players" value="OtherPlayers"/>
       // If only Sparta, 'when' should be at the EndTurn */
       <option name="when" value="before:SpartaEndTurn"/>
       // Otherwise just use this to change the value before purchase */
       <option name="when" value="before:OtherPlayersPurchase"/>
    </attachment>
    

    Sorry for being long winded, but I hope this helps some.

    Cheers...



  • Thanks a lot!

    TransportCapacity was just a test example of things I tried in case the issue was specific to consumesUnits. So I'm trying the rest as suggested, but still something isn't working. Infantry still has consumesUnits during Purchase. If the triggers worked they should appear in game history right?

    Here's what I have:

    <attachment name="conditionAttachment_AlwaysTrue" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
        <option name="switch" value="true"/>
    </attachment>
    
    <attachment name="triggerAttachment_Infantry_BeforePurchase" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
       <option name="conditions" value="conditionAttachment_AlwaysTrue"/>
       <option name="unitType" value="infantry"/>
       <option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
       <option name="unitProperty" value="consumesUnits" count="-reset-"/>
       <option name="players" value="Sparta:Macedon:Aetolia:Achaia:Pergamon:Rhodos:Dardanii"/>
       <option name="when" value="before:SpartaPurchase"/>
       <option name="when" value="before:MacedonPurchase"/>
       <option name="when" value="before:AetoliaPurchase"/>
       <option name="when" value="before:AchaiaPurchase"/>
       <option name="when" value="before:PergamonPurchase"/>
       <option name="when" value="before:RhodosPurchase"/>
       <option name="when" value="before:DardaniiPurchase"/>
    </attachment>
    
    <attachment name="triggerAttachment_Infantry_BeforePlace" attachTo="Sparta" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
       <option name="conditions" value="conditionAttachment_AlwaysTrue"/>
       <option name="unitType" value="infantry"/>
       <option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
       <option name="unitProperty" value="consumesUnits" count="-reset-1:citizens"/>
       <option name="players" value="Sparta:Macedon:Aetolia:Achaia:Pergamon:Rhodos:Dardanii"/>
       <option name="when" value="before:SpartaPlace"/>
       <option name="when" value="before:MacedonPlace"/>
       <option name="when" value="before:AetoliaPlace"/>
       <option name="when" value="before:AchaiaPlace"/>
       <option name="when" value="before:PergamonPlace"/>
       <option name="when" value="before:RhodosPlace"/>
       <option name="when" value="before:DardaniiPlace"/>
    </attachment>
    

    Could it be that I need separate triggers for each player?

    Edit: I guess not, using the triggers just for Sparta Purchace/Place, with and without
    <option name="players" value="Sparta"/>
    still won't work.



  • @Name you said you see nothing in the game history? Do you have your properties set?

    <property name="Use Triggers" value="true" editable="false">
       <boolean/>
    </property>
    

    Cheers...



  • @wc_sumpton It's fine now thanks again:)



  • @Name LOL, no problem. Don't know how many times the simple/overlooked answer has eluded me! Happy to hear it is working. 😉

    Cheers...



  • Another question:

    Is there any known reason that this:

     <attachment name="unitAttachment" attachTo="citizens" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
          <option name='isInfrastructure' value='true'/>
          <option name="consumesUnits" value="1:slaves"/>
          <option name='whenCapturedChangesInto' value='any:any:true:slaves:1'/>
          <option name='createsResourcesList' value='1:Manpower'/>		 
      </attachment>	
    

    Won't convert into this on capture? ('whenCapturedChangesInto')

        <attachment name="unitAttachment" attachTo="slaves" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
    	<option name='isInfrastructure' value='true'/>
            <option name="movement" value="1"/>
    	<option name='canNotMoveDuringCombatMove' value='true'/>				 
            <option name="transportCost" value="1"/>	
            <option name='fuelCost' value='Supplies' count='1'/>	
            <option name="consumesUnits" value="1:citizens"/>				 
            <option name='createsResourcesList' value='1:PUs'/>
    	<option name='createsResourcesList' value='1:Supplies'/>
        </attachment>

  • Moderators

    @Name Try removing the...

    <option name="consumesUnits" value="1:slaves"/>
    

    From the Citizen attachment. This attachment means it would consume one of your (already in your possession) slaves when you try to build a citizen... not when you capture a territory with an enemy citizen in it. Your unit attachment for an enemy "citizen" already addresses this need as 'whenCapturedChangesIinto' already deals with this.

    "consumesUnit" should only be used when you are trying to use something that is already yours that is transformed into a different unit during your placement phase.

    Actually you probably need to remove the "consumesUnit" from both units.

    Though to be honest without knowing what your full intentions are it is hard to say for certain.



  • @Hepps I've already tried that (no consumesUnit for either of them), won't work. Adding the rest of the slaves' attributes to citizens won't work as well.

    Adding isConstruction and it's extras also not working, with or without consumesUnit.

    Edit: What I've tried to test is mechanics that allow:

    • Capturing of foreign citizens into slaves (whenCapturedChangesInto)
    • Promotion/Demotion of populations through purchase (consumesUnits)
    • (Somewhat related) Upgraded cities spawn citizens per turn.

    I could do without the first feature, seems rather unbalanced and not AI friendly, but I'll like to test it first and it's strange that it's not working nomatter what.


  • Moderators

    @Name Do you have all the game properties set up correctly?

     <!-- allows a player to let its units be captured by another player if true, when the territory is captured. units must have canBeCapturedOnEnteringBy and territories must have captureUnitOnEnteringBy and the players must have the player attachment captureUnitOnEnteringBy -->
        <property name="Capture Units On Entering Territory" value="false" editable="false">
          <boolean/>
        </property>
        <!-- if "Capture Units On Entering Territory" is true, then the units can either be captured (default) or destroyed (only if this property below is true: "On Entering Units Destroyed Instead Of Captured") -->
        <property name="On Entering Units Destroyed Instead Of Captured" value="false" editable="false">
          <boolean/>
        </property>
        <!-- specific rules -->
        <!-- land related -->
        <!-- if true, units with destroyedWhenCapturedBy will be destroyed instead of captured. only applies to non-combat units, since combat units die in combat -->
        <property name="Units Can Be Destroyed Instead Of Captured" value="true" editable="false">
          <boolean/>
        </property>
        <!-- allows units to change into other units using the whenCapturedChangesInto ability -->
        <property name="Units Can Be Changed On Capture" value="true" editable="false">
          <boolean/>
        </property>
    

  • Moderators

    @Hepps said in Simple Trigger Help:
    This one in particular is absolutely a MUST for what you are trying to accomplish.

    <!-- allows units to change into other units using the whenCapturedChangesInto ability -->
    <property name="Units Can Be Changed On Capture" value="true" editable="false">
      <boolean/>
    </property>


  • @Hepps said in Simple Trigger Help:

    @Hepps said in Simple Trigger Help:
    This one in particular is absolutely a MUST for what you are trying to accomplish.

    <!-- allows units to change into other units using the whenCapturedChangesInto ability -->
    <property name="Units Can Be Changed On Capture" value="true" editable="false">
      <boolean/>
    </property>
    

    That was it, thanks. Btw it works with consumesUnit.


  • Moderators

    @Name Yes... after looking at it figured my initial guess was wrong... but often it is a process of elimination of different things. More so when you are guessing at what people are trying to accomplish. 😃

    Glad it worked.



  • @Hepps said in Simple Trigger Help:

    @Name Yes... after looking at it figured my initial guess was wrong... but often it is a process of elimination of different things. More so when you are guessing at what people are trying to accomplish. 😃

    Glad it worked.

    Well in most cases so far (including ones not posted here), my troubles were simply some missing property, but at least by now I've learned to check if I can find a related one needed for something to work.

    The citizens/slaves feature is probably getting scrapped though since its extra visual burden and really hard to balance, income-wise, with added units per turn that give income.

    I'll eventually make a map development thread but for now I'll keep asking here. I'm getting used to making triggers and started looking into politics. Before doing loads of tedious work I'd like opinions on possible and advisable political features. I've read a bit across the forums but I still can't say a have a clear view on this.

    The background:

    • The map is set in Hellenistic/Roman times, probably starting at 222BC. Focus will be around Cleomenian, Second Punic, Macedonian and Syrian Wars.
    • There are many factions, of varied power and faction balance is not a primary concern. I'd like to have around 30 playables eventually.
    • The map is detailed (many regions) and big.

    The concerns:

    • FFA or Fixed Alliances seem unrealistic but easy to make.
    • Detailed politics (players can change any relation possible) would be ideal but a lot of work. I've read that the AI is really bad at it, but in what way?
    • Triggered relationships could work and keep historical accuracy reasonable. Say if Macedon or Rome gains a territory in Illyria, the other declares war. But I'm afraid it would railroad the game too much and limit player agency. Is it possible to have set AI reactions (or chances) but let a human decide how to react?

    Are there other options? Or any upsides/downsides I'm unaware of?


  • Moderators

    Hi Name. Welcome to the site.@Name said in Simple Trigger Help:

    ...Is it possible to have set AI reactions (or chances) but let a human decide how to react?

    Are there other options? Or any upsides/downsides I'm unaware of?

    Not sure if I understand you 100% correctly, but you might be able to have a AI player activate a trigger for a Human player if the right conditions are met and then on the Human players turn, a notification could show up, such as asking to declare war on somebody ? Idk could be worth a shot though.

    It seems that there's a game that uses lend lease kinda like that. I can't remember what it is though. Zim Xero's "Pacific Challenge" has a lot of triggers and interaction that goes on. Frostion's "Age of Tribes" as well. "Total World War" is another complex map that does a lot of different things. Actually it might be the one I was thinking of about the lend lease. "Feudal Japan" does a lot of stuff too.

    Anyway, you might want to check those out and see if any of their behavior does what you want.

    Also Pacific Challenge is heavily AI based if I remember right. Maybe that's his "Solo" challenge. Anyway 🙂



  • @beelee
    Hi and thanks!

    What I meant by that is that when a trigger to (potentially) change relationship is activated (say Player1 captured region X )

    • If Player2 is AI it is given a set reaction (declare war on Player1) or a chance (say 1:6 to declare war - maybe increasing by further 1:6 each passing turn).
    • If Player2 is Human, they are given a choice (User/Political Action I guess), to declare war if they want.

    I'll check those maps to get ideas, but I'm mostly interested on informed opinions of the general possibilities and which ones would better fit the scale/setting of mine. And later look into details on implementation (if something complex is needed).

    I'd generally prefer something AI friendly and not too memory heavy, since ~30 player turns will take quite long anyway.


  • Admin

    @Name I would probably recommend fixed alliances at least to start with as its the simplest and easiest to test with the AI. There are a few various options around diplomacy:

    1. Fixed alliances
    2. FFA either with no diplomacy or open diplomacy where players can declare alliance or war with each other freely or for some cost
    3. Diplomacy with restricted options and alliances like Global 40
    4. Some sort of unit based system like we are creating for PoP: https://forums.triplea-game.org/topic/1063/power-of-politics-1914-a-wwi-scenario

    It mostly boils down to how much effort you want to put into diplomacy and if you want the AI to be able to handle it.


  • Moderators Admin

    @redrum said in Simple Trigger Help:

    @Name I would probably recommend fixed alliances at least to start with as its the simplest and easiest to test with the AI. There are a few various options around diplomacy:

    1. Fixed alliances
    2. FFA either with no diplomacy or open diplomacy where players can declare alliance or war with each other freely or for some cost
    3. Diplomacy with restricted options and alliances like Global 40
    4. Some sort of unit based system like we are creating for PoP: https://forums.triplea-game.org/topic/1063/power-of-politics-1914-a-wwi-scenario

    It mostly boils down to how much effort you want to put into diplomacy and if you want the AI to be able to handle it.

    From what he said so far, sounds like the game would be about as AI unplayable as Civil War, which adds to the fact that the AI is currently very bad at FFA politics, so, while it is always possible the AI to be upgraded to that level, that makes it currently largely unfeasible going with option 2, as that would require 30 human players, that also probably don't care at all about game balance (as a matter of fair winning chances).

    @Name Probably the best compromise between what TripleA offers and realism is going with a Domination style politics, in which you would have something like 5 or 6 sides (fixed alliances), each having a number of powers (if 30 in total, respectively 6 or 5 powers per side), and you would distribute such power in a way to make the most sense with historical politics (grouping those that were tendentially friendly to each other and assure that those that were main enemies of each other stay in different sides). That way the game might have a chance to get played, especially PBF (you would need "only" to find 5 or 6 players, committing for what is probably going to be a year long gaming experience, if not several years).

    Theorically, I think the best (both for playability and for historical consistency) would be going Feudal Japan style, having each human player taking 1 power (under some balanced distribution), all remaining ones given to the AI (that is what most commercial historical digital games do, as well), but, for this, you would need the AI actually playing the game at a level of skill comparable to the persons.


  • Moderators Admin

    @Cernel said in Simple Trigger Help:

    Theorically, I think the best (both for playability and for historical consistency) would be going Feudal Japan style, having each human player taking 1 power (under some balanced distribution), all remaining ones given to the AI (that is what most commercial historical digital games do, as well), but, for this, you would need the AI actually playing the game at a level of skill comparable to the persons.

    Also since this would allow playing the game solo too, taking only 1 player and going for taking over the (known) world (as I guess most commercial historical digital games are usually played).



  • @Cernel @redrum

    Decent AI compatibility is a must. I want to be able to play the game solo or hotseat with a few friends. So far it works rather well, besides a couple of issues.

    • "Garrisons" (0/3/0), maximum of 4 per territory are a central part of the gameplay. But the AI won't buy them or I have to use "hacks" giving them 1 movement (triggered movement change during purchase, requiresUnitsToMove, or the best it seems, givesMoment -1 from factory type units). But if I use those hacks, the AI often buys more Garrisons than it can place.
    • I'm under the impression (could be wrong though), that the AI doesn't consider nevative isMarine when launching naval invasions and I have the majority of land units at isMarine -1 or -2.

    Online is secondary concern but I'll look into it as well. I doubt a game would take months or a year. I'll avoid heavy triggering. There are also severe limits to how many troops a player can have (mostly due to upkeep). Each unit represents around 1000 troops and factions will usually have those in the range of 5-50, depending on territory size and casualties (the upkeep system ensures it takes quite long to reach total troop potential, while garrisons make snowballing hard-ish). The more I say or read the more I think I'd better present the whole target gameplay before hoping for better advice. I'd do that soon.

    Anyway back to diplomacy:

    • FFA with politics seems out of the question, too much work and AI won't handle it.

    • FFA without politics doesn't fit the era much.

    • I'll take a look at the maps mentioned.

    • A mix of fixed alliances and triggered changes seems the most probable. But can someone explain if something like this is possible:

      What I meant by that is that when a trigger to (potentially) change relationship is activated (say Player1 captured region X )
      - If Player2 is AI it is given a set reaction (declare war on Player1) or a chance (say 1:6 to declare war - maybe increasing by further 1:6 each passing turn).
      - If Player2 is Human, they are given a choice (User/Political Action I guess), to declare war if they want.
      

    If not I wonder how it would feel to force diplo changes to both player and AI depending on where they invaded etc. Like entering some other power's sphere of influnce is guaranteed war, instantly or soon. I guess it would need some visual feedback to work decently. Some form of "casus beli" markers with the flag of the one getting it on triggering territories.


Log in to reply