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

Bring ressources to nearest building

Status
Not open for further replies.
Level 37
Joined
Mar 6, 2006
Messages
9,240
This pick the closest Town hall owned by the same player in playable map area, and orders Temp_Unit_1 to right-click it. You need some event and set Temp_Unit_1 to some unit ofcoruse.

The event could be "unit acquires and item" and then check the item type.

  • Untitled Trigger 052 Copy
    • Events
    • Conditions
    • Actions
      • Temp_Unit_1 = Triggering unit // or something else
      • Temp_Unit_2 = No unit
      • Set Temp_Loc_1 = (Position of Temp_Unit_1)
      • Set Temp_Real_1 = 9999999.00
      • Set Temp_Group_1 = (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) Equal to Town Hall) and ((Owner of (Matching unit)) Equal to (Owner of (Temp_Unit_1))))))
      • Unit Group - Pick every unit in Temp_Group_1 and do (Actions)
        • Loop - Actions
          • Set Temp_Loc_2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Temp_Loc_1 and Temp_Loc_2) Less than Temp_Real_1
            • Then - Actions
              • Set Temp_Unit_2 = (Picked unit)
              • Set Temp_Real_1 = (Distance between Temp_Loc_1 and Temp_Loc_2)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Temp_Loc_2)
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
      • Custom script: call DestroyGroup(udg_Temp_Group_1)
      • Unit - Order Temp_Unit_1 to Right-Click Temp_Unit_2
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
How about this:
  • Set x = 100
  • For each Integer A from 1 to x/5 do:
    • Set temppoint1 = Position of (Triggering Unit)
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in x from (Triggering Unit) matching ((Matching Unit) is of Unit-type Pit) or ((Matching Unit) is of Unit-type Village Center) and do:
      • Unit - Order (Triggering Unit) to - right-click (Picked Unit)
      • Set x = 0
      • Custom script: call RemoveLocation(udg_temppoint1)
      • Skip remaining actions
    • Set x = x + 100
    • Custom script: call RemoveLocation(udg_temppoint1)
It checks every 100 range around the unit for a building and if there's one matching the condition orders the unit to go there.
 
Status
Not open for further replies.
Top