Native Vs. Bj

jhnam95

Active Member
Reaction score
12
I'm sorry if this thread doesn't belong in this section. I'm not quite familiar with this territory. :p

Can anyone explain to me why natives are more preferred than Bj's? I've read quite a few guides on JASS and none of them really gave a decent explanation on why natives would be preferred over Bj's.

Also, do the two functions have a distinct difference? (I'm not even sure if I used the second one correctly.)
JASS:
call UnitRemoveAbilityBJ('A000',u)

JASS:
call UnitRemoveAbility(u,'A000')
 

Romek

Super Moderator
Reaction score
963
This is in the correct section.

People prefer natives simply because BJ's are just functions which (usually) call natives anyway. A lot of them simply reverse the parameters because of the GUI system. It's just an extra function call, really. It's less efficient, with no gain whatsoever.
JASS:
function UnitRemoveAbilityBJ takes integer abilityId, unit whichUnit returns boolean
    return UnitRemoveAbility(whichUnit, abilityId)
endfunction
 

Sevion

The DIY Ninja
Reaction score
413
3 day bump o_O'

But some useful information!

Not all BJ's are bad.

I.E. [ljass]TriggerRegisterAnyUnitEventBJ[/ljass]

(Though, Romek does say this... albiet very subtly ["usually"])
 

Tamisrah

Active Member
Reaction score
16
The questions shouldn't be so much about good or bad.
It's just some/most of the bj's do something you can do better with natives.
(there are even some which do nothing except calling the native)
My opinion is: if you know what the bj does and it does what you want it to do, use it.
 

Bribe

vJass errors are legion
Reaction score
67
It's weird that [ljass]BJDebugMsg[/ljass] loops through all players to message them instead of doing a singular, 20x more efficient message to [ljass]GetLocalPlayer()[/ljass]. You notice the performance hit when you need a lot of debug messages per instant.
 

jhnam95

Active Member
Reaction score
12
Yea... I managed to make most of my BJ's to natives using JassCraft <3 but some of them I can't seem to figure out, such as getting AngleBetweenPoints, BJDebugMsg, SetCameraFieldForPlayer, etc. AngleBetweenPoints, I don't think I understand the math (Haven't taken that level math yet). BJDebugMsg and SetCameraFieldForPlayer, I don't understand their "function" forms. Would I have to create a new function for it or something?


EDIT: Actually, I found a tutorial showing examples of a lot of different conversions. http://www.thehelper.net/forums/showthread.php?t=28321
 

Bribe

vJass errors are legion
Reaction score
67
x2-x, y2-y just gets the difference between the two to form the lines needed for the computation of Atan2 ([ljass]AngleBetweenPoints[/ljass]).

The [LJASS]bj_RADTODEG[/LJASS] part of it is because Atan2 returns its value in radians, while BJ's are designed for degrees.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Anything prefixed by "bj_" is defined as a global variable in the blizzard.j. They are fine to use. (but certain variables might interfere with some other GUI functions if you set values to them)
 

jhnam95

Active Member
Reaction score
12
You mean prefix :p. And I'm planning on avoiding GUI as much as possible.

So basically, anything that's not in red text in JassCraft or NewGen are ok?


Also, is there a way to acquire an angle between two points using coordinates? I heard that coordinates are preferred over points.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
So basically, anything that's not in red text in JassCraft or NewGen are ok?

Yeah, natives are always better than BJ's, without exceptions ;)
Though, as said, some can still be quite useful :D

Also, is there a way to acquire an angle between two points using coordinates? I heard that coordinates are preferred over points.

Well, why don't you take a look in JassCraft (Or why not use Newgen and TESH ? :S) and see what the function [ljass]AngleBetweenPoints()[/ljass] is made of, and there you'll see that it's actually using coordinates internally :D
 

jhnam95

Active Member
Reaction score
12
[ljass]Atan2(y2-y1, x2-x1)[/ljass]

You're basically inlining it and changing the arguments. The function uses coordinates anyhow.

Oooh... It had some weird names for the coordinates so I couldn't recognize them...


Are there any BJ's that don't have a native form? I know there are natives that can't be accessed using BJ's but what about the opposite?
 

Sevion

The DIY Ninja
Reaction score
413
All BJ's work off of existing code.

No, there are no BJ's that dont' have a native form.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Though there are some BJ's which use a HUGE amount of other BJ's and stuff, such as the function [ljass]CustomVictoryBJ[/ljass] which internally uses 5 BJ's by itself, and these are quite heavy ones ;)
 

jhnam95

Active Member
Reaction score
12
Oh wow. That calls BJ's that call more BJ's... Then wouldn't it be easier for the coder to just use that simple BJ function rather than making it 15 lines long, or does that bit of laziness affect the gameplay significantly?
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, since this is the Defeat and Victory functions, the game would usually end after those actions anyways, so it wouldn't be a problem ;)
 

jhnam95

Active Member
Reaction score
12
Oh, that's a good point... Didn't think that through... Are there any other BJ's that long?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top