Smart & Attack: detecting unit/point/item target

Curo

Why am I still playing this game...?
Reaction score
109
Short version:
When a unit is given an order, how do I detect what type of thing is being targeted (unit, point, or item)?

Long version:
So say I want to have unit B mimic unit A's orders. I use a trigger that detects when unit A is ordered to do something. Stop and hold position are very simple: I just order unit B to stop/hold position. Even move and patrol aren't too difficult: all I have to do is order unit B to move to the target position of the order.

However, I get stumped when it comes to smart and attack, since these orders can target both points, units, and items. I can't order a unit to attack-move to a point if the target of the order was a unit or item. Similarly I can't order a unit to right click a unit if the target of the order was a point or item.

I tried using conditions like target unit of issued order = no unit and target item of issued order = no item to find if the target was a point. However these conditions don't seem to work properly together, and I'm having trouble detecting what the target of the order is.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Have you tried multiple triggers where each one has a different event of the type (Unit is Issued an Order Targeting a point/Targeting a Unit/With no target)?
 

Curo

Why am I still playing this game...?
Reaction score
109
Have you tried multiple triggers where each one has a different event of the type (Unit is Issued an Order Targeting a point/Targeting a Unit/With no target)?

I suppose that would be the smart thing to do. However I still have the problem of distinguishing between units and items as "objects".
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
I suppose you could try issuing both orders - one for the unit and one for the item - at the same time. One of them should not take since there will be no unit or item to reference, then the other would work.
 

Curo

Why am I still playing this game...?
Reaction score
109
I suppose you could try issuing both orders - one for the unit and one for the item - at the same time. One of them should not take since there will be no unit or item to reference, then the other would work.

True. If I isolate it into 3 different triggers (point, no target, object), I shouldn't have a problem. My biggest fear was that with a smart or attack order, I would order my unit to attack-move or right click the target point, and if the target was an object, the unit would move to the center of the playable map area (which tends to happen when the game can't find the point you are looking for). But since I'm separating the point target into a different trigger, I should have no problem.

Thanks, Ghan!
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
I believe the problem is that it is difficult to use a condition to tell what type of order was issued - you are almost forced to use the events themselves to distinguish such things.
 

Curo

Why am I still playing this game...?
Reaction score
109
So I've separated it into 3 triggers. One them looks like this:

Trigger:
  • ghoul command object
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Triggering unit) Equal to hero_ghoul
      • generals_command Equal to True
    • Actions
      • Set TempGroup = (Units owned by (Owner of hero_ghoul) matching (((Unit-type of (Matching unit)) Equal to Gorified Minion (lv 1)) or (((Unit-type of (Matching unit)) Equal to Gorified Minion (lv 2)) or (((Unit-type of (Matching unit)) Equal to Gorified Minion (lv 3)) or ((Unit-type of (Matching unit)) Equal to Gorified Minion (lv 4))
      • Game - Display to (All players) for 5.00 seconds the text: (Number of minions: + (String((Number of units in TempGroup))))
      • If ((Issued order) Equal to (Order(smart))) then do (Unit Group - Pick every unit in TempGroup and do (Unit - Order (Picked unit) to Right-Click (Target unit of issued order))) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(attack))
        • Then - Actions
          • Unit Group - Pick every unit in TempGroup and do (Unit - Order (Picked unit) to Attack (Target unit of issued order))
          • Unit Group - Pick every unit in TempGroup and do (Unit - Order (Picked unit) to Attack (Target item of issued order))
        • Else - Actions
      • Custom script: call DestroyGroup (udg_TempGroup)


My problem is that even though my chat line displays the correct number of minions, only the first minion follows the orders. It works fine for the point and no object orders, but for some reason I only get one minion at a time listening to the object orders. If at any time I only have one minion, that minion will become the one that listens (so if all but one die, or all die and a new one is born). Regardless of how many minions I have, the only one that listens is one that has been alive alone at some time or another...if that makes any sense.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Do you know whether or not your if statements evaluate to true so that the action is really run?
 

Curo

Why am I still playing this game...?
Reaction score
109
Do you know whether or not your if statements evaluate to true so that the action is really run?

If they weren't true, wouldn't it be that none of the minions would respond (as opposed to just the one)?

Just for curiosity, I added a line that displays the given order as a chat string. Indeed it does come up as "smart" or "attack", so the if statements are true. An interesting thing I did notice though was that if my hero is already attacking, the game does not register my smart and attack orders (as in it does not display the string). Regardless, only one minion listens when the order is properly registered, as I said previously.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
So assuming that all of the conditions are correct.... (Since at least one minion responds for all commands.)
You might try using a unit variable for Target Unit of Order... since that function can be evil at times (basically, I believe it can get lost if you're not careful). So set a unit variable to that and then use that in the Unit Group loop. Same method should work for non-units (we hope).
 

Curo

Why am I still playing this game...?
Reaction score
109
So assuming that all of the conditions are correct.... (Since at least one minion responds for all commands.)
You might try using a unit variable for Target Unit of Order... since that function can be evil at times (basically, I believe it can get lost if you're not careful). So set a unit variable to that and then use that in the Unit Group loop. Same method should work for non-units (we hope).

Hmm so you are saying that Target Unit of Order may get lost in the loop? That makes sense. I'll try out a variable.

You say "if I'm not careful". How am I not being careful here? Is just the fact that I'm using GUI enough to say that I'm not being careful?

Edit: You were right, it worked. Thanks again Ghan! I'd still like to know why it was getting lost previously, and why the smart/attack event does not register if my hero is already attacking.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> How am I not being careful here?

It's not that you're not being careful. It's simply that the function there is untrustworthy. You're giving an order to your minion, right? Well, what is the Target of Issued Order now? It may have changed. That's why you need a variable. Much more stable. :)
 

Curo

Why am I still playing this game...?
Reaction score
109
You're giving an order to your minion, right? Well, what is the Target of Issued Order now? It may have changed. That's why you need a variable. Much more stable. :)

I actually had that train of thought as well. But, the target of the minion is the same as the target that fired the trigger in the first place. So it must just be that wc3 doesn't hold Target of Issued Order through loops.
 
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