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.
 
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)?
 
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".
 
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.
 
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!
 
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.
 
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.
 
Do you know whether or not your if statements evaluate to true so that the action is really run?
 
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.
 
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).
 
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.
 
> 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. :)
 
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.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      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