|
 |   |  |  |
JASS Functions Approved JASS functions will be located here.
Remember to submit your own resources to the submission forum. |
 |
|
06-10-2007, 12:59 AM
|
#1 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
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 ()endglobalsfunction LocustEnumerators_AntiLeak takes nothing returns boolean return trueendfunctionfunction 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 endloopendfunctionfunction 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 endloopendfunctionfunction 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 = nullendfunctionfunction 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 = nullendfunctionfunction 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 ) endloopendfunctionfunction 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 ) endloopendfunction
Last edited by PurplePoot; 08-31-2008 at 09:29 PM..
Reason: Detatched signature
|
|
|
06-11-2007, 10:45 AM
|
#2 (permalink)
|
Owner
WoW! StarCraft II
Join Date: Oct 2004
Posts: 6,116
|
I am still new to JASS.
Aren't there already functions to do these things?
I think I have seen them in the triggers.
|
|
|
06-11-2007, 12:29 PM
|
#3 (permalink)
|
Shifting voidwalker!
Join Date: Nov 2004
Posts: 396
|
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.
|
|
|
06-11-2007, 09:42 PM
|
#4 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
The only enum functions that pick up locusts are GroupEnumUnitsOfPlayer and GroupEnumUnitsOfType, which is why I made these.
|
|
|
06-12-2007, 11:25 PM
|
#5 (permalink)
|
Owner
WoW! StarCraft II
Join Date: Oct 2004
Posts: 6,116
|
|
|
|
08-16-2007, 04:22 PM
|
#6 (permalink)
|
User
Join Date: Jul 2007
Posts: 10
|
How do you put these things into gui?
|
|
|
08-16-2007, 10:13 PM
|
#7 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
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.
|
|
|
10-01-2007, 03:04 AM
|
#8 (permalink)
|
User
Join Date: Sep 2007
Posts: 58
|
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
|
|
|
10-01-2007, 03:20 AM
|
#9 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
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 =/
|
|
|
10-01-2007, 08:56 PM
|
#10 (permalink)
|
User
Join Date: Sep 2007
Posts: 4
|
yeah! realized that right after posting my comment! 
|
|
|
10-12-2007, 01:10 AM
|
#11 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
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.
|
|
|
12-20-2007, 02:25 AM
|
#12 (permalink)
|
Me in a few words???
Join Date: Aug 2007
Posts: 949
|
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)
|
|
|
12-20-2007, 08:44 PM
|
#13 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
GroupRemoveGroup has to loop through the other group anyways, so it wouldn't be great.
|
|
|
12-20-2007, 08:54 PM
|
#14 (permalink)
|
Me in a few words???
Join Date: Aug 2007
Posts: 949
|
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???
|
|
|
12-21-2007, 03:48 AM
|
#15 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
Units of Player enums locusts, no others do.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
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 |
|
| |
|
|