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

When a unit builds a structure, how do I refer to the builder unit?

Status
Not open for further replies.
Level 1
Joined
Jan 6, 2013
Messages
3
Just a question here, such as if a peasant builds a farm.
I've tried things like "casting unit" and "summoning unit", but I can't seem to find the right one.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
@ruler
You can't really tell or refer to a worker that has just finished constructed a building by using that method.

You're limited to only differentiate between the worker repairs a completed building, and the worker repairs a constructing building - Unit Group check.
But you can't refer to the unit when it has done finished constructed the building - not unless you handle a system which checks the worker's current order per X interval.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Assuming the building is created before the ability starts; you can add set the building to a temporary unit variable when it enters the map, and immediately after when the ability starts, refer to this building, and null it to prevent conflicts with normal repairs.

EDIT: Here are two triggers that seem to work quite nicely:
  • Get Repair
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Repair (Human)
    • Actions
      • Game - Display to (All players) the text: Starts
      • Set NewBuilder = (Triggering unit)
  • Get Building
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Game - Display to (All players) the text: ((Name of (Triggering unit)) + ( being constructed by + (Name of NewBuilder)))
      • Set NewBuilder = No unit
Seemingly instant-speed as well.

EDIT2: This doesn't work if the building is placed at the exact same position as the peasant. The order will be reversed in that case.

EDIT3: Better:
  • Get Building 2
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Set NewBuilding = (Triggering unit)
      • Game - Display to (All players) the text: Construction started
  • Get Repair 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Repair (Human)
    • Actions
      • Game - Display to (All players) the text: ((Name of (Triggering unit)) + ( has started constructing + (Name of NewBuilding)))
      • Set NewBuilding = No unit
(using the order first hypothesised)
 
Status
Not open for further replies.
Top