• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Solved] Remove Units in Region when no player-owned units in Region

Status
Not open for further replies.

Warchieftan

W

Warchieftan

Hey,

Ive been racking my mind over this the last two days so any help would be appreciated.

I'm attempting to create a trigger to remove all units in a region owned by player 12 ((brown)Computer) when there are no units in the region owned by players 1-10 (Users) Ive tried any variation of trigger I can think of so I'm rather stumped. There are several different unit types in the region under Player 12's control so I'm not sure a 'remove unit type' would be appropriate in this situation. I have included the main trigger I have been trying with variations below but for simplicity sake only included units owned by Player 1 in the condition:

Unit Despawn
Events
Unit - A unit leaves Unit Spawn Region <gen>
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in (Units in Unit Spawn Region <gen> owned by Player 1 (Red))) Equal to 0
Then - Actions
Unit Group - Pick every unit in (Units in Unit Spawn Region <gen>) and do (Unit - Remove (Picked unit) from the game)
Else - Actions

Thanks in advance!
 
So what exactly is the problem?
In your example you remove all units. If you only want units removed by player 12 you can do it like in the condition: Units in Spawn owned by player 12

You should however add additional events. If a unit dies "leaves region" is not triggered, so you need an extra event for a unit dies.
Maybe you also want the event "enters region". I don't know what you want to happen if there are no units of player 1-10 in the region and a unit owned by player 12 enters the region.

The triggers how you posted them here leak (Things That Leak).

Code:
you can post your triggers using the trigger tags: [trigger]your trigger[/trigger]
 
So basically as you say, I have a trigger to spawn units when players enter region, and I want them to despawn again when the player leaves the region to prevent lag however as there could be more then one player in the region, I can't use 'player leaves region' on its own to remove the units, I need some form of condition to ensure there are no other players in the region before despawning the units in the region. I was initially using 'owned by player 12' but have tried many variations of this trigger to get it to work with no luck, this trigger was simply an example of what I was trying to achieve.
 
That's the trigger.
If a unit owned by player 12 enters the region and there are no player 1-10 units in the region all units of player 12 in the region will be removed. If you do not want this behaviour, remove the A unit enters Region event.
If a unit dies and there are no player 1-10 units in the region all units of player 12 in the region will be removed. If you do not want this behaviour, remove the A unit Dies event.
  • Trigger
    • Events
      • Unit - A unit leaves Region 000 <gen>
      • Unit - A unit Dies
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Set TempGroup = (Units in Region 000 <gen> matching ((((Matching unit) is alive) Equal to True) and ((Player number of (Owner of (Matching unit))) Less than or equal to 10)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Equal to 0
        • Then - Actions
          • Custom script: call DestroyGroup(udg_TempGroup)
          • Set TempGroup = (Units in Region 000 <gen> matching ((Owner of (Matching unit)) Equal to Player 12 (Brown)))
          • 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)
        • Else - Actions
          • Custom script: call DestroyGroup(udg_TempGroup)
 
Awesome man, thanks! That did the trick! One last question, any chance you know a way to condition a trigger to your IP address or server or something? I want to make a trigger that changes my name e.g and possibly creator commands, but don't want other players on other servers or players on lan games to be able to access them?

  • Khonsu
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
      • (Player 1 (Red) controller) Equal to User
      • (Name of Player 1 (Red)) Equal to Warchieftan
    • Actions
      • Game - Display to (All players) the text: The Tok'ra Khonsu h...
      • Player - Set name of Player 1 (Red) to Khonsu
Thanks!
 
There is an easier thing can remove every unit when not owned of player.you must first create an event = a unit enters [name of region].second you must create a condition from boolean= owner of entering unit is an enemy of [your target player] and finally create an action that removes entering units=remove entering unit from game
 
Status
Not open for further replies.
Back
Top