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

Units in range owned by player?

Status
Not open for further replies.
Level 8
Joined
Jul 29, 2010
Messages
319
I need a trigger that basically checks this "Number of units in range of unit owned by ally of player greater than number of units in range of unit owned by enemy of player" i can't seem to find all the right arguments even though i know exactly what i need, any help is appreciated :):p
 
Level 14
Joined
Nov 30, 2013
Messages
926
"Number of units in range of unit owned by ally of player greater than number of units in range of unit owned by enemy of player"
What you mean is to pick multiple units owned by two teams then define which is the two teams has larger amount of units?
  • Actions
    • Set Team[0] = (All allies of Player 1 (Red))
    • Set Team[1] = (All enemies of Player 1 (Red))
    • For each (Integer A) from 0 to 1, do (Actions)
      • Loop - Actions
        • Player Group - Pick every player in Team[(Integer A)] and do (Actions)
          • Loop - Actions
            • Set TempGroup = (Units owned by (Picked player))
            • Unit Group - Pick every unit in TempGroup and do (Actions)
              • Loop - Actions
                • Set CountUnits[(Integer A)] = (CountUnits[(Integer A)] + 1)
            • Custom script: call DestroyGroup(udg_TempGroup)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CountUnits[0] Greater than CountUnits[1]
      • Then - Actions
        • -------- Team 1 --------
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • CountUnits[1] Greater than CountUnits[0]
          • Then - Actions
            • -------- Team 2 --------
          • Else - Actions
            • -------- Tie --------
    • Custom script: call DestroyForce(udg_Team[0])
    • Custom script: call DestroyForce(udg_Team[1])
 
Level 8
Joined
Jul 29, 2010
Messages
319
What you mean is to pick multiple units owned by two teams then define which is the two teams has larger amount of units?
  • Actions
    • Set Team[0] = (All allies of Player 1 (Red))
    • Set Team[1] = (All enemies of Player 1 (Red))
    • For each (Integer A) from 0 to 1, do (Actions)
      • Loop - Actions
        • Player Group - Pick every player in Team[(Integer A)] and do (Actions)
          • Loop - Actions
            • Set TempGroup = (Units owned by (Picked player))
            • Unit Group - Pick every unit in TempGroup and do (Actions)
              • Loop - Actions
                • Set CountUnits[(Integer A)] = (CountUnits[(Integer A)] + 1)
            • Custom script: call DestroyGroup(udg_TempGroup)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CountUnits[0] Greater than CountUnits[1]
      • Then - Actions
        • -------- Team 1 --------
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • CountUnits[1] Greater than CountUnits[0]
          • Then - Actions
            • -------- Team 2 --------
          • Else - Actions
            • -------- Tie --------
    • Custom script: call DestroyForce(udg_Team[0])
    • Custom script: call DestroyForce(udg_Team[1])
it's for a zone capture type game mode, basically points get awarded periodically to the team who controls the zone, control of the zone is changed when a unit enters the zone and a timer starts, say 8 seconds, when the timer ends, which ever team has the most units in the zone is awarded control of the zone.
 
Level 14
Joined
Nov 30, 2013
Messages
926
it's for a zone capture type game mode, basically points get awarded periodically to the team who controls the zone, control of the zone is changed when a unit enters the zone and a timer starts, say 8 seconds, when the timer ends, which ever team has the most units in the zone is awarded control of the zone.
So how this system works is that whoever has the most units in that zone, that zone will be given to the team?
Then you'll need an array for the zones to get the numbers of units in that zone.
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Region Variables --------
      • Set Zone[0] = Zone 0 <gen>
      • Set Zone[1] = Zone 1 <gen>
      • Set Zone[2] = Zone 2 <gen>
      • Set Zone[3] = Zone 3 <gen>
      • -------- Examples --------
      • Set ZoneStructure[0] = Guard Tower 0000 <gen>
      • Set ZoneStructure[1] = Guard Tower 0003 <gen>
      • Set ZoneStructure[2] = Guard Tower 0001 <gen>
      • Set ZoneStructure[3] = Guard Tower 0002 <gen>
  • Actions
    • Set Team[0] = (All allies of Player 1 (Red))
    • Set Team[1] = (All enemies of Player 1 (Red))
    • For each (Integer A) from 0 to <Numbers of Zones>, do (Actions)
      • Loop - Actions
        • For each (Integer B) from 0 to 1, do (Actions)
          • Loop - Actions
            • Player Group - Pick every player in Team[(Integer B)] and do (Actions)
              • Loop - Actions
                • Set TempGroup = (Units in Zone[(Integer A)] owned by (Picked player))
                • Unit Group - Pick every unit in TempGroup and do (Actions)
                  • Loop - Actions
                    • Set CountUnits[(Integer B)] = (CountUnits[(Integer B)] + 1)
                • Custom script: call DestroyGroup(udg_TempGroup)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • CountUnits[0] Greater than CountUnits[1]
          • Then - Actions
            • -------- Team 1 : Win Statement --------
            • Unit - Change ownership of ZoneStructure[(Integer A)] to AllyPlayer and Change color
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • CountUnits[1] Greater than CountUnits[0]
              • Then - Actions
                • -------- Team 2 : Win Statement --------
                • Unit - Change ownership of ZoneStructure[(Integer A)] to EnemyPlayer and Change color
              • Else - Actions
                • -------- Tie Statement --------
        • Set CountUnits[0] = 0
        • Set CountUnits[1] = 0
    • Custom script: call DestroyForce(Team[0])
    • Custom script: call DestroyForce(Team[1])
 
Level 10
Joined
Sep 16, 2016
Messages
269
  • Events
  • Conditions
  • Actions
    • Set TempUnitGroup = (Units within 512.00 of TempPoint)
    • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
      • Loop - Actions
        • Set TempUnit = (Picked unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (TempUnit is A structure) Equal to False
            • (TempUnit is dead) Equal to False
            • (Owner of TempUnit) Not equal to Neutral Passive
            • (Owner of TempUnit) Not equal to Neutral Hostile
          • Then - Actions
            • If ((TempUnit belongs to an ally of Player 1 (Red)) Equal to True) then do (Set TeamACount = (TeamACount + 1)) else do (Set TeamBCount = (TeamBCount + 1))
          • Else - Actions
    • Custom script: call RemoveLocation( udg_TempPoint )
    • Custom script: call DestroyGroup( udg_TempUnitGroup )
 
Level 8
Joined
Jul 29, 2010
Messages
319
So how this system works is that whoever has the most units in that zone, that zone will be given to the team?
Then you'll need an array for the zones to get the numbers of units in that zone.
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Region Variables --------
      • Set Zone[0] = Zone 0 <gen>
      • Set Zone[1] = Zone 1 <gen>
      • Set Zone[2] = Zone 2 <gen>
      • Set Zone[3] = Zone 3 <gen>
      • -------- Examples --------
      • Set ZoneStructure[0] = Guard Tower 0000 <gen>
      • Set ZoneStructure[1] = Guard Tower 0003 <gen>
      • Set ZoneStructure[2] = Guard Tower 0001 <gen>
      • Set ZoneStructure[3] = Guard Tower 0002 <gen>
  • Actions
    • Set Team[0] = (All allies of Player 1 (Red))
    • Set Team[1] = (All enemies of Player 1 (Red))
    • For each (Integer A) from 0 to <Numbers of Zones>, do (Actions)
      • Loop - Actions
        • For each (Integer B) from 0 to 1, do (Actions)
          • Loop - Actions
            • Player Group - Pick every player in Team[(Integer B)] and do (Actions)
              • Loop - Actions
                • Set TempGroup = (Units in Zone[(Integer A)] owned by (Picked player))
                • Unit Group - Pick every unit in TempGroup and do (Actions)
                  • Loop - Actions
                    • Set CountUnits[(Integer B)] = (CountUnits[(Integer B)] + 1)
                • Custom script: call DestroyGroup(udg_TempGroup)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • CountUnits[0] Greater than CountUnits[1]
          • Then - Actions
            • -------- Team 1 : Win Statement --------
            • Unit - Change ownership of ZoneStructure[(Integer A)] to AllyPlayer and Change color
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • CountUnits[1] Greater than CountUnits[0]
              • Then - Actions
                • -------- Team 2 : Win Statement --------
                • Unit - Change ownership of ZoneStructure[(Integer A)] to EnemyPlayer and Change color
              • Else - Actions
                • -------- Tie Statement --------
        • Set CountUnits[0] = 0
        • Set CountUnits[1] = 0
    • Custom script: call DestroyForce(Team[0])
    • Custom script: call DestroyForce(Team[1])
When trying to save the map with this trigger i get this error
 

Attachments

  • Capture.JPG
    Capture.JPG
    52.1 KB · Views: 59
Level 14
Joined
Nov 30, 2013
Messages
926
It's because of the invalid parameter in these two.
  • Custom script: call DestroyForce(Team[0])
  • Custom script: call DestroyForce(Team[1])
Changed that into:
  • Custom script: call DestroyForce(udg_Team[0])
  • Custom script: call DestroyForce(udg_Team[1])
"udg_" is a kind of prefix that is commonly compiled on one of the variables in the Variables Editor as JASS.
 
Level 8
Joined
Jul 29, 2010
Messages
319
It's because of the invalid parameter in these two.
  • Custom script: call DestroyForce(Team[0])
  • Custom script: call DestroyForce(Team[1])
Changed that into:
  • Custom script: call DestroyForce(udg_Team[0])
  • Custom script: call DestroyForce(udg_Team[1])
"udg_" is a kind of prefix that is commonly compiled on one of the variables in the Variables Editor as JASS.
Oh, thanks for the info :D also what should the event be for this trigger
  • Change Ownership
    • Events
    • Conditions
    • Actions
      • Set Team[0] = (All allies of Player 1 (Red))
      • Set Team[1] = (All enemies of Player 1 (Red))
      • For each (Integer A) from 0 to 1, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 0 to 1, do (Actions)
            • Loop - Actions
              • Player Group - Pick every player in Team[(Integer B)] and do (Actions)
                • Loop - Actions
                  • Set TempGroup = (Units in Zone[(Integer A)] owned by (Picked player))
                  • Unit Group - Pick every unit in TempGroup and do (Actions)
                    • Loop - Actions
                      • Set CountUnits[(Integer B)] = (CountUnits[(Integer B)] + 1)
                  • Custom script: call DestroyGroup(udg_TempGroup)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CountUnits[0] Greater than CountUnits[1]
            • Then - Actions
              • -------- Team 1 Wins Control --------
              • Unit - Change color of Capture Point Glow (large) 0007 <gen> to Red
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CountUnits[1] Greater than CountUnits[0]
                • Then - Actions
                  • -------- Team 2 Wins Control --------
                  • Unit - Change color of Capture Point Glow (large) 0007 <gen> to Blue
                • Else - Actions
                  • -------- Tie Wins Control --------
                  • Set CountUnits[0] = 0
                  • Set CountUnits[1] = 0
                  • Custom script: call DestroyForce(udg_Team[0])
                  • Custom script: call DestroyForce(udg_Team[1])
EDIT: Nevermind the above question.

RE-EDIT i cannot seem to get any of the triggers to work at all, i'd need an actual map template to copy from, i can upload my map here if you want?
 
Last edited:
Level 11
Joined
May 16, 2016
Messages
730
it's for a zone capture type game mode, basically points get awarded periodically to the team who controls the zone, control of the zone is changed when a unit enters the zone and a timer starts, say 8 seconds, when the timer ends, which ever team has the most units in the zone is awarded control of the zone.
Here is a template for capturing zones.
In the INIT trigger you may change parameters:
1) Set AREA[0] - choose area on the map.
2) temp_unit[0] - set tower-marker which shows who controls the current area.
3)MAX CAPTURE - the current zone can't be captured more than x units. for example i set 4 units it means:
if you have 99 units in the area then capturing process speed will be like the area has only 4 units.
If you have 10 units of player 1 and 9 units of player 2, then 10-9 =1 it means player 1 start to capturing the area with speed of 1 unit.
If you have 10 units of player 1 and 5 units of player 2 then 10-5=5<4 ->4 it means player 1 start to capturing area with 4 units.
4)TIME TO CAPTURE - time of capturing the area. I set 8.
5)UNIT CAPTURING VALUE - the more unit on the area the larger speed. Each unit decreases time of capture I set 0.5 it means if you have 2 units then every second they would decrease time to capture by 0.5x2 = 1 sec so they need to wait 8 sec to capture the point. If you have 4 units then 0.5x4=2 sec. so they need to wait only 4 sec.

THE PROCESS OF CAPTURING:
TOWER IS NEUTRAL - beat THE TIME OF CAPTURE barrier then tower changed owner to your.
TOWER IS YOURS - You can "reinforce" your area by adding addtional timer to the captured area. Max additional timer can't be larger than TIME OF CAPTURE
TOWER IS ENEMY - Wait "reinforced" timer then the tower turns into neutral -> see TOWER IS NEUTRAL paragraph.
 

Attachments

  • CAPTURE ZONE TEMPLATE.w3x
    22.6 KB · Views: 29
Status
Not open for further replies.
Top