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

Check the distance moved (blinked or moved instantly)

Status
Not open for further replies.
Level 4
Joined
Apr 15, 2016
Messages
61
How to do so ? In this case I want to make an unit increase its movement speed every 300 units (distance) moved, doesn't matter if it is by blinking, by simply walking, by teleporting, etc. So I would need to check the current position of the unit and the distance moved, right ? But how to do SO ? If you can trigger, do so :x
 
  • Detect walking
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • b Equal to True
        • Then - Actions
          • Set b = False
          • Custom script: call RemoveLocation(udg_point[1])
          • Set point[1] = (Position of unit)
        • Else - Actions
          • Set b = True
          • Custom script: call RemoveLocation(udg_point[2])
          • Set point[2] = (Position of unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between point[1] and point[2]) Greater than or equal to 1.00
          • (unit is alive) Equal to True
        • Then - Actions
          • Set IsMoving = True
        • Else - Actions
          • Set IsMoving = False
          • Set CurrentOrder = (Current order of unit)
          • Sound - Stop step <gen> Immediately
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of unit) Equal to (Order(<Empty String>))
              • Standing Equal to False
            • Then - Actions
              • Set Standing = True
              • Animation - Reset unit's animation
              • Animation - Change unit's animation speed to 777.00% of its original speed
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (EquipmenT 0036 <gen> has an item of type Enchanted Shield) Equal to False
                  • (EquipmenT 0036 <gen> has an item of type Wooden Shield) Equal to False
                  • (EquipmenT 0036 <gen> has an item of type Crude Buckler) Equal to False
                • Then - Actions
                  • Custom script: call SetUnitAnimationByIndex( udg_unit , 2 )
                • Else - Actions
                  • Custom script: call SetUnitAnimationByIndex( udg_unit , 0 )
              • Wait 0.02 seconds
              • Animation - Change unit's animation speed to 0.00% of its original speed
            • Else - Actions
This gets a Bool but you can get the real too if you want.
 
Level 19
Joined
Jul 2, 2011
Messages
2,162
I do not understand what you are asking
clarify!

but if I get the titles meaning correctly. you want to measure the distance traveled by a blink ability

create a 0.4 second delay in blink

event
castes ability

condition
ability cast blink

action
create invisible unit at point of casting unit.
now
use ranger of invisible unit as real value to position of ability target

there is your solution
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
I do not understand what you are asking
clarify!

but if I get the titles meaning correctly. you want to measure the distance traveled by a blink ability

Nope, it is more, what Legal Ease posted.

He simply wants to find out from a starting point in time, whether a unit has travelled 300 no matter how it did so.

The obvious way to do so, is something like Legal Ease posted. Allthough I do not really get, where this trigger exactly matches the problem specified ...

Try this instead: (this works only for one unit at a time without modification though)

  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • 'IF'-Conditions
        • Custom script: (udg_YourUnitLocation != null)
      • 'THEN'-Actions
  • Set TempLocation = (Position of YourUnit)
    • Set DistanceCount = (DistanceCount + (Distance between YourUnitLocation and TempLocation ))
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • DistanceCount greater or equal (>=) 300.00
        • 'THEN'-Actions
          • Set DistanceCount = (DistanceCount - 300.00)
          • -------- do your stuff here --------
        • 'ELSE'-Actions
    • Set YourUnitLocation = (Position of YourUnit)
  • Custom script: call RemoveLocation(udg_TempLocation)
    • 'ELSE'-Actions
      • Set YourUnitLocation = (Position of YourUnit)
 
Last edited:
Level 4
Joined
Apr 15, 2016
Messages
61
Should I create an unit group if I wanted to check if they have any buff or passive ? Like "Pick Every Unit matching that has a buff" and do these actions

Or maybe, I can create a Start Trigger that turns on this one (the periodic trigger).

One Question @Emm-A- the custom script should be really in Conditions tab ? I can't understand very well your triggers, but they look good enough to solve my problem. My problem is HOW to detect the 300 units moved. I just can't understand them. XD
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Should I create an unit group if I wanted to check if they have any buff or passive ? Like "Pick Every Unit matching that has a buff" and do these actions

Or maybe, I can create a Start Trigger that turns on this one (the periodic trigger).

One Question @Emm-A- the custom script should be really in Conditions tab ? I can't understand very well your triggers, but they look good enough to solve my problem. My problem is HOW to detect the 300 units moved. I just can't understand them. XD

-It is totally up to you, when to start this periodic trigger. It really depends on the "what do you need it for", as already TheLordOfChaos201 was asking you to specify your problem. Right now, it runs from the map initialization with any unit, you set to YourUnit at map init (this is an "event" in GUI).

-About that custom script: Sry I am not sure, if this can be found there, if you are not using the Jass New Gen Pack Editor or UMSWE. You can just delete this if-then-else and set YourUnitLocation to the location of your wanted unit at map initialization.

As already said, it is hard to help you because you did not specify anything.

Unfortunately, I dont have the time to explain my trigger in detail, but I wrote it as easy as possible. Maybe you try to rebuild it line by line for yourself, this is the best way to understand it. DistanceCount is a real variable, to which the distance, your unit travels each 0.3 seconds of game time is added.

Obviously this is not perfect, as your unit might travel around in between 0.3 seconds, but I wanted to give you an example, that you can understand.

Maybe check for a Jass library in the spells section as well, you might find an easier way there.
 
Level 4
Joined
Apr 15, 2016
Messages
61
I'm still having trouble to understand... I mean, I understand most of these, but I don't get HOW can I check the unit first position to then detect the distance it moved starting from this first position.

The whole thing is, the unit is not in the game (it has to be chosen first. It would be WAY easier if it was already in the game, so I just would have to use the Event Map Int and Actions Set = Position of 007 Tauren and then start a periodic trigger) and it has a passive. What I wanted was that whenever this unit (the unit with this passive) moves 300 units (it doesn't matter if it is by blinking, by teleport, whatever, if it travels 150 units and then turns around and travels more 150 units, DOESN'T MATTER) it would stomp the area.

as your unit might travel around in between 0.3 seconds.

It doesn't matter.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
As you already thought for yourself, you will have to disable this periodic loop then and make a new trigger, that fires, when your passive skill is learnt, or when the unit is created. Then you just set this variable YourUnit = TriggeringUnit(), and enable the periodic loop and you are fine.
The loop does exactly what you described with that little "0.3" flaw, that will be noticable, if the unit is ported over long distances in less than 0.3 sec.
If you add that stomp action, where I wrote that "do your stuff here", you got what you want.

This periodic loop will get the distance between your unit and its last position 0.3 seconds earlier everytime and add this value to this DistanceCount, that in turn is substracted by 300. once it reached this treshhold. Your action will be executed then, and no matter what, the unit's position is updated to the new one.
 
Level 4
Joined
Apr 15, 2016
Messages
61
fires when the unit is created.

YES, THIS IS WHAT I WAS NEEDING. The event, the skill can't be learned as it is already with the unit (unit ability), so the best event I can use (as I said the unit is not in the map) is when the unit is created. Thank you for the help.

NOTE: If anyone else knows any other way to do it feel free to tell. The problem is solved, but if you have another method, I'll check it here.
 
Status
Not open for further replies.
Top