• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] (Solved!) Help with player group tier units

Level 4
Joined
Sep 10, 2023
Messages
43
Hello. Im making a map where 2 players share control of units. These players have 4 tier of units. I want to make a trigger where if one of the two players research the upgrade both players unlock the unit. I want to make this tiers with avaible/unavaible units, since I only want to display the current researched unit in the 0,0 grid of the building.

I have something like this but cant figure out how to make unavaible units of t2,t3,t4 at start since the trigger doesnt work for map initialization.

1707347928199.png



1707347973624.png

1707348035968.png
 

Attachments

  • 1707347993411.png
    1707347993411.png
    1.7 MB · Views: 0

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,552
So your triggers have some little mistakes like using (Integer A) without a For Loop. For limiting at startup, you could use either Map Initialization or Elapsed Time of 0.01 seconds as the Event, then simply Limit/Make Unavailable like you're doing already for your desired Players. If Map Initialization doesn't work for some reason then use Elapsed Time instead.

Anyway, I've created a system that should save you from having to create so many triggers. See the attached map below (requires latest patch to open).

It uses a Player Group variable and Tech-Type/Unit-Type array variables to automate the whole Begin/Cancel/Finish research process. It's a little more advanced but it's actually super simple to use. It's also dynamic in that it can work for any number of "shared players", not just two.

This is the only trigger you need to modify:
  • Shared Players Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- Setup our Shared Upgrade variables which our Begin/Cancel/Finish triggers use. --------
      • -------- --------
      • -------- How many upgrades does this system use? --------
      • Set VariableSet Shared_Upgrade_Count = 2
      • -------- --------
      • -------- What are the different types of upgrades? --------
      • Set VariableSet Shared_Upgrade_Type[1] = Black Gunpowder
      • Set VariableSet Shared_Upgrade_Type[2] = Iron Forged Swords
      • -------- --------
      • -------- What are the different types of units that these upgrades unlock? [0] should be your starting unit! --------
      • Set VariableSet Shared_Upgrade_Unit_Type[0] = Footman
      • Set VariableSet Shared_Upgrade_Unit_Type[1] = Rifleman
      • Set VariableSet Shared_Upgrade_Unit_Type[2] = Knight
      • -------- --------
      • -------- Add our "Shared" Players to the Shared Player Group: --------
      • Player Group - Add Player 1 (Red) to Shared_Player_Group
      • Player Group - Add Player 2 (Blue) to Shared_Player_Group
      • -------- --------
      • -------- Limit training for all of the upgrade units besides the starting unit: --------
      • Player Group - Pick every player in Shared_Player_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Shared_Player = (Picked player)
          • For each (Integer Shared_Loop) from 1 to Shared_Upgrade_Count, do (Actions)
            • Loop - Actions
              • Player - Make Shared_Upgrade_Unit_Type[Shared_Loop] Unavailable for training/construction by Shared_Player
  • Shared Players Begin Upg
    • Events
      • Unit - A unit Begins research
    • Conditions
      • ((Owner of (Triggering unit)) is in Shared_Player_Group.) Equal to True
    • Actions
      • Set VariableSet Shared_Upgrading_Player = (Owner of (Triggering unit))
      • Set VariableSet Shared_Upgrade_Type[0] = (Researched tech-type)
      • -------- --------
      • -------- Loop over all of the different upgrades we setup in the Shared Players Setup trigger: --------
      • For each (Integer Shared_Loop) from 1 to Shared_Upgrade_Count, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Shared_Upgrade_Type[0] Equal to Shared_Upgrade_Type[Shared_Loop]
            • Then - Actions
              • -------- We found our upgrade! Shared_Loop is set to it's [index]. --------
              • Player Group - Pick every player in Shared_Player_Group and do (Actions)
                • Loop - Actions
                  • Set VariableSet Shared_Player = (Picked player)
                  • -------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Shared_Player Not equal to Shared_Upgrading_Player
                    • Then - Actions
                      • Player - Set the max research level of Shared_Upgrade_Type[Shared_Loop] to 0 for Shared_Player
                    • Else - Actions
            • Else - Actions
  • Shared Players Cancel Upg
    • Events
      • Unit - A unit Cancels research
    • Conditions
      • ((Owner of (Triggering unit)) is in Shared_Player_Group.) Equal to True
    • Actions
      • Set VariableSet Shared_Upgrading_Player = (Owner of (Triggering unit))
      • Set VariableSet Shared_Upgrade_Type[0] = (Researched tech-type)
      • -------- --------
      • -------- Loop over all of the different upgrades we setup in the Shared Players Setup trigger: --------
      • For each (Integer Shared_Loop) from 1 to Shared_Upgrade_Count, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Shared_Upgrade_Type[0] Equal to Shared_Upgrade_Type[Shared_Loop]
            • Then - Actions
              • -------- We found our upgrade! Shared_Loop is set to it's [index]. --------
              • Player Group - Pick every player in Shared_Player_Group and do (Actions)
                • Loop - Actions
                  • Set VariableSet Shared_Player = (Picked player)
                  • -------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Shared_Player Not equal to Shared_Upgrading_Player
                    • Then - Actions
                      • Player - Set the max research level of Shared_Upgrade_Type[Shared_Loop] to 1 for Shared_Player
                    • Else - Actions
            • Else - Actions
  • Shared Players Finish Upg
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • ((Owner of (Triggering unit)) is in Shared_Player_Group.) Equal to True
    • Actions
      • Set VariableSet Shared_Upgrading_Player = (Owner of (Triggering unit))
      • Set VariableSet Shared_Upgrade_Type[0] = (Researched tech-type)
      • -------- --------
      • -------- Loop over all of the different upgrades we setup in the Shared Players Setup trigger: --------
      • For each (Integer Shared_Loop) from 1 to Shared_Upgrade_Count, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Shared_Upgrade_Type[0] Equal to Shared_Upgrade_Type[Shared_Loop]
            • Then - Actions
              • -------- We found our upgrade! Shared_Loop is set to it's [index]. --------
              • Player Group - Pick every player in Shared_Player_Group and do (Actions)
                • Loop - Actions
                  • Set VariableSet Shared_Player = (Picked player)
                  • -------- --------
                  • -------- Make the previous unit unavailable and the new unit available: --------
                  • Player - Make Shared_Upgrade_Unit_Type[(Shared_Loop - 1)] Unavailable for training/construction by Shared_Player
                  • Player - Make Shared_Upgrade_Unit_Type[Shared_Loop] Available for training/construction by Shared_Player
                  • -------- --------
                  • -------- Research the upgrade for the other player: --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Shared_Player Not equal to Shared_Upgrading_Player
                    • Then - Actions
                      • Player - Set the max research level of Shared_Upgrade_Type[Shared_Loop] to 1 for Shared_Player
                      • Player - Set the current research level of Shared_Upgrade_Type[Shared_Loop] to 1 for Shared_Player
                    • Else - Actions
            • Else - Actions
 

Attachments

  • Shared Upgrades 1.w3m
    21.7 KB · Views: 0
Last edited:
Level 4
Joined
Sep 10, 2023
Messages
43
Not only you helped me with the trigger but actually learned something of how to create better triggers and how to think with triggers if thats something.
 
Level 4
Joined
Sep 10, 2023
Messages
43
So your triggers have some little mistakes like using (Integer A) without a For Loop. For limiting at startup, you could use either Map Initialization or Elapsed Time of 0.01 seconds as the Event, then simply Limit/Make Unavailable like you're doing already for your desired Players. If Map Initialization doesn't work for some reason then use Elapsed Time instead.

Anyway, I've created a system that should save you from having to create so many triggers. See the attached map below (requires latest patch to open).

It uses a Player Group variable and Tech-Type/Unit-Type array variables to automate the whole Begin/Cancel/Finish research process. It's a little more advanced but it's actually super simple to use. It's also dynamic in that it can work for any number of "shared players", not just two.

This is the only trigger you need to modify:
  • Shared Players Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- Setup our Shared Upgrade variables which our Begin/Cancel/Finish triggers use. --------
      • -------- --------
      • -------- How many upgrades does this system use? --------
      • Set VariableSet Shared_Upgrade_Count = 2
      • -------- --------
      • -------- What are the different types of upgrades? --------
      • Set VariableSet Shared_Upgrade_Type[1] = Black Gunpowder
      • Set VariableSet Shared_Upgrade_Type[2] = Iron Forged Swords
      • -------- --------
      • -------- What are the different types of units that these upgrades unlock? [0] should be your starting unit! --------
      • Set VariableSet Shared_Upgrade_Unit_Type[0] = Footman
      • Set VariableSet Shared_Upgrade_Unit_Type[1] = Rifleman
      • Set VariableSet Shared_Upgrade_Unit_Type[2] = Knight
      • -------- --------
      • -------- Add our "Shared" Players to the Shared Player Group: --------
      • Player Group - Add Player 19 (Mint) to Shared_Player_Group
      • Player Group - Add Player 20 (Lavender) to Shared_Player_Group
      • -------- --------
      • -------- Limit training for all of the upgrade units besides the starting unit: --------
      • Player Group - Pick every player in Shared_Player_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Shared_Player = (Picked player)
          • For each (Integer Shared_Loop) from 1 to Shared_Upgrade_Count, do (Actions)
            • Loop - Actions
              • Player - Make Shared_Upgrade_Unit_Type[Shared_Loop] Unavailable for training/construction by Shared_Player
  • Shared Players Begin Upg
    • Events
      • Unit - A unit Begins research
    • Conditions
      • ((Owner of (Triggering unit)) is in Shared_Player_Group.) Equal to True
    • Actions
      • Set VariableSet Shared_Upgrading_Player = (Owner of (Triggering unit))
      • Set VariableSet Shared_Upgrade_Type[0] = (Researched tech-type)
      • -------- --------
      • -------- Loop over all of the different upgrades we setup in the Shared Players Setup trigger: --------
      • For each (Integer Shared_Loop) from 1 to Shared_Upgrade_Count, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Shared_Upgrade_Type[0] Equal to Shared_Upgrade_Type[Shared_Loop]
            • Then - Actions
              • -------- We found our upgrade! Shared_Loop is set to it's [index]. --------
              • Player Group - Pick every player in Shared_Player_Group and do (Actions)
                • Loop - Actions
                  • Set VariableSet Shared_Player = (Picked player)
                  • -------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Shared_Player Not equal to Shared_Upgrading_Player
                    • Then - Actions
                      • Player - Set the max research level of Shared_Upgrade_Type[Shared_Loop] to 0 for Shared_Player
                    • Else - Actions
            • Else - Actions
  • Shared Players Cancel Upg
    • Events
      • Unit - A unit Cancels an upgrade
    • Conditions
      • ((Owner of (Triggering unit)) is in Shared_Player_Group.) Equal to True
    • Actions
      • Set VariableSet Shared_Upgrading_Player = (Owner of (Triggering unit))
      • Set VariableSet Shared_Upgrade_Type[0] = (Researched tech-type)
      • -------- --------
      • -------- Loop over all of the different upgrades we setup in the Shared Players Setup trigger: --------
      • For each (Integer Shared_Loop) from 1 to Shared_Upgrade_Count, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Shared_Upgrade_Type[0] Equal to Shared_Upgrade_Type[Shared_Loop]
            • Then - Actions
              • -------- We found our upgrade! Shared_Loop is set to it's [index]. --------
              • Player Group - Pick every player in Shared_Player_Group and do (Actions)
                • Loop - Actions
                  • Set VariableSet Shared_Player = (Picked player)
                  • -------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Shared_Player Not equal to Shared_Upgrading_Player
                    • Then - Actions
                      • Player - Set the max research level of Shared_Upgrade_Type[Shared_Loop] to 1 for Shared_Player
                    • Else - Actions
            • Else - Actions
  • Shared Players Finish Upg
    • Events
      • Unit - A unit Finishes an upgrade
    • Conditions
      • ((Owner of (Triggering unit)) is in Shared_Player_Group.) Equal to True
    • Actions
      • Set VariableSet Shared_Upgrading_Player = (Owner of (Triggering unit))
      • Set VariableSet Shared_Upgrade_Type[0] = (Researched tech-type)
      • -------- --------
      • -------- Loop over all of the different upgrades we setup in the Shared Players Setup trigger: --------
      • For each (Integer Shared_Loop) from 1 to Shared_Upgrade_Count, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Shared_Upgrade_Type[0] Equal to Shared_Upgrade_Type[Shared_Loop]
            • Then - Actions
              • -------- We found our upgrade! Shared_Loop is set to it's [index]. --------
              • Player Group - Pick every player in Shared_Player_Group and do (Actions)
                • Loop - Actions
                  • Set VariableSet Shared_Player = (Picked player)
                  • -------- --------
                  • -------- Make the previous unit unavailable and the new unit available: --------
                  • Player - Make Shared_Upgrade_Unit_Type[(Shared_Loop - 1)] Unavailable for training/construction by Shared_Player
                  • Player - Make Shared_Upgrade_Unit_Type[Shared_Loop] Available for training/construction by Shared_Player
                  • -------- --------
                  • -------- Research the upgrade for the other player: --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Shared_Player Not equal to Shared_Upgrading_Player
                    • Then - Actions
                      • Player - Set the max research level of Shared_Upgrade_Type[Shared_Loop] to 1 for Shared_Player
                      • Player - Set the current research level of Shared_Upgrade_Type[Shared_Loop] to 1 for Shared_Player
                    • Else - Actions
            • Else - Actions
It doesnt seem to work, I cant figure what I did wrong. The units are unavaible at first as intended but the upgrades dont change the avaibility for other tiers.


1707362151110.png
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,552
I assume those are all Zombie (T1) in the video.

One possible issue that comes to mind -> The Crypt needs to have all four of these Zombies added to it's Units Trained field.

I didn't actually test the system so apologies if there's some mistakes, I'll try and test it now.
 
Level 4
Joined
Sep 10, 2023
Messages
43
I assume those are all Zombie (T1) in the video.

One possible issue that comes to mind -> The Crypt needs to have all four of these Zombies added to it's Units Trained field.

I didn't actually test the system so apologies if there's some mistakes, I'll try and test it now.
No need for apologies, yeah I checked that too

1707365725089.png



1707365764879.png


Wonder if its something with the Make Share_upgrade_unit_type (Shared_loop - 1)

Tried your map too and couldnt make it work either.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,552
No need for apologies, yeah I checked that too

View attachment 461008


View attachment 461009

Wonder if its something with the Make Share_upgrade_unit_type (Shared_loop - 1)

Tried your map too and couldnt make it work either.
I found the issue, I used the wrong Events for the Cancel/Finish triggers:
  • Unit - A unit Cancels research
  • Unit - A unit Finishes research
I mixed up Upgrade and Research.

This one always trips me up since you Upgrade a unit from say Scout Tower to Guard Tower but you also Research an Upgrade like Animal War Training. Then the Trigger Editor refers to Animal War Training as a Tech-Type but the Object Editor refers to it as an Upgrade...

Also, I recommend using this to post your triggers here:
It's easier for everyone to to work with these "Hive triggers" since we can edit them freely.
 
Last edited:
Level 4
Joined
Sep 10, 2023
Messages
43
I found the issue, I used the wrong Events for the Cancel/Finish triggers:
  • Unit - A unit Cancels research
  • Unit - A unit Finishes research
I mixed up Upgrade and Research.

This one always trips me up since you Upgrade a unit from say Scout Tower to Guard Tower but you also Research an Upgrade like Animal War Training. Then the Trigger Editor refers to Animal War Training as a Tech-Type but the Object Editor refers to it as an Upgrade...

Also, I recommend using this to post your triggers here:
It's easier for everyone to to work with these "Hive triggers" since we can edit them freely.
Thanks! I was also looking for a way to post triggers in the discord but couldnt find any
 
Top