how to create an local group variable

Ashlebede

New Member
Reaction score
43
In JASS :

JASS:
local group myGroup


In GUI, you have to create a variable normally (CTRL+B), then you can create a local using Custom Script, with the same name as your variable pre-declared with CTRL+B. The local will have priority over the global when you use it :

Trigger:
  • Custom Script : local group udg_myGroupsName


Don't forget to place [ljass]udg_[/ljass] before your variable's name.

Note : it will not exist in your whole trigger, but only in the trigger's main function. It might not work as intended.
 

RangerX

I am justice!
Reaction score
69
well i know that but [this is my bad didn't put it straight] i need an variable in a jass spell :|

JASS:

function Trig_PA_GetG_II_Func003002002 takes nothing returns boolean
    return ( UnitHasBuffBJ(GetFilterUnit(), 'B007') == true )
endfunction

function Actions takes nothing returns nothing
    local group g
    local unit tu = GetEnumUnit()
    local location pos
    local location offpos
    set g = udg_Pulse_A
    set pos = GetUnitLoc(GetEnumUnit())
    set offpos = PolarProjectionBJ(pos, 150.00, ( 180.00 + GetUnitFacing(tu) ))
    call SetUnitPositionLoc( GetEnumUnit(), offpos )
    call RemoveLocation(pos)
    call RemoveLocation(offpos)
    call UnitRemoveAbility( tu, 'B007' )
    call GroupRemoveUnit( g,tu)
    call DestroyGroup (udg_Pulse_A)
endfunction

function Trig_PA_GetG_II_Actions takes nothing returns nothing
    local group g
    call TriggerSleepAction( 0.50 )
    set g = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_PA_GetG_II_Func003002002))
    call ForGroup( g, function Actions )
    call TriggerSleepAction( 0.10 )
    call DestroyGroup (g)
    set udg_Pulse_A = g
endfunction

//===========================================================================
function InitTrig_PA_GetG_II takes nothing returns nothing
    set gg_trg_PA_GetG_II = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_PA_GetG_II, 0.03 )
    call TriggerAddAction( gg_trg_PA_GetG_II, function Trig_PA_GetG_II_Actions )
endfunction


i need to get rid of that "udg_Pulse_A" thingy so i can be sure is mui :p
 

tooltiperror

Super Moderator
Reaction score
231
Despite what many coders think, boolexpr variables created through Condition or Filter do not leak any more than a string would, as they are recycled. When a boolexpr is first created, it is placed in the memory.

Actually, as the quote explains, [LJASS]boolexpr[/LJASS]'s are not created everytime you use [LJASS]Condition[/LJASS] or [LJASS]Filter[/LJASS], however they are created for the following functions.

JASS:

And(...,...)
Or(...,...)
Not(...)


You can also use [LJASS]null[/LJASS] in a boolexpr without leaking.
 

RangerX

I am justice!
Reaction score
69
is this the right way of doing this ?
JASS:

function filter takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(),'B007')>0
endfunction
function Main_Actions takes nothing returns nothing 
    local unit tu = GetEnumUnit()
    local location pos
    local location offpos
    local real angle
  if GetUnitAbilityLevel(tu,'B007')>0 then 
    set pos = GetUnitLoc(GetEnumUnit())
    set angle = AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetUnitLoc(tu)) 
    set offpos = PolarProjectionBJ(pos, 150.00, ( angle ) )
    call SetUnitPositionLoc( GetEnumUnit(), offpos )
    call RemoveLocation(pos)
    call RemoveLocation(offpos)
    call UnitRemoveAbility( tu, 'B007' )
  endif
endfunction

function Actions takes nothing returns nothing
    local group g = CreateGroup()
    local boolexpr be = Condition(function filter)
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea,be)
    call DestroyBoolExpr(be)
    call TriggerSleepAction(0.05)
    call ForGroup( g, function Main_Actions )
    call DestroyGroup (g)
endfunction



//===========================================================================
function InitTrig_PA_GetG_II takes nothing returns nothing
    set gg_trg_PA_GetG_II = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_PA_GetG_II, 0.03 )
    call TriggerAddAction( gg_trg_PA_GetG_II, function Actions )
endfunction
 

tooltiperror

Super Moderator
Reaction score
231
There are a few problems.

  • [LJASS]TriggerAddAction[/LJASS] is slower than [LJASS]TriggerAddCondition[/LJASS].
  • You make use of a few BJ's.
  • The Boolexpr doesn't need to be leak cleared like that, it's fine.
  • You are using leaking groups.
  • You don't need the filter function.
  • This should be in a scope/library.
 

RangerX

I am justice!
Reaction score
69
could you help me get this right I'm tring to learn jass
[without the BJ i know how to fix them but they are my last problem ]
 

tooltiperror

Super Moderator
Reaction score
231
JASS:
//warning: untested
 library Periodic initializer OnInit
   globals
       group GROUP=CreateGroup()
   endglobals
   private function filter takes nothing returns boolean
       local unit e = GetEnumUnit()
       local location pos
       local location offpos
       local real angle
       if GetUnitAbilityLevel(tu,'B007')>0 then 
           set pos = GetUnitLoc(GetEnumUnit())
           set angle = AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetUnitLoc(tu)) 
           set offpos = PolarProjectionBJ(pos, 150.00, ( angle ) )
           call SetUnitPositionLoc( GetEnumUnit(), offpos )
           call UnitRemoveAbility( tu, 'B007' )
       endif
       call RemoveLocation(pos)
       call RemoveLocation(offpos)
       set pos=null
       set offpos=null
       set e=null
       return false
   endfunction
   private function Actions takes nothing returns boolean
       call GroupEnumUnitsInRect(GROUP,bj_mapInitialPlayableArea,Filter(function filter))
       return false
   endfunction
   private function OnInit takes nothing returns nothing
       call TimerStart(CreateTimer(),0.05,true,function Actions)
   endfunction
 endlibrary


Completely untested, but it should work. Just remove the BJ's. I hope you know using a low frequency like this may cause lag.
 

RangerX

I am justice!
Reaction score
69
k testing :) i know but i use that just because the spell is an auto-attack spell [searing arrows] and i need it so the target go be pushed back [without using any slide cuz only in this is used knowkback :p let's see :p
 

tooltiperror

Super Moderator
Reaction score
231
If you just base your ability off of an existing one and use this library you can actually register the event.
 

RangerX

I am justice!
Reaction score
69
with the old trigger ? yes with this one they get the buff but it seems that the buff is not removed or instamove 150point backward
 

tooltiperror

Super Moderator
Reaction score
231
JASS:
//warning: untested
 library Periodic initializer OnInit
   globals
       group GROUP=CreateGroup()
   endglobals
   private function filter takes nothing returns boolean
       local unit e = GetEnumUnit()
       local location pos
       local location offpos
       local real angle
       if GetUnitAbilityLevel(tu,'B007')>0 then 
           set pos = GetUnitLoc(e)
           set angle = GetUnitFacing(e)+180
           set offpos = PolarProjectionBJ(pos, 150.00, ( angle ) )
           call SetUnitPositionLoc( GetEnumUnit(), offpos )
           call UnitRemoveAbility( tu, 'B007' )
       endif
       call RemoveLocation(pos)
       call RemoveLocation(offpos)
       set pos=null
       set offpos=null
       set e=null
       return false
   endfunction
   private function Actions takes nothing returns boolean
       call GroupEnumUnitsInRect(GROUP,bj_mapInitialPlayableArea,Filter(function filter))
       return false
   endfunction
   private function OnInit takes nothing returns nothing
       call TimerStart(CreateTimer(),0.05,true,function Actions)
   endfunction
 endlibrary


Should work now, I forgot that I separated the functions and didn't carry over a variable.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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