adding units that match conditions into group

W!†A_cRaft

Ultra Cool Member
Reaction score
28
I am roughly new to JASS and i wandered into this problem.

I need to pick every enemy, alive, non-building, non-dummy unit within 200 range around the caster (or dummy to be precise)

The function GetUnitsInRangeOfLocMatching doesnt allow me to put parameters into the matching function and i cannot check wheather the picked unit matches the above mentioned conditios. how should i do this?

I am making a spell that picks units around certain point every few seconds. Made it with a timer to which i bound the caster/dummy/damage/etc.
But it is suppose to damage only enemies and i cannot pick only enemies, how am i suppose to do that?
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
While trying to figgure this out i managed to find out that every time my timer picks units around me (0.03) seconds he picks the dummy (caster) as well as any other friendly units, i managed to get around the part when he ignores them with a loop liek this, but I think it still causes too much stress for RAM because units get picked every tiem even though they arent affected.

JASS:
local group temp = GetUnitsInRangeOfLocAll(140, GetUnitLoc(arrow))
set target = FirstOfGroup(temp)
    loop
        exitwhen (target == null)
        if(not(IsUnitEnemy(target, GetOwningPlayer(u)))) then
        else
            if(IsUnitDeadBJ(target)) then
            else
                call GroupAddUnit(grp, target)
            endif
        endif
    call GroupRemoveUnit(temp, target)
    set target = FirstOfGroup(temp)
    call BJDebugMsg("u loopu")
    endloop
    set target = FirstOfGroup(grp)
    if (target != null) then
//Ability code goes here
    endif


Is ther some better way to do this?
 

Flare

Stops copies me!
Reaction score
662
Global variable + GroupEnumUnitsInRange

JASS:
function GroupCallback takes nothing returns nothing
  ...
endfunction

function GroupFilter takes nothing returns boolean
  return IsUnitEnemy (GetFilterUnit (), GetOwningPlayer (udg_refUnit)) and ...
  //Alternatively, depending on how you plan to use the enumerated units, you may handle all the units in this function, without ever adding them to the group - removes the necessity for the ForGroup call, but it's not possible to do in EVERY situation
endfunction

function Test takes nothing returns nothing
  local group g = CreateGroup ()
  set udg_refUnit = GetTriggerUnit () //Since we need a global variable to reference in the filter function - if you have NewGen, just declare a globals block instead of using a Variable Editor global <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />
  call GroupEnumUnitsInRange (g, GetUnitX (unit), GetUnitY (unit), radius, Condition (function GroupFilter)) //replace the &#039;unit&#039; value for GetUnitX/Y with your desired unit, and &#039;radius&#039; with your desired radius

  call ForGroup (g, function GroupCallback)
endfunction


Assuming you don't have NewGen - if you do, that udg_ global can be replaced with a globals block if you so wish.
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
if i use a global it is no longer MUI

Edit: what BJ's? the DebugMessage?
I do have NewGen but i dont know how exactly to reference a global block, and what is the difference between doing it like that and with variable editor?
 

saw792

Is known to say things. That is all.
Reaction score
280
>If I use a global it is no longer MUI
You don't understand how MUI works.
The global variable stores data for an instantaneous action, not a time delayed action, so it will not be overwritten.

The BJs you are using are the ones that show up in red text in the jass tags on thehelper. BJDebugMsgs are fine when used for debugging so don't remove those if you want to debug your script.

Globals blocks are declared with
JASS:
globals
...
endglobals


Read a vJASS tutorial, you sound like you need it.
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
when i said what BJ's i was being sarcastic because i am using them for debugging purposes of course....
The global variable stores data for an instantaneous action, not a time delayed action, so it will not be overwritten.[/qoute]

even if too units use the ability at same exact time (not that it is likly to happen but)??

is there any difference between the global block and regular global variables made throguh the editor
 
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
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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