Adding unit to local group

Leazy

You can change this now in User CP.
Reaction score
50
Hey!

I try to add a unit to a local group using:
Code:
Custom script:   Call GroupAddUnitSimple( udg_Target, Knocked )

I get error message saying "Expected 'endif'"

This is the whole trigger:
Trigger:
  • Repulsion Totem Repel
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Custom script: local group Knocked
      • Unit Group - Pick every unit in RepulsionTotem_Group and do (Actions)
        • Loop - Actions
          • Set Caster = (Picked unit)
          • Set Point[1] = (Position of Caster)
          • Set Group[1] = (Units within 300.00 of Point[1] matching ((((Matching unit) belongs to an enemy of (Owner of Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is in Knockback_Group) Equal to False))))
          • Unit Group - Pick every unit in Group[1] and do (Actions)
            • Loop - Actions
              • Set Target = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Target is in Repel_Group) Equal to False
                • Then - Actions
                  • Set Point[2] = (Position of Target)
                  • Set Damage = ((Max life of Target) x 0.08)
                  • Unit - Cause Caster to damage Target, dealing Damage damage of attack type Normal and damage type Normal
                  • Set Knockback_Angle[(Custom value of Target)] = (Angle from Point[1] to Point[2])
                  • Set Knockback_Time[(Custom value of Target)] = 0.40
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Distance between Point[1] and Point[2]) + 150.00) Greater than 300.00
                    • Then - Actions
                      • Set Knockback_Distance[(Custom value of Target)] = 150.00
                    • Else - Actions
                      • Set Knockback_Distance[(Custom value of Target)] = ((Distance between Point[1] and Point[2]) + 50.00)
                  • Unit Group - Add Target to Knockback_Group
                  • Unit Group - Add Target to Repel_Group
                  • Trigger - Turn on Knockback <gen>
                  • Custom script: Call GroupAddUnitSimple( udg_Target, Knocked )
                  • Custom script: call RemoveLocation (udg_Point[2])
                • Else - Actions
                  • Unit Group - Remove Target from Group[1]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Group[1] is empty) Equal to False
            • Then - Actions
              • For each (Integer A) from 1 to 18, do (Actions)
                • Loop - Actions
                  • For each (Integer B) from 1 to 6, do (Actions)
                    • Loop - Actions
                      • Set Point[2] = (Point[1] offset by (50.00 x (Real((Integer B)))) towards ((360.00 / 18.00) x (Real((Integer A)))) degrees)
                      • Special Effect - Create a special effect at Point[2] using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Custom script: call RemoveLocation (udg_Point[2])
            • Else - Actions
          • Custom script: call RemoveLocation (udg_Point[1])
          • Custom script: call DestroyGroup (udg_Group[1])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (RepulsionTotem_Group is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • Wait 2.00 seconds
      • Custom script: set Knocked = udg_Group[1]
      • Unit Group - Pick every unit in Group[1] and do (Unit Group - Remove (Picked unit) from Repel_Group)
      • Custom script: call DestroyGroup (Knocked)
 

Dirac

22710180
Reaction score
147
[ljass]Call[/ljass]
->
[ljass]call[/ljass]

Jass is case sensitve

[ljass]GroupAddUnitSimple()[/ljass]
->
[ljass]GroupAddUnit()[/ljass]
 

Leazy

You can change this now in User CP.
Reaction score
50
Ah, lol, thanks! :) Still doesn't work tho:

Code:
Custom script:   call GroupAddUnit( udg_Target, Knocked )
 

Dirac

22710180
Reaction score
147
Trigger:
  • Custom script: call DestroyGroup (Knocked)

There you're not destroying the Knocked group, you're destroying Group[1], you set it to another group here...
Trigger:
  • Custom script: set Knocked = udg_Group[1]

That Knocked group has to be destroyed and nulled otherwise it would leak.

Also...
[ljass]call GroupAddUnit(group, unit)[/ljass]
Not otherwise.

Using locals in GUI -> bad idea.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
he has a wait before he destroys the variables, so locals must be used for this, eventho they arent great, iv seen many players be fine with locals in gui, but i do think leazy is ready for JASS
 

Leazy

You can change this now in User CP.
Reaction score
50
Custom script: call GroupAddUnit(Knocked, udg_Target)
still error :/
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
i believe it should be UDG_Knocked

and try switching the places around, you cant add the unit (UDG_Group) to the group (UDG_Unit) get it?
 

Dirac

22710180
Reaction score
147
i believe it should be UDG_Knocked

and try switching the places around, you cant add the unit (UDG_Group) to the group (UDG_Unit) get it?
GFreak45 i know you're trying to help but stop that nonsense.

Are you sure that line is causing the error? If you delete it then the code compiles?
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
just a heads up dirac, that sounded really rude regardless of how you meant it -.-

and i was suggesting what i would do in his circumstances, and isnt Knocked a variable? so it should have UDG_ before it shouldnt it?

i basically told him to test it out, there isnt a huge problem in that
 

Leazy

You can change this now in User CP.
Reaction score
50
No, you don't use udg_ before local variables. Thanks anyway :)

Yes, the trigger works when I delete that particular line.
 

Dirac

22710180
Reaction score
147
I really can't see how i was rude there, you were plain wrong and all i did was pointing it out, it's the "ask for a thanks for unhelpful stuff" all over again. If anything you should be sorry for posting wrong info, investigate a little more and come back with real help.
You can't answer something you don't know about. You might as well ask "Isn't supposed to have the udg_ prefix? and if so should it be written in CAPS?"
Variables created through the variable editor carry the udg_ prefix in JASS, but locals and globals don't. There's something you should know, but Leazy knew that as he didn't do it.
Remember that because JASS is case sensitive writing UDG instead of udg would break the code.

Also that kind of replies should be taken directly to me instead of posting it in the thread, i posted it in here because now i had to explain why UDG is wrong.

Leazy please post your trigger converted to custom text
 

Leazy

You can change this now in User CP.
Reaction score
50
JASS:
function Trig_Repulsion_Totem_Repel_Func002Func003002003001 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_Caster)) == true )
endfunction

function Trig_Repulsion_Totem_Repel_Func002Func003002003002001 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Repulsion_Totem_Repel_Func002Func003002003002002 takes nothing returns boolean
    return ( IsUnitInGroup(GetFilterUnit(), udg_Knockback_Group) == false )
endfunction

function Trig_Repulsion_Totem_Repel_Func002Func003002003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Repulsion_Totem_Repel_Func002Func003002003002001(), Trig_Repulsion_Totem_Repel_Func002Func003002003002002() )
endfunction

function Trig_Repulsion_Totem_Repel_Func002Func003002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Repulsion_Totem_Repel_Func002Func003002003001(), Trig_Repulsion_Totem_Repel_Func002Func003002003002() )
endfunction

function Trig_Repulsion_Totem_Repel_Func002Func004Func002Func008C takes nothing returns boolean
    if ( not ( ( DistanceBetweenPoints(udg_Point[1], udg_Point[2]) + 150.00 ) > 300.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Repulsion_Totem_Repel_Func002Func004Func002C takes nothing returns boolean
    if ( not ( IsUnitInGroup(udg_Target, udg_Repel_Group) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Repulsion_Totem_Repel_Func002Func004A takes nothing returns nothing
    set udg_Target = GetEnumUnit()
    if ( Trig_Repulsion_Totem_Repel_Func002Func004Func002C() ) then
        set udg_Point[2] = GetUnitLoc(udg_Target)
        set udg_Damage = ( GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_Target) * 0.08 )
        call UnitDamageTargetBJ( udg_Caster, udg_Target, udg_Damage, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL )
        set udg_Knockback_Angle[GetUnitUserData(udg_Target)] = AngleBetweenPoints(udg_Point[1], udg_Point[2])
        set udg_Knockback_Time[GetUnitUserData(udg_Target)] = 0.40
        if ( Trig_Repulsion_Totem_Repel_Func002Func004Func002Func008C() ) then
            set udg_Knockback_Distance[GetUnitUserData(udg_Target)] = 150.00
        else
            set udg_Knockback_Distance[GetUnitUserData(udg_Target)] = ( DistanceBetweenPoints(udg_Point[1], udg_Point[2]) + 50.00 )
        endif
        call GroupAddUnitSimple( udg_Target, udg_Knockback_Group )
        call GroupAddUnitSimple( udg_Target, udg_Repel_Group )
        call EnableTrigger( gg_trg_Knockback )
        call GroupAddUnit(Knocked, udg_Target)
        call RemoveLocation (udg_Point[2])
    else
        call GroupRemoveUnitSimple( udg_Target, udg_Group[1] )
    endif
endfunction

function Trig_Repulsion_Totem_Repel_Func002Func005C takes nothing returns boolean
    if ( not ( IsUnitGroupEmptyBJ(udg_Group[1]) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Repulsion_Totem_Repel_Func002A takes nothing returns nothing
    set udg_Caster = GetEnumUnit()
    set udg_Point[1] = GetUnitLoc(udg_Caster)
    set udg_Group[1] = GetUnitsInRangeOfLocMatching(300.00, udg_Point[1], Condition(function Trig_Repulsion_Totem_Repel_Func002Func003002003))
    call ForGroupBJ( udg_Group[1], function Trig_Repulsion_Totem_Repel_Func002Func004A )
    if ( Trig_Repulsion_Totem_Repel_Func002Func005C() ) then
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 18
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            set bj_forLoopBIndex = 1
            set bj_forLoopBIndexEnd = 6
            loop
                exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
                set udg_Point[2] = PolarProjectionBJ(udg_Point[1], ( 50.00 * I2R(GetForLoopIndexB()) ), ( ( 360.00 / 18.00 ) * I2R(GetForLoopIndexA()) ))
                call AddSpecialEffectLocBJ( udg_Point[2], "Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl" )
                call DestroyEffectBJ( GetLastCreatedEffectBJ() )
                call RemoveLocation (udg_Point[2])
                set bj_forLoopBIndex = bj_forLoopBIndex + 1
            endloop
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
    else
    endif
    call RemoveLocation (udg_Point[1])
    call DestroyGroup (udg_Group[1])
endfunction

function Trig_Repulsion_Totem_Repel_Func003C takes nothing returns boolean
    if ( not ( IsUnitGroupEmptyBJ(udg_RepulsionTotem_Group) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Repulsion_Totem_Repel_Func006002 takes nothing returns nothing
    call GroupRemoveUnitSimple( GetEnumUnit(), udg_Repel_Group )
endfunction

function Trig_Repulsion_Totem_Repel_Actions takes nothing returns nothing
    local group Knocked
    call ForGroupBJ( udg_RepulsionTotem_Group, function Trig_Repulsion_Totem_Repel_Func002A )
    if ( Trig_Repulsion_Totem_Repel_Func003C() ) then
        call DisableTrigger( GetTriggeringTrigger() )
    else
    endif
    call TriggerSleepAction( 2 )
    set Knocked = udg_Group[1]
    call ForGroupBJ( udg_Group[1], function Trig_Repulsion_Totem_Repel_Func006002 )
    call DestroyGroup (Knocked)
    call DestroyGroup (udg_Group[1])
endfunction

//===========================================================================
function InitTrig_Repulsion_Totem_Repel takes nothing returns nothing
    set gg_trg_Repulsion_Totem_Repel = CreateTrigger(  )
    call DisableTrigger( gg_trg_Repulsion_Totem_Repel )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Repulsion_Totem_Repel, 0.03 )
    call TriggerAddAction( gg_trg_Repulsion_Totem_Repel, function Trig_Repulsion_Totem_Repel_Actions )
endfunction
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
thats not it at all, its called trying to help, i may be wrong but at least im trying to help and a lot of my suggestions have been successful without me being sure 100% whether they are right at first beforehand, and if they are wrong, explain, dont act like a jackass and say stop that nonsense, if you dont see that being rude then you obviously have english as a second language or were never taught how to speak to others, idc if you are rude to me when its in pms, i actually prefer it but in the forum like this it pushes people away when they see people acting like jackasses, see what im saying?

ps. i do think ur chill and i do think you help but try to be nicer on the forum, idc if ur rude to me but the way you act reflects on the mods and the site, regardless of how good or bad it is, and i have seen others get offended by the way you act
 

Dirac

22710180
Reaction score
147
Yea i can see the issue.
This is why i say declaring locals in GUI is a bad idea, if you don't know JASS then i can't really explain you what's wrong, but you can't use the Knocked local inside the group's enumeration part, you just can't. My advise:
Add the units to a TempGroup inside the group enumeration, then just before the wait do this
Trigger:
  • Custom Script: set Knocked = udg_TempGroup
and then remove the group, it wont leak.
 

NotInTheFace

Member
Reaction score
17
Looks like the problem is that you're trying to use a local variable outside of the function it's declared in.

Everything under
Trigger:
  • Unit Group - Pick every unit in RepulsionTotem_Group and do (Actions)
is in a different function from the main trigger actions, so the local variable is no longer in scope.

It would probably just be easier to use a global variable, or a hashtable value if you're trying to make it MUI.
 

Romek

Super Moderator
Reaction score
964
The whole trigger is instant until the wait at the very bottom. Use a global group for the main bulk of the trigger, and set it to a local just before the wait.
 

Leazy

You can change this now in User CP.
Reaction score
50
Finally got it working :D Thanks a lot for all the support guys!
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • 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
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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