HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Handle Vars and GroupEnumUnitsInRangeOfLoc

12-10-2007, 08:34 PM#1
WNxCryptic
First: I have a timer which uses handles to pass a location to an evaluative function, but when I use the following code:

Collapse JASS:
local timer t = GetExpiredTimer()
local location l = GetHandleHandle(t, "l")

I get a compile error that says "Cannot convert handle to location", but I've checked through the GetHandleSomething functions, and there is no "GetHandleLocation" :(

Second: Part of that same function needs to group enemy units from around a location, so I have the following code:

Collapse JASS:
call GroupEnumUnitsInRangeOfLoc( g, l, 400, Condition(function Ensnare_EnemyUnit))

Ensnare_EnemyUnit is:

Collapse JASS:
return ( IsUnitEnemy(GetTriggerUnit(), Player(0)) == true )

I need to replace "GetTriggerUnit()" with something...what? and I need to replace "Player(0)" with "GetOwningPlayer(GetSpellAbilityUnit())" but that won't work since the Ensnare_EnemyUnit isn't within the scope of GetSpellAbilityUnit()
Any help?
12-10-2007, 08:36 PM#2
Av3n
Make an GetHandleLocation then just CnP GetHandleHandle rename it to GetHandleLocation and make sure it returns location
+ even though locations are handles... handles aren't locations

-Av3n
12-10-2007, 08:40 PM#3
WNxCryptic
Thanks, that solves my first problem, +Rep
12-10-2007, 08:47 PM#4
Av3n
its GetFilterUnit...

-Av3n
12-10-2007, 08:52 PM#5
moyack
Hmm... it seems you are using an incomplete Kattana's HandleVars, then you should create this function:
Collapse JASS:
function GetHandleLocation takes handle subject, string name returns location
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

For the second question: you must use GetFilterUnit() command

EDIT: Av3n won me :P
12-10-2007, 09:07 PM#6
WNxCryptic
Wait, so what does GetFilterUnit() reference, exactly? Does it reference the unit from the group to check the condition against, or does it check the original, casting unit?
12-10-2007, 09:17 PM#7
HINDYhat
It's the equivalent of 'Matching Unit' in the GUI.
12-10-2007, 09:46 PM#8
WNxCryptic
So is there anyway to reference the casting unit?
12-11-2007, 01:37 AM#9
Pyrogasm
GetTriggerUnit()
12-11-2007, 03:03 AM#10
Av3n
return ( IsUnitEnemy(GetTriggerUnit(), Player(0)) == true )
For your needs... Well you'll want to set up this up before grouping your units
Collapse JASS:
set bj_groupEnumOwningPlayer = GetOwningPlayer(GetSpellAbilityUnit)
set bj_ghoul[100] = GetSpellAbilityUnit
then you cond ahould be like this: return ( IsUnitEnemy(GetFilterUnit(), bj_groupEnumOwningPlayer) == true )
Now to reference to the casting unit... You'll have to code your group function(First of Group, ForGroup etc.) to check if bj_ghoul[100] is your casting unit.

This isn't a good way to do it... Well it is for me. Learn how to abuse Blizzard.j globals

-Av3n