• 🏆 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!

Need Help (to detect player owned units in region)

Status
Not open for further replies.
Level 4
Joined
Jan 23, 2009
Messages
74
The the trigger i made there are 4 conditions which are supposed to detect units owned by 4 different players in 4 different regions (1 for each)
Each one of them is supposed to detect a unit from a different player in my player array (comp). But i don't understand what I'm doing wrong.

B/c most of the triggers are linked to each other, its easier to just upload the map instead of link triggers.

i hope som1 can help me >.>
 
Last edited:
Level 4
Joined
Jan 23, 2009
Messages
74
  • map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • If ((Player 1 (Red) slot status) Equal to Is playing) then do (Set red = Player 1 (Red)) else do (Do nothing)
      • If ((Player 2 (Blue) slot status) Equal to Is playing) then do (Set blue = Player 2 (Blue)) else do (Do nothing)
      • If ((Player 3 (Teal) slot status) Equal to Is playing) then do (Set teal = Player 3 (Teal)) else do (Do nothing)
      • If ((Player 4 (Purple) slot status) Equal to Is playing) then do (Set purp = Player 4 (Purple)) else do (Do nothing)
      • Visibility - Disable black mask
      • Visibility - Disable fog of war
  • Comp
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching ((((((Picked player) is an ally of teal) Equal to True) or (((Picked player) is an ally of purp) Equal to True)) or ((((Picked player) is an ally of red) Equal to True) or (((Picked player) is an ally of blue) Equal to True))) and (((Pic and do (Actions)
        • Loop - Actions
          • Set Comp[(Integer A)] = (Picked player)
  • Pits
    • Events
      • Unit - A unit enters Player1 Pit <gen>
      • Unit - A unit enters Player2 Pit <gen>
      • Unit - A unit enters Player3 Pit <gen>
      • Unit - A unit enters Player4 Pit <gen>
    • Conditions
      • (Number of units in (Units in Player1 Pit <gen> owned by Comp[(Integer A)])) Equal to 1
      • (Number of units in (Units in Player2 Pit <gen> owned by Comp[(Integer A)])) Equal to 1
      • (Number of units in (Units in Player3 Pit <gen> owned by Comp[(Integer A)])) Equal to 1
      • (Number of units in (Units in Player4 Pit <gen> owned by Comp[(Integer A)])) Equal to 1
    • Actions
      • Game - Display to (All players) for 5.00 seconds the text: FIGHT STARTED
      • Unit Group - Pick every unit in (Units owned by red) and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to (Center of Player1 Spawn <gen>)
      • Unit Group - Pick every unit in (Units owned by blue) and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to (Center of Player2 Spawn <gen>)
      • Unit Group - Pick every unit in (Units owned by teal) and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to (Center of Player3 Spawn <gen>)
      • Unit Group - Pick every unit in (Units owned by purp) and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to (Center of Player4 Spawn <gen>)
  • end
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Player - Add 1 to Player 8 (Pink) Current gold
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in Arena <gen>)) Less than 2
        • Then - Actions
          • Unit Group - Pick every unit in (Units in Arena <gen>) 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 5 (Yellow)
                • Then - Actions
                  • Player - Add 1 to Player 1 (Red) Current lumber
                  • Unit - Kill (Picked unit)
                  • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Player 1 ...
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Equal to Player 6 (Orange)
                • Then - Actions
                  • Player - Add 1 to Player 2 (Blue) Current lumber
                  • Unit - Kill (Picked unit)
                  • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Player 2 ...
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Equal to Player 7 (Green)
                • Then - Actions
                  • Player - Add 1 to Player 3 (Teal) Current lumber
                  • Unit - Kill (Picked unit)
                  • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Player 3 ...
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Equal to Player 8 (Pink)
                • Then - Actions
                  • Player - Add 1 to Player 4 (Purple) Current lumber
                  • Unit - Kill (Picked unit)
                  • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Player 4 ...
                • Else - Actions
        • Else - Actions
  • Winner
    • Events
      • Player - Player 8 (Pink)'s Current gold becomes Equal to 7.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (((Player 2 (Blue) Current lumber) Greater than or equal to (Player 4 (Purple) Current lumber)) and ((Player 2 (Blue) Current lumber) Greater than (Player 1 (Red) Current lumber))) and (((Player 2 (Blue) Current lumber) Greater than or equal to (Player 3 (Teal) Current lumber)) and ((Player 2 (Blue) Current lumber) Greater than or equal to (Player 2 (Blue) Current lumber)))
        • Then - Actions
          • Game - Display to (All players) the text: PLAYER 2 IS A WINNE...
          • Wait 5.00 seconds
          • Game - Victory Player 2 (Blue) (Skip dialogs, Skip scores)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (((Player 3 (Teal) Current lumber) Greater than or equal to (Player 4 (Purple) Current lumber)) and ((Player 3 (Teal) Current lumber) Greater than (Player 1 (Red) Current lumber))) and (((Player 3 (Teal) Current lumber) Greater than or equal to (Player 3 (Teal) Current lumber)) and ((Player 3 (Teal) Current lumber) Greater than or equal to (Player 2 (Blue) Current lumber)))
        • Then - Actions
          • Game - Display to (All players) the text: PLAYER 3 IS A WINNE...
          • Wait 5.00 seconds
          • Game - Victory Player 3 (Teal) (Skip dialogs, Skip scores)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (((Player 4 (Purple) Current lumber) Greater than or equal to (Player 4 (Purple) Current lumber)) and ((Player 4 (Purple) Current lumber) Greater than (Player 1 (Red) Current lumber))) and (((Player 4 (Purple) Current lumber) Greater than or equal to (Player 3 (Teal) Current lumber)) and ((Player 4 (Purple) Current lumber) Greater than or equal to (Player 2 (Blue) Current lumber)))
        • Then - Actions
          • Game - Display to (All players) the text: PLAYER 4 IS A WINNE...
          • Wait 5.00 seconds
          • Game - Victory Player 4 (Purple) (Skip dialogs, Skip scores)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (((Player 1 (Red) Current lumber) Greater than or equal to (Player 4 (Purple) Current lumber)) and ((Player 1 (Red) Current lumber) Greater than (Player 1 (Red) Current lumber))) and (((Player 1 (Red) Current lumber) Greater than or equal to (Player 3 (Teal) Current lumber)) and ((Player 1 (Red) Current lumber) Greater than or equal to (Player 2 (Blue) Current lumber)))
        • Then - Actions
          • Game - Display to (All players) the text: PLAYER 1 IS A WINNE...
          • Wait 5.00 seconds
          • Game - Victory Player 1 (Red) (Skip dialogs, Skip scores)
        • Else - Actions
  • Choose
    • Events
      • Player - Player 1 (Red) types a chat message containing -Choose as An exact match
    • Conditions
      • (Player 1 (Red) Food used) Equal to 0
    • Actions
      • Unit - Create 1 RedPick for Player 5 (Yellow) at (Center of Player1 Pit <gen>) facing Default building facing degrees
  • Gull
    • Events
      • Player - Player 1 (Red) types a chat message containing -gull as An exact match
    • Conditions
    • Actions
      • Set RedPick = Sea Gull
 
Level 4
Joined
Jan 23, 2009
Messages
74
Well what i had in mind was to require all possible units would be in their respective pits before starting, not just one of the pits being filled.
This way every single "pit" would have a unit inside (except for the one that correspond the the computer player w/o a user ally)
 
Wait, you can't have IntegerA in a raw condition. Use this:
  • trigger1
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set Pits[1] = (Region 1 Pit <gen>)
    • Set Pits[2] = (Region 2 Pit <gen>)
    • Set Pits[3] = (Region 3 Pit <gen>)
    • Set Pits[4] = (Region 4 Pit <gen>)
  • Trigger
  • Events
    • Unit - A unit enters Player1 Pit <gen>
    • Unit - A unit enters Player2 Pit <gen>
    • Unit - A unit enters Player3 Pit <gen>
    • Unit - A unit enters Player4 Pit <gen>
  • Conditions
  • Actions
    • For each (IntegerA) from 1 to 10, do (Actions)
      • Loop - Actions
        • For each (IntegerB) from 1 to 4, do (Actions)
          • Loop - Actions
            • Set Unit_Group = (Units in Pits[(IntegerB)] owned by Comp[(IntegerA)]
            • If (All conditions are true) then do (Actions) else do (Actions)
              • If - Conditions
                • (Number of units in Unit_Group) Equal to 1
              • Then - Actions
                • //Actions here
            • Custom script: call DestroyGroup (udg_Unit_Group)
Pits[] are Region type variable.
 
Level 4
Joined
Jan 23, 2009
Messages
74
Ok so i changed the triggers but it still doesnt work (at least with only 2 people)
  • map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Pits[1] = Player1 Pit <gen>
      • Set Pits[2] = Player2 Pit <gen>
      • Set Pits[3] = Player3 Pit <gen>
      • Set Pits[4] = Player4 Pit <gen>
      • Set Spawn[1] = Player1 Spawn <gen>
      • Set Spawn[2] = Player2 Spawn <gen>
      • Set Spawn[3] = Player3 Spawn <gen>
      • Set Spawn[4] = Player4 Spawn <gen>
      • If ((Player 1 (Red) slot status) Equal to Is playing) then do (Set red = Player 1 (Red)) else do (Do nothing)
      • If ((Player 2 (Blue) slot status) Equal to Is playing) then do (Set blue = Player 2 (Blue)) else do (Do nothing)
      • If ((Player 3 (Teal) slot status) Equal to Is playing) then do (Set teal = Player 3 (Teal)) else do (Do nothing)
      • If ((Player 4 (Purple) slot status) Equal to Is playing) then do (Set purp = Player 4 (Purple)) else do (Do nothing)
      • Visibility - Disable black mask
  • Pits alt
    • Events
      • Unit - A unit enters Player1 Pit <gen>
      • Unit - A unit enters Player2 Pit <gen>
      • Unit - A unit enters Player3 Pit <gen>
      • Unit - A unit enters Player4 Pit <gen>
    • Conditions
    • Actions
      • Game - Display to (All players) for 5.00 seconds the text: FIGHT STARTED
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 4, do (Actions)
            • Loop - Actions
              • Set unit_group = (Units in Pits[(Integer B)] owned by Comp[(Integer A)])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in unit_group) Equal to 1
                • Then - Actions
                  • Unit Group - Pick every unit in (Units owned by red) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Player1 Spawn <gen>)
                  • Unit Group - Pick every unit in (Units owned by blue) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Player2 Spawn <gen>)
                  • Unit Group - Pick every unit in (Units owned by teal) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Player3 Spawn <gen>)
                  • Unit Group - Pick every unit in (Units owned by purp) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Player4 Spawn <gen>)
                • Else - Actions
              • Custom script: call DestroyGroup (udg_unit_group)
i still dont under stand why it doesnt work :/
 

Attachments

  • Animal Abuse0.02C.w3x
    29.5 KB · Views: 41
It's because your Comp trigger is wrong, so the reference in Comp[(IntegerA)] is also wrong.

This is your Comp trigger:
  • Comp
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching ((((((Picked player) is an ally of teal) Equal to True) or (((Picked player) is an ally of purp) Equal to True)) or ((((Picked player) is an ally of red) Equal to True) or (((Picked player) is an ally of blue) Equal to True))) and (((Pic and do (Actions)
        • Loop - Actions
          • Set Comp[(Player number of (Picked player))] = (Picked player)
When you use ''Pick every player in (All players matching'', you need "Matching player" to perform the "match", not "Picked player". Picked player is after you pick the players.
So, it should be:
  • Player Group - Pick every player in (All players matching ((((((Matching player) is an ally of teal) Equal to True) or (((Matching player) is an ally of purp) Equal to True)) or ((((Matching player) is an ally of red) Equal to True) or (((Matching player) is an ally of blue) Equal to True))) and (((Mat and do (Actions)
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,456
You have a lot of locations leaks. Fix them like this:

  • Pits alt
    • Events
      • Unit - A unit enters Player1 Pit <gen>
      • Unit - A unit enters Player2 Pit <gen>
      • Unit - A unit enters Player3 Pit <gen>
      • Unit - A unit enters Player4 Pit <gen>
    • Conditions
    • Actions
      • Game - Display to (All players) for 5.00 seconds the text: FIGHT STARTED
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 4, do (Actions)
            • Loop - Actions
              • Set unit_group = (Units in Pits[(Integer B)] owned by Comp[(Integer A)])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in unit_group) Equal to 1
                • Then - Actions
                  • Set Point1 = (Center of Player1 Spawn <gen>)
                  • Unit Group - Pick every unit in (Units owned by red) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Point1)
                  • Custom script: call RemoveLocation(udg_Point1)
                  • Set Point1 = (Center of Player2 Spawn <gen>)
                  • Unit Group - Pick every unit in (Units owned by blue) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Point1)
                  • Custom script: call RemoveLocation(udg_Point1)
                  • Set Point1 = (Center of Player3 Spawn <gen>)
                  • Unit Group - Pick every unit in (Units owned by teal) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Point1)
                  • Custom script: call RemoveLocation(udg_Point1)
                  • Set Point1 = (Center of Player1 Spawn <gen>)
                  • Unit Group - Pick every unit in (Units owned by purp) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Point1)
                  • Custom script: call RemoveLocation(udg_Point1)
                • Else - Actions
              • Custom script: call DestroyGroup (udg_unit_group)
 
Level 4
Joined
Jan 23, 2009
Messages
74
I tried doing what you said, but it wouldlt allow it. there were some errors.
Mainly the errors were where i set Point1 as players 2, 3, and 4 spawns


  • Pits alt
    • Events
      • Unit - A unit enters Player1 Pit <gen>
      • Unit - A unit enters Player2 Pit <gen>
      • Unit - A unit enters Player3 Pit <gen>
      • Unit - A unit enters Player4 Pit <gen>
    • Conditions
    • Actions
      • Game - Display to (All players) for 5.00 seconds the text: Unit Chosen
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 4, do (Actions)
            • Loop - Actions
              • Set unit_group = (Units in Pits[(Integer B)] owned by Comp[(Integer A)])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in unit_group) Equal to 1
                • Then - Actions
                  • Set Point1 = Player1 Spawn <gen>
                  • Unit Group - Pick every unit in (Units owned by Player 5 (Yellow)) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Point1)
                  • Custom script: call RemoveLocation (udg_Point1)
                  • Set Point1 = Player2 Spawn <gen>
                  • Unit Group - Pick every unit in (Units owned by Player 6 (Orange)) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Point1)
                  • Custom script: call RemoveLocation (udg_Point1)
                  • Set Point1 = Player3 Spawn <gen>
                  • Unit Group - Pick every unit in (Units owned by Player 7 (Green)) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Point1)
                  • Custom script: call RemoveLocation (udg_Point1)
                  • Set Point1 = Player4 Spawn <gen>
                  • Unit Group - Pick every unit in (Units owned by Player 8 (Pink)) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Point1)
                  • Custom script: call RemoveLocation (udg_Point1)
                • Else - Actions
              • Custom script: call DestroyGroup (udg_unit_group)
Also before trying to fix the leaks by using this variable, when i i tested this map with some friends, we were all able to choose our units, and they spawned in their respective "pit" regions but nothing happend after that, the units did not enter the arena
if you want me to link the (current) map i will
 
  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set unit_group = (Units in Pits[(Integer B)] owned by Comp[(Integer A)])
Since you use the same Integer Number, 1 to 4, you don't need Integer B here, just use the Integer A:

  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • Set unit_group = (Units in Pits[(Integer A)] owned by Comp[(Integer A)])
 
Level 4
Joined
Jan 23, 2009
Messages
74
It Still wont let me enable the trigger,
this is it currently
  • Pits alt
    • Events
      • Unit - A unit enters Player1 Pit <gen>
      • Unit - A unit enters Player2 Pit <gen>
      • Unit - A unit enters Player3 Pit <gen>
      • Unit - A unit enters Player4 Pit <gen>
    • Conditions
    • Actions
      • Game - Display to (All players) for 5.00 seconds the text: Unit Chosen
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 4, do (Actions)
            • Loop - Actions
              • Set unit_group = (Units in Pits[(Integer A)] owned by Comp[(Integer A)])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in unit_group) Equal to 1
                • Then - Actions
                  • Set Point1 = Player1 Spawn <gen>
                  • Unit Group - Pick every unit in (Units owned by Player 5 (Yellow)) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Point1)
                  • Custom script: call RemoveLocation (udg_Point1)
                  • Set Point1 = Player2 Spawn <gen>
                  • Unit Group - Pick every unit in (Units owned by Player 6 (Orange)) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Point1)
                  • Custom script: call RemoveLocation (udg_Point1)
                  • Set Point1 = Player3 Spawn <gen>
                  • Unit Group - Pick every unit in (Units owned by Player 7 (Green)) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Point1)
                  • Custom script: call RemoveLocation (udg_Point1)
                  • Set Point1 = Player4 Spawn <gen>
                  • Unit Group - Pick every unit in (Units owned by Player 8 (Pink)) and do (Actions)
                    • Loop - Actions
                      • Unit - Move (Picked unit) instantly to (Center of Point1)
                  • Custom script: call RemoveLocation (udg_Point1)
                • Else - Actions
              • Custom script: call DestroyGroup (udg_unit_group)
but to show you whats wrong you'll have to check it out in trigger editor yourself imo
 

Attachments

  • Animal Abuse0.02E1.w3x
    26.5 KB · Views: 36
Level 4
Joined
Jan 23, 2009
Messages
74
I now allows me to enable the trigger again, but it still send the units to their respective Point1s, which leads me to believe the conditions are the problem. it'd probably be less confusing if i knew how to work the actions that use integer A/B. or what they did for that matter xD
 
Level 4
Joined
Jan 23, 2009
Messages
74
the units appear in "pit" region fine, however once all players have chosen and create their unit in their pit the units do not move to their point1

WAIT could it be that it doesn't work BECAUSE the unit is created in the pit and doesn't "enter" it per-say?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Player Group - Pick every player in (All players matching ((((((Matching player) is an ally of teal) Equal to True) or... and do (Actions)
    • Loop - Actions
      • Set Comp[(Player number of (Picked player))] = (Picked player)
  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • Set unit_group = (Units in Pits[(Integer A)] owned by Comp[(Integer A)])
Computer players 5-8, integer runs from 1-4.
 
Status
Not open for further replies.
Top