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
  • 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 The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Sticking with the desserts for now the latest recipe is Fried Apple Pies - https://www.thehelper.net/threads/recipe-fried-apple-pies.194297/
  • The Helper The Helper:
    Finally finding about some of the bots that are flooding the users online - bytespider apparently is a huge offender here - ignores robots.txt and comes in from a ton of different IPs
  • Monovertex Monovertex:
    @The Helper I'm really not seeing the "Signature" link in the sidebar on that page. Here's a screenshot:
  • The Helper The Helper:
    I have reported it - I was wondering why nobody I have given sigs to over the last few years have used them
  • The Helper The Helper:
    Ghan has said he has fixed this. Monovertex please confirm this fix. This was only a problem with people that had signatures in the upper levels like not the special members but the respected members.
  • The Helper The Helper:
    Here is a better place to manage this stuff https://www.thehelper.net/account/account-details which I think should be way more visible
  • The Helper The Helper:
    I am hoping that online user count drop is finally that TikTok bot banned

      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