• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Building Distance

Status
Not open for further replies.
Level 2
Joined
Nov 26, 2021
Messages
11
Hey wondering how to set a building distance so players cant build within 500 range of each other, mostly, a Specific builder cant build near buildings owned be enemy.
 
Level 7
Joined
Dec 9, 2014
Messages
89
This is probably the simplest way to do it. I attached a map with the trigger.

  • BuildingDistanceCheck
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • -------- Change the distance variable to the distance you want --------
      • -------- The building construction is cancelled if there are enemy buildings nearby. --------
      • -------- The resources are still used, so you need to refund the gold/lumber cost of the building. --------
      • -------- Unfortunetly there is no way to retrieve these costs directly, so you need to save these values somewhere. --------
      • -------- I find the easiest way is to use point value which you can set in the object editor for each building to correspond to the gold cost. --------
      • -------- If you need lumber cost as well you are probably better off saving all of the information in arrays. --------
      • Set VariableSet Distance = 500.00
      • Set VariableSet Point = (Position of (Constructing structure))
      • Set VariableSet TriggeringPlayer = (Owner of (Constructing structure))
      • Set VariableSet TriggeringUnit = (Constructing structure)
      • Set VariableSet UnitGroup = (Units within Distance of Point matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) belongs to an enemy of TriggeringPlayer.) Equal to True)).)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in UnitGroup) Greater than 0
        • Then - Actions
          • Unit - Explode TriggeringUnit.
          • Player - Add (Point-value of TriggeringUnit) to TriggeringPlayer.Current gold
          • Game - Display to (All players) the text: (You cannot build within + ((String(Distance)) + range of enemy buildings.))
        • Else - Actions
      • Custom script: call DestroyGroup(udg_UnitGroup)
      • Custom script: call RemoveLocation(udg_Point)
 

Attachments

  • building distance testmap.w3m
    18.5 KB · Views: 14
Status
Not open for further replies.
Top