• 🏆 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!

[Solved] Detecting worker(orc type)

Status
Not open for further replies.
Level 20
Joined
Nov 20, 2005
Messages
1,178
Hello!
I need a functon to detect if the color of the worker that has just started the construction is blue(example) so to paint the constructing structure in the same color as soon as its building site "spawns".
I know it's a pain to detect undead or human constructing units type, but this one regards only orc type builders. Anyone can help, please?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
this should work for your need.
GetWorker() - Wc3C.net

There is room for script improvement, but i don't really care.
the principle is that : you register each unit who get a point order construction event and later when a construction start event trigger you check amongst them which one is hidden at the building position.
 
Last edited:
Level 20
Joined
Nov 20, 2005
Messages
1,178
Actually, because in my project the workers are building structures through a spellbook ability "build", i have a last ditch of effort to try this out with.
I will move on your alternative right after failing my attempt(sigh) although, not knowing anything about jass, i can't see how i could arrange your solution for my needs.
Thanks for helping. I shall update shortly.

EDIT: As i predicted, i'm out of any other options.
So, how do I use this system of yours, based on what i need?
 
Last edited:
Level 1
Joined
Aug 8, 2020
Messages
5
How do you do the construction spell, it would be very useful for my dungeon keeper map
upload_2020-8-8_12-42-14.png
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,522
Here's a GUI example of what you can do to get the Worker:
  • Add Worker To Loop
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peon
      • ((Triggering unit) is in Worker_Group.) Equal to False
      • (Issued order) Not equal to (Order(move))
      • (Issued order) Not equal to (Order(attack))
      • (Issued order) Not equal to (Order(smart))
      • (Issued order) Not equal to (Order(patrol))
    • Actions
      • Unit Group - Add (Triggering unit) to Worker_Group
      • Game - Display to (All players) for 1.00 seconds the text: (|cff00ff00Add|r: + (Name of (Triggering unit)))
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Worker_Group) Equal to 1
        • Then - Actions
          • Trigger - Turn on Worker Loop <gen>
        • Else - Actions
  • Remove Worker Orders
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peon
      • ((Triggering unit) is in Worker_Group.) Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(move))
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(holdposition))
          • (Issued order) Equal to (Order(attack))
          • (Issued order) Equal to (Order(stand down))
          • (Issued order) Equal to (Order(stop))
    • Actions
      • Unit Group - Remove (Triggering unit) from Worker_Group.
      • Game - Display to (All players) for 1.00 seconds the text: (|cffff0000Remove|r: + (Name of (Triggering unit)))
  • Remove Worker Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peon
      • ((Triggering unit) is in Worker_Group.) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from Worker_Group.
      • Game - Display to (All players) for 1.00 seconds the text: (|cffff0000Remove|r: + (Name of (Triggering unit)))
  • Worker Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Worker_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Worker = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Worker is hidden) Equal to True
            • Then - Actions
              • Set VariableSet Worker_Point = (Position of Worker)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 1.00 of Worker_Point.) and do (Actions)
                • Loop - Actions
                  • Set VariableSet Structure = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Structure is A structure) Equal to True
                      • (Structure is alive) Equal to True
                      • (Owner of Structure) Equal to (Owner of Worker)
                    • Then - Actions
                      • -------- THIS IS WHERE YOU CAN INTERACT WITH THE WORKER + STRUCTURE --------
                      • Game - Display to (All players) for 1.00 seconds the text: (Name of Worker)
                      • Game - Display to (All players) for 1.00 seconds the text: (Name of Structure)
                    • Else - Actions
              • Custom script: call RemoveLocation (udg_Worker_Point)
              • Unit Group - Remove Worker from Worker_Group.
            • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Worker_Group) Equal to 0
        • Then - Actions
          • Trigger - Turn off Worker Loop <gen>
        • Else - Actions
The Display Text Messages are not needed. They're just used for testing purposes.

Worker Loop is Initially OFF.
 

Attachments

  • GetWorker Example.w3m
    19 KB · Views: 16

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,522
Sorry for double post:
@Uncle it doesn't work:
Are the 3 event lines necessary in the second trigger or do i need to choose the one i need based on my situation?
It works, you must've made a mistake somewhere. Post your triggers and I can help you find the mistake.

An important thing I forgot to mention:
I designed this around the standard Peon, so you need to add conditions for any new orders that your worker may have available. Say for example you gave your Worker an ability like Blink, the "blink" order needs to be added to the conditions in the Add Worker To Loop and Remove Worker Orders triggers.

Add Worker To Loop:
This trigger is used to detect when you issue an order to build a structure. It uses a simple process of elimination, if the issued order wasn't move, attack, patrol, etc... then we know it must've been a build order. So make sure to eliminate any other orders your Peon can have that aren't related to building a structure.

Remove Worker Orders:
This trigger is used to detect when you issue a NON-build order. So now we're just doing the opposite of what we did in Add Worker To Loop.
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
there is no need of a timer loop, you're supposed to be able to get the builder when the build event fire

EDIT :

Since of native support of vJass of reforged editor, you need to paste the 2 library in your map.

And you use set udg_myVariableName = GetWorker() on a trigger with construction start event.

where myVariableName is a global unit GUI variable declared in variable editor
 
Last edited:
Level 20
Joined
Nov 20, 2005
Messages
1,178
2) You never turn on Worker Loop. Look closely, you're doing "Turn Off this trigger" when it should be "Turn On Worker Loop".

Epic fail :goblin_cry:

Stand by for update.

EDIT: It's working! It's f***ing working!!
Thank you Uncle! I need to remember your name. You just got a place in my credits list!
I'll call you in the future, should i get some further issues from a system such as this.
 
Last edited:
Status
Not open for further replies.
Top