• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Unit Enters - "variable - point" or set right clicked point as "variable - region" ?

Level 18
Joined
Jun 2, 2009
Messages
1,233
As the title says. I was checking old topics and i am totally confused.
Let me show you what exactly i need.

You are casting spell OR summoning unit at OR right clicking on "any of registered regions"
It does not matter which method should i use for that.
Set TempPoint = target point of issued order OR right clicked point OR position of created unit

Unit Enters - TempPoint
>> Actions
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
I'm not too sure I understand. I'll try to answer what I THINK you're asking.

There are Event Responses for just about every Event.

In a lot of cases we can get a Point related to our Event:
  • Events
    • Unit - A unit Begins casting an ability
    • Unit - A unit Begins channeling an ability
    • Unit - A unit Starts the effect of an ability
  • Conditions
  • Actions
    • Set TempPoint = (Target point of ability being cast)
    • Set TempPoint = (Position of (Target unit of ability being cast))
    • Set TempPoint = (Position of (Casting unit))
  • Events
    • Unit - A unit Spawns a summoned unit
  • Conditions
  • Actions
    • Set TempPoint = (Position of (Summoning unit))
    • Set TempPoint = (Position of (Summoned unit))
  • Events
    • Unit - A unit Is issued an order targeting a point
  • Conditions
  • Actions
    • Set TempPoint = (Target point of issued order)
    • Set TempPoint = (Position of (Ordered unit))
  • Events
    • Unit - A unit Is issued an order targeting an object
  • Conditions
  • Actions
    • Set TempPoint = (Position of (Target unit of issued order))
    • Set TempPoint = (Position of (Ordered unit))
Unit Enters - TempPoint
But there is no such thing as "entering" a Point.

Warcraft 3 uses a grid of X, Y, Z coordinates to determine where everything is positioned:
grid xyz.png

A Point is an object that stores X, Y, and Z coordinates.

It would be near impossible for you to detect when a unit "enters" those exact coordinates since they're so small and precise. That's why you use Regions which are rectangles centered at a Point. Regions have a minimum X, maximum X, minimum Y, maximum Y coordinate which can be compared with the X and Y coordinates of a Unit, Item, or Destructible to determine if they're inside of the Region.

With that information you should be able to figure out how to create your own Regions and check if Units are within them. I believe it's easier to do in Jass/Lua (code) since GUI doesn't have all of the tools needed.

But you don't necessarily need to use Warcraft 3's Regions, the concept is easy to recreate.
 
Last edited:
Level 18
Joined
Jun 2, 2009
Messages
1,233
Ok let me give you the example first @Uncle

1736092896244.png


But we can ignore this because i found alternative. I am checking travelled location with their mana amounts. Here what i done.

This one simply decreases mana of the unit.

  • SetMana
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Unit - Set mana of Paladin 0001 <gen> to ((Mana of Paladin 0001 <gen>) - 1.00)
This one detects if it hits zero

  • DetectMana
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
      • (Mana of Paladin 0001 <gen>) Less than or equal to (<=) 1.00
    • Actions
      • Game - Display to (All players) for 0.10 seconds the text: MANA BITTI
      • Unit - Order Paladin 0001 <gen> to Stop
      • Unit - Set mana of Paladin 0001 <gen> to 4.00
      • Trigger - Turn off SetMana <gen>
      • Trigger - Turn off (This trigger)
      • Game - Display to (All players) the text: (Name of the current trigger)
And this one turns on the triggers.

  • StopCheck2
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Name of the current trigger)
      • Trigger - Turn on SetMana <gen>
      • Trigger - Turn on DetectMana <gen>
This is the method i have found.
But you can suggest any method for that
If i will decide specific unit have 5 MOVEMENT that means unit can travels 5 tiles.
Detecting with mana bit of weird and difficult but i do not know any system "EXACT" the moved location.

1736092826226.png
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
Detecting with mana bit of weird and difficult but i do not know any system "EXACT" the moved location.
Okay, I think I understand.

This can be a little difficult to do but here's one way to store how much distance a unit has travelled or moved:
  • Detect Movement Start
    • Events
    • Conditions
    • Actions
      • Set Moving_Unit = (Paladin 0001 <gen>)
      • Set Moving_Id = (Custom value of Moving_Unit)
      • Set Moving_Point[Moving_Id] = (Position of Moving_Unit)
      • Set Moving_Distance[Moving_Id] = 0.00
      • Unit - Unpause Moving_Unit // OPTIONAL
      • Unit Group - Add Moving_Unit to Moving_Unit_Group
      • Trigger - Turn on Detect Movement Interval <gen>
  • Detect Movement Loop
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Moving_Unit_Group and do (Actions)
        • Loop - Actions
          • Set Moving_Unit = (Picked unit)
          • Set Moving_Id = (Custom value of Moving_Unit)
          • -------- --------
          • Set Moving_Point[0] = (Position of Moving_Unit)
          • Set Moving_Distance[0] = (Distance between Moving_Point[0] and Moving_Point[Moving_Id])
          • Set Moving_Distance[Moving_Id] = (Moving_Distance[Moving_Id] + Moving_Distance[0])
          • Custom script: call RemoveLocation( udg_Moving_Point[0] )
          • Custom script: call RemoveLocation( udg_Moving_Point[udg_Moving_Id] )
          • Set Moving_Point[Moving_Id] = (Position of Moving_Unit)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Moving_Distance[Moving_Id] Greater than or equal to 128.00
            • Then - Actions
              • Unit Group - Remove Moving_Unit from Moving_Unit_Group
              • Unit - Pause Moving_Unit // OPTIONAL
              • -------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Moving_Unit_Group is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off Detect Movement Loop <gen>
                • Else - Actions
            • Else - Actions
This uses Unit Indexing to store how much distance any unit has travelled or moved. When they travel >= 128.00 distance they will be removed from the Unit Group and Paused so that they stop moving. I Pause and Unpause units as an example, you don't need to do that.

You can turn this into a simple system by changing the Movement Start trigger to this:
  • Detect Movement Start
    • Events
    • Conditions
    • Actions
      • -------- Set Moving_Unit to your desired unit before running this trigger! --------
      • Set Moving_Id = (Custom value of Moving_Unit)
      • Set Moving_Point[Moving_Id] = (Position of Moving_Unit)
      • Set Moving_Distance[Moving_Id] = 0.00
      • Unit - Unpause Moving_Unit // OPTIONAL
      • Unit Group - Add Moving_Unit to Moving_Unit_Group
      • Trigger - Turn on Detect Movement Interval <gen>
Now you do this on ANY unit to begin detecting it's movement:
  • Some Other Trigger
    • Events
    • Conditions
    • Actions
      • Set Moving_Unit = (Paladin 0001 <gen>)
      • Trigger - Run Detect Movement Start (ignoring conditions)
      • -------- --------
      • -------- You can detect multiple units at the same time: --------
      • Set Moving_Unit = (Demon Hunter 0006 <gen>)
      • Trigger - Run Detect Movement Start (ignoring conditions)
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
Yes, it is bit of advanced. Tomorrow i will check and try to understand before the implementation. I just want to calculate EXACT distances for every tile.
Is 128 default size for 4 times 1x1 tiles or is it just an example?
Go into the World Editor and move your mouse around the grid. Press G to turn it on. You can press G again to show or hide the different sizes of tiles. Then look at the Point: (X, Y, Z) values in the bottom left corner of the screen, that should help visualize the distances between tiles.

Regions are another easy way to understand how the grid works:
1736177592101.png

Left = X coordinate on the left side.
Right = X coordinate on the right side.
Bottom = Y coordinate on the bottom side.
Top = Y coordinate on the top side.

So these are your Min X, Max X, Min Y, Max Y coordinates.

To check if something like a Unit is inside of a Region you would compare it's X/Y values to these Min/Max values:
  • Set Unit_X = (Get unit's X coordinate)
  • Set Unit_Y = (Get unit's Y coordinate)
  • -------- --------
  • Set Min_X = (Get region's Left -> Min X)
  • Set Max_X = (Get region's Right -> Max X)
  • Set Min_Y = (Get region's Bottom -> Min Y)
  • Set Max_Y = (Get region's Top -> Max Y)
  • -------- --------
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Unit_X Greater than or equal to Min_X
      • Unit_X Less than or equal to Max_X
      • Unit_X Greater than or equal to Min_Y
      • Unit_X Less than or equal to Max_Y
    • Then - Actions
      • -------- The Unit is in the Region! --------
    • Else - Actions
Of course a Region isn't necessary, you're simply comparing coordinates on a grid.
 
Last edited:
Top