Question about BJ's

BRUTAL

I'm working
Reaction score
118
alright you know how some BJ's like for example; is just one line of code, then if you control + click it, you see the correct way to do it, you would need a integer variable, then do a 'call ForGroup' function and then fidn out what the integers value is

so my question is, if i fixed the bj and did what needed to be done, would be be more efficient? the bj takes one line, and less space : s
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
It's good coding practice, plus I think it is faster.
 

BRUTAL

I'm working
Reaction score
118
but it does take up more space right?
but i suppose i'll get rid of all the bj's :p
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
Yeah, there are a few you can get away with like CountUnitsInGroup or something.
 

Joker(Div)

Always Here..
Reaction score
86
There are 2 types of BJ's. The useless/pointless/wtfwasblizzarddoing BJ and the actually useful BJ. There is no point on removing every single BJ function in your map. Also, if you want to talk about efficiency, someone did a test on BJs on WC3C and found that you would need ~1000 BJ calls to drop the frame rate by 0.1. Honestly, it is not that big of a deal.

The only thing that you should stay away from are those leaking BJs.
 

Azlier

Old World Ghost
Reaction score
461
For starters, here's a BJ that's just stupid:
JASS:
function DoNothing takes nothing returns nothing
endfunction


This is, again, rather useless.
JASS:
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    call ForGroup(whichGroup, callback)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
endfunction


Utter uselessness.
JASS:
function SetUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit, integer level returns integer
    return SetUnitAbilityLevel(whichUnit, abilcode, level)
endfunction


Oh, and a famous leaking one.
JASS:
function PolledWait takes real duration returns nothing
    local timer t
    local real  timeRemaining

    if (duration > 0) then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining <= 0

            // If we have a bit of time left, skip past 10% of the remaining
            // duration instead of checking every interval, to minimize the
            // polling on long waits.
            if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
    endif
endfunction
 
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