Help with regions and unit alliance compared to another

njb013

New Member
Reaction score
0
Hi there, made a second thread because this is a different issue than with the other one.

I need to make an If statement using the following general syntax:

If ((entering unit) belongs to (an enemy of(the owner of(another unit already in region))) Equal to (False)) Then...

Problem is, I can't find a way to express this. The 'another unit already in region' part throws everything off completely. It could just be that I can't the right functions, I'm not sure. If you could help me with this, I would be forever grateful.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
One way you could do it is with a trigger combination like this:
(written in pseudo code)
Code:
Events
  Unit enters region
Conditions
Actions
  add triggering unit to RegionUnitGroup
  set OwnerOfRegion = Owner of Triggering Unit
  pick all units in RegionUnitGroup and do
    if ( Owner of picked Unit != OwnerOfRegion )
      set OwnerOfRegion = NoPlayer
    end
  end
Code:
Events
  Unit leaves region
Conditions
Actions
  remove triggering unit from RegionUnitGroup
  set OwnerOfRegion = Owner of ( Random unit from RegionUnitGroup )
  pick all units in RegionUnitGroup and do
    if ( Owner of picked Unit != OwnerOfRegion )
      set OwnerOfRegion = NoPlayer
    end
  end

At the end the Variable OwnerOfRegion (which is a player variable obviously) will always tell you who is currently the player who got the only units in the region. If two players have units in the region at least the variable OwnerOfRegion will be NoPlayer.

The other variable needed is RegionUnitGroup which is a unit group variable.

You should be able to do this in wc3 fairly easily i guess.
 

njb013

New Member
Reaction score
0
Wow, that works wonderfully, I think. I might just need the first part, we'll see. I'll get working on it and let you know! ^_^
 
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