• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

BJ's and Non BJ's

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Yes I have a little free time now and I don't know why I this get into my mind but here it is: Actually I want ask WHY BJ's are so bad. And this isn't just simple, because there are more things I don't understand.

What is the difference between a BJ and a non BJ. Like in this example:
JASS:
    call SetUnitAbilityLevelSwapped('ANab', GetTriggerUnit(), 1)
    call SetUnitAbilityLevel(GetTriggerUnit(), 'ANab', 1)
I mean, what's so bad, if I pick first the ability and then the unit as first the unit and then the ability?


Second part I notice and I'm still wondering is about this:
JASS:
    if GetUnitTypeId(GetKillingUnitBJ()) == 'hfoo' then
    if GetUnitTypeId(GetKillingUnit()) == 'hf00' then
As you see you don't write anything into the (), but still there's a BJ and the same thing without the BJ. How this work there and why there's a BJ and non BJ?


Another thing I notice for some minutes and I don't understand this too, was the GUI Action "Game Cache - Save Game Cache". Anyway I'm confused, that I have this action and others not, but when I convert this with the normal World Editor I get: call SaveGameCacheBJ. When I convert this with the NewGen Editor I get: call SaveGameCache.
Wondering about that, because NewGen doesn't convert BJ's to non BJ's automatically and why there are a difference now between both editors?


Another thing is about "Not bad BJ's". For example "Event BJ's" like:
JASS:
   call TriggerRegisterAnyUnitEventBJ( gg_trg_1, EVENT_PLAYER_UNIT_DEATH )
Why these BJ's are now ok and you can leave them as they are.

Now you see, with what I spend my free time @work and I hope I get clear answers about this, that even I can understand this whole thing. =)


One more thing I notice, that some BJ's aren't red marked if I use them with NewGen like:
JASS:
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 10
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
Again, BJ doesn't seem to be bad here and why those Bj's aren't marked with red?

Btw: Is BJ = BlizzardJass or what?^^

Greetings
~ The Bomb King > Dr. Boom
 
Well, firstly, BJ's are bad as something like
GetLastCreatedUnit()

is

JASS:
constant function GetLastCreatedUnit takes nothing returns unit
    return bj_LastCreatedUnit
endfunction
so as you can see, you're executing another trigger, which takes some memory, instead of just using the bj_LastCreatedUnit variable.

other functions like "GetKillingUnitTypeBJ" are this
JASS:
function GetKillingUnitBJ takes nothing returns unit
     return GetKillingUnit()
endfunction
So, why wouldn't you just use "GetKillingUnitType()" instead of having to go through another function?

There's a few functions that are actually not like that, i don't have the editor open at the moment, but the event actions look like this
JASS:
function TriggerRegisterAnyUnitEventBJ takes trigger t, triggerevent, returns nothing
     local integer loop = 0
     loop
          call TriggerRegisterPlayerUnitEvent(t, triggerevent, Player(loop)
          set loop = loop + 1
          exitwhen loop = bj_maxplayers
endfunction
and the reason some bjs aren't considered "evil" is they're bj Variables.

such as bj_forLoopAIndex

and finally, the jngp can automatically switch the useless ones, (like KillUnitBJ()) with the normal ones (KillUnit())
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
If you truly need the extra actions that a BJ function provides then they aren't bad - but in most cases (and situations like GetKillingUnitBJ) it is completely redundant to use a BJ function that simply returns another function; you might as well take out the "middle-man" and just use the value that the BJ function returns.

You wouldn't use functions that return constant numbers.

JASS:
function Ten takes nothing returns integer
    return 10
endfunction

Instead you would just use 10 - which should be fairly obvious.
 
Status
Not open for further replies.
Top