Start when all units in region?

Jscooby

New Member
Reaction score
1
I need a trigger that checks that all players are in a region to start another trigger. I know this is probably going to need variables, such as player groups. But can't think of how to make it exactly.

Also, is there a way for one triggers event/condition to be that another trigger was turned off?
 

Sevion

The DIY Ninja
Reaction score
413
Do a trigger that fires on entering a region.

Set an integer variable to integer + 1.

If it's equal to the current amount of playing players or w/e you need, then do your thing.

Another trigger on exit to decrement the integer variable.
 

tommerbob

Minecraft. :D
Reaction score
110
Well you can check if a player's UNITS are in a region. It's a simple boolean condition. If you look, you shoudl be able to find it pretty easily.

For your second question, it is under

Trigger:
  • Trigger - Turn off (this trigger) (or any other trigger)
 

Jscooby

New Member
Reaction score
1
I'm still having trouble with this... :/ Any help? I don't think a boolean would do what I want.
 

BAkil

New Member
Reaction score
9
Alrighty this is I got, I hope it's what you want..

Now this trigger fires every time a unit enters Region 000. Obviously you're to replace Region 000 with your region of desire.
I heard that you need to make a variable for PLAYERGROUP to avoid memory leaks, although I don't really know how to work them, but I done my best..

Now what happens, it sets a PLAYERGROUP to (All Players), simply to avoid a memory leak.
It then picks all players in PLAYERGROUP - which is everyone - and sets a UNITGROUP too all units owned by the picked player which ARE in Region 000.
It checks if there's more than 0 units in the region, if that's true - meaning there is 1 or more units in the region belonging to a particular player - a variable called INTEGER is increased by 1. The UNITGROUP is then cleared to avoid memory leaks..
This process is repeated for every single player, which can be modified by altering the PLAYERGROUP.
Then the PLAYERGROUP is erased.

After all of this stuff, it then checks if INTEGER is 12 (This number must be changed depending on how many players are allowed in the map, and how many you want to be in the region at once to do your effect thingy..). If it is 12, that means units belonging to 12 different players have been found within Region 000, and then the action to run the trigger called Kill01 is executed. Again you must replace Kill01 with your trigger of desire.
Otherwise, it will display a message to all players saying "Need More Players!"

Here's the stuff, don't forget to ask me if you need more clarification - I'm a pretty bad teacher:
Trigger:
  • Check01
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Set PLAYERGROUP = (All players)
      • Player Group - Pick every player in PLAYERGROUP and do (Actions)
        • Loop - Actions
          • Set UNITGROUP = (Units owned by (Picked player) matching ((Region 000 <gen> contains (Matching unit)) Equal to True))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in UNITGROUP) Greater than 0
            • Then - Actions
              • Set INTEGER = (INTEGER + 1)
            • Else - Actions
          • Custom script: call DestroyGroup (udg_UNITGROUP)
      • Custom script: call DestroyForce (udg_PLAYERGROUP)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • INTEGER Equal to 12
          • Then - Actions
            • Trigger - Run Kill01 <gen> (ignoring conditions)
          • Else - Actions
            • Game - Display to (All players) the text: Need More Players!
 

BAkil

New Member
Reaction score
9
Fixed something!

I found out how to deal with memory leaks regarding Player Groups and updated/edited the above post for you.
 

Jscooby

New Member
Reaction score
1
Looks good. The only thing is, when the integer is set to 9 (the amount of playable players) does this mean it will not start unless there is 9 players? Is there a way to set so if only 3 players are playing that it will set the integer to 3?
 

Sevion

The DIY Ninja
Reaction score
413
Yes. You need to do this:

Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • INTEGER Equal to NUMBEROFPLAYERS


And in the map initialization, set NUMBEROFPLAYERS to the number of playing human players.

And make sure to have a trigger that checks for when players leave/get disconnected/kicked to decrement that integer.

However, you don't have to use the player group "leak" removal because, as BlackRose said, All Players doesn't leak.
 

Jscooby

New Member
Reaction score
1
I can't seem to find that line...? :/

EDIT:

This?

Trigger:
  • Set NUMBEROFPLAYERS = (All players controlled by a User player)
 

Jscooby

New Member
Reaction score
1
But the variable has to be an interger. And that isn't selectable as an integer... Any help?
 

tommerbob

Minecraft. :D
Reaction score
110
Trigger:
  • Set Players = (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) controller) Equal to User)))
    • Set PlayerCount = (Number of players in Players)


Make sure when a player leaves the game that you update the variable.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top