• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Detect if ancient is rooted/uprooted?

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
This should work fairly well:
  • Root Orders
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Triggering unit) is An Ancient) Equal to True
    • Actions
      • Set VariableSet Root_Unit = (Triggering unit)
      • Set VariableSet Root_Order = (Issued order)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Root_Order Equal to (Order(unroot))
        • Then - Actions
          • -------- UPROOTED: --------
          • Game - Display to (All players) for 1.00 seconds the text: Uprooted
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Root_Order Equal to (Order(root))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Root_Unit is in Root_Group.) Equal to False
                • Then - Actions
                  • Unit Group - Add Root_Unit to Root_Group
                  • Trigger - Turn on Root Loop <gen>
                • Else - Actions
            • Else - Actions
              • -------- It issued a different order so it's no longer trying to Root. --------
              • Unit Group - Remove Root_Unit from Root_Group.
  • Root Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Root_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Root_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of Root_Unit) Not equal to (Order(root))
            • Then - Actions
              • Unit Group - Remove Root_Unit from Root_Group.
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Root_Unit is alive) Equal to True
                • Then - Actions
                  • -------- ROOTED: --------
                  • Game - Display to (All players) for 1.00 seconds the text: Rooted
                • Else - Actions
            • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Root_Group) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 

Attachments

  • Detect Root 1.w3m
    18.1 KB · Views: 4
Last edited:
Level 12
Joined
Jan 10, 2023
Messages
191
I've tried to do this once before and I'm surprised the building check worked because apparently I ended up checking the armor type instead of whether it was a building.

I think there may be a flaw in Uncle's trigger because if I order a unit to root, it will continue to have that order until it roots. If I then tell that unit to move or cancel before it has actually rooted, it will be considered as rooted per the condition, so you'll have to check Iceman's condition once the meet the condition of not having the root order.

So
if order not equal to root AND unit is a structure then...

If the structure but doesn't work try checking the armor type, for some reason I thought that both counted as a structure, rooted or unrooted. I'll look at my system when I got home, it was GUI and very similar to Uncle's trigger
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
I've tried to do this once before and I'm surprised the building check worked because apparently I ended up checking the armor type instead of whether it was a building.

I think there may be a flaw in Uncle's trigger because if I order a unit to root, it will continue to have that order until it roots. If I then tell that unit to move or cancel before it has actually rooted, it will be considered as rooted per the condition, so you'll have to check Iceman's condition once the meet the condition of not having the root order.

So
if order not equal to root AND unit is a structure then...

If the structure but doesn't work try checking the armor type, for some reason I thought that both counted as a structure, rooted or unrooted. I'll look at my system when I got home, it was GUI and very similar to Uncle's trigger
The Root Orders trigger will remove the Unit from the Unit Group if it issues an order other than root/unroot:
  • -------- It issued a different order so it's no longer trying to Root. --------
  • Unit Group - Remove Root_Unit from Root_Group.
The Condition you mentioned only runs for Units that are still inside of the Unit Group.

But after learning about the Building classification check that makes things a lot easier:
  • Root Order
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • ((Triggering unit) is An Ancient) Equal to True
    • Actions
      • Set VariableSet Root_Unit = (Triggering unit)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(unroot))
        • Then - Actions
          • -------- UPROOTED: --------
          • Game - Display to (All players) for 1.00 seconds the text: Uprooted
          • -------- --------
          • Set VariableSet Root_Counter = (Root_Counter + 1)
          • -------- --------
          • Unit Group - Add Root_Unit to Root_Group
          • -------- --------
          • Trigger - Turn on Root Loop <gen>
        • Else - Actions
  • Root Loop
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Root_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Root_Unit = (Picked unit)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit: Root_Unit's Boolean Field: Is a Building ('ubdg')) Equal to True
            • Then - Actions
              • Set VariableSet Root_Counter = (Root_Counter - 1)
              • -------- --------
              • Unit Group - Remove Root_Unit from Root_Group.
              • -------- --------
              • -------- This Condition may not be necessary: --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Root_Unit is alive) Equal to True
                • Then - Actions
                  • -------- ROOTED: --------
                  • Game - Display to (All players) for 1.00 seconds the text: Rooted
                • Else - Actions
              • -------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Root_Counter Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 

Attachments

  • Detect Root 2.w3m
    18.2 KB · Views: 4
Last edited:
Level 12
Joined
Jan 10, 2023
Messages
191
That should work now, but I'm not sure if you understood my point, unless I'm completely mistaken, but I don't think I was.

If the unit was in root group and didn't have the root order it would be removed, and then so long as it was alive it would display the 'Rooted' message.

But it's water under the bridge because that building check would cover it.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
That should work now, but I'm not sure if you understood my point, unless I'm completely mistaken, but I don't think I was.

If the unit was in root group and didn't have the root order it would be removed, and then so long as it was alive it would display the 'Rooted' message.

But it's water under the bridge because that building check would cover it.
You're mistaken, it works fine. A Unit can only ever be in Root_Group if it has the 'root' order. This will always be the case when it's trying to Root somewhere. The moment you change it's Orders to something else it is removed from Root_Group via the Root Orders trigger. A Unit that isn't inside of Root_Group cannot display the 'Rooted' message, that's simply not possible.

Root Orders always happens before Root Loop and prevents what you described.
 
Last edited:
Level 12
Joined
Jan 10, 2023
Messages
191
You're mistaken, it works 100% fine. A Unit can only ever be in Root_Group IF it has the Root order which will always be the case when it's trying to Root somewhere. The moment you change it's Orders it is removed from Root_Group via the Root Orders trigger. A Unit that isn't inside of Root_Group CANNOT display the 'Rooted' message, that's simply not possible since it need to be in the group to do so. Root Orders always happens before Root Loop which is the important thing to understand.
Your updated trigger does work 100%, the original one doesn't.

A unit enters root group when it unroots. When the order ceases to be root, which may well be because they were given a move or attack order, they were removed from the group.

But if the order was given to attack, or move or something else, they would have been removed and yet not rooted.

Here's what was done:
All root ordered units added to root group.
Every second pick root group unit.
If picked unit no longer has root order, for example if it was cancelled as well as if it was actually rooted, then it would check if it was alive and then if it was alive it would give the message "Rooted".

It's still up there in your post if you want to look.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
Your updated trigger does work 100%, the original one doesn't.

A unit enters root group when it unroots. When the order ceases to be root, which may well be because they were given a move or attack order, they were removed from the group.

But if the order was given to attack, or move or something else, they would have been removed and yet not rooted.

Here's what was done:
All root ordered units added to root group.
Every second pick root group unit.
If picked unit no longer has root order, for example if it was cancelled as well as if it was actually rooted, then it would check if it was alive and then if it was alive it would give the message "Rooted".

It's still up there in your post if you want to look.
A Unit enters Root_Group when it is issued the order to Root, not when it Unroots. We're tracking whether or not it's still trying to Root.

I tested the map quite a bit, I'm not sure what you're talking about.

Edit:
That being said, I think a Periodic Interval less than 0.10 would be wiser just in case there's a way to slip in an Order during the Rooting phase. Like during the Rooting animation, right before Root Loop runs, the Ancient seems to have a moment where it can issue another Order in it's Rooted form which would break things, although in my tests I can't produce this potential issue. Also, if the user reduces the Animation Time of the Root ability it could cause issues, that goes untested.
 
Last edited:
Level 12
Joined
Jan 10, 2023
Messages
191
If you order a unit to root across the map, it's order will remain root for the entire walk. If that order is cancelled they wrongly leave the group.

Again, it's water under the bridge but with the first trigger you posted that is what will happen.

Did your test include ordering a root from a range and then giving another order before the root occurs? You don't need an animation cancel to pull it off, you just need an accidental right click to break it.

I've also tested this under almost the exact same system and instead of using a building check I used an armor type check because they change armor types when rooted/unrooted.

Try it, or just read the original trigger, but I'm dropping it because it's off-topic at this point.

You should check it out if it's still of interest to you, I'm 100% correct and I don't need to test it to read the trigger and what it says.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
No, you're not 100% correct, lol. I don't think you fully understand how the Order events work or something. If you give another order before the root occurs it will be removed from the unit group, which is what we want to happen. The unit group is what detects when it has successfully rooted.

Anyway, it's pointless to even argue it since there's a demo map with all the proof you could ever need...
 
Level 12
Joined
Jan 10, 2023
Messages
191
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)If - Conditions
    • Root_Order Equal to (Order(unroot))
  • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Root_Order Equal to (Order(root))
      • Else - Actions
        • -------- It issued a different order so it's no longer trying to Root. --------
        • Unit Group - Remove Root_Unit from Root_Group.

I removed everything but the part I wasn't noticing. Sorry about that and sorry I've made an ass of myself.
Anyway, good work, for what it's worth coming for me after all that...
 
Level 12
Joined
Jan 10, 2023
Messages
191
I was damn surprised when I thought there was a mistake, I even did some double-takes, but I guess it was just one of those days where I was determined to play the fool 😅

Your trigger's honor is sound :thumbs_up:
 
Top