• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Building Requirements - 200 distance of each other

Status
Not open for further replies.
Level 8
Joined
Dec 29, 2006
Messages
359
How can I make it so buildings have to be built within 200 of each other, and if the player tries to build a building more than 200 from another allied building, an error message appears?
 
I hope this helps:
  • Way 1
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Set TempLocA = (Position of (Constructing structure))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 200.00 of TempLocA matching ((((Matching unit) is A structure) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of (Constructing structure))) Equal to True)))) and do (Actions)
        • Loop - Actions
          • Set TempIntA = (TempIntA + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempIntA Equal to 0
        • Then - Actions
          • Unit - Kill (Constructing structure)
        • Else - Actions
Way 1 is the most effective way, it will never fail, but you will not get your gold back if you fail to build close to an allied building.

  • Way 2
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Set TempLocA = (Position of (Constructing structure))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 200.00 of TempLocA matching ((((Matching unit) is A structure) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of (Constructing structure))) Equal to True)))) and do (Actions)
        • Loop - Actions
          • Set TempIntA = (TempIntA + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempIntA Equal to 0
        • Then - Actions
          • Selection - Select (Constructing structure) for (Owner of (Constructing structure))
          • Game - Force (Owner of (Constructing structure)) to press Escape/Cancel
        • Else - Actions
Way 2 is slightly less efficient, but it will give you your money back.
 
Level 17
Joined
Apr 13, 2008
Messages
1,608
You don't have to select and force the player to press cancel, you can just issue the building the cancel order.
I would also like to note that the player won't get back 100% of the resources unless you set the gameplay constants so.

There's actually a third way, I think I would go with: Aura.
Give all buildings an aura with 200 range, make this aura affect units as well, so players would have a visible indicator where can they build (the aura buff / model on the builder).
 
Status
Not open for further replies.
Top