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

[General] How to teleport a unit if it enters to a different terrain.

Level 11
Joined
Sep 11, 2013
Messages
327
Hi there!
Is there an easy/smart way to make a trigger that teleport instantly a specific unit type back to center of the map(X) if that unit try to enter to a different terrain?
Capture1.JPG

The unit type must be free to walk only inside that red border. If that unit type try to escape outside the red border, that trigger must instantly teleport the unit back to (X) every single time.

Well I can make 12 regions, but I try to find a better way..

The help will be appreciated!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,598
You basically have a circle there, so you could also do a Distance check if you don't mind some minor inaccuracy:
  • Events
    • Time - Every 0.10 seconds of game time
  • Conditions
  • Actions
    • Set Variable Point = (Position of YourUnit)
    • If all Conditions are true then do Actions
      • If - Conditions
        • (Distance between Point and CenterPoint) Greater than 1280.00
      • Then - Actions
        • Unit - Move YourUnit to CenterPoint
      • Else - Actions
    • Custom script: call RemoveLocation( udg_Point )
Adjust 1280.00 to be the max distance that you want to allow. I assumed each of those red blocks in your picture were 512.00 units in size.
  • Events
    • Time - Elapsed game time is 0.00 seconds
  • Conditions
  • Actions
    • Set Variable CenterPoint = (Center of YourRegion)
    • Set Variable YourUnit = The unit (set this whenever you can)
Don't forget to initialize the CenterPoint variable at the start of the game. Same goes for the YourUnit variable.

Rename these variables to something that makes sense for your map.
 
Last edited:
Top