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

[Solved] Need help with my road system

Level 12
Joined
Oct 28, 2019
Messages
481
After some study I´ve made myself a road system

I have set a Scout tower dummy to build the Road (cause the small area)
The building time is 1 second, when it finish it create a dummy in the place (to detect any buildings near)
  • Build Road
    • Events
      • Unit - A unit owned by Player 1 (Red) Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Road
    • Actions
      • Environment - Change terrain type at (Position of (Constructed structure)) to Dalaran - White Marble using variation -1 in an area of size 1 and shape Square
      • Unit - Remove (Constructed structure) from the game
      • Unit - Create 1 Road Dummy for Neutral Passive at (Position of (Constructed structure)) facing (Position of (Triggering unit))
now the exemple of the building, it will locate near dummies to enable or not the building.
  • Barracks
    • Events
      • Unit - A unit owned by Player 1 (Red) Begins construction
    • Conditions
      • (Unit-type of (Constructing structure)) Equal to Barracks
    • Actions
      • Custom script: call DestroyGroup(udg_UGroads)
      • Set VariableSet PointBuilding = (Position of (Constructing structure))
      • Set VariableSet UGroads = (Units within 300.00 of (Position of (Constructing structure)) matching ((Unit-type of (Matching unit)) Equal to Road Dummy).)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between (Position of (Constructing structure)) and (Position of (Random unit from UGroads))) Less than or equal to 300.00
        • Then - Actions
          • Else - Actions
          • Game - Display to (All players) the text: Build near road sys...
          • Wait 0.50 seconds
          • Player - Add 160 to Player 1 (Red).Current gold
          • Player - Add 60 to Player 1 (Red).Current lumber
          • Unit - Kill (Constructing structure)

obs: the trigger is working, but building the road is taking so much time, I need other way to build more fast like WC1 style, and sometimes the place of the dummy varies, IDK why is not always in center of the road.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,640
There's no need for a Dummy unit, you can simply track the positions of the Roads using a Point array.

Also, you can't search for nearby units with the Locust ability (assuming your Dummy has this ability). Locust is designed to prevent the majority of things from affecting the unit since it would cause all sorts of issues otherwise.

Also, none of these triggers need to be restricted to Player 1, they're all easily made Generic to work for everyone.

Here's what I came up with:
  • Build Road
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Road
    • Actions
      • Set VariableSet Road_Index = (Road_Index + 1)
      • Set VariableSet Road_Point[Road_Index] = (Position of (Triggering unit))
      • Environment - Change terrain type at Road_Point[Road_Index] to Dalaran - White Marble using variation -1 in an area of size 1 and shape Circle
      • Unit - Remove (Triggering unit) from the game
  • Build Barracks
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • Set VariableSet Road_Point[0] = (Position of (Triggering unit))
      • -------- --------
      • -------- Check to see if there are any roads nearby: --------
      • Set VariableSet Is_Too_Far_From_Road = True
      • For each (Integer Road_Loop) from 1 to Road_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Road_Point[0] and Road_Point[Road_Loop]) Less than or equal to 300.00
            • Then - Actions
              • Set VariableSet Is_Too_Far_From_Road = False
              • Custom script: exitwhen true
            • Else - Actions
      • Custom script: call RemoveLocation( udg_Road_Point[0] )
      • -------- --------
      • -------- Destroy and refund the building if it wasn't near any roads: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Is_Too_Far_From_Road Equal to True
        • Then - Actions
          • Game - Display to (All players) for 3.00 seconds the text: |cffff0000You must ...
          • Player - Add 160 to (Owner of (Triggering unit)).Current gold
          • Player - Add 60 to (Owner of (Triggering unit)).Current lumber
          • Unit - Remove (Triggering unit) from the game
        • Else - Actions
You could take it one step further and detect when a "build order" is issued and interrupt the order if (Target point of issued order) isn't near any Road_Point. This would prevent your worker from even attempting to build in the first place if it was a bad location.
 

Attachments

  • Road Example 1.w3m
    19 KB · Views: 2
Last edited:
Level 12
Joined
Oct 28, 2019
Messages
481
OK aproved! But have one issue. The road must be constructed only connected by other road. For this a "initial" road triggered need be placed in the map....
in my mode only changing the environment and place some dummies and was ok. Any idea to do with your system
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,640
OK aproved! But have one issue. The road must be constructed only connected by other road. For this a "initial" road triggered need be placed in the map....
in my mode only changing the environment and place some dummies and was ok. Any idea to do with your system
You could do the same Distance check that the Barracks trigger uses, but reduce it to a 128 range.

Of course you need to register your pre-placed roads:
  • Starting Roads
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set VariableSet Road_Index = (Road_Index + 1)
      • Set VariableSet Road_Point[Road_Index] = (Center of RoadRegion1)
      • Environment - Change terrain type at Road_Point[Road_Index] to Dalaran - White Marble using variation -1 in an area of size 1 and shape Circle
      • Set VariableSet Road_Index = (Road_Index + 1)
      • Set VariableSet Road_Point[Road_Index] = (Center of RoadRegion2)
      • Environment - Change terrain type at Road_Point[Road_Index] to Dalaran - White Marble using variation -1 in an area of size 1 and shape Circle
      • Set VariableSet Road_Index = (Road_Index + 1)
      • Set VariableSet Road_Point[Road_Index] = (Center of RoadRegion3)
      • Environment - Change terrain type at Road_Point[Road_Index] to Dalaran - White Marble using variation -1 in an area of size 1 and shape Circle
^ You could use Regions to get your Points.
 
Top