[Simple] is this event okay (BJ)

R 3 T R O

New Member
Reaction score
12
Ive heard that BJ's arent good to use. I use allot of those for events is that what they are talking about, if so how could i go about doing the same thing without using BJ

JASS:
function SmokeGrenadeConditions takes nothing returns boolean
    local integer i = GetSpellAbilityId()
    return i=='A01B'
endfunction

function SmokeGrenade takes nothing returns nothing
    local unit marine = GetTriggerUnit()
    local unit u
    local unit missile 
    local location l = GetSpellTargetLoc()
    local real x = GetLocationX(l)
    local real y = GetLocationY(l)
    local player p = GetOwningPlayer(marine)
    call FieldChat(marine,5.0, udg_Pcolors[GetConvertedPlayerId(p)] + GetPlayerName(p) + "|r : Smoke!" )
    call PolledWait(0.1)
    set missile = CreateUnit(Player(11),'h00H',GetUnitX(marine),GetUnitY(marine),0.0)
    call IssuePointOrderLoc(missile,"attackground",l)
    call PolledWait(2.5)
    set u = CreateUnit(Player(11),'h00I',x,y,0.0)
    call UnitApplyTimedLife(u,'Bhwd',40.0)
    call PolledWait(4.5)
    set bj_meleeNearestMineDist = GetUnitX(u)
    set bj_lastTransmissionDuration = GetUnitY(u)
    call RemoveLocation(l)
    call RemoveUnit(missile)
    set missile = null
    set marine = null
    set u = null
    set l = null
endfunction

//===========================================================================
function InitTrig_Smoke_Grenade takes nothing returns nothing
    set gg_trg_Smoke_Grenade = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Smoke_Grenade,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition( gg_trg_Smoke_Grenade, Condition( function SmokeGrenadeConditions ) )
    call TriggerAddAction( gg_trg_Smoke_Grenade, function SmokeGrenade )
endfunction
 

Trollvottel

never aging title
Reaction score
262
Just looked at the event and i say it IS okay. Just because it only called ONCE at map init. so in the end its just 1! additional function call. you have to avoid too much bjs in functions which are called frequently and even there it isnt too bad if you have some bjs used (but remove them if it wouldnt make the code more unreadable).
 

R 3 T R O

New Member
Reaction score
12
Well, I rather just remove then how would go about using the same type of event just better and why are bjs so bad
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
They're bad because they:
-Require 1 more function call
-Occasionally leak

In this case, probably shouldn't worry about it. Replacing that with the natives would be incredibly ugly and performance difference negligible.
 

Karawasa

Element Tower Defense
Reaction score
38
Please note that some BJs are irreplaceable. The ones you want to destroy are the ones that simply place a call to a native. Don't get confused by all of this "BJs must die" talk.
 
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