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

Any way to ban specific units from using way gates?

Status
Not open for further replies.
Level 7
Joined
Mar 16, 2014
Messages
152
I know I could just trigger such a system, but then units will not acknowledge the paths made by way gates when searching for paths.

Changing the targets allowed in "waygate ability" does not seem to have any kind of effect.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,582
Edit:
This seems to work.

Use Unit-type of Triggering Unit to exclude specific types of units. An OR is necessary for multiple unit-types. In this example i'm preventing the Paladin from using a Way Gate.
  • Waygate Prevention
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(smart))
      • (Unit-type of (Triggering unit)) Equal to Paladin
      • (Unit-type of (Target unit of issued order)) Equal to Way Gate
    • Actions
      • Set VariableSet TempPoint = (Position of (Target unit of issued order))
      • Unit - Order (Triggering unit) to Move To TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
The trigger replaces the order when you right click a Way Gate with a Move order to the position of the Way Gate. This prevents the unit from teleporting.
 
Last edited:
Level 20
Joined
Feb 27, 2019
Messages
593
  • Environment - Set terrain pathing at (Destination of Way Gate) of type Amphibious Pathing to On
Can playing around a bit with pathing and movement type be of help?
 
Level 20
Joined
Apr 12, 2018
Messages
494
Edit:
This seems to work.

Use Unit-type of Triggering Unit to exclude specific types of units. An OR is necessary for multiple unit-types. In this example i'm preventing the Paladin from using a Way Gate.
  • Waygate Prevention
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(smart))
      • (Unit-type of (Triggering unit)) Equal to Paladin
      • (Unit-type of (Target unit of issued order)) Equal to Way Gate
    • Actions
      • Set VariableSet TempPoint = (Position of (Target unit of issued order))
      • Unit - Order (Triggering unit) to Move To TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
The trigger replaces the order when you right click a Way Gate with a Move order to the position of the Way Gate. This prevents the unit from teleporting.
Can't a unit just bypass it by clicking their destination on the other side of the gate? I don't think 'smart' Waygate is necessary for units to path through it.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,582
Edit: Hold on, I somehow managed to unset their Regions when I first tested it. Testing it now.

I managed to get it to work for targeting the Way Gates but I couldn't figure out a fix for when players teleport by right clicking the ground near a Way Gate. It probably needs to be triggered from scratch.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,582
Alright, I THINK I got it working. Hopefully you use the latest version and can open my map.

When a "banned" unit attempts to use a Way Gate I pick every single Way Gate in the map and disable them for 0.05 seconds. It seems to work from my testing but you can never be certain with these things.
  • WG Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet WayGate_Group = (Units of type Way Gate)
Remember to adjust the Unit-Types to fit your needs. The Paladin is the example unit that i'm "banning" from using Way Gates.
  • WG Target Object
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(smart))
      • (Unit-type of (Target unit of issued order)) Equal to Way Gate
      • (Unit-type of (Triggering unit)) Equal to Paladin
    • Actions
      • Unit Group - Pick every unit in WayGate_Group and do (Actions)
        • Loop - Actions
          • Neutral Building - Disable (Picked unit)
      • Custom script: call PreventWayGate()
I'm using Bribe's Unit Indexer as well. This is to make sure that a unit is actually on a Way Gate when you issue a Point order (that way the trigger isn't running all of the time). You might have to add additional Point orders as well for Point abilities since they will fire the trigger.
  • WG Target Point
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(move))
          • (Issued order) Equal to (Order(patrol))
          • (Issued order) Equal to (Order(attack))
      • IsOnWayGate[(Custom value of (Triggering unit))] Equal to True
      • (Unit-type of (Triggering unit)) Equal to Paladin
    • Actions
      • Unit Group - Pick every unit in WayGate_Group and do (Actions)
        • Loop - Actions
          • Neutral Building - Disable (Picked unit)
      • Custom script: call PreventWayGate()
These 2 Triggers need to use all of your Way Gate regions.
  • Enter WG
    • Events
      • Unit - A unit enters WayGate A <gen>
      • Unit - A unit enters WayGate B <gen>
    • Conditions
    • Actions
      • Set VariableSet IsOnWayGate[(Custom value of (Triggering unit))] = True
  • Leave WG
    • Events
      • Unit - A unit leaves WayGate A <gen>
      • Unit - A unit leaves WayGate B <gen>
    • Conditions
    • Actions
      • Set VariableSet IsOnWayGate[(Custom value of (Triggering unit))] = False
This trigger corrects an error that Regions have. Their rects are off causing certain Region-related things to not work properly. If you've ever had issues with Regions it's probably because of this issue.

Make sure to add all of your Way Gate regions in here:
  • Fix Regions
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: local rect r
      • -------- --------
      • -------- Set this to the number of Regions you want to fix --------
      • Set VariableSet FixRegionCount = 2
      • -------- --------
      • -------- Assign each Region you want to fix --------
      • Set VariableSet FixRegions[1] = WayGate A <gen>
      • Set VariableSet FixRegions[2] = WayGate B <gen>
      • -------- --------
      • -------- Once our variables are setup, loop through all of the FixRegions and adjust them so that they have the correct size --------
      • For each (Integer A) from 1 to FixRegionCount, do (Actions)
        • Loop - Actions
          • Custom script: set r = udg_FixRegions[bj_forLoopAIndex]
          • Custom script: call SetRect(r, GetRectMinX(r) - 32., GetRectMinY(r) - 32., GetRectMaxX(r) + 32., GetRectMaxY(r) + 32.)
      • Custom script: set r = null
Here's the code for the Jass functions:
vJASS:
function EnableWayGates takes nothing returns nothing
    call WaygateActivate(GetEnumUnit(), true)
endfunction

function PreventWayGateFunc takes nothing returns nothing
    local timer t = GetExpiredTimer()
    call ForGroup(udg_WayGate_Group, function EnableWayGates)
    call PauseTimer(t)
    call DestroyTimer(t)
    set t = null
endfunction

function PreventWayGate takes nothing returns nothing
    local timer t = CreateTimer()
    call TimerStart(t, 0.05, false, function PreventWayGateFunc)
    set t = null
endfunction
Requires Bribe's Unit Indexer, link in my signature. (Or any Unit Indexer really)

Edit #1: Added version 2. I forgot to destroy the Timers causing a leak. Also removed the BJ stuff from the code.

Edit #2: Added version 3. This one seems to fix everything but has some extra steps/variables required.

I wonder if there's some classification of unit or some type of targeting that prevents a unit from using a Way Gate. That would probably solve everything.
 

Attachments

  • Waygate Exclusion 2.w3m
    23.5 KB · Views: 11
  • Waygate Exclusion 3.w3m
    26.2 KB · Views: 15
Last edited:
Status
Not open for further replies.
Top