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
889
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
889
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
889
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
889
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
889
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
889
> 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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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