vJass need help

tuantai120

Cool Member
Reaction score
1
How to make the dummy move like this with x , y and TT ???
thanks very much

missile.jpg
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
The basics would be something like the following:

JASS:
set x = GetUnitX(myDummyUnit) + SomeOffset * Cos(myAngle)
set y = GetUnitY(myDummyUnit) + SomeOffset * Sin(myAngle)
call SetUnitX(myDummyUnit, x)
call SetUnitY(myDummyUnit, y)


Never used TT myself, but you should just add that in your callback function, with the dummy unit and the angle stored in a struct or something.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
You can set your angle to whatever you want it to be, just make sure the value of the angle is in radians. If you're using AngleBetweenPoints() for example, you'll have to change the functions to the following:

JASS:
set x = GetUnitX(myDummyUnit) + SomeOffset * Cos(myAngle * bj_DEGTORAD)
set y = GetUnitY(myDummyUnit) + SomeOffset * Sin(myAngle * bj_DEGTORAD)


That is unless you skip using the BJ function AngleBetweenPoints() and instead call the natives the BJ does, just without the bj_RADTODEG multiplication.
 

wraithseeker

Tired.
Reaction score
122
just make sure the value of the angle is in radians.

It is better to use radians as you don't have to convert back and forth but if you are totally messing with degrees, you have to do converting which is inefficient.

Use Atan2 to get the angle.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
just make sure the value of the angle is in radians.

It is better to use radians as you don't have to convert back and forth but if you are totally messing with degrees, you have to do converting which is inefficient.

I can't see anywhere in my post where I told him to use degrees over radians, I told him to make sure the angle value is in radians.

> i dont know how to do with Atan2

Check out the function GetAngleBetweenPoints() in the function list and you'll see how to use it. Just ignore the part where the BJ uses "bj_RADTODEG * ..." since you don't want to convert it from radians to degrees.
 

wraithseeker

Tired.
Reaction score
122
Atan2(your target value of y - your caster value of y,your target value of x - your caster value of x)

@Larcenist

It doesn't have to be in radians, it might take some time to change to radians usage for him.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Umm, the angle value in the trigonometrical functions HAS to be in radians, there's no "either degrees or radians" if you want the correct angle here. Which is why I wrote what I did, that either you use the natives directly to get the radian value, or you use the bj_DEGTORAD within the trigonometrical functions.
 

Rainther

I guess I should write something of value here...
Reaction score
61
I do:
JASS:
library XY

function OrbitX takes real X, real dist, real angle returns real
    return ( X + dist * Cos(angle * bj_DEGTORAD) )
endfunction

function OrbitY takes real Y, real dist, real angle returns real
    return ( Y + dist * Sin(angle * bj_DEGTORAD) )
endfunction

function DisXY takes real X1, real Y1, real X2, real Y2 returns real
    local real dx = X2 - X1
    local real dy = Y2 - Y1
    return SquareRoot(dx * dx + dy * dy)
endfunction

function AngXY takes real X1, real Y1, real X2, real Y2 returns real
    return bj_RADTODEG * Atan2(Y2 - Y1, X2 - X1)
endfunction

endlibrary

call OrbitX(X, distance, angle)
call OrbitY(Y,distance, angle)
call DisXY(X1, Y1, X2, Y2)
call AngXY(X1, Y1, X2, Y2)


I call them like that all the time to skip the usage of locations. OrbitX and Orbit Y is like Polar projection, just that I snatched the function and made 2 functions.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Why would one even bother writing his own pretty much useless BJ functions? You didn't even remove the useless conversions between radians to degrees (and the other way around)...
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Because they make things easier to work with and reduce your total code length.

And because working in radians with angle arithmetic is painful.


It's largely an ease-of-use thing, and it's awesome.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Because they make things easier to work with and reduce your total code length.

And because working in radians with angle arithmetic is painful.


It's largely an ease-of-use thing, and it's awesome.

In that case you should write your code with the BJ's until it works, and then convert them to natives. They are really inefficient for moving units if you don't want lag.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
In that case you should write your code with the BJ's until it works, and then convert them to natives. They are really inefficient for moving units if you don't want lag.
No, because no BJ's are built for handling it directly with coordinates.

I don't use those functions either, but it's not really that big of a deal if you do. Single function calls with a few passed variables aren't THAT innefficient.


Messing up with how you handle handles and graphics overkill are generally far more prominent in map performance than slightly innefficient but unleaky code.
 

Rainther

I guess I should write something of value here...
Reaction score
61
There isn't a right way for everyone :D

I did how I do because I noticed a total removal of lag on one of my abilitied when I did like this and not PolarBJ

If one method is easy for you to use and doesn't cause huge problems then use them, but don't go picking too much on others that prefers methods that in the end barerly changes nothing.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top