"Herding" units

W

witch doctor

Guest
Hello, I'm posting because I have a bit of a problem. I want one of my units (I.e. this dog) to be able to "herd" other units, e.g. sheep.

I've tried things like swapping ownership when it gets close, so I can manualy move it, and losing ownership when it gets too far away from the sheep. I've also tried editing monster lures, but i can't see what "lures" the units or how to change what they lure...
Another thing is I tried doing the "if units enter a region around a point" or something (i.e. around the dog) that they swap ownership, but this seems not to work, or works very infrequently...

If anyone had anything to say or do that'd help me, I'd be glad.

So, in brief, I'd like either something that changes ownership of a unit in proximity with another, and loses it when the distance is too great, Or, something that causes units to follow another...

Any help is appreciated!
 

Romek

Super Moderator
Reaction score
963
E: Unit comes within range of <Dog>
C: Triggering unit is a Sheep
A: Order triggering unit to move to [Polar offset [ angle between units, distance between units + 400]

Brief, and quite rubbish. But might give you a general idea :)
If you want a better trigger [from the editor], just ask :)
 

Squishy

You can change this now in User CP.
Reaction score
127
Wouldn't it be more realistic if the units moved away from the dog when the dog came too close? But if you wanna go with the ownership method, make a periodic trigger that picks all units within 500 (or whatever range you want) of the dog and adds them to a unit group while giving control of the units to you. Then, make another periodic trigger that checks all units within your unit group, and when one of them isn't within 500 of the dog anymore, return it to its original owner and remove it from the unit group.

EDIT: Too late
 
W

witch doctor

Guest
I know about the units moving away and that, but I thought it might be too difficult as it is :p lol
But if there was some way I could do that it'd be great! lol

But yeah, I'm still havin trouble... what I've done is:

E: Every Second
C: Unit-type of (picked unit) Equal to Footman
A: Unit group- Pick every unit in (units in (region centered at (Position of Dog 0000 <gen>) with size (300, 300)) and do (actions)
- loop - Actions
Unit - Change ownership of (picked unit) to player one (red) and change color

I think that's similar to what you suggested, but I'm not sure if what I've done is wrong... I suspect it might b e the (picked unit) bit, but I'm not sure....

I've tried doing the ordering it to move to a polar offset bit, but I'm not sure how to do this and how it would stop if out of range or w.e :(

Well thanks for your help lol :p

Edit: And yeah, I know it says footman, It's just a test until it works lol, as that's the first unit that appeared in the unit bit :p lol
 

Squishy

You can change this now in User CP.
Reaction score
127
To do the move units to position with polar offset, you need to use the action Unit-Issue Order Targetting a point. Then, at the part where it asks for a point, look for point with polar offset and use arithmetic to get the '+400' bit. If you want to go with the control swap idea, this is what the triggers would look like.
Code:
Trigger 1
    Events
        Unit - A unit comes within 500.00 of Your Dog Unit
    Conditions
        (Unit-type of (Triggering unit)) Equal to Sheep
    Actions
        Unit - Change ownership of (Triggering Unit) to Player 1 (Red) and Retain color
        Unit Group - Add (Triggering unit) to (Unit_Group_Variable)
Code:
Trigger 2
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Unit_Group_Variable)) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked Unit) is in (Units within 500.00 of (Position of Your Dog Unit)) Equal to False
                    Then - Actions
                        Unit - Change ownership of (Picked unit) to Neutral Passive and Retain color
                    Else - Actions
 
W

witch doctor

Guest
Right thanks :)

It all works apart from the last bit; I can't seem to work out how to find the

"((Picked Unit) is in (Units within 500.00 of (Position of Your Dog Unit)) Equal to False"

thing. I've had a look, but I can't find where that is in the conditions, like I mean, do I find it under e.g. boolen comparison or something?

Sorry for being a pain lol :p and thanks for your help!
 

Romek

Super Moderator
Reaction score
963
Seriously.. Just do what I said :p

Code:
    Events
        Unit - A unit comes within 500.00 of [B][Wolf][/B]
    Conditions
        (Unit-type of (Triggering unit)) Equal to [B][Sheep][/B]
    Actions
        Set Temp_Point = Position of (Triggering unit)
        Set Temp_Point2 = Position of [b][Wolf][/b]
        Unit - Order (Triggering unit) to Move To (Temp_Point) offset by 500.00 towards (Angle from (Temp_Point2) to (Temp_Point) degrees)
        Custom Script: call RemoveLocation(udg_Temp_Point)
        Custom Script: call RemoveLocation(udg_Temp_Point2)

Works perfectly. [tested]
 
W

witch doctor

Guest
Thanks for your help everyone! :D

I didn't really understand the triggers (not because I'm new to world edit, but because I'm new to using more detailed triggers!) but I had a look and it works!

:D


Edit:
Btw, is there anyway to get the trigger to work if the dog dies? Like, can I summon a new dog and get the trigger to work on that?
Thanks :)
 

Squishy

You can change this now in User CP.
Reaction score
127
If the dog is a Hero and you revive it, it will still work fine. If it is a unit, set the unit to a variable and every time the unit respawns, set the variable to the new unit. Then use your variable in the trigger is replace of Dog.
 
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