Custom Map Script vs. BJ

Nevyll

New Member
Reaction score
1
Which is faster, writing a function in the custom map script section of a map and calling it from a trigger, or simply calling a BJ?

Example:

JASS:
function GetAngleBetweenPoints takes real x1, real x2, real y1, real y2 returns real
    return bj_RADTODEG * Atan2( y2 - y1, x2 - x1 )
endfunction


As opposed to

JASS:
    set SomeReal = AngleBetweenPoints( locA, locB )
 

Komaqtion

You can change this now in User CP.
Reaction score
469
No, first is faster, as you use reals directly...

And, it's simply better to use anyways ;)
 

Nevyll

New Member
Reaction score
1
...but the fastest would simply be not writing any functions at all, but just using the Atan2() native directly in the trigger? ;)
 

Sevion

The DIY Ninja
Reaction score
413
The speed difference versus readability isn't exactly worth it... Using your user-defined function would be better IMHO.

JASS:
local real angle = GetAngleBetweenPoints(x1, x2, y1 ,y2)


If you're just comparing distances, then you don't have to even use the square root ;)

JASS:
local real d1 = dx1*dx1+dy1*dy1
local real d2 = dx2*dx2+dy2+dy2
if ( d1 > d2 ) then
else
endif
 

Sevion

The DIY Ninja
Reaction score
413
Possibly. Actually, I believe it does... Each argument is only used once and there's only one line.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top