BJs.

Exide

I am amazingly focused right now!
Reaction score
448
People keep telling me to get rid of BJs. Now I thought I'd do something about it, but I'm not quite sure how. :p

My first guess was to look up the Bj in JassCraft and see what it says, so this is what I get:

JASS:

//GetLastCreatedLightningBJ =

function GetLastCreatedLightningBJ takes nothing returns lightning
    return bj_lastCreatedLightning
endfunction


So I thought I'd just put that function above my actions, and change the function name.

JASS:

//Like so:

function LastEffect takes nothing returns lightning
    return bj_lastCreatedLightning
endfunction

//and then call for 
    set LightningEffect = LastEffect()


Now I get confused. The 'LastEffect' function contains a new bj? (return bj_lastCreatedLightning), what good does that do?

I figured I might as well search for that too and found:



..hmm. :confused:
What the heck is this? :p What do I do about it? Do I keep 'bj_lastCreatedLightning' in my 'LastEffect' function, or do I replace it with something else?
Am I doing this all wrong? :p

On top of it, almost every other BJ I can find develops the same way, and ends up confusing me. -As if conditions and loops weren't enough for me to handle..
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Well...BJ stands for blizzard jass...It is a damn anoying thing that it causes your maps engine to decode the code slower...

I'll take your example:
JASS:
//GetLastCreatedLightningBJ = 
function GetLastCreatedLightningBJ takes nothing returns lightning  
return bj_lastCreatedLightning 
endfunction

Since GetLastCreatedLightningBJ is as same as "bj_lastCreatedLightning" right?

In your situation...bj_lastCreatedLightning stands as a variable and it is NOT a BLIZZARD JASS...

You could straight:
JASS:
set bj_lastCreatedLightning = CreateLightning...


If you do like this:
JASS:
function LastEffect takes nothing returns lightning
    return bj_lastCreatedLightning
endfunction

Now the function "LastEffect" is as same as a BlizzardJass.

Since you uses a variable "LightningEffect" to create a lightning...You could really set the LightningEffect = CreateEffect bla bla bla...

You doesnt need to care about the bj_lastCreatedLightning...since it is the stupid GUI's code...
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
> bj_lastCreatedLightning
> set LightningEffect = LastEffect()

You created a function to avoid having to call a function? ... Good job :p


set LightningEffect = bj_lastCreatedLightning

Better yet:
set LightningEffect = AddSpecialEffectLoc(...)
 

Exide

I am amazingly focused right now!
Reaction score
448
So, like this, then:

JASS:

    set LightningEffect = bj_lastCreatedLightning


Is that as optimized as it can be? Nothing else needs to be done there?
Why is it called bj_...? -That bothers me. :p

EDIT: Replied at about the same time as AceHart posted. :p

>Better yet:
set LightningEffect = AddSpecialEffectLoc(...)

-What's this all about?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
Oh, yeah, lightning is not a special effect...


Anyway:
JASS:
function AddLightningLoc takes string codeName, location where1, location where2 returns lightning
    set bj_lastCreatedLightning = AddLightningEx(codeName, true, GetLocationX(where1), GetLocationY(where1), GetLocationZ(where1), GetLocationX(where2), GetLocationY(where2), GetLocationZ(where2))
    return bj_lastCreatedLightning
endfunction


When this function is called, is creates the lightning and stores it in the global variable.
That variable is, later on, returned by "GetLastCreated...".

Now, instead of passing through all of that mess, do it all yourself, in one line:

set myVariable = AddLightningEx(...)
 

Exide

I am amazingly focused right now!
Reaction score
448
EDIT:
I think I have realized that:

JASS:

native AddLightningEx               takes string codeName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns lightning


Is like in GUI:

Code:
Lightning - Create a Forked Lightning lightning effect from source (Position of (Attacking unit)) to target (Position of (Attacked unit))

Where x1 and y1 is co-ordinates of (as in my case)(Position of (Attacking unit)), and x2 and y2 is; (Position of (Attacked unit)).
Is that correct?
I have yet to figure out what z1 and z2 is, though..
 

Arkan

Nobody rides for free
Reaction score
92
JASS:
local lightning lite = AddLightningEx('MBRN',true,x1,y1,z1,x2,y2,z2)

call DestroyLightning(lite)
set lite = null


codeName = the type of lightning, manaburn, shackles etc.
checkVisibility = not sure, I think whether it shows the lightning only if fog is visible or not

z1 & z2 = don't think these work, the intention was probably to make a lightning in any direction plane

set LightningEffect = AddSpecialEffectLoc(...)

As AceHart said before this doesn't work, Special Effect != Lightning Effect
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
the x1 y1 z1 and x2 y2 z2

1 represent the Attacking unit and 2 represent Attacked unit...(Case of your example)

You might use this though:
JASS:
1. GetUnitX(<unit>)
2. GetUnitY(<unit>)
3. GetUnitZ(<unit>)
 

Exide

I am amazingly focused right now!
Reaction score
448
Ok, so I got this:

JASS:

function Trig_Lightning_Effect_Conditions takes nothing returns boolean
    return ( ( GetUnitTypeId(GetAttacker()) == 'h000' ) )
endfunction

function Trig_Lightning_Effect_Actions takes nothing returns nothing
    local lightning LightningEffect
    local integer LoopStart = 1
    local integer LoopEnd = 2
    local real x = GetUnitX(GetAttacker())
    local real y = GetUnitY(GetAttacker())
    local real x2 = GetUnitX(GetAttackedUnitBJ())
    local real y2 = GetUnitX(GetAttackedUnitBJ())
    local real z
    local real z2
    loop
        exitwhen LoopStart > LoopEnd
        set LightningEffect = AddLightningEx( "FORK", true, x, y, x2, y2, z, z2)        
        call TriggerSleepAction( 0.50 )
        call DestroyLightning(LightningEffect)
        set LoopStart = LoopStart + 1
    endloop
    call PlaySoundAtPointBJ( gg_snd_LightningBolt, 90.00, GetUnitLoc(GetAttacker()), 0 )
endfunction

//===========================================================================
function InitTrig_Lightning_Effect takes nothing returns nothing
    set gg_trg_Lightning_Effect = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Effect, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Lightning_Effect, Condition( function Trig_Lightning_Effect_Conditions ) )
    call TriggerAddAction( gg_trg_Lightning_Effect, function Trig_Lightning_Effect_Actions )
endfunction


Yes, I know I have another BJ to fix. I just wanted to ask if this looks allright?
I also wanted to state that adding 6 local variables to call one function doesn't seem smarter in any way, to me. But I guess I can't see the whole picture. :p
 

Exide

I am amazingly focused right now!
Reaction score
448

Exide

I am amazingly focused right now!
Reaction score
448
But that gives me three more BJs to worry about..
My trigger will change from maybe 20 lines to 60 lines, when I'm done with all the BJs.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>My trigger will change from maybe 20 lines to 60 lines
Well...for me...i would rather uses some BJ since they are more efficient to be...

Example will let you sees the truth:
JASS:
function TriggerRegisterAnyUnitEventBJ takes trigger trig, playerunitevent whichEvent returns nothing


It's function is:
JASS:
function TriggerRegisterAnyUnitEventBJ takes trigger trig, playerunitevent whichEvent returns nothing
    local integer index

    set index = 0
    loop
        call TriggerRegisterPlayerUnitEvent(trig, Player(index), whichEvent, null)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
endfunction


Though it is a BJ...But we had no choise but to use it... :O
 

Exide

I am amazingly focused right now!
Reaction score
448
Ok, so I THINK I got this all sorted out now..
This is what my trigger looks like now:

JASS:

function Trig_Lightning_Effect_Conditions takes nothing returns boolean
    return ( ( GetUnitTypeId(GetAttacker()) == 'h000' ) )
endfunction

function Trig_Lightning_Effect_Actions takes nothing returns nothing
    local lightning LightningEffect
    local integer LoopStart = 1
    local integer LoopEnd = 2
    local real x = GetUnitX(GetAttacker())
    local real y = GetUnitY(GetAttacker())
    local real x2 = GetUnitX(GetTriggerUnit())
    local real y2 = GetUnitX(GetTriggerUnit())
    local real z
    local real z2
    local sound soundeffect = gg_snd_LightningBolt
    local location loc = GetUnitLoc(GetAttacker())
    local integer volume = 90
    loop
        exitwhen LoopStart > LoopEnd
        set LightningEffect = AddLightningEx( "FORK", true, x, y, x2, y2, z, z2)        
        call TriggerSleepAction( 0.50 )
        call DestroyLightning(LightningEffect)
        set LoopStart = LoopStart + 1
    endloop
    call SetSoundPosition(soundeffect, x, y, z)
    call SetSoundVolume(soundeffect, volume)
    call StartSound(soundeffect)
    call RemoveLocation(loc)
    set loc = null    
endfunction

//===========================================================================
function InitTrig_Lightning_Effect takes nothing returns nothing
    set gg_trg_Lightning_Effect = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Effect, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Lightning_Effect, Condition( function Trig_Lightning_Effect_Conditions ) )
    call TriggerAddAction( gg_trg_Lightning_Effect, function Trig_Lightning_Effect_Actions )
endfunction


I haven't tested it yet, so I don't know if it works. :p
Tell me if you find any errors, or anything that can be changed.
Thanks for all the help. :)

EDIT: I tested it, and as I expected, nothing works. :p
No sound or lightning effects.. :(
 

Arkan

Nobody rides for free
Reaction score
92
You messed up the order of the arguments in AddLightningEx.

it's x, y, z, x2, y2, z2.

And try use 0 for z and z2.

And why create a location when you don't use it?
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>"FORK"
Who is teh fork?

IF it doesnt work on the sound...you may try using the BJ's
JASS:
    
call SetSoundPosition(soundeffect, x, y, z)
call SetSoundVolume(soundeffect, volume)
call StartSound(soundeffect)//removed these 3 lines and replace it with BJ's function...see if it work?
 

Sooda

Diversity enchants
Reaction score
318
> "FORK"

Stands for Forked Lightning effect. In our tutorial repository there is tutorial how to optimize your code aka getting rid of BJs.

> IF it doesnt work on the sound...you may try using the BJ's

If problem fix is to use BJs then you could stay to GUI triggering at first place, no need to start to do double work.
 

N-a-z-g-u-l

New Member
Reaction score
30
BJs dont instant-destroy your whole code, they only make the code about ~20% slower, if you use them... and some BJs are useful, for example the sound BJs might be...

(and i hate it when people are against BJs but use local handle vars, as local handle vars are about as useful as BJs... if you really need that performance, then use the gamecache itself... on your own, and not thorugh that system)

nevertheless, you should at least try to remove some BJs... like GetKillingUnit() instead of GetKillingUnitBJ()... but you wont feel a difference (except for if you post your code in a forum and everyone hates you for the BJs^^)
 

Exide

I am amazingly focused right now!
Reaction score
448
This thing is killing me. :p
I changed it a little, it's still not working, but I can see the lightning effects and hear the sounds, at least..
I believe z in this case would be some sort of co-ordinate, because the lightning effects only appear from north to south. They also appear beside the attacker. They don't start at the position of the attacking unit, and only go straight up (south-to-north degree).

JASS:

function Trig_Lightning_Effect_Conditions takes nothing returns boolean
    return ( ( GetUnitTypeId(GetAttacker()) == 'h000' ) )
endfunction

function Trig_Lightning_Effect_Actions takes nothing returns nothing
    local lightning LightningEffect
    local integer LoopStart = 1
    local integer LoopEnd = 2
    local real x = GetUnitX(GetTriggerUnit())
    local real y = GetUnitY(GetAttacker())
    local real x2 = GetUnitX(GetTriggerUnit())
    local real y2 = GetUnitX(GetTriggerUnit())
    local real z = 0
    local sound soundeffect = gg_snd_LightningBolt
    local integer volume = 90
    loop
        exitwhen LoopStart > LoopEnd
        set LightningEffect = AddLightning( "FORK", true, x, y, x2, y2)        
        call TriggerSleepAction( 0.50 )
        call DestroyLightning(LightningEffect)
        set LoopStart = LoopStart + 1
    endloop
    call SetSoundPosition(soundeffect, x, y, z)
    call SetSoundVolume(soundeffect, volume)
    call StartSound(soundeffect)
endfunction

//===========================================================================
function InitTrig_Lightning_Effect takes nothing returns nothing
    set gg_trg_Lightning_Effect = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Effect, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Lightning_Effect, Condition( function Trig_Lightning_Effect_Conditions ) )
    call TriggerAddAction( gg_trg_Lightning_Effect, function Trig_Lightning_Effect_Actions )
endfunction


EDIT: Should sound effects be removed/nulled, or something?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol

      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