• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Anyway to make these triggers work for 8 regions instead of 1

Status
Not open for further replies.
Level 7
Joined
Aug 5, 2010
Messages
147
I have these 2 triggers working for the region Creep Spawn One, but there are 7 more regions that need to have the same actions happen, the only difference would be the array number of ConquestPointsTick1 and ConquestPointsTick2, array 1 being Creep Spawn One and so on.

Now i could make 16 triggers, 8 Enter triggers and 8 Leave triggers, but i want to know if its possible to do it using less triggers, preferable two triggers

  • Point Enter
    • Events
      • Unit - A unit enters Creep Spawn One <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Entering unit) belongs to an ally of Player 1 (Red)) Equal to True
          • ((Unit-type of (Entering unit)) is A Hero) Equal to True
        • Then - Actions
          • Set ConquestPointsTick1[1] = (ConquestPointsTick1[1] + 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Entering unit) belongs to an ally of Player 7 (Green)) Equal to True
          • ((Unit-type of (Entering unit)) is A Hero) Equal to True
        • Then - Actions
          • Set ConquestPointsTick2[1] = (ConquestPointsTick2[1] + 1)
        • Else - Actions

  • Point Leave
    • Events
      • Unit - A unit leaves Creep Spawn One <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Entering unit) belongs to an ally of Player 1 (Red)) Equal to True
          • ((Unit-type of (Entering unit)) is A Hero) Equal to True
        • Then - Actions
          • Set ConquestPointsTick1[1] = (ConquestPointsTick1[1] - 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Entering unit) belongs to an ally of Player 7 (Green)) Equal to True
          • ((Unit-type of (Entering unit)) is A Hero) Equal to True
        • Then - Actions
          • Set ConquestPointsTick2[1] = (ConquestPointsTick2[1] - 1)
        • Else - Actions
 
Alright.

That does make it tricky in GUI.
My best idea without making it complicated would be something like:

Trigger 1
Events
on map init​
Actions
set regions[0] = region1
set regions[1] = region2
set regions[2] = region3
set count = 3

loop 1 to count
add unit enters regions[integerA/B] to Trigger 2
add unit leaves regions[integerA/B] to Trigger 3​
Trigger 2
Events:
Conditions:
((Unit-type of (Entering unit)) is A Hero) Equal to True​
Actions:
loop 1 to count
if regions[integerA/B] contains triggering unit equals true
if ((Entering unit) belongs to an ally of Player 7 (Green)) Equal to True
Set ConquestPointsTick1[integerA/B] = (ConquestPointsTick1[integerA/B] + 1)​
else if ((Entering unit) belongs to an ally of Player 1 (Red)) Equal to True
Set ConquestPointsTick2[integerA/B] = (ConquestPointsTick2[integerA/B] + 1)
Trigger 3 would be the same as 2 with swapped values for leaving region
 
Alright.

That does make it tricky in GUI.
My best idea without making it complicated would be something like:

Trigger 1
Events
on map init​
Actions
set regions[0] = region1
set regions[1] = region2
set regions[2] = region3
set count = 3

loop 1 to count
add unit enters regions[integerA/B] to Trigger 2
add unit leaves regions[integerA/B] to Trigger 3​
Trigger 2
Events:
Conditions:
((Unit-type of (Entering unit)) is A Hero) Equal to True​
Actions:
loop 1 to count
if regions[integerA/B] contains triggering unit equals true
if ((Entering unit) belongs to an ally of Player 7 (Green)) Equal to True
Set ConquestPointsTick1[integerA/B] = (ConquestPointsTick1[integerA/B] + 1)​
else if ((Entering unit) belongs to an ally of Player 1 (Red)) Equal to True
Set ConquestPointsTick2[integerA/B] = (ConquestPointsTick2[integerA/B] + 1)
Trigger 3 would be the same as 2 with swapped values for leaving region
This works perfectly thanks
 
I did this already in another thread so here:
For all others here are the triggers:
  • Initialize Hostile Group
    • Events
      • Time - Elapsed game time is 0.30 seconds
    • Conditions
    • Actions
      • -------- The Amount of different groups you want to pause --------
      • Set Lure_GroupAmount = 3
      • -------- I think on your map are more then just one group --------
      • -------- thats why I store everything in arrays --------
      • -------- Set the Regions to loop through later on --------
      • Set Lure_HostileRegions[1] = HostileRegion01 <gen>
      • Set Lure_HostileRegions[2] = HostileRegion02 <gen>
      • Set Lure_HostileRegions[3] = HostileRegion03 <gen>
      • -------- Loop through all Regions and save their contained units in groups --------
      • For each (Integer Lure_Index) from 1 to Lure_GroupAmount, do (Actions)
        • Loop - Actions
          • Set Lure_HostileGroup[Lure_Index] = (Units in Lure_HostileRegions[Lure_Index])
          • -------- Loop through all units and filter the right one to add them to the unpause trigger --------
          • Unit Group - Pick every unit in Lure_HostileGroup[Lure_Index] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Equal to Player 2 (Blue)
                • Then - Actions
                  • Trigger - Add to Unpause Hostile Group <gen> the event (Unit - (Picked unit) Takes damage)
                  • Unit - Pause (Picked unit)
                • Else - Actions
                  • -------- If the unit is not fitting remove it from the group again --------
                  • Unit Group - Remove (Picked unit) from Lure_HostileGroup[Lure_Index]
  • Unpause Hostile Group
    • Events
    • Conditions
    • Actions
      • -------- Loop through all groups to check wich one to unpause --------
      • For each (Integer Lure_Index) from 1 to Lure_GroupAmount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) is in Lure_HostileGroup[Lure_Index]) Equal to True
            • Then - Actions
              • -------- unpause the group --------
              • Unit Group - Pick every unit in Lure_HostileGroup[Lure_Index] and do (Actions)
                • Loop - Actions
                  • Unit - Unpause (Picked unit)
              • Custom script: call DestroyGroup(udg_Lure_HostileGroup[udg_Lure_Index])
            • Else - Actions
and the map.
Edit:
Improved the system again now you just need to enter your regions and the rest is done by the system itself.
Triggers:
  • Lure System Initialize
    • Events
      • Time - Elapsed game time is 0.30 seconds
    • Conditions
    • Actions
      • -------- I think on your map are more then just one group --------
      • -------- thats why I store everything in arrays --------
      • -------- Set the Regions to loop through later on --------
      • Set Lure_HostileRegions[1] = HostileRegion01 <gen>
      • Set Lure_HostileRegions[2] = HostileRegion02 <gen>
      • Set Lure_HostileRegions[3] = HostileRegion03 <gen>
      • -------- Because the entering unit event fires before the unit is inside the Region --------
      • -------- we have to create points in offset around the unit to check wich region is entered --------
      • Set Lure_PointOffset = 60.00
      • -------- Loop through all Regions and save their contained units in groups --------
      • For each (Integer Lure_Index) from 0 to Lure_GroupAmount, do (Actions)
        • Loop - Actions
          • -------- check if there will be more groups --------
          • Custom script: if ( not(udg_Lure_HostileRegions[udg_GroupAmount + 1 ] == null)) then
          • Set Lure_GroupAmount = (Lure_GroupAmount + 1)
          • Set Lure_HostileGroup[Lure_GroupAmount] = (Units in Lure_HostileRegions[Lure_GroupAmount])
          • -------- Loop through all units and filter the right one to add them to the unpause trigger --------
          • Unit Group - Pick every unit in Lure_HostileGroup[Lure_GroupAmount] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Equal to Player 2 (Blue)
                • Then - Actions
                  • Trigger - Add to Lure System Unpause By Attack <gen> the event (Unit - (Picked unit) Takes damage)
                  • Unit - Pause (Picked unit)
                • Else - Actions
                  • -------- If the unit is not fitting remove it from the group again --------
                  • Unit Group - Remove (Picked unit) from Lure_HostileGroup[Lure_GroupAmount]
          • -------- If the group is empty after filtering the units clear memory --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in Lure_HostileGroup[Lure_GroupAmount]) Equal to 0
            • Then - Actions
              • Custom script: call DestroyGroup(udg_Lure_HostileGroup[udg_Lure_GroupAmount])
            • Else - Actions
          • -------- Add Region to entering trigger --------
          • Trigger - Add to Lure System Unpause By Enter <gen> the event (Unit - A unit enters Lure_HostileRegions[Lure_GroupAmount])
          • Custom script: endif
  • Lure System Unpause By Attack
    • Events
    • Conditions
    • Actions
      • -------- Loop through all groups to check wich one to unpause --------
      • For each (Integer Lure_Index) from 1 to Lure_GroupAmount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) is in Lure_HostileGroup[Lure_Index]) Equal to True
            • Then - Actions
              • -------- unpause the group --------
              • Unit Group - Pick every unit in Lure_HostileGroup[Lure_Index] and do (Actions)
                • Loop - Actions
                  • Unit - Unpause (Picked unit)
              • Custom script: call DestroyGroup(udg_Lure_HostileGroup[udg_Lure_Index])
            • Else - Actions
  • Lure System Unpause By Enter
    • Events
    • Conditions
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • -------- we have to create a area around the triggering unit to be able to check in wich region the unit is --------
      • Set Lure_Points[1] = (TempPoint offset by ((Lure_PointOffset x -1.00), (Lure_PointOffset x -1.00)))
      • Set Lure_Points[2] = (TempPoint offset by ((Lure_PointOffset x -1.00), Lure_PointOffset))
      • Set Lure_Points[3] = (TempPoint offset by (Lure_PointOffset, Lure_PointOffset))
      • Set Lure_Points[4] = (TempPoint offset by (Lure_PointOffset, (Lure_PointOffset x -1.00)))
      • -------- Check in wich region the unit is --------
      • For each (Integer Lure_Index) from 1 to Lure_GroupAmount, do (Actions)
        • Loop - Actions
          • -------- add here all your filters you want underneath the "or" condition --------
          • -------- My example is if the unit is a hero... --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Lure_HostileRegions[Lure_Index] contains Lure_Points[1]) Equal to True
                  • (Lure_HostileRegions[Lure_Index] contains Lure_Points[2]) Equal to True
                  • (Lure_HostileRegions[Lure_Index] contains Lure_Points[3]) Equal to True
                  • (Lure_HostileRegions[Lure_Index] contains Lure_Points[4]) Equal to True
              • ((Triggering unit) is A Hero) Equal to True
            • Then - Actions
              • -------- unpause the group --------
              • Unit Group - Pick every unit in Lure_HostileGroup[Lure_Index] and do (Actions)
                • Loop - Actions
                  • Unit - Unpause (Picked unit)
              • Custom script: call DestroyGroup(udg_Lure_HostileGroup[udg_Lure_Index])
            • Else - Actions
      • -------- Remove Memory leaks --------
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_Lure_Points[1])
      • Custom script: call RemoveLocation(udg_Lure_Points[2])
      • Custom script: call RemoveLocation(udg_Lure_Points[3])
      • Custom script: call RemoveLocation(udg_Lure_Points[4])
and the map:
 
Status
Not open for further replies.
Back
Top