• 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.

Commanding Player using Triggers

Status
Not open for further replies.
Level 13
Joined
Jan 2, 2016
Messages
978
  • Buildings
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Building[0] = Farm 0000 <gen>
      • Set Building[1] = Farm 0001 <gen>
      • Set Building[2] = Farm 0002 <gen>
      • Set Building[3] = Farm 0003 <gen>
  • Test
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Player 2 (Blue)) and do (Actions)
        • Loop - Actions
          • Set TempBoolean = False
          • For each (Integer A) from 0 to 3, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Building[(Integer A)] is alive) Equal to True
                  • TempBoolean Equal to False
                • Then - Actions
                  • Unit - Order (Picked unit) to Attack Building[(Integer A)]
                  • Set TempBoolean = True
                • Else - Actions
This way you will have a sequence - when building 1 is dead - they attack building 2, when it dies - they attack building 3, then building 4, and so on.
 
Yeah my bad there, forgot about that part on the end. What WereElf has written up is what you'd want; disregard my 1st post. :p

Yeah sure no problem, actually you dont have to delete it because i am here to learn more. :)

This way you will have a sequence - when building 1 is dead - they attack building 2, when it dies - they attack building 3, then building 4, and so on.

I'm sure you're also the one who helped me last time, thank you once again. :)
 
Level 12
Joined
May 22, 2015
Messages
1,051
Slight update to WereElf's trigger. I think it won't be a big deal assuming there are just 4 buildings, but if you added a lot, and there were a lot of units to order, it would be a lot of extra loops. This version basically does the same thing, but it figures out which building to attack first and then just tells all the units to attack it.
  • Test
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set TempBoolean = False
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Building[(Integer A)] is alive) Equal to True
              • TempBoolean Equal to False
            • Then - Actions
              • Set TempInteger = Integer A
              • Set TempBoolean = True
            • Else - Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Player 2 (Blue)) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack Building[(TempInteger)]
 
Level 23
Joined
Feb 6, 2014
Messages
2,466
^could be optimized to

  • Test
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set TempBoolean = False
      • For each (Integer TempInteger) from 0 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Building[(TempInteger)] is alive) Equal to True
            • Then - Actions
              • Set TempBoolean = True
              • Custom script: exitwhen true
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempBoolean Equal to True
        • Then - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by Player 2 (Blue)) and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Attack Building[(TempInteger)]
 
Last edited:
Level 12
Joined
May 22, 2015
Messages
1,051
It was basically what WereElf has but for only one building. It was also a really simple trigger (simpler than the other ones here) so you're not missing out on any valuable information. :D

Mines equally simple to WereElf's but is more efficient :D Though if it is indeed just for one building with no further buildings to be added, the difference is small enough that you will not notice it (this would be the case for probably quite a few buildings lol).
 
Slight update to WereElf's trigger. I think it won't be a big deal assuming there are just 4 buildings, but if you added a lot, and there were a lot of units to order, it would be a lot of extra loops. This version basically does the same thing, but it figures out which building to attack first and then just tells all the units to attack it.

Hey, thanks :).
 
Status
Not open for further replies.
Top