Multiple Units in Region?

g0tmk

New Member
Reaction score
0
Hi, I have been searching around for a method to check when a region contains multiple units - as in, when two peasants enter a region, it kills the two. When one enters by itself, nothing, and when three enters, it kills two and leaves one alone.

My apologies if this question has been asked before, but I have searched every phrasing of my problem I can think of.
 

the_ideal

user title
Reaction score
61
First you have to have a region placed (obviously). Then in the trigger editor do an Integer Comparison for (number of units in region) equal to (1), etc.
 

g0tmk

New Member
Reaction score
0
I've tried this, but it does nothing when two (or more) riflemen enter the region. I'm not sure, but I think the problem lies with my condition..? Also, would that action be enough to kill both units? I think it would, as the trigger should fire twice, once for each unit.

Events
Unit - A unit enters P1Combine1 <gen>

Conditions
(Number of units in (Units in P1Combine2 <gen> matching ((Unit-type of (Matching unit)) Equal to Rifleman))) Equal to 2

Actions
Unit - Kill (Triggering unit)
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, for the first this will only kill the entering unit...
You'll need to pick the units inside the region first, and then kill them ;)

Then, the event "Unit - Unit Enters Region" will actually fire before the unit is actually counted as "Inside the region" by the condition...

So I'd suggest you add a 0.00 wait before the first actions and then use an "If" and use your condition there and then do the group thing ;)
 

g0tmk

New Member
Reaction score
0
This is what I have so far, thanks for all the input - it does everything right now but kill the units that enter. The whole trigger was supposed to detect two units, kill them, and replace them with a higher level unit. Unfortunately I think there is something wrong with the check I run

Trigger:
  • Combine
    • Events
      • Unit - A unit enters P1Combine1 &lt;gen&gt;
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Rifleman
          • (Unit-type of (Triggering unit)) Equal to Archer
    • Actions
      • Wait 0.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in P1Combine1 &lt;gen&gt; matching ((Unit-type of (Matching unit)) Equal to (Unit-type of (Triggering unit))))) Equal to 2
        • Then - Actions
          • Unit Group - Pick every unit in (Units in P1Combine1 &lt;gen&gt; matching (((Picked unit) is in (Units of type (Unit-type of (Triggering unit)))) Equal to True)) and do (Unit - Kill (Picked unit))
          • If ((Unit-type of (Triggering unit)) Equal to Rifleman) then do (Unit - Create 1 Sniper for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees) else do (Do nothing)
          • If ((Unit-type of (Triggering unit)) Equal to Archer) then do (Unit - Create 1 Legolas for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees) else do (Do nothing)
        • Else - Actions
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top