[General] Explanation of movement variables?

Level 3
Joined
Nov 17, 2024
Messages
32
I am making an RPG type map and wish to have a character that I will describe as 'dexterous'. I want his shtick to be kiting and attack moving. I'm having trouble getting this to work the way that I want.

The current issue that I'm having is there is a long delay between a movement command ending and an attack command beginning. What value controls this? How can I reduce this 'cooldown' for this unit?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I am making an RPG type map and wish to have a character that I will describe as 'dexterous'. I want his shtick to be kiting and attack moving. I'm having trouble getting this to work the way that I want.

The current issue that I'm having is there is a long delay between a movement command ending and an attack command beginning. What value controls this? How can I reduce this 'cooldown' for this unit?
For Spells you would modify the unit's Cast Backswing + Cast Point and for Attacks you would modify it's Damage Backswing + Damage Point:
anim.png

These values represent how long the action takes to execute (Point) and how long the Unit continues to play their animation afterwards (Backswing). The Backswing can be interrupted, which is known as Animation Cancelling - something you likely do already without even thinking about it.

The two Combat values will scale based on your current Attack Cooldown. The faster you attack the lower they become to prevent these values from interfering with your next attack.

These fields are found in the Object Editor under the Units category.
 
Last edited:
Level 3
Joined
Nov 17, 2024
Messages
32
That did smooth it out a little bit. It's definitely still not where I would like it to be. Is there a way to override the original movement script?
I set the cast backswing and backswing animation both to 0 and turn radius to 3. It works alright for slow enough attack speeds, but for faster speeds it's still pretty delayed.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
That did smooth it out a little bit. It's definitely still not where I would like it to be. Is there a way to override the original movement script?
I set the cast backswing and backswing animation both to 0 and turn radius to 3. It works alright for slow enough attack speeds, but for faster speeds it's still pretty delayed.
Ehhh, not easily. You could trigger things from scratch, but that's quite the task, especially if you want to retain most of the standard game mechanics and have them play nice together.

An example of "just do it yourself":

But I could be wrong and there could be an easy solution. Warcraft 3 has a huge number of quirks that allow you to break through the seemingly impossible.
 
Last edited:
Level 30
Joined
Aug 29, 2012
Messages
1,382
I wonder if something like this could help

  • Face
    • Events
      • Unit - Paladin 0003 <gen> Acquires a target
    • Conditions
    • Actions
      • Unit - Make Paladin 0003 <gen> face (Targeted unit) over 0.00 seconds
The idea being to instantly make your hero face the target once acquired
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I wonder if something like this could help

  • Face
    • Events
      • Unit - Paladin 0003 <gen> Acquires a target
    • Conditions
    • Actions
      • Unit - Make Paladin 0003 <gen> face (Targeted unit) over 0.00 seconds
The idea being to instantly make your hero face the target once acquired
That could work but that Action isn't instant, I think you'd want to use the Set Facing Immediately action, which means you'll need to get the angle between the two units.
 
Level 3
Joined
Nov 17, 2024
Messages
32
Hmm maybe. I am going to try that and see. I'm getting stuck here. I have a global unit array HeroArr. I need to use specific unit event for the acquired target, and wish to grab the unit HeroArr[0]. It doesn't show up in the variables. I use a picker/circle of power thing to pick, create and add the unit to the array.

Edit:
I just used HeroArr[0] for distance between two points, position of HeroArr[0]. It isn't registering for the condition on specific unit event, which is the only place I see to get the acquires target function.
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Hmm maybe. I am going to try that and see. I'm getting stuck here. I have a global unit array HeroArr. I need to use specific unit event for the acquired target, and wish to grab the unit HeroArr[0]. It doesn't show up in the variables. I use a picker/circle of power thing to pick, create and add the unit to the array.
You should be able to use "A unit is Attacked" since that runs the moment an attack starts. "Acquired target" is a little different and likely not what you want.

Edit: Actually, on second thought, you'll want to rely on Orders. Neither of those Events will work.
  • Events
    • Unit - A unit Is issued an order targeting an object
  • Conditions
    • Or - Multiple conditions
      • (Issued order) Equal to (Order(smart))
      • (Issued order) Equal to (Order(attack))
  • Actions
    • Set Variable Point[0] = (Position of (Triggering unit))
    • Set Variable Point[1] = (Position of (Target unit of issued order))
    • Unit - Make (Triggering unit) face (Angle from Point[0] to Point[1])
    • Custom script: call RemoveLocation( udg_Point[0] )
    • Custom script: call RemoveLocation( udg_Point[1] )
Add more conditions as needed.
 
Level 3
Joined
Nov 17, 2024
Messages
32
A unit is issued an order targeting a unit? Hmm... Ok what is a good way to check if the unit needs to path around terrain?

Edit: I missed the trigger in your post.
 
Last edited:
Level 3
Joined
Nov 17, 2024
Messages
32
2 questions about your trigger.
1) what is order(smart)?
2) if I'm doing this for every attack move, I will just be overwriting the previous points in the array with new points, correct? So do I really need to deal with that leak?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
2) if I'm doing this for every attack move, I will just be overwriting the previous points in the array with new points, correct? So do I really need to deal with that leak?
Replacing the variable's current 'value' with a new object to point to doesn't delete/remove the original object. In fact they become permanent memory allocations since there is no way to refer to the object any more to fully remove it. Remove object -> Overwrite variable.
 
Level 3
Joined
Nov 17, 2024
Messages
32
What? That seems like a terrible way to have a language work.
So if I have point[0], that has a specific memory address, and presumably some value stored at that address. If I now set point[0] equal to something else, it reallocates memory for point[0] in order to give it a new value?
 
Level 3
Joined
Nov 17, 2024
Messages
32
  • Marine Atk Move
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Issued order) Equal to (Order(attack))) or ((Issued order) Equal to (Order(smart)))
      • (Triggering unit) Equal to HerosArr[0]
    • Actions
      • Unit - Make HerosArr[0] face (Angle from (Position of (Triggering unit)) to (Position of (Target unit of issued order)))
So is this going to leak? And is attack-move an order targeting a point? or how does that get referenced?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
  • Marine Atk Move
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Issued order) Equal to (Order(attack))) or ((Issued order) Equal to (Order(smart)))
      • (Triggering unit) Equal to HerosArr[0]
    • Actions
      • Unit - Make HerosArr[0] face (Angle from (Position of (Triggering unit)) to (Position of (Target unit of issued order)))
So is this going to leak? And is attack-move an order targeting a point? or how does that get referenced?
Yes, I wouldn't have bothered with using the variables/custom script otherwise :p

It's a pain but that's GUI.

When targeting, if you click on a Unit, Destructible, or Item you're targeting an "Object". If you click on nothing then you're targeting No object. If you click on the ground then you're targeting a Point in the game world (coordinates on a grid).
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
OK, what is this custom script? Do I need to make that? Does memory work like C or...?
That's how you clean up the memory leak and it varies for each object type. "Get rid of the object that this variable is pointing to".
  • Custom script: call RemoveLocation( udg_PointVariable )
  • Custom script: call DestroyGroup( udg_UnitGroupVariable )
  • Custom script: call DestroyForce( udg_PlayerGroupVariable )
  • Special Effect - Destroy (Last created special effect)
^ That's what you'll be using in GUI most of the time to avoid common memory leaks.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
What? That seems like a terrible way to have a language work.
So if I have point[0], that has a specific memory address, and presumably some value stored at that address. If I now set point[0] equal to something else, it reallocates memory for point[0] in order to give it a new value?
Effectively the variable itself is just a pointer to the actual object in memory, not the object itself. So yes by assigning a new value to point[0] you leave the original memory allocated wherever it was with whatever address it had, but now the point[0] pointer points to a different address.

This sort of setup makes sense for the wc3 object types that can be 'found' or 'interacted with' in some way in-game. If I overwrite a unit variable that's not inherently a memory leak because that unit can die and go through garbage collection automatically without a trigger removing it, or I could find that specific unit again by doing a search, it being an event response like Triggering Unit for some action, etc. The same thing applies to destructables, items, players, and a few more... but there are a whole host of data types you can't interact with in the same way that can never be 'found' again if their last reference is dropped. I think the original WE developers believed mapmakers wouldn't have much use for the non-interactable types so just didn't think to support them well.
 
Level 3
Joined
Nov 17, 2024
Messages
32
Hmm ok.
So this is what I'm trying to make but am having trouble:
Event: issue targeting a point or issue targeting a unit
conditions
actions:
if
target of action is point
then face point, clear memory, etc.
else face unit, clear memory, etc.
 
Level 3
Joined
Nov 17, 2024
Messages
32
Actually that's not what I want exactly. I still want to be able to check if the target of the order is a point or an object.
 
Level 3
Joined
Nov 17, 2024
Messages
32
And just to clarify, are these custom scripts built in? Or do I need to make a custom script for each one object type?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Actually that's not what I want exactly. I still want to be able to check if the target of the order is a point or an object.
Confirm that there is a (Target unit of issued order). It will be equal to "No unit" if you issued a Point order.
  • If all conditions are true then do (Actions)
    • If - Conditions
      • (Target unit of issued order) Equal to No unit
    • Then - Actions
      • // It's a Point order
    • Else - Actions
      • // It's an Object order targeting a unit
And just to clarify, are these custom scripts built in? Or do I need to make a custom script for each one object type?
Custom Script allows you to call a function that exists within the game's API. That example I posted earlier shows you how to call the functions for cleaning up a Point leak, a Unit Group leak, and a Player Group leak. That's all you'll really need to deal with most of the time.

The GUI portion of the Trigger Editor is missing a lot of functions/tools which are only accessible if you write your own Jass/Lua code (OR) if you use Custom Script which is effectively the same thing. That means you could use Custom Script to declare local variables in your GUI triggers, something that is unfortunately not accessible otherwise.
 
Last edited:
Level 3
Joined
Nov 17, 2024
Messages
32
I'm still not sure I 100% follow. Is the function RemoveLocation built in or do I need to write a custom script with that function?
How do we feel about this?
  • Marine Atk Move
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Issued order) Equal to (Order(attack))) or ((Issued order) Equal to (Order(smart)))
      • (Triggering unit) Equal to HerosArr[0]
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Targeted unit) Equal to No unit
        • Then - Actions
          • Set VariableSet Point[0] = (Position of (Triggering unit))
          • Set VariableSet Point[1] = (Target point of issued order)
          • Unit - Order (Triggering unit) to Attack-Move To (Point[1] offset by (((Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0) x (Cos((Angle from Point[0] to Point[1])))), ((Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0) x (Sin((Angle from Point[0] to
        • Else - Actions
          • Unit - Make HerosArr[0] face (Angle from Point[0] to Point[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Point[0] and Point[1]) Greater than or equal to (Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0)
            • Then - Actions
              • Unit - Order (Triggering unit) to Attack-Move To (Point[1] offset by (((Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0) x (Cos((Angle from Point[0] to Point[1])))), ((Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0) x (Sin((Angle from Point[0] to
            • Else - Actions
      • Custom script: call RemoveLocation( udg_Point[0])
      • Custom script: call RemoveLocation( udg_Point[1])
 
Level 3
Joined
Nov 17, 2024
Messages
32
I'm particularly unsure of a few spots. 1) this attack range ('ua1m) at index 0. Does this get the range of attack 1?

How leaky is this? Does me getting things like the attack range cause a leak?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I'm still not sure I 100% follow. Is the function RemoveLocation built in or do I need to write a custom script with that function?
Yes, it's built-in. You aren't writing your own version of the function, you're simply calling one that already exists in the API. I showed you three examples of these which exist to deal with those types of variables.

How do we feel about this?
I'm not too sure what you're trying to accomplish in your trigger.

As far as I know you simply want to do this:
  • Marine Atk Move
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Triggering unit) Equal to HerosArr[0]
      • ((Issued order) Equal to (Order(attack))) or ((Issued order) Equal to (Order(smart)))
      • (Target unit of issued order) Not equal to No unit
    • Actions
      • Set VariableSet Point[0] = (Position of HerosArr[0])
      • Set VariableSet Point[1] = (Position of (Target unit of issued order))
      • Set Variable Distance = (Distance from Point[0] to Point[1])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Distance Less than or equal to (Unit: HerosArr[0]'s Weapon Real Field: Attack Range ('ua1m') at Index:0)
        • Then - Actions
          • Unit - Make HerosArr[0] face (Angle from Point[0] to Point[1])
        • Else - Actions
      • Custom script: call RemoveLocation( udg_Point[0])
      • Custom script: call RemoveLocation( udg_Point[1])
Now your unit will immediately turn to face it's target if it's within attack range of it. Yes, weapon indexes start at 0 in this function.

If you want to automatically face a Point then remove the Distance check and adjust the Events/Actions as necessary.

Here's a trigger that does everything that I THINK you want:
  • Marine Atk Move
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Triggering unit) Equal to HerosArr[0]
      • ((Issued order) Equal to (Order(attack))) or ((Issued order) Equal to (Order(smart)))
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target unit of issued order) Equal to No unit
        • Then - Actions
          • Set VariableSet Point[0] = (Position of HerosArr[0])
          • Set VariableSet Point[1] = (Target point of issued order)
          • Unit - Make HerosArr[0] face (Angle from Point[0] to Point[1])
          • Custom script: call RemoveLocation( udg_Point[0])
          • Custom script: call RemoveLocation( udg_Point[1])
        • Else - Actions
          • // Same actions from previous trigger that use the Distance check
 
Last edited:
Level 3
Joined
Nov 17, 2024
Messages
32
OK, so the game kept crashing until I turned off the bits with the ua1m. Hitting ctrl d shows me that ua1m is missile art... it should be ua1r

...
I can't seem to find this as an option. But the crash makes sense since I'm trying to multiply a directory by cos(x).
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I'm trying to have the unit move in a straight line to the edge of his attack range.
Why exactly? If he's ordered to Attack-Move he will simply engage any unit within his acquisition range. If you order a Smart/Attack order at a Point, the unit will literally Attack-Move to that point.

Remember that an Action can cause an Event to run, you're crashing because you're creating an infinite loop -> On issued order -> Issue that same order.

If you want to interrupt an issued order and replace it with a new one, without issues, you could try this:
  • Actions
    • Trigger - Turn off (this trigger)
    • Custom script: call BlzPauseUnitEx( udg_YourUnit, true )
    • Unit - Order YourUnit to Stop
    • Custom script: call BlzPauseUnitEx( udg_YourUnit, false )
    • Unit - Order YourUnit to Attack-Move To YourDestinationPoint
    • Trigger - Turn on (this trigger)
This will Turn off the trigger causing it to ignore future orders, Stun the unit, Order it to Stop, Unstun it, Issue the new Attack-Move order, and finally turn the trigger back on. The Off/On will avoid the crash, the weird Custom script + Stop stuff will interrupt the unit, and the Attack-Move order is your new "replacement" order. I used some random unset variables in this example but you would want to use your own variables + the same logic from the previous triggers.

Also, just rely on the already provided math functions for getting Angle/Distance -> Angle between units, Distance between units. Cos/Sin would only be necessary here if you were working with coordinates. You're relying on Point variables which containers of x/y/z coordinates with helper functions to make things easy for you.
 
Last edited:
Level 3
Joined
Nov 17, 2024
Messages
32
Ahh, that makes sense. The why is because there are still a couple of cases where there are delays in the commands being executed.

However, I have an issue with my conditions.

I have if then else
if targeted unit = no unit
then create floating text "point"
else create floating text "unit"

No matter what, I'm getting point, even when I right click on a unit.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Ahh, that makes sense. The why is because there are still a couple of cases where there are delays in the commands being executed.

However, I have an issue with my conditions.

I have if then else
if targeted unit = no unit
then create floating text "point"
else create floating text "unit"

No matter what, I'm getting point, even when I right click on a unit.
(Targeted unit) is NOT the (Target unit of issued order). That Event Response is for an unrelated Event. You should post your trigger though.
 
Last edited:
Level 3
Joined
Nov 17, 2024
Messages
32
Changing that fixed it.
Here is the current trigger. Still not complete. The angle change works when I right click on the unit. I need to get it so that it works when I a-click.
  • Marine Atk Move
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Issued order) Equal to (Order(attack))) or ((Issued order) Equal to (Order(smart)))
      • (Triggering unit) Equal to HerosArr[0]
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target unit of issued order) Equal to No unit
        • Then - Actions
          • Set VariableSet Point[0] = (Position of (Triggering unit))
          • Set VariableSet Point[1] = (Target point of issued order)
          • Floating Text - Create floating text that reads Point above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
          • Unit - Order (Triggering unit) to Attack-Move To (Point[1] offset by (((Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0) x (Cos((Angle from Point[0] to Point[1])))), ((Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0) x (Sin((Angle from Point[0] to
        • Else - Actions
          • Floating Text - Create floating text that reads Unit above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
          • Set VariableSet Point[0] = (Position of (Triggering unit))
          • Set VariableSet Point[1] = (Position of (Targeted unit))
          • Unit - Make HerosArr[0] face (Angle from Point[0] to Point[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Point[0] and Point[1]) Greater than or equal to (Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0)
            • Then - Actions
              • Unit - Order (Triggering unit) to Attack-Move To (Point[1] offset by (((Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0) x (Cos((Angle from Point[0] to Point[1])))), ((Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0) x (Sin((Angle from Point[0] to
            • Else - Actions
      • Custom script: call RemoveLocation( udg_Point[0])
      • Custom script: call RemoveLocation( udg_Point[1])
Is there any way to make floating text follow a character?

Edit: the issue order bits are disabled
I also confirmed that the ua1m does in fact give the range, I had it print as floating text. It's confusing that the field ua1m is displayed as the missile art file path.
1732751906245.png

Do I need to destroy floating text then as well? Or is that done in the lifespan?
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
Uncle should have linked this easy reference, but somehow didn't (shame!): Things That Leak
Do I need to destroy floating text then as well? Or is that done in the lifespan?
Lifespan and the Disable Permanence line above allow it to be garbage collected automatically. There is a special limitation with that type: each player can only have 99 floating text at a time, and any 100th concurrent text will overwrite the 1st one.
 
Level 3
Joined
Nov 17, 2024
Messages
32
There is still a delay between the end of a movement and the beginning of an attack, and it's fairly significant. The movement is fairly smooth, but there is maybe a .2-.3s delay between cancelling the movement and begging the attack. I'm right click moving and then a-left clicking, like you would in a MOBA.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
There is still a delay between the end of a movement and the beginning of an attack, and it's fairly significant. The movement is fairly smooth, but there is maybe a .2-.3s delay between cancelling the movement and begging the attack. I'm right click moving and then a-left clicking, like you would in a MOBA.
You're still doing some weird stuff, drop the Sin and Cos and look at the triggers I posted.
 
Level 3
Joined
Nov 17, 2024
Messages
32
I also think I'm still leaking these points, or something. My memory usage is going up by ~100MB everytime I test.
 
Level 3
Joined
Nov 17, 2024
Messages
32
Here is the trigger in it's current state:
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Target unit of issued order) Equal to No unit
      • Then - Actions
        • Set VariableSet Point[0] = (Position of (Triggering unit))
        • Set VariableSet Point[1] = (Target point of issued order)
        • Unit - Make HerosArr[0] face (Angle from Point[0] to Point[1])
      • Else - Actions
        • Set VariableSet Point[0] = (Position of (Triggering unit))
        • Set VariableSet Point[1] = (Position of (Targeted unit))
        • Unit - Make HerosArr[0] face (Angle from Point[0] to Point[1])
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Distance between Point[0] and Point[1]) Greater than or equal to (Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m') at Index:0)
          • Then - Actions
          • Else - Actions
    • Custom script: call RemoveLocation( udg_Point[0])
    • Custom script: call RemoveLocation( udg_Point[1])
 
Level 3
Joined
Nov 17, 2024
Messages
32
The only thing I'm controlling right now is the point direction.
Here are the values of the character that I think are important. Let me know if I'm missing something:
1732755699217.png

1732755732562.png

I'm intentionally testing it with a really high attack speed. When I use .7 or .8, the whole motion feels relatively smooth, but less than .5s or so for the ATK cooldown and it starts to feel clunky.
 
Level 3
Joined
Nov 17, 2024
Messages
32
The cosine sine bit was calculating 300 units from the intended target along the line of the direction between them. Well, "attack range" units, which happens to be 300 here.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
The cosine sine bit was calculating 300 units from the intended target along the line of the direction between them. Well, "attack range" units, which happens to be 300 here.
Attack Range "units" should be the same as Cast Range or anything like that - without considering collision size of the unit which would be added into the calculation for actual combat.

If you want to get 300 units in front of the unit you can use Point with polar offset:
  • Set Variable Point[0] = (Position of YourUnit)
  • Set Variable Point[1] = (Point[0] offset by 300.00 towards (Facing of YourUnit) degrees)
^ Facing angle can be unreliable though, since your Order event will fire before the unit has even started turning to face it's target.

So something like this would work:
  • Set Variable Point[0] = (Position of YourUnit)
  • Set Variable Point[1] = (Position of YourTarget)
  • Set Variable Point[2] = (Point[0] offset by 300.00 towards (Angle between Point[0] and Point[1]) degrees)
Seems like a cleaner solution.

  • (Position of (Targeted unit))
^ Still using the wrong Event Response.
 
Last edited:
Level 3
Joined
Nov 17, 2024
Messages
32
I think I'm just not aware of a lot of the built in functions. Any idea about the cooldown between switching from a move command to an attack command?
 
Level 3
Joined
Nov 17, 2024
Messages
32
Here is a video so you can hopefully see what I'm talking about. This is with attack cooldown set to 0.1. Sometimes I'm even cancelling the attack command, which shouldn't be happening if it goes right away (which it's not), at least not at .1 seconds.
 

Attachments

  • Warcraft III 2024-11-27 21-12-12.mp4
    36.5 MB

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Here is a video so you can hopefully see what I'm talking about. This is with attack cooldown set to 0.1. Sometimes I'm even cancelling the attack command, which shouldn't be happening if it goes right away (which it's not), at least not at .1 seconds.
Oh, you're talking about base attack cooldown. That doesn't have to do with Orders - which is what I assumed you meant when you said Commands. I believe Warcraft 3 allows up to 5 attacks per second. Something like that, although I think you can bypass it with the "Set Attack Interval" function, should be easy enough to test yourself.

Edit: Nevermind, I see what you mean. You can definitely issue at least 100 orders per second but those were triggered orders.

We're messing around with mechanics that were not designed to be so snappy. The game may limit user input, plus other funky stuff going on under the hood.
 
Last edited:
Level 3
Joined
Nov 17, 2024
Messages
32
Yea when I sit and attack he attacks really fast. When I give a move command and then an attack command, there is a delay before he starts attacking. I feel like there is "dead time" at the end of the movement animation that I would like to cut off.

I really like the snappiness of the face angle that we have. The only thing I want to change is deciding if there is pathing involved (like around a corner) and then not face the angle.
 
Top