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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top