(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Resources > JASS Functions

JASS Functions Approved JASS functions will be located here.
Remember to submit your own resources to the submission forum.

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 06-10-2007, 12:59 AM   #1 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Locust Enumerator (group) functions

Less efficient than normal grouping functions, significantly, but...

-GroupEnumLocusts... functions ONLY pick up locusts
-GroupEnum...Ex functions pick up locusts and normal
-GroupEnumNormal... functions ONLY pick up non-locusts. (For GroupEnumUnitsOfPlayer and GroupEnumUnitsOfType)

Improvement suggestions and such are appreciated.



Note: If you do not use JassNewGenPack or another preprocessor that allows for free global declaration, remove the first three lines and make a global Unit Group variable called enumGrp

globals
    group udg_enumGrp = CreateGroup()
endglobals

function LocustEnumerators_AntiLeak takes nothing returns boolean
    return true
endfunction

function GroupEnumLocustsInRange takes group g, real x, real y, real radius, boolexpr filter returns nothing
    local integer i = 0
    local unit u
    if filter == null then
        set filter = Filter( function LocustEnumerators_AntiLeak )
    endif
    loop
        exitwhen i > 11
        call GroupEnumUnitsOfPlayer( udg_enumGrp, Player( i ), filter )
loop
            set u = FirstOfGroup(udg_enumGrp)
            exitwhen u == null
            if IsUnitInRangeXY( u, x, y, radius ) and GetUnitAbilityLevel(u,'Aloc') > 0 then
                call GroupAddUnit( g, u )
            endif
            call GroupRemoveUnit(udg_enumGrp,u)
        endloop
        set i = i + 1
    endloop
endfunction

function GroupEnumUnitsInRangeEx takes group g, real x, real y, real radius, boolexpr filter returns nothing
    local integer i = 0
    local unit u
    if filter == null then
        set filter = Filter( function LocustEnumerators_AntiLeak )
    endif
    loop
        exitwhen i > 11
        call GroupEnumUnitsOfPlayer( udg_enumGrp, Player( i ), filter )
loop
            set u = FirstOfGroup(udg_enumGrp)
            exitwhen u == null
            if IsUnitInRangeXY( u, x, y, radius ) then
                call GroupAddUnit( g, u )
            endif
            call GroupRemoveUnit(udg_enumGrp,u)
        endloop
        set i = i + 1
    endloop
endfunction

function GroupEnumLocustsInRect takes group g, rect r, boolexpr filter returns nothing
    local integer i = 0
    local unit u
    local region re = CreateRegion()
    call RegionAddRect( re, r )
    if filter == null then
        set filter = Filter( function LocustEnumerators_AntiLeak )
    endif
    loop
        exitwhen i > 11
        call GroupEnumUnitsOfPlayer( udg_enumGrp, Player( i ), filter )
        loop
            set u = FirstOfGroup(udg_enumGrp)
            exitwhen u == null
if GetUnitAbilityLevel( u, 'Aloc' ) > 0 and IsUnitInRegion( re, u ) then
                call GroupAddUnit( g, u )
            endif
            call GroupRemoveUnit(udg_enumGrp,u)
        endloop
        set i = i + 1
    endloop
    call RegionClearRect( re, r )
    call RemoveRegion( re )
    set re = null
endfunction

function GroupEnumUnitsInRectEx takes group g, rect r, boolexpr filter returns nothing
    local integer i = 0
    local unit u
    local region re = CreateRegion()
    call RegionAddRect( re, r )
    if filter == null then
        set filter = Filter( function LocustEnumerators_AntiLeak )
    endif
    loop
        exitwhen i > 11
        call GroupEnumUnitsOfPlayer( udg_enumGrp, Player( i ), filter )
        loop
            set u = FirstOfGroup(udg_enumGrp)
            exitwhen u == null
if IsUnitInRegion( re, u ) then
                call GroupAddUnit( g, u )
            endif
            call GroupRemoveUnit(udg_enumGrp,u)
        endloop
        set i = i + 1
    endloop
    call RegionClearRect( re, r )
    call RemoveRegion( re )
    set re = null
endfunction

function GroupEnumNormalUnitsOfPlayer takes group g, player p, boolexpr filter returns nothing
    local unit u
    if filter == null then
        set filter = Filter( function LocustEnumerators_AntiLeak )
endif
    call GroupEnumUnitsOfPlayer( udg_enumGrp, p, filter )
    loop
        set u = FirstOfGroup( udg_enumGrp )
        exitwhen u == null
        if GetUnitAbilityLevel( u, 'Aloc' ) == 0 then
            call GroupAddUnit( g, u )
        endif
        call GroupRemoveUnit( udg_enumGrp, u )
    endloop
endfunction

function GroupEnumNormalUnitsOfType takes group g, string unitName, boolexpr filter returns nothing
    local unit u
    if filter == null then
        set filter = Filter( function LocustEnumerators_AntiLeak )
    endif
    call GroupEnumUnitsOfType( udg_enumGrp, unitName, filter )
    loop
        set u = FirstOfGroup( udg_enumGrp )
        exitwhen u == null
        if GetUnitAbilityLevel( u, 'Aloc' ) == 0 then
            call GroupAddUnit( g, u )
        endif
        call GroupRemoveUnit( udg_enumGrp, u )
    endloop
endfunction

Last edited by PurplePoot; 08-31-2008 at 09:29 PM.. Reason: Detatched signature
PurplePoot is offline  
Old 06-11-2007, 10:45 AM   #2 (permalink)
Owner
 
Ralle's Avatar

WoW! StarCraft II
 
Join Date: Oct 2004
Posts: 6,116

Ralle has disabled reputation (1523)Ralle has disabled reputation (1523)Ralle has disabled reputation (1523)Ralle has disabled reputation (1523)


I am still new to JASS.
Aren't there already functions to do these things?
I think I have seen them in the triggers.
__________________
Info:
Ralle'sSigna-ture
Todo ListPM MeNews
Progress:
New Section
||||||||||
Ralle is offline  
Old 06-11-2007, 12:29 PM   #3 (permalink)
 
Diablo-dk's Avatar

Shifting voidwalker!
 
Join Date: Nov 2004
Posts: 396

Diablo-dk has a spectacular aura about (129)Diablo-dk has a spectacular aura about (129)Diablo-dk has a spectacular aura about (129)Diablo-dk has a spectacular aura about (129)


These are made for enumerating units with the locust ability("Aloc") Since There's some bugs with some group enum functions or something..I've heard many times that group enum functions doesn't pick up locust units or that they only sometimes picks them up.
__________________
Need an easy Recipe System for your map?
Wonder what is inside the Spellbook?
Check my Cinematic!

Vote for the hive, the most friendly wc3 website.
Diablo-dk is offline  
Old 06-11-2007, 09:42 PM   #4 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

The only enum functions that pick up locusts are GroupEnumUnitsOfPlayer and GroupEnumUnitsOfType, which is why I made these.
PurplePoot is offline  
Old 06-12-2007, 11:25 PM   #5 (permalink)
Owner
 
Ralle's Avatar

WoW! StarCraft II
 
Join Date: Oct 2004
Posts: 6,116

Ralle has disabled reputation (1523)Ralle has disabled reputation (1523)Ralle has disabled reputation (1523)Ralle has disabled reputation (1523)


~approved~
__________________
Info:
Ralle'sSigna-ture
Todo ListPM MeNews
Progress:
New Section
||||||||||
Ralle is offline  
Old 08-16-2007, 04:22 PM   #6 (permalink)

User
 
Join Date: Jul 2007
Posts: 10

ChosenCheese is an unknown quantity at this point (0)


How do you put these things into gui?
ChosenCheese is offline  
Old 08-16-2007, 10:13 PM   #7 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Put them in the map's "Custom Script Section" (click on the map's picture in the trigger editor, and there's an area to place script)

Then, when you want to use them...

Let's say you have a group called

MyGroup

and a point called

MyLoc

then...

Custom script: call GroupEnum<rest of function name>(params)

Eg:

Custom script: call GroupEnumLocustsInRange( udg_MyGroup, GetLocationX( udg_MyLoc ), GetLocationY( udg_MyLoc ), 500, null )

Where 500 would be the range, and null the filter.

Then, you would do

Unit Group - Pick Every Unit in MyGroup and do actions

Adding filters in GUI is a little tricky (basically impossible without JASS knowledge), so I'd suggest you skip that out and use an if-statement to filter within the group loop instead.
PurplePoot is offline  
Old 10-01-2007, 03:04 AM   #8 (permalink)
 
PandaMine's Avatar

User
 
Join Date: Sep 2007
Posts: 58

PandaMine has little to show at this moment (24)PandaMine has little to show at this moment (24)PandaMine has little to show at this moment (24)


I was also under the impression that locust units could not be picked up in unit groups, guess I was wrong with GroupEnumUnitsOfPlayer and GroupEnumUnitsOfType.

I remember once I accidentally picked up projectile attacks from ranged units when making a spell, however I lost the spell and I couldn't manage to recreate what happened. I guess that means that ranged attacks could possibly be units with locust

If you want to make the functions more efficient you can use ForGroup function which is proven to be faster then using a loop, however then you would need to pass variables over through globals
PandaMine is offline  
Old 10-01-2007, 03:20 AM   #9 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Yeah, I'd rather keep this un-vjassed - I doubt it makes very much of a difference, either way.

I'll probably look over them in a bit, I wrote these half a year or so ago.

Maybe I'll make a faster vJassed alternative version...

Ignitor, as for your <deleted> comment, if you're still wondering about it, the GroupEnumUnitsInRange/Rect functions don't pick up locust units, so that wouldn't work =/
PurplePoot is offline  
Old 10-01-2007, 08:56 PM   #10 (permalink)

User
 
Join Date: Sep 2007
Posts: 4

Ignitor is an unknown quantity at this point (0)


yeah! realized that right after posting my comment!
Ignitor is offline  
Old 10-12-2007, 01:10 AM   #11 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Updated; optimized as much as I could think of doing at the moment.

If you don't use vJass, just create a variable called enumGrp (group) which is initialized as CreateGroup().

I also removed the ...Counted funcs, they're sorta pointless.
PurplePoot is offline  
Old 12-20-2007, 02:25 AM   #12 (permalink)
 
Herman's Avatar

Me in a few words???
 
Join Date: Aug 2007
Posts: 949

Herman has little to show at this moment (40)Herman has little to show at this moment (40)Herman has little to show at this moment (40)Herman has little to show at this moment (40)Herman has little to show at this moment (40)


Hmmm

Yeah when I first started with movement triggers in GUI I noticed something along the lines of bugging with locust units

But, I haven't noticed that in a while, strange

I might use this anyway

By the way, you can set a new unit group, and set it to the units you would like to remove, and then remove said group from the locust group

That would be using boolexprs in GUI, although I'm not sure which is more efficient, using the If/Thens, or the secondary unit group (of course var + leak removal, goes w/o saying)
Herman is offline  
Old 12-20-2007, 08:44 PM   #13 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

GroupRemoveGroup has to loop through the other group anyways, so it wouldn't be great.
PurplePoot is offline  
Old 12-20-2007, 08:54 PM   #14 (permalink)
 
Herman's Avatar

Me in a few words???
 
Join Date: Aug 2007
Posts: 949

Herman has little to show at this moment (40)Herman has little to show at this moment (40)Herman has little to show at this moment (40)Herman has little to show at this moment (40)Herman has little to show at this moment (40)


Oh

Heh, I didn't know that

Hmmm, you could definitely use the GroupRemoveGroup for groups in movement trigs, where you only set the group once, and it loops extremely often, in that case an If/Then would take off quite a bit more than the GroupRemoveGroup

Yeah, I think I could use this for a certain map I made a while ago

When you do GroupEnum's in GUI, which ones enum locusts, and which don't???
Herman is offline  
Old 12-21-2007, 03:48 AM   #15 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Units of Player enums locusts, no others do.
PurplePoot is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add a locust to a unit group? Kamikazzee World Editor Help Zone 3 03-08-2008 06:46 PM
Locust + Orbs Black-Templar World Editor Help Zone 5 04-27-2007 07:21 PM
Locust ChrisLee World Editor Help Zone 20 03-20-2007 04:21 PM