• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Scanning map and removing specific building type.

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
  • Unclaim base
    • Events
      • Player - Player 1 (Red) types a chat message containing -unclaim as An exact match
      • Player - Player 2 (Blue) types a chat message containing -unclaim as An exact match
      • Player - Player 3 (Teal) types a chat message containing -unclaim as An exact match
      • Player - Player 4 (Purple) types a chat message containing -unclaim as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -unclaim as An exact match
      • Player - Player 6 (Orange) types a chat message containing -unclaim as An exact match
      • Player - Player 7 (Green) types a chat message containing -unclaim as An exact match
      • Player - Player 8 (Pink) types a chat message containing -unclaim as An exact match
      • Player - Player 9 (Gray) types a chat message containing -unclaim as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -unclaim as An exact match
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Bases[(Integer A)] Equal to (Triggering player)
            • Then - Actions
              • -------- CHANGE 11 if more bases --------
              • Set Bases[(Integer A)] = Bases[11]
              • Set BasesInUse[(Integer A)] = False
              • Game - Display to (Player group((Triggering player))) the text: |cffffcc00Base 1 ha...
            • Else - Actions
In my game, a human places a flag like object down to claim the base. When he types -unclaim I have the base/region free up. But I also need to remove the flag object if it's found in the map. Only one flag is able to be made.

How can I in this trigger scan the map for a specific object, and remove it if it's ownership is the triggering player?
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I assume your flag object is actually a unit, since it has an ownership. Actions under "Unit Group" category is used for these "scanning" tasks. For your example:

  • Unit Group - Pick every unit in (Units owned by (Triggering player) of type YOUR_FLAG) and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game
Picked unit refers to units that satisfy your search criteria.
 
Level 13
Joined
Oct 12, 2016
Messages
769
Don't forget to also remove your unit groups to prevent leaks:
  • Set TempGroup = (Units owned by (Triggering player) of type of type Flag)
  • Unit Group - Pick every unit in TempGroup and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game
  • Custom script: call DestroyGroup(udg_TempGroup)
 
Level 12
Joined
Dec 2, 2016
Messages
733
Don't forget to also remove your unit groups to prevent leaks:
  • Set TempGroup = (Units owned by (Triggering player) of type of type Flag)
  • Unit Group - Pick every unit in TempGroup and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game
  • Custom script: call DestroyGroup(udg_TempGroup)

What do leaks do? I briefly read about them months ago. Also why do I need to assign the unit group to a variable hen remove it?
 
What do leaks do?
Short:
Onto Leaks you have no access anymore, but they still exist, take up space in ram and calculating power.
That slowes down the performance, after a LOT of Leaks the match becomes quite uncomfortable to play.​
handling common Leaks.
technical detail.
Also why do I need to assign the unit group to a variable hen remove it?
That is one way, good one if you access one group multiple times.

other way is to set the autodestroy Flag (bj_wantDestroyGroup = true) provided by blizz, but sadly not setable without custom script.
The flag is reseted after each Group Function/Enumeration (to false).
This auto-destroy Flag works on most GUI Unit-Group-Actions.
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Playable Map Area) and do (Unit - Hide (Picked unit))
 
Status
Not open for further replies.
Top