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

Buildable Waygates

Status
Not open for further replies.
Level 7
Joined
Feb 13, 2022
Messages
86
Hello i am working on my custom warcraft map. I want the players to be able to build "tunnels" (waygates). There are two types of Tunnels, Tunnel A and Tunnel B. I want each player to be able to build only one of each. Each Tunnel is linked to the other, ie Tunnel A is linked to Tunnel B. These tunnels can be destroyed, but can't be used by enemies, only by other players. I want the tunnels to be linked for each players Tunnels, basically player ones two tunnels are linked with each other, but not with the other tunnels of the other players. If anyone knows how to make these buildable waygates work, the help would be super beneficial!
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
sure it's possible to trigger.

something like this:

for limiting to one per player, you make a trigger that detects when a player orders to build one of these buildings. if he already has one (or is currently building one), you order a stop command to the builder in the same trigger, and show an error message to the player that they can only build one.

for building the buildings -

trigger a:

whenever a tunnel building is completed:

add it to a unit group for all these tunnels.
if the peropdic tunnel trigger is off, turn it on.

periodic tunnel trigger:

for each unit in the unit group:

periodically checks what units are in range x of it (however close you want to actiavate it). (also make the buildings walkable in the unit editor). for units in that range - filter for allied units. after that, check if there is an allied unit of the other tunnel type in the map. if so, send the filtered units there.

if the tummel group is empty, turn off the periodic (this) trigger.
 
Level 7
Joined
Feb 13, 2022
Messages
86
sure it's possible to trigger.

something like this:

for limiting to one per player, you make a trigger that detects when a player orders to build one of these buildings. if he already has one (or is currently building one), you order a stop command to the builder in the same trigger, and show an error message to the player that they can only build one.

for building the buildings -

trigger a:

whenever a tunnel building is completed:

add it to a unit group for all these tunnels.
if the peropdic tunnel trigger is off, turn it on.

periodic tunnel trigger:

for each unit in the unit group:

periodically checks what units are in range x of it (however close you want to actiavate it). (also make the buildings walkable in the unit editor). for units in that range - filter for allied units. after that, check if there is an allied unit of the other tunnel type in the map. if so, send the filtered units there.

if the tummel group is empty, turn off the periodic (this) trigger.
Thank you for the response, I appreciate it alot! I was able to set up the system for allowing players to be able to only build one of each tunnel. Im not able to set up the periodic tunnel trigger, could you show me how to do that part? Could you send a screenshot of how that trigger would look? Thank in advance!
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
  • built tunnel
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Constructed structure)) Equal to tunnel A
          • (Unit-type of (Constructed structure)) Equal to tunnel B
    • Actions
      • Unit Group - Add (Constructed structure) to tunnelGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in tunnelGroup) Greater than 1
          • (tunnel loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on tunnel loop <gen>
        • Else - Actions
this one starts off inactive:
  • tunnel loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in tunnelGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet TempTunnel = (Picked unit)
          • -------- setting up a quick way to access opposite type of tunnel --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of TempTunnel) Equal to tunnel A
            • Then - Actions
              • Set VariableSet OppositeType = tunnel B
            • Else - Actions
              • Set VariableSet OppositeType = tunnel A
          • -------- checking if any "opposite type" of tunnels owned by ally exist --------
          • Set VariableSet matchingTunnelGroup = (Units of type OppositeType)
          • Unit Group - Pick every unit in matchingTunnelGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) belongs to an ally of (Owner of TempTunnel).) Equal to False
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from matchingTunnelGroup.
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (matchingTunnelGroup is empty) Equal to False
            • Then - Actions
              • Set VariableSet TargetTunnel = (Random unit from matchingTunnelGroup)
              • -------- the transportation distance needs to be smaller than the destination distance, or it will keep sending them back and forth --------
              • -------- the size of this should be changed according to the size of the building you are using --------
              • Set VariableSet TargetPoint = ((Position of TargetTunnel) offset by (200.00, 0.00))
              • Set VariableSet TempTunnelPoint = (Position of TempTunnel)
              • Set VariableSet NearTunnelGroup = (Units within 150.00 of TempTunnelPoint matching ((((Matching unit) belongs to an enemy of (Owner of TempTunnel).) Equal to False) and (((Matching unit) is A structure) Equal to False)).)
              • Unit Group - Pick every unit in NearTunnelGroup and do (Actions)
                • Loop - Actions
                  • -------- add SFX here --------
                  • Unit - Move (Picked unit) instantly to TargetPoint
              • Custom script: call DestroyGroup(udg_NearTunnelGroup)
              • Custom script: call RemoveLocation(udg_TargetPoint)
              • Custom script: call RemoveLocation(udg_TempTunnelPoint)
            • Else - Actions
          • Custom script: call DestroyGroup(udg_matchingTunnelGroup)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in tunnelGroup) Less than 2
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions

obviously as opposed to the native waygates - the game's pathing will not recognize these and they will need to be targeted directly, and units will not use them by default as the shortest path.

added the demo map (I didn't bother with tooltips, just order the peasant to build a farm).

good luck!
 

Attachments

  • buildable waygates.w3m
    20.4 KB · Views: 10
Level 15
Joined
Sep 29, 2008
Messages
362
Another way to make tunnels is moving predefined regions.

steps:
  • make your tunnel unit with walkable path
  • create two predefined regions into ur map: TunnelEntranceRegion and TunnelExitRegion
  • put these regions on inaccessible terrain to prevent units entering if no tunnel is available.
  • Make a Unit enters Rect trigger for TunnelEntranceRegion
  • Move entering unit to TunnelExitRegion on Trigger actions
  • Use event Unit finished building when your tunnel is completed, to move TunnelEntranceRegion to Finished building location.
  • When the tunnel is destroyed, return the region to its initial location.

Run test and make a Unit walk into ur tunnel.

To make unit come back, create another two regions in reverse order and repeat the steps. Dont use same regions cuz it'll make a infinite loop.
 
Status
Not open for further replies.
Top