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

Building must be within range of another..

Status
Not open for further replies.
Level 9
Joined
Jul 20, 2009
Messages
427
Could someone please help me make a trigger that requires a building to be built within the range of another building.
For example in my map before any building can be built it must be within x range of a road otherwise it won't be created and it won't cost you any resources then a text would appear that informs you that it must be built near a road..thanks in advance trigger tags please..
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Start Building
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(farm))
          • (Issued order) Equal to (Order(altarofkings))
    • Actions
      • Set Temp_Loc_1 = (Target point of issued order)
      • Set Temp_Loc_2 = (Position of (Triggering unit))
      • -------- ---------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Road_Boolean Equal to False
        • Then - Actions
          • Set Temp_Real_1 = 0.00
          • For each (Integer A) from 1 to 12, do (Actions)
            • Loop - Actions
              • Set Temp_Loc_3 = (Temp_Loc_1 offset by 256.00 towards Temp_Real_1 degrees)
              • Set Temp_Real_1 = (Temp_Real_1 + 36.00)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at Temp_Loc_3) Equal to Lordaeron Summer - Rock
                • Then - Actions
                  • Set Road_Boolean = True
                • Else - Actions
              • Custom script: call RemoveLocation(udg_Temp_Loc_3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Road_Boolean Equal to False
            • Then - Actions
              • Unit - Order (Triggering unit) to Move To Temp_Loc_2
              • Floating Text - Create floating text that reads Can't build there -... above (Triggering unit) with Z offset 96.00, using font size 12.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 2.75 seconds
            • Else - Actions
        • Else - Actions
          • Set Temp_Group = (Units within 512.00 of Temp_Loc_1 matching (((Matching unit) is A structure) Equal to True))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in Temp_Group) Equal to 0
            • Then - Actions
              • Unit - Order (Triggering unit) to Move To Temp_Loc_2
              • Floating Text - Create floating text that reads Can't build there -... above (Triggering unit) with Z offset 96.00, using font size 12.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 2.75 seconds
            • Else - Actions
          • Custom script: call DestroyGroup(udg_Temp_Group)
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
      • Custom script: call RemoveLocation(udg_Temp_Loc_2)
The first building has to be built next to a road. Change the terrain typed used in this trigger to terrain type of your road. Following building have to be built near some other building. You can change the distances.

Create a variable called Road_Boolean. It should be false initially. You may need to use an array if it's for multiplaying.

Add all buildings you need to conditions.
Add some conditions to the unit group selection, like owner of picked unit equal to owner of triggering unit.
 
Level 9
Joined
Jul 20, 2009
Messages
427
  • Start Building
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(farm))
          • (Issued order) Equal to (Order(altarofkings))
    • Actions
      • Set Temp_Loc_1 = (Target point of issued order)
      • Set Temp_Loc_2 = (Position of (Triggering unit))
      • -------- ---------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Road_Boolean Equal to False
        • Then - Actions
          • Set Temp_Real_1 = 0.00
          • For each (Integer A) from 1 to 12, do (Actions)
            • Loop - Actions
              • Set Temp_Loc_3 = (Temp_Loc_1 offset by 256.00 towards Temp_Real_1 degrees)
              • Set Temp_Real_1 = (Temp_Real_1 + 36.00)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at Temp_Loc_3) Equal to Lordaeron Summer - Rock
                • Then - Actions
                  • Set Road_Boolean = True
                • Else - Actions
              • Custom script: call RemoveLocation(udg_Temp_Loc_3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Road_Boolean Equal to False
            • Then - Actions
              • Unit - Order (Triggering unit) to Move To Temp_Loc_2
              • Floating Text - Create floating text that reads Can't build there -... above (Triggering unit) with Z offset 96.00, using font size 12.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 2.75 seconds
            • Else - Actions
        • Else - Actions
          • Set Temp_Group = (Units within 512.00 of Temp_Loc_1 matching (((Matching unit) is A structure) Equal to True))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in Temp_Group) Equal to 0
            • Then - Actions
              • Unit - Order (Triggering unit) to Move To Temp_Loc_2
              • Floating Text - Create floating text that reads Can't build there -... above (Triggering unit) with Z offset 96.00, using font size 12.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 2.75 seconds
            • Else - Actions
          • Custom script: call DestroyGroup(udg_Temp_Group)
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
      • Custom script: call RemoveLocation(udg_Temp_Loc_2)
The first building has to be built next to a road. Change the terrain typed used in this trigger to terrain type of your road. Following building have to be built near some other building. You can change the distances.

Create a variable called Road_Boolean. It should be false initially. You may need to use an array if it's for multiplaying.

Add all buildings you need to conditions.
Add some conditions to the unit group selection, like owner of picked unit equal to owner of triggering unit.

It worked!thanks but how do I do it such that every building I build has to be near a road?
 
Level 9
Joined
Jul 20, 2009
Messages
427
Silly me, I forgot to add the other buildings to the condition, hehe..Problem resolved!+ reputation for you and I will credit you in map when its done..
 
Status
Not open for further replies.
Top