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

[Trigger] Simple math question

Status
Not open for further replies.
Level 19
Joined
Aug 16, 2007
Messages
881
Well, I'm not the skillest one at math so I need a probably very simple help.

I need to calculate how long time it will take for a missile-attack with 900speed to reach a target ability point. The dummy unit that will fire the missile will spawn at the spellcasters location and attack at target ability point. :)

Thx.
 
Level 11
Joined
Feb 14, 2009
Messages
884
u = dx/dt

u is velocity
dx is the distance you need to cover
dt is the time needed

To calculate the distance, do this: SquareRoot((x2 - x1)2 + (y2 - y1)2)

(x1,y1) are the coordinates of your missile's initial position
(x2,y2) are the coordinates of your missile's target location
 
Level 19
Joined
Aug 16, 2007
Messages
881
u = dx/dt

u is velocity
dx is the distance you need to cover
dt is the time needed

To calculate the distance, do this: SquareRoot((x2 - x1)2 + (y2 - y1)2)

(x1,y1) are the coordinates of your missile's initial position
(x2,y2) are the coordinates of your missile's target location

Thanks =) But... As I said, my math skills is far away from good. Could you show me a GUI example of this? Because I don't really get it x) I think I'll have to study more math in school...
 
Level 11
Joined
Feb 14, 2009
Messages
884
  • BANZAIII
    • Events
    • Conditions
    • Actions
      • Set Distance = (Square root(((Power(((X of (Position of (Attacked unit))) - (X of (Position of (Triggering unit)))), 2.00)) + (Power(((Y of (Position of (Attacked unit))) - (Y of (Position of (Triggering unit)))), 2.00)))))
      • Set Velocity = 900.00
      • Set Time = (Distance / Velocity)
Attacked unit is your target and Triggering unit is your caster. Not sure what you need exactly, but I assume you can change them. I just emphasized on the formula.

EDIT: Time assumes that the speed of your missile is 900m/s and the distance is in meters. I have no idea how you can convert meters to W3 units, maybe somebody else can help ^^
 
Level 19
Joined
Aug 16, 2007
Messages
881
  • BANZAIII
    • Events
    • Conditions
    • Actions
      • Set Distance = (Square root(((Power(((X of (Position of (Attacked unit))) - (X of (Position of (Triggering unit)))), 2.00)) + (Power(((Y of (Position of (Attacked unit))) - (Y of (Position of (Triggering unit)))), 2.00)))))
      • Set Velocity = 900.00
      • Set Time = (Distance / Velocity)
Attacked unit is your target and Triggering unit is your caster. Not sure what you need exactly, but I assume you can change them. I just emphasized on the formula.

EDIT: Time assumes that the speed of your missile is 900m/s and the distance is in meters. I have no idea how you can convert meters to W3 units, maybe somebody else can help ^^

Thanks for the help ;) Yeah, I can change this actions to what I need easily, I've been working with GUI over 3 years, so it's now a problem for me. Just the math ;p

I'll try this ASAP, thx again! +rep
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Wow, too bad we dont have a (Distance between (Point1) and (Point2)) function, eh?
oh wait, we do!
  • Set Distance = (Distance Between (Point1) and (Point2))
Oooooh, and look, it does exactly what that huge line of Kercyn does:
JASS:
function DistanceBetweenPoints takes location locA, location locB returns real
    local real dx = GetLocationX(locB) - GetLocationX(locA)
    local real dy = GetLocationY(locB) - GetLocationY(locA)
    return SquareRoot(dx * dx + dy * dy)
endfunction
Take the square root of the squared x-distance plus the squared y-distance!

Just use Distance between Points, will leak only twice if you do it wrong, instead of 4 times with the Kercyn-method, and will not leak if you do it right.
 
Level 11
Joined
Feb 14, 2009
Messages
884
Could you show me a GUI example of this?

Do you have to be ironic? I guess you can't help it. I forgot the Point to Point thing, plus I wanted to show him how to do it. I wasn't writing any "10 ways to avoid leaks" book.
 
Level 19
Joined
Aug 16, 2007
Messages
881
Do you have to be ironic? I guess you can't help it. I forgot the Point to Point thing, plus I wanted to show him how to do it. I wasn't writing any "10 ways to avoid leaks" book.

Ignore him, your example worked perfect and I know how to remove leaks and such, as I said, I've been working with GUI for 3 years. =)

@Yixx

Your example may work, but I can't JASS but I understand JASS, so that won't help me, thanks anyway. :)
 
Status
Not open for further replies.
Top