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')
 
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
 
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"])
 
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.
 
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.
 
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
 
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.
 
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)
 
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.
 
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
 
[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?
 
All BJ's work off of existing code.

No, there are no BJ's that dont' have a native form.
 
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 ;)
 
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?
 
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 ;)
 
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.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      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