Secondary Unit who Mimic Primary Unit.

Kitt

New Member
Reaction score
5
Basically what I would like, is to have one main unit (the hero) who is followed around by a secondary unit, but CANNOT be controlled by the player directly. The secondary unit should alway try and stay within about 400 AoE of the Primary Unit, and should follow all commands given by the player to the Primary unit, such as Attack and Halt commands.

The main unit will have an array of skills which cause both units to make an action, but I think this will be the easiest part, as I just have to code things like I normally would for a skill, but do something in two places.

I'm primarily worried about figuring out how to get the Secondary Unit to follow and mimic the Primary unit in a fluid manner. If anyone has any ideas, or suggestions on ways I can accomplish this, or even a link to a guide that covers something like this, I would be very grateful =D

--Kitt
 

woot

New Member
Reaction score
8
cool idea.. I'm doing something similar in my map


Do you want the following unit to be invulnerable?

if so.. use the "Locust" ability on the following unit to make it untargetable

You can also use the Event - Unit is issued an order (something like that) and then set the following unit (based on which unit issued the order) to do the same order

and perhaps a periodic event that checks the current order of your following units, and if its blank, set it to move towards the owner
 

FireBladesX

Eating my wings!
Reaction score
123
You can accomplish basic following through the generic "follow" command, although you probably already knew that. You probably also already know to locust the shadow unit, but maybe not. I would also assume transparency (Animation, change vertex coloring).

2 triggers, with the events being (Unit is issued an order targeting a point), (Unit is issued an order targeting a unit).

The conditions are string comparisons, if the order is equal to move or if the order is equal to attack.

If the issued order is equal to move, then order the shadow to follow the hero. If the issued order is equal to attack, then order the shadow to attack that unit.

I know that giving a unit the classification of "worker" makes it so that the unit won't auto-attack, but it also gives it an icon in the corner. Annoying, huh?

Edit: Slow :|
 

Kitt

New Member
Reaction score
5
Thank you both!

Using the Follow command is nice and smooth, but it has the Secondary Unit practically hugging the Primary. Is there any way to have the Secondary Unit stop following at about 400 range?

Also, I still haven't figured out how to make the unit uncontrollable, yet still auto acquire (making them Neutral Passive prevents this, and Neutral Aggressive causes them to attack the Primary Unit).
 

FireBladesX

Eating my wings!
Reaction score
123
Have you tried adding the Locust ability to it?

I think that there's a gameplay constant called "Follow Range", but I'm not sure if that's what changes it.
 

Kitt

New Member
Reaction score
5
Have you tried adding the Locust ability to it?

I think that there's a gameplay constant called "Follow Range", but I'm not sure if that's what changes it.

The problem, though, is that I want Allies or Opponents to be able to Heal/Attack/Target/etc. the Secondary Unit.
 

woot

New Member
Reaction score
8
You could make the unit owned by Neutral Hostile I guess ? =\ although that seems kind of iffy
 

Azlier

Old World Ghost
Reaction score
461
Well, you can add and remove locust via a trigger. It will make it unselectable but targetable. (I think, I don't know if you have to go through the Hide/Unhide steps or not. And even if it does work, I don't know whether you can target it with spells and targeted attacks or not.)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
maybe have a look at this map i once made awhile ago.

theres a companion (warden) which is following your hero all the time attacking nearby enemys etc etc.
there are different commands you can give you companion by typing them as a chat message:
-go (warden searches nearby enemys)
-help (warden attacks enemys which attack you + follows your hero)
-follow (warden follows your hero but doesnt attack)
-stay back (warden is moving randomly within 500 range of your hero)
-hold position (warden stops following your hero nor will she attack enemys)
-do your best (warden follows your hero + attacks nearby enemys + attacks enemys which attack you hero + attacks enemys attacked by you.)

the warden does always target the creep with lowest hitpoints.
 

Kitt

New Member
Reaction score
5
I know this is a bit of an old topic, but I recently took my project up again, and began working with this idea of a "shadow unit" some more. I've got a fairly decently working set of triggers - though they're rough, and of course they leak - but they should be enough to give anyone else who wants to do something similar enough to work with =)

The three triggers take care of making the the "shadow unit" do the following:
1) Be 'unselectable' - that is, unable to control directly, though still targetable.
2) Follow the "main unit" (The mechanics of this are actually a little more intricate then originally planned. Description below).
3) Attack whatever the "main unit" was ordered to attack. If no order, then the "shadow unit" will auto attack.

The way the trigger that makes the "shadow unit" follow actually only triggers when the "main unit" is ordered to move to a spot via a right click. If this happens, then the "shadow unit" will also move to that location (with a small offset to prevent bumping into one another); however, if the "main unit" is ordered to move to a location via the 'move' command, then the "shadow unit" will stay put. This way, with some strategy, it's actually possible to split up the two in order to do some interesting tricks.

I'm actually pleased with how this method worked out - it feels more fluid and less frustrating, yet still generally disallows you from simply treating them as two different units (it's very hard to control them separately in different areas of a map).

And here are my (rough) triggers:

Unselectable Trigger:
Code:
    Events
        Time - Every 0.10 seconds of game time
    Conditions
    Actions
        Selection - Remove "Shadow Unit" from selection for (Owner of "Shadow Unit")

Following Trigger:
Code:
    Events
        Unit - "Main Unit" Is issued an order targeting a point
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Issued order) Equal to (Order(smart))
            Then - Actions
                Unit - Order "Shadow Unit" to Move To ((Target point of issued order) offset by 100.00 towards (Angle from (Position of "Main Unit") to (Position of "Shadow Unit")) degrees)
            Else - Actions
                Do nothing

Attacking Trigger:
Code:
    Events
        Unit - "Main Unit" Is issued an order targeting an object
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Or - Any (Conditions) are true
                    Conditions
                        (Issued order) Equal to (Order(attack))
                        (Issued order) Equal to (Order(smart))
            Then - Actions
                Unit - Order "Shadow Unit" to Attack (Target unit of issued order)
            Else - Actions
                Do nothing

Let me know what you think, and hopefully I've helped someone else, too =)
Meow!
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Selection actions tend to be really slow to run...

And, what about other orders?
Or, "smart / object" could also be an item on the ground that you right-click.

"Do nothing" is not needed. Just remove it. It does exactly what it says, nothing...
 

vinkia

New Member
Reaction score
0
wow cool spell, i tried to make a similar as u did but whenever the hero died the illusion was still at the place the hero died and when i revived it would come straight back to me..weird..:D
 
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