Need Help Making A Trigger Work Completely

Level 8
Joined
Jul 21, 2015
Messages
143
So the purpose of this trigger is for a unit to "drop" a feather (item) every so often. I don't want the feather to stay on the map, as in it should disappear if it is not picked up. I have currently 10 eagles (set as variables for simplicity) and the trigger checks that the feather has not been picked up.

Things that work:
* the feather does disappear

Things that don't work:
*the feather still disappears even if certain units have the item in their inventory

I will accept any suggestions to make the trigger work better, even if it means completely deleting this trigger. I have the eagles set as variables and they can die but a new one takes their place with the proper variable, so that is a constant. Anyways here is the trigger... sorry its long

  • DropFeathers Copy
    • Events
      • Time - Every 13.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set udg_Feather1 = null
      • Custom script: set udg_Feather2 = null
      • Custom script: set udg_Feather3 = null
      • Custom script: set udg_Feather4 = null
      • Custom script: set udg_Feather5 = null
      • Custom script: set udg_Feather6 = null
      • Custom script: set udg_Feather7 = null
      • Custom script: set udg_Feather8 = null
      • Custom script: set udg_Feather9 = null
      • Custom script: set udg_Feather10 = null
      • Item - Create Feather at (Position of Eagle1)
      • Set VariableSet Feather1 = (Last created item)
      • Item - Create Feather at (Position of Eagle10)
      • Set VariableSet Feather10 = (Last created item)
      • Item - Create Feather at (Position of Eagle2)
      • Set VariableSet Feather2 = (Last created item)
      • Item - Create Feather at (Position of Eagle3)
      • Set VariableSet Feather3 = (Last created item)
      • Item - Create Feather at (Position of Eagle4)
      • Set VariableSet Feather4 = (Last created item)
      • Item - Create Feather at (Position of Eagle5)
      • Set VariableSet Feather5 = (Last created item)
      • Item - Create Feather at (Position of Eagle6)
      • Set VariableSet Feather6 = (Last created item)
      • Item - Create Feather at (Position of Eagle7)
      • Set VariableSet Feather7 = (Last created item)
      • Item - Create Feather at (Position of Eagle8)
      • Set VariableSet Feather8 = (Last created item)
      • Item - Create Feather at (Position of Eagle9)
      • Set VariableSet Feather9 = (Last created item)
      • Wait 10.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather1) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather1) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather1) Equal to False
              • (Main Character 0006 <gen> has Feather1) Equal to False
              • (Main Character 0007 <gen> has Feather1) Equal to False
              • (Main Character 0049 <gen> has Feather1) Equal to False
        • Then - Actions
          • Item - Remove Feather1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather2) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather2) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather2) Equal to False
              • (Main Character 0006 <gen> has Feather2) Equal to False
              • (Main Character 0007 <gen> has Feather2) Equal to False
              • (Main Character 0049 <gen> has Feather2) Equal to False
        • Then - Actions
          • Item - Remove Feather2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather3) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather3) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather3) Equal to False
              • (Main Character 0006 <gen> has Feather3) Equal to False
              • (Main Character 0007 <gen> has Feather3) Equal to False
              • (Main Character 0049 <gen> has Feather3) Equal to False
        • Then - Actions
          • Item - Remove Feather3
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather4) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather4) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather4) Equal to False
              • (Main Character 0006 <gen> has Feather4) Equal to False
              • (Main Character 0007 <gen> has Feather4) Equal to False
              • (Main Character 0049 <gen> has Feather4) Equal to False
        • Then - Actions
          • Item - Remove Feather4
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather5) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather5) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather5) Equal to False
              • (Main Character 0006 <gen> has Feather5) Equal to False
              • (Main Character 0007 <gen> has Feather5) Equal to False
              • (Main Character 0049 <gen> has Feather5) Equal to False
        • Then - Actions
          • Item - Remove Feather5
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather6) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather6) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather6) Equal to False
              • (Main Character 0006 <gen> has Feather6) Equal to False
              • (Main Character 0007 <gen> has Feather6) Equal to False
              • (Main Character 0049 <gen> has Feather6) Equal to False
        • Then - Actions
          • Item - Remove Feather6
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather7) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather7) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather7) Equal to False
              • (Main Character 0006 <gen> has Feather7) Equal to False
              • (Main Character 0007 <gen> has Feather7) Equal to False
              • (Main Character 0049 <gen> has Feather7) Equal to False
        • Then - Actions
          • Item - Remove Feather7
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather8) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather8) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather8) Equal to False
              • (Main Character 0006 <gen> has Feather8) Equal to False
              • (Main Character 0007 <gen> has Feather8) Equal to False
              • (Main Character 0049 <gen> has Feather8) Equal to False
        • Then - Actions
          • Item - Remove Feather8
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather9) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather9) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather9) Equal to False
              • (Main Character 0006 <gen> has Feather9) Equal to False
              • (Main Character 0007 <gen> has Feather9) Equal to False
              • (Main Character 0049 <gen> has Feather9) Equal to False
        • Then - Actions
          • Item - Remove Feather9
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Main Character (ranged) 0008 <gen> has Feather10) Equal to False
              • (Main Character (ranged) 0050 <gen> has Feather10) Equal to False
              • (Main Character (ranged) 0051 <gen> has Feather10) Equal to False
              • (Main Character 0006 <gen> has Feather10) Equal to False
              • (Main Character 0007 <gen> has Feather10) Equal to False
              • (Main Character 0049 <gen> has Feather10) Equal to False
        • Then - Actions
          • Item - Remove Feather10
        • Else - Actions
 
Level 24
Joined
Feb 27, 2019
Messages
833
Setting the Feathers to null just before creating new ones and setting them to new items has no use. It doesnt clean any accumulating leaks. There are no accumulating leaks from this variable and how its used.
  • Custom script: set udg_Feather1 = null
Instead of creating 9 different Feather variables you could create a single Feather array variable. This has benefits that Ill show later.
  • Feather[1]
The main issue with the current trigger is the Or - Any (Conditions) are true. If any of the conditions are true it will return true. The conditions are asking if 6 different units do not have a specific item and will return true if any of those conditions are true. Now remember, if the Main Character (ranged) 0008 <gen> doesnt have the item, thats the same as (Main Character (ranged) 0008 <gen> has Feather10) Equal to False which means the condition is true. What you want is an And condition, which is the default for If - Conditions so it doesnt have to be specified.

Now to the benefits of the Feather array variable. A benefit is that each item or unit can be referenced with a number/value. This requires a loop. A loop is an action that allows you to repeat any actions within the loop, the loop variable is the value the loop has each time its repeated. The loop variable starts at the lowest number and increases by +1 towards to the highest number each time its repeated. When it reaches the highest number the loop ends. The loop variable for this example is LoopA, the lowest number/starting value is 1, the highest number/end value is 10.
  • Drop Feathers
    • Events
      • Time - Every 13.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set VariableSet TempPoint = (Position of Eagle[LoopA])
          • Item - Create Tome of Experience at TempPoint
          • Set VariableSet Feather[LoopA] = (Last created item)
          • Custom script: call RemoveLocation(udg_TempPoint)
      • Wait 10.00 game-time seconds
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Feather[LoopA] is owned) Equal to False
            • Then - Actions
              • Item - Remove Feather[LoopA]
            • Else - Actions
I also added a different condition that might fit your purpose. This condition checks if the item is in any units inventory but you could keep your original conditions if you want.
 
Level 8
Joined
Jul 21, 2015
Messages
143
Setting the Feathers to null just before creating new ones and setting them to new items has no use. It doesnt clean any accumulating leaks. There are no accumulating leaks from this variable and how its used.
  • Custom script: set udg_Feather1 = null
Instead of creating 9 different Feather variables you could create a single Feather array variable. This has benefits that Ill show later.
  • Feather[1]
The main issue with the current trigger is the Or - Any (Conditions) are true. If any of the conditions are true it will return true. The conditions are asking if 6 different units do not have a specific item and will return true if any of those conditions are true. Now remember, if the Main Character (ranged) 0008 <gen> doesnt have the item, thats the same as (Main Character (ranged) 0008 <gen> has Feather10) Equal to False which means the condition is true. What you want is an And condition, which is the default for If - Conditions so it doesnt have to be specified.

Now to the benefits of the Feather array variable. A benefit is that each item or unit can be referenced with a number/value. This requires a loop. A loop is an action that allows you to repeat any actions within the loop, the loop variable is the value the loop has each time its repeated. The loop variable starts at the lowest number and increases by +1 towards to the highest number each time its repeated. When it reaches the highest number the loop ends. The loop variable for this example is LoopA, the lowest number/starting value is 1, the highest number/end value is 10.
  • Drop Feathers
    • Events
      • Time - Every 13.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set VariableSet TempPoint = (Position of Eagle[LoopA])
          • Item - Create Tome of Experience at TempPoint
          • Set VariableSet Feather[LoopA] = (Last created item)
          • Custom script: call RemoveLocation(udg_TempPoint)
      • Wait 10.00 game-time seconds
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Feather[LoopA] is owned) Equal to False
            • Then - Actions
              • Item - Remove Feather[LoopA]
            • Else - Actions
I also added a different condition that might fit your purpose. This condition checks if the item is in any units inventory but you could keep your original conditions if you want.
Wow this is simply so helpful man! I will definitely use your version of the trigger and remove the custom script. You are so awesome, thanks man!
 
Level 8
Joined
Jul 21, 2015
Messages
143
Setting the Feathers to null just before creating new ones and setting them to new items has no use. It doesnt clean any accumulating leaks. There are no accumulating leaks from this variable and how its used.
  • Custom script: set udg_Feather1 = null
Instead of creating 9 different Feather variables you could create a single Feather array variable. This has benefits that Ill show later.
  • Feather[1]
The main issue with the current trigger is the Or - Any (Conditions) are true. If any of the conditions are true it will return true. The conditions are asking if 6 different units do not have a specific item and will return true if any of those conditions are true. Now remember, if the Main Character (ranged) 0008 <gen> doesnt have the item, thats the same as (Main Character (ranged) 0008 <gen> has Feather10) Equal to False which means the condition is true. What you want is an And condition, which is the default for If - Conditions so it doesnt have to be specified.

Now to the benefits of the Feather array variable. A benefit is that each item or unit can be referenced with a number/value. This requires a loop. A loop is an action that allows you to repeat any actions within the loop, the loop variable is the value the loop has each time its repeated. The loop variable starts at the lowest number and increases by +1 towards to the highest number each time its repeated. When it reaches the highest number the loop ends. The loop variable for this example is LoopA, the lowest number/starting value is 1, the highest number/end value is 10.
  • Drop Feathers
    • Events
      • Time - Every 13.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set VariableSet TempPoint = (Position of Eagle[LoopA])
          • Item - Create Tome of Experience at TempPoint
          • Set VariableSet Feather[LoopA] = (Last created item)
          • Custom script: call RemoveLocation(udg_TempPoint)
      • Wait 10.00 game-time seconds
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Feather[LoopA] is owned) Equal to False
            • Then - Actions
              • Item - Remove Feather[LoopA]
            • Else - Actions
I also added a different condition that might fit your purpose. This condition checks if the item is in any units inventory but you could keep your original conditions if you want.
Okay so this is the newly constructed trigger I made, literally just copying what you suggested, so much shorter and easier. Let me know if I messed anything up. :D

  • DropFeathers Copy
    • Events
      • Time - Every 13.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set VariableSet PointEagle = (Position of ArrayEagle[LoopA])
          • Item - Create Feather at PointEagle
          • Set VariableSet Feather1[LoopA] = (Last created item)
          • Custom script: call RemoveLocation(udg_PointEagle)
      • Wait 10.00 seconds
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Feather1[LoopA] is owned) Equal to False
            • Then - Actions
              • Item - Remove Feather1[LoopA]
            • Else - Actions
 
Last edited:
Level 24
Joined
Feb 27, 2019
Messages
833
You could also create your own boolean and set it whenever you want. Such as this, the boolean is set when for the feathers when any of the are picked up and the feather will not be removed even if dropped afterwards. The only thing that matters for the feather not to be removed is that the feather was picked up at one point during these 10 seconds.
  • DropFeathers
    • Events
    • Conditions
    • Actions
      • Trigger - Turn on PickupFeathers <gen>
      • Wait 10.00 game-time seconds
      • Trigger - Turn off PickupFeathers <gen>
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • WasFeatherAcquired[LoopA] Equal to False
            • Then - Actions
              • Item - Remove Feather[LoopA]
            • Else - Actions
              • Set VariableSet WasFeatherAcquired[LoopA] = False
  • PickupFeathers
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Tome of Experience
    • Actions
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item being manipulated) Equal to Feather[LoopA]
            • Then - Actions
              • Set VariableSet WasFeatherAcquired[LoopA] = True
            • Else - Actions
 
Level 8
Joined
Jul 21, 2015
Messages
143
You could also create your own boolean and set it whenever you want. Such as this, the boolean is set when for the feathers when any of the are picked up and the feather will not be removed even if dropped afterwards. The only thing that matters for the feather not to be removed is that the feather was picked up at one point during these 10 seconds.
  • DropFeathers
    • Events
    • Conditions
    • Actions
      • Trigger - Turn on PickupFeathers <gen>
      • Wait 10.00 game-time seconds
      • Trigger - Turn off PickupFeathers <gen>
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • WasFeatherAcquired[LoopA] Equal to False
            • Then - Actions
              • Item - Remove Feather[LoopA]
            • Else - Actions
              • Set VariableSet WasFeatherAcquired[LoopA] = False
  • PickupFeathers
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Tome of Experience
    • Actions
      • For each (Integer LoopA) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item being manipulated) Equal to Feather[LoopA]
            • Then - Actions
              • Set VariableSet WasFeatherAcquired[LoopA] = True
            • Else - Actions
Ohhhh thank you man I like that!
 
Top