BJs.

Sooda

Diversity enchants
Reaction score
318
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 unit attacker = GetAttacker()
    local unit target = GetTriggerUnit()
    
    local lightning LightningEffect
    
    local integer volume = 90
    local integer LoopStart = 1
    local integer LoopEnd = 2
    
    local real x = GetUnitX(attacker)
    local real y = GetUnitY(attacker)
    local real x2 = GetUnitX(target)
    local real y2 = GetUnitX(target)
    local real z = 0

    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(gg_snd_LightningBolt, x, y, z)
    call SetSoundVolume(gg_snd_LightningBolt, volume)
    call StartSound(gg_snd_LightningBolt)
    
    // Cleaning is important.
    set attacker = null
    set target = null
    set LightningEffect = 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

Your x, x and x2,y2 coordinates where wrongly set up. All local handles needs to be nulled. It means local sounds need to be nulled. But your sound is constant and isn' t changing so you could directly use that instead. Then you don' t have to null it. Though when you want to use different sound it is better to use local sound and after null local sound. So you don' t have to change in all places sound when you want to fastly change function.

> local real z = 0

It' s height from ground where sound is played. Default game camera z height is 1600. If you would change your z to 1600 it would play your sound louder because it is closer to player view. Thats why sound becomes louder when you scroll your game screen view to lower where are units.
 

substance

New Member
Reaction score
34
JASS:
function Trig_Lightning_Effect_Actions takes nothing returns nothing
 local lightning LightningEffect
 local integer LoopStart = 1
 local real x = GetUnitX(GetAttacker())
 local real y = GetUnitY(GetAttacker())
 local real x2 = GetUnitX(GetTriggerUnit())
 local real y2 = GetUnitX(GetTriggerUnit())
    
    loop
       exitwhen LoopStart > 2
       set LightningEffect = AddLightningEx("FORK", true, x, y, 0., x2, y2, 0.)        
       call TriggerSleepAction( 0.50 )
       call DestroyLightning(LightningEffect)
       set LoopStart = LoopStart + 1
    endloop    
    call SetSoundPosition(gg_snd_LightningBolt, x, y, 0.)
    call SetSoundVolume(gg_snd_LightningBolt, 90)
    call StartSound(gg_snd_LightningBolt)
    
 set LightningEffect = null
endfunction


you had alot of useless locals. Btw it's not a good idea to use waits inside of loops, use a timer.
 

Sim

Forum Administrator
Staff member
Reaction score
534
Exide, one thing you should always do first before worrying about BJ stuff, leaks, etc. is making sure it works.

In short, use BJs first, and if it works, start switching them into natives one by one. Then clean leaks, and then null everything.

Happened to me once and I decided never to rush right into the natives. (It was with the stats changing stuff - SetHeroAgi, Int, Str, etc, they don't work properly when combined together with their native "Get..." equivalents).

So, if it doesn't work, try working with BJs first :)

For future reference...
 

Vexorian

Why no custom sig?
Reaction score
187
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...
"Get rid of BJs" is often said about the lame BJ functions, the ones that aren't useful at all.

I am not sure if any of the sound functions in blizzard.j is useful though.

(and i hate it when people are against BJs but use local handle vars, as local handle vars are about as useful as BJs...
This is senseless.

This is what functions should do:
- Make things faster for you to write.
- Make code easier to read
- Save dev. time
- improve maintainability

A BJ does not follow any of those , in fact it actually makes things slower to write since you add BJ to everything. And some also make things harder to read and understand, since they got such unfriendly order of arguments, why exactly "UnitAddAbilityBJ" takes ability before unit? Also why exactly should you do things like this:

Code:
   call CreateLightningBlahblahbllah
   set  var = LastCreatedLighting()

instead of

Code:
   set  var = CreateLighting

second will always be cleaner...

Handle vars on the other hand do fulfill the objectives of a function.

if you really need that performance, then use the gamecache itself... on your own, and not thorugh that system)
That's a common statement and it is wrong as heck, if you want performance don't use gamecache, just using the natives directly and messing with return bug exploiters will make your code look like spaguetty, won't improve performance at all (since gamecache is itself much slower than a function call) and will also waste your time.

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^^)

Yes, you would look like a total lamer if you actually use GetKillingUnitBJ() it tells me "look I didn't learn Jass I just took a GUI trigger and converted it to custom text"

That's a huge difference to me...

Happened to me once and I decided never to rush right into the natives. (It was with the stats changing stuff - SetHeroAgi, Int, Str, etc, they don't work properly when combined together with their native "Get..." equivalents).

Here's a suggestion, forget about blizzard.j it doesn't make anything useful, And if you had problems with SetHeroAgi, please use the bonus argument correctly.

There is no need to first learn and write bad code and spend time fixing it later when you can do things correctly from the start.
 

Sim

Forum Administrator
Staff member
Reaction score
534
My opinion stands. He should not rush into natives right away if it can mess up his triggers.

First, learn how JASS works. Then, polish it.

> And if you had problems with SetHeroAgi, please use the bonus argument correctly.

I'm not argumenting, I'm helping him.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
"Get rid of BJs" is often said about the lame BJ functions, the ones that aren't useful at all.

I am not sure if any of the sound functions in blizzard.j is useful though.

Some DNC sound functions are a little useful. But not that much.

This is senseless.

This is what functions should do:
- Make things faster for you to write.
- Make code easier to read
- Save dev. time
- improve maintainability

A BJ does not follow any of those , in fact it actually makes things slower to write since you add BJ to everything. And some also make things harder to read and understand, since they got such unfriendly order of arguments, why exactly "UnitAddAbilityBJ" takes ability before unit? Also why exactly should you do things like this:

Then wtf does BJ stand for? Blizzard.j or Bad Jass?

Really, once you come down to it, if you are a newb it will be quite confusing to know that "bj_"s are BJs but they are good BJs, some BJs don't have "BJ", BJs with "BJ" are BJs, BJs that don't save time, don't improve maintainability, don't make the code easier to read, and doesn't makes things faster to write are BJs. Oh, yea, and all content from the Blizzard.j are BJs. :p
 

Sim

Forum Administrator
Staff member
Reaction score
534
> As conclusion, Some BJs are good and Some BJs are bad, you need to differentshape it.

Hence why I suggest making sure that your trigger works before "optimizing" it.
 

Exide

I am amazingly focused right now!
Reaction score
448
Thanks for all the replies. :)
I got it all working now, I also found out that:

z = height at x + y, and z2 = height at x2 + y2.
In other words, if I put 300 at z, the lightning effect will start at (Attacking Unit) at flying height 300.

I have one more question, though..
These bj_ confused me further..
bj_.. is a variable?

JASS:

    set bj_lastCreatedEffect = //blabla..


Should I null it?

JASS:
 

Exide

I am amazingly focused right now!
Reaction score
448
So I should just leave it then?
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
This will do:
JASS:
call DestroyLightning(<YourLightning'sName>)


The next time u set the Global it will overwrite the last data...so you can just leave it then after you had cleared the leak inside it..
 

Exide

I am amazingly focused right now!
Reaction score
448
New BJ problem..

JASS:

function CreateTextTagLocBJ takes string s, location loc, real zOffset, real size, real red, real green, real blue, real transparency returns texttag
    set bj_lastCreatedTextTag = CreateTextTag()
    call SetTextTagTextBJ(bj_lastCreatedTextTag, s, size)
    call SetTextTagPosBJ(bj_lastCreatedTextTag, loc, zOffset)
    call SetTextTagColorBJ(bj_lastCreatedTextTag, red, green, blue, transparency)

    return bj_lastCreatedTextTag
endfunction


How do I fix this?
I tried the following:

JASS:

    local texttag tt = "|cffff0000" + ( I2S(GetUnitUserData(GetKillingUnit())) + "|r")

    call SetTextTagPosUnit(tt, GetKillingUnit(), z)


But JassCraft tells me I cannot convert string to texttag. So I guess it doesn't work like that..
 

Exide

I am amazingly focused right now!
Reaction score
448
Ok, so I did something which is obviously wrong, since I can't see any floating text. What I did was:

JASS:

    local location loc = GetUnitLoc(GetKillingUnit())
    local real z = 300
    local texttag tt = CreateTextTag()
    local string s = ( I2S(GetUnitUserData(GetKillingUnit())))

    call SetTextTagPosUnit(tt, GetKillingUnit(), z)
    call SetTextTagText(tt, s, 15)
    call SetTextTagPos(tt, GetLocationX(loc), GetLocationY(loc), 15)    
    call SetTextTagColor(tt, PercentTo255(255), PercentTo255(0), PercentTo255(0), PercentTo255(100.0-0))        
    set tt = GetLastCreatedTextTag()

    call TriggerSleepAction( 0.60 )
    call DestroyTextTag( tt )
    call RemoveLocation(loc)
    set loc = null


I'm not sure what '15' in call SetTextTagText, is.. I figured it might be the font size or something..
Help appriciated.
 

N-a-z-g-u-l

New Member
Reaction score
30
in that case the BJ contains a BJ again... thats very hard with texttags, if you anti-BJ them^^

i use this:
http://jass.sourceforge.net/doc/api/Blizzard_j-source.shtml

and then STRG + F for the function, searching from the top... if it exists as a function, the first find is the function, otherwise it must be a common.j function ( http://jass.sourceforge.net/doc/api/common_j-source.shtml )

and i know, its possible with other programs, too, but i dont know how to do it there, so i post my way^^

and for your problem:

JASS:
call SetTextTagVisibility(tt, true)


and you dont need set tt = GetLastCreatedTextTag(), it is not even possible to have it there, because it returns a variable only BJ-functions set:

JASS:
//===========================================================================
function GetLastCreatedTextTag takes nothing returns texttag
    return bj_lastCreatedTextTag
endfunction


and tt already contains your texttag... thats the variable you are accessing it through all the time, isnt it?^^
 

Exide

I am amazingly focused right now!
Reaction score
448
>and tt already contains your texttag... thats the variable you are accessing it through all the time, isnt it?^^
I really don't know. If you say so..

Ok, so I just added that visible function and removed that 'set blabla' function, but it still doesn't work. I thought making it visible would make it work, but I can't see anything..

This is what it looks like now:
JASS:

    local location loc = GetUnitLoc(GetKillingUnit())
    local real z = 300
    local texttag tt = CreateTextTag()
    local string s = ( I2S(GetUnitUserData(GetKillingUnit())))

    call SetUnitUserData( GetKillingUnit(), ( GetUnitUserData(GetKillingUnit()) + 1 ) )
    call SetTextTagPosUnit(tt, GetKillingUnit(), z)
    call SetTextTagText(tt, s, 0)
    call SetTextTagPos(tt, GetLocationX(loc), GetLocationY(loc), 0)    
    call SetTextTagColor(tt, PercentTo255(255), PercentTo255(0), PercentTo255(0), PercentTo255(100.0-0))
    call SetTextTagVisibility(tt, true)

    call TriggerSleepAction( 0.60 )
    call DestroyTextTag( tt )
    call RemoveLocation(loc)
    set loc = null


Could it be my local string variable? I'm gonna try and change it to something else and see..

EDIT: I saw ..Something! :p
It was like a few red dots by my killing unit, every time I killed something. Almost as if the height of the actual font was set to 0.
So I tried changing: call SetTextTagText(tt, s, 0), 0 to 15. But now the red dots are gone...
Does anyone know what I need to change to make my font height larger? :p
 

N-a-z-g-u-l

New Member
Reaction score
30
call SetTextTagText(tt, s, 0)

that means your text has a size of 0...^^

call SetTextTagText(tt, s, 0.23) is standard afaik

and you have the texttag in tt, of course:

JASS:
    local texttag tt = CreateTextTag()


from then on its saved there... and you already give it as parameters to the other functions...

(if it still does not work, then that could be the texttag color, 0% transparancy sometimes means 0 as value, and sometimes its 255...)

EDIT: 15 just was too big^^
 

Exide

I am amazingly focused right now!
Reaction score
448
EDIT: I got it all working as I wanted it to, thanks for all the help! :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • 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 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